From 9ca32bbcd6a627784f14363159246b4c188227c9 Mon Sep 17 00:00:00 2001 From: FanLian Date: Mon, 17 Jul 2023 15:18:39 +0800 Subject: [PATCH 01/32] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Tnb.WarehouseMgr/WmsCarryBindService.cs | 2 +- .../Tnb.WarehouseMgr/WmsPDAFeedingService.cs | 41 +++---------------- 2 files changed, 7 insertions(+), 36 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs index 3cb9e96c..fb5460ab 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs @@ -94,7 +94,7 @@ namespace Tnb.WarehouseMgr { WmsCarrybindCode wmsCarrybindCode = new(); wmsCarrybindCode.id = SnowflakeIdHelper.NextId(); - wmsCarrybindCode.org_id = subCarry?.org_id!; + wmsCarrybindCode.org_id = (subCarry != null && subCarry.org_id != null) ? subCarry.org_id : _userManager.User.OrganizeId; wmsCarrybindCode.carrybind_id = input.data["ReturnIdentity"]?.ToString()!; wmsCarrybindCode.material_id = items[i].material_id; wmsCarrybindCode.material_code = items[i].material_code; diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAFeedingService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAFeedingService.cs index ff96cddc..23b83bb3 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAFeedingService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAFeedingService.cs @@ -27,25 +27,28 @@ namespace Tnb.WarehouseMgr /// PDA投料记录 /// [OverideVisualDev(ModuleConsts.MODULE_WMSFEEDINGRECORDPDA_ID)] - public class WmsPDAFeedingService : BaseWareHouseService, IWmsCarryService, IPdaStroage + public class WmsPDAFeedingService : BaseWareHouseService, IPdaStroage { private readonly ISqlSugarClient _db; private readonly IUserManager _userManager; private readonly IBillRullService _billRullService; private readonly IRunService _runService; private readonly IVisualDevService _visualDevService; + private readonly IWmsCarryService _carryService; public WmsPDAFeedingService( ISqlSugarRepository repository, IUserManager userManager, IBillRullService billRullService, IRunService runService, - IVisualDevService visualDevService) + IVisualDevService visualDevService, + IWmsCarryService carryService) { _db = repository.AsSugarClient(); _userManager = userManager; _billRullService = billRullService; _runService = runService; _visualDevService = visualDevService; + _carryService = carryService; OverideFuncs.CreateAsync = WmsPDAFeedingRecord; } @@ -97,7 +100,7 @@ namespace Tnb.WarehouseMgr it.modify_time }).ExecuteCommandAsync(); //更新载具 - row = await UpdateNullCarry(carry); + row = await _carryService.UpdateNullCarry(carry); isOk = (row > 0); if (!isOk) throw Oops.Oh(ErrorCode.COM1001); } @@ -124,37 +127,5 @@ namespace Tnb.WarehouseMgr return isOk; } - public async Task UpdateNullCarry(WmsCarryH carryObj) - { - var row = -1; - try - { - carryObj.status = 0; - carryObj.carry_status = ((int)EnumCarryStatus.空闲).ToString(); - carryObj.location_id = null; - carryObj.location_code = null; - carryObj.out_status = "0"; - carryObj.is_check = 0; - carryObj.status = 1; - carryObj.bale_num = null; - carryObj.collocation_scheme_id = null; - carryObj.collocation_scheme_code = null; - carryObj.source_id = null; - carryObj.source_code = null; - row = await _db.Updateable(carryObj).ExecuteCommandAsync(); - //删除对应明细表 - //删除载具明细 - await _db.Deleteable().Where(it => it.carry_id == carryObj.id).ExecuteCommandHasChangeAsync(); - //删除载具分拣物料明细 - await _db.Deleteable().Where(it => it.carry_id == carryObj.id).ExecuteCommandHasChangeAsync(); - //删除载具条码 - await _db.Deleteable().Where(it => it.carry_id == carryObj.id).ExecuteCommandHasChangeAsync(); - } - catch (Exception) - { - - } - return row; - } } } \ No newline at end of file From 8c06c4c622ec7d70a2d1d67ef3e55fbb2346b7a8 Mon Sep 17 00:00:00 2001 From: alex Date: Mon, 17 Jul 2023 17:06:40 +0800 Subject: [PATCH 02/32] =?UTF-8?q?=E9=87=8D=E5=86=99=E9=A2=84=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E7=94=B3=E8=AF=B7=EF=BC=8C=E4=BB=BB=E5=8A=A1=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E5=88=A0=E9=99=A4=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Consts/ModuleConsts.cs | 10 +++- .../Entity/Constraints/ITaskManagerDel.cs | 15 +++++ .../Entity/WmsDistaskH.part.cs | 3 +- .../Entity/WmsPretaskH.part.cs | 3 +- .../Tnb.WarehouseMgr/TaskManagerDelBase.cs | 56 +++++++++++++++++++ .../Tnb.WarehouseMgr/WareHouseService.cs | 3 + .../Tnb.WarehouseMgr/WmsDistaskService.cs | 52 +++++++++++++++++ .../Tnb.WarehouseMgr/WmsInStockService.cs | 26 ++++----- .../Tnb.WarehouseMgr/WmsPretaskService.cs | 23 ++++++++ .../Tnb.WarehouseMgr/WmskittingOutService.cs | 4 +- 10 files changed, 177 insertions(+), 18 deletions(-) create mode 100644 WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/Constraints/ITaskManagerDel.cs create mode 100644 WarehouseMgr/Tnb.WarehouseMgr/TaskManagerDelBase.cs create mode 100644 WarehouseMgr/Tnb.WarehouseMgr/WmsDistaskService.cs create mode 100644 WarehouseMgr/Tnb.WarehouseMgr/WmsPretaskService.cs diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/ModuleConsts.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/ModuleConsts.cs index 9ebfe36f..f3c226da 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/ModuleConsts.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/ModuleConsts.cs @@ -48,7 +48,7 @@ public class ModuleConsts /// 模块标识-PDA空载具入库 /// public const string MODULE_WMSEMPTYINSTKPDA_ID = "26475795363877"; - + /// /// 模块标识-PDA载具更换 /// @@ -144,5 +144,13 @@ public class ModuleConsts /// 模块标识-空载具入库 /// public const string MODULE_WMSEMPTYINSTOCK_ID = "26120915344165"; + /// + /// 模块标识-预任务申请 + /// + public const string MODULE_WMSPRETASK_ID = "26126898582309"; + /// + /// 模块标识-任务执行 + /// + public const string MODULE_WMSDISTASK_ID = "26128621455141"; } \ No newline at end of file diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/Constraints/ITaskManagerDel.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/Constraints/ITaskManagerDel.cs new file mode 100644 index 00000000..24ca34f1 --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/Constraints/ITaskManagerDel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tnb.WarehouseMgr.Entities.Entity +{ + public interface ITaskManagerDel + { + string startlocation_id { get; set; } + string endlocation_id { get; set; } + string carry_id { get; set; } + } +} diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsDistaskH.part.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsDistaskH.part.cs index cf9870e0..e380d56d 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsDistaskH.part.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsDistaskH.part.cs @@ -1,13 +1,14 @@ using JNPF.Common.Contracts; using JNPF.Common.Security; using SqlSugar; +using Tnb.WarehouseMgr.Entities.Entity; namespace Tnb.WarehouseMgr.Entities; /// /// 任务执行主表 /// -public partial class WmsDistaskH +public partial class WmsDistaskH : ITaskManagerDel { /// /// 载具状态 diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsPretaskH.part.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsPretaskH.part.cs index 5136949b..aa14821e 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsPretaskH.part.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsPretaskH.part.cs @@ -1,13 +1,14 @@ using JNPF.Common.Contracts; using JNPF.Common.Security; using SqlSugar; +using Tnb.WarehouseMgr.Entities.Entity; namespace Tnb.WarehouseMgr.Entities; /// /// 预任务申请主表 /// -public partial class WmsPretaskH +public partial class WmsPretaskH : ITaskManagerDel { /// /// 单次搬运数量 diff --git a/WarehouseMgr/Tnb.WarehouseMgr/TaskManagerDelBase.cs b/WarehouseMgr/Tnb.WarehouseMgr/TaskManagerDelBase.cs new file mode 100644 index 00000000..73ab5f78 --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr/TaskManagerDelBase.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using JNPF.Common.Contracts; +using SqlSugar; +using Tnb.BasicData.Entities; +using Tnb.WarehouseMgr.Entities; +using Tnb.WarehouseMgr.Entities.Entity; + +namespace Tnb.WarehouseMgr +{ + public class TaskManagerDelBase : BaseWareHouseService where T : BaseEntity, ITaskManagerDel, new() + { + private readonly ISqlSugarClient _db; + + public TaskManagerDelBase(ISqlSugarClient db) + { + _db = db; + OverideFuncs.DeleteAsync = UnLockLocationAndCarry; + } + private async Task UnLockLocationAndCarry(string id) + { + try + { + await _db.Ado.BeginTranAsync(); + + var preTask = await _db.Queryable().SingleAsync(it => it.id == id); + if (preTask != null) + { + var locIds = new[] { preTask.startlocation_id, preTask.endlocation_id }; + var locs = await _db.Queryable().Where(it => locIds.Contains(it.id)).ToListAsync(); + if (locs?.Count > 0) + { + locs.ForEach(it => { it.is_lock = 0; }); + await _db.Updateable(locs).UpdateColumns(it => it.is_lock).ExecuteCommandAsync(); + } + var carry = await _db.Queryable().SingleAsync(it => it.id == preTask.carry_id); + if (carry != null) + { + carry.is_lock = 0; + await _db.Updateable(carry).UpdateColumns(it => it.is_lock).ExecuteCommandAsync(); + } + await _db.Deleteable(preTask).ExecuteCommandAsync(); + } + await _db.Ado.CommitTranAsync(); + } + catch (Exception) + { + await _db.Ado.RollbackTranAsync(); + throw; + } + } + } +} diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs index 0af932f0..c2114d31 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs @@ -488,6 +488,9 @@ namespace Tnb.WarehouseMgr } } + + + /// /// 生成预任务 /// diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsDistaskService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsDistaskService.cs new file mode 100644 index 00000000..28bc827f --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsDistaskService.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using JNPF.VisualDev; +using SqlSugar; +using Tnb.WarehouseMgr.Entities; +using Tnb.WarehouseMgr.Entities.Consts; +using Tnb.WarehouseMgr.Entities.Entity; + +namespace Tnb.WarehouseMgr +{ + [OverideVisualDev(ModuleConsts.MODULE_WMSDISTASK_ID)] + public class WmsDistaskService : BaseWareHouseService + { + private readonly ISqlSugarClient _db; + + public WmsDistaskService(ISqlSugarRepository repository) + { + _db = repository.AsSugarClient(); + OverideFuncs.DeleteAsync = Delete; + } + + private async Task Delete(string id) + { + try + { + await _db.Ado.BeginTranAsync(); + + var disTask = await _db.Queryable().SingleAsync(it => it.id == id); + if (disTask != null) + { + var preTask = await _db.Queryable().SingleAsync(it => it.id == disTask.pretask_id); + if (preTask != null) + { + preTask.status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID; + await _db.Updateable(preTask).UpdateColumns(it => it.status).ExecuteCommandAsync(); + } + await _db.Deleteable(disTask).ExecuteCommandAsync(); + } + + await _db.Ado.CommitTranAsync(); + } + catch (Exception) + { + await _db.Ado.RollbackTranAsync(); + throw; + } + } + } +} diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs index 9a5da81b..1cfec063 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs @@ -221,12 +221,12 @@ namespace Tnb.WarehouseMgr await _db.Updateable(instockDetails).ExecuteCommandAsync(); var instock = await _db.Queryable().SingleAsync(it => it.id == input.requireId); if (instock.IsNull()) ArgumentNullException.ThrowIfNull(nameof(instock)); - if (instock?.sync_status != WmsWareHouseConst.SYNC_STATUS_NONEEDSYNC) + if (instock.sync_status != WmsWareHouseConst.SYNC_STATUS_NONEEDSYNC) { //如果是自动单据,需要回更上层系统 - Dictionary pars = new() { { nameof(WmsInstockH.source_id), instock!.source_id } }; + Dictionary pars = new() { { nameof(WmsInstockH.source_id), instock?.source_id ?? string.Empty } }; var callBackRes = await _prdInstockService.SyncInstock(pars); - instock.sync_status = callBackRes == true ? WmsWareHouseConst.SYNC_STATUS__SYNCCOMPLETE : WmsWareHouseConst.SYNC_STATUS__SYNCFAILED; + instock!.sync_status = callBackRes == true ? WmsWareHouseConst.SYNC_STATUS__SYNCCOMPLETE : WmsWareHouseConst.SYNC_STATUS__SYNCFAILED; await _db.Updateable(instock).UpdateColumns(it => it.sync_status).ExecuteCommandAsync(); } var allInstockDetails = await _db.Queryable().Where(it => it.bill_id == input.requireId).ToListAsync(); @@ -348,22 +348,22 @@ namespace Tnb.WarehouseMgr WmsPretaskH preTask = new(); preTask.org_id = _userManager.User.OrganizeId; - preTask.startlocation_id = sPoint?.location_id!; - preTask.startlocation_code = sPoint?.location_code!; - preTask.endlocation_id = ePoint?.location_id!; - preTask.endlocation_code = ePoint?.location_code!; + preTask.startlocation_id = sPoint?.location_id ?? string.Empty; + preTask.startlocation_code = sPoint?.location_code ?? string.Empty; + preTask.endlocation_id = ePoint?.location_id ?? string.Empty; + preTask.endlocation_code = ePoint?.location_code ?? string.Empty; preTask.start_floor = sPoint?.floor.ToString(); preTask.end_floor = ePoint?.floor.ToString(); preTask.bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult(); preTask.status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID; - preTask.biz_type = instock.biz_type; + preTask.biz_type = instock?.biz_type ?? string.Empty; preTask.task_type = WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID; - preTask.carry_id = instock.carry_id!; - preTask.carry_code = instock.carry_code!; - preTask.area_id = sPoint?.area_id!; + preTask.carry_id = instock?.carry_id ?? string.Empty; + preTask.carry_code = instock?.carry_code ?? string.Empty; + preTask.area_id = sPoint?.area_id ?? string.Empty; preTask.area_code = it.Key; - preTask.require_id = instock.id; - preTask.require_code = instock.bill_code; + preTask.require_id = instock?.id ?? string.Empty; + preTask.require_code = instock?.bill_code ?? string.Empty; preTask.create_id = _userManager.UserId; preTask.create_time = DateTime.Now; return preTask; diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPretaskService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPretaskService.cs new file mode 100644 index 00000000..d8668c42 --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPretaskService.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading.Tasks; +using JNPF.VisualDev; +using NPOI.SS.Formula.Functions; +using SqlSugar; +using Tnb.BasicData.Entities; +using Tnb.WarehouseMgr.Entities; + +namespace Tnb.WarehouseMgr +{ + [OverideVisualDev(ModuleConsts.MODULE_WMSPRETASK_ID)] + public class WmsPretaskService : TaskManagerDelBase + { + public WmsPretaskService(ISqlSugarRepository repository) : base(repository.AsSugarClient()) + { + + } + } +} diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs index 79fff1cd..fbfbc76b 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs @@ -290,7 +290,7 @@ namespace Tnb.WarehouseMgr // isOk = row > 0; //} //判断当前载具是否为料架,如果是料架 清空所有料架/料箱数据, - if (carry.carrystd_id == WmsWareHouseConst.CARRY_LJSTD_ID) + if (carry.carrystd_id == WmsWareHouseConst.CARRY_LJSTD_ID && carryMIds?.Count > 0) { var carrys = await _db.Queryable().Where(it => carryMIds.Contains(it.id)).ToListAsync(); carrys.Add(carry); @@ -325,7 +325,7 @@ namespace Tnb.WarehouseMgr public async Task MESKittingOutStk(List input) { var isSuccessFul = false; - if (input.IsNull()) throw new ArgumentNullException("input"); + if (input.IsNull()) throw new ArgumentNullException(nameof(input)); try { From 2509eb739dd4c90cb645cd6767b572fd7649399b Mon Sep 17 00:00:00 2001 From: FanLian Date: Mon, 17 Jul 2023 17:06:57 +0800 Subject: [PATCH 03/32] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AD=98=E5=82=A8?= =?UTF-8?q?=E5=BA=93=E4=BD=8D=E5=88=A4=E6=96=AD=EF=BC=8C=E9=99=90=E5=88=B6?= =?UTF-8?q?=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Tnb.WarehouseMgr/WmsEmptyOutstockService .cs | 4 ++-- WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs | 2 +- WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs | 2 +- .../Tnb.WarehouseMgr/WmskittingOutService.cs | 12 +++++++++--- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs index 63f2391c..336f4758 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs @@ -171,7 +171,7 @@ namespace Tnb.WarehouseMgr it => new BasLocation { is_lock = 1 }); } } - else + else { throw new AppFriendlyException("无可出库的空载具或目标库位不存在或者目标库位被锁", 500); } @@ -226,7 +226,7 @@ namespace Tnb.WarehouseMgr if (input.IsNull()) throw new ArgumentNullException("input"); try { - var location = await _db.Queryable().SingleAsync(it => it.location_code == input.location_code); + var location = await _db.Queryable().SingleAsync(it => it.location_code == input.location_code && it.is_type != EnumLocationType.存储库位.ToString()); var dic = new Dictionary(); dic[nameof(WmsEmptyOutstockH.id)] = SnowflakeIdHelper.NextId(); dic[nameof(WmsEmptyOutstockH.org_id)] = input.org_id; diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs index 9a5da81b..f1c685d6 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs @@ -270,7 +270,7 @@ namespace Tnb.WarehouseMgr //入库申请条码明细表 List instockcodes = input.instockcodes.Adapt>(); - var loc = await _db.Queryable().SingleAsync(it => it.location_code == input.instock.location_code); + var loc = await _db.Queryable().SingleAsync(it => it.location_code == input.instock.location_code && it.is_type != EnumLocationType.存储库位.ToString()); var carry = await _db.Queryable().SingleAsync(it => it.carry_code == input.instock.carry_code); //如果数据不全, if (carry.IsNull() || loc.IsNull() || instockds?.Count < 1 || instockcodes?.Count < 1) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs index 357de608..b2f552c0 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs @@ -316,7 +316,7 @@ namespace Tnb.WarehouseMgr //出库申请明细表 List outstockDs = input.outstockDs.Adapt>(); - var location = await _db.Queryable().SingleAsync(it => it.location_code == input.outstock.location_code); + var location = await _db.Queryable().SingleAsync(it => it.location_code == input.outstock.location_code && it.is_type != EnumLocationType.存储库位.ToString()); //如果数据不全, if (location.IsNull() || outstockDs?.Count < 1) { diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs index 79fff1cd..71fb5512 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs @@ -13,6 +13,7 @@ using JNPF.Common.Enums; using JNPF.Common.Extension; using JNPF.Common.Security; using JNPF.FriendlyException; +using JNPF.LinqBuilder; using JNPF.Logging; using JNPF.Systems.Interfaces.System; using Mapster; @@ -70,20 +71,25 @@ namespace Tnb.WarehouseMgr // var set = true ; 如果有 把set修改为false var items = await _db.Queryable().Where(it => it.status == WmsWareHouseConst.BILLSTATUS_CALLED_ID).ToListAsync(); var isCalled = items?.Count > 0; + if (kittingOuts?.Count > 0) { foreach (var ko in kittingOuts) { + //a.carrystd_id == WmsWareHouseConst.CARRY_LJSTD_ID + + Expression> whereExp = (ko.carry_id != null) ? a=>a.id == ko.carry_id : a => a.carrystd_id == WmsWareHouseConst.CARRY_LJSTD_ID; + var carrys = await _db.Queryable() .InnerJoin((a, b) => a.collocation_scheme_id == b.id) - .Where(a => a.collocation_scheme_id == ko.collocation_scheme_id && a.is_lock == 0) + .Where(whereExp.And(a => a.collocation_scheme_id == ko.collocation_scheme_id && a.is_lock == 0)) .OrderBy((a, b) => b.seq) .ToListAsync(); if (carrys?.Count > 0) { var firstCarry = carrys.FirstOrDefault(); GenPreTaskUpInput genPreTaskInput = new() { CarryId = firstCarry?.id }; - await _warehouseService.GenInStockTaskHandleAfter(genPreTaskInput, it => new WmsCarryH { is_lock = 1 }, null!); + await _warehouseService.GenInStockTaskHandleAfter(genPreTaskInput, it => new WmsCarryH { is_lock = 1 , out_status = EnumOutStatus.全部出.ToString()}, null!); ko.status = WmsWareHouseConst.BILLSTATUS_TOBESHIPPED_ID; ko.carry_id = firstCarry?.id; ko.carry_code = firstCarry?.carry_code; @@ -185,7 +191,7 @@ namespace Tnb.WarehouseMgr preTask.bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult(); preTask.status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID; preTask.biz_type = ko.biz_type; - preTask.task_type = WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID; + preTask.task_type = WmsWareHouseConst.WMS_PRETASK_OUTSTOCK_TYPE_ID; preTask.carry_id = ko!.carry_id!; preTask.carry_code = ko!.carry_code!; preTask.area_id = sPoint?.area_id!; From 193da3ac1b0f08e5e574d4194566e77d7b3c4bef Mon Sep 17 00:00:00 2001 From: FanLian Date: Mon, 17 Jul 2023 17:07:06 +0800 Subject: [PATCH 04/32] 1 --- WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs index f1c685d6..ce972d06 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs @@ -270,7 +270,7 @@ namespace Tnb.WarehouseMgr //入库申请条码明细表 List instockcodes = input.instockcodes.Adapt>(); - var loc = await _db.Queryable().SingleAsync(it => it.location_code == input.instock.location_code && it.is_type != EnumLocationType.存储库位.ToString()); + var loc = await _db.Queryable().FirstAsync(it => it.location_code == input.instock.location_code && it.is_type != EnumLocationType.存储库位.ToString()); var carry = await _db.Queryable().SingleAsync(it => it.carry_code == input.instock.carry_code); //如果数据不全, if (carry.IsNull() || loc.IsNull() || instockds?.Count < 1 || instockcodes?.Count < 1) From c92dbc3397087199a81e9e8ce4b846bdcea6ab4b Mon Sep 17 00:00:00 2001 From: taomin0419 <865692298@qq.com> Date: Mon, 17 Jul 2023 17:39:02 +0800 Subject: [PATCH 05/32] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E4=B8=80=E6=AC=A1?= =?UTF-8?q?=E5=90=8C=E6=97=B6=E5=A4=84=E7=90=86=E5=A4=9A=E4=B8=AAupdate/pr?= =?UTF-8?q?ogress=E5=86=B2=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WarehouseMgr/Tnb.WarehouseMgr/WmsCarryService.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryService.cs index 86984f8b..2e8b719b 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryService.cs @@ -172,18 +172,19 @@ namespace Tnb.WarehouseMgr carryObj.collocation_scheme_code = null; carryObj.source_id = null; carryObj.source_code = null; - row = await _db.Updateable(carryObj).ExecuteCommandAsync(); + row = await _db.CopyNew().Updateable(carryObj).ExecuteCommandAsync(); //删除对应明细表 //删除载具明细 - await _db.Deleteable().Where(it => it.carry_id == carryObj.id).ExecuteCommandHasChangeAsync(); + await _db.CopyNew().Deleteable().Where(it => it.carry_id == carryObj.id).ExecuteCommandHasChangeAsync(); //删除载具分拣物料明细 - await _db.Deleteable().Where(it => it.carry_id == carryObj.id).ExecuteCommandHasChangeAsync(); + await _db.CopyNew().Deleteable().Where(it => it.carry_id == carryObj.id).ExecuteCommandHasChangeAsync(); //删除载具条码 - await _db.Deleteable().Where(it => it.carry_id == carryObj.id).ExecuteCommandHasChangeAsync(); + await _db.CopyNew().Deleteable().Where(it => it.carry_id == carryObj.id).ExecuteCommandHasChangeAsync(); } - catch (Exception) + catch (Exception ex) { - + Log.Error("更新空载具出错",ex); + throw; } return row; } From 919af3542c768551a3a0c588a38d3dea79ffc130 Mon Sep 17 00:00:00 2001 From: FanLian Date: Tue, 18 Jul 2023 09:10:57 +0800 Subject: [PATCH 06/32] =?UTF-8?q?=E6=B3=A8=E9=87=8A=E5=92=8C=E6=8A=A5?= =?UTF-8?q?=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Tnb.WarehouseMgr/WmsCarryQueryService.cs | 2 +- .../WmsEmptyOutstockService .cs | 32 +++--- .../Tnb.WarehouseMgr/WmsInStockService.cs | 8 +- .../Tnb.WarehouseMgr/WmsOutStockService.cs | 6 +- .../WmsPDAEmptyOutstockService .cs | 102 ++++++++++-------- .../Tnb.WarehouseMgr/WmskittingOutService.cs | 42 ++++---- 6 files changed, 103 insertions(+), 89 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryQueryService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryQueryService.cs index fefe2f4a..c76028c8 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryQueryService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryQueryService.cs @@ -72,7 +72,7 @@ namespace Tnb.WarehouseMgr data.wmsCarryCodes = carryCodes.Adapt>(); } - catch (Exception ex) + catch (Exception) { await _db.Ado.RollbackTranAsync(); //return await ToApiResult(JNPF.Common.Enums.HttpStatusCode.InternalServerError, ex.Message); diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs index 336f4758..319031d9 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs @@ -58,12 +58,12 @@ namespace Tnb.WarehouseMgr _wareHouseService = wareHouseService; _userManager = userManager; _billRullService = billRullService; - OverideFuncs.CreateAsync = PDAWmsEmptyOut; + OverideFuncs.CreateAsync = WmsEmptyOut; } - private async Task PDAWmsEmptyOut(VisualDevModelDataCrInput input) + private async Task WmsEmptyOut(VisualDevModelDataCrInput input) { try @@ -226,24 +226,26 @@ namespace Tnb.WarehouseMgr if (input.IsNull()) throw new ArgumentNullException("input"); try { - var location = await _db.Queryable().SingleAsync(it => it.location_code == input.location_code && it.is_type != EnumLocationType.存储库位.ToString()); - var dic = new Dictionary(); - dic[nameof(WmsEmptyOutstockH.id)] = SnowflakeIdHelper.NextId(); - dic[nameof(WmsEmptyOutstockH.org_id)] = input.org_id; - dic[nameof(WmsEmptyOutstockH.location_id)] = location.id; - dic[nameof(WmsEmptyOutstockH.carrystd_id)] = input.carrystd_id; - dic[nameof(WmsEmptyOutstockH.bill_code)] = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_EMPTYOUTSTK_ENCODE).GetAwaiter().GetResult(); - dic[nameof(WmsEmptyOutstockH.status)] = WmsWareHouseConst.BILLSTATUS_ADD_ID; - dic[nameof(WmsEmptyOutstockH.qty)] = input.qty; - dic[nameof(WmsEmptyOutstockH.biz_type)] = WmsWareHouseConst.BIZTYPE_WMSEPTYOUTSTK_ID; - dic[nameof(WmsEmptyOutstockH.create_id)] = input.create_id; - dic[nameof(WmsEmptyOutstockH.create_time)] = DateTime.Now; + var location = await _db.Queryable().SingleAsync(it => it.location_code == input.location_code && it.is_type != EnumLocationType.存储库位.ToString()) ?? throw new AppFriendlyException("无此库位或为存储库位",500); + Dictionary dic = new() + { + [nameof(WmsEmptyOutstockH.id)] = SnowflakeIdHelper.NextId(), + [nameof(WmsEmptyOutstockH.org_id)] = input.org_id, + [nameof(WmsEmptyOutstockH.location_id)] = location.id, + [nameof(WmsEmptyOutstockH.carrystd_id)] = input.carrystd_id, + [nameof(WmsEmptyOutstockH.bill_code)] = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_EMPTYOUTSTK_ENCODE).GetAwaiter().GetResult(), + [nameof(WmsEmptyOutstockH.status)] = WmsWareHouseConst.BILLSTATUS_ADD_ID, + [nameof(WmsEmptyOutstockH.qty)] = input.qty, + [nameof(WmsEmptyOutstockH.biz_type)] = WmsWareHouseConst.BIZTYPE_WMSEPTYOUTSTK_ID, + [nameof(WmsEmptyOutstockH.create_id)] = input.create_id, + [nameof(WmsEmptyOutstockH.create_time)] = DateTime.Now + }; VisualDevModelDataCrInput visualDevModelDataCrInput = new VisualDevModelDataCrInput { data = dic, }; - await PDAWmsEmptyOut(visualDevModelDataCrInput); + await WmsEmptyOut(visualDevModelDataCrInput); } catch (Exception ex) { diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs index 0468a35d..5a538235 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs @@ -272,11 +272,11 @@ namespace Tnb.WarehouseMgr var loc = await _db.Queryable().FirstAsync(it => it.location_code == input.instock.location_code && it.is_type != EnumLocationType.存储库位.ToString()); var carry = await _db.Queryable().SingleAsync(it => it.carry_code == input.instock.carry_code); - //如果数据不全, + //如果数据不全或有误, if (carry.IsNull() || loc.IsNull() || instockds?.Count < 1 || instockcodes?.Count < 1) { - //报错, 提示数据不全。 - throw new AppFriendlyException("数据不全!", 500); + //报错, 提示数据不全或有误。 + throw new AppFriendlyException("数据不全或有误!", 500); } // 生成入库申请数据,添加其他数据 主表 instock.id = SnowflakeIdHelper.NextId(); @@ -330,7 +330,7 @@ namespace Tnb.WarehouseMgr //入库取终点 //出库起点 var inStockStrategyInput = new InStockStrategyQuery { warehouse_id = instock?.warehouse_id!, Size = 1 }; var endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput); - WmsPointH sPoint = await _db.Queryable().FirstAsync(it => it.location_id == instock.location_id); + WmsPointH sPoint = await _db.Queryable().FirstAsync(it => it.location_id == instock.location_id); WmsPointH ePoint = await _db.Queryable().FirstAsync(it => it.location_id == endLocations[0].id); diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs index b2f552c0..f4b9be85 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs @@ -317,11 +317,11 @@ namespace Tnb.WarehouseMgr List outstockDs = input.outstockDs.Adapt>(); var location = await _db.Queryable().SingleAsync(it => it.location_code == input.outstock.location_code && it.is_type != EnumLocationType.存储库位.ToString()); - //如果数据不全, + //如果数据不全或有误, if (location.IsNull() || outstockDs?.Count < 1) { - //报错, 提示数据不全。 - throw new AppFriendlyException("数据不全!", 500); + //报错, 提示数据不全或有误。 + throw new AppFriendlyException("数据不全或有误!", 500); } // 生成出库申请数据,添加其他数据 主表 outstock.id = SnowflakeIdHelper.NextId(); diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyOutstockService .cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyOutstockService .cs index a38bbb9e..cae51fdc 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyOutstockService .cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyOutstockService .cs @@ -106,24 +106,26 @@ namespace Tnb.WarehouseMgr { var sPoint = it.FirstOrDefault(); var ePoint = it.LastOrDefault(); - - WmsPretaskH preTask = new(); - preTask.org_id = _userManager.User.OrganizeId; - preTask.startlocation_id = sPoint?.location_id!; - preTask.startlocation_code = sPoint?.location_code!; - preTask.endlocation_id = ePoint?.location_id!; - preTask.endlocation_code = ePoint?.location_code!; - preTask.start_floor = sPoint?.floor.ToString(); - preTask.end_floor = ePoint?.floor.ToString(); - preTask.bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult(); - preTask.status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID; - preTask.biz_type = WmsWareHouseConst.BIZTYPE_WMSEPTYOUTSTK_ID; - preTask.task_type = WmsWareHouseConst.WMS_PRETASK_OUTSTOCK_TYPE_ID; - preTask.carry_id = carrys![i].id; - preTask.carry_code = carrys![i].carry_code; - preTask.area_id = sPoint?.area_id!; - preTask.area_code = it.Key; - preTask.require_id = input.data["ReturnIdentity"].ToString(); + //生成预任务 + WmsPretaskH preTask = new() + { + org_id = _userManager.User.OrganizeId, + startlocation_id = sPoint?.location_id!, + startlocation_code = sPoint?.location_code!, + endlocation_id = ePoint?.location_id!, + endlocation_code = ePoint?.location_code!, + start_floor = sPoint?.floor.ToString(), + end_floor = ePoint?.floor.ToString(), + bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult(), + status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID, + biz_type = WmsWareHouseConst.BIZTYPE_WMSEPTYOUTSTK_ID, + task_type = WmsWareHouseConst.WMS_PRETASK_OUTSTOCK_TYPE_ID, + carry_id = carrys![i].id, + carry_code = carrys![i].carry_code, + area_id = sPoint?.area_id!, + area_code = it.Key, + require_id = input.data["ReturnIdentity"].ToString() + }; preTask.require_code = input.data[nameof(preTask.bill_code)]?.ToString()!; preTask.create_id = _userManager.UserId; preTask.create_time = DateTime.Now; @@ -139,39 +141,47 @@ namespace Tnb.WarehouseMgr } if (isOk) { - var preTaskUpInput = new GenPreTaskUpInput(); - preTaskUpInput.RquireId = input.data["ReturnIdentity"].ToString()!; - preTaskUpInput.CarryId = carrys![i].id; - preTaskUpInput.CarryStartLocationId = points.FirstOrDefault()!.location_id!; - preTaskUpInput.CarryStartLocationCode = points.FirstOrDefault()!.location_code!; - preTaskUpInput.LocationIds = points.Select(x => x.location_id).ToList()!; + //生成预任务上传输入 + GenPreTaskUpInput preTaskUpInput = new() + { + RquireId = input.data["ReturnIdentity"].ToString()!, + CarryId = carrys![i].id, + CarryStartLocationId = points.FirstOrDefault()!.location_id!, + CarryStartLocationCode = points.FirstOrDefault()!.location_code!, + LocationIds = points.Select(x => x.location_id).ToList()! + }; //更新明细表 - WmsEmptyOutstockD wmsEmptyOutstockD = new(); - wmsEmptyOutstockD.id = SnowflakeIdHelper.NextId(); - wmsEmptyOutstockD.bill_id = preTaskUpInput.RquireId; - wmsEmptyOutstockD.biz_type = WmsWareHouseConst.BIZTYPE_WMSEPTYOUTSTK_ID; - wmsEmptyOutstockD.location_id = ePoint!.location_id!; - wmsEmptyOutstockD.status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID; - wmsEmptyOutstockD.carry_id = carrys[i].id; - wmsEmptyOutstockD.carry_code = carrys[i].carry_code; - wmsEmptyOutstockD.create_id = _userManager.UserId; - wmsEmptyOutstockD.create_time = DateTime.Now; + WmsEmptyOutstockD wmsEmptyOutstockD = new() + { + id = SnowflakeIdHelper.NextId(), + bill_id = preTaskUpInput.RquireId, + biz_type = WmsWareHouseConst.BIZTYPE_WMSEPTYOUTSTK_ID, + location_id = ePoint!.location_id!, + status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID, + carry_id = carrys[i].id, + carry_code = carrys[i].carry_code, + create_id = _userManager.UserId, + create_time = DateTime.Now + }; await _db.Insertable(wmsEmptyOutstockD) .ExecuteCommandAsync(); - WmsHandleH handleH = new(); - handleH.org_id = _userManager.User.OrganizeId; - handleH.startlocation_id = carrys?[i].location_id!; - handleH.endlocation_id = ePoint!.location_id!; - handleH.bill_code = input.data[nameof(WmsHandleH.bill_code)]?.ToString()!; - handleH.biz_type = input.data[nameof(WmsHandleH.biz_type)]?.ToString()!; - handleH.carry_id = input.data[nameof(WmsHandleH.carry_id)]?.ToString()!; - handleH.carry_code = input.data[nameof(WmsHandleH.carry_code)]?.ToString()!; - handleH.require_id = input.data["ReturnIdentity"].ToString(); - handleH.require_code = input.data[nameof(WmsHandleH.bill_code)]?.ToString()!; - handleH.create_id = _userManager.UserId; - handleH.create_time = DateTime.Now; + //生成操作记录表 + WmsHandleH handleH = new() + { + org_id = _userManager.User.OrganizeId, + startlocation_id = carrys?[i].location_id!, + endlocation_id = ePoint!.location_id!, + bill_code = input.data[nameof(WmsHandleH.bill_code)]?.ToString()!, + biz_type = input.data[nameof(WmsHandleH.biz_type)]?.ToString()!, + carry_id = input.data[nameof(WmsHandleH.carry_id)]?.ToString()!, + carry_code = input.data[nameof(WmsHandleH.carry_code)]?.ToString()!, + require_id = input.data["ReturnIdentity"].ToString(), + require_code = input.data[nameof(WmsHandleH.bill_code)]?.ToString()!, + create_id = _userManager.UserId, + create_time = DateTime.Now + }; preTaskUpInput.PreTaskRecord = handleH; //根据空载具出库Id,回更单据状态 await _db.Updateable().SetColumns(it => new WmsEmptyOutstockH { status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => it.id == preTaskUpInput.RquireId).ExecuteCommandAsync(); diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs index fb0b41d8..eed1bc1c 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs @@ -180,26 +180,28 @@ namespace Tnb.WarehouseMgr var sPoint = it.FirstOrDefault(); var ePoint = it.LastOrDefault(); - WmsPretaskH preTask = new(); - preTask.org_id = _userManager.User.OrganizeId; - preTask.startlocation_id = sPoint?.location_id!; - preTask.startlocation_code = sPoint?.location_code!; - preTask.endlocation_id = ePoint?.location_id!; - preTask.endlocation_code = ePoint?.location_code!; - preTask.start_floor = sPoint?.floor.ToString(); - preTask.end_floor = ePoint?.floor.ToString(); - preTask.bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult(); - preTask.status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID; - preTask.biz_type = ko.biz_type; - preTask.task_type = WmsWareHouseConst.WMS_PRETASK_OUTSTOCK_TYPE_ID; - preTask.carry_id = ko!.carry_id!; - preTask.carry_code = ko!.carry_code!; - preTask.area_id = sPoint?.area_id!; - preTask.area_code = it.Key; - preTask.require_id = ko.id; - preTask.require_code = ko.bill_code; - preTask.create_id = _userManager.UserId; - preTask.create_time = DateTime.Now; + WmsPretaskH preTask = new() + { + org_id = _userManager.User.OrganizeId, + startlocation_id = sPoint?.location_id!, + startlocation_code = sPoint?.location_code!, + endlocation_id = ePoint?.location_id!, + endlocation_code = ePoint?.location_code!, + start_floor = sPoint?.floor.ToString(), + end_floor = ePoint?.floor.ToString(), + bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult(), + status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID, + biz_type = ko.biz_type, + task_type = WmsWareHouseConst.WMS_PRETASK_OUTSTOCK_TYPE_ID, + carry_id = ko!.carry_id!, + carry_code = ko!.carry_code!, + area_id = sPoint?.area_id!, + area_code = it.Key, + require_id = ko.id, + require_code = ko.bill_code, + create_id = _userManager.UserId, + create_time = DateTime.Now + }; return preTask; }).ToList(); if (loc.is_sign == 0) From ecca272e76781186085b377c6d5a34229f9138f6 Mon Sep 17 00:00:00 2001 From: FanLian Date: Tue, 18 Jul 2023 09:11:22 +0800 Subject: [PATCH 07/32] 1 --- .../Tnb.WarehouseMgr/WmsInStockService.cs | 56 ++++++++++--------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs index 5a538235..e0b3ecb9 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs @@ -346,26 +346,28 @@ namespace Tnb.WarehouseMgr var sPoint = it.FirstOrDefault(); var ePoint = it.LastOrDefault(); - WmsPretaskH preTask = new(); - preTask.org_id = _userManager.User.OrganizeId; - preTask.startlocation_id = sPoint?.location_id ?? string.Empty; - preTask.startlocation_code = sPoint?.location_code ?? string.Empty; - preTask.endlocation_id = ePoint?.location_id ?? string.Empty; - preTask.endlocation_code = ePoint?.location_code ?? string.Empty; - preTask.start_floor = sPoint?.floor.ToString(); - preTask.end_floor = ePoint?.floor.ToString(); - preTask.bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult(); - preTask.status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID; - preTask.biz_type = instock?.biz_type ?? string.Empty; - preTask.task_type = WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID; - preTask.carry_id = instock?.carry_id ?? string.Empty; - preTask.carry_code = instock?.carry_code ?? string.Empty; - preTask.area_id = sPoint?.area_id ?? string.Empty; - preTask.area_code = it.Key; - preTask.require_id = instock?.id ?? string.Empty; - preTask.require_code = instock?.bill_code ?? string.Empty; - preTask.create_id = _userManager.UserId; - preTask.create_time = DateTime.Now; + WmsPretaskH preTask = new() + { + org_id = _userManager.User.OrganizeId, + startlocation_id = sPoint?.location_id ?? string.Empty, + startlocation_code = sPoint?.location_code ?? string.Empty, + endlocation_id = ePoint?.location_id ?? string.Empty, + endlocation_code = ePoint?.location_code ?? string.Empty, + start_floor = sPoint?.floor.ToString(), + end_floor = ePoint?.floor.ToString(), + bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult(), + status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID, + biz_type = instock?.biz_type ?? string.Empty, + task_type = WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID, + carry_id = instock?.carry_id ?? string.Empty, + carry_code = instock?.carry_code ?? string.Empty, + area_id = sPoint?.area_id ?? string.Empty, + area_code = it.Key, + require_id = instock?.id ?? string.Empty, + require_code = instock?.bill_code ?? string.Empty, + create_id = _userManager.UserId, + create_time = DateTime.Now + }; return preTask; }).ToList(); //生成预任务条码信息 @@ -395,12 +397,14 @@ namespace Tnb.WarehouseMgr if (isOk) { - var preTaskUpInput = new GenPreTaskUpInput(); - preTaskUpInput.RquireId = instock?.id; - preTaskUpInput.CarryId = instock?.carry_id!; - preTaskUpInput.CarryStartLocationId = points.FirstOrDefault()?.location_id; - preTaskUpInput.CarryStartLocationCode = points.FirstOrDefault()?.location_code; - preTaskUpInput.LocationIds = (points?.Select(x => x.location_id)?.ToList() ?? Enumerable.Empty().ToList()) as List; + GenPreTaskUpInput preTaskUpInput = new() + { + RquireId = instock?.id, + CarryId = instock?.carry_id!, + CarryStartLocationId = points.FirstOrDefault()?.location_id, + CarryStartLocationCode = points.FirstOrDefault()?.location_code, + LocationIds = (points?.Select(x => x.location_id)?.ToList() ?? Enumerable.Empty().ToList()) as List + }; //创建预任务操作记录 var operBillId = string.Empty; From bfc948a718371b9adbcbb09095e4889fcb92b5d6 Mon Sep 17 00:00:00 2001 From: FanLian Date: Tue, 18 Jul 2023 09:15:50 +0800 Subject: [PATCH 08/32] =?UTF-8?q?=E9=87=8D=E5=91=BD=E5=90=8D=E5=8F=98?= =?UTF-8?q?=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs index eed1bc1c..ee1165c0 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs @@ -246,14 +246,14 @@ namespace Tnb.WarehouseMgr var carry = await _db.Queryable().SingleAsync(it => it.id == carryId); var kods = await _db.Queryable().Where(it => it.bill_id == input.requireId).ToListAsync(); //载具为料架时,取所有料箱的条码 - List carryMIds = new(); + List mCarryIds = new(); if (carry.carrystd_id == WmsWareHouseConst.CARRY_LJSTD_ID) { var carryDs = await _db.Queryable().Where(it => it.carry_id == carryId).ToListAsync(); - carryMIds = carryDs.Select(x => x.membercarry_id).ToList(); + mCarryIds = carryDs.Select(x => x.membercarry_id).ToList(); } //当前载具对应的所有条码插入 - Expression> whereExp = carryMIds?.Count > 0 ? a => carryMIds.Contains(a.carry_id) : a => a.carry_id == carryId; + Expression> whereExp = mCarryIds?.Count > 0 ? a => mCarryIds.Contains(a.carry_id) : a => a.carry_id == carryId; var carryCodes = await _db.Queryable().Where(whereExp).ToListAsync(); var kittingoutCodes = carryCodes.Adapt>(); @@ -298,9 +298,9 @@ namespace Tnb.WarehouseMgr // isOk = row > 0; //} //判断当前载具是否为料架,如果是料架 清空所有料架/料箱数据, - if (carry.carrystd_id == WmsWareHouseConst.CARRY_LJSTD_ID && carryMIds?.Count > 0) + if (carry.carrystd_id == WmsWareHouseConst.CARRY_LJSTD_ID && mCarryIds?.Count > 0) { - var carrys = await _db.Queryable().Where(it => carryMIds.Contains(it.id)).ToListAsync(); + var carrys = await _db.Queryable().Where(it => mCarryIds.Contains(it.id)).ToListAsync(); carrys.Add(carry); if (carrys?.Count > 0) { From bbce3accf3981bcfe9fd54ac5020b3ed8a6d409c Mon Sep 17 00:00:00 2001 From: zhoukeda <1315948824@qq.com> Date: Tue, 18 Jul 2023 10:32:23 +0800 Subject: [PATCH 09/32] bug --- .../Tnb.ProductionMgr/PrdMoTaskService.cs | 2 +- .../Tnb.ProductionMgr/PrdTaskManageService.cs | 32 +++++++++++-------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs index f73b3872..4b8074d5 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs @@ -515,7 +515,7 @@ namespace Tnb.ProductionMgr [HttpGet] public async Task GetUnSchedulingList([FromQuery] VisualDevModelListQueryInput input) { - Dictionary queryJson = input.queryJson!=null ? JsonConvert.DeserializeObject>(input.queryJson) : null; + Dictionary queryJson = !string.IsNullOrEmpty(input.queryJson) ? JsonConvert.DeserializeObject>(input.queryJson) : new Dictionary(); List moStatusList = new List(); if (queryJson!=null && queryJson.ContainsKey("mo_stauts")) { diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs index ff33e912..c7cb7feb 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs @@ -23,6 +23,7 @@ using Microsoft.AspNetCore.Mvc; using DbModels; using JNPF.Common.Extension; using JNPF.Common.Filter; +using JNPF.Common.Security; using Tnb.ProductionMgr.Entities.Dto.PrdManage; using NPOI.OpenXmlFormats; using JNPF.Systems.Entitys.Permission; @@ -116,26 +117,31 @@ namespace Tnb.ProductionMgr private async Task GetList(VisualDevModelListQueryInput input) { var db = _repository.AsSugarClient(); - Dictionary queryJson = input.queryJson!=null ? JsonConvert.DeserializeObject>(input.queryJson) : null; + Dictionary queryJson = !string.IsNullOrEmpty(input.queryJson) ? JsonConvert.DeserializeObject>(input.queryJson) : new Dictionary(); string moTaskCode = queryJson!=null && queryJson.ContainsKey("mo_task_code") ? queryJson["mo_task_code"].ToString() : ""; - Dictionary dic = new Dictionary() + Dictionary dic = await _dictionaryDataService.GetDicByKey(DictConst.TaskStatus); + + DateTime[] planStartDateArr = null; + DateTime[] planEndDateArr = null; + if (queryJson.TryGetValue("plan_start_date", out var value1)) { - [DictConst.ToBeStartedEnCode] = "待开工", - [DictConst.InProgressEnCode] = "进行中", - [DictConst.ClosedEnCode] = "关闭", - [DictConst.ComplatedEnCode] = "完工", - [DictConst.ToBeScheduledEncode] = "待排产", - [DictConst.MoStatusPauseCode] = "暂停", - [DictConst.MoStatusExceptionCode] = "异常", - [DictConst.MoStatusRevokeCode] = "撤销", - }; + planStartDateArr = value1.ToObject().Select(x=>x.TimeStampToDateTime()).ToArray(); + } + if (queryJson.TryGetValue("plan_end_date", out var value2)) + { + planEndDateArr = value2.ToObject().Select(x=>x.TimeStampToDateTime()).ToArray(); + } + + var result = await db.Queryable() .LeftJoin((a, b) => a.eqp_id == b.id) .LeftJoin((a, b, c) => a.material_id == c.id) .LeftJoin((a, b, c, d) => a.mold_id == d.id) - //.Where((a,b,c,d)=>(a.mo_task_status==DictConst.ToBeStartedEnCode || a.mo_task_status==DictConst.InProgressEnCode || a.mo_task_status==DictConst.MoStatusExceptionCode)) + .Where((a,b,c,d)=>(a.mo_task_status==DictConst.ToBeStartedEnCode || a.mo_task_status==DictConst.InProgressEnCode || a.mo_task_status==DictConst.MoStatusExceptionCode || a.mo_task_status==DictConst.MoStatusPauseCode || a.mo_task_status==DictConst.ComplatedEnCode)) .Where((a,b,c,d)=>a.schedule_type==1) .WhereIF(!string.IsNullOrEmpty(moTaskCode),(a,b,c,d)=>a.mo_task_code.Contains(moTaskCode)) + .WhereIF(planStartDateArr!=null, (a, b, c, d) => a.estimated_start_date>=planStartDateArr[0] && a.estimated_start_date<=planStartDateArr[1]) + .WhereIF(planEndDateArr!=null, (a, b, c, d) => a.estimated_end_date>=planEndDateArr[0] && a.estimated_end_date<=planEndDateArr[1]) .OrderByDescending((a, b, c, d) => a.create_time) .Select((a, b, c, d) => new PrdTaskManageListOutput() { @@ -152,7 +158,7 @@ namespace Tnb.ProductionMgr schedule_type = a.schedule_type.ToString() }) - .Mapper(x=>x.mo_task_status=dic[x.mo_task_status]) + .Mapper(x=>x.mo_task_status=dic[x.mo_task_status].ToString()) .ToPagedListAsync(input.currentPage, input.pageSize); return PageResult.SqlSugarPageResult(result); } From 81f7672980a7579b780b6661a6e0c91a472584bc Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 18 Jul 2023 10:38:44 +0800 Subject: [PATCH 10/32] =?UTF-8?q?=E6=96=B0=E5=A2=9E=EF=BC=8C=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E7=9B=AE=E6=A0=87=E5=BA=93=E4=BD=8D=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E6=94=BE=E7=BD=AE=E5=BD=93=E5=89=8D=E8=BD=BD?= =?UTF-8?q?=E5=85=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entity/BasLocation.cs | 4 +++ .../Tnb.WarehouseMgr/BaseWareHouseService.cs | 28 ++++++++++++++++++- .../Tnb.WarehouseMgr/WmsSetSortingService.cs | 23 +++++++++------ 3 files changed, 46 insertions(+), 9 deletions(-) diff --git a/BasicData/Tnb.BasicData.Entities/Entity/BasLocation.cs b/BasicData/Tnb.BasicData.Entities/Entity/BasLocation.cs index 4a348d76..9c902bc1 100644 --- a/BasicData/Tnb.BasicData.Entities/Entity/BasLocation.cs +++ b/BasicData/Tnb.BasicData.Entities/Entity/BasLocation.cs @@ -75,6 +75,10 @@ public partial class BasLocation : BaseEntity /// 修改用户 /// public string? modify_id { get; set; } + /// + /// 载具规格分类Id + /// + public string carrystd_id { get; set; } /// /// 修改时间 diff --git a/WarehouseMgr/Tnb.WarehouseMgr/BaseWareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/BaseWareHouseService.cs index bb3d2c6f..aa747ad7 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/BaseWareHouseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/BaseWareHouseService.cs @@ -15,7 +15,9 @@ using JNPF.DynamicApiController; using JNPF.Systems.Interfaces.System; using JNPF.VisualDev; using Microsoft.AspNetCore.Mvc; +using Newtonsoft.Json.Linq; using SqlSugar; +using Tnb.BasicData.Entities; using Tnb.WarehouseMgr.Entities; using Tnb.WarehouseMgr.Entities.Attributes; using Tnb.WarehouseMgr.Entities.Consts; @@ -47,8 +49,32 @@ namespace Tnb.WarehouseMgr } } } + /// + /// 判断最终目标库位是否可以放置当前载具 + /// + /// 当前载具 + /// 目标库位 + /// + /// + [NonAction] + protected Task IsCarryAndLocationMatchByCarryStd(WmsCarryH carry, BasLocation locDest) + { + bool isMatch = false; + string errMessage = string.Empty; + if (carry == null) throw new ArgumentNullException(nameof(carry)); + if (locDest == null) throw new ArgumentNullException(nameof(locDest)); + if (!carry.carrystd_id.IsNullOrEmpty() && !locDest.carrystd_id.IsNullOrEmpty()) + { + var jsonArr = JArray.Parse(locDest.carrystd_id); + var locCarryStdArr = jsonArr.Select(x => x.ToObject()).ToArray(); + if (locCarryStdArr.Contains(carry.carrystd_id)) + { + isMatch = true; + } + } + return Task.FromResult(isMatch); + } - [NonAction] protected async Task DoUpdate(WareHouseUpInput input) { diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs index 282556f8..a2a3af29 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs @@ -52,6 +52,9 @@ namespace Tnb.WarehouseMgr [HttpPost] public async Task PackSortingByAdd(WmsCarryMat? carryMat) { + string firstLocationId = "27010980724501", secondLocationId = "27010987857941"; + var endLocation = await _db.Queryable().SingleAsync(it => it.id == secondLocationId); + var setSortings = await _db.Queryable() .Where(a => a.status == WmsWareHouseConst.BILLSTATUS_ADD_ID).OrderBy(a => a.seq) .ToListAsync(); @@ -61,9 +64,14 @@ namespace Tnb.WarehouseMgr { await _db.Ado.BeginTranAsync(); + var singleSorting = setSortings[^setSortings.Count]; + var curCarry = await _db.Queryable().SingleAsync(it => it.id == singleSorting.carry_id); + var isMatch = await IsCarryAndLocationMatchByCarryStd(curCarry, endLocation); + if (!isMatch) throw new AppFriendlyException("库位与载具规格不匹配", 500); + if (setSortings?.Count > 0 && !onFlag) { - var singleSorting = setSortings[^setSortings.Count]; + var setSortingDList = await _db.Queryable().Where(it => it.bill_id == singleSorting.id).ToListAsync(); if (setSortingDList?.Count > 0) { @@ -141,18 +149,18 @@ namespace Tnb.WarehouseMgr { List preTasks = new(); List locIds = new(); - string firstLocationId = "27010980724501", secondLocationId = "27010987857941"; + var mid = 6; if (carrys.Length > mid) { var leftCarrys = carrys[..mid]; var rightCarrys = carrys[mid..]; - await InnerGenPreTask(leftCarrys, locIds, firstLocationId, singleSorting.id, singleSorting.bill_code, preTasks); - await InnerGenPreTask(rightCarrys, locIds, secondLocationId, singleSorting.id, singleSorting.bill_code, preTasks); + await InnerGenPreTask(leftCarrys, locIds, firstLocationId, singleSorting.id, singleSorting.bill_code, preTasks, endLocation); + await InnerGenPreTask(rightCarrys, locIds, secondLocationId, singleSorting.id, singleSorting.bill_code, preTasks, endLocation); } else { - await InnerGenPreTask(carrys, locIds, firstLocationId, singleSorting.id, singleSorting.bill_code, preTasks); + await InnerGenPreTask(carrys, locIds, firstLocationId, singleSorting.id, singleSorting.bill_code, preTasks, endLocation); } List pretaskCodes = new(); foreach (var pt in preTasks) @@ -187,9 +195,8 @@ namespace Tnb.WarehouseMgr } } - private async Task InnerGenPreTask(WmsCarryH[] carrys, List locIds, string eLocationId, string requireId, string requireCode, List preTasks) + private async Task InnerGenPreTask(WmsCarryH[] carrys, List locIds, string eLocationId, string requireId, string requireCode, List preTasks, BasLocation endLocation) { - var loc = await _db.Queryable().SingleAsync(it => it.id == eLocationId); foreach (var carry in carrys) { WmsPointH sPoint = await _db.Queryable().FirstAsync(it => it.location_id == carry.location_id); @@ -232,7 +239,7 @@ namespace Tnb.WarehouseMgr }; return preTask; }).ToList(); - if (loc.is_sign == 0) + if (endLocation.is_sign == 0) { curPreTasks[^1].is_sign = 0; // 修改最后一个元素的是否签收值 } From 0daf7fe6632ebeed7515c089e3617f8487b691af Mon Sep 17 00:00:00 2001 From: FanLian Date: Tue, 18 Jul 2023 11:17:51 +0800 Subject: [PATCH 11/32] =?UTF-8?q?=E5=85=A5=E5=BA=93=E4=B8=9A=E5=8A=A1?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=BA=93=E4=BD=8D=E4=B8=8E=E8=BD=BD=E5=85=B7?= =?UTF-8?q?=E8=A7=84=E6=A0=BC=E5=85=B3=E8=81=94=E7=9A=84=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WmsCarryMoveInStockService.cs | 11 ++++++++-- .../WmsEmptyInstockService.cs | 20 +++++++++++++------ .../Tnb.WarehouseMgr/WmsInStockService.cs | 2 ++ .../WmsKittingInStkService.cs | 9 +++++++-- .../WmsPDACarryMoveInStockService.cs | 13 ++++++++---- .../WmsPDAEmptyInstockService.cs | 11 +++++++--- .../Tnb.WarehouseMgr/WmsPDAInbaleService.cs | 4 ++++ 7 files changed, 53 insertions(+), 17 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryMoveInStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryMoveInStockService.cs index 93da5a11..eb71689f 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryMoveInStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryMoveInStockService.cs @@ -66,8 +66,6 @@ namespace Tnb.WarehouseMgr { await _db.Ado.BeginTranAsync(); - VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_CARRYMOVEINSTOCK_ID, true); - await _runService.Create(templateEntity, input); //入库取终点 //出库起点 var inStockStrategyInput = new InStockStrategyQuery { warehouse_id = input.data[nameof(InStockStrategyQuery.warehouse_id)].ToString()!, Size = 1 }; var endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput); @@ -79,9 +77,18 @@ namespace Tnb.WarehouseMgr } if (endLocations?.Count > 0) { + var carry = await _db.Queryable().SingleAsync(it => it.id == input.data[nameof(WmsCarryD.carry_id)].ToString()); + var loc = await _db.Queryable().SingleAsync(it => it.id == endLocations[0].id); + var isMatch = await IsCarryAndLocationMatchByCarryStd(carry, loc); + if (!isMatch) throw new AppFriendlyException("库位与载具规格不匹配", 500); ePoint = await _db.Queryable().FirstAsync(it => it.location_id == endLocations[0].id); } + + VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_CARRYMOVEINSTOCK_ID, true); + await _runService.Create(templateEntity, input); + + if (sPoint != null && ePoint != null) { var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id); diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyInstockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyInstockService.cs index 1af501e8..0909866f 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyInstockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyInstockService.cs @@ -68,8 +68,6 @@ namespace Tnb.WarehouseMgr { await _db.Ado.BeginTranAsync(); - VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSEMPTYINSTOCK_ID, true); - await _runService.Create(templateEntity, input); //入库取终点 var inStockStrategyInput = new InStockStrategyQuery { warehouse_id = input.data[nameof(InStockStrategyQuery.warehouse_id)].ToString()!, Size = 1 }; var endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput); @@ -81,8 +79,16 @@ namespace Tnb.WarehouseMgr } if (endLocations?.Count > 0) { + var carry = await _db.Queryable().SingleAsync(it => it.id == input.data[nameof(WmsCarryD.carry_id)].ToString()); + var loc = await _db.Queryable().SingleAsync(it => it.id == endLocations[0].id); + var isMatch = await IsCarryAndLocationMatchByCarryStd(carry, loc); + if (!isMatch) throw new AppFriendlyException("库位与载具规格不匹配", 500); ePoint = await _db.Queryable().FirstAsync(it => it.location_id == endLocations[0].id); } + + //在线开发 + VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSEMPTYINSTOCK_ID, true); + await _runService.Create(templateEntity, input); if (sPoint != null && ePoint != null) { @@ -180,19 +186,21 @@ namespace Tnb.WarehouseMgr try { var carry = await _db.Queryable().SingleAsync(it => it.carry_code == input.carry_code); - var location = await _db.Queryable().SingleAsync(it => it.location_code == input.location_code); + var loc = await _db.Queryable().SingleAsync(it => it.location_code == input.location_code); + var isMatch = await IsCarryAndLocationMatchByCarryStd(carry, loc); + if (!isMatch) throw new AppFriendlyException("库位与载具规格不匹配", 500); var emptyInstock = await _db.Queryable().FirstAsync(it => it.carry_code == input.carry_code && it.status == WmsWareHouseConst.BILLSTATUS_ADD_ID); if (emptyInstock != null) { - return ToApiResult(HttpStatusCode.InternalServerError, $"空载具{emptyInstock.carry_code},预任务已生成"); + return isSuccessful; } - if (carry != null && location != null) + if (carry != null && loc != null) { var cols = new List(); var dic = new Dictionary(); dic[nameof(WmsEmptyInstock.id)] = SnowflakeIdHelper.NextId(); dic[nameof(WmsEmptyInstock.org_id)] = input.org_id ?? _userManager.User.OrganizeId; - dic[nameof(WmsEmptyInstock.location_id)] = location.id; + dic[nameof(WmsEmptyInstock.location_id)] = loc.id; dic[nameof(WmsEmptyInstock.bill_code)] = await _billRullService.GetBillNumber(WmsWareHouseConst.WMS_EMPTYINSTK_ENCODE); dic[nameof(WmsEmptyInstock.status)] = WmsWareHouseConst.BILLSTATUS_ADD_ID; dic[nameof(WmsEmptyInstock.carry_id)] = carry.id; diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs index e0b3ecb9..2915a375 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs @@ -272,6 +272,8 @@ namespace Tnb.WarehouseMgr var loc = await _db.Queryable().FirstAsync(it => it.location_code == input.instock.location_code && it.is_type != EnumLocationType.存储库位.ToString()); var carry = await _db.Queryable().SingleAsync(it => it.carry_code == input.instock.carry_code); + var isMatch = await IsCarryAndLocationMatchByCarryStd(carry, loc); + if (!isMatch) throw new AppFriendlyException("库位与载具规格不匹配", 500); //如果数据不全或有误, if (carry.IsNull() || loc.IsNull() || instockds?.Count < 1 || instockcodes?.Count < 1) { diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsKittingInStkService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsKittingInStkService.cs index 7ad379ee..0a37f8c1 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsKittingInStkService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsKittingInStkService.cs @@ -67,8 +67,6 @@ namespace Tnb.WarehouseMgr { await _db.Ado.BeginTranAsync(); - VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSKITTINGINSTK_ID, true); - await _runService.Create(templateEntity, input); //入库取终点 //出库起点 var inStockStrategyInput = new InStockStrategyQuery { warehouse_id = input.data[nameof(InStockStrategyQuery.warehouse_id)].ToString()!, Size = 1 }; var endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput); @@ -80,9 +78,16 @@ namespace Tnb.WarehouseMgr } if (endLocations?.Count > 0) { + var carry = await _db.Queryable().SingleAsync(it => it.id == input.data[nameof(WmsCarryD.carry_id)].ToString()); + var loc = await _db.Queryable().SingleAsync(it => it.id == endLocations[0].id); + var isMatch = await IsCarryAndLocationMatchByCarryStd(carry, loc); + if (!isMatch) throw new AppFriendlyException("库位与载具规格不匹配", 500); ePoint = await _db.Queryable().FirstAsync(it => it.location_id == endLocations[0].id); } + VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSKITTINGINSTK_ID, true); + await _runService.Create(templateEntity, input); + if (sPoint != null && ePoint != null) { var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id); diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryMoveInStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryMoveInStockService.cs index 6b87d88e..d89d3c80 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryMoveInStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryMoveInStockService.cs @@ -66,22 +66,27 @@ namespace Tnb.WarehouseMgr { await _db.Ado.BeginTranAsync(); - VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true); - await _runService.Create(templateEntity, input); //入库取终点 //出库起点 var inStockStrategyInput = new InStockStrategyQuery { warehouse_id = input.data[nameof(InStockStrategyQuery.warehouse_id)].ToString()!, Size = 1 }; var endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput); - WmsPointH? sPoint = null; - WmsPointH? ePoint = null; + WmsPointH sPoint = null!; + WmsPointH ePoint = null!; if (input.data.ContainsKey(nameof(WmsPointH.location_id))) { sPoint = await _db.Queryable().FirstAsync(it => it.location_id == input.data[nameof(WmsPointH.location_id)].ToString()); } if (endLocations?.Count > 0) { + var carry = await _db.Queryable().SingleAsync(it => it.id == input.data[nameof(WmsCarryD.carry_id)].ToString()); + var loc = await _db.Queryable().SingleAsync(it => it.id == endLocations[0].id); + var isMatch = await IsCarryAndLocationMatchByCarryStd(carry, loc); + if (!isMatch) throw new AppFriendlyException("库位与载具规格不匹配", 500); ePoint = await _db.Queryable().FirstAsync(it => it.location_id == endLocations[0].id); } + VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true); + await _runService.Create(templateEntity, input); + if (sPoint != null && ePoint != null) { var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id); diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyInstockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyInstockService.cs index 051aa9d9..ad2de004 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyInstockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyInstockService.cs @@ -65,9 +65,7 @@ namespace Tnb.WarehouseMgr { await _db.Ado.BeginTranAsync(); - VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSEMPTYINSTKPDA_ID, true); - await _runService.Create(templateEntity, input); - //入库取终点 + //入库取终点 //出库起点 var inStockStrategyInput = new InStockStrategyQuery { warehouse_id = input.data[nameof(InStockStrategyQuery.warehouse_id)].ToString()!, Size = 1 }; var endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput); WmsPointH sPoint = null!; @@ -78,9 +76,16 @@ namespace Tnb.WarehouseMgr } if (endLocations?.Count > 0) { + var carry = await _db.Queryable().SingleAsync(it => it.id == input.data[nameof(WmsCarryD.carry_id)].ToString()); + var loc = await _db.Queryable().SingleAsync(it => it.id == endLocations[0].id); + var isMatch = await IsCarryAndLocationMatchByCarryStd(carry, loc); + if (!isMatch) throw new AppFriendlyException("库位与载具规格不匹配", 500); ePoint = await _db.Queryable().FirstAsync(it => it.location_id == endLocations[0].id); } + VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSEMPTYINSTKPDA_ID, true); + await _runService.Create(templateEntity, input); + if (sPoint != null && ePoint != null) { var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id); diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInbaleService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInbaleService.cs index 7322f013..6e4c6ca2 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInbaleService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInbaleService.cs @@ -80,6 +80,10 @@ namespace Tnb.WarehouseMgr } if (endLocations?.Count > 0) { + var carry = await _db.Queryable().SingleAsync(it => it.id == input.data[nameof(WmsCarryD.carry_id)].ToString()); + var loc = await _db.Queryable().SingleAsync(it => it.id == endLocations[0].id); + var isMatch = await IsCarryAndLocationMatchByCarryStd(carry, loc); + if (!isMatch) throw new AppFriendlyException("库位与载具规格不匹配", 500); ePoint = await _db.Queryable().FirstAsync(it => it.location_id == endLocations[0].id); } From 480c2a6d1142f77d5b59b4ac4c2daad0c1515e34 Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 18 Jul 2023 11:21:57 +0800 Subject: [PATCH 12/32] 1 --- .../Tnb.WarehouseMgr/WmsOutBaleService.cs | 8 ++++++-- .../Tnb.WarehouseMgr/WmsOutStockService.cs | 4 ++-- .../Tnb.WarehouseMgr/WmskittingOutService.cs | 15 ++++++++++----- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsOutBaleService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsOutBaleService.cs index d38712ef..665a32ee 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsOutBaleService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsOutBaleService.cs @@ -66,11 +66,15 @@ namespace Tnb.WarehouseMgr { await _db.Ado.BeginTranAsync(); + var carry = await _db.Queryable().FirstAsync(it => it.id == input.data[nameof(WmsOutbale.carry_id)].ToString()); + var loc = await _db.Queryable().SingleAsync(it => it.id == input.data[nameof(WmsPointH.location_id)].ToString()); + var isMatch = await IsCarryAndLocationMatchByCarryStd(carry, loc); + if (!isMatch) throw new AppFriendlyException("该载具无法放置到目标库位", 500); + VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSOUTBALE_ID, true); await _runService.Create(templateEntity, input); //入库取终点 //var OutStockStrategyInput = new OutStockStrategyQuery { carry_id = input.data[nameof(OutStockStrategyQuery.carry_id)].ToString(), Size = 1 }; - var carry = await _db.Queryable().FirstAsync(it => it.id == input.data[nameof(WmsOutbale.carry_id)].ToString()); WmsPointH? sPoint = null; WmsPointH? ePoint = null; if (input.data.ContainsKey(nameof(WmsPointH.location_id))) @@ -117,7 +121,7 @@ namespace Tnb.WarehouseMgr return preTask; }).ToList(); //判断目标库位是否自动签收 - var loc = await _db.Queryable().SingleAsync(it => it.id == input.data[nameof(WmsPointH.location_id)].ToString()); + if (loc.is_sign == 0) { preTasks[^1].is_sign = 0; // 修改最后一个元素的是否签收值 diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs index f4b9be85..b86fb731 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs @@ -78,12 +78,12 @@ namespace Tnb.WarehouseMgr try { await _db.Ado.BeginTranAsync(); + //判断目标库位是否自动签收 + var loc = await _db.Queryable().SingleAsync(it => it.id == input.data[nameof(WmsPointH.location_id)].ToString()); VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSOUTSTOCK_ID, true); await _runService.Create(templateEntity, input); - //判断目标库位是否自动签收 - var loc = await _db.Queryable().SingleAsync(it => it.id == input.data[nameof(WmsPointH.location_id)].ToString()); var carryIds = new List(); //tablefield120 出库物料明细 diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs index eed1bc1c..1717c0fc 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs @@ -71,15 +71,15 @@ namespace Tnb.WarehouseMgr // var set = true ; 如果有 把set修改为false var items = await _db.Queryable().Where(it => it.status == WmsWareHouseConst.BILLSTATUS_CALLED_ID).ToListAsync(); var isCalled = items?.Count > 0; - + if (kittingOuts?.Count > 0) { foreach (var ko in kittingOuts) { //a.carrystd_id == WmsWareHouseConst.CARRY_LJSTD_ID - - Expression> whereExp = (ko.carry_id != null) ? a=>a.id == ko.carry_id : a => a.carrystd_id == WmsWareHouseConst.CARRY_LJSTD_ID; - + + Expression> whereExp = (ko.carry_id != null) ? a => a.id == ko.carry_id : a => a.carrystd_id == WmsWareHouseConst.CARRY_LJSTD_ID; + var carrys = await _db.Queryable() .InnerJoin((a, b) => a.collocation_scheme_id == b.id) .Where(whereExp.And(a => a.collocation_scheme_id == ko.collocation_scheme_id && a.is_lock == 0)) @@ -89,7 +89,7 @@ namespace Tnb.WarehouseMgr { var firstCarry = carrys.FirstOrDefault(); GenPreTaskUpInput genPreTaskInput = new() { CarryId = firstCarry?.id }; - await _warehouseService.GenInStockTaskHandleAfter(genPreTaskInput, it => new WmsCarryH { is_lock = 1 , out_status = EnumOutStatus.全部出.ToString()}, null!); + await _warehouseService.GenInStockTaskHandleAfter(genPreTaskInput, it => new WmsCarryH { is_lock = 1, out_status = EnumOutStatus.全部出.ToString() }, null!); ko.status = WmsWareHouseConst.BILLSTATUS_TOBESHIPPED_ID; ko.carry_id = firstCarry?.id; ko.carry_code = firstCarry?.carry_code; @@ -336,6 +336,11 @@ namespace Tnb.WarehouseMgr if (input.IsNull()) throw new ArgumentNullException(nameof(input)); try { + var kittingOut = input[^1]; + var curCarry = await _db.Queryable().SingleAsync(it => it.id == kittingOut.carry_id); + var endLocation = await _db.Queryable().SingleAsync(it => it.id == kittingOut.location_id); + var isMatch = await IsCarryAndLocationMatchByCarryStd(curCarry, endLocation); + if (!isMatch) throw new AppFriendlyException("该载具无法放置到目标库位", 500); await _db.Ado.BeginTranAsync(); List kittingOutDs = new(); From 790ed73bef3ed1ebeb2498d80eea76462aa90969 Mon Sep 17 00:00:00 2001 From: zhoukeda <1315948824@qq.com> Date: Tue, 18 Jul 2023 11:23:11 +0800 Subject: [PATCH 13/32] 1 --- BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs b/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs index bbd98d72..8c6eede0 100644 --- a/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs +++ b/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs @@ -102,8 +102,10 @@ public static class DictConst /// 模具保养状态-待保养编码 /// public const string MoldMaintainStatusDBYCode = "UnMaintain"; - - + /// + /// 任务单状态key + /// + public const string TaskStatus = "TaskStatus"; #endregion From a5f7ded7d3e12447c93ec994775e63780d140aa7 Mon Sep 17 00:00:00 2001 From: FanLian Date: Tue, 18 Jul 2023 11:35:56 +0800 Subject: [PATCH 14/32] =?UTF-8?q?=E8=A1=A5=E6=BC=8F=EF=BC=8C=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WmsEmptyInstockService.cs | 2 -- .../Tnb.WarehouseMgr/WmsInStockService.cs | 19 +++++++++++-------- .../Tnb.WarehouseMgr/WmsPDAInStockService.cs | 4 ++++ 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyInstockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyInstockService.cs index 0909866f..cb64b15e 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyInstockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyInstockService.cs @@ -187,8 +187,6 @@ namespace Tnb.WarehouseMgr { var carry = await _db.Queryable().SingleAsync(it => it.carry_code == input.carry_code); var loc = await _db.Queryable().SingleAsync(it => it.location_code == input.location_code); - var isMatch = await IsCarryAndLocationMatchByCarryStd(carry, loc); - if (!isMatch) throw new AppFriendlyException("库位与载具规格不匹配", 500); var emptyInstock = await _db.Queryable().FirstAsync(it => it.carry_code == input.carry_code && it.status == WmsWareHouseConst.BILLSTATUS_ADD_ID); if (emptyInstock != null) { diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs index 2915a375..e47c878a 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs @@ -270,10 +270,19 @@ namespace Tnb.WarehouseMgr //入库申请条码明细表 List instockcodes = input.instockcodes.Adapt>(); - var loc = await _db.Queryable().FirstAsync(it => it.location_code == input.instock.location_code && it.is_type != EnumLocationType.存储库位.ToString()); + //入库取终点 //出库起点 + var inStockStrategyInput = new InStockStrategyQuery { warehouse_id = instock?.warehouse_id!, Size = 1 }; + var endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput); + WmsPointH sPoint = await _db.Queryable().FirstAsync(it => it.location_id == instock.location_id); + WmsPointH ePoint = await _db.Queryable().FirstAsync(it => it.location_id == endLocations[0].id); + var carry = await _db.Queryable().SingleAsync(it => it.carry_code == input.instock.carry_code); + var loc = await _db.Queryable().FirstAsync(it => it.id == endLocations[0].id); var isMatch = await IsCarryAndLocationMatchByCarryStd(carry, loc); if (!isMatch) throw new AppFriendlyException("库位与载具规格不匹配", 500); + + loc = await _db.Queryable().FirstAsync(it => it.location_code == input.instock.location_code && it.is_type != EnumLocationType.存储库位.ToString()); + //如果数据不全或有误, if (carry.IsNull() || loc.IsNull() || instockds?.Count < 1 || instockcodes?.Count < 1) { @@ -329,13 +338,7 @@ namespace Tnb.WarehouseMgr await _db.Insertable(instockCOdes).CallEntityMethod(it => it.Create(orgId)).ExecuteCommandAsync(); //生成预任务申请 - //入库取终点 //出库起点 - var inStockStrategyInput = new InStockStrategyQuery { warehouse_id = instock?.warehouse_id!, Size = 1 }; - var endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput); - WmsPointH sPoint = await _db.Queryable().FirstAsync(it => it.location_id == instock.location_id); - WmsPointH ePoint = await _db.Queryable().FirstAsync(it => it.location_id == endLocations[0].id); - - + if (sPoint != null && ePoint != null) { var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id); diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInStockService.cs index d1f52154..d18391c3 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInStockService.cs @@ -92,6 +92,10 @@ namespace Tnb.WarehouseMgr } if (endLocations?.Count > 0) { + var carry = await _db.Queryable().SingleAsync(it => it.id == input.data[nameof(WmsCarryD.carry_id)].ToString()); + var loc = await _db.Queryable().SingleAsync(it => it.id == endLocations[0].id); + var isMatch = await IsCarryAndLocationMatchByCarryStd(carry, loc); + if (!isMatch) throw new AppFriendlyException("库位与载具规格不匹配", 500); ePoint = await _db.Queryable().FirstAsync(it => it.location_id == endLocations[0].id); } From bc5a67338a048a9c12369d6b9b93e40ded39a7d9 Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 18 Jul 2023 14:03:58 +0800 Subject: [PATCH 15/32] 1 --- .../WmsCarryMoveOutStockService.cs | 10 +- .../WmsEmptyOutstockService .cs | 170 +++++++++--------- .../Tnb.WarehouseMgr/WmsOutStockService.cs | 30 +++- .../WmsPDACarryMoveOutStockService.cs | 7 +- 4 files changed, 128 insertions(+), 89 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryMoveOutStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryMoveOutStockService.cs index c4e28b0b..e763bf4d 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryMoveOutStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryMoveOutStockService.cs @@ -63,11 +63,17 @@ namespace Tnb.WarehouseMgr { await _db.Ado.BeginTranAsync(); + //判断目标库位是否自动签收 + var loc = await _db.Queryable().SingleAsync(it => it.id == input.data[nameof(WmsPointH.location_id)].ToString()); + var carry = await _db.Queryable().FirstAsync(it => it.id == input.data[nameof(WmsMoveOutstock.carry_id)].ToString()); + var isMatch = await IsCarryAndLocationMatchByCarryStd(carry, loc); + if (!isMatch) throw new AppFriendlyException("该载具无法放置到目标库位", 500); + + VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSCARRYMOOUTSTK_ID, true); await _runService.Create(templateEntity, input); //入库取终点 //var OutStockStrategyInput = new OutStockStrategyQuery { carry_id = input.data[nameof(OutStockStrategyQuery.carry_id)].ToString(), Size = 1 }; - var carry = await _db.Queryable().FirstAsync(it => it.id == input.data[nameof(WmsMoveOutstock.carry_id)].ToString()); WmsPointH? sPoint = null; WmsPointH? ePoint = null; if (input.data.ContainsKey(nameof(WmsPointH.location_id))) @@ -113,8 +119,6 @@ namespace Tnb.WarehouseMgr preTask.create_time = DateTime.Now; return preTask; }).ToList(); - //判断目标库位是否自动签收 - var loc = await _db.Queryable().SingleAsync(it => it.id == input.data[nameof(WmsPointH.location_id)].ToString()); if (loc.is_sign ==0 ) { preTasks[^1].is_sign = 0; // 修改最后一个元素的是否签收值 } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs index 319031d9..de713b5a 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs @@ -70,8 +70,7 @@ namespace Tnb.WarehouseMgr { await _db.Ado.BeginTranAsync(); - VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSEMPTYOUTSTK_ID, true); - await _runService.Create(templateEntity, input); + /*//入库取终点 var inStockStrategyInput = new InStockStrategyQuery { warehouse_id = input.data[nameof(InStockStrategyQuery.warehouse_id)].ToString(), Size = 1 }; @@ -85,6 +84,17 @@ namespace Tnb.WarehouseMgr && a.carry_status == ((int)EnumCarryStatus.空闲).ToString() && a.is_lock == 0 && b.is_lock == 0 && b.is_type == ((int)EnumLocationType.存储库位).ToString()) .ToListAsync(); + // 判断最终目标库位是否可以放置当前载具 + if (carrys?.Count > 0) + { + var curCarry = carrys[^carrys.Count]; + var isMatch = await IsCarryAndLocationMatchByCarryStd(curCarry, loc); + if (!isMatch) throw new AppFriendlyException("该载具无法放置到目标库位", 500); + } + + VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSEMPTYOUTSTK_ID, true); + await _runService.Create(templateEntity, input); + WmsPointH? sPoint = null; WmsPointH? ePoint = null; if (input.data.ContainsKey(nameof(WmsPointH.location_id))) @@ -92,90 +102,90 @@ namespace Tnb.WarehouseMgr ePoint = await _db.Queryable().FirstAsync(it => it.location_id == input.data[nameof(WmsPointH.location_id)].ToString() && it.is_lock == 0); } //根据每个载具的起始库位做路径运算 - for (int i = 0; i < setQty.qty; i++) + if (carrys?.Count > 0) { - if (carrys?.Count > 0) + for (int i = 0; i < setQty.qty; i++) { sPoint = await _db.Queryable().FirstAsync(it => it.location_id == carrys[i].location_id); - } - var isOk = false; - if (sPoint != null && ePoint != null) - { - var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id); - if (points.Count <= 2) throw new AppFriendlyException("该路径不存在", 500); - //根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序) + + var isOk = false; + if (sPoint != null && ePoint != null) + { + var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id); + if (points.Count <= 2) throw new AppFriendlyException("该路径不存在", 500); + //根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序) + else + { + var preTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it => + { + var sPoint = it.FirstOrDefault(); + var ePoint = it.LastOrDefault(); + + WmsPretaskH preTask = new(); + preTask.org_id = _userManager.User.OrganizeId; + preTask.startlocation_id = sPoint?.location_id!; + preTask.startlocation_code = sPoint?.location_code!; + preTask.endlocation_id = ePoint?.location_id!; + preTask.endlocation_code = ePoint?.location_code!; + preTask.start_floor = sPoint?.floor.ToString(); + preTask.end_floor = ePoint?.floor.ToString(); + preTask.bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult(); + preTask.status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID; + preTask.biz_type = WmsWareHouseConst.BIZTYPE_WMSEPTYOUTSTK_ID; + preTask.task_type = WmsWareHouseConst.WMS_PRETASK_OUTSTOCK_TYPE_ID; + preTask.carry_id = carrys![i].id; + preTask.carry_code = carrys![i].carry_code; + preTask.area_id = sPoint?.area_id!; + preTask.area_code = it.Key; + preTask.require_id = input.data["ReturnIdentity"].ToString(); + preTask.require_code = input.data[nameof(preTask.bill_code)]?.ToString()!; + preTask.create_id = _userManager.UserId; + preTask.create_time = DateTime.Now; + return preTask; + }).ToList(); + //更新页面 + //赋值签收状态 + if (loc.is_sign == 0) + { + preTasks[^1].is_sign = 0; // 修改最后一个元素的是否签收值 + } + isOk = await _wareHouseService.GenPreTask(preTasks, null!); + } + if (isOk) + { + var preTaskUpInput = new GenPreTaskUpInput(); + preTaskUpInput.RquireId = input.data["ReturnIdentity"].ToString()!; + preTaskUpInput.CarryId = carrys![i].id; + preTaskUpInput.CarryStartLocationId = points!.FirstOrDefault()!.location_id!; + preTaskUpInput.CarryStartLocationCode = points!.FirstOrDefault()!.location_code!; + preTaskUpInput.LocationIds = points!.Select(x => x.location_id).ToList()!; + + //更新明细表 + WmsEmptyOutstockD wmsEmptyOutstockD = new(); + wmsEmptyOutstockD.id = SnowflakeIdHelper.NextId(); + wmsEmptyOutstockD.bill_id = preTaskUpInput.RquireId; + wmsEmptyOutstockD.biz_type = WmsWareHouseConst.BIZTYPE_WMSEPTYOUTSTK_ID; + wmsEmptyOutstockD.location_id = ePoint.location_id!; + wmsEmptyOutstockD.status = WmsWareHouseConst.BILLSTATUS_ON_ID; + wmsEmptyOutstockD.carry_id = carrys[i].id; + wmsEmptyOutstockD.carry_code = carrys[i].carry_code; + wmsEmptyOutstockD.create_id = _userManager.UserId; + wmsEmptyOutstockD.create_time = DateTime.Now; + await _db.Insertable(wmsEmptyOutstockD) + .ExecuteCommandAsync(); + + //根据空载具出库Id,回更单据状态 + await _db.Updateable().SetColumns(it => new WmsEmptyOutstockH { status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => it.id == preTaskUpInput.RquireId).ExecuteCommandAsync(); + await _wareHouseService.GenInStockTaskHandleAfter(preTaskUpInput, + it => new WmsCarryH { is_lock = 1 }, + it => new BasLocation { is_lock = 1 }); + } + } else { - var preTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it => - { - var sPoint = it.FirstOrDefault(); - var ePoint = it.LastOrDefault(); - - WmsPretaskH preTask = new(); - preTask.org_id = _userManager.User.OrganizeId; - preTask.startlocation_id = sPoint?.location_id!; - preTask.startlocation_code = sPoint?.location_code!; - preTask.endlocation_id = ePoint?.location_id!; - preTask.endlocation_code = ePoint?.location_code!; - preTask.start_floor = sPoint?.floor.ToString(); - preTask.end_floor = ePoint?.floor.ToString(); - preTask.bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult(); - preTask.status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID; - preTask.biz_type = WmsWareHouseConst.BIZTYPE_WMSEPTYOUTSTK_ID; - preTask.task_type = WmsWareHouseConst.WMS_PRETASK_OUTSTOCK_TYPE_ID; - preTask.carry_id = carrys![i].id; - preTask.carry_code = carrys![i].carry_code; - preTask.area_id = sPoint?.area_id!; - preTask.area_code = it.Key; - preTask.require_id = input.data["ReturnIdentity"].ToString(); - preTask.require_code = input.data[nameof(preTask.bill_code)]?.ToString()!; - preTask.create_id = _userManager.UserId; - preTask.create_time = DateTime.Now; - return preTask; - }).ToList(); - //更新页面 - //赋值签收状态 - if (loc.is_sign == 0) - { - preTasks[^1].is_sign = 0; // 修改最后一个元素的是否签收值 - } - isOk = await _wareHouseService.GenPreTask(preTasks, null!); - } - if (isOk) - { - var preTaskUpInput = new GenPreTaskUpInput(); - preTaskUpInput.RquireId = input.data["ReturnIdentity"].ToString()!; - preTaskUpInput.CarryId = carrys![i].id; - preTaskUpInput.CarryStartLocationId = points!.FirstOrDefault()!.location_id!; - preTaskUpInput.CarryStartLocationCode = points!.FirstOrDefault()!.location_code!; - preTaskUpInput.LocationIds = points!.Select(x => x.location_id).ToList()!; - - //更新明细表 - WmsEmptyOutstockD wmsEmptyOutstockD = new(); - wmsEmptyOutstockD.id = SnowflakeIdHelper.NextId(); - wmsEmptyOutstockD.bill_id = preTaskUpInput.RquireId; - wmsEmptyOutstockD.biz_type = WmsWareHouseConst.BIZTYPE_WMSEPTYOUTSTK_ID; - wmsEmptyOutstockD.location_id = ePoint.location_id!; - wmsEmptyOutstockD.status = WmsWareHouseConst.BILLSTATUS_ON_ID; - wmsEmptyOutstockD.carry_id = carrys[i].id; - wmsEmptyOutstockD.carry_code = carrys[i].carry_code; - wmsEmptyOutstockD.create_id = _userManager.UserId; - wmsEmptyOutstockD.create_time = DateTime.Now; - await _db.Insertable(wmsEmptyOutstockD) - .ExecuteCommandAsync(); - - //根据空载具出库Id,回更单据状态 - await _db.Updateable().SetColumns(it => new WmsEmptyOutstockH { status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => it.id == preTaskUpInput.RquireId).ExecuteCommandAsync(); - await _wareHouseService.GenInStockTaskHandleAfter(preTaskUpInput, - it => new WmsCarryH { is_lock = 1 }, - it => new BasLocation { is_lock = 1 }); + throw new AppFriendlyException("无可出库的空载具或目标库位不存在或者目标库位被锁", 500); } } - else - { - throw new AppFriendlyException("无可出库的空载具或目标库位不存在或者目标库位被锁", 500); - } - } await _db.Ado.CommitTranAsync(); @@ -226,7 +236,7 @@ namespace Tnb.WarehouseMgr if (input.IsNull()) throw new ArgumentNullException("input"); try { - var location = await _db.Queryable().SingleAsync(it => it.location_code == input.location_code && it.is_type != EnumLocationType.存储库位.ToString()) ?? throw new AppFriendlyException("无此库位或为存储库位",500); + var location = await _db.Queryable().SingleAsync(it => it.location_code == input.location_code && it.is_type != EnumLocationType.存储库位.ToString()) ?? throw new AppFriendlyException("无此库位或为存储库位", 500); Dictionary dic = new() { [nameof(WmsEmptyOutstockH.id)] = SnowflakeIdHelper.NextId(), diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs index b86fb731..f3504aab 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs @@ -81,8 +81,8 @@ namespace Tnb.WarehouseMgr //判断目标库位是否自动签收 var loc = await _db.Queryable().SingleAsync(it => it.id == input.data[nameof(WmsPointH.location_id)].ToString()); - VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSOUTSTOCK_ID, true); - await _runService.Create(templateEntity, input); + + var carryIds = new List(); @@ -178,9 +178,19 @@ namespace Tnb.WarehouseMgr await _db.Updateable().SetColumns(it => new WmsCarryH { out_status = ((int)EnumOutStatus.全部出).ToString() }).Where(it => allOutIds.Contains(it.id)).ExecuteCommandAsync(); await _db.Updateable().SetColumns(it => new WmsCarryH { out_status = ((int)EnumOutStatus.分拣出).ToString() }).Where(it => sortingOutIds.Contains(it.id)).ExecuteCommandAsync(); } + + + var carrys = await _db.Queryable().Where(it => carryIds.Contains(it.id)).ToListAsync(); if (carrys?.Count > 0) { + var curCarry = carrys[^carrys.Count]; + var isMatch = await IsCarryAndLocationMatchByCarryStd(curCarry, loc); + if (!isMatch) throw new AppFriendlyException("该载具无法放置到目标库位", 500); + + VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSOUTSTOCK_ID, true); + await _runService.Create(templateEntity, input); + List preTasks = new(); List locIds = new(); foreach (var carry in carrys) @@ -274,6 +284,9 @@ namespace Tnb.WarehouseMgr } + + + await _db.Ado.CommitTranAsync(); } catch (Exception) @@ -333,7 +346,7 @@ namespace Tnb.WarehouseMgr outstock.status = WmsWareHouseConst.BILLSTATUS_ADD_ID;// 新增 outstock.create_id = _userManager.UserId; outstock.create_time = DateTime.Now; - await _db.Insertable(outstock).ExecuteCommandAsync(); + //明细表 foreach (var outstockD in outstockDs!) { @@ -344,7 +357,7 @@ namespace Tnb.WarehouseMgr outstock.create_time = outstock.create_time; outstock.create_id = outstock.create_id; } - await _db.Insertable(outstockDs).ExecuteCommandAsync(); + //var loc = await _db.Queryable().SingleAsync(it => it.id == outstock.location_id.ToString()); var carryIds = new List(); //tablefield120 出库物料明细 @@ -432,6 +445,15 @@ namespace Tnb.WarehouseMgr } } carryIds = allOutIds.Concat(sortingOutIds).ToList(); + if(carryIds?.Count> 0) + { + var carryId = carryIds[^carryIds.Count]; + var curCurry =await _db.Queryable().SingleAsync(it=>it.id == carryId); + var isMatch = await IsCarryAndLocationMatchByCarryStd(curCurry, location); + if (!isMatch) throw new AppFriendlyException("该载具无法放置到目标库位", 500); + } + await _db.Insertable(outstock).ExecuteCommandAsync(); + await _db.Insertable(outstockDs).ExecuteCommandAsync(); await _db.Updateable().SetColumns(it => new WmsCarryH { out_status = ((int)EnumOutStatus.全部出).ToString() }).Where(it => allOutIds.Contains(it.id)).ExecuteCommandAsync(); await _db.Updateable().SetColumns(it => new WmsCarryH { out_status = ((int)EnumOutStatus.分拣出).ToString() }).Where(it => sortingOutIds.Contains(it.id)).ExecuteCommandAsync(); diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryMoveOutStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryMoveOutStockService.cs index 036ed9f3..b2f14243 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryMoveOutStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryMoveOutStockService.cs @@ -63,10 +63,14 @@ namespace Tnb.WarehouseMgr { await _db.Ado.BeginTranAsync(); + var carry = await _db.Queryable().FirstAsync(it => it.id == input.data[nameof(WmsMoveOutstock.carry_id)].ToString()); + var loc = await _db.Queryable().SingleAsync(it => it.id == input.data[nameof(WmsPointH.location_id)].ToString()); + var isMatch = await IsCarryAndLocationMatchByCarryStd(carry, loc); + if (!isMatch) throw new AppFriendlyException("该载具无法放置到目标库位", 500); + VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSCARRYMOOUTSTKPDA_ID, true); await _runService.Create(templateEntity, input); //出库取起点 - var carry = await _db.Queryable().FirstAsync(it => it.id == input.data[nameof(WmsMoveOutstock.carry_id)].ToString()); WmsPointH? sPoint = null; WmsPointH? ePoint = null; if (input.data.ContainsKey(nameof(WmsPointH.location_id))) @@ -114,7 +118,6 @@ namespace Tnb.WarehouseMgr return preTask; }).ToList(); //判断目标库位是否自动签收 - var loc = await _db.Queryable().SingleAsync(it => it.id == input.data[nameof(WmsPointH.location_id)].ToString()); if (loc.is_sign == 0) { preTasks[^1].is_sign = 0; // 修改最后一个元素的是否签收值 From 97c0e96b86890d5d9ff50baabee01091b3cdd003 Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 18 Jul 2023 14:12:56 +0800 Subject: [PATCH 16/32] =?UTF-8?q?=E5=88=A4=E6=96=AD=E6=9C=80=E7=BB=88?= =?UTF-8?q?=E7=9B=AE=E6=A0=87=E5=BA=93=E4=BD=8D=E6=98=AF=E5=90=A6=E5=8F=AF?= =?UTF-8?q?=E6=94=BE=E7=BD=AE=E5=BD=93=E5=89=8D=E8=BD=BD=E5=85=B7=EF=BC=8C?= =?UTF-8?q?=E5=85=AC=E5=85=B1=E5=87=BD=E6=95=B0=E4=BB=A3=E7=A0=81=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WarehouseMgr/Tnb.WarehouseMgr/BaseWareHouseService.cs | 6 +----- .../Tnb.WarehouseMgr/WmsPDACarryMoveOutStockService.cs | 3 +-- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/BaseWareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/BaseWareHouseService.cs index aa747ad7..aad43cdd 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/BaseWareHouseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/BaseWareHouseService.cs @@ -60,17 +60,13 @@ namespace Tnb.WarehouseMgr protected Task IsCarryAndLocationMatchByCarryStd(WmsCarryH carry, BasLocation locDest) { bool isMatch = false; - string errMessage = string.Empty; if (carry == null) throw new ArgumentNullException(nameof(carry)); if (locDest == null) throw new ArgumentNullException(nameof(locDest)); if (!carry.carrystd_id.IsNullOrEmpty() && !locDest.carrystd_id.IsNullOrEmpty()) { var jsonArr = JArray.Parse(locDest.carrystd_id); var locCarryStdArr = jsonArr.Select(x => x.ToObject()).ToArray(); - if (locCarryStdArr.Contains(carry.carrystd_id)) - { - isMatch = true; - } + isMatch = locCarryStdArr.Contains(carry.carrystd_id); } return Task.FromResult(isMatch); } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryMoveOutStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryMoveOutStockService.cs index b2f14243..1eb351ca 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryMoveOutStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryMoveOutStockService.cs @@ -71,8 +71,7 @@ namespace Tnb.WarehouseMgr VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSCARRYMOOUTSTKPDA_ID, true); await _runService.Create(templateEntity, input); //出库取起点 - WmsPointH? sPoint = null; - WmsPointH? ePoint = null; + WmsPointH? sPoint = null, ePoint = null; if (input.data.ContainsKey(nameof(WmsPointH.location_id))) { ePoint = await _db.Queryable().FirstAsync(it => it.location_id == input.data[nameof(WmsPointH.location_id)].ToString()); From 29d2f240c2d070c84e2dd72edfbfb89c9e6d04ee Mon Sep 17 00:00:00 2001 From: zhoukeda <1315948824@qq.com> Date: Tue, 18 Jul 2023 17:14:49 +0800 Subject: [PATCH 17/32] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E4=BA=A7=E7=BA=BF?= =?UTF-8?q?=E5=92=8C=E6=B3=A8=E5=A1=91=E6=8C=A4=E5=87=BA=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E6=A0=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Consts/DictConst.cs | 12 ++++ .../Dto/WorklineAndEquipTreeOutput.cs | 42 ++++++++++++ .../IEquipmentService.cs | 6 ++ EquipMgr/Tnb.EquipMgr/EquipmentService.cs | 67 +++++++++++++++++++ 4 files changed, 127 insertions(+) create mode 100644 EquipMgr/Tnb.EquipMgr.Entities/Dto/WorklineAndEquipTreeOutput.cs diff --git a/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs b/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs index 8c6eede0..bfc6fcf5 100644 --- a/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs +++ b/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs @@ -12,6 +12,18 @@ public static class DictConst /// public const string RegionCategoryStationCode = "workstation"; /// + /// 区域类型-公司Code + /// + public const string RegionCategoryCompanyCode = "company"; + /// + /// 区域类型-车间Code + /// + public const string RegionCategoryWorkshopCode = "workshop"; + /// + /// 区域类型-产线Code + /// + public const string RegionCategoryWorklineCode = "workline"; + /// /// 备品备件类型 /// public const string SparePartsType = "SparePartsType"; diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Dto/WorklineAndEquipTreeOutput.cs b/EquipMgr/Tnb.EquipMgr.Entities/Dto/WorklineAndEquipTreeOutput.cs new file mode 100644 index 00000000..dcfee410 --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Entities/Dto/WorklineAndEquipTreeOutput.cs @@ -0,0 +1,42 @@ +namespace Tnb.EquipMgr.Entities.Dto +{ + public class WorklineAndEquipTreeOutput + { + /// + /// 获取节点id. + /// + /// + public string id { get; set; } + + /// + /// 标题 + /// + public string title { get; set; } + + /// + /// 获取节点父id. + /// + /// + public string parentId { get; set; } + + /// + /// 是否有子级. + /// + public bool hasChildren { get; set; } + + /// + /// 设置Children. + /// + public List? children { get; set; } = new List(); + + /// + /// 子节点数量. + /// + public int num { get; set; } + + /// + /// 是否为子节点. + /// + public bool isLeaf { get; set; } = false; + } +} \ No newline at end of file diff --git a/EquipMgr/Tnb.EquipMgr.Interfaces/IEquipmentService.cs b/EquipMgr/Tnb.EquipMgr.Interfaces/IEquipmentService.cs index a1255946..3473dbf8 100644 --- a/EquipMgr/Tnb.EquipMgr.Interfaces/IEquipmentService.cs +++ b/EquipMgr/Tnb.EquipMgr.Interfaces/IEquipmentService.cs @@ -17,5 +17,11 @@ namespace Tnb.EquipMgr.Interfaces /// /// public Task GetListByTypeId(Dictionary dic); + + /// + /// 获取产线和注塑挤出设备树 + /// + /// + public Task GetWorklineAndEquipTree(Dictionary dic); } } \ No newline at end of file diff --git a/EquipMgr/Tnb.EquipMgr/EquipmentService.cs b/EquipMgr/Tnb.EquipMgr/EquipmentService.cs index f2be6958..a904bcaa 100644 --- a/EquipMgr/Tnb.EquipMgr/EquipmentService.cs +++ b/EquipMgr/Tnb.EquipMgr/EquipmentService.cs @@ -1,13 +1,18 @@ using Aop.Api.Domain; using Aspose.Cells.Drawing; using JNPF.Common.Filter; +using JNPF.Common.Security; using JNPF.DependencyInjection; using JNPF.DynamicApiController; +using JNPF.Extras.CollectiveOAuth.Models; +using JNPF.Systems.Entitys.Permission; using JNPF.VisualDev; using JNPF.VisualDev.Entitys.Dto.VisualDevModelData; using Mapster; using Microsoft.AspNetCore.Mvc; +using Senparc.NeuChar.ApiHandlers; using SqlSugar; +using Tnb.BasicData; using Tnb.EquipMgr.Entities; using Tnb.EquipMgr.Entities.Dto; using Tnb.EquipMgr.Interfaces; @@ -78,5 +83,67 @@ namespace Tnb.EquipMgr return await _repository.AsSugarClient().Queryable().Where(x => typeIdArr.Contains(x.equip_type_id)) .ToListAsync(); } + + [HttpPost] + public async Task GetWorklineAndEquipTree(Dictionary dic) + { + string equipTypes = dic.ContainsKey("equipTypes") ? dic["equipTypes"] : ""; + var db = _repository.AsSugarClient(); + var queryable1 = db.Queryable() + .Where((a) => a.DeleteMark == null && a.Category==DictConst.RegionCategoryWorkshopCode) + .Select((a) => new WorklineAndEquipTreeOutput() + { + id = a.Id, + title = a.EnCode+"/"+a.FullName, + parentId = "0", + hasChildren = SqlFunc.Subqueryable().Where(b=>b.ParentId==a.Id && b.DeleteMark==null && b.Category==DictConst.RegionCategoryWorklineCode).Any(), + num = SqlFunc.Subqueryable().Where(b=>b.ParentId==a.Id && b.DeleteMark==null && b.Category==DictConst.RegionCategoryWorklineCode).Count(), + isLeaf = false, + children = SqlFunc.Subqueryable().Where(b=>b.ParentId==a.Id && b.DeleteMark==null && b.Category==DictConst.RegionCategoryWorklineCode).ToList(b=>new WorklineAndEquipTreeOutput() + { + id = b.Id, + title = b.EnCode+"/"+b.FullName, + parentId = b.ParentId, + hasChildren = false, + num = 0, + isLeaf = true, + }) + }); + + List list2 = new List(); + if (!string.IsNullOrEmpty(equipTypes)) + { + string[] equipTypeArr = equipTypes.Split(","); + list2 = await db.Queryable() + .Where((a) => equipTypeArr.Contains(a.code)) + .Select((a) => new WorklineAndEquipTreeOutput() + { + id = a.id, + title = a.name, + parentId = "0", + hasChildren = SqlFunc.Subqueryable().Where(b=>b.equip_type_id==a.id).Any(), + num = SqlFunc.Subqueryable().Where(b=>b.equip_type_id==a.id).Count(), + isLeaf = false, + children = SqlFunc.Subqueryable().Where(b=>b.equip_type_id==a.id).ToList(b=>new WorklineAndEquipTreeOutput() + { + id = b.id, + title = b.code+"/"+b.name, + parentId = b.equip_type_id, + hasChildren = false, + num = 0, + isLeaf = true, + }) + }).ToListAsync(); + + } + + // var list = await db.UnionAll(queryable1, queryable2).ToListAsync(); + var list1 = await queryable1.ToListAsync(); + list1.AddRange(list2); + return new AuthResponse(200, "", new Dictionary() + { + ["list"] = list1, + }); + } } } \ No newline at end of file From 36c65acc0e1d7267cbd11feea2d2c302341fa662 Mon Sep 17 00:00:00 2001 From: zhoukeda <1315948824@qq.com> Date: Wed, 19 Jul 2023 11:06:17 +0800 Subject: [PATCH 18/32] bug --- .../PrdMoTaskIssueService.cs | 121 +++++++++++------- 1 file changed, 77 insertions(+), 44 deletions(-) diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskIssueService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskIssueService.cs index 28190f8d..2f3ebcec 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskIssueService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskIssueService.cs @@ -20,6 +20,11 @@ using Tnb.ProductionMgr.Interfaces; using Aspose.Cells.Drawing; using Microsoft.AspNetCore.Mvc; using JNPF.Common.Extension; +using JNPF.Common.Filter; +using JNPF.Systems.Entitys.System; +using Newtonsoft.Json; +using Senparc.Weixin.Work.AdvancedAPIs.OaDataOpen; +using Tnb.BasicData; namespace Tnb.ProductionMgr { @@ -46,54 +51,82 @@ namespace Tnb.ProductionMgr } + // private async Task GetList(VisualDevModelListQueryInput input) + // { + // var db = _repository.AsSugarClient(); + // VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true); + // var data = await _runService.GetListResult(templateEntity, input); + // if (data?.list?.Count > 0) + // { + // var scheduledTypeField = nameof(PrdMoTask.schedule_type); + // data.list = data.list.Where(it => it[scheduledTypeField].IsNotEmptyOrNull() && it[scheduledTypeField].ParseToInt() == 1).ToList(); + // foreach (var row in data.list) + // { + // var dic = row.ToDictionary(x => x.Key, x => x.Value); + // var pkName = "material_id"; + // if (dic.ContainsKey(pkName)) + // { + // var materialId = dic[pkName]?.ToString(); + // var material = await db.Queryable().FirstAsync(it => it.id == materialId); + // if (material != null) + // { + // row["material_id"] = $"{material.code}/{material.name}"; + // row["materialid"] = material.id; + // } + // } + // //模具 + // if (dic.ContainsKey("mold_id")) + // { + // var moldId = dic["mold_id"]?.ToString(); + // var mold = await db.Queryable().FirstAsync(it => it.id == moldId); + // if (mold != null) + // { + // row["mold_id"] = $"{mold.mold_code}/{mold.mold_name}"; + // row["moldid"] = mold.id; + // } + // } + // //设备 + // if (dic.ContainsKey("eqp_id")) + // { + // var eqpId = dic["eqp_id"]?.ToString(); + // var eqp = await db.Queryable().FirstAsync(it => it.id == eqpId); + // if (eqp != null) + // { + // row["eqp_id"] = $"{eqp.code}/{eqp.name}"; + // row["eqpid"] = eqp.id; + // } + // } + // } + // } + // return data!; + // } + private async Task GetList(VisualDevModelListQueryInput input) { var db = _repository.AsSugarClient(); - VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true); - var data = await _runService.GetListResult(templateEntity, input); - if (data?.list?.Count > 0) - { - var scheduledTypeField = nameof(PrdMoTask.schedule_type); - data.list = data.list.Where(it => it[scheduledTypeField].IsNotEmptyOrNull() && it[scheduledTypeField].ParseToInt() == 1).ToList(); - foreach (var row in data.list) + Dictionary queryJson = !string.IsNullOrEmpty(input.queryJson) ? JsonConvert.DeserializeObject>(input.queryJson) : new Dictionary(); + string moTaskCode = queryJson.ContainsKey("mo_task_code") ? queryJson["mo_task_code"].ToString() : ""; + string moTaskStatus = queryJson.ContainsKey("mo_task_status") ? queryJson["mo_task_status"].ToString() : ""; + var result = await db.Queryable() + .LeftJoin((a, b) => a.material_id == b.id) + .LeftJoin((a, b, c) => c.EnCode == DictConst.TaskStatus) + .LeftJoin((a, b, c, d) => c.Id == d.DictionaryTypeId && a.mo_task_status == d.EnCode) + .LeftJoin((a,b,c,d,e)=>a.mold_id==e.id) + .LeftJoin((a,b,c,d,e,f)=>a.mo_id==f.id) + .WhereIF(!string.IsNullOrEmpty(moTaskCode), (a, b, c, d) => a.mo_task_code.Contains(moTaskCode)) + .WhereIF(!string.IsNullOrEmpty(moTaskStatus), (a, b, c, d) => a.mo_task_status == moTaskStatus) + .Where((a,b,c,d,e,f)=>a.schedule_type==1) + .Select((a, b, c, d,e,f) => new PrdMoTask { - var dic = row.ToDictionary(x => x.Key, x => x.Value); - var pkName = "material_id"; - if (dic.ContainsKey(pkName)) - { - var materialId = dic[pkName]?.ToString(); - var material = await db.Queryable().FirstAsync(it => it.id == materialId); - if (material != null) - { - row["material_id"] = $"{material.code}/{material.name}"; - row["materialid"] = material.id; - } - } - //模具 - if (dic.ContainsKey("mold_id")) - { - var moldId = dic["mold_id"]?.ToString(); - var mold = await db.Queryable().FirstAsync(it => it.id == moldId); - if (mold != null) - { - row["mold_id"] = $"{mold.mold_code}/{mold.mold_name}"; - row["moldid"] = mold.id; - } - } - //设备 - if (dic.ContainsKey("eqp_id")) - { - var eqpId = dic["eqp_id"]?.ToString(); - var eqp = await db.Queryable().FirstAsync(it => it.id == eqpId); - if (eqp != null) - { - row["eqp_id"] = $"{eqp.code}/{eqp.name}"; - row["eqpid"] = eqp.id; - } - } - } - } - return data!; + id = a.id, + mo_task_code = a.mo_task_code, + material_id = b.code+"/"+b.name, + mold_id = e.mold_code+"/"+e.mold_name, + mo_task_status = d.FullName, + plan_qty = f.plan_qty, + scheduled_qty = a.scheduled_qty, + }).ToPagedListAsync(input.currentPage, input.pageSize); + return PageResult.SqlSugarPageResult(result); } } } From 3fac1f47d02615d134ba8bc923acfb7eed2e5c03 Mon Sep 17 00:00:00 2001 From: FanLian Date: Wed, 19 Jul 2023 11:07:49 +0800 Subject: [PATCH 19/32] =?UTF-8?q?=E7=A9=BA=E8=BD=BD=E5=85=B7=E5=87=BA?= =?UTF-8?q?=E5=BA=93=E6=9C=80=E5=B0=8F=E5=80=BC=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WmsEmptyOutstockService .cs | 82 ++++++++++--------- 1 file changed, 45 insertions(+), 37 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs index de713b5a..2bf0f988 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs @@ -104,7 +104,8 @@ namespace Tnb.WarehouseMgr //根据每个载具的起始库位做路径运算 if (carrys?.Count > 0) { - for (int i = 0; i < setQty.qty; i++) + int min = (carrys.Count > setQty.qty) ? setQty.qty : carrys.Count; + for (int i = 0; i < min; i++) { sPoint = await _db.Queryable().FirstAsync(it => it.location_id == carrys[i].location_id); @@ -121,26 +122,29 @@ namespace Tnb.WarehouseMgr var sPoint = it.FirstOrDefault(); var ePoint = it.LastOrDefault(); - WmsPretaskH preTask = new(); - preTask.org_id = _userManager.User.OrganizeId; - preTask.startlocation_id = sPoint?.location_id!; - preTask.startlocation_code = sPoint?.location_code!; - preTask.endlocation_id = ePoint?.location_id!; - preTask.endlocation_code = ePoint?.location_code!; - preTask.start_floor = sPoint?.floor.ToString(); - preTask.end_floor = ePoint?.floor.ToString(); - preTask.bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult(); - preTask.status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID; - preTask.biz_type = WmsWareHouseConst.BIZTYPE_WMSEPTYOUTSTK_ID; - preTask.task_type = WmsWareHouseConst.WMS_PRETASK_OUTSTOCK_TYPE_ID; - preTask.carry_id = carrys![i].id; - preTask.carry_code = carrys![i].carry_code; - preTask.area_id = sPoint?.area_id!; - preTask.area_code = it.Key; - preTask.require_id = input.data["ReturnIdentity"].ToString(); - preTask.require_code = input.data[nameof(preTask.bill_code)]?.ToString()!; - preTask.create_id = _userManager.UserId; - preTask.create_time = DateTime.Now; + WmsPretaskH preTask = new() + { + org_id = _userManager.User.OrganizeId, + startlocation_id = sPoint?.location_id!, + startlocation_code = sPoint?.location_code!, + endlocation_id = ePoint?.location_id!, + endlocation_code = ePoint?.location_code!, + start_floor = sPoint?.floor.ToString(), + end_floor = ePoint?.floor.ToString(), + bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult(), + status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID, + biz_type = WmsWareHouseConst.BIZTYPE_WMSEPTYOUTSTK_ID, + task_type = WmsWareHouseConst.WMS_PRETASK_OUTSTOCK_TYPE_ID, + carry_id = carrys![i].id, + carry_code = carrys![i].carry_code, + area_id = sPoint?.area_id!, + area_code = it.Key, + require_id = input.data["ReturnIdentity"].ToString(), + require_code = input.data[nameof(preTask.bill_code)]?.ToString()!, + create_id = _userManager.UserId, + create_time = DateTime.Now + }; + return preTask; }).ToList(); //更新页面 @@ -153,24 +157,28 @@ namespace Tnb.WarehouseMgr } if (isOk) { - var preTaskUpInput = new GenPreTaskUpInput(); - preTaskUpInput.RquireId = input.data["ReturnIdentity"].ToString()!; - preTaskUpInput.CarryId = carrys![i].id; - preTaskUpInput.CarryStartLocationId = points!.FirstOrDefault()!.location_id!; - preTaskUpInput.CarryStartLocationCode = points!.FirstOrDefault()!.location_code!; - preTaskUpInput.LocationIds = points!.Select(x => x.location_id).ToList()!; + GenPreTaskUpInput preTaskUpInput = new() + { + RquireId = input.data["ReturnIdentity"].ToString()!, + CarryId = carrys![i].id, + CarryStartLocationId = points!.FirstOrDefault()!.location_id!, + CarryStartLocationCode = points!.FirstOrDefault()!.location_code!, + LocationIds = points!.Select(x => x.location_id).ToList()! + }; //更新明细表 - WmsEmptyOutstockD wmsEmptyOutstockD = new(); - wmsEmptyOutstockD.id = SnowflakeIdHelper.NextId(); - wmsEmptyOutstockD.bill_id = preTaskUpInput.RquireId; - wmsEmptyOutstockD.biz_type = WmsWareHouseConst.BIZTYPE_WMSEPTYOUTSTK_ID; - wmsEmptyOutstockD.location_id = ePoint.location_id!; - wmsEmptyOutstockD.status = WmsWareHouseConst.BILLSTATUS_ON_ID; - wmsEmptyOutstockD.carry_id = carrys[i].id; - wmsEmptyOutstockD.carry_code = carrys[i].carry_code; - wmsEmptyOutstockD.create_id = _userManager.UserId; - wmsEmptyOutstockD.create_time = DateTime.Now; + WmsEmptyOutstockD wmsEmptyOutstockD = new() + { + id = SnowflakeIdHelper.NextId(), + bill_id = preTaskUpInput.RquireId, + biz_type = WmsWareHouseConst.BIZTYPE_WMSEPTYOUTSTK_ID, + location_id = ePoint.location_id!, + status = WmsWareHouseConst.BILLSTATUS_ON_ID, + carry_id = carrys[i].id, + carry_code = carrys[i].carry_code, + create_id = _userManager.UserId, + create_time = DateTime.Now + }; await _db.Insertable(wmsEmptyOutstockD) .ExecuteCommandAsync(); From 42e0e3a13ce88bbcf2caa7685c0e0f62e9b9fb9b Mon Sep 17 00:00:00 2001 From: zhoukeda <1315948824@qq.com> Date: Wed, 19 Jul 2023 11:45:17 +0800 Subject: [PATCH 20/32] bug --- .../WorkOrderAdjustmentListOutput.cs | 21 +++ .../Tnb.ProductionMgr/PrdMoTaskService.cs | 128 ++++++++++++------ 2 files changed, 110 insertions(+), 39 deletions(-) create mode 100644 ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/WorkOrderAdjustmentListOutput.cs diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/WorkOrderAdjustmentListOutput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/WorkOrderAdjustmentListOutput.cs new file mode 100644 index 00000000..46a099c5 --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/WorkOrderAdjustmentListOutput.cs @@ -0,0 +1,21 @@ +namespace Tnb.ProductionMgr.Entities.Dto.PrdManage +{ + /// + /// 任务单调整列表输出 + /// + public class WorkOrderAdjustmentListOutput + { + public string id { get; set; } + public string mo_task_code { get; set; } + public string mo_task_status { get; set; } + public string material_id { get; set; } + public string mold_id { get; set; } + public int? plan_qty { get; set; } + public int? complete_qty { get; set; } + public int? scheduled_qty { get; set; } + public string workline_id { get; set; } + public string estimated_start_date { get; set; } + public string estimated_end_date { get; set; } + public string eqp_id { get; set; } + } +} \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs index 4b8074d5..b53f0461 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs @@ -888,6 +888,7 @@ namespace Tnb.ProductionMgr if (subTaskList?.Count > 0) { List subMoTasks = new(); + List subMoTaskLogs = new(); foreach (var item in subTaskList) { PrdMoTask subMoTask = new(); @@ -909,6 +910,20 @@ namespace Tnb.ProductionMgr subMoTask.create_id = _userManager.UserId; subMoTask.create_time = DateTime.Now; subMoTasks.Add(subMoTask); + + var subTaskLog = new PrdTaskLog(); + var subMaterial = await _db.Queryable().SingleAsync(x => x.id == item.material_id); + subTaskLog.id = SnowflakeIdHelper.NextId(); + subTaskLog.mo_code = (await _db.Queryable().FirstAsync(it => it.id == input.mo_id))?.mo_code!; + subTaskLog.item_code = subMaterial?.code!; + subTaskLog.item_standard = subMaterial?.material_standard!; + subTaskLog.status = DictConst.ToBeScheduledEncode; + subTaskLog.operator_name = _userManager.RealName; + subTaskLog.create_id = _userManager.UserId; + subTaskLog.create_time = DateTime.Now; + subTaskLog.mo_task_id = subMoTask.id; + subTaskLog.mo_task_code = subMoTask.mo_task_code!; + subMoTaskLogs.Add(subTaskLog); } //根据生产任务编号生成子任务编号 if (moTask.mo_task_code!.IsNotEmptyOrNull()) @@ -920,6 +935,7 @@ namespace Tnb.ProductionMgr } } row = await _db.Insertable(subMoTasks).ExecuteCommandAsync(); + await _db.Insertable(subMoTaskLogs).ExecuteCommandAsync(); } await _db.Ado.CommitTranAsync(); } @@ -1575,49 +1591,83 @@ namespace Tnb.ProductionMgr } return instance; } + // private async Task GetList(VisualDevModelListQueryInput input) + // { + // var db = _repository.AsSugarClient(); + // VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true); + // var data = await _runService.GetListResult(templateEntity, input); + // if (data?.list?.Count > 0) + // { + // foreach (var row in data.list) + // { + // var dic = row.ToDictionary(x => x.Key, x => x.Value); + // var pkName = "material_id_id"; + // if (dic.ContainsKey(pkName)) + // { + // var materialId = dic[pkName]?.ToString(); + // var material = await db.Queryable().FirstAsync(it => it.id == materialId); + // if (material != null) + // { + // row["material_id"] = $"{material.code}/{material.name}"; + // } + // } + // //模具 + // if (dic.ContainsKey("mold_id")) + // { + // var moldId = dic["mold_id"]?.ToString(); + // var mold = await db.Queryable().FirstAsync(it => it.id == moldId); + // if (mold != null) + // { + // row["mold_id"] = $"{mold.mold_code}/{mold.mold_name}"; + // } + // } + // //设备 + // if (dic.ContainsKey("eqp_id")) + // { + // var eqpId = dic["eqp_id"]?.ToString(); + // var eqp = await db.Queryable().FirstAsync(it => it.id == eqpId); + // if (eqp != null) + // { + // row["eqp_id"] = $"{eqp.code}/{eqp.name}"; + // } + // } + // } + // } + // return data!; + // } + private async Task GetList(VisualDevModelListQueryInput input) { var db = _repository.AsSugarClient(); - VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true); - var data = await _runService.GetListResult(templateEntity, input); - if (data?.list?.Count > 0) - { - foreach (var row in data.list) + Dictionary queryJson = !string.IsNullOrEmpty(input.queryJson) ? JsonConvert.DeserializeObject>(input.queryJson) : new Dictionary(); + string moTaskCode = queryJson.ContainsKey("mo_task_code") ? queryJson["mo_task_code"].ToString() : ""; + string eqpId = queryJson.ContainsKey("eqp_id") ? queryJson["eqp_id"].ToString() : ""; + var result = await db.Queryable() + .LeftJoin((a, b) => a.material_id == b.id) + .LeftJoin((a, b, c) => c.EnCode == DictConst.TaskStatus) + .LeftJoin((a, b, c, d) => c.Id == d.DictionaryTypeId && a.mo_task_status == d.EnCode) + .LeftJoin((a,b,c,d,e)=>a.mold_id==e.id) + .LeftJoin((a,b,c,d,e,f)=>a.mo_id==f.id) + .LeftJoin((a,b,c,d,e,f,g)=>a.workline_id==g.Id) + .LeftJoin((a,b,c,d,e,f,g,h)=>a.eqp_id==h.id) + .WhereIF(!string.IsNullOrEmpty(moTaskCode), (a, b, c, d) => a.mo_task_code.Contains(moTaskCode)) + .WhereIF(!string.IsNullOrEmpty(eqpId), (a, b, c, d) => a.workline_id==eqpId || a.eqp_id==eqpId) + .Select((a, b, c, d,e,f,g,h) => new WorkOrderAdjustmentListOutput { - var dic = row.ToDictionary(x => x.Key, x => x.Value); - var pkName = "material_id_id"; - if (dic.ContainsKey(pkName)) - { - var materialId = dic[pkName]?.ToString(); - var material = await db.Queryable().FirstAsync(it => it.id == materialId); - if (material != null) - { - row["material_id"] = $"{material.code}/{material.name}"; - } - } - //模具 - if (dic.ContainsKey("mold_id")) - { - var moldId = dic["mold_id"]?.ToString(); - var mold = await db.Queryable().FirstAsync(it => it.id == moldId); - if (mold != null) - { - row["mold_id"] = $"{mold.mold_code}/{mold.mold_name}"; - } - } - //设备 - if (dic.ContainsKey("eqp_id")) - { - var eqpId = dic["eqp_id"]?.ToString(); - var eqp = await db.Queryable().FirstAsync(it => it.id == eqpId); - if (eqp != null) - { - row["eqp_id"] = $"{eqp.code}/{eqp.name}"; - } - } - } - } - return data!; + id = a.id, + mo_task_code = a.mo_task_code, + material_id = b.code+"/"+b.name, + mold_id = e.mold_code+"/"+e.mold_name, + mo_task_status = d.FullName, + plan_qty = f.plan_qty, + complete_qty = SqlFunc.IsNull(a.reported_work_qty,0) + SqlFunc.IsNull(a.scrap_qty,0), + scheduled_qty = a.scheduled_qty, + workline_id = a.workline_id==null ? "" :g.EnCode+"/"+g.FullName, + estimated_start_date = a.estimated_start_date==null ? "" : a.estimated_start_date.Value.ToString("yyyy-MM-dd"), + estimated_end_date = a.estimated_end_date==null ? "" : a.estimated_end_date.Value.ToString("yyyy-MM-dd"), + eqp_id = a.eqp_id==null ? "" : h.code+"/"+h.name, + }).ToPagedListAsync(input.currentPage, input.pageSize); + return PageResult.SqlSugarPageResult(result); } /// From e6d2dda71cb0f134d92906e24e96b7d922ba3d45 Mon Sep 17 00:00:00 2001 From: zhoukeda <1315948824@qq.com> Date: Wed, 19 Jul 2023 13:37:36 +0800 Subject: [PATCH 21/32] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E5=8D=95=E8=B0=83=E6=95=B4=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs index b53f0461..b73e6164 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs @@ -1642,6 +1642,14 @@ namespace Tnb.ProductionMgr Dictionary queryJson = !string.IsNullOrEmpty(input.queryJson) ? JsonConvert.DeserializeObject>(input.queryJson) : new Dictionary(); string moTaskCode = queryJson.ContainsKey("mo_task_code") ? queryJson["mo_task_code"].ToString() : ""; string eqpId = queryJson.ContainsKey("eqp_id") ? queryJson["eqp_id"].ToString() : ""; + List worklineIds = new List(); + List equipIds = new List(); + if (!string.IsNullOrEmpty(eqpId)) + { + worklineIds = await db.Queryable().Where(x => x.ParentId == eqpId && x.Category==DictConst.RegionCategoryWorklineCode && x.DeleteMark==null).Select(x=>x.Id).ToListAsync(); + equipIds = await db.Queryable().Where(x => x.equip_type_id == eqpId).Select(x => x.id).ToListAsync(); + } + var result = await db.Queryable() .LeftJoin((a, b) => a.material_id == b.id) .LeftJoin((a, b, c) => c.EnCode == DictConst.TaskStatus) @@ -1651,7 +1659,9 @@ namespace Tnb.ProductionMgr .LeftJoin((a,b,c,d,e,f,g)=>a.workline_id==g.Id) .LeftJoin((a,b,c,d,e,f,g,h)=>a.eqp_id==h.id) .WhereIF(!string.IsNullOrEmpty(moTaskCode), (a, b, c, d) => a.mo_task_code.Contains(moTaskCode)) - .WhereIF(!string.IsNullOrEmpty(eqpId), (a, b, c, d) => a.workline_id==eqpId || a.eqp_id==eqpId) + .WhereIF(!string.IsNullOrEmpty(eqpId) && equipIds.Count<=0 && worklineIds.Count<=0, (a, b, c, d) => a.workline_id==eqpId || a.eqp_id==eqpId) + .WhereIF(worklineIds.Count>0,(a, b, c, d)=>worklineIds.Contains(a.workline_id)) + .WhereIF(equipIds.Count>0,(a, b, c, d)=>equipIds.Contains(a.eqp_id)) .Select((a, b, c, d,e,f,g,h) => new WorkOrderAdjustmentListOutput { id = a.id, From 9f7c61b0b0620b50ca2ba7fd57e17fd673fc71de Mon Sep 17 00:00:00 2001 From: alex Date: Wed, 19 Jul 2023 16:05:44 +0800 Subject: [PATCH 22/32] =?UTF-8?q?=E6=B6=88=E9=99=A4=E9=83=A8=E5=88=86warni?= =?UTF-8?q?ng?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Tnb.WarehouseMgr/WmsSetSortingService.cs | 19 +++++++++++++------ .../WmsSignForDeliveryService.cs | 4 ++-- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs index a2a3af29..c0483adf 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs @@ -64,10 +64,14 @@ namespace Tnb.WarehouseMgr { await _db.Ado.BeginTranAsync(); - var singleSorting = setSortings[^setSortings.Count]; - var curCarry = await _db.Queryable().SingleAsync(it => it.id == singleSorting.carry_id); - var isMatch = await IsCarryAndLocationMatchByCarryStd(curCarry, endLocation); - if (!isMatch) throw new AppFriendlyException("库位与载具规格不匹配", 500); + var singleSorting = new WmsSetsortingH(); + if (setSortings?.Count > 0) + { + singleSorting = setSortings[0]; + var curCarry = await _db.Queryable().SingleAsync(it => it.id == singleSorting.carry_id); + var isMatch = await IsCarryAndLocationMatchByCarryStd(curCarry, endLocation); + if (!isMatch) throw new AppFriendlyException("库位与载具规格不匹配", 500); + } if (setSortings?.Count > 0 && !onFlag) { @@ -132,7 +136,7 @@ namespace Tnb.WarehouseMgr carryMats = carryMats.OrderBy(o => o.create_time).GroupBy(g => new { g.carry_id, g.material_id, g.code_batch }) .Select(x => { - WmsCarryMat? carryMat = x.FirstOrDefault(); + WmsCarryMat carryMat = new(); carryMat.need_qty = x.Sum(d => d.need_qty); return carryMat; }) @@ -205,7 +209,10 @@ namespace Tnb.WarehouseMgr if (sPoint != null && ePoint != null) { var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id); - locIds.AddRange(points.Select(x => x.location_id).ToList()!); + if (points?.Count> 0) + { + locIds.AddRange(points.Select(x => x.location_id).ToList()!); + } //根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序) if (points?.Count > 0) { diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsSignForDeliveryService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsSignForDeliveryService.cs index f9d0b86a..6cb7f10d 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsSignForDeliveryService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsSignForDeliveryService.cs @@ -76,7 +76,7 @@ namespace Tnb.WarehouseMgr } if (carry != null) { - if (carry!.location_id!.IsNotEmptyOrNull()) + if (carry?.location_id?.IsNotEmptyOrNull() ?? false) { var loc = await _db.Queryable().SingleAsync(it => it.id == carry.location_id); loc.is_use = ((int)EnumCarryStatus.空闲).ToString(); @@ -139,7 +139,7 @@ namespace Tnb.WarehouseMgr } catch (Exception) { - isSuccessFul= false; + isSuccessFul = false; } return isSuccessFul; } From 659464f04abfbb2921414b9be3a4851f5933dafc Mon Sep 17 00:00:00 2001 From: alex Date: Wed, 19 Jul 2023 17:28:45 +0800 Subject: [PATCH 23/32] =?UTF-8?q?=E8=B0=83=E6=95=B4Mes->Wms=E7=94=9F?= =?UTF-8?q?=E4=BA=A7=E5=87=BA=E5=BA=93=E8=BF=94=E5=9B=9E=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs index f3504aab..f02850ef 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs @@ -321,6 +321,7 @@ namespace Tnb.WarehouseMgr //[NonUnify] public async Task MESCreateOutstock(MESCreateOutstockInput input) { + var isSuccessful = true; try { await _db.Ado.BeginTranAsync(); @@ -346,7 +347,7 @@ namespace Tnb.WarehouseMgr outstock.status = WmsWareHouseConst.BILLSTATUS_ADD_ID;// 新增 outstock.create_id = _userManager.UserId; outstock.create_time = DateTime.Now; - + //明细表 foreach (var outstockD in outstockDs!) { @@ -357,7 +358,7 @@ namespace Tnb.WarehouseMgr outstock.create_time = outstock.create_time; outstock.create_id = outstock.create_id; } - + //var loc = await _db.Queryable().SingleAsync(it => it.id == outstock.location_id.ToString()); var carryIds = new List(); //tablefield120 出库物料明细 @@ -445,10 +446,10 @@ namespace Tnb.WarehouseMgr } } carryIds = allOutIds.Concat(sortingOutIds).ToList(); - if(carryIds?.Count> 0) + if (carryIds?.Count > 0) { var carryId = carryIds[^carryIds.Count]; - var curCurry =await _db.Queryable().SingleAsync(it=>it.id == carryId); + var curCurry = await _db.Queryable().SingleAsync(it => it.id == carryId); var isMatch = await IsCarryAndLocationMatchByCarryStd(curCurry, location); if (!isMatch) throw new AppFriendlyException("该载具无法放置到目标库位", 500); } @@ -549,11 +550,11 @@ namespace Tnb.WarehouseMgr } catch (Exception ex) { + isSuccessful = false; JNPF.Logging.Log.Error(ex.Message); await _db.Ado.RollbackTranAsync(); - return await ToApiResult(JNPF.Common.Enums.HttpStatusCode.InternalServerError, ex.Message); } - return await ToApiResult(); + return isSuccessful; } public override async Task ModifyAsync(WareHouseUpInput input) From b2354f31bbcffb3d20433bab2758a8ab8ad263e8 Mon Sep 17 00:00:00 2001 From: alex Date: Wed, 19 Jul 2023 17:29:22 +0800 Subject: [PATCH 24/32] 1 --- 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 f02850ef..55a83527 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs @@ -553,6 +553,7 @@ namespace Tnb.WarehouseMgr isSuccessful = false; JNPF.Logging.Log.Error(ex.Message); await _db.Ado.RollbackTranAsync(); + throw ex; } return isSuccessful; } From 48208de17388eb6771f2991f3004bcd17a9372d9 Mon Sep 17 00:00:00 2001 From: zhoukeda <1315948824@qq.com> Date: Wed, 19 Jul 2023 17:32:56 +0800 Subject: [PATCH 25/32] =?UTF-8?q?=E7=94=9F=E4=BA=A7=E9=A2=86=E6=96=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Consts/WebApiConst.cs | 3 + .../Entity/PrdOutstockD.cs | 57 +++++++++ .../Entity/PrdOutstockH.cs | 72 +++++++++++ .../IPrdOutstockService.cs | 10 ++ .../Tnb.ProductionMgr/PrdOutstockService.cs | 115 ++++++++++++++++++ 5 files changed, 257 insertions(+) create mode 100644 ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdOutstockD.cs create mode 100644 ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdOutstockH.cs create mode 100644 ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdOutstockService.cs create mode 100644 ProductionMgr/Tnb.ProductionMgr/PrdOutstockService.cs diff --git a/BasicData/Tnb.BasicData.Entities/Consts/WebApiConst.cs b/BasicData/Tnb.BasicData.Entities/Consts/WebApiConst.cs index c3312e59..bc6ff7f8 100644 --- a/BasicData/Tnb.BasicData.Entities/Consts/WebApiConst.cs +++ b/BasicData/Tnb.BasicData.Entities/Consts/WebApiConst.cs @@ -9,6 +9,9 @@ namespace Tnb.BasicData //载具签收接口 public const string MES_CARRY_SIGN = "/api/wms/wms-sign-for-delivery/mes-carry-sign"; + + //生产出库接口 + public const string MES_CREATE_OUTSTOCK = "/api/wms/wms-out-stock/mes-create-outstock"; #endregion diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdOutstockD.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdOutstockD.cs new file mode 100644 index 00000000..960834c6 --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdOutstockD.cs @@ -0,0 +1,57 @@ +using JNPF.Common.Contracts; +using JNPF.Common.Security; +using SqlSugar; + +namespace Tnb.ProductionMgr.Entities; + +/// +/// mes生产领料子表 +/// +[SugarTable("prd_outstock_d")] +public partial class PrdOutstockD : BaseEntity +{ + public PrdOutstockD() + { + id = SnowflakeIdHelper.NextId(); + } + /// + /// 物料id + /// + public string? material_id { get; set; } + + /// + /// 物料编号 + /// + public string? material_code { get; set; } + + /// + /// 单位id + /// + public string? unit_id { get; set; } + + /// + /// 出库需求数量 + /// + public string? pr_qty { get; set; } + + /// + /// 来源单据id + /// + public string? source_id { get; set; } + + /// + /// 批次 + /// + public string? code_batch { get; set; } + + /// + /// 生产领料主表id + /// + public string? outstock_id { get; set; } + + /// + /// 物料名称 + /// + public string? material_name { get; set; } + +} \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdOutstockH.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdOutstockH.cs new file mode 100644 index 00000000..8e07b8db --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdOutstockH.cs @@ -0,0 +1,72 @@ +using JNPF.Common.Contracts; +using JNPF.Common.Security; +using SqlSugar; + +namespace Tnb.ProductionMgr.Entities; + +/// +/// mes生产领料主表 +/// +[SugarTable("prd_outstock_h")] +public partial class PrdOutstockH : BaseEntity +{ + public PrdOutstockH() + { + id = SnowflakeIdHelper.NextId(); + } + /// + /// 出库单创建日期 + /// + public string? bill_date { get; set; } + + /// + /// 单据类型 + /// + public string? bill_type { get; set; } + + /// + /// 发料仓库id + /// + public string? warehouse_id { get; set; } + + /// + /// 目标库位编号 + /// + public string? location_code { get; set; } + + /// + /// 创建用户 + /// + public string? create_id { get; set; } + + /// + /// 所属组织 + /// + public string? org_id { get; set; } + + /// + /// 单据编号 + /// + public string? bill_code { get; set; } + + /// + /// 发料工位 + /// + public string? workstation { get; set; } + + /// + /// 所属产线 + /// + public string? workline { get; set; } + + /// + /// 流程任务Id + /// + public string? f_flowtaskid { get; set; } + + /// + /// 流程引擎Id + /// + public string? f_flowid { get; set; } + +} \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdOutstockService.cs b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdOutstockService.cs new file mode 100644 index 00000000..3d8bed0f --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdOutstockService.cs @@ -0,0 +1,10 @@ +namespace Tnb.ProductionMgr.Interfaces +{ + /// + /// 生产领料服务 + /// + public interface IPrdOutstockService + { + + } +} \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdOutstockService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdOutstockService.cs new file mode 100644 index 00000000..87cd0810 --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr/PrdOutstockService.cs @@ -0,0 +1,115 @@ +using JNPF; +using JNPF.Common.Core.Manager; +using JNPF.Common.Dtos.VisualDev; +using JNPF.DependencyInjection; +using JNPF.DynamicApiController; +using JNPF.Extras.CollectiveOAuth.Models; +using JNPF.Extras.CollectiveOAuth.Utils; +using JNPF.FriendlyException; +using JNPF.Logging; +using JNPF.Systems.Interfaces.System; +using JNPF.VisualDev; +using JNPF.VisualDev.Entitys; +using JNPF.VisualDev.Interfaces; +using Microsoft.AspNetCore.Mvc; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using SqlSugar; +using Tnb.BasicData; +using Tnb.BasicData.Entities; +using Tnb.ProductionMgr.Entities; +using Tnb.ProductionMgr.Interfaces; +using Tnb.WarehouseMgr.Entities.Dto.Inputs; + +namespace Tnb.ProductionMgr +{ + /// + /// 生产领料 + /// + [ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 700)] + [Route("api/[area]/[controller]/[action]")] + [OverideVisualDev(ModuleId)] + public class PrdOutstockService : IOverideVisualDevService, IPrdOutstockService, IDynamicApiController, ITransient + { + private const string ModuleId = "27542506559765"; + private readonly ISqlSugarRepository _repository; + private readonly ISqlSugarClient _db; + private readonly IRunService _runService; + private readonly IVisualDevService _visualDevService; + private readonly IDictionaryDataService _dictionaryDataService; + private readonly IUserManager _userManager; + public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc(); + + public PrdOutstockService(ISqlSugarRepository repository, IRunService runService, IUserManager userManager,IVisualDevService visualDevService, IDictionaryDataService dictionaryDataService) + { + _db = repository.AsSugarClient(); + _runService = runService; + _visualDevService = visualDevService; + _dictionaryDataService = dictionaryDataService; + _repository = repository; + _userManager = userManager; + OverideFuncs.CreateAsync = Create; + } + + private async Task Create(VisualDevModelDataCrInput visualDevModelDataCrInput) + { + try + { + var db = _repository.AsSugarClient(); + VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true); + await _runService.Create(templateEntity, visualDevModelDataCrInput); + + + MESCreateOutstockInput input = new MESCreateOutstockInput(); + input.outstock = new MESWmsOutstockHInput(); + input.outstockDs = new List(); + + string locationId = visualDevModelDataCrInput.data.ContainsKey("location_id") ? visualDevModelDataCrInput.data["location_id"].ToString() : ""; + BasLocation location = await db.Queryable().SingleAsync(x => x.id == locationId); + + input.outstock.bill_type = visualDevModelDataCrInput.data.ContainsKey("bill_type") ? visualDevModelDataCrInput.data["bill_type"].ToString() : ""; + input.outstock.bill_date = visualDevModelDataCrInput.data.ContainsKey("bill_date") ? Convert.ToDateTime(visualDevModelDataCrInput.data["bill_date"].ToString()) : DateTime.Now; + input.outstock.org_id = _userManager.GetUserInfo().Result.organizeId; + input.outstock.warehouse_id = visualDevModelDataCrInput.data.ContainsKey("warehouse_id") ? visualDevModelDataCrInput.data["warehouse_id"].ToString() : ""; + input.outstock.create_id = _userManager.UserId; + input.outstock.location_code = location?.location_code ?? ""; + + // foreach (var item in (JArray)visualDevModelDataCrInput.data["tablefield107"]) + // { + // input.outstockDs.Add(new MESWmsOutstockDInput() + // { + // material_id = item.Value("material_id"), + // material_code = item.Value("material_code"), + // unit_id = item.Value("unit_id"), + // pr_qty = item.Value("pr_qty"), + // code_batch = item.Value("code_batch"), + // source_id = item.Value("source_id"), + // }); + // } + + input.outstockDs = JsonConvert.DeserializeObject>(JsonConvert.SerializeObject(visualDevModelDataCrInput.data["tablefield107"])); + string domain = (App.HttpContext.Request.IsHttps ? "https://" : "http://") + App.HttpContext.Request.Host; + Dictionary header = new Dictionary() + { + ["Authorization"] = App.HttpContext.Request.Headers["Authorization"] + }; + var sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CREATE_OUTSTOCK,JsonConvert.SerializeObject(input),header); + Log.Information(sendResult); + + AuthResponse authResponse = JsonConvert.DeserializeObject(sendResult); + if (authResponse.code != 200) + { + throw Oops.Bah(authResponse.msg); + } + return await Task.FromResult(true); + } + catch (Exception e) + { + Console.WriteLine(e); + Log.Error(e.Message); + throw Oops.Bah(e.Message); + } + + } + } +} \ No newline at end of file From 630a8b76d061ca5adc2a3193beff2d51b285b781 Mon Sep 17 00:00:00 2001 From: zhoukeda <1315948824@qq.com> Date: Wed, 19 Jul 2023 17:57:53 +0800 Subject: [PATCH 26/32] =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E4=BA=8C=E7=BB=B4?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entity/BasQrcode.cs | 47 ++++++++++ EquipMgr/Tnb.EquipMgr/EquipmentService.cs | 92 +++++++++++++++++- .../Tnb.EquipMgr/ToolMoldLocationService.cs | 94 ++++++++++++++++++- .../Permission/DepartmentService.cs | 63 +++++++++++++ 4 files changed, 292 insertions(+), 4 deletions(-) create mode 100644 BasicData/Tnb.BasicData.Entities/Entity/BasQrcode.cs diff --git a/BasicData/Tnb.BasicData.Entities/Entity/BasQrcode.cs b/BasicData/Tnb.BasicData.Entities/Entity/BasQrcode.cs new file mode 100644 index 00000000..8e0e5ebc --- /dev/null +++ b/BasicData/Tnb.BasicData.Entities/Entity/BasQrcode.cs @@ -0,0 +1,47 @@ +using JNPF.Common.Contracts; +using JNPF.Common.Security; +using SqlSugar; + +namespace Tnb.BasicData.Entities; + +/// +/// 系统二维码表 +/// +[SugarTable("bas_qrcode")] +public partial class BasQrcode : BaseEntity +{ + public BasQrcode() + { + id = SnowflakeIdHelper.NextId(); + } + /// + /// 编码 + /// + public string code { get; set; } = string.Empty; + + /// + /// 关联表id + /// + public string? source_id { get; set; } + + /// + /// 关联表名 + /// + public string? source_name { get; set; } + + /// + /// 创建用户 + /// + public string? create_id { get; set; } + + /// + /// 创建时间 + /// + public DateTime? create_time { get; set; } + + /// + /// 所属组织 + /// + public string? org_id { get; set; } + +} \ No newline at end of file diff --git a/EquipMgr/Tnb.EquipMgr/EquipmentService.cs b/EquipMgr/Tnb.EquipMgr/EquipmentService.cs index a904bcaa..610e4002 100644 --- a/EquipMgr/Tnb.EquipMgr/EquipmentService.cs +++ b/EquipMgr/Tnb.EquipMgr/EquipmentService.cs @@ -1,13 +1,19 @@ using Aop.Api.Domain; using Aspose.Cells.Drawing; +using JNPF.Common.Core.Manager; +using JNPF.Common.Dtos.VisualDev; using JNPF.Common.Filter; using JNPF.Common.Security; using JNPF.DependencyInjection; using JNPF.DynamicApiController; using JNPF.Extras.CollectiveOAuth.Models; +using JNPF.FriendlyException; +using JNPF.Logging; using JNPF.Systems.Entitys.Permission; using JNPF.VisualDev; +using JNPF.VisualDev.Entitys; using JNPF.VisualDev.Entitys.Dto.VisualDevModelData; +using JNPF.VisualDev.Interfaces; using Mapster; using Microsoft.AspNetCore.Mvc; using Senparc.NeuChar.ApiHandlers; @@ -16,6 +22,7 @@ using Tnb.BasicData; using Tnb.EquipMgr.Entities; using Tnb.EquipMgr.Entities.Dto; using Tnb.EquipMgr.Interfaces; +using Tnb.BasicData.Entities; namespace Tnb.EquipMgr { @@ -29,12 +36,24 @@ namespace Tnb.EquipMgr public class EquipmentService : IOverideVisualDevService, IEquipmentService, IDynamicApiController, ITransient { public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc(); - private const string ModuleId = "25064865727509"; + private const string ModuleId = "26012367560469"; private readonly ISqlSugarRepository _repository; + private readonly IVisualDevService _visualDevService; + private readonly IRunService _runService; + private readonly IUserManager _userManager; - public EquipmentService(ISqlSugarRepository repository) + public EquipmentService(ISqlSugarRepository repository, + IVisualDevService visualDevService, + IUserManager userManager, + IRunService runService + ) { _repository = repository; + _visualDevService = visualDevService; + _runService = runService; + _userManager = userManager; + OverideFuncs.CreateAsync = Create; + OverideFuncs.UpdateAsync = Update; } /// /// 在线开发-获取设备列表 @@ -67,6 +86,75 @@ namespace Tnb.EquipMgr .ToPagedListAsync(input.currentPage, input.pageSize); return pagedList; } + + private async Task Create(VisualDevModelDataCrInput visualDevModelDataCrInput) + { + string qrcode = visualDevModelDataCrInput.data.ContainsKey("qrcode") ? visualDevModelDataCrInput.data["qrcode"].ToString() : ""; + if (!string.IsNullOrEmpty(qrcode) && await _repository.AsSugarClient().Queryable().AnyAsync(x => x.code == qrcode)) + { + throw Oops.Bah("二维码总表中已存在该二维码"); + } + else + { + VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true); + await _runService.Create(templateEntity, visualDevModelDataCrInput); + + string equipId = visualDevModelDataCrInput.data["ReturnIdentity"].ToString() ?? ""; + + if (!string.IsNullOrEmpty(qrcode)) + { + BasQrcode basQrcode = new BasQrcode() + { + code = visualDevModelDataCrInput.data["qrcode"].ToString(), + source_id = equipId, + source_name = "EQP_EQUIPMENT", + create_id = _userManager.UserId, + create_time = DateTime.Now, + org_id = _userManager.GetUserInfo().Result.organizeId, + }; + await _repository.AsSugarClient().Insertable(basQrcode).ExecuteCommandAsync(); + } + } + return await Task.FromResult(true); + } + + private async Task Update(string id,VisualDevModelDataUpInput visualDevModelDataUpInput) + { + string qrcode = visualDevModelDataUpInput.data.ContainsKey("qrcode") ? visualDevModelDataUpInput.data["qrcode"].ToString() : ""; + if (!string.IsNullOrEmpty(qrcode) && await _repository.AsSugarClient().Queryable().AnyAsync(x => x.code == visualDevModelDataUpInput.data["qrcode"] && x.source_id!=id)) + { + throw Oops.Bah("二维码总表中已存在该二维码"); + } + else + { + VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true); + await _runService.Update(id,templateEntity, visualDevModelDataUpInput); + + if (!string.IsNullOrEmpty(qrcode)) + { + if (await _repository.AsSugarClient().Queryable().AnyAsync(x => x.source_id == id)) + { + await _repository.AsSugarClient().Updateable() + .SetColumns(x => x.code == visualDevModelDataUpInput.data["qrcode"].ToString()).Where(x => x.source_id == id) + .ExecuteCommandAsync(); + } + else + { + BasQrcode basQrcode = new BasQrcode() + { + code = visualDevModelDataUpInput.data["qrcode"].ToString(), + source_id = id, + source_name = "EQP_EQUIPMENT", + create_id = _userManager.UserId, + create_time = DateTime.Now, + org_id = _userManager.GetUserInfo().Result.organizeId, + }; + await _repository.AsSugarClient().Insertable(basQrcode).ExecuteCommandAsync(); + } + } + } + return await Task.FromResult(true); + } [HttpPost] public async Task GetEntityById(Dictionary dic) diff --git a/EquipMgr/Tnb.EquipMgr/ToolMoldLocationService.cs b/EquipMgr/Tnb.EquipMgr/ToolMoldLocationService.cs index bfc73a31..465f1a23 100644 --- a/EquipMgr/Tnb.EquipMgr/ToolMoldLocationService.cs +++ b/EquipMgr/Tnb.EquipMgr/ToolMoldLocationService.cs @@ -4,10 +4,17 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Aspose.Cells.Drawing; +using JNPF.Common.Core.Manager; +using JNPF.Common.Dtos.VisualDev; using JNPF.DependencyInjection; using JNPF.DynamicApiController; +using JNPF.FriendlyException; +using JNPF.VisualDev; +using JNPF.VisualDev.Entitys; +using JNPF.VisualDev.Interfaces; using Microsoft.AspNetCore.Mvc; using SqlSugar; +using Tnb.BasicData.Entities; using Tnb.EquipMgr.Entities; using Tnb.EquipMgr.Interfaces; @@ -18,16 +25,99 @@ namespace Tnb.EquipMgr /// [ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)] [Route("api/[area]/[controller]/[action]")] - public class ToolMoldLocationService : IToolMoldLocationService, IDynamicApiController, ITransient + [OverideVisualDev(ModuleId)] + public class ToolMoldLocationService : IToolMoldLocationService,IOverideVisualDevService, IDynamicApiController, ITransient { + public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc(); + private const string ModuleId = "27207685649173"; private readonly ISqlSugarClient _db; - public ToolMoldLocationService(ISqlSugarRepository repository) + private readonly IVisualDevService _visualDevService; + private readonly IRunService _runService; + private readonly IUserManager _userManager; + public ToolMoldLocationService(ISqlSugarRepository repository, + IVisualDevService visualDevService, + IUserManager userManager, + IRunService runService) { _db = repository.AsSugarClient(); + _visualDevService = visualDevService; + _runService = runService; + _userManager = userManager; + OverideFuncs.CreateAsync = Create; + OverideFuncs.UpdateAsync = Update; } public async Task> GetLocationDictionary() { return await _db.Queryable().ToDictionaryAsync(x => x.id, x => x.location_code); } + + private async Task Create(VisualDevModelDataCrInput visualDevModelDataCrInput) + { + string qrcode = visualDevModelDataCrInput.data.ContainsKey("qrcode") ? visualDevModelDataCrInput.data["qrcode"].ToString() : ""; + if (!string.IsNullOrEmpty(qrcode) && await _db.Queryable().AnyAsync(x => x.code == qrcode)) + { + throw Oops.Bah("二维码总表中已存在该二维码"); + } + else + { + VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true); + await _runService.Create(templateEntity, visualDevModelDataCrInput); + + string id = visualDevModelDataCrInput.data["ReturnIdentity"].ToString() ?? ""; + + if (!string.IsNullOrEmpty(qrcode)) + { + BasQrcode basQrcode = new BasQrcode() + { + code = visualDevModelDataCrInput.data["qrcode"].ToString(), + source_id = id, + source_name = "TOOL_LOCATION", + create_id = _userManager.UserId, + create_time = DateTime.Now, + org_id = _userManager.GetUserInfo().Result.organizeId, + }; + await _db.Insertable(basQrcode).ExecuteCommandAsync(); + } + } + return await Task.FromResult(true); + } + + private async Task Update(string id,VisualDevModelDataUpInput visualDevModelDataUpInput) + { + string qrcode = visualDevModelDataUpInput.data.ContainsKey("qrcode") ? visualDevModelDataUpInput.data["qrcode"].ToString() : ""; + if (!string.IsNullOrEmpty(qrcode) && await _db.Queryable().AnyAsync(x => x.code == visualDevModelDataUpInput.data["qrcode"] && x.source_id!=id)) + { + throw Oops.Bah("二维码总表中已存在该二维码"); + } + else + { + VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true); + await _runService.Update(id,templateEntity, visualDevModelDataUpInput); + + if (!string.IsNullOrEmpty(qrcode)) + { + if (await _db.Queryable().AnyAsync(x => x.source_id == id)) + { + await _db.Updateable() + .SetColumns(x => x.code == visualDevModelDataUpInput.data["qrcode"].ToString()).Where(x => x.source_id == id) + .ExecuteCommandAsync(); + } + else + { + BasQrcode basQrcode = new BasQrcode() + { + code = visualDevModelDataUpInput.data["qrcode"].ToString(), + source_id = id, + source_name = "TOOL_LOCATION", + create_id = _userManager.UserId, + create_time = DateTime.Now, + org_id = _userManager.GetUserInfo().Result.organizeId, + }; + await _db.Insertable(basQrcode).ExecuteCommandAsync(); + } + } + } + return await Task.FromResult(true); + } } } diff --git a/system/Tnb.Systems/Permission/DepartmentService.cs b/system/Tnb.Systems/Permission/DepartmentService.cs index 85325c15..17b56670 100644 --- a/system/Tnb.Systems/Permission/DepartmentService.cs +++ b/system/Tnb.Systems/Permission/DepartmentService.cs @@ -313,6 +313,32 @@ public class DepartmentService : IDepartmentService, IDynamicApiController, ITra if (adminlist.Any()) await _repository.AsSugarClient().Insertable(adminlist).CallEntityMethod(m => m.Create()).ExecuteReturnEntityAsync(); #endregion + + if (input.category != DictConst.RegionCategoryCompanyCode) + { + var jsonObj = input.propertyJson; + var qrcode = jsonObj.GetValue("qrcode"); + if (qrcode is not null && !string.IsNullOrEmpty(qrcode.ToString())) + { + if (await _repository.AsSugarClient().Queryable().AnyAsync(x => x.code == qrcode.ToString())) + { + throw Oops.Bah("二维码总表中已存在该二维码"); + } + else + { + BasQrcode basQrcode = new BasQrcode() + { + code = qrcode.ToString(), + source_id = entity.Id, + source_name = "BASE_ORGANIZE", + create_id = _userManager.UserId, + create_time = DateTime.Now, + org_id = _userManager.GetUserInfo().Result.organizeId, + }; + await _repository.AsSugarClient().Insertable(basQrcode).ExecuteCommandAsync(); + } + } + } #region 第三方同步 @@ -450,6 +476,43 @@ public class DepartmentService : IDepartmentService, IDynamicApiController, ITra int isOK = await _repository.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).CallEntityMethod(m => m.LastModify()).ExecuteCommandAsync(); if (!(isOK > 0)) throw Oops.Oh(ErrorCode.D2018); + + //modified by zkd on 20230718 处理二维码 + if (input.category != DictConst.RegionCategoryCompanyCode) + { + var jsonObj = input.propertyJson; + var qrcode = jsonObj.GetValue("qrcode"); + if (qrcode is not null && !string.IsNullOrEmpty(qrcode.ToString())) + { + if (await _repository.AsSugarClient().Queryable().AnyAsync(x => x.code == qrcode.ToString() && x.source_id!=id)) + { + throw Oops.Bah("二维码总表中已存在该二维码"); + } + else + { + if (await _repository.AsSugarClient().Queryable().AnyAsync(x => x.source_id == id)) + { + await _repository.AsSugarClient().Updateable() + .SetColumns(x => x.code == qrcode.ToString()).Where(x => x.source_id == id) + .ExecuteCommandAsync(); + } + else + { + BasQrcode basQrcode = new BasQrcode() + { + code = qrcode.ToString(), + source_id = id, + source_name = "BASE_ORGANIZE", + create_id = _userManager.UserId, + create_time = DateTime.Now, + org_id = _userManager.GetUserInfo().Result.organizeId, + }; + await _repository.AsSugarClient().Insertable(basQrcode).ExecuteCommandAsync(); + } + } + } + } + //modified by ly on 20230426 处理工位信息,将工位插入到设备表 if (input.category == DictConst.RegionCategoryStationCode) { From 7cc193c978da3bd4bfcc46410784846c30a47bd5 Mon Sep 17 00:00:00 2001 From: alex Date: Thu, 20 Jul 2023 09:53:20 +0800 Subject: [PATCH 27/32] =?UTF-8?q?=E8=B0=83=E6=95=B4Mes->Wms=20=E5=87=BA?= =?UTF-8?q?=E5=BA=93=E7=94=B3=E8=AF=B7=E6=8E=A5=E5=8F=A3=EF=BC=8Ccarry=5Fi?= =?UTF-8?q?d=E4=B8=BA=E7=A9=BA=E7=9A=84bug?= 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 55a83527..3a7ff065 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs @@ -422,6 +422,7 @@ namespace Tnb.WarehouseMgr .Select(x => { WmsCarryMat carryMat = new(); + carryMat.carry_id = x.Key.carry_id; carryMat.need_qty = x.Sum(d => d.need_qty); return carryMat; }) From 46e280bf4cc61bed1e85a7d059a5111d606a1ae7 Mon Sep 17 00:00:00 2001 From: alex Date: Thu, 20 Jul 2023 10:37:45 +0800 Subject: [PATCH 28/32] 1 --- WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs | 7 ++++--- WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs index 3a7ff065..1e6c5334 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs @@ -150,7 +150,8 @@ namespace Tnb.WarehouseMgr carryMats = carryMats.OrderBy(o => o.create_time).GroupBy(g => new { g.carry_id, g.material_id, g.code_batch }) .Select(x => { - WmsCarryMat carryMat = new(); + var arr = x.ToArray(); + WmsCarryMat carryMat = arr[^arr.Length]; carryMat.need_qty = x.Sum(d => d.need_qty); return carryMat; }) @@ -421,8 +422,8 @@ namespace Tnb.WarehouseMgr carryMats = carryMats.OrderBy(o => o.create_time).GroupBy(g => new { g.carry_id, g.material_id, g.code_batch }) .Select(x => { - WmsCarryMat carryMat = new(); - carryMat.carry_id = x.Key.carry_id; + var arr = x.ToArray(); + WmsCarryMat carryMat = arr[^arr.Length]; carryMat.need_qty = x.Sum(d => d.need_qty); return carryMat; }) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs index c0483adf..857344dc 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs @@ -136,8 +136,9 @@ namespace Tnb.WarehouseMgr carryMats = carryMats.OrderBy(o => o.create_time).GroupBy(g => new { g.carry_id, g.material_id, g.code_batch }) .Select(x => { - WmsCarryMat carryMat = new(); - carryMat.need_qty = x.Sum(d => d.need_qty); + var arr = x.ToArray(); + WmsCarryMat carryMat = arr[^arr.Length]; + carryMat.need_qty = arr.Sum(d => d.need_qty); return carryMat; }) .ToList(); @@ -209,7 +210,7 @@ namespace Tnb.WarehouseMgr if (sPoint != null && ePoint != null) { var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id); - if (points?.Count> 0) + if (points?.Count > 0) { locIds.AddRange(points.Select(x => x.location_id).ToList()!); } From 74b13dcfbd9d89bb225fcfc7a692d4a32bd0c125 Mon Sep 17 00:00:00 2001 From: zhoukeda <1315948824@qq.com> Date: Thu, 20 Jul 2023 14:04:21 +0800 Subject: [PATCH 29/32] =?UTF-8?q?=E7=94=9F=E4=BA=A7=E6=8E=92=E4=BA=A7?= =?UTF-8?q?=E7=AE=97=E9=A2=84=E8=AE=A1=E7=BB=93=E6=9D=9F=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entity/BasStandardTime.cs | 112 ++++++++++++++++++ .../PrdManage/CountEstimatedEndTimeInput.cs | 25 ++++ .../Dto/PrdManage/FeedingRecordTreeOutput.cs | 26 ++++ .../Tnb.ProductionMgr.csproj | 1 + 4 files changed, 164 insertions(+) create mode 100644 BasicData/Tnb.BasicData.Entities/Entity/BasStandardTime.cs create mode 100644 ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/CountEstimatedEndTimeInput.cs create mode 100644 ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/FeedingRecordTreeOutput.cs diff --git a/BasicData/Tnb.BasicData.Entities/Entity/BasStandardTime.cs b/BasicData/Tnb.BasicData.Entities/Entity/BasStandardTime.cs new file mode 100644 index 00000000..e52075d7 --- /dev/null +++ b/BasicData/Tnb.BasicData.Entities/Entity/BasStandardTime.cs @@ -0,0 +1,112 @@ +using JNPF.Common.Contracts; +using JNPF.Common.Security; +using SqlSugar; + +namespace Tnb.BasicData.Entities; + +/// +/// 标准工时 +/// +[SugarTable("bas_standard_time")] +public partial class BasStandardTime : BaseEntity +{ + public BasStandardTime() + { + id = SnowflakeIdHelper.NextId(); + } + /// + /// 生产BOMid + /// + public string? mbom_id { get; set; } + + /// + /// 工艺路线id + /// + public string? routing_id { get; set; } + + /// + /// 工序id + /// + public string? process_id { get; set; } + + /// + /// 工位id + /// + public string? station_id { get; set; } + + /// + /// 类型 + /// + public string? type { get; set; } + + /// + /// 标准工时 + /// + public string? standard_time { get; set; } + + /// + /// 标准工时单位 + /// + public string? standard_time_unit { get; set; } + + /// + /// 标准产能 + /// + public string? standard_capacity { get; set; } + + /// + /// 标准产能单位 + /// + public string? standard_capacity_unit { get; set; } + + /// + /// 创建用户 + /// + public string? create_id { get; set; } + + /// + /// 创建时间 + /// + public DateTime? create_time { get; set; } + + /// + /// 修改用户 + /// + public string? modify_id { get; set; } + + /// + /// 修改时间 + /// + public DateTime? modify_time { get; set; } + + /// + /// 所属组织 + /// + public string? org_id { get; set; } + + /// + /// 编号 + /// + public string? code { get; set; } + + /// + /// 流程任务Id + /// + public string? f_flowtaskid { get; set; } + + /// + /// 流程引擎Id + /// + public string? f_flowid { get; set; } + + /// + /// 是否启用 + /// + public int? enabled { get; set; } + + /// + /// 工序来源选择 + /// + public string? process_source { get; set; } + +} diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/CountEstimatedEndTimeInput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/CountEstimatedEndTimeInput.cs new file mode 100644 index 00000000..4f74f496 --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/CountEstimatedEndTimeInput.cs @@ -0,0 +1,25 @@ +namespace Tnb.ProductionMgr.Entities.Dto.PrdManage +{ + /// + /// 排产用于计算预计结束时间 + /// + public class CountEstimatedEndTimeInput + { + public DateTime estimated_start_date { get; set; } + + public int scheduled_qty { get; set; } + + public string? equip_id { get; set; } + + public string? molds_id { get; set; } + + public string? material_id { get; set; } + + public string? mbom_id { get; set; } + + /// + /// 1 注塑挤出排产 2 组装包装排产 + /// + public int type { get; set; } + } +} \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/FeedingRecordTreeOutput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/FeedingRecordTreeOutput.cs new file mode 100644 index 00000000..f8cae0d2 --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/FeedingRecordTreeOutput.cs @@ -0,0 +1,26 @@ +namespace Tnb.ProductionMgr.Entities.Dto +{ + public class FeedingRecordTreeOutput + { + public string id { get; set; } + public string mo_task_code { get; set; } + public List children { get; set; } = new List(); + } + + public class FeedingRecordChildren + { + public string id { get; set; } + public string code { get; set; } + + public string mo_task_id { get; set; } + + public List children { get; set; } = new List(); + } + + public class FeedingRecordMaterialChildren + { + public string material_code { get; set; } + + public string material_name { get; set; } + } +} \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr/Tnb.ProductionMgr.csproj b/ProductionMgr/Tnb.ProductionMgr/Tnb.ProductionMgr.csproj index 6316cd83..6aa07278 100644 --- a/ProductionMgr/Tnb.ProductionMgr/Tnb.ProductionMgr.csproj +++ b/ProductionMgr/Tnb.ProductionMgr/Tnb.ProductionMgr.csproj @@ -12,6 +12,7 @@ + From 818e2592059368e2fc114315ecb906310b16cd78 Mon Sep 17 00:00:00 2001 From: zhoukeda <1315948824@qq.com> Date: Thu, 20 Jul 2023 14:06:35 +0800 Subject: [PATCH 30/32] =?UTF-8?q?=E8=B0=83wms=E6=8E=A5=E5=8F=A3=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E6=88=90=E5=8A=9F=E5=90=8E=E5=86=8D=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entity/PerProcessStandardsH.cs | 5 ++ .../Dto/PrdManage/ReportRecordListOutput.cs | 2 + .../IPrdFeedingService.cs | 6 ++ .../Tnb.ProductionMgr/PrdFeedingService.cs | 79 +++++++++++++++++-- .../Tnb.ProductionMgr/PrdInstockService.cs | 64 +++++++++++---- .../Tnb.ProductionMgr/PrdMoTaskService.cs | 37 +++++++++ .../Tnb.ProductionMgr/PrdOutstockService.cs | 10 ++- .../ProductionReportRecordService.cs | 3 +- 8 files changed, 177 insertions(+), 29 deletions(-) diff --git a/PerMgr/Tnb.PerMgr.Entities/Entity/PerProcessStandardsH.cs b/PerMgr/Tnb.PerMgr.Entities/Entity/PerProcessStandardsH.cs index feee5438..2c3cf474 100644 --- a/PerMgr/Tnb.PerMgr.Entities/Entity/PerProcessStandardsH.cs +++ b/PerMgr/Tnb.PerMgr.Entities/Entity/PerProcessStandardsH.cs @@ -103,5 +103,10 @@ public partial class PerProcessStandardsH : BaseEntity /// 流程引擎Id /// public string? f_flowid { get; set; } + + /// + /// 成型周期 + /// + public decimal? moulding_cycle { get; set; } } diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/ReportRecordListOutput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/ReportRecordListOutput.cs index d337b189..b060203a 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/ReportRecordListOutput.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/ReportRecordListOutput.cs @@ -27,5 +27,7 @@ namespace Tnb.ProductionMgr.Entities.Dto public string? create_id { get; set; } = string.Empty; public string? create_id_id { get; set; } = string.Empty; public string? create_time { get; set; } = string.Empty; + + public string? batch { get; set; } = string.Empty; } } \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdFeedingService.cs b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdFeedingService.cs index c719944a..17e095c4 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdFeedingService.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdFeedingService.cs @@ -21,5 +21,11 @@ namespace Tnb.ProductionMgr.Interfaces /// /// public Task SaveDataNew(MaterialReceiptNewInput input); + + /// + /// 投料记录 + /// + /// + public Task GetFeedingRecordTree(); } } \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs index 2a0d6aec..32bc5917 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs @@ -4,10 +4,13 @@ using JNPF.Common.Enums; using JNPF.Common.Security; using JNPF.DependencyInjection; using JNPF.DynamicApiController; +using JNPF.Extras.CollectiveOAuth.Models; using JNPF.Extras.CollectiveOAuth.Utils; using JNPF.FriendlyException; +using JNPF.Logging; using JNPF.Systems.Entitys.Permission; using JNPF.Systems.Interfaces.System; +using JNPF.VisualDev.Entitys; using Microsoft.AspNetCore.Mvc; using Microsoft.ClearScript.Util.Web; using Newtonsoft.Json; @@ -163,6 +166,9 @@ namespace Tnb.ProductionMgr public async Task SaveDataNew(MaterialReceiptNewInput input) { var db = _repository.AsSugarClient(); + PrdFeedingH prdFeedingH = null; + List list = new List(); + DbResult result2 = new DbResult(); DbResult result = await db.Ado.UseTranAsync(async () => { var moTask = await db.Queryable().FirstAsync(x => x.id == input.mo_task_id); @@ -176,9 +182,8 @@ namespace Tnb.ProductionMgr .ToListAsync(); - string code = await _billRullService.GetBillNumber(Tnb.BasicData.CodeTemplateConst.FEEDING_CODE); - PrdFeedingH prdFeedingH = new PrdFeedingH() + prdFeedingH = new PrdFeedingH() { code = code, station_id = input.station_id, @@ -195,8 +200,7 @@ namespace Tnb.ProductionMgr create_time = DateTime.Now, org_id = _userManager.GetUserInfo().Result.organizeId }; - - List list = new List(); + if (input.details != null && input.details.Count > 0) { foreach (var item in input.details) @@ -253,8 +257,8 @@ namespace Tnb.ProductionMgr } - await db.Insertable(prdFeedingH).ExecuteCommandAsync(); - await db.Insertable(list).ExecuteCommandAsync(); + // await db.Insertable(prdFeedingH).ExecuteCommandAsync(); + // await db.Insertable(list).ExecuteCommandAsync(); }); @@ -281,10 +285,69 @@ namespace Tnb.ProductionMgr ["Authorization"] = App.HttpContext.Request.Headers["Authorization"] }; var sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CARRY_SIGN,JsonConvert.SerializeObject(mesCarrySignInput),header); + Log.Information(sendResult); + AuthResponse authResponse = JsonConvert.DeserializeObject(sendResult); + if (authResponse.code != 200) + { + throw Oops.Bah(authResponse.msg); + } + else + { + result2 = await db.Ado.UseTranAsync(async () => + { + await db.Insertable(prdFeedingH).ExecuteCommandAsync(); + await db.Insertable(list).ExecuteCommandAsync(); + }); + + } } - if(!result.IsSuccess) throw Oops.Oh(result.ErrorMessage); - return result.IsSuccess ? "签收成功" : result.ErrorMessage; + if(!result2.IsSuccess) throw Oops.Oh(result2.ErrorMessage); + return result2.IsSuccess ? "签收成功" : result2.ErrorMessage; + } + + [HttpPost] + public async Task GetFeedingRecordTree() + { + var db = _repository.AsSugarClient(); + var result = await db.Queryable() + .Where(a => a.schedule_type == 2 && a.parent_id!=null) + .Select(a => new FeedingRecordTreeOutput() + { + mo_task_code = a.mo_task_code, + children = SqlFunc.Subqueryable().Where(b=>a.id==b.mo_task_id).ToList(b=>new FeedingRecordChildren() + { + id = b.id, + code = b.code, + // children = SqlFunc.Subqueryable().LeftJoin((c,d)=>c.material_id==d.id) + // .Where((c,d)=>SqlFunc.IIF(b==null,"0",b.id)==c.feeding_id).ToList((c,d)=>new FeedingRecordMaterialChildren() + // { + // // material_code = d.code, + // // material_name = d.name, + // }) + // children = new List(), + // children = b!=null ? SqlFunc.Subqueryable() + // .Where((c)=>"26897270557717"=="26897270557717").ToList((c)=>new FeedingRecordMaterialChildren() + // { + // // material_code = d.code, + // // material_name = d.name, + // }) : new List() + }) + }).Mapper(x => + { + foreach (var item in x.children) + { + item.children = db.Queryable() + .LeftJoin((c, d) => c.material_id == d.id) + .Where((c, d) => item.id == c.feeding_id).Select((c,d) => new FeedingRecordMaterialChildren() + { + material_code = d.code, + material_name = d.name, + }).ToList(); + } + }) + .ToListAsync(); + return result; } } } \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs index 4f2ededd..c56832e0 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs @@ -3,8 +3,10 @@ using JNPF.Common.Core.Manager; using JNPF.Common.Enums; using JNPF.DependencyInjection; using JNPF.DynamicApiController; +using JNPF.Extras.CollectiveOAuth.Models; using JNPF.Extras.CollectiveOAuth.Utils; using JNPF.FriendlyException; +using JNPF.Logging; using JNPF.RemoteRequest; using JNPF.Systems.Interfaces.System; using Mapster; @@ -48,6 +50,8 @@ namespace Tnb.ProductionMgr var db = _repository.AsSugarClient(); var location = await db.Queryable().FirstAsync(x => x.location_code == input.location_code); PrdInstockH prdInstockH = null; + List prdInstockDs = new List() { }; + DbResult result2 = new DbResult(); DbResult result = await db.Ado.UseTranAsync(async () => { prdInstockH = new PrdInstockH() @@ -63,7 +67,6 @@ namespace Tnb.ProductionMgr status = 0, }; - List prdInstockDs = new List() { }; foreach (var item in input.details) { prdInstockDs.Add(new PrdInstockD() @@ -79,12 +82,12 @@ namespace Tnb.ProductionMgr }); } - await _repository.InsertAsync(prdInstockH); - - if (prdInstockDs.Count > 0) - { - await db.Insertable(prdInstockDs).ExecuteCommandAsync(); - } + // await _repository.InsertAsync(prdInstockH); + // + // if (prdInstockDs.Count > 0) + // { + // await db.Insertable(prdInstockDs).ExecuteCommandAsync(); + // } }); @@ -132,11 +135,29 @@ namespace Tnb.ProductionMgr ["Authorization"] = App.HttpContext.Request.Headers["Authorization"] }; var sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CREATE_INSTOCK,JsonConvert.SerializeObject(mesCreateInstockInput),header); - Console.WriteLine(sendResult); + Log.Information(sendResult); + AuthResponse authResponse = JsonConvert.DeserializeObject(sendResult); + if (authResponse.code != 200) + { + throw Oops.Bah(authResponse.msg); + } + else + { + result2 = await db.Ado.UseTranAsync(async () => + { + await _repository.InsertAsync(prdInstockH); + + if (prdInstockDs.Count > 0) + { + await db.Insertable(prdInstockDs).ExecuteCommandAsync(); + } + }); + + } } - if(!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008); - return result.IsSuccess ? "保存成功" : result.ErrorMessage; + if(!result2.IsSuccess) throw Oops.Oh(ErrorCode.COM1008); + return result2.IsSuccess ? "保存成功" : result2.ErrorMessage; } /// @@ -147,15 +168,26 @@ namespace Tnb.ProductionMgr public async Task SyncInstock(Dictionary dic) { string sourceId = dic.ContainsKey("source_id") ? dic["source_id"] : ""; - if (!string.IsNullOrEmpty(sourceId)) + var db = _repository.AsSugarClient(); + DbResult result = await db.Ado.UseTranAsync(async () => { - return await _repository.UpdateAsync(x => new PrdInstockH() + if (!string.IsNullOrEmpty(sourceId)) { - status = 1 - }, x => x.id == sourceId); - } + await _repository.UpdateAsync(x => new PrdInstockH() + { + status = 1 + }, x => x.id == sourceId); + var details = await db.Queryable().Where(x => x.instock_id == sourceId).ToListAsync(); - return false; + foreach (var item in details) + { + await db.Updateable().SetColumns(x => x.status == 1) + .Where(x => x.id == item.report_id).ExecuteCommandAsync(); + } + } + }); + + return result.IsSuccess; } } } \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs index b73e6164..45287ded 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs @@ -43,6 +43,9 @@ using Microsoft.ClearScript.Util.Web; using Newtonsoft.Json; using Tnb.BasicData.Entities.Dto; using NPOI.SS.Formula.Functions; +using Tnb.PerMgr.Entities; + +// using Tnb.PerMgr.Entities; namespace Tnb.ProductionMgr { @@ -1711,5 +1714,39 @@ namespace Tnb.ProductionMgr { return await _db.Queryable().Where(it => it.eqp_id == eqpId && it.mo_task_status == DictConst.InProgressEnCode).ToListAsync(); } + + [HttpPost] + public async Task GetEstimatedEndTime(CountEstimatedEndTimeInput input) + { + var db = _repository.AsSugarClient(); + if (input.type == 1) + { + PerProcessStandardsH processStandardsH = await db.Queryable() + .Where(x => x.equip_id == input.equip_id && x.molds_id == input.molds_id && + x.output_material_id == input.material_id && x.enabled == 1) + .OrderByDescending(x => x.create_time).FirstAsync(); + + ToolMolds toolMolds = await db.Queryable().SingleAsync(x => x.id == input.molds_id); + if(toolMolds==null) throw Oops.Bah("没找到模具"); + if(toolMolds?.mold_cavity<=0) throw Oops.Bah("模穴数错误"); + if (processStandardsH == null) throw Oops.Bah("工艺标准成型周期错误"); + if (processStandardsH?.moulding_cycle <= 0) throw Oops.Bah("工艺标准成型周期错误"); + + decimal? addTime = (input.scheduled_qty * toolMolds.mold_cavity - 1) / processStandardsH?.moulding_cycle + 1; + return input.estimated_start_date.AddSeconds((double)addTime.Value).ToString("yyyy-MM-dd HH:mm:ss"); + } + else + { + var list = await db.Queryable() + .LeftJoin((a,b)=>a.process_id==b.process_id) + .Where((a,b)=>a.mbom_id==input.mbom_id).Select((a,b)=>b).ToListAsync(); + + decimal max = list.Select(x => Convert.ToDecimal(x.standard_time)).Max(x => x); + decimal? addTime = input.scheduled_qty * max; + return input.estimated_start_date.AddSeconds((double)addTime.Value).ToString("yyyy-MM-dd HH:mm:ss"); + } + + } + } } diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdOutstockService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdOutstockService.cs index 87cd0810..91be4166 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdOutstockService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdOutstockService.cs @@ -56,9 +56,6 @@ namespace Tnb.ProductionMgr try { var db = _repository.AsSugarClient(); - VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true); - await _runService.Create(templateEntity, visualDevModelDataCrInput); - MESCreateOutstockInput input = new MESCreateOutstockInput(); input.outstock = new MESWmsOutstockHInput(); @@ -100,7 +97,12 @@ namespace Tnb.ProductionMgr if (authResponse.code != 200) { throw Oops.Bah(authResponse.msg); - } + } + else + { + VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true); + await _runService.Create(templateEntity, visualDevModelDataCrInput); + } return await Task.FromResult(true); } catch (Exception e) diff --git a/ProductionMgr/Tnb.ProductionMgr/ProductionReportRecordService.cs b/ProductionMgr/Tnb.ProductionMgr/ProductionReportRecordService.cs index 78493934..40f896d0 100644 --- a/ProductionMgr/Tnb.ProductionMgr/ProductionReportRecordService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/ProductionReportRecordService.cs @@ -126,7 +126,8 @@ namespace Tnb.ProductionMgr reported_qty = x.reported_qty, create_id = y.RealName, create_id_id = x.create_id, - create_time = x.create_time==null ? "" : x.create_time.Value.ToString("yyyy-MM-dd HH:mm") + create_time = x.create_time==null ? "" : x.create_time.Value.ToString("yyyy-MM-dd HH:mm"), + batch = x.batch }) }).ToPagedListAsync(input.currentPage, input.pageSize); return PageResult.SqlSugarPageResult(result); From bf76a846212e0aa3f36da7cdfe0e77fc6b878c8c Mon Sep 17 00:00:00 2001 From: alex Date: Thu, 20 Jul 2023 14:42:31 +0800 Subject: [PATCH 31/32] =?UTF-8?q?1=E3=80=81=E8=A7=A3=E5=86=B3=E5=9C=A8?= =?UTF-8?q?=E7=BA=BF=E5=BC=80=E5=8F=91=E6=98=8E=E7=BB=86=E6=9C=80=E5=90=8E?= =?UTF-8?q?=E4=B8=80=E6=9D=A1=E5=88=A0=E9=99=A4=E4=B8=8D=E4=BA=86=E7=9A=84?= =?UTF-8?q?bug=202=E3=80=81=E8=A7=A3=E5=86=B3=E5=9C=A8=E7=BA=BF=E5=BC=80?= =?UTF-8?q?=E5=8F=91=E6=98=8E=E7=BB=86=E6=96=B0=E5=A2=9E=E6=97=B6=E6=8A=A5?= =?UTF-8?q?=E4=B8=BB=E9=94=AE=E9=87=8D=E5=A4=8D=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- visualdev/Tnb.VisualDev/RunService.cs | 34 +++++++++++++++------------ 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/visualdev/Tnb.VisualDev/RunService.cs b/visualdev/Tnb.VisualDev/RunService.cs index 00545f6c..214bb0df 100644 --- a/visualdev/Tnb.VisualDev/RunService.cs +++ b/visualdev/Tnb.VisualDev/RunService.cs @@ -753,15 +753,15 @@ public class RunService : IRunService, ITransient dictionarySql.Clear(); tableField.Add("ReturnIdentity", mainId); dictionarySql.Add("MainTableReturnIdentity", new List>() { tableField }); - } - + } + //modify by zhoukeda 20230428 雪花id返回至传入参数中 开始 if (templateInfo.FormModel.primaryKeyPolicy.Equals(1)) { dataInput.data.Add("ReturnIdentity", mainId); } //modify by zhoukeda 20230428 雪花id返回至传入参数中 结束 - + // 拼接副表 sql if (templateInfo.AuxiliaryTableFieldsModelList.Any()) @@ -823,7 +823,11 @@ public class RunService : IRunService, ITransient { if (child.Key.Equals("id") && child.Value.IsNotEmptyOrNull()) { - tableField[childPrimary.field] = child.Value; + //modify by ly on 20230720 判断如果子表主键为空的把原主键值赋值给子表主键,直接复制会导致主键重复 + if(tableField[childPrimary.field].IsNull() || tableField[childPrimary.field].ToString().IsNullOrEmpty()) + { + tableField[childPrimary.field] = child.Value; + } } else if (child.Key.IsNotEmptyOrNull() && child.Value.IsNotEmptyOrNull() && child.Value.ToString() != "[]") { @@ -986,7 +990,7 @@ public class RunService : IRunService, ITransient // 查找到该控件数据 List>? model = allDataMap[item].ToObject>>(); - if (model != null && model.Count > 0) + if (model != null && model.Count >= 0) //modify by ly on 20230720 将Count>0改为>=0,否则最后一条明细数据删除不掉 { // 利用key去找模板 FieldsModel? fieldsModel = templateInfo.FieldsModelList.Find(f => f.__vModel__ == item); @@ -1199,7 +1203,7 @@ public class RunService : IRunService, ITransient var oldTInfo = new TemplateParsingBase(oldFEntity.PropertyJson, oldFEntity.TableJson, (int)oldFEntity.FormType); // 旧模板 var newTInfo = new TemplateParsingBase(newFEntity.PropertyJson, newFEntity.TableJson, (int)newFEntity.FormType); // 新模板 - if(oldFEntity.FormType.Equals(1) || newFEntity.FormType.Equals(1)) + if (oldFEntity.FormType.Equals(1) || newFEntity.FormType.Equals(1)) { oldTInfo.AllFieldsModel.ForEach(it => { @@ -1689,7 +1693,7 @@ public class RunService : IRunService, ITransient Dictionary? newChildData = new Dictionary(); foreach (KeyValuePair item in childmap) { - if(item.Key.Equals("id")) newChildData[item.Key] = childmap[item.Key]; + if (item.Key.Equals("id")) newChildData[item.Key] = childmap[item.Key]; FieldsModel? childFieldsModel = childFieldsModelList.Where(c => c.__vModel__ == item.Key).FirstOrDefault(); if (childFieldsModel != null && childFieldsModel.__vModel__.Equals(item.Key)) { @@ -1999,7 +2003,7 @@ public class RunService : IRunService, ITransient /// private string GetPrimary(DbLinkEntity link, string MainTableName) { - // modified by PhilPan + // modified by PhilPan var keys = _databaseService.GetPrimaries(link, MainTableName); if (keys.Count < 1) throw Oops.Oh(ErrorCode.D1402); // 主表未设置主键 return keys.First(); @@ -2464,7 +2468,7 @@ public class RunService : IRunService, ITransient } // 子表字段为空 查询 处理. - if (templateInfo.ChildTableFields.Any(x => x.Value.Contains(tName + "."))&&(dicList.ToJsonString().Contains("\"ConditionalType\":11") || dicList.ToJsonString().Contains("\"ConditionalType\":14"))) + if (templateInfo.ChildTableFields.Any(x => x.Value.Contains(tName + ".")) && (dicList.ToJsonString().Contains("\"ConditionalType\":11") || dicList.ToJsonString().Contains("\"ConditionalType\":14"))) queryOrSqlList.Add(string.Format(" OR ( [{0}] NOT IN ( SELECT {1} FROM {2} ) ) ", primaryKey, templateInfo.AllTable.Where(x => x.table.Equals(tName)).First().tableField, tName)); if (!tableWhere.ContainsKey(tName)) tableWhere.Add(tName, new List() { conList }); @@ -2945,7 +2949,7 @@ public class RunService : IRunService, ITransient // 多选时为模糊查询 if (model.multiple || model.searchMultiple) { - var value = item.Value.ToString().Contains("[") ? item.Value.ToObject>():new List() { item.Value.ToString() }; + var value = item.Value.ToString().Contains("[") ? item.Value.ToObject>() : new List() { item.Value.ToString() }; var addItems = new List>(); for (int i = 0; i < value.Count; i++) { @@ -2987,7 +2991,7 @@ public class RunService : IRunService, ITransient var objIdList = new List(); if (item.Value.ToString().Contains("[")) objIdList = item.Value.ToObject>(); else objIdList.Add(item.Value.ToString()); - var rIdList = _visualDevRepository.AsSugarClient().Queryable().Where(x => objIdList.Select(xx=>xx.Replace("--user", string.Empty)).Contains(x.UserId)).Select(x => new { x.ObjectId, x.ObjectType }).ToList(); + var rIdList = _visualDevRepository.AsSugarClient().Queryable().Where(x => objIdList.Select(xx => xx.Replace("--user", string.Empty)).Contains(x.UserId)).Select(x => new { x.ObjectId, x.ObjectType }).ToList(); rIdList.ForEach(x => { if (x.ObjectType.Equals("Organize")) @@ -3193,7 +3197,7 @@ public class RunService : IRunService, ITransient var add = new KeyValuePair(i == 0 ? WhereType.And : WhereType.Or, new ConditionalModel { FieldName = item.Key, - ConditionalType = model.multiple ? ConditionalType.Like: ConditionalType.Equal, + ConditionalType = model.multiple ? ConditionalType.Like : ConditionalType.Equal, FieldValue = model.multiple ? value[i].ToJsonString() : value[i].ToString() }); addItems.Add(add); @@ -3317,7 +3321,7 @@ public class RunService : IRunService, ITransient conModels.Add(new ConditionalModel { FieldName = item.Key, ConditionalType = ConditionalType.In, FieldValue = values }); } - else + else { conModels.Add(new ConditionalCollections() { @@ -3527,7 +3531,7 @@ public class RunService : IRunService, ITransient dataRuleConditionalList = _visualDevRepository.AsSugarClient().Utilities.JsonToConditionalModels(pList.ToJsonString()); dataRuleConditionalList = GetIConditionalModelListByTableName(dataRuleConditionalList, item.Key); var json = dataRuleConditionalList.ToJsonString().Replace(item.Key + ".", string.Empty); - dataRuleConditionalList= _visualDevRepository.AsSugarClient().Utilities.JsonToConditionalModels(json); + dataRuleConditionalList = _visualDevRepository.AsSugarClient().Utilities.JsonToConditionalModels(json); } } @@ -3875,7 +3879,7 @@ public class RunService : IRunService, ITransient { Console.WriteLine(item.Value); Console.WriteLine(item.Key.Replace("jnpf_searchType_equals_", "")); - if (item.Key.Contains("jnpf_searchType_equals_")) resList = resList.Where(x => x[item.Key.Replace("jnpf_searchType_equals_","")].ToString().Equals(item.Value)).ToList(); + if (item.Key.Contains("jnpf_searchType_equals_")) resList = resList.Where(x => x[item.Key.Replace("jnpf_searchType_equals_", "")].ToString().Equals(item.Value)).ToList(); else resList = resList.Where(x => x[item.Key].ToString().Contains(item.Value)).ToList(); } } From 473059adda288243adca1a6d6473c39472ca6636 Mon Sep 17 00:00:00 2001 From: FanLian Date: Thu, 20 Jul 2023 15:06:56 +0800 Subject: [PATCH 32/32] =?UTF-8?q?MES=E7=94=9F=E4=BA=A7=E5=85=A5=E5=BA=93?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Tnb.WarehouseMgr.Entities/Entity/WmsCarryunbindCode.cs | 5 ----- WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs | 2 +- WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs | 2 +- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryunbindCode.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryunbindCode.cs index dcc4ee07..09119e5e 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryunbindCode.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryunbindCode.cs @@ -49,11 +49,6 @@ public partial class WmsCarryunbindCode : BaseEntity /// public decimal? codeqty { get; set; } - /// - /// 行号 - /// - public int? no { get; set; } - /// /// 子载具ID /// diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs index e47c878a..71cfd65c 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs @@ -273,7 +273,7 @@ namespace Tnb.WarehouseMgr //入库取终点 //出库起点 var inStockStrategyInput = new InStockStrategyQuery { warehouse_id = instock?.warehouse_id!, Size = 1 }; var endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput); - WmsPointH sPoint = await _db.Queryable().FirstAsync(it => it.location_id == instock.location_id); + WmsPointH sPoint = await _db.Queryable().FirstAsync(it => it.location_code == input.instock.location_code); WmsPointH ePoint = await _db.Queryable().FirstAsync(it => it.location_id == endLocations[0].id); var carry = await _db.Queryable().SingleAsync(it => it.carry_code == input.instock.carry_code); diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs index c0483adf..77560665 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs @@ -50,7 +50,7 @@ namespace Tnb.WarehouseMgr /// /// [HttpPost] - public async Task PackSortingByAdd(WmsCarryMat? carryMat) + public async Task PackSortingByAdd(WmsCarryMat carryMat) { string firstLocationId = "27010980724501", secondLocationId = "27010987857941"; var endLocation = await _db.Queryable().SingleAsync(it => it.id == secondLocationId);