diff --git a/WarehouseMgr/Tnb.WarehouseMgr/LocationDefinitionService.cs b/WarehouseMgr/Tnb.WarehouseMgr/LocationDefinitionService.cs index d5d00c30..4801470e 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/LocationDefinitionService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/LocationDefinitionService.cs @@ -21,6 +21,9 @@ using NPOI.SS.Formula.Functions; namespace Tnb.WarehouseMgr { + /// + /// 库位定义业务类 + /// [OverideVisualDev(ModuleConsts.MODULE_LOCATIONDEFINITION_ID)] public class LocationDefinitionService : BaseWareHouseService { @@ -41,27 +44,29 @@ namespace Tnb.WarehouseMgr List> dics = input.list; List locs = new List(); BasLocation loc = new BasLocation(); - List cCodes = new List(); + List cStdCodes = new List(); + //遍历字典,找出需要查询数据库拿的相关字段 foreach (var d in dics) { - var cCode = d["carrystd_id"].ToString() ?? string.Empty; - if (cCode == string.Empty) throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}行载具规格不可为空", 500); - cCodes.Add(cCode); + var LCode = d["location_code"].ToString() ?? string.Empty; + if (LCode == string.Empty) throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据起始点位编号不可为空", 500); + var cStdCode = d["carrystd_id"].ToString() ?? string.Empty; + cStdCodes.Add(cStdCode); d["create_time"] = DateTime.Now; d.Remove("modify_time"); loc = d.Adapt(); locs.Add(loc); } - var carryStdDic = await _db.Queryable().Where(it => cCodes.Contains(it.carrystd_code)).ToDictionaryAsync(x => x.carrystd_code, x => x.id); + var carryStdDic = await _db.Queryable().Where(it => cStdCodes.Contains(it.carrystd_code)).ToDictionaryAsync(x => x.carrystd_code, x => x.id); if (carryStdDic?.Count > 0) { locs.ForEach(x => { - if (!carryStdDic.Keys.Contains(x.carrystd_id)) throw new AppFriendlyException($"第{locs.IndexOf(x) + 1}行的载具规格有误", 500); + if (!carryStdDic.Keys.Contains(x.carrystd_id)) throw new AppFriendlyException($"第{locs.IndexOf(x) + 1}个数据的载具规格有误", 500); x.id = SnowflakeIdHelper.NextId(); x.org_id = _userManager.User.OrganizeId; x.is_lock = 0; - x.carrystd_id = carryStdDic[x.carrystd_id].ToString() ?? throw new AppFriendlyException($"第{locs.IndexOf(x) + 1}行的载具规格有误", 500); + x.carrystd_id = carryStdDic[x.carrystd_id].ToString() ?? throw new AppFriendlyException($"第{locs.IndexOf(x) + 1}个数据的载具规格有误", 500); x.create_id = _userManager.UserId; x.modify_id = null; x.modify_time = null; diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryLedgerService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryLedgerService.cs index ce70c0a6..ead8cf04 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryLedgerService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryLedgerService.cs @@ -62,32 +62,33 @@ namespace Tnb.WarehouseMgr List> dics = input.list; List carrys = new List(); List locCodes = new(); - List cCodes = new(); + List cStdCodes = new(); WmsCarryH carryH = new WmsCarryH(); + //遍历字典,找出需要查询数据库拿的相关字段 foreach (var d in dics) { - var cCode = d["carrystd_id"].ToString() ?? string.Empty; - if (cCode == string.Empty) throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}行载具规格不可为空", 500); + var cStdCode = d["carrystd_id"].ToString() ?? string.Empty; + //if (cStdCode == string.Empty) throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据载具规格不可为空", 500); locCodes.Add(d["location_code"]?.ToString() ?? string.Empty); - cCodes.Add(cCode); + cStdCodes.Add(cStdCode); d["create_time"] = DateTime.Now; d.Remove("modify_time"); carryH = d.Adapt(); carrys.Add(carryH); } - var carryStdDic = await _db.Queryable().Where(it => cCodes.Contains(it.carrystd_code)).ToDictionaryAsync(x => x.carrystd_code, x => x.id); + var carryStdDic = await _db.Queryable().Where(it => cStdCodes.Contains(it.carrystd_code)).ToDictionaryAsync(x => x.carrystd_code, x => x.id); var locs = await _db.Queryable().Where(it => locCodes.Contains(it.location_code)).ToDictionaryAsync(x => x.location_code, x => x.id); carrys.ForEach(x => { - if (!carryStdDic.Keys.Contains(x.carrystd_id)) throw new AppFriendlyException($"第{carrys.IndexOf(x) + 1}行的载具规格有误", 500); - if (!locs.Keys.Contains(x.location_code)) throw new AppFriendlyException($"第{carrys.IndexOf(x) + 1}行的库位编号有误", 500); + if (!carryStdDic.Keys.Contains(x.carrystd_id)) throw new AppFriendlyException($"第{carrys.IndexOf(x) + 1}个数据的载具规格有误", 500); + if (!locs.Keys.Contains(x.location_code)) throw new AppFriendlyException($"第{carrys.IndexOf(x) + 1}个数据的库位编号有误", 500); x.id = SnowflakeIdHelper.NextId(); x.org_id = _userManager.User.OrganizeId; x.status = 1; x.is_lock = 0; - x.carrystd_id = carryStdDic[x.carrystd_id].ToString() ?? throw new AppFriendlyException($"第{carrys.IndexOf(x) + 1}行的载具规格有误", 500); + x.carrystd_id = carryStdDic[x.carrystd_id].ToString() ?? throw new AppFriendlyException($"第{carrys.IndexOf(x) + 1}个数据的载具规格有误", 500); x.carry_status = ((int)EnumCarryStatus.空闲).ToString(); - x.location_id = locs[x.location_code].ToString() ?? throw new AppFriendlyException($"第{carrys.IndexOf(x) + 1}行的库位编号有误", 500); + x.location_id = locs[x.location_code].ToString() ?? throw new AppFriendlyException($"第{carrys.IndexOf(x) + 1}个数据的库位编号有误", 500); x.out_status = ((int)EnumOutStatus.正常).ToString(); x.is_check = 1; x.create_id = _userManager.UserId; diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPointService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPointService.cs index 99f216b0..d19f7bda 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPointService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPointService.cs @@ -16,6 +16,9 @@ using Tnb.WarehouseMgr.Entities; namespace Tnb.WarehouseMgr { + /// + /// 点位管理业务类 + /// [OverideVisualDev(ModuleConsts.MODULE_WMSPOINT_ID)] public class WmsPointService : BaseWareHouseService { @@ -37,16 +40,17 @@ namespace Tnb.WarehouseMgr List points = new List(); WmsPointH pt = new WmsPointH(); List aCodes = new List(); + //遍历字典,找出需要查询数据库拿的相关字段 foreach (var d in dics) { var pCode = d["point_code"].ToString() ?? string.Empty; var pName = d["point_name"].ToString() ?? string.Empty; var aCode = d["area_code"].ToString() ?? string.Empty; var floor = d["floor"].ToString() ?? string.Empty; - if (pCode == string.Empty) throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}行点位编号不可为空", 500); - if (pName == string.Empty) throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}行点位名称不可为空", 500); - if (aCode == string.Empty) throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}行管理区编号不可为空", 500); - if (floor == string.Empty) throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}行楼层不可为空", 500); + if (pCode == string.Empty) throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据点位编号不可为空", 500); + if (pName == string.Empty) throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据点位名称不可为空", 500); + //if (aCode == string.Empty) throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据管理区编号不可为空", 500); + if (floor == string.Empty) throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据楼层不可为空", 500); aCodes.Add(aCode); d["create_time"] = DateTime.Now; d.Remove("modify_time"); @@ -56,7 +60,7 @@ namespace Tnb.WarehouseMgr var areas = await _db.Queryable().Where(it => aCodes.Contains(it.code)).ToDictionaryAsync(x => x.code, x => x.id); points.ForEach(x => { - if (!areas.Keys.Contains(x.area_code)) throw new AppFriendlyException($"第{points.IndexOf(x) + 1}行的管理区编号有误", 500); + if (!areas.Keys.Contains(x.area_code)) throw new AppFriendlyException($"第{points.IndexOf(x) + 1}个数据的管理区编号有误", 500); x.id = SnowflakeIdHelper.NextId(); x.org_id = _userManager.User.OrganizeId; x.is_lock = 0; @@ -64,7 +68,7 @@ namespace Tnb.WarehouseMgr x.point_x = 0; x.point_y = 0; x.point_z = 0; - x.area_id = areas[x.area_code].ToString() ?? throw new AppFriendlyException($"第{points.IndexOf(x) + 1}行的管理区编号编号有误", 500); + x.area_id = areas[x.area_code].ToString() ?? throw new AppFriendlyException($"第{points.IndexOf(x) + 1}个数据的管理区编号编号有误", 500); x.create_id = _userManager.UserId; x.modify_id = null; x.modify_time = null; diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsRouteMgrService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsRouteMgrService.cs index a6cb1af8..f76686fa 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsRouteMgrService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsRouteMgrService.cs @@ -76,18 +76,19 @@ namespace Tnb.WarehouseMgr List pointCodes = new List(); List locCodes = new(); WmsRoad road = new WmsRoad(); + //遍历字典,找出需要查询数据库拿的相关字段 foreach (var d in dics) { var sCode = d["startpoint_code"].ToString() ?? string.Empty; var eCode = d["endpoint_code"].ToString() ?? string.Empty; var dis = d["distance"].ToString() ?? string.Empty; if(sCode == eCode) throw new AppFriendlyException("起始点位不能等于终止点位", 500); - if (sCode.IsEmpty()) - throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}行起始点位编号不可为空", 500); - if (eCode.IsEmpty()) - throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}行终止点位编号不可为空", 500); + //if (sCode.IsEmpty()) + // throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据数据起始点位编号不可为空", 500); + //if (eCode.IsEmpty()) + // throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据终止点位编号不可为空", 500); if (dis.IsEmpty()) - throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}行距离不可为空", 500); + throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据距离不可为空", 500); pointCodes.Add(sCode); pointCodes.Add(eCode); d["create_time"] = DateTime.Now; @@ -100,12 +101,12 @@ namespace Tnb.WarehouseMgr { roads.ForEach(x => { - if (!points.Keys.Contains(x.startpoint_code) ) throw new AppFriendlyException($"第{roads.IndexOf(x) + 1}行的起始点位编号有误", 500); - if (!points.Keys.Contains(x.endpoint_code)) throw new AppFriendlyException($"第{roads.IndexOf(x) + 1}行的终止点位编号有误", 500); + if (!points.Keys.Contains(x.startpoint_code) ) throw new AppFriendlyException($"第{roads.IndexOf(x) + 1}个数据的起始点位编号有误", 500); + if (!points.Keys.Contains(x.endpoint_code)) throw new AppFriendlyException($"第{roads.IndexOf(x) + 1}个数据的终止点位编号有误", 500); x.id = SnowflakeIdHelper.NextId(); x.org_id = _userManager.User.OrganizeId; - x.startpoint_id = points[x.startpoint_code].ToString() ?? throw new AppFriendlyException($"第{roads.IndexOf(x) + 1}行的起始点位编号有误", 500); - x.endpoint_id = points[x.endpoint_code].ToString() ?? throw new AppFriendlyException($"第{roads.IndexOf(x) + 1}行的终止点位编号有误", 500); + x.startpoint_id = points[x.startpoint_code].ToString() ?? throw new AppFriendlyException($"第{roads.IndexOf(x) + 1}个数据的起始点位编号有误", 500); + x.endpoint_id = points[x.endpoint_code].ToString() ?? throw new AppFriendlyException($"第{roads.IndexOf(x) + 1}个数据的终止点位编号有误", 500); x.road_code = $"{x.startpoint_code}-{x.endpoint_code}"; x.status = 1; x.create_id = _userManager.UserId;