From 038a234d9ad1ed7e86e67491ec363452f3304ff0 Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 27 Jun 2023 17:54:34 +0800 Subject: [PATCH 01/12] =?UTF-8?q?=E6=94=B9bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryH.cs | 4 ++-- .../Tnb.WarehouseMgr.Entities/Entity/WmsDistaskH.part.cs | 2 +- WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs | 7 ++++--- WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs | 4 ++-- WarehouseMgr/Tnb.WarehouseMgr/WmsCarryService.cs | 2 +- WarehouseMgr/Tnb.WarehouseMgr/WmsCarryUnbindService.cs | 4 ++-- WarehouseMgr/Tnb.WarehouseMgr/WmsDeliveryService.cs | 2 +- WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs | 2 +- WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryBindService.cs | 4 ++-- WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryUnbindService .cs | 4 ++-- WarehouseMgr/Tnb.WarehouseMgr/WmsPDADeliveryService.cs | 2 +- .../Tnb.WarehouseMgr/WmsPDAEmptyOutstockService .cs | 6 +++--- WarehouseMgr/Tnb.WarehouseMgr/WmsPDAFeedingService.cs | 2 +- WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInStockService.cs | 2 +- WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInbaleService.cs | 2 +- WarehouseMgr/Tnb.WarehouseMgr/WmsPDATransferService.cs | 2 +- WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs | 4 ++-- WarehouseMgr/Tnb.WarehouseMgr/WmsTransferService.cs | 2 +- WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs | 2 +- 19 files changed, 30 insertions(+), 29 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryH.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryH.cs index fcd567dd..4ef88721 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryH.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryH.cs @@ -44,8 +44,8 @@ public partial class WmsCarryH : BaseEntity /// 载具状态 /// /// - [SugarColumn(ColumnDataType = "varchar(32)", SqlParameterDbType = typeof(CommonPropertyConvert))] - public int carry_status { get; set; } + //[SugarColumn(ColumnDataType = "varchar(32)", SqlParameterDbType = typeof(CommonPropertyConvert))] + public string carry_status { get; set; } /// /// 载具分类ID diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsDistaskH.part.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsDistaskH.part.cs index 9bbbc560..cf9870e0 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsDistaskH.part.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsDistaskH.part.cs @@ -13,5 +13,5 @@ public partial class WmsDistaskH /// 载具状态 /// [SugarColumn(IsIgnore = true)] - public int carry_status { get; set; } + public string carry_status { get; set; } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs index 56f2fd96..ffae366f 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs @@ -458,11 +458,12 @@ namespace Tnb.WarehouseMgr for (int i = 0; i < multis.Count; i++) { var carryStatus = multis[i].carry_status; - if (multis[i].carry_status == (int)EnumCarryStatus.空闲) + if (multis[i].carry_status == ((int)EnumCarryStatus.空闲).ToString()) { - carryStatus = (int)EnumCarryStatus.空闲; + carryStatus = ((int)EnumCarryStatus.空闲).ToString(); } - await _db.Updateable().SetColumns(it => new BasLocation { is_use = carryStatus, is_lock = 0 }).Where(it => it.id == multis[i].endlocation_id).ExecuteCommandAsync(); + var cStatus =carryStatus.ParseToInt(); + await _db.Updateable().SetColumns(it => new BasLocation { is_use = cStatus, is_lock = 0 }).Where(it => it.id == multis[i].endlocation_id).ExecuteCommandAsync(); } //更新业务主表的单据状态 if (disTasks?.Count > 0) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs index 85a9ccd0..c8a19f8f 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs @@ -70,9 +70,9 @@ namespace Tnb.WarehouseMgr var subCarry = await _db.Queryable().SingleAsync(it => it.id == subCarryId); if (carry != null && subCarry != null) { - carry.carry_status = (int)EnumCarryStatus.占用; + carry.carry_status = ((int)EnumCarryStatus.占用).ToString(); var row = await _db.Updateable(carry).ExecuteCommandAsync(); - subCarry.carry_status = (int)EnumCarryStatus.占用; + subCarry.carry_status = ((int)EnumCarryStatus.占用).ToString(); row = await _db.Updateable(subCarry).ExecuteCommandAsync(); //更新载具明细表 WmsCarryD wmsCarryD = new() diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryService.cs index 8945d77a..42cab97b 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryService.cs @@ -160,7 +160,7 @@ namespace Tnb.WarehouseMgr try { carryObj.status = 0; - carryObj.carry_status = (int)EnumCarryStatus.空闲; + carryObj.carry_status = ((int)EnumCarryStatus.空闲).ToString(); carryObj.location_id = null; carryObj.location_code = null; carryObj.out_status = "0"; diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryUnbindService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryUnbindService.cs index 1bdd4499..7b8577ae 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryUnbindService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryUnbindService.cs @@ -92,9 +92,9 @@ namespace Tnb.WarehouseMgr wmsCarryUnbindCode.create_time = DateTime.Now; row = await _db.Insertable(wmsCarryUnbindCode).ExecuteCommandAsync(); } - carry.carry_status = (int)EnumCarryStatus.空闲; + carry.carry_status = ((int)EnumCarryStatus.空闲).ToString(); row = await _db.Updateable(carry).ExecuteCommandAsync(); - subCarry.carry_status = (int)EnumCarryStatus.空闲; + subCarry.carry_status = ((int)EnumCarryStatus.空闲).ToString(); row = await _db.Updateable(subCarry).ExecuteCommandAsync(); isOk = (row > 0); if (!isOk) throw Oops.Oh(ErrorCode.COM1001); diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsDeliveryService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsDeliveryService.cs index 5066db04..94c43365 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsDeliveryService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsDeliveryService.cs @@ -158,7 +158,7 @@ namespace Tnb.WarehouseMgr var location = await _db.Queryable().SingleAsync(it => it.id == input.data[nameof(WmsDelivery.startlocation_id)].ToString()); { //载具加锁,增加库位信息 - await _db.Updateable().SetColumns(it => new WmsCarryH { carry_status = (int)EnumCarryStatus.占用, + await _db.Updateable().SetColumns(it => new WmsCarryH { carry_status = ((int)EnumCarryStatus.占用).ToString(), is_lock = 1, location_id = input.data[nameof(WmsDelivery.startlocation_id)].ToString(), location_code = location.location_code}).Where(it => it.id == input.data[nameof(WmsDelivery.carry_id)].ToString()).ExecuteCommandAsync(); } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs index fe5418ca..9ac2b976 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs @@ -78,7 +78,7 @@ namespace Tnb.WarehouseMgr var setQty = await _db.Queryable().FirstAsync(it => it.bill_code == input.data[nameof(WmsEmptyOutstockH.bill_code)].ToString()); var carrys = await _db.Queryable().LeftJoin((a, b) => a.location_id == b.id) .Where((a, b) => a.carrystd_id == input.data[nameof(WmsEmptyOutstockH.carrystd_id)].ToString() - && a.carry_status == (int)EnumCarryStatus.空闲 && a.is_lock == 0 && b.is_lock == 0) + && a.carry_status == ((int)EnumCarryStatus.空闲).ToString() && a.is_lock == 0 && b.is_lock == 0) .ToListAsync(); WmsPointH sPoint = null; diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryBindService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryBindService.cs index 657c232a..61a57092 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryBindService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryBindService.cs @@ -84,9 +84,9 @@ namespace Tnb.WarehouseMgr create_time = DateTime.Now }; var row = await _db.Insertable(wmsCarryD).ExecuteCommandAsync(); - carry.carry_status = (int)EnumCarryStatus.占用; + carry.carry_status = ((int)EnumCarryStatus.占用).ToString(); row = await _db.Updateable(carry).ExecuteCommandAsync(); - subCarry.carry_status = (int)EnumCarryStatus.占用; + subCarry.carry_status = ((int)EnumCarryStatus.占用).ToString(); row = await _db.Updateable(subCarry).ExecuteCommandAsync(); var items = await _db.Queryable().Where(it => it.carry_id == subCarryId).ToListAsync(); //更新载具绑定条码表 diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryUnbindService .cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryUnbindService .cs index 6652b476..2e499b53 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryUnbindService .cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryUnbindService .cs @@ -91,9 +91,9 @@ namespace Tnb.WarehouseMgr wmsCarryUnbindCode.create_time = DateTime.Now; row = await _db.Insertable(wmsCarryUnbindCode).ExecuteCommandAsync(); } - carry.carry_status = (int)EnumCarryStatus.空闲; + carry.carry_status = ((int)EnumCarryStatus.空闲).ToString(); row = await _db.Updateable(carry).ExecuteCommandAsync(); - subCarry.carry_status = (int)EnumCarryStatus.空闲; + subCarry.carry_status = ((int)EnumCarryStatus.空闲).ToString(); row = await _db.Updateable(subCarry).ExecuteCommandAsync(); isOk = (row > 0); if (!isOk) throw Oops.Oh(ErrorCode.COM1001); diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDADeliveryService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDADeliveryService.cs index 3b44dd0b..2ecb1828 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDADeliveryService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDADeliveryService.cs @@ -157,7 +157,7 @@ namespace Tnb.WarehouseMgr //载具加锁,增加库位信息 await _db.Updateable().SetColumns(it => new WmsCarryH { - carry_status = (int)EnumCarryStatus.占用, + carry_status = ((int)EnumCarryStatus.占用).ToString(), is_lock = 1, location_id = input.data[nameof(WmsDelivery.startlocation_id)].ToString(), location_code = location.location_code diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyOutstockService .cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyOutstockService .cs index c3733ac8..d6a71cc6 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyOutstockService .cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyOutstockService .cs @@ -70,12 +70,12 @@ namespace Tnb.WarehouseMgr //判断目标库位是否自动签收 var loc = await _db.Queryable().SingleAsync(it => it.id == input.data[nameof(WmsPointH.location_id)].ToString()); - + //出库取起点,获取所有符合输入的载具规格的载具 var setQty = await _db.Queryable().FirstAsync(it => it.bill_code == input.data[nameof(WmsEmptyOutstockH.bill_code)].ToString()); var carrys = await _db.Queryable().LeftJoin((a, b) => a.location_id == b.id) .Where((a, b) => a.carrystd_id == input.data[nameof(WmsEmptyOutstockH.carrystd_id)].ToString() - && a.carry_status ==(int)EnumCarryStatus.空闲 && a.is_lock == 0 && b.is_lock == 0) + && a.carry_status == ((int)EnumCarryStatus.空闲).ToString() && a.is_lock == 0 && b.is_lock == 0) .ToListAsync(); WmsPointH sPoint = null; @@ -216,7 +216,7 @@ namespace Tnb.WarehouseMgr { await _db.Ado.RollbackTranAsync(); throw; - + } } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAFeedingService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAFeedingService.cs index 5143677d..349e1ab6 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAFeedingService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAFeedingService.cs @@ -130,7 +130,7 @@ namespace Tnb.WarehouseMgr try { carryObj.status = 0; - carryObj.carry_status = (int)EnumCarryStatus.空闲; + carryObj.carry_status = ((int)EnumCarryStatus.空闲).ToString(); carryObj.location_id = null; carryObj.location_code = null; carryObj.out_status = "0"; diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInStockService.cs index d5c7a96c..8a5b86ab 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInStockService.cs @@ -239,7 +239,7 @@ namespace Tnb.WarehouseMgr await _db.Insertable(carryCodes).ExecuteCommandAsync(); await _db.Insertable(instockCOdes).CallEntityMethod(it => it.Create(orgId)).ExecuteCommandAsync(); await _wareHouseService.GenInStockTaskHandleAfter(preTaskUpInput, - it => new WmsCarryH { carry_code = input.data[nameof(WmsCarryH.carry_code)].ToString()!, is_lock = 1, carry_status = (int)EnumCarryStatus.占用, location_id = preTaskUpInput.CarryStartLocationId, location_code = preTaskUpInput.CarryStartLocationCode }, + it => new WmsCarryH { carry_code = input.data[nameof(WmsCarryH.carry_code)].ToString()!, is_lock = 1, carry_status = ((int)EnumCarryStatus.占用).ToString(), location_id = preTaskUpInput.CarryStartLocationId, location_code = preTaskUpInput.CarryStartLocationCode }, it => new BasLocation { is_lock = 1, is_use = (int)EnumCarryStatus.占用 }); if (instockCOdes?.Count > 0) { diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInbaleService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInbaleService.cs index 89027139..54c69b7b 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInbaleService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInbaleService.cs @@ -145,7 +145,7 @@ namespace Tnb.WarehouseMgr var baleNum = input.data[nameof(WmsCarryH.bale_num)]?.ToString(); await _wareHouseService.GenInStockTaskHandleAfter(preTaskUpInput, - it => new WmsCarryH { is_lock = 1, location_id = preTaskUpInput.CarryStartLocationId, location_code = preTaskUpInput.CarryStartLocationCode, carry_status = (int)EnumCarryStatus.寄存, bale_num = baleNum }, + it => new WmsCarryH { is_lock = 1, location_id = preTaskUpInput.CarryStartLocationId, location_code = preTaskUpInput.CarryStartLocationCode, carry_status = ((int)EnumCarryStatus.寄存).ToString(), bale_num = baleNum }, it => new BasLocation { is_lock = 1 }); //((int)EnumCarryStatus.寄存).ToString() } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDATransferService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDATransferService.cs index 259fa4e2..44c4981a 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDATransferService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDATransferService.cs @@ -122,7 +122,7 @@ namespace Tnb.WarehouseMgr //载具加锁,增加库位信息 await _db.Updateable().SetColumns(it => new WmsCarryH { - carry_status = (int)EnumCarryStatus.占用, + carry_status = ((int)EnumCarryStatus.占用).ToString(), is_lock = 1, location_id = input.data[nameof(WmsTransfer.startlocation_id)].ToString(), location_code = location.location_code diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs index 9fa176f7..ecc671a9 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs @@ -128,7 +128,7 @@ namespace Tnb.WarehouseMgr GenPreTaskUpInput genPreTaskAfterUpInput = new(); genPreTaskAfterUpInput.CarryIds = preTasks.Select(x => x.carry_id).ToList(); genPreTaskAfterUpInput.LocationIds = new HashSet(locIds).ToList(); - await _wareHouseService.GenInStockTaskHandleAfter(genPreTaskAfterUpInput, it => new WmsCarryH { is_lock = 1, carry_status = (int)EnumCarryStatus.齐套分拣 }, it => new BasLocation { is_use = (int)EnumCarryStatus.齐套分拣 }); + await _wareHouseService.GenInStockTaskHandleAfter(genPreTaskAfterUpInput, it => new WmsCarryH { is_lock = 1, carry_status = ((int)EnumCarryStatus.齐套分拣).ToString() }, it => new BasLocation { is_use = (int)EnumCarryStatus.齐套分拣 }); } } @@ -198,7 +198,7 @@ namespace Tnb.WarehouseMgr { await _db.Ado.BeginTranAsync(); - await _db.Updateable().SetColumns(it => new WmsCarryH { carry_status = (int)EnumCarryStatus.齐套, location_id = null, location_code = null }).ExecuteCommandAsync(); + await _db.Updateable().SetColumns(it => new WmsCarryH { carry_status = ((int)EnumCarryStatus.齐套).ToString(), location_id = null, location_code = null }).ExecuteCommandAsync(); await _db.Updateable().SetColumns(it => new BasLocation { is_use = (int)EnumCarryStatus.空闲 }).ExecuteCommandAsync(); await _db.Ado.CommitTranAsync(); diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsTransferService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsTransferService.cs index 20f2935c..2ce0a3c7 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsTransferService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsTransferService.cs @@ -122,7 +122,7 @@ namespace Tnb.WarehouseMgr //载具加锁,增加库位信息 await _db.Updateable().SetColumns(it => new WmsCarryH { - carry_status = (int)EnumCarryStatus.占用, + carry_status = ((int)EnumCarryStatus.占用).ToString(), is_lock = 1, location_id = input.data[nameof(WmsTransfer.startlocation_id)].ToString(), location_code = location.location_code diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs index acb65df1..49223de9 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs @@ -180,7 +180,7 @@ namespace Tnb.WarehouseMgr var subCarrys = await _db.Queryable().Where(it => it.carry_id == ko.carry_id).ToListAsync(); var carryIds = subCarrys.Select(x => x.carry_id).Concat(new[] { ko.carry_id }).Distinct().ToList(); GenPreTaskUpInput genPreTaskInput = new() { CarryIds = carryIds, LocationIds = new List { carry.location_id, ko.location_id } }; - await _warehouseService.GenInStockTaskHandleAfter(genPreTaskInput, it => new WmsCarryH { is_lock = 1, carry_status = (int)EnumCarryStatus.齐套 }, it => new BasLocation { is_lock = 1 }); + await _warehouseService.GenInStockTaskHandleAfter(genPreTaskInput, it => new WmsCarryH { is_lock = 1, carry_status = ((int)EnumCarryStatus.齐套).ToString() }, it => new BasLocation { is_lock = 1 }); } } From 8db015233606f19cf8502d87fe9bbbd4e2559b47 Mon Sep 17 00:00:00 2001 From: alex Date: Wed, 28 Jun 2023 09:23:53 +0800 Subject: [PATCH 02/12] =?UTF-8?q?=E5=87=BA=E5=BA=93=E7=94=B3=E8=AF=B7?= =?UTF-8?q?=EF=BC=8C=E6=9C=AA=E6=89=BE=E5=88=B0=E8=BD=BD=E5=85=B7=E6=97=B6?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=EF=BC=8C=E2=80=9C=E5=BA=93=E5=AD=98=E4=B8=8D?= =?UTF-8?q?=E8=B6=B3=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs index ba350f16..5341929a 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs @@ -219,6 +219,7 @@ namespace Tnb.WarehouseMgr genPreTaskAfterUpInput.LocationIds = new HashSet(locIds).ToList(); await _wareHouseService.GenInStockTaskHandleAfter(genPreTaskAfterUpInput, it => new WmsCarryH { is_lock = 1 }, it => new BasLocation { is_lock = 1 }); } + else throw new AppFriendlyException("库存不足", 500); } else throw new AppFriendlyException($"请输入物料明细", 500); From c665a59fd9472c4349db11701e682599bff23513 Mon Sep 17 00:00:00 2001 From: taomin0419 <865692298@qq.com> Date: Wed, 28 Jun 2023 10:37:49 +0800 Subject: [PATCH 03/12] =?UTF-8?q?=E5=87=BA=E5=BA=93=E7=94=B3=E8=AF=B7?= =?UTF-8?q?=E4=B8=9A=E5=8A=A1=E5=9B=9E=E6=9B=B4=E4=BB=A3=E7=A0=81=E6=8F=90?= =?UTF-8?q?=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Tnb.WarehouseMgr/WmsOutStockService.cs | 91 +++++++++++-------- .../WmsSignForDeliveryService.cs | 25 +++-- 2 files changed, 72 insertions(+), 44 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs index ba350f16..3b15c0eb 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs @@ -17,6 +17,7 @@ using Microsoft.AspNetCore.Mvc; using SqlSugar; using Tnb.BasicData.Entities; using Tnb.WarehouseMgr.Entities; +using Tnb.WarehouseMgr.Entities.Attributes; using Tnb.WarehouseMgr.Entities.Consts; using Tnb.WarehouseMgr.Entities.Dto; using Tnb.WarehouseMgr.Entities.Enums; @@ -28,8 +29,10 @@ namespace Tnb.WarehouseMgr /// 出库申请业务类 /// [OverideVisualDev(ModuleConsts.MODULE_WMSOUTSTOCK_ID)] + [ServiceModule(BizTypeId)] public class WmsOutStockService : BaseWareHouseService, IWmsOutStockService { + private const string BizTypeId = "26191522660645"; private readonly ISqlSugarClient _db; private readonly IDictionaryDataService _dictionaryDataService; private readonly IRunService _runService; @@ -271,54 +274,68 @@ namespace Tnb.WarehouseMgr public override async Task ModifyAsync(WareHouseUpInput input) { if (input == null) throw new ArgumentNullException("input"); - var carryId = input.carryIds[^input.carryIds.Count]; - var carry = await _db.Queryable().SingleAsync(it => it.id == carryId); - if (carry != null) - { - var outStatus = carry.out_status.ToEnum(); - if (outStatus == EnumOutStatus.全部出) - { - //当前载具对应的所有条码插入 - var carryCodes = await _db.Queryable().Where(it => it.carry_id == carryId).ToListAsync(); - var outStockCodes = carryCodes.Adapt>(); - var otds = await _db.Queryable().Where(it => it.bill_id == input.requireId).ToListAsync(); - outStockCodes.ForEach(x => - { - var billDId = otds?.Find(xx => xx.material_id == x.material_id && xx.code_batch == x.code_batch)?.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(outStockCodes).ExecuteCommandAsync(); - var detailIds = outStockCodes.Select(x => x.bill_d_id).ToList(); - var curOutstockDetails = otds.FindAll(x => detailIds.Contains(x.id)); - var dic = outStockCodes.GroupBy(g => g.bill_d_id).ToDictionary(x => x.Key, x => x.Select(x => x.codeqty).ToList()); - foreach (var osd in curOutstockDetails) + + try + { + var carryId = input.carryIds[^input.carryIds.Count]; + var carry = await _db.Queryable().SingleAsync(it => it.id == carryId); + if (carry != null) + { + var outStatus = carry.out_status.ToEnum(); + if (outStatus == EnumOutStatus.全部出) { - if (dic.ContainsKey(osd.id)) + //当前载具对应的所有条码插入 + var carryCodes = await _db.Queryable().Where(it => it.carry_id == carryId).ToListAsync(); + var outStockCodes = carryCodes.Adapt>(); + var otds = await _db.Queryable().Where(it => it.bill_id == input.requireId).ToListAsync(); + outStockCodes.ForEach(x => { - osd.qty += dic[osd.id].Sum(d => d); - if (osd.qty >= osd.pr_qty) + var billDId = otds?.Find(xx => xx.material_id == x.material_id && xx.code_batch == x.code_batch)?.id; + if (billDId.IsNullOrEmpty()) { - osd.line_status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID; + billDId = otds?.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(outStockCodes).ExecuteCommandAsync(); + + var detailIds = outStockCodes.Select(x => x.bill_d_id).ToList(); + var curOutstockDetails = otds.FindAll(x => detailIds.Contains(x.id)); + var dic = outStockCodes.GroupBy(g => g.bill_d_id).ToDictionary(x => x.Key, x => x.Select(x => x.codeqty).ToList()); + foreach (var osd in curOutstockDetails) + { + 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; + } } } + await _db.Updateable(curOutstockDetails).ExecuteCommandAsync(); + if (otds.All(x => x.line_status == WmsWareHouseConst.BILLSTATUS_COMPLETE_ID)) + { + await _db.Updateable().SetColumns(it => new WmsOutstockH { status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID }).Where(it => it.id == input.requireId).ExecuteCommandAsync(); + //如果是自动单据,需要回更上层系统 + } } - await _db.Updateable(curOutstockDetails).ExecuteCommandAsync(); - if (otds.All(x => x.line_status == WmsWareHouseConst.BILLSTATUS_COMPLETE_ID)) + else if (outStatus == EnumOutStatus.分拣出) { - await _db.Updateable().SetColumns(it => new WmsOutstockH { status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID }).Where(it => it.id == input.requireId).ExecuteCommandAsync(); - //如果是自动单据,需要回更上层系统 + } } - else if (outStatus == EnumOutStatus.分拣出) - { + } + catch (Exception ex) + { - } + throw; } } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsSignForDeliveryService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsSignForDeliveryService.cs index 6af12c94..5f972f85 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsSignForDeliveryService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsSignForDeliveryService.cs @@ -66,6 +66,12 @@ namespace Tnb.WarehouseMgr var carry = await _db.Queryable().SingleAsync(it => it.id == input.carryId); if (carry != null) { + if (carry.location_id.IsNotEmptyOrNull()) + { + var loc = await _db.Queryable().SingleAsync(it => it.id == carry.location_id); + loc.is_use = (int)EnumCarryStatus.空闲; + await _db.Updateable(loc).UpdateColumns(it => it.is_use).ExecuteCommandAsync(); + } var disTask = await _db.Queryable().SingleAsync(it => it.id == input.disTaskId); if (disTask != null) { @@ -77,18 +83,23 @@ namespace Tnb.WarehouseMgr case "寄存出库": case "齐套出库": case "一般出库": - await _wareCarryService.UpdateNullCarry(carry); + { + WareHouseUpInput upInput = new() { loginType = "web", bizTypeId = disTask.biz_type, requireId = disTask.require_id, carryIds = new List { input.carryId } }; + await DoUpdate(upInput); //回更业务 + await _wareCarryService.UpdateNullCarry(carry); + } break; + case "载具移出": + { + WareHouseUpInput upInput = new() { loginType = "web", bizTypeId = disTask.biz_type, requireId = disTask.require_id, carryIds = new List { input.carryId } }; + await DoUpdate(upInput); //回更业务 + } + break; + } } - var loc = await _db.Queryable().SingleAsync(it => it.id == carry.location_id); - loc.is_use = (int)EnumCarryStatus.空闲; - await _db.Updateable(loc).UpdateColumns(it => it.is_use).ExecuteCommandAsync(); - WareHouseUpInput upInput = new() { loginType = "web", bizTypeId = disTask.biz_type, requireId = disTask.require_id, carryIds = new List { input.carryId } }; - await DoUpdate(upInput); //回更业务 } } - await _db.Ado.CommitTranAsync(); } catch (Exception) From 6db872c17dbe66a8069e5e8716765279e347f7e0 Mon Sep 17 00:00:00 2001 From: alex Date: Wed, 28 Jun 2023 11:25:46 +0800 Subject: [PATCH 04/12] =?UTF-8?q?=E5=87=BA=E5=BA=93=E7=AD=BE=E6=94=B6?= =?UTF-8?q?=EF=BC=8C=E6=96=B0=E5=A2=9E=E8=BE=93=E5=85=A5=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dto/Inputs/SignForDeliveryInput.cs | 11 ++++++++++- .../Dto/Inputs/WareHouseUpInput.cs | 1 + WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs | 2 ++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/SignForDeliveryInput.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/SignForDeliveryInput.cs index f41c5f38..c1de744a 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/SignForDeliveryInput.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/SignForDeliveryInput.cs @@ -18,6 +18,15 @@ namespace Tnb.WarehouseMgr.Entities.Dto.Inputs /// /// 载具ID /// - public string carryId { get; set; } + public string carryId { get; set; } + + public string new_carry_code { get; set; } + + /// + /// 任务执行条码表 + /// + public List distaskCodes { get; set; } } + + } diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/WareHouseUpInput.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/WareHouseUpInput.cs index cdd1bb7a..fa48bda3 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/WareHouseUpInput.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/WareHouseUpInput.cs @@ -35,5 +35,6 @@ namespace Tnb.WarehouseMgr.Entities.Dto + } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs index d2537086..63a030f5 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs @@ -331,6 +331,8 @@ namespace Tnb.WarehouseMgr { } + + //更新执行任务已签收 } } catch (Exception ex) From 83e0b1294bca175a6a77e2ac75356d5ddf63934f Mon Sep 17 00:00:00 2001 From: zhoukeda <1315948824@qq.com> Date: Wed, 28 Jun 2023 14:02:20 +0800 Subject: [PATCH 05/12] bug --- .../Consts/CodeTemplateConst.cs | 23 +++++++++ .../IBasDefectService.cs | 15 ++++++ BasicData/Tnb.BasicData/BasDefectService.cs | 43 +++++++++++++++++ .../Consts/DictionaryConstants.cs | 9 ---- .../Tnb.ProductionMgr/PrdFeedingService.cs | 2 +- .../PrdMaterialReceiptService.cs | 2 +- .../Tnb.ProductionMgr/PrdMoTaskService.cs | 48 +++++++++++-------- .../Tnb.ProductionMgr/PrdTaskManageService.cs | 6 ++- 8 files changed, 116 insertions(+), 32 deletions(-) create mode 100644 BasicData/Tnb.BasicData.Entities/Consts/CodeTemplateConst.cs create mode 100644 BasicData/Tnb.BasicData.Interfaces/IBasDefectService.cs create mode 100644 BasicData/Tnb.BasicData/BasDefectService.cs diff --git a/BasicData/Tnb.BasicData.Entities/Consts/CodeTemplateConst.cs b/BasicData/Tnb.BasicData.Entities/Consts/CodeTemplateConst.cs new file mode 100644 index 00000000..a62d9c12 --- /dev/null +++ b/BasicData/Tnb.BasicData.Entities/Consts/CodeTemplateConst.cs @@ -0,0 +1,23 @@ +namespace Tnb.BasicData +{ + /// + /// 单据模板业务编码 + /// + public class CodeTemplateConst + { + /// + /// 物料签收编码 + /// + public const string MATERIAL_RECEIPT_CODE = "MaterialReceipt"; + + /// + /// 生产投料编码 + /// + public const string FEEDING_CODE = "Feeding"; + + /// + /// 生产任务单号单据模板编码 + /// + public const string PRDMOTASK_CODE = "ProductionPlanAndSchedule"; + } +} \ No newline at end of file diff --git a/BasicData/Tnb.BasicData.Interfaces/IBasDefectService.cs b/BasicData/Tnb.BasicData.Interfaces/IBasDefectService.cs new file mode 100644 index 00000000..21992ccb --- /dev/null +++ b/BasicData/Tnb.BasicData.Interfaces/IBasDefectService.cs @@ -0,0 +1,15 @@ +namespace Tnb.BasicData.Interfaces +{ + /// + /// 次品项服务 + /// + public interface IBasDefectService + { + /// + /// 根据工序id获取次品项列表 + /// + /// + /// + public Task GetDefectListByProcessId(Dictionary dic); + } +} \ No newline at end of file diff --git a/BasicData/Tnb.BasicData/BasDefectService.cs b/BasicData/Tnb.BasicData/BasDefectService.cs new file mode 100644 index 00000000..2ee6d6ba --- /dev/null +++ b/BasicData/Tnb.BasicData/BasDefectService.cs @@ -0,0 +1,43 @@ +using JNPF.Common.Core.Manager; +using JNPF.DependencyInjection; +using JNPF.DynamicApiController; +using JNPF.Systems.Interfaces.System; +using JNPF.VisualDev; +using Microsoft.AspNetCore.Mvc; +using SqlSugar; +using Tnb.BasicData.Entities; +using Tnb.BasicData.Interfaces; + +namespace Tnb.BasicData +{ + /// + /// 物料清单 + /// + [ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 1102)] + [Route("api/[area]/[controller]/[action]")] + public class BasDefectService: IBasDefectService,IDynamicApiController, ITransient + { + private readonly ISqlSugarRepository _repository; + private readonly DataBaseManager _dbManager; + private readonly IDictionaryDataService _dictionaryDataService; + + public BasDefectService( + ISqlSugarRepository repository,DataBaseManager dbManager,IDictionaryDataService dictionaryDataService) + { + _repository = repository; + _dbManager = dbManager; + _dictionaryDataService = dictionaryDataService; + } + + [HttpPost] + public async Task GetDefectListByProcessId(Dictionary dic) + { + string processId = dic["processId"]; + return await _repository.AsSugarClient().Queryable() + .LeftJoin((a, b) => a.process_id == b.id) + .LeftJoin((a, b, c) => a.defective_id == c.id) + .Where((a, b, c) => a.process_id == processId) + .Select((a, b, c) => c).ToListAsync(); + } + } +} \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Consts/DictionaryConstants.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Consts/DictionaryConstants.cs index a97b121c..cd925157 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Consts/DictionaryConstants.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Consts/DictionaryConstants.cs @@ -20,15 +20,6 @@ namespace Tnb.ProductionMgr.Entities.Consts /// public const string WaitProductId = "25019244276501"; - /// - /// 物料签收编码 - /// - public const string MATERIAL_RECEIPT_CODE = "MaterialReceipt"; - - /// - /// 生产投料编码 - /// - public const string FEEDING_CODE = "Feeding"; } diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs index 047a6725..e45e0109 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs @@ -52,7 +52,7 @@ namespace Tnb.ProductionMgr .Select(x=>x.material_id) .ToListAsync(); - string code = await _billRullService.GetBillNumber(MoStatus.FEEDING_CODE); + string code = await _billRullService.GetBillNumber(Tnb.BasicData.CodeTemplateConst.FEEDING_CODE); PrdFeedingH prdFeedingH = new PrdFeedingH() { code = code, diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs index 7a2baec7..bf6d721d 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs @@ -79,7 +79,7 @@ namespace Tnb.ProductionMgr .Select(x=>x.material_id) .ToListAsync(); - string code = await _billRullService.GetBillNumber(MoStatus.MATERIAL_RECEIPT_CODE); + string code = await _billRullService.GetBillNumber(Tnb.BasicData.CodeTemplateConst.MATERIAL_RECEIPT_CODE); PrdMaterialReceiptH prdMaterialReceiptH = new PrdMaterialReceiptH() { code = code, diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs index 79fe64ea..0fd84c98 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs @@ -63,6 +63,7 @@ namespace Tnb.ProductionMgr private static Dictionary _dicWorkLine = new Dictionary(); private static Dictionary _dicProcess = new Dictionary(); private readonly ISqlSugarClient _db; + private readonly IBillRullService _billRuleService; public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc(); @@ -71,6 +72,7 @@ namespace Tnb.ProductionMgr IUserManager userManager, IDictionaryDataService dictionaryDataService, IRunService runService, + IBillRullService billRullService, IVisualDevService visualDevService ) { @@ -82,6 +84,7 @@ namespace Tnb.ProductionMgr _db = _repository.AsSugarClient(); OverideFuncs.DeleteAsync = Delete; OverideFuncs.GetListAsync = GetList; + _billRuleService = billRullService; } @@ -321,7 +324,7 @@ namespace Tnb.ProductionMgr .LeftJoin((a, b, c) => a.material_id == c.id) .LeftJoin((a, b, c, d) => a.workline_id == d.Id) .LeftJoin((a,b,c,d,e)=>a.process_id==e.id) - .Where((a, b, c, d) => b.id == moId || b.parent_id == moId) + .Where((a, b, c, d) => (b.id == moId || b.parent_id == moId) && SqlFunc.IsNullOrEmpty(a.parent_id)) .Select((a, b, c, d,e) => new PrdMoTaskOutput { mo_task_code = a.mo_task_code, @@ -411,6 +414,8 @@ namespace Tnb.ProductionMgr scheduled_qty = a.scheduled_qty, plan_qty = d.plan_qty, process_task_qty = a.process_task_qty, + estimated_start_date = a.estimated_start_date, + estimated_end_date = a.estimated_end_date, bom_version = SqlFunc.Subqueryable().Where(it => it.material_id == a.material_id).Select(it => it.version) }) .Mapper(it => it.mo_task_status = dic.ContainsKey(it.mo_task_status) ? dic[it.mo_task_status].ToString()! : "") @@ -764,25 +769,27 @@ namespace Tnb.ProductionMgr moTask.scheduled_qty = input.scheduled_qty; var mo = await _db.Queryable().FirstAsync(it => it.id == input.mo_id); var moCode = mo?.mo_code; - var taskCode = await _db.Queryable().Where(it => string.IsNullOrEmpty(it.parent_id) && !string.IsNullOrEmpty(it.mo_task_code) && it.mo_task_code.Contains(moCode)) - .OrderByDescending(it => it.mo_task_code) - .Select(it => it.mo_task_code) - .FirstAsync(); - if (taskCode is null || taskCode.IsNullOrEmpty()) - { - moTask.mo_task_code = $"{moCode}-01"; - } - else - { - var pos = taskCode?.IndexOf("-", StringComparison.Ordinal); - if (pos.HasValue && pos.Value > -1) - { - var num = taskCode.AsSpan().Slice(pos.Value + 1).ToString().ParseToInt(); - var code = taskCode.AsSpan().Slice(0, pos.Value).ToString(); - var n = (num + 1).ToString().PadLeft(2, '0'); - moTask.mo_task_code = $"{code}-{n}"; - } - } + // var taskCode = await _db.Queryable().Where(it => string.IsNullOrEmpty(it.parent_id) && !string.IsNullOrEmpty(it.mo_task_code) && it.mo_task_code.Contains(moCode)) + // .OrderByDescending(it => it.mo_task_code) + // .Select(it => it.mo_task_code) + // .FirstAsync(); + var taskCode = await _billRuleService.GetBillNumber(Tnb.BasicData.CodeTemplateConst.PRDMOTASK_CODE); + moTask.mo_task_code = taskCode; + // if (taskCode is null || taskCode.IsNullOrEmpty()) + // { + // moTask.mo_task_code = $"{moCode}-01"; + // } + // else + // { + // var pos = taskCode?.IndexOf("-", StringComparison.Ordinal); + // if (pos.HasValue && pos.Value > -1) + // { + // var num = taskCode.AsSpan().Slice(pos.Value + 1).ToString().ParseToInt(); + // var code = taskCode.AsSpan().Slice(0, pos.Value).ToString(); + // var n = (num + 1).ToString().PadLeft(2, '0'); + // moTask.mo_task_code = $"{code}-{n}"; + // } + // } row = await _db.Insertable(moTask).ExecuteCommandAsync(); var material_h = await _db.Queryable().FirstAsync(it => it.id == moTask.material_id); //添加生产任务操作记录日志 @@ -860,6 +867,7 @@ namespace Tnb.ProductionMgr .LeftJoin((a, b, c, d) => b.route_detail_id == d.id) .LeftJoin((a, b, c, d, e) => a.id == e.mbom_id && e.mbom_process_id == b.id) .Where((a, b, c, d, e) => a.id == input.bom_id) + .OrderBy((a,b,c,d,e)=>b.ordinal) .Select((a, b, c, d, e) => new SubBomListOutput { version = a.version, diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs index 2bb31058..6501a0e1 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs @@ -257,8 +257,10 @@ namespace Tnb.ProductionMgr .LeftJoin((a,b,c)=>a.mold_id==c.id) .LeftJoin((a,b,c,d)=>a.eqp_id==d.id) .LeftJoin((a,b,c,d,e)=>e.DictionaryTypeId==DictConst.PrdTaskStatusTypeId && a.mo_task_status==e.EnCode) + .LeftJoin((a,b,c,d,e,f)=>a.workline_id==f.Id) + .LeftJoin((a,b,c,d,e,f,g)=>a.process_id==g.id) .Where((a,b) => a.mo_task_code == mo_task_code) - .Select((a,b,c,d,e) => new + .Select((a,b,c,d,e,f,g) => new { id = a.id, mo_task_code = a.mo_task_code, @@ -278,6 +280,8 @@ namespace Tnb.ProductionMgr // reported_qty = a.reported_qty, // prd_qty = a.prd_qty, eqp_code = d.code, + workline_name = f.FullName, + process_name = g.process_name }).FirstAsync(); return prdTask; From 35b7d3ea975c51644ec9435ca18eca64f6c0cfbe Mon Sep 17 00:00:00 2001 From: zhoukeda <1315948824@qq.com> Date: Wed, 28 Jun 2023 14:09:51 +0800 Subject: [PATCH 06/12] bug --- .../Dto/PrdManage/PackSechelToBeIssueListOutput.cs | 5 +++++ ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PackSechelToBeIssueListOutput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PackSechelToBeIssueListOutput.cs index 08bc9117..5a71e3ce 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PackSechelToBeIssueListOutput.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PackSechelToBeIssueListOutput.cs @@ -76,6 +76,11 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage /// 预计结束时间 /// public DateTime? estimated_end_date { get; set; } + + /// + /// 工序名称 + /// + public string? process_name { get; set; } } } diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs index 0fd84c98..571761ec 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs @@ -401,8 +401,9 @@ namespace Tnb.ProductionMgr .LeftJoin((a, b) => a.material_id == b.id) .LeftJoin((a, b, c) => a.workline_id == c.Id) .LeftJoin((a, b, c, d) => a.mo_id == d.id) + .LeftJoin((a,b,c,d,e)=>a.process_id==e.id) .Where((a, b, c, d) => a.parent_id == mo_task_id) - .Select((a, b, c, d) => new PackSechelToBeIssueListOutput + .Select((a, b, c, d,e) => new PackSechelToBeIssueListOutput { mo_task_id = a.id, mo_task_code = a.mo_task_code, @@ -416,6 +417,7 @@ namespace Tnb.ProductionMgr process_task_qty = a.process_task_qty, estimated_start_date = a.estimated_start_date, estimated_end_date = a.estimated_end_date, + process_name = e.process_name, bom_version = SqlFunc.Subqueryable().Where(it => it.material_id == a.material_id).Select(it => it.version) }) .Mapper(it => it.mo_task_status = dic.ContainsKey(it.mo_task_status) ? dic[it.mo_task_status].ToString()! : "") From dcbf6fbc953901c79bc59a253439fa094ee35616 Mon Sep 17 00:00:00 2001 From: alex Date: Wed, 28 Jun 2023 14:36:07 +0800 Subject: [PATCH 07/12] =?UTF-8?q?=E5=87=BA=E5=BA=93=E7=AD=BE=E6=94=B6?= =?UTF-8?q?=E4=B8=9A=E5=8A=A1=E5=9B=9E=E6=9B=B4=EF=BC=8C=E5=88=86=E6=8B=A3?= =?UTF-8?q?=E5=87=BA=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IWmsCarryMoveInStockService.cs | 17 +++++ .../WmsCarryMoveInStockService.cs | 5 +- .../Tnb.WarehouseMgr/WmsOutStockService.cs | 67 +++++++++++++++++-- .../WmsSignForDeliveryService.cs | 7 +- 4 files changed, 89 insertions(+), 7 deletions(-) create mode 100644 WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmsCarryMoveInStockService.cs diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmsCarryMoveInStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmsCarryMoveInStockService.cs new file mode 100644 index 00000000..c6308eba --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmsCarryMoveInStockService.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using JNPF.Common.Dtos.VisualDev; + +namespace Tnb.WarehouseMgr.Interfaces +{ + /// + /// 载具移入服务接口 + /// + public interface IWmsCarryMoveInStockService + { + Task CarryMoveIn(VisualDevModelDataCrInput input); + } +} diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryMoveInStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryMoveInStockService.cs index 4e9ade4d..ab349cb8 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryMoveInStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryMoveInStockService.cs @@ -30,7 +30,7 @@ namespace Tnb.WarehouseMgr /// [OverideVisualDev(ModuleConsts.MODULE_CARRYMOVEINSTOCK_ID)] [ServiceModule(BizTypeId)] - public class WmsCarryMoveInStockService : BaseWareHouseService + public class WmsCarryMoveInStockService : BaseWareHouseService, IWmsCarryMoveInStockService { private const string BizTypeId = "26121988909861"; private readonly ISqlSugarClient _db; @@ -58,7 +58,8 @@ namespace Tnb.WarehouseMgr OverideFuncs.CreateAsync = CarryMoveIn; } - private async Task CarryMoveIn(VisualDevModelDataCrInput input) + [NonAction] + public async Task CarryMoveIn(VisualDevModelDataCrInput input) { try diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs index 63a030f5..d7ddf2b2 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs @@ -40,6 +40,9 @@ namespace Tnb.WarehouseMgr private readonly IWareHouseService _wareHouseService; private readonly IUserManager _userManager; private readonly IBillRullService _billRullService; + private readonly IWmsCarryMoveInStockService _wmsCarryMoveInStockService; + private readonly IWmsCarryService _wareCarryService; + public WmsOutStockService( ISqlSugarRepository repository, @@ -48,7 +51,9 @@ namespace Tnb.WarehouseMgr IVisualDevService visualDevService, IWareHouseService wareHouseService, IUserManager userManager, - IBillRullService billRullService) + IBillRullService billRullService, + IWmsCarryMoveInStockService wmsCarryMoveInStockService, + IWmsCarryService wareCarryService) { _db = repository.AsSugarClient(); _dictionaryDataService = dictionaryDataService; @@ -57,6 +62,8 @@ namespace Tnb.WarehouseMgr _wareHouseService = wareHouseService; _userManager = userManager; _billRullService = billRullService; + _wmsCarryMoveInStockService = wmsCarryMoveInStockService; + _wareCarryService = wareCarryService; OverideFuncs.CreateAsync = OutStockApplyFor; } @@ -261,7 +268,7 @@ namespace Tnb.WarehouseMgr [HttpGet] public async Task Testxx() { - var carryCodePropNames = typeof(WmsCarryCode).GetProperties().Select(p => p.Name); + var carryCodePropNames = typeof(WmsDistaskCode).GetProperties().Select(p => p.Name); var outStockCodePropNames = typeof(WmsOutstockCode).GetProperties().Select(p => p.Name); var intersects = carryCodePropNames.Intersect(outStockCodePropNames).ToList(); var excepts = carryCodePropNames.Except(outStockCodePropNames).ToList(); @@ -326,13 +333,65 @@ namespace Tnb.WarehouseMgr await _db.Updateable().SetColumns(it => new WmsOutstockH { status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID }).Where(it => it.id == input.requireId).ExecuteCommandAsync(); //如果是自动单据,需要回更上层系统 } + await _wareCarryService.UpdateNullCarry(carry); } else if (outStatus == EnumOutStatus.分拣出) { + if (input.distaskCodes?.Count > 0) + { + var osCodes = input.distaskCodes.Adapt>(); + osCodes.ForEach(x => x.id = SnowflakeIdHelper.NextId()); + await _db.Insertable(osCodes).ExecuteCommandAsync(); + + var carryCodes = await _db.Queryable().Where(it => input.carryIds.Contains(it.carry_id)).ToListAsync(); + var dicCodeQty = carryCodes.GroupBy(g => g.barcode).ToDictionary(x => x.Key, x => x.First().codeqty); + var dicUpdate = new Dictionary(); + var delBarcodes = new List(); + foreach (var dtc in input.distaskCodes) + { + if (dicCodeQty.ContainsKey(dtc.barcode)) + { + if (dtc.codeqty < dicCodeQty[dtc.barcode]) + { + dicUpdate[dtc.barcode] = dicCodeQty[dtc.barcode] - dtc.codeqty; + } + else + { + delBarcodes.Add(dtc.barcode); + } + } + } + if (dicUpdate.Count > 0) + { + foreach (var pair in dicUpdate) + { + WmsCarryCode carryCode = new(); + carryCode.codeqty = pair.Value; + await _db.Updateable(carryCode).UpdateColumns(it => it.codeqty).Where(it => it.barcode == pair.Key).ExecuteCommandAsync(); + } + await _db.Updateable().SetColumns(it => new WmsCarryH { out_status = ((int)EnumOutStatus.正常).ToString() }).Where(it => input.carryIds.Contains(it.id)).ExecuteCommandAsync(); + await _db.Deleteable().Where(it => input.carryIds.Contains(it.carry_id)).ExecuteCommandAsync(); + + } + if (delBarcodes.Count > 0) + { + await _db.Deleteable().Where(it => delBarcodes.Contains(it.barcode)).ExecuteCommandAsync(); + } + //载具移入 + var outStockH = await _db.Queryable().SingleAsync(it => it.id == input.requireId); + var visulDevInput = new VisualDevModelDataCrInput(); + visulDevInput.data = new Dictionary + { + [nameof(InStockStrategyQuery.warehouse_id)] = outStockH.warehouse_id, + [nameof(WmsPointH.location_id)] = outStockH.location_id, + [nameof(WmsCarryD.carry_id)] = input.carryIds.First(), + [nameof(WmsHandleH.biz_type)] = input.bizTypeId, + [nameof(WmsHandleH.bill_code)] = outStockH.bill_code, + }; + await _wmsCarryMoveInStockService.CarryMoveIn(visulDevInput); + } } - - //更新执行任务已签收 } } catch (Exception ex) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsSignForDeliveryService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsSignForDeliveryService.cs index 5f972f85..ca8672f7 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsSignForDeliveryService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsSignForDeliveryService.cs @@ -30,12 +30,14 @@ namespace Tnb.WarehouseMgr private readonly ISqlSugarClient _db; private readonly IWmsCarryService _wareCarryService; private readonly IDictionaryDataService _dictionaryDataService; + private readonly IWmsCarryMoveInStockService _wmsCarryMoveInStockService; private static Dictionary _dicBizType = new(); - public WmsSignForDeliveryService(ISqlSugarRepository repository, IWmsCarryService wareCarryService, IDictionaryDataService dictionaryDataService) + public WmsSignForDeliveryService(ISqlSugarRepository repository, IWmsCarryService wareCarryService, IDictionaryDataService dictionaryDataService, IWmsCarryMoveInStockService wmsCarryMoveInStockService) { _db = repository.AsSugarClient(); _wareCarryService = wareCarryService; _dictionaryDataService = dictionaryDataService; + _wmsCarryMoveInStockService = wmsCarryMoveInStockService; } /// /// 根据载具ID获取,对应的执行任务记录 @@ -87,6 +89,7 @@ namespace Tnb.WarehouseMgr WareHouseUpInput upInput = new() { loginType = "web", bizTypeId = disTask.biz_type, requireId = disTask.require_id, carryIds = new List { input.carryId } }; await DoUpdate(upInput); //回更业务 await _wareCarryService.UpdateNullCarry(carry); + } break; case "载具移出": @@ -98,6 +101,8 @@ namespace Tnb.WarehouseMgr } } + disTask.is_sign = 1; + await _db.Updateable(disTask).UpdateColumns(it => it.is_sign).ExecuteCommandAsync(); } } await _db.Ado.CommitTranAsync(); From 49578c27c2094fc921a9c4c95caddede5f95ae6f Mon Sep 17 00:00:00 2001 From: alex Date: Wed, 28 Jun 2023 14:36:20 +0800 Subject: [PATCH 08/12] +1 --- WarehouseMgr/Tnb.WarehouseMgr/WmsSignForDeliveryService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsSignForDeliveryService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsSignForDeliveryService.cs index ca8672f7..34cccb55 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsSignForDeliveryService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsSignForDeliveryService.cs @@ -88,7 +88,7 @@ namespace Tnb.WarehouseMgr { WareHouseUpInput upInput = new() { loginType = "web", bizTypeId = disTask.biz_type, requireId = disTask.require_id, carryIds = new List { input.carryId } }; await DoUpdate(upInput); //回更业务 - await _wareCarryService.UpdateNullCarry(carry); + } break; From 8c0a23215f8311bd377c9aaf46e0f17eac91c690 Mon Sep 17 00:00:00 2001 From: zhoukeda <1315948824@qq.com> Date: Wed, 28 Jun 2023 14:38:32 +0800 Subject: [PATCH 09/12] bug --- ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs index 6501a0e1..6e2d5482 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs @@ -281,7 +281,8 @@ namespace Tnb.ProductionMgr // prd_qty = a.prd_qty, eqp_code = d.code, workline_name = f.FullName, - process_name = g.process_name + process_name = g.process_name, + process_id = a.process_id }).FirstAsync(); return prdTask; From bf0217998fafb610e9db3e46305e516038ccd2af Mon Sep 17 00:00:00 2001 From: alex Date: Wed, 28 Jun 2023 14:40:00 +0800 Subject: [PATCH 10/12] 1 --- BasicData/Tnb.BasicData.Entities/Entity/BasLocation.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BasicData/Tnb.BasicData.Entities/Entity/BasLocation.cs b/BasicData/Tnb.BasicData.Entities/Entity/BasLocation.cs index e27f81bd..dbac4e6f 100644 --- a/BasicData/Tnb.BasicData.Entities/Entity/BasLocation.cs +++ b/BasicData/Tnb.BasicData.Entities/Entity/BasLocation.cs @@ -44,7 +44,7 @@ public partial class BasLocation : BaseEntity /// 是否使用 /// //[SugarColumn(ColumnDataType = "varchar(32)", SqlParameterDbType = typeof(CommonPropertyConvert))] - public int is_use { get; set; } + public int is_use { get; set; } /// /// 是否最小 From 68b975c49830fec10e9fcf7936d3ba30f47ea6a0 Mon Sep 17 00:00:00 2001 From: zhoukeda <1315948824@qq.com> Date: Wed, 28 Jun 2023 15:31:02 +0800 Subject: [PATCH 11/12] bug --- .../Dto/PrdManage/PackSechelToBeIssueListOutput.cs | 4 ++-- .../Tnb.ProductionMgr.Entities/Entity/PrdMo.cs | 5 +++++ .../Tnb.ProductionMgr.Entities/Entity/PrdMoTask.cs | 5 +++++ ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs | 10 ++++++---- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PackSechelToBeIssueListOutput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PackSechelToBeIssueListOutput.cs index 5a71e3ce..66d4d2ec 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PackSechelToBeIssueListOutput.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PackSechelToBeIssueListOutput.cs @@ -71,11 +71,11 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage /// /// 预计开始时间 /// - public DateTime? estimated_start_date { get; set; } + public string? estimated_start_date { get; set; } /// /// 预计结束时间 /// - public DateTime? estimated_end_date { get; set; } + public string? estimated_end_date { get; set; } /// /// 工序名称 diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMo.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMo.cs index 4a2a743f..f456faf7 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMo.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMo.cs @@ -222,5 +222,10 @@ public partial class PrdMo : BaseEntity /// 父工单id /// public string parent_id { get; set; } + + /// + /// 物料单位 + /// + public string? unit_id { get; set; } } diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTask.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTask.cs index 097e9df0..d2135450 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTask.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTask.cs @@ -187,5 +187,10 @@ public partial class PrdMoTask : BaseEntity /// 最后一道工序完成数量 /// public int? last_process_complete_qty { get; set; } + + /// + /// 物料单位 + /// + public string? unit_id { get; set; } } diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs index 571761ec..f78051c0 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs @@ -379,8 +379,8 @@ namespace Tnb.ProductionMgr // scheduled_qty = SqlFunc.Subqueryable().Where(it => it.mo_id == a.mo_id).Sum(it => it.scheduled_qty), scheduled_qty = a.scheduled_qty, plan_qty = SqlFunc.Subqueryable().Where(it => it.id == a.mo_id).Select(it => it.plan_qty), - estimated_start_date = a.estimated_start_date, - estimated_end_date = a.estimated_end_date, + estimated_start_date = a.estimated_start_date==null ? null : a.estimated_start_date.Value.ToString("yyyy-MM-dd HH:mm"), + estimated_end_date = a.estimated_end_date==null ? null : a.estimated_end_date.Value.ToString("yyyy-MM-dd HH:mm"), bom_id = d.id, bom_version = d.version }) @@ -415,8 +415,8 @@ namespace Tnb.ProductionMgr scheduled_qty = a.scheduled_qty, plan_qty = d.plan_qty, process_task_qty = a.process_task_qty, - estimated_start_date = a.estimated_start_date, - estimated_end_date = a.estimated_end_date, + estimated_start_date = a.estimated_start_date==null ? null : a.estimated_start_date.Value.ToString("yyyy-MM-dd HH:mm"), + estimated_end_date = a.estimated_end_date==null ? null : a.estimated_end_date.Value.ToString("yyyy-MM-dd HH:mm"), process_name = e.process_name, bom_version = SqlFunc.Subqueryable().Where(it => it.material_id == a.material_id).Select(it => it.version) }) @@ -658,6 +658,7 @@ namespace Tnb.ProductionMgr var mo = await db.Queryable().FirstAsync(it => it.id == input.mo_id); var moCode = mo?.mo_code; var taskCode = await db.Queryable().Where(it => !string.IsNullOrEmpty(it.mo_task_code) && it.mo_task_code.Contains(moCode)).OrderByDescending(it => it.mo_task_code).Select(it => it.mo_task_code).FirstAsync(); + moTask.unit_id = mo.unit_id; if (taskCode.IsNullOrEmpty()) { moTask.mo_task_code = $"{moCode}-01"; @@ -770,6 +771,7 @@ namespace Tnb.ProductionMgr moTask.estimated_end_date = input.estimated_end_date; moTask.scheduled_qty = input.scheduled_qty; var mo = await _db.Queryable().FirstAsync(it => it.id == input.mo_id); + moTask.unit_id = mo.unit_id; var moCode = mo?.mo_code; // var taskCode = await _db.Queryable().Where(it => string.IsNullOrEmpty(it.parent_id) && !string.IsNullOrEmpty(it.mo_task_code) && it.mo_task_code.Contains(moCode)) // .OrderByDescending(it => it.mo_task_code) From 0cb5abb2ef66c649d16cd4c7eb572c94a08fc555 Mon Sep 17 00:00:00 2001 From: alex Date: Wed, 28 Jun 2023 15:58:41 +0800 Subject: [PATCH 12/12] =?UTF-8?q?wms=20=E7=94=9F=E6=88=90=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E4=BB=A3=E7=A0=81=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Consts/WmsWareHouseConst.cs | 4 ++ .../Tnb.WarehouseMgr/WareHouseService.cs | 31 ++++++++++- .../Tnb.WarehouseMgr/WmsInStockService.cs | 55 +++++++++++++++++++ .../Tnb.WarehouseMgr/WmsOutStockService.cs | 27 +++++++-- .../Tnb.WarehouseMgr/WmsPDAInStockService.cs | 1 + 5 files changed, 111 insertions(+), 7 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs index 83daa894..53b76564 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs @@ -23,6 +23,10 @@ namespace Tnb.WarehouseMgr.Entities.Consts /// public const string WMS_PRETASK_H_ENCODE = "PreTaskGen"; /// + /// 载具移入生成Encode + /// + public const string WMS_CARRYMOINSTK_ENCODE = "CarryMoInStk"; + /// /// 任务执行ENCODE /// public const string WMS_TASK_EXECUTE_ENCODE = "WmsTaskRequest"; diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs index ffae366f..812656cc 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs @@ -270,7 +270,7 @@ namespace Tnb.WarehouseMgr } //获取所有未下发的预任务申请 - var preTasks = await _db.Queryable().InnerJoin((a, b) => a.startlocation_id == b.location_id) + var preTasks = await _db.Queryable().InnerJoin((a, b) => a.startlocation_id == b.location_id && a.carry_id == b.id) .InnerJoin((a, b, c) => a.area_id == c.id) .Where(a => a.status == WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID) .OrderBy(a => new { priority = SqlFunc.Desc(a.priority), a.bill_code }) @@ -279,15 +279,20 @@ namespace Tnb.WarehouseMgr move_num = c.move_num }, true) .ToListAsync(); + var ids = preTasks.Select(x => x.id).Distinct().ToList(); + var preTaskCodes = await _db.Queryable().Where(it => ids.Contains(it.bill_id)).ToListAsync(); if (preTasks.Count > 0) { //根据预任务管理区分组,获取到所有分组后的预任务,遍历每个预任务 是否为任务链,通过管理区ID var preTaskGroups = preTasks.GroupBy(g => g.area_code).ToList(); List disTasks = new(); + List distaskCodes = new(); foreach (var itGroup in preTaskGroups) { var moveNum = itGroup.First().move_num; var items = itGroup.Adapt>(); + + items.ForEach(x => SnowflakeIdHelper.NextId()); items.ForEach(x => { x.status = WmsWareHouseConst.TASK_BILL_STATUS_DZX_ID; @@ -325,14 +330,34 @@ namespace Tnb.WarehouseMgr await _taskChainAttrHandle(items, areaPreTasks, moveNum); } } + if (preTaskCodes?.Count > 0) + { + foreach (var disTask in items) + { + var curPreTaskCodes = preTaskCodes.FindAll(x => x.bill_id == disTask.pretask_id); + var curDisTaskCodes = curPreTaskCodes.Adapt>(); + curPreTaskCodes.ForEach(x => + { + x.id = SnowflakeIdHelper.NextId(); + x.bill_id = disTask.id; + x.create_time = DateTime.Now; + }); + distaskCodes.AddRange(curDisTaskCodes); + } + } + disTasks.AddRange(items); } try { await _db.Ado.BeginTranAsync(); - disTasks.ForEach(x => x.id = SnowflakeIdHelper.NextId()); + //disTasks.ForEach(x => x.id = SnowflakeIdHelper.NextId()); var row = await _db.Insertable(disTasks).ExecuteCommandAsync(); + if (preTaskCodes?.Count > 0) + { + row = await _db.Insertable(distaskCodes).ExecuteCommandAsync(); + } if (row > 0) { var preTaskIds = preTasks.Select(x => x.id).ToList(); @@ -462,7 +487,7 @@ namespace Tnb.WarehouseMgr { carryStatus = ((int)EnumCarryStatus.空闲).ToString(); } - var cStatus =carryStatus.ParseToInt(); + var cStatus = carryStatus.ParseToInt(); await _db.Updateable().SetColumns(it => new BasLocation { is_use = cStatus, is_lock = 0 }).Where(it => it.id == multis[i].endlocation_id).ExecuteCommandAsync(); } //更新业务主表的单据状态 diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs index d26a486a..ff57cc39 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs @@ -12,7 +12,9 @@ using NPOI.SS.Formula.Functions; using SqlSugar; using Tnb.BasicData.Entities; using Tnb.WarehouseMgr.Entities; +using Tnb.WarehouseMgr.Entities.Attributes; using Tnb.WarehouseMgr.Entities.Consts; +using Tnb.WarehouseMgr.Entities.Dto; using Tnb.WarehouseMgr.Entities.Dto.Inputs; using Tnb.WarehouseMgr.Interfaces; @@ -21,8 +23,10 @@ namespace Tnb.WarehouseMgr /// /// 入库申请服务 /// + [ServiceModule(BizTypeId)] public class WmsInStockService : BaseWareHouseService, IWmsInStockService { + private const string BizTypeId = "26191496816421"; private readonly ISqlSugarClient _db; private readonly IDictionaryDataService _dictionaryDataService; private readonly IUserManager _userManager; @@ -155,5 +159,56 @@ namespace Tnb.WarehouseMgr return barCode; } + + public override async Task ModifyAsync(WareHouseUpInput input) + { + if (input == null) throw new ArgumentNullException("input"); + //更具distaskCode的barcode 更新 instockcode 的 is_end 为 1 + try + { + await _db.Ado.BeginTranAsync(); + + if (input.distaskCodes?.Count > 0) + { + var barCodes = input.distaskCodes.Select(x => x.barcode); + await _db.Updateable().SetColumns(it => new WmsInstockCode { is_end = 1 }).Where(it => barCodes.Contains(it.barcode)).ExecuteCommandAsync(); + var instockCodes = await _db.Queryable().Where(it => barCodes.Contains(it.barcode)).Select(it => new + { + id = it.bill_d_id, + barcode_qty = it.codeqty, + }).ToListAsync(); + var dic = instockCodes.GroupBy(g => g.id).ToDictionary(x => x.Key, x => x.Select(d => d.barcode_qty).ToList()); + var ids = instockCodes.Select(it => it.id).ToList(); + var instockDetails = await _db.Queryable().Where(it => ids.Contains(it.id)).ToListAsync(); + + foreach (var item in instockDetails) + { + if (dic.ContainsKey(item.id)) + { + item.qty += dic[item.id].Sum(x => x); + if (item.qty >= item.pr_qty) + { + item.line_status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID; + } + } + } + await _db.Updateable(instockDetails).ExecuteCommandAsync(); + var allInstockDetails = await _db.Queryable().Where(it => it.bill_id == input.requireId).ToListAsync(); + if (allInstockDetails.All(x => x.line_status == WmsWareHouseConst.BILLSTATUS_COMPLETE_ID)) + { + await _db.Updateable().SetColumns(it => new WmsInstockH { status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID }).Where(it => it.id == input.requireId).ExecuteCommandAsync(); + //如果是自动单据,需要回更上层系统 + } + } + + await _db.Ado.CommitTranAsync(); + } + catch (Exception) + { + await _db.Ado.RollbackTranAsync(); + throw; + } + } + } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs index d7ddf2b2..1641dc39 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs @@ -286,17 +286,21 @@ namespace Tnb.WarehouseMgr try { + + await _db.Ado.BeginTranAsync(); + var carryId = input.carryIds[^input.carryIds.Count]; var carry = await _db.Queryable().SingleAsync(it => it.id == carryId); if (carry != null) { + var otds = await _db.Queryable().Where(it => it.bill_id == input.requireId).ToListAsync(); var outStatus = carry.out_status.ToEnum(); if (outStatus == EnumOutStatus.全部出) { //当前载具对应的所有条码插入 var carryCodes = await _db.Queryable().Where(it => it.carry_id == carryId).ToListAsync(); var outStockCodes = carryCodes.Adapt>(); - var otds = await _db.Queryable().Where(it => it.bill_id == input.requireId).ToListAsync(); + outStockCodes.ForEach(x => { var billDId = otds?.Find(xx => xx.material_id == x.material_id && xx.code_batch == x.code_batch)?.id; @@ -340,7 +344,20 @@ namespace Tnb.WarehouseMgr if (input.distaskCodes?.Count > 0) { var osCodes = input.distaskCodes.Adapt>(); - osCodes.ForEach(x => x.id = SnowflakeIdHelper.NextId()); + osCodes.ForEach(x => + { + var billDId = otds?.Find(xx => xx.material_id == x.material_id && xx.code_batch == x.code_batch)?.id; + if (billDId.IsNullOrEmpty()) + { + billDId = otds?.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(osCodes).ExecuteCommandAsync(); var carryCodes = await _db.Queryable().Where(it => input.carryIds.Contains(it.carry_id)).ToListAsync(); @@ -386,17 +403,19 @@ namespace Tnb.WarehouseMgr [nameof(WmsPointH.location_id)] = outStockH.location_id, [nameof(WmsCarryD.carry_id)] = input.carryIds.First(), [nameof(WmsHandleH.biz_type)] = input.bizTypeId, - [nameof(WmsHandleH.bill_code)] = outStockH.bill_code, + [nameof(WmsHandleH.bill_code)] = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_CARRYMOINSTK_ENCODE).GetAwaiter().GetResult(), }; await _wmsCarryMoveInStockService.CarryMoveIn(visulDevInput); } } + + await _db.Ado.CommitTranAsync(); } } catch (Exception ex) { - + await _db.Ado.RollbackTranAsync(); throw; } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInStockService.cs index 8a5b86ab..59d85c04 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInStockService.cs @@ -150,6 +150,7 @@ namespace Tnb.WarehouseMgr } } } + //生成预任务,同时如果包含条码信息同时插入条码记录 var isOk = await _wareHouseService.GenPreTask(preTasks, pretaskCodes); if (isOk)