diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs index f853b92c..599aadc0 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs @@ -59,7 +59,7 @@ namespace Tnb.WarehouseMgr { await _db.Ado.BeginTranAsync(); - VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSCARRYMOOUTSTK_ID, true); + VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSCARRYBIND_ID, true); await _runService.Create(templateEntity, input); if (input == null) throw new ArgumentNullException(nameof(input)); @@ -67,18 +67,21 @@ namespace Tnb.WarehouseMgr var subCarryId = input.data.ContainsKey("newcarry_id") ? input.data["newcarry_id"]?.ToString() : ""; var carry = await _db.Queryable().SingleAsync(it => it.id == carryId); var subCarry = await _db.Queryable().SingleAsync(it => it.id == subCarryId); - WmsCarrybindH wmsCarrybindH = carry.Adapt(); + WmsCarryD wmsCarryD = new() + { + id = SnowflakeIdHelper.NextId(), + carry_id = carry.id, + org_id = carry?.org_id!, + membercarry_id = subCarry.id, + membercarry_code = subCarry.carry_code, + loc = input.data[nameof(WmsCarrybindH.loc)]?.ToString()!, + create_id = _userManager.UserId, + create_time = DateTime.Now + }; + //WmsCarrybindH wmsCarrybindH = carry?.Adapt()!; if (carry != null && subCarry != null) { - wmsCarrybindH.id = SnowflakeIdHelper.NextId(); - wmsCarrybindH.org_id = carry.org_id; - wmsCarrybindH.carry_id = carry.id; - wmsCarrybindH.membercarry_id = subCarry.id; - wmsCarrybindH.membercarry_code = subCarry.carry_code; - wmsCarrybindH.loc = input.data[nameof(WmsCarrybindH.loc)].ParseToInt(1); - wmsCarrybindH.create_id = _userManager.UserId; - wmsCarrybindH.create_time = DateTime.Now; - var row = await _db.Insertable(wmsCarrybindH).ExecuteCommandAsync(); + var row = await _db.Insertable(wmsCarryD).ExecuteCommandAsync(); carry.carry_status = "1"; row = await _db.Updateable(carry).ExecuteCommandAsync(); subCarry.carry_status = "1"; @@ -88,15 +91,15 @@ namespace Tnb.WarehouseMgr { WmsCarrybindCode wmsCarrybindCode = new(); wmsCarrybindCode.id = SnowflakeIdHelper.NextId(); - wmsCarrybindCode.org_id = subCarry.id; - wmsCarrybindCode.carrybind_id = wmsCarrybindH.id; + wmsCarrybindCode.org_id = subCarry?.org_id!; + wmsCarrybindCode.carrybind_id = input.data["ReturnIdentity"]?.ToString()!; wmsCarrybindCode.material_id = items[i].material_id; wmsCarrybindCode.material_code = items[i].material_code; wmsCarrybindCode.barcode = items[i].barcode; wmsCarrybindCode.code_batch = items[i].code_batch; wmsCarrybindCode.codeqty = items[i].codeqty; - wmsCarrybindCode.membercarry_id = subCarry.id; - wmsCarrybindCode.membercarry_code = subCarry.carry_code; + wmsCarrybindCode.membercarry_id = subCarry?.id; + wmsCarrybindCode.membercarry_code = subCarry?.carry_code; wmsCarrybindCode.unit_id = items[i].unit_id; wmsCarrybindCode.unit_code = items[i].unit_code; wmsCarrybindCode.create_id = _userManager.UserId; diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryUnbindService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryUnbindService.cs index 74bd890b..f50d12e8 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryUnbindService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryUnbindService.cs @@ -58,7 +58,7 @@ namespace Tnb.WarehouseMgr { await _db.Ado.BeginTranAsync(); - VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSCARRYMOOUTSTK_ID, true); + VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSCARRYUNBIND_ID, true); await _runService.Create(templateEntity, input); if (input == null) throw new ArgumentNullException(nameof(input)); @@ -69,7 +69,27 @@ namespace Tnb.WarehouseMgr //WmsCarryunbindH wmsCarryUnbindH = carry.Adapt(); if (carry != null && subCarry != null) { - var row = await _db.Deleteable().Where(it => it.carry_id == subCarry.id).ExecuteCommandAsync(); + var row = await _db.Deleteable().Where(it => it.carry_id == carryId && it.membercarry_id == subCarryId).ExecuteCommandAsync(); + var items = await _db.Queryable().Where(it => it.carry_id == subCarryId).ToListAsync(); + WmsCarryunbindCode wmsCarryUnbindCode = new(); + for (int i = 0; i < items.Count; i++) + { + wmsCarryUnbindCode.id = SnowflakeIdHelper.NextId(); + wmsCarryUnbindCode.org_id = subCarry?.org_id!; + wmsCarryUnbindCode.carryunbind_id = input.data["ReturnIdentity"]?.ToString()!; + wmsCarryUnbindCode.material_id = items[i].material_id; + wmsCarryUnbindCode.material_code = items[i].material_code; + wmsCarryUnbindCode.barcode = items[i].barcode; + wmsCarryUnbindCode.code_batch = items[i].code_batch; + wmsCarryUnbindCode.codeqty = items[i].codeqty; + wmsCarryUnbindCode.membercarry_id = subCarry?.id; + wmsCarryUnbindCode.membercarry_code = subCarry?.carry_code; + wmsCarryUnbindCode.unit_id = items[i].unit_id; + wmsCarryUnbindCode.unit_code = items[i].unit_code; + wmsCarryUnbindCode.create_id = _userManager.UserId; + wmsCarryUnbindCode.create_time = DateTime.Now; + row = await _db.Insertable(wmsCarryUnbindCode).ExecuteCommandAsync(); + } carry.carry_status = "0"; row = await _db.Updateable(carry).ExecuteCommandAsync(); subCarry.carry_status = "0"; diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryBindService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryBindService.cs index 983dbb47..e05ffdda 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryBindService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryBindService.cs @@ -59,7 +59,7 @@ namespace Tnb.WarehouseMgr { await _db.Ado.BeginTranAsync(); - VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSCARRYMOOUTSTK_ID, true); + VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSCARRYBINDPDA_ID, true); await _runService.Create(templateEntity, input); if (input == null) throw new ArgumentNullException(nameof(input)); @@ -67,18 +67,21 @@ namespace Tnb.WarehouseMgr var subCarryId = input.data.ContainsKey("newcarry_id") ? input.data["newcarry_id"]?.ToString() : ""; var carry = await _db.Queryable().SingleAsync(it => it.id == carryId); var subCarry = await _db.Queryable().SingleAsync(it => it.id == subCarryId); - WmsCarrybindH wmsCarrybindH = carry.Adapt(); + WmsCarryD wmsCarryD = new() + { + id = SnowflakeIdHelper.NextId(), + carry_id = carry.id, + org_id = carry?.org_id!, + membercarry_id = subCarry.id, + membercarry_code = subCarry.carry_code, + loc = input.data[nameof(WmsCarrybindH.loc)]?.ToString()!, + create_id = _userManager.UserId, + create_time = DateTime.Now + }; + //WmsCarrybindH wmsCarrybindH = carry?.Adapt()!; if (carry != null && subCarry != null) { - wmsCarrybindH.id = SnowflakeIdHelper.NextId(); - wmsCarrybindH.org_id = carry.org_id; - wmsCarrybindH.carry_id = carry.id; - wmsCarrybindH.membercarry_id = subCarry.id; - wmsCarrybindH.membercarry_code = subCarry.carry_code; - wmsCarrybindH.loc = input.data[nameof(WmsCarrybindH.loc)].ParseToInt(1); - wmsCarrybindH.create_id = _userManager.UserId; - wmsCarrybindH.create_time = DateTime.Now; - var row = await _db.Insertable(wmsCarrybindH).ExecuteCommandAsync(); + var row = await _db.Insertable(wmsCarryD).ExecuteCommandAsync(); carry.carry_status = "1"; row = await _db.Updateable(carry).ExecuteCommandAsync(); subCarry.carry_status = "1"; @@ -88,15 +91,15 @@ namespace Tnb.WarehouseMgr { WmsCarrybindCode wmsCarrybindCode = new(); wmsCarrybindCode.id = SnowflakeIdHelper.NextId(); - wmsCarrybindCode.org_id = subCarry.id; - wmsCarrybindCode.carrybind_id = wmsCarrybindH.id; + wmsCarrybindCode.org_id = subCarry?.org_id!; + wmsCarrybindCode.carrybind_id = input.data["ReturnIdentity"]?.ToString()!; wmsCarrybindCode.material_id = items[i].material_id; wmsCarrybindCode.material_code = items[i].material_code; wmsCarrybindCode.barcode = items[i].barcode; wmsCarrybindCode.code_batch = items[i].code_batch; wmsCarrybindCode.codeqty = items[i].codeqty; - wmsCarrybindCode.membercarry_id = subCarry.id; - wmsCarrybindCode.membercarry_code = subCarry.carry_code; + wmsCarrybindCode.membercarry_id = subCarry?.id; + wmsCarrybindCode.membercarry_code = subCarry?.carry_code; wmsCarrybindCode.unit_id = items[i].unit_id; wmsCarrybindCode.unit_code = items[i].unit_code; wmsCarrybindCode.create_id = _userManager.UserId; diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryUnbindService .cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryUnbindService .cs index d1128ff6..8dacb645 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryUnbindService .cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryUnbindService .cs @@ -58,7 +58,7 @@ namespace Tnb.WarehouseMgr { await _db.Ado.BeginTranAsync(); - VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSCARRYMOOUTSTK_ID, true); + VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSCARRYUNBINDPDA_ID, true); await _runService.Create(templateEntity, input); if (input == null) throw new ArgumentNullException(nameof(input)); @@ -69,7 +69,27 @@ namespace Tnb.WarehouseMgr //WmsCarryunbindH wmsCarryUnbindH = carry.Adapt(); if (carry != null && subCarry != null) { - var row = await _db.Deleteable().Where(it => it.carry_id == subCarry.id).ExecuteCommandAsync(); + var row = await _db.Deleteable().Where(it => it.carry_id == carryId && it.membercarry_id == subCarryId).ExecuteCommandAsync(); + var items = await _db.Queryable().Where(it => it.carry_id == subCarryId).ToListAsync(); + WmsCarryunbindCode wmsCarryUnbindCode = new(); + for (int i = 0; i < items.Count; i++) + { + wmsCarryUnbindCode.id = SnowflakeIdHelper.NextId(); + wmsCarryUnbindCode.org_id = subCarry?.org_id!; + wmsCarryUnbindCode.carryunbind_id = input.data["ReturnIdentity"]?.ToString()!; + wmsCarryUnbindCode.material_id = items[i].material_id; + wmsCarryUnbindCode.material_code = items[i].material_code; + wmsCarryUnbindCode.barcode = items[i].barcode; + wmsCarryUnbindCode.code_batch = items[i].code_batch; + wmsCarryUnbindCode.codeqty = items[i].codeqty; + wmsCarryUnbindCode.membercarry_id = subCarry?.id; + wmsCarryUnbindCode.membercarry_code = subCarry?.carry_code; + wmsCarryUnbindCode.unit_id = items[i].unit_id; + wmsCarryUnbindCode.unit_code = items[i].unit_code; + wmsCarryUnbindCode.create_id = _userManager.UserId; + wmsCarryUnbindCode.create_time = DateTime.Now; + row = await _db.Insertable(wmsCarryUnbindCode).ExecuteCommandAsync(); + } carry.carry_status = "0"; row = await _db.Updateable(carry).ExecuteCommandAsync(); subCarry.carry_status = "0";