From 8db0c10e59a85137f1cbe55536acc988f645d4c3 Mon Sep 17 00:00:00 2001 From: FanLian Date: Thu, 10 Aug 2023 11:13:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AF=BC=E5=85=A5=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LocationDefinitionService.cs | 38 +++++++++++-------- .../Tnb.WarehouseMgr/WmsCarryLedgerService.cs | 11 +++--- .../Tnb.WarehouseMgr/WmsPointService.cs | 1 - .../Tnb.WarehouseMgr/WmsRouteMgrService.cs | 4 -- 4 files changed, 29 insertions(+), 25 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/LocationDefinitionService.cs b/WarehouseMgr/Tnb.WarehouseMgr/LocationDefinitionService.cs index 4801470e..cf3716f8 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/LocationDefinitionService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/LocationDefinitionService.cs @@ -49,7 +49,17 @@ namespace Tnb.WarehouseMgr foreach (var d in dics) { var LCode = d["location_code"].ToString() ?? string.Empty; - if (LCode == string.Empty) throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据起始点位编号不可为空", 500); + if (LCode == string.Empty) throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据库位编号不可为空", 500); + var isType = d["is_type"].ToString() ?? string.Empty; + if (isType == string.Empty) throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据库位类型不可为空", 500); + var floor = d["floor"].ToString() ?? string.Empty; + if (floor == string.Empty) throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据楼层不可为空", 500); + var layers = d["layers"].ToString() ?? string.Empty; + var locLine = d["loc_line"].ToString() ?? string.Empty; + var locColumn = d["loc_column"].ToString() ?? string.Empty; + if (locLine == string.Empty || locColumn == string.Empty || layers == string.Empty) throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据行列层不可为空", 500); + var isSign = d["is_sign"].ToString() ?? string.Empty; + if(isSign==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; @@ -58,21 +68,19 @@ namespace Tnb.WarehouseMgr locs.Add(loc); } 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 => { - locs.ForEach(x => - { - 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.create_id = _userManager.UserId; - x.modify_id = null; - x.modify_time = null; - x.is_mix = 1; - }); - } + 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.create_id = _userManager.UserId; + x.modify_id = null; + x.modify_time = null; + x.is_mix = 1; + }); + row = await _db.Insertable(locs).ExecuteCommandAsync(); } catch (Exception ex) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryLedgerService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryLedgerService.cs index ead8cf04..7a455402 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryLedgerService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryLedgerService.cs @@ -61,6 +61,7 @@ namespace Tnb.WarehouseMgr { List> dics = input.list; List carrys = new List(); + Dictionary? locs = null; List locCodes = new(); List cStdCodes = new(); WmsCarryH carryH = new WmsCarryH(); @@ -68,8 +69,7 @@ namespace Tnb.WarehouseMgr foreach (var d in dics) { 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); + locCodes.Add(d["location_code"].ToString() ?? string.Empty); cStdCodes.Add(cStdCode); d["create_time"] = DateTime.Now; d.Remove("modify_time"); @@ -77,18 +77,19 @@ namespace Tnb.WarehouseMgr carrys.Add(carryH); } 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); + if (locCodes?.Count > 0) + 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); 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.carry_status = ((int)EnumCarryStatus.空闲).ToString(); - x.location_id = locs[x.location_code].ToString() ?? throw new AppFriendlyException($"第{carrys.IndexOf(x) + 1}个数据的库位编号有误", 500); + if (locs != null && x.location_code != null && x.location_code != string.Empty) + 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 d19f7bda..93cdfd12 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPointService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPointService.cs @@ -49,7 +49,6 @@ namespace Tnb.WarehouseMgr 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); aCodes.Add(aCode); d["create_time"] = DateTime.Now; diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsRouteMgrService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsRouteMgrService.cs index f76686fa..de6e2ae4 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsRouteMgrService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsRouteMgrService.cs @@ -83,10 +83,6 @@ namespace Tnb.WarehouseMgr 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 (dis.IsEmpty()) throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}个数据距离不可为空", 500); pointCodes.Add(sCode);