From bbd9a4ea2c0dea7b5de69672214fdb2633903a18 Mon Sep 17 00:00:00 2001 From: FanLian Date: Mon, 19 Jun 2023 16:33:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0PDA=E5=9B=9E=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Tnb.WarehouseMgr/WmsBindService.cs | 177 +++++++++++++++++- .../WmsPDACarryMoveInStockService.cs | 12 +- .../WmsPDACarryMoveOutStockService.cs | 15 +- .../Tnb.WarehouseMgr/WmsPDADeliveryService.cs | 7 + .../WmsPDAEmptyInstockService.cs | 13 +- .../WmsPDAEmptyOutstockService .cs | 22 +-- .../Tnb.WarehouseMgr/WmsPDATransferService.cs | 2 +- 7 files changed, 210 insertions(+), 38 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsBindService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsBindService.cs index b01e963b..6d961624 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsBindService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsBindService.cs @@ -1,12 +1,175 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using JNPF.Common.Contracts; +using JNPF.Common.Core.Manager; +using JNPF.Common.Dtos.VisualDev; +using JNPF.Common.Enums; +using JNPF.Common.Security; +using JNPF.DependencyInjection; +using JNPF.DynamicApiController; +using JNPF.FriendlyException; +using JNPF.Logging; +using JNPF.Systems.Interfaces.System; +using JNPF.VisualDev; +using Mapster; +using Microsoft.AspNetCore.Mvc; +using SqlSugar; +using Tnb.Common.Utils; +using Tnb.WarehouseMgr.Entities; +using Tnb.WarehouseMgr.Entities.Consts; +using Tnb.WarehouseMgr.Entities.Dto; +using Tnb.WarehouseMgr.Entities.Enums; +using Tnb.WarehouseMgr.Interfaces; namespace Tnb.WarehouseMgr { - internal class WmsBindService + /// + /// 载具服务 + /// + [OverideVisualDev(ModuleId)] + public class WmsBindService : BaseWareHouseService, IWmsCarryService { + private const string ModuleId = "26496560237333"; + private readonly ISqlSugarClient _db; + private readonly IUserManager _userManager; + private readonly IBillRullService _billRullService; + public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc(); + public WmsBindService(ISqlSugarRepository repository, IUserManager userManager, IBillRullService billRullService) + { + _db = repository.AsSugarClient(); + _userManager = userManager; + _billRullService = billRullService; + OverideFuncs.CreateAsync = WmsBind; + } + + /// + /// 更换载具 + /// + /// + /// 输入参数: + ///
{ + ///
old_carry_id:老载具id + ///
new_carry_id:新载具ID + ///
} + /// + /// + /// + [HttpPost] + public async Task WmsBind(VisualDevModelDataCrInput input) + { + var isOk = false; + try + { + await _db.Ado.BeginTranAsync(); + var oldCarryId = input.data.ContainsKey("carry_id") ? input.data["carry_id"]?.ToString() : ""; + var newCarryId = input.data.ContainsKey("newcarry_id") ? input.data["newcarry_id"]?.ToString() : ""; + var oldCarry = await _db.Queryable().FirstAsync(it => it.id == oldCarryId); + var newCarry = await _db.Queryable().FirstAsync(it => it.id == newCarryId); + if (oldCarry != null && newCarry != null) + { + ExChangeCarryInput carryInput = new() { old_carry_id = oldCarry.id, new_carry_id = newCarry.id }; + isOk = await _updateSubCarry(carryInput); + isOk = await _updateSubCarry(carryInput); + isOk = await _updateSubCarry(carryInput); + + newCarry.status = oldCarry.status; + newCarry.carry_status = oldCarry.carry_status; + newCarry.location_id = oldCarry.location_id; + newCarry.location_code = oldCarry.location_code; + newCarry.is_lock = oldCarry.is_lock; + newCarry.out_status = oldCarry.out_status; + newCarry.is_check = oldCarry.is_check; + newCarry.bale_num = oldCarry.bale_num; + newCarry.collocation_scheme_id = oldCarry.collocation_scheme_id; + newCarry.collocation_scheme_code = oldCarry.collocation_scheme_code; + newCarry.source_id = oldCarry.source_id; + newCarry.source_code = oldCarry.source_code; + newCarry.create_id = _userManager.UserId; + newCarry.create_time = DateTime.Now; + var row = await _db.Updateable(newCarry).ExecuteCommandAsync(); + WmsCarryReplaceH wmsCarryReplaceH = oldCarry.Adapt(); + wmsCarryReplaceH.id = SnowflakeIdHelper.NextId(); + wmsCarryReplaceH.org_id = oldCarry.org_id; + wmsCarryReplaceH.bill_code = await _billRullService.GetBillNumber(WmsCarryConst.WMS_CARRY_REPLACE_ENCODE); + wmsCarryReplaceH.carry_id = oldCarry.id; + wmsCarryReplaceH.carry_code = oldCarry.carry_code; + wmsCarryReplaceH.newcarry_id = newCarry.id; + wmsCarryReplaceH.newcarry_code = newCarry.carry_code; + row = await _db.Insertable(wmsCarryReplaceH).ExecuteCommandAsync(); + row = await UpdateNullCarry(oldCarry); + isOk = (row > 0); + if (!isOk) throw Oops.Oh(ErrorCode.COM1001); + } + else + { + if (oldCarry == null) + { + throw new AppFriendlyException("没有可用的旧载具", 500); + } + if (newCarry == null) + { + throw new AppFriendlyException("没有可用的新载具", 500); + } + + } + await _db.Ado.CommitTranAsync(); + } + catch (Exception ex) + { + Log.Error("载具更换失败", ex); + await _db.Ado.RollbackTranAsync(); + throw; + } + return isOk; + } + + public async Task UpdateNullCarry(WmsCarryH carryObj) + { + var row = -1; + try + { + carryObj.status = 0; + carryObj.carry_status = "0"; + 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(); + } + catch (Exception ex) + { + + } + return row; + } + + private async Task _updateSubCarry(ExChangeCarryInput input) where T : BaseEntity, IWmsCarryEntity, new() + { + var row = -1; + var items = await _db.Queryable().Where(it => it.carry_id == input.old_carry_id).ToListAsync(); + if (items?.Count > 0) + { + List newItems = DeepCopyHelper.DeepCopyList(items); + if (newItems?.Count > 0) + { + newItems.ForEach(x => + { + x.id = SnowflakeIdHelper.NextId(); + x.carry_id = input.new_carry_id; + + }); + row = await _db.Insertable(newItems).ExecuteCommandAsync(); + } + if (row > 0) + { + row = await _db.Deleteable(items).ExecuteCommandAsync(); + } + } + return (row > 0); + } } -} +} \ No newline at end of file diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryMoveInStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryMoveInStockService.cs index 0864585c..fd621afc 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryMoveInStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryMoveInStockService.cs @@ -149,11 +149,11 @@ namespace Tnb.WarehouseMgr 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 WmsMoveInstock { status = input.bizTypeId }).Where(it => it.id == input.requireId).ExecuteCommandHasChangeAsync(); - // if (!isOk) throw Oops.Oh(ErrorCode.COM1001); - //} + public override async Task ModifyAsync(WareHouseUpInput input) + { + if (input == null) throw new ArgumentNullException(nameof(input)); + var isOk = await _db.Updateable().SetColumns(it => new WmsMoveInstock { status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID }).Where(it => it.id == input.requireId).ExecuteCommandHasChangeAsync(); + if (!isOk) throw Oops.Oh(ErrorCode.COM1001); + } } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryMoveOutStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryMoveOutStockService.cs index 38682c85..666a683d 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryMoveOutStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryMoveOutStockService.cs @@ -144,11 +144,12 @@ namespace Tnb.WarehouseMgr } 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 WmsMoveOutstock { status = input.bizTypeId }).Where(it => it.id == input.requireId).ExecuteCommandHasChangeAsync(); - // if (!isOk) throw Oops.Oh(ErrorCode.COM1001); - //} - } + + public override async Task ModifyAsync(WareHouseUpInput input) + { + if (input == null) throw new ArgumentNullException(nameof(input)); + var isOk = await _db.Updateable().SetColumns(it => new WmsMoveOutstock { status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID }).Where(it => it.id == input.requireId).ExecuteCommandHasChangeAsync(); + if (!isOk) throw Oops.Oh(ErrorCode.COM1001); + } + } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDADeliveryService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDADeliveryService.cs index 86dac091..181110f0 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDADeliveryService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDADeliveryService.cs @@ -6,6 +6,7 @@ using System.Threading.Tasks; using Aspose.Cells.Drawing; using JNPF.Common.Core.Manager; using JNPF.Common.Dtos.VisualDev; +using JNPF.Common.Enums; using JNPF.Common.Extension; using JNPF.DependencyInjection; using JNPF.DynamicApiController; @@ -181,5 +182,11 @@ namespace Tnb.WarehouseMgr } return await Task.FromResult(true); } + public override async Task ModifyAsync(WareHouseUpInput input) + { + if (input == null) throw new ArgumentNullException(nameof(input)); + var row = await _db.Updateable().SetColumns(it => new WmsDelivery { status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID }).Where(it => it.id == input.requireId).ExecuteCommandAsync(); + if (row < 1) throw Oops.Oh(ErrorCode.COM1001); + } } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyInstockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyInstockService.cs index f457bce2..35f24ada 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyInstockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyInstockService.cs @@ -104,6 +104,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 = WmsWareHouseConst.BIZTYPE_WMSEMPTYINSTOCK_ID; + preTask.task_type = WmsWareHouseConst.WMS_PRETASK_INSTOCK_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; @@ -158,11 +159,11 @@ namespace Tnb.WarehouseMgr return Task.FromResult(true); } - //public async Task ModifyAsync(WareHouseUpInput input) - //{ - // if (input == null) throw new ArgumentNullException(nameof(input)); - // var isOk = await _db.Updateable().SetColumns(it => new WmsEmptyInstock { status = input.bizTypeId }).Where(it => it.id == input.requireId).ExecuteCommandHasChangeAsync(); - // if (!isOk) throw Oops.Oh(ErrorCode.COM1001); - //} + public override async Task ModifyAsync(WareHouseUpInput input) + { + if (input == null) throw new ArgumentNullException(nameof(input)); + var isOk = await _db.Updateable().SetColumns(it => new WmsEmptyInstock { status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID }).Where(it => it.id == input.requireId).ExecuteCommandHasChangeAsync(); + if (!isOk) throw Oops.Oh(ErrorCode.COM1001); + } } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyOutstockService .cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyOutstockService .cs index 0c34399a..7b1b5f6d 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyOutstockService .cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyOutstockService .cs @@ -169,12 +169,12 @@ namespace Tnb.WarehouseMgr handleH.create_id = _userManager.UserId; handleH.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(); + //根据载具移出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, location_id = preTaskUpInput.CarryStartLocationId, location_code = preTaskUpInput.CarryStartLocationCode }, - // it => new BasLocation { is_lock = 1 }); + await _wareHouseService.GenInStockTaskHandleAfter(preTaskUpInput, + it => new WmsCarryH { is_lock = 1, location_id = preTaskUpInput.CarryStartLocationId, location_code = preTaskUpInput.CarryStartLocationCode }, + it => new BasLocation { is_lock = 1 }); } } @@ -190,11 +190,11 @@ namespace Tnb.WarehouseMgr return Task.FromResult(true); } - //public async Task ModifyAsync(WareHouseUpInput input) - //{ - // if (input == null) throw new ArgumentNullException(nameof(input)); - // var isOk = await _db.Updateable().SetColumns(it => new WmsEmptyInstock { status = input.bizTypeId }).Where(it => it.id == input.requireId).ExecuteCommandHasChangeAsync(); - // if (!isOk) throw Oops.Oh(ErrorCode.COM1001); - //} + public override async Task ModifyAsync(WareHouseUpInput input) + { + if (input == null) throw new ArgumentNullException(nameof(input)); + var isOk = await _db.Updateable().SetColumns(it => new WmsEmptyInstock { status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID }).Where(it => it.id == input.requireId).ExecuteCommandHasChangeAsync(); + if (!isOk) throw Oops.Oh(ErrorCode.COM1001); + } } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDATransferService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDATransferService.cs index d4e7769f..3b9afb65 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDATransferService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDATransferService.cs @@ -150,7 +150,7 @@ namespace Tnb.WarehouseMgr public override async Task ModifyAsync(WareHouseUpInput input) { if (input == null) throw new ArgumentNullException(nameof(input)); - var isOk = await _db.Updateable().SetColumns(it => new WmsMoveInstock { status = input.bizTypeId }).Where(it => it.id == input.requireId).ExecuteCommandHasChangeAsync(); + var isOk = await _db.Updateable().SetColumns(it => new WmsTransfer { status = input.bizTypeId }).Where(it => it.id == input.requireId).ExecuteCommandHasChangeAsync(); if (!isOk) throw Oops.Oh(ErrorCode.COM1001); } }