From 6dcacc38e5b2bbca0aef3ed640717dd6263ee590 Mon Sep 17 00:00:00 2001 From: FanLian Date: Wed, 21 Jun 2023 17:34:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=8D=E7=94=A8=E8=BD=BD=E5=85=B7=E6=9B=B4?= =?UTF-8?q?=E6=8D=A2=E7=B1=BB=EF=BC=8C=E4=BF=AE=E6=94=B9PDA=E6=8A=95?= =?UTF-8?q?=E6=96=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WmsPDACarryReplaceService.cs | 154 +----------------- .../Tnb.WarehouseMgr/WmsPDAFeedingService.cs | 9 - 2 files changed, 3 insertions(+), 160 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryReplaceService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryReplaceService.cs index e3f3b9a9..7e82e984 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryReplaceService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryReplaceService.cs @@ -27,7 +27,7 @@ namespace Tnb.WarehouseMgr /// PDA载具更换 /// [OverideVisualDev(ModuleConsts.MODULE_WMSCARRYREPLACEPDA_ID)] - public class WmsPDACarryService : BaseWareHouseService, IWmsCarryService, IPdaStroage + public class WmsPDACarryService : WmsCarryService ,IPdaStroage { private readonly ISqlSugarClient _db; private readonly IUserManager _userManager; @@ -39,158 +39,10 @@ namespace Tnb.WarehouseMgr IUserManager userManager, IBillRullService billRullService, IRunService runService, - IVisualDevService visualDevService) + IVisualDevService visualDevService) : base(repository, userManager, billRullService, runService, visualDevService) { - _db = repository.AsSugarClient(); - _userManager = userManager; - _billRullService = billRullService; - _runService = runService; - _visualDevService = visualDevService; - OverideFuncs.CreateAsync = WMSPDACarryReplace; + } - /// - /// PDA载具更换 - /// - /// - /// 输入参数: - ///
{ - ///
old_carry_id:老载具ID - ///
new_carry_id:新载具ID - ///
} - /// - /// - /// - private async Task WMSPDACarryReplace(VisualDevModelDataCrInput input) - { - - - var isOk = false; - try - { - await _db.Ado.BeginTranAsync(); - - VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSCARRYREPLACEPDA_ID, true); - await _runService.Create(templateEntity, input); - - 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(); - //删除对应明细表 - //删除载具明细 - 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 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/WmsPDAFeedingService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAFeedingService.cs index 0809c924..69d89454 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAFeedingService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAFeedingService.cs @@ -99,15 +99,6 @@ namespace Tnb.WarehouseMgr 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);