diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/Constraints/ITaskManagerDel.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/Constraints/ITaskManagerDel.cs index 24ca34f1..021221fc 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/Constraints/ITaskManagerDel.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/Constraints/ITaskManagerDel.cs @@ -11,5 +11,6 @@ namespace Tnb.WarehouseMgr.Entities.Entity string startlocation_id { get; set; } string endlocation_id { get; set; } string carry_id { get; set; } + string area_code { get;set; } } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/TaskManagerDelBase.cs b/WarehouseMgr/Tnb.WarehouseMgr/TaskManagerDelBase.cs index 73ab5f78..e1b220b1 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/TaskManagerDelBase.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/TaskManagerDelBase.cs @@ -6,6 +6,7 @@ using System.Threading.Tasks; using JNPF.Common.Contracts; using SqlSugar; using Tnb.BasicData.Entities; +using Tnb.ProductionMgr.Entities; using Tnb.WarehouseMgr.Entities; using Tnb.WarehouseMgr.Entities.Entity; @@ -43,6 +44,7 @@ namespace Tnb.WarehouseMgr await _db.Updateable(carry).UpdateColumns(it => it.is_lock).ExecuteCommandAsync(); } await _db.Deleteable(preTask).ExecuteCommandAsync(); + await _db.Updateable().SetColumns(it => it.task_nums == it.task_nums - 1).Where(it => it.area_code == preTask.area_code).ExecuteCommandAsync(); } await _db.Ado.CommitTranAsync(); } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs index 1fc9e6d7..9122cf9b 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs @@ -28,6 +28,7 @@ using Microsoft.CodeAnalysis; using NPOI.HPSF; using NPOI.OpenXmlFormats.Wordprocessing; using Polly.Timeout; +using Senparc.NeuChar.Helpers; using Senparc.Weixin.Work.AdvancedAPIs.OaDataOpen; using Spire.Pdf.Widget; using SqlSugar; @@ -243,7 +244,7 @@ namespace Tnb.WarehouseMgr } } foreach (var (i, v) in dic) - { + { foreach (var it in v) { it.groups = groupCode; @@ -382,16 +383,19 @@ namespace Tnb.WarehouseMgr //更新任务执行表,单据状态为 完成 await _db.Updateable().SetColumns(it => new WmsDistaskH { status = WmsWareHouseConst.TASK_BILL_STATUS_COMPLE_ID }).Where(it => input.disTaskIds.Contains(it.id)).ExecuteCommandAsync(); - //更新预任务申请表,单据状态为 已完成 var disTasks = await _db.Queryable().InnerJoin((a, b) => a.carry_id == b.id).Where(a => input.disTaskIds.Contains(a.id)).Select((a, b) => new WmsDistaskH { carry_status = b.carry_status }, true).ToListAsync(); if (disTasks?.Count > 0) { + // 更新预任务申请表,单据状态为 已完成 var preTaskIds = disTasks.Select(x => x.pretask_id).ToList(); await _db.Updateable().SetColumns(it => new WmsPretaskH { status = WmsWareHouseConst.PRETASK_BILL_STATUS_COMPLE_ID }).Where(it => preTaskIds.Contains(it.id)).ExecuteCommandAsync(); - } - //更新载具,锁定状态为未锁定,更新载具的库位当前任务的目标库位 - if (disTasks?.Count > 0) - { + + //更新电梯任务数量 + var eles = await _db.Queryable().Where(it => disTasks.Select(x => x.area_code).Contains(it.area_code)).ToListAsync(); + if (eles?.Count > 0) + await _db.Updateable(eles).ReSetValue(it => it.task_nums--).ExecuteCommandAsync(); + + //更新载具,锁定状态为未锁定,更新载具的库位当前任务的目标库位 var multiList = disTasks.Select(it => (it.carry_id, it.endlocation_id, it.endlocation_code)).ToList(); for (int i = 0; i < multiList.Count; i++) { @@ -404,10 +408,8 @@ namespace Tnb.WarehouseMgr await _db.Updateable().SetColumns(it => new WmsCarryCode { warehouse_id = loc.wh_id, location_id = multiList[i].endlocation_id, location_code = multiList[i].endlocation_code }).Where(it => it.id == multiList[i].carry_id).ExecuteCommandAsync(); } } - } - //更新库位信息,使用状态为 使用,锁定状态为未锁定 - if (disTasks?.Count > 0) - { + + //更新库位信息,使用状态为 使用,锁定状态为未锁定 var multis = disTasks.Select(it => (it.endlocation_id, it.carry_status)).ToList(); for (int i = 0; i < multis.Count; i++) { @@ -419,27 +421,25 @@ namespace Tnb.WarehouseMgr var cStatus = carryStatus.ParseToInt(); await _db.Updateable().SetColumns(it => new BasLocation { is_use = cStatus.ToString(), is_lock = 0 }).Where(it => it.id == multis[i].endlocation_id).ExecuteCommandAsync(); } + //更新业务主表的单据状态 - if (disTasks?.Count > 0) + foreach (var dt in disTasks) { - foreach (var dt in disTasks) + var disTaskCodes = await _db.Queryable().Where(it => it.bill_id == dt.id).ToListAsync(); + var upInput = new WareHouseUpInput { bizTypeId = dt.biz_type, requireId = dt.require_id!, distaskCodes = disTaskCodes, carryIds = disTasks.Select(x => x.carry_id).ToList() }; + upInput.loginType = !_userManager.LoginType.IsNullOrEmpty() ? "app" : "web"; + if (dt.is_sign == 1 && dt.chain_type == "3") { - var disTaskCodes = await _db.Queryable().Where(it => it.bill_id == dt.id).ToListAsync(); - var upInput = new WareHouseUpInput { bizTypeId = dt.biz_type, requireId = dt.require_id!, distaskCodes = disTaskCodes, carryIds = disTasks.Select(x => x.carry_id).ToList() }; - upInput.loginType = !_userManager.LoginType.IsNullOrEmpty() ? "app" : "web"; - if (dt.is_sign == 1 && dt.chain_type == "3") - { - await DoUpdate(upInput); - } + await DoUpdate(upInput); } } - - await _db.Ado.CommitTranAsync(); } + await _db.Ado.CommitTranAsync(); } catch (Exception) { await _db.Ado.RollbackTranAsync(); + throw; } } /// @@ -496,6 +496,11 @@ namespace Tnb.WarehouseMgr { row = await _db.Insertable(preTaskCodes).ExecuteCommandAsync(); } + var eleP = preTasks.Find(x => x.area_code.Contains("ELE")); + if (eleP != null) + { + row = await _db.Updateable().SetColumns(it => it.task_nums == it.task_nums + 1).Where(it => it.area_code == eleP.area_code).ExecuteCommandAsync(); + } return row > 0; } /// diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyInstockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyInstockService.cs index d719fe04..57aec1a7 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyInstockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyInstockService.cs @@ -125,12 +125,6 @@ namespace Tnb.WarehouseMgr return preTask; }).ToList(); var isOk = await _wareHouseService.GenPreTask(preTasks, null!); - //更新电梯任务数量 - var eleP = points.Find(x => x.area_code.Contains("ELE")); - if (eleP != null) - { - await _db.Updateable().SetColumns(it => it.task_nums == it.task_nums + 1).Where(it => it.area_code == eleP.area_code).ExecuteCommandAsync(); - } if (isOk) { var preTaskUpInput = new GenPreTaskUpInput(); @@ -162,6 +156,10 @@ namespace Tnb.WarehouseMgr it => new WmsCarryH { is_lock = 1, location_id = preTaskUpInput.CarryStartLocationId, location_code = preTaskUpInput.CarryStartLocationCode }, it => new BasLocation { is_lock = 1 }); } + else + { + throw new AppFriendlyException("预任务生成失败,路径或者设备相关配置错误", 500); + } } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs index e6cfb620..a2c9de08 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs @@ -71,8 +71,6 @@ namespace Tnb.WarehouseMgr { await _db.Ado.BeginTranAsync(); - - /*//入库取终点 var inStockStrategyInput = new InStockStrategyQuery { warehouse_id = input.data[nameof(InStockStrategyQuery.warehouse_id)].ToString(), Size = 1 }; var endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput);*/ @@ -156,12 +154,6 @@ namespace Tnb.WarehouseMgr preTasks[^1].is_sign = 0; // 修改最后一个元素的是否签收值 } isOk = await _wareHouseService.GenPreTask(preTasks, null!); - //更新电梯任务数量 - var eleP = points.Find(x => x.area_code.Contains("ELE")); - if (eleP != null) - { - await _db.Updateable().SetColumns(it => it.task_nums == it.task_nums + 1).Where(it => it.area_code == eleP.area_code).ExecuteCommandAsync(); - } } if(isOk) {