From d8a95aa1e0a3c6ca5265e114e1cb3d569dc61498 Mon Sep 17 00:00:00 2001 From: FanLian Date: Fri, 16 Jun 2023 13:26:35 +0800 Subject: [PATCH 1/2] 1 --- .../Tnb.WarehouseMgr/WmsCarryBindService.cs | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs index ea22ae7b..807de664 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs @@ -15,6 +15,7 @@ using JNPF.VisualDev.Entitys; using JNPF.VisualDev.Interfaces; using Mapster; using Microsoft.AspNetCore.Mvc; +using NPOI.SS.Formula; using SqlSugar; using Tnb.BasicData.Entities; using Tnb.WarehouseMgr.Entities; @@ -73,15 +74,26 @@ namespace Tnb.WarehouseMgr // string errorMessege = "新老载具规格应相同"; // throw Oops.Oh(errorMessege); //} + /* + * + */ + var insert_id = await _db.Insertable(new WmsCarryD { + carry_id = carry.id, + membercarry_id = subCarry.id, + membercarry_code = subCarry.carry_code, + loc = input.data[nameof(WmsCarrybindH.loc)].ToString() + }) + .ExecuteCommandAsync(); + if (insert_id<=0) throw Oops.Oh(ErrorCode.COM1000); //更新主载具明细表的子载具ID和编号以及位置 - var isOk = await _db.Updateable().SetColumns(it => it.membercarry_id == subCarry.id) - .SetColumns(it => it.membercarry_code == subCarry.carry_code) - .SetColumns(it => it.loc == input.data[nameof(WmsCarrybindH.loc)].ToString()) - .Where(it => it.id == carry.id) - .ExecuteCommandHasChangeAsync(); - if (!isOk) throw Oops.Oh(ErrorCode.COM1001); - + /* var isOk = await _db.Updateable().SetColumns(it => it.membercarry_id == subCarry.id) + .SetColumns(it => it.membercarry_code == subCarry.carry_code) + .SetColumns(it => it.loc == input.data[nameof(WmsCarrybindH.loc)].ToString()) + .Where(it => it.id == carry.id) + .ExecuteCommandHasChangeAsync(); + if (!isOk) throw Oops.Oh(ErrorCode.COM1001); + */ From 78f726d139001d3de12a7213e647b05a74addc71 Mon Sep 17 00:00:00 2001 From: FanLian Date: Fri, 16 Jun 2023 13:48:36 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E8=BD=BD=E5=85=B7=E8=A7=A3=E7=BB=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entity/WmsCarrybindH.cs | 2 +- .../Entity/WmsCarryunbindH.cs | 5 + .../Tnb.WarehouseMgr/WmsCarryBindService.cs | 95 +------------------ .../Tnb.WarehouseMgr/WmsCarryUnbindService.cs | 93 ++++++++++++++++++ 4 files changed, 100 insertions(+), 95 deletions(-) create mode 100644 WarehouseMgr/Tnb.WarehouseMgr/WmsCarryUnbindService.cs diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarrybindH.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarrybindH.cs index de0a98a1..1eb7a537 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarrybindH.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarrybindH.cs @@ -25,7 +25,7 @@ public partial class WmsCarrybindH : BaseEntity public string? org_id { get; set; } /// - /// 所属组织ID + /// 载具ID /// public string? carry_id { get; set; } diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryunbindH.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryunbindH.cs index 58865bce..0e5d78ba 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryunbindH.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryunbindH.cs @@ -24,6 +24,11 @@ public partial class WmsCarryunbindH : BaseEntity /// public string? org_id { get; set; } + /// + /// 载具ID + /// + public string? carry_id { get; set; } + /// /// 载具编号 /// diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs index 807de664..647e5794 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs @@ -68,16 +68,7 @@ namespace Tnb.WarehouseMgr if (input == null) throw new ArgumentNullException(nameof(input)); var carry = await _db.Queryable().FirstAsync(it => it.id == input.data[nameof(WmsCarrybindH.carry_id)].ToString()); var subCarry = await _db.Queryable().FirstAsync(it => it.id == input.data[nameof(WmsCarrybindH.membercarry_id)].ToString()); - - //if (oldCarry.carrystd_id != newCarry.carrystd_id) - //{ - // string errorMessege = "新老载具规格应相同"; - // throw Oops.Oh(errorMessege); - //} - /* - * - */ - + //更新主载具明细表,增加新的数据 var insert_id = await _db.Insertable(new WmsCarryD { carry_id = carry.id, membercarry_id = subCarry.id, @@ -86,90 +77,6 @@ namespace Tnb.WarehouseMgr }) .ExecuteCommandAsync(); if (insert_id<=0) throw Oops.Oh(ErrorCode.COM1000); - //更新主载具明细表的子载具ID和编号以及位置 - /* var isOk = await _db.Updateable().SetColumns(it => it.membercarry_id == subCarry.id) - .SetColumns(it => it.membercarry_code == subCarry.carry_code) - .SetColumns(it => it.loc == input.data[nameof(WmsCarrybindH.loc)].ToString()) - .Where(it => it.id == carry.id) - .ExecuteCommandHasChangeAsync(); - if (!isOk) throw Oops.Oh(ErrorCode.COM1001); - */ - - - - - - - /* - * db.Updateable(WmsCarryD).SetColumns(it => it.carry_id == newCarry.id).Where(it=>it.carry_id == oldCarry.id).ExecuteCommand(); - */ - - /* //入库取终点 - //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))) - { - ePoint = await _db.Queryable().FirstAsync(it => it.location_id == input.data[nameof(WmsPointH.location_id)].ToString()); - } - if (carry != null) - { - sPoint = await _db.Queryable().FirstAsync(it => it.location_id == carry.location_id); - } - - if (sPoint != null && ePoint != null) - { - var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id); - //根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序) - if (points?.Count > 0) - { - if (points.Count <= 2) throw new AppFriendlyException("该路径不存在", 500); - 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_WMSMOOUTSTK_ID; - preTask.task_type = WmsWareHouseConst.WMS_PRETASK_OUTSTOCK_TYPE_ID; - preTask.carry_id = input.data[nameof(preTask.carry_id)]?.ToString()!; - preTask.carry_code = input.data[nameof(preTask.carry_code)]?.ToString()!; - 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(); - var isOk = await _wareHouseService.GenPreTask(preTasks); - if (isOk) - { - var preTaskUpInput = new GenPreTaskUpInput(); - preTaskUpInput.RquireId = input.data["ReturnIdentity"].ToString(); - preTaskUpInput.CarryId = input.data[nameof(WmsCarryD.carry_id)]?.ToString()!; - preTaskUpInput.CarryStartLocationId = points.FirstOrDefault().location_id; - preTaskUpInput.CarryStartLocationCode = points.FirstOrDefault().location_code; - preTaskUpInput.LocationIds = points.Select(x => x.location_id).ToList(); - preTaskUpInput.PreTaskRecords = preTasks.Adapt>(); - preTaskUpInput.PreTaskRecords.ForEach(x => x.id = SnowflakeIdHelper.NextId()); - await _wareHouseService.GenInStockTaskHandleAfter(preTaskUpInput, null, null); - - } - } - - }*/ - await _db.Ado.CommitTranAsync(); } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryUnbindService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryUnbindService.cs new file mode 100644 index 00000000..17b746c5 --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryUnbindService.cs @@ -0,0 +1,93 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using JNPF.Common.Core.Manager; +using JNPF.Common.Dtos.VisualDev; +using JNPF.Common.Enums; +using JNPF.Common.Extension; +using JNPF.Common.Security; +using JNPF.FriendlyException; +using JNPF.Systems.Interfaces.System; +using JNPF.VisualDev; +using JNPF.VisualDev.Entitys; +using JNPF.VisualDev.Interfaces; +using Mapster; +using Microsoft.AspNetCore.Mvc; +using NPOI.SS.Formula; +using SqlSugar; +using Tnb.BasicData.Entities; +using Tnb.WarehouseMgr.Entities; +using Tnb.WarehouseMgr.Entities.Attributes; +using Tnb.WarehouseMgr.Entities.Consts; +using Tnb.WarehouseMgr.Entities.Dto; +using Tnb.WarehouseMgr.Interfaces; + +namespace Tnb.WarehouseMgr +{ + /// + /// 载具移出 + /// + [OverideVisualDev(ModuleConsts.MODULE_WMSCARRYREPLACE_ID)] + public class WmsCarryUnbindService : BaseWareHouseService + { + private readonly ISqlSugarClient _db; + private readonly IRunService _runService; + private readonly IVisualDevService _visualDevService; + private readonly IWareHouseService _wareHouseService; + private readonly IBillRullService _billRullService; + private readonly IUserManager _userManager; + public WmsCarryUnbindService( + ISqlSugarRepository repository, + IRunService runService, + IVisualDevService visualDevService, + IWareHouseService wareHouseService, + IUserManager userManager, + IBillRullService billRullService) + { + _db = repository.AsSugarClient(); + _runService = runService; + _visualDevService = visualDevService; + _wareHouseService = wareHouseService; + _userManager = userManager; + _billRullService = billRullService; + OverideFuncs.CreateAsync = CarryUnbind; + } + + private async Task CarryUnbind(VisualDevModelDataCrInput input) + { + + try + { + await _db.Ado.BeginTranAsync(); + + VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSCARRYMOOUTSTK_ID, true); + await _runService.Create(templateEntity, input); + + if (input == null) throw new ArgumentNullException(nameof(input)); + var carry = await _db.Queryable().FirstAsync(it => it.id == input.data[nameof(WmsCarryunbindH.carry_id)].ToString()); + var subCarry = await _db.Queryable().FirstAsync(it => it.id == input.data[nameof(WmsCarryunbindH.membercarry_id)].ToString()); + + + var deleteQty = await _db.Deleteable().Where(it => it.carry_id == carry.id ).ExecuteCommandAsync(); + + if (deleteQty <= 0) throw Oops.Oh(ErrorCode.COM1002); + + await _db.Ado.CommitTranAsync(); + } + catch (Exception ex) + { + await _db.Ado.RollbackTranAsync(); + throw; + } + return Task.FromResult(true); + } + /* public override async Task ModifyAsync(WareHouseUpInput input) + { + if (input == null) throw new ArgumentNullException(nameof(input)); + var isOk = await _db.Updateable().SetColumns(it => new WmsCarryReplaceH { status = input.bizTypeId }).Where(it => it.id == input.requireId).ExecuteCommandHasChangeAsync(); + if (!isOk) throw Oops.Oh(ErrorCode.COM1001); + }*/ + } +}