// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 // // 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 // // 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! using Admin.NET.Application.Entity; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Admin.NET.Application.CommonHelper; public class BaseInfoHelper { private readonly SqlSugarRepository _wmsContainerRep; private readonly SqlSugarRepository _wmsAreaRep; private readonly SqlSugarRepository _wmsPlaceRep; /// /// 根据库区号获取库区信息 /// /// /// /// public static async Task GetAreaByPlace(WmsBasePlace wmsPlace, SqlSugarRepository _wmsAreaRep) { var wmsArea = await _wmsAreaRep.GetFirstAsync(x => x.Id == wmsPlace.AreaId && x.IsDelete == false); //判断库区信息是否为空 if (wmsArea == null) { //抛出异常库区不存在 throw Oops.Oh($"库区{wmsPlace.AreaCode}不存在"); } if (wmsArea.IsDisabled) { //抛出异常库区已禁用 throw Oops.Oh($"库区{wmsArea.AreaCode}已禁用"); } return wmsArea; } /// /// 根据库位号获取库位信息 /// /// /// /// public static async Task GetPlace(string toPlaceCode, SqlSugarRepository _wmsPlaceRep) { var wmsPlace = await _wmsPlaceRep.GetFirstAsync(x => x.PlaceCode == toPlaceCode && x.IsDelete == false); //判断库位信息是否为空 if (wmsPlace == null) { //抛出异常库位不存在 throw Oops.Oh($"库位:{toPlaceCode}不存在"); } if (wmsPlace.IsDisabled) { //抛出异常库位已禁用 throw Oops.Oh($"库位:{toPlaceCode}已禁用"); } return wmsPlace; } /// /// 根据库位号获取库位信息 /// /// /// /// public static WmsBasePlace GetPlace(string toPlaceCode, List wmsBasePlaceList) { var wmsPlace = wmsBasePlaceList.FirstOrDefault(x => x.PlaceCode == toPlaceCode && x.IsDelete == false); //判断库位信息是否为空 if (wmsPlace == null) { //抛出异常库位不存在 throw Oops.Oh($"库位:{toPlaceCode}不存在"); } if (wmsPlace.IsDisabled) { //抛出异常库位已禁用 throw Oops.Oh($"库位:{toPlaceCode}已禁用"); } return wmsPlace; } /// /// 根据容器号获取库位信息 /// /// /// /// /// public static async Task GetPlaceByContinerCode(string containerCode, SqlSugarRepository _wmsBasePlaceRep, SqlSugarRepository _wmsContainerPlaceRep) { var containerPlace = await _wmsContainerPlaceRep.GetFirstAsync(u => u.ContainerCode == containerCode); if (containerPlace == null) { throw Oops.Oh($"根据容器号{containerCode}没有找到容器库位绑定关系"); } var place = await _wmsBasePlaceRep.GetFirstAsync(u => u.PlaceCode == containerPlace.PlaceCode); if (place == null) { throw Oops.Oh($"根据库位号{containerPlace.PlaceCode}没有找到库位信息"); } return place; } /// /// 根据容器号获取容器信息 /// /// /// /// public static async Task GetContainer(string toContainer, SqlSugarRepository _wmsContainerRep) { var wmsContainer = await _wmsContainerRep.GetFirstAsync(x => x.ContainerCode == toContainer && x.IsDelete == false); //判断容器信息是否为空 if (wmsContainer == null) { //抛出异常容器不存在 throw Oops.Oh($"容器{toContainer}不存在"); } if (wmsContainer.IsDisabled) { //抛出异常容器已禁用 throw Oops.Oh($"容器{toContainer}已禁用"); } return wmsContainer; } /// /// 根据仓库号获取容器信息 /// /// /// /// public static async Task GetWarehouse(string toWarehouse, SqlSugarRepository _wmsWmsWarehouseRep) { var wmsContainer = await _wmsWmsWarehouseRep.GetFirstAsync(x => x.Code == toWarehouse && x.IsDelete == false); //判断容器信息是否为空 if (wmsContainer == null) { //抛出异常容器不存在 throw Oops.Oh($"仓库{toWarehouse}不存在"); } if (wmsContainer.IsDisabled) { //抛出异常容器已禁用 throw Oops.Oh($"仓库{toWarehouse}已禁用"); } return wmsContainer; } }