From a60fd76ff33445fe6096113b906aa3f68a84df30 Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 30 Jun 2023 09:54:57 +0800 Subject: [PATCH] =?UTF-8?q?=E9=BD=90=E5=A5=97=E5=87=BA=E5=BA=93=EF=BC=8C?= =?UTF-8?q?=E9=BD=90=E5=A5=97=E5=88=86=E6=8B=A3=EF=BC=8C=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E6=98=8E=E7=BB=86=E6=9D=A1=E7=A0=81=E8=A1=A8=EF=BC=8C=E5=86=8D?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=98=8E=E7=BB=86=EF=BC=8C=E6=9C=80=E5=90=8E?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=B8=BB=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entity/WmsKittingoutCode.cs | 12 +----- .../Entity/WmsKittingoutD.cs | 4 ++ .../Entity/WmsSetsortingCode.cs | 11 +---- .../Entity/WmsSetsortingD.cs | 4 ++ .../Tnb.WarehouseMgr/WmsOutStockService.cs | 4 +- .../Tnb.WarehouseMgr/WmsSetSortingService.cs | 40 +++++++++++++++++- .../Tnb.WarehouseMgr/WmskittingOutService.cs | 42 ++++++++++++++++++- 7 files changed, 91 insertions(+), 26 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsKittingoutCode.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsKittingoutCode.cs index 7124f6a4..b0b7be96 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsKittingoutCode.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsKittingoutCode.cs @@ -24,10 +24,6 @@ public partial class WmsKittingoutCode : BaseEntity /// public string bill_id { get; set; } = string.Empty; - /// - /// 行号 - /// - public int bill_line { get; set; } /// /// 物品ID @@ -62,7 +58,7 @@ public partial class WmsKittingoutCode : BaseEntity /// /// 条码数量 /// - public int barcode_qty { get; set; } + public decimal codeqty { get; set; } /// /// 备注 @@ -113,10 +109,4 @@ public partial class WmsKittingoutCode : BaseEntity /// 出库单明细ID /// public string bill_d_id { get; set; } = string.Empty; - - /// - /// 出库单明细行号 - /// - public int bill_d_line { get; set; } - } diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsKittingoutD.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsKittingoutD.cs index bc66a4e0..0eb5a142 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsKittingoutD.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsKittingoutD.cs @@ -109,5 +109,9 @@ public partial class WmsKittingoutD : BaseEntity /// 修改时间 /// public DateTime? modify_time { get; set; } + /// + /// 明细状态 + /// + public string line_status { get; set; } = string.Empty; } diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsSetsortingCode.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsSetsortingCode.cs index ffad91cd..c2f500c1 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsSetsortingCode.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsSetsortingCode.cs @@ -24,10 +24,6 @@ public partial class WmsSetsortingCode : BaseEntity /// public string bill_id { get; set; } = string.Empty; - /// - /// 行号 - /// - public int bill_line { get; set; } /// /// 物品ID @@ -62,7 +58,7 @@ public partial class WmsSetsortingCode : BaseEntity /// /// 条码数量 /// - public int barcode_qty { get; set; } + public int codeqty { get; set; } /// /// 备注 @@ -104,9 +100,4 @@ public partial class WmsSetsortingCode : BaseEntity /// public string bill_d_id { get; set; } = string.Empty; - /// - /// 出库单明细行号 - /// - public int bill_d_line { get; set; } - } diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsSetsortingD.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsSetsortingD.cs index dc728335..4b45362e 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsSetsortingD.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsSetsortingD.cs @@ -98,5 +98,9 @@ public partial class WmsSetsortingD : BaseEntity /// 修改时间 /// public DateTime? modify_time { get; set; } + /// + /// 明细状态 + /// + public string line_status { get; set; } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs index bea1e56b..3c0f27d2 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs @@ -282,8 +282,8 @@ namespace Tnb.WarehouseMgr [HttpGet] public async Task Testxx() { - var carryCodePropNames = typeof(WmsDistaskCode).GetProperties().Select(p => p.Name); - var outStockCodePropNames = typeof(WmsOutstockCode).GetProperties().Select(p => p.Name); + var carryCodePropNames = typeof(WmsCarryCode).GetProperties().Select(p => p.Name); + var outStockCodePropNames = typeof(WmsSetsortingCode).GetProperties().Select(p => p.Name); var intersects = carryCodePropNames.Intersect(outStockCodePropNames).ToList(); var excepts = carryCodePropNames.Except(outStockCodePropNames).ToList(); var excepts2 = outStockCodePropNames.Except(carryCodePropNames).ToList(); diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs index eecf8edf..f8990c98 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs @@ -240,6 +240,44 @@ namespace Tnb.WarehouseMgr await _db.Ado.BeginTranAsync(); var carryId = input.carryIds[^input.carryIds.Count]; + var ssds = await _db.Queryable().Where(it => it.bill_id == input.requireId).ToListAsync(); + var carryCodes = await _db.Queryable().Where(it => it.carry_id == carryId).ToListAsync(); + + var sortingCoees = carryCodes.Adapt>(); + sortingCoees.ForEach(x => + { + var billDId = ssds?.Find(xx => xx.material_id == x.material_id && xx.code_batch == x.code_batch)?.id; + if (billDId.IsNullOrEmpty()) + { + billDId = ssds?.Find(xx => xx.material_id == x.material_id)?.id; + } + x.id = SnowflakeIdHelper.NextId(); + x.bill_id = input.requireId; + x.bill_d_id = billDId; + x.org_id = _userManager.User.OrganizeId; + x.create_id = _userManager.UserId; + x.create_time = DateTime.Now; + }); + await _db.Insertable(sortingCoees).ExecuteCommandAsync(); + var detailIds = sortingCoees.Select(x => x.bill_d_id).ToList(); + var curSortingDetails = ssds.FindAll(x => detailIds.Contains(x.id)); + var dic = sortingCoees.GroupBy(g => g.bill_d_id).ToDictionary(x => x.Key, x => x.Select(x => x.codeqty).ToList()); + foreach (var osd in curSortingDetails) + { + if (dic.ContainsKey(osd.id)) + { + osd.qty += dic[osd.id].Sum(d => d); + if (osd.qty >= osd.pr_qty) + { + osd.line_status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID; + } + else + { + osd.line_status = WmsWareHouseConst.BILLSTATUS_ON_ID; + } + } + } + await _db.Updateable(curSortingDetails).ExecuteCommandAsync(); var carry = await _db.Queryable().SingleAsync(it => it.id == carryId); if (carry != null) { @@ -251,7 +289,7 @@ namespace Tnb.WarehouseMgr carry.carry_status = ((int)EnumCarryStatus.齐套).ToString(); carry.location_id = null; carry.location_code = null; - await _db.Updateable(carry).UpdateColumns(it => new { it.out_status,it.carry_status, it.location_id, it.location_code }).ExecuteCommandAsync(); + await _db.Updateable(carry).UpdateColumns(it => new { it.out_status, it.carry_status, it.location_id, it.location_code }).ExecuteCommandAsync(); await _db.Deleteable().Where(it => it.carry_id == carryId).ExecuteCommandAsync(); } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs index 2cadd38c..c1dd5be0 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs @@ -202,12 +202,50 @@ namespace Tnb.WarehouseMgr { await _db.Ado.BeginTranAsync(); - var isOk = await _db.Updateable().SetColumns(it => new WmsKittingoutH { status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID }).Where(it => it.id == input.requireId).ExecuteCommandHasChangeAsync(); var carryId = input.carryIds[^input.carryIds.Count]; + var kods = await _db.Queryable().Where(it => it.bill_id == input.requireId).ToListAsync(); + //当前载具对应的所有条码插入 + var carryCodes = await _db.Queryable().Where(it => it.carry_id == carryId).ToListAsync(); + var kittingoutCodes = carryCodes.Adapt>(); + kittingoutCodes.ForEach(x => + { + var billDId = kods?.Find(xx => xx.material_id == x.material_id && xx.code_batch == x.code_batch)?.id; + if (billDId.IsNullOrEmpty()) + { + billDId = kods?.Find(xx => xx.material_id == x.material_id)?.id; + } + x.id = SnowflakeIdHelper.NextId(); + x.bill_id = input.requireId; + x.bill_d_id = billDId; + x.org_id = _userManager.User.OrganizeId; + x.create_id = _userManager.UserId; + x.create_time = DateTime.Now; + }); + var row = await _db.Insertable(kittingoutCodes).ExecuteCommandAsync(); + var detailIds = kittingoutCodes.Select(x => x.bill_d_id).ToList(); + var curKittingoutDetails = kods.FindAll(x => detailIds.Contains(x.id)); + var dic = kittingoutCodes.GroupBy(g => g.bill_d_id).ToDictionary(x => x.Key, x => x.Select(x => x.codeqty).ToList()); + foreach (var kod in curKittingoutDetails) + { + if (dic.ContainsKey(kod.id)) + { + kod.qty += dic[kod.id].Sum(d => d); + if (kod.qty >= kod.pr_qty) + { + kod.line_status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID; + } + else + { + kod.line_status = WmsWareHouseConst.BILLSTATUS_ON_ID; + } + } + } + await _db.Updateable(curKittingoutDetails).ExecuteCommandAsync(); + var isOk = await _db.Updateable().SetColumns(it => new WmsKittingoutH { status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID }).Where(it => it.id == input.requireId).ExecuteCommandHasChangeAsync(); var carry = await _db.Queryable().SingleAsync(it => it.id == carryId); if (carry != null) { - var row = await _carryService.UpdateNullCarry(carry); + row = await _carryService.UpdateNullCarry(carry); isOk = row > 0; } if (!isOk) throw Oops.Oh(ErrorCode.COM1001);