Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
2023-06-25 11:41:41 +08:00
4 changed files with 41 additions and 34 deletions

View File

@@ -47,7 +47,7 @@ public partial class WmsFeedbox : BaseEntity<string>
/// <summary> /// <summary>
/// 理论数量 /// 理论数量
/// </summary> /// </summary>
public int qty { get; set; } public decimal qty { get; set; }
/// <summary> /// <summary>
/// 当前批次 /// 当前批次

View File

@@ -47,7 +47,7 @@ public partial class WmsFeedingrecordCode : BaseEntity<string>
/// <summary> /// <summary>
/// 条码数量 /// 条码数量
/// </summary> /// </summary>
public int codeqty { get; set; } public decimal codeqty { get; set; }
/// <summary> /// <summary>
/// 单位ID /// 单位ID

View File

@@ -27,14 +27,14 @@ namespace Tnb.WarehouseMgr
/// PDA载具更换 /// PDA载具更换
/// </summary> /// </summary>
[OverideVisualDev(ModuleConsts.MODULE_WMSCARRYREPLACEPDA_ID)] [OverideVisualDev(ModuleConsts.MODULE_WMSCARRYREPLACEPDA_ID)]
public class WmsPDACarryService : WmsCarryService ,IPdaStroage public class WmsPDACarryReplaceService : WmsCarryService ,IPdaStroage
{ {
private readonly ISqlSugarClient _db; private readonly ISqlSugarClient _db;
private readonly IUserManager _userManager; private readonly IUserManager _userManager;
private readonly IBillRullService _billRullService; private readonly IBillRullService _billRullService;
private readonly IRunService _runService; private readonly IRunService _runService;
private readonly IVisualDevService _visualDevService; private readonly IVisualDevService _visualDevService;
public WmsPDACarryService( public WmsPDACarryReplaceService(
ISqlSugarRepository<WmsCarryH> repository, ISqlSugarRepository<WmsCarryH> repository,
IUserManager userManager, IUserManager userManager,
IBillRullService billRullService, IBillRullService billRullService,

View File

@@ -46,7 +46,7 @@ namespace Tnb.WarehouseMgr
_billRullService = billRullService; _billRullService = billRullService;
_runService = runService; _runService = runService;
_visualDevService = visualDevService; _visualDevService = visualDevService;
OverideFuncs.CreateAsync = WmsPDABind; OverideFuncs.CreateAsync = WmsPDAFeedingRecord;
} }
/// <summary> /// <summary>
@@ -61,7 +61,7 @@ namespace Tnb.WarehouseMgr
/// </param> /// </param>
/// <returns></returns> /// <returns></returns>
/// <exception cref="ArgumentNullException"></exception> /// <exception cref="ArgumentNullException"></exception>
private async Task<dynamic> WmsPDABind(VisualDevModelDataCrInput input) private async Task<dynamic> WmsPDAFeedingRecord(VisualDevModelDataCrInput input)
{ {
@@ -73,43 +73,50 @@ namespace Tnb.WarehouseMgr
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSFEEDINGRECORDPDA_ID, true); VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSFEEDINGRECORDPDA_ID, true);
await _runService.Create(templateEntity, input); await _runService.Create(templateEntity, input);
var oldCarryId = input.data.ContainsKey("carry_id") ? input.data["carry_id"]?.ToString() : ""; var carryId = input.data.ContainsKey("carry_id") ? input.data["carry_id"]?.ToString() : "";
var newCarryId = input.data.ContainsKey("newcarry_id") ? input.data["newcarry_id"]?.ToString() : ""; var feedBoxCode = input.data.ContainsKey("feedbox_code") ? input.data["feedbox_code"]?.ToString() : "";
var oldCarry = await _db.Queryable<WmsCarryH>().FirstAsync(it => it.id == oldCarryId); var carry = await _db.Queryable<WmsCarryH>().FirstAsync(it => it.id == carryId);
var newCarry = await _db.Queryable<WmsCarryH>().FirstAsync(it => it.id == newCarryId); var feedBox = await _db.Queryable<WmsFeedbox>().FirstAsync(it => it.id == feedBoxCode);
if (oldCarry != null && newCarry != null) var carryMaterial = await _db.Queryable<WmsCarryMat>().FirstAsync(it => it.carry_id == carryId);
var carryCodes = await _db.Queryable<WmsCarryCode>().Where(it=>it.carry_id == carryId).ToListAsync();
if (carry != null && feedBox != null)
{ {
ExChangeCarryInput carryInput = new() { old_carry_id = oldCarry.id, new_carry_id = newCarry.id }; feedBox.material_id = carryMaterial.material_id;
isOk = await _updateSubCarry<WmsCarryD>(carryInput); feedBox.material_code = carryMaterial.material_code;
isOk = await _updateSubCarry<WmsCarryMat>(carryInput); feedBox.qty = carryMaterial.qty;
isOk = await _updateSubCarry<WmsCarryCode>(carryInput); feedBox.batch = carryMaterial?.code_batch!;
feedBox.status = carry.status;
newCarry.status = oldCarry.status; feedBox.create_id = _userManager.UserId;
newCarry.carry_status = oldCarry.carry_status; feedBox.create_time = DateTime.Now;
newCarry.location_id = oldCarry.location_id; var row = await _db.Updateable(feedBox).ExecuteCommandAsync();
newCarry.location_code = oldCarry.location_code; foreach(var carryCode in carryCodes)
newCarry.is_lock = oldCarry.is_lock; {
newCarry.out_status = oldCarry.out_status; WmsFeedingrecordCode wmsFeedingrecordCode = new();
newCarry.is_check = oldCarry.is_check; wmsFeedingrecordCode.id = SnowflakeIdHelper.NextId();
newCarry.bale_num = oldCarry.bale_num; wmsFeedingrecordCode.org_id = _userManager.User.OrganizeId;
newCarry.collocation_scheme_id = oldCarry.collocation_scheme_id; wmsFeedingrecordCode.record_id = input.data["ReturnIdentity"]?.ToString()!;
newCarry.collocation_scheme_code = oldCarry.collocation_scheme_code; wmsFeedingrecordCode.material_id = carryCode.material_id;
newCarry.source_id = oldCarry.source_id; wmsFeedingrecordCode.material_code = carryCode.material_code;
newCarry.source_code = oldCarry.source_code; wmsFeedingrecordCode.barcode = carryCode.barcode;
newCarry.create_id = _userManager.UserId; wmsFeedingrecordCode.code_batch = carryCode.code_batch;
newCarry.create_time = DateTime.Now; wmsFeedingrecordCode.codeqty = carryCode.codeqty;
var row = await _db.Updateable(newCarry).ExecuteCommandAsync(); wmsFeedingrecordCode.unit_id = carryCode.unit_id;
row = await UpdateNullCarry(oldCarry); wmsFeedingrecordCode.unit_code = carryCode.unit_code;
wmsFeedingrecordCode.create_id = _userManager.UserId;
wmsFeedingrecordCode.create_time = DateTime.Now;
row = await _db.Insertable(wmsFeedingrecordCode).ExecuteCommandAsync();
}
row = await UpdateNullCarry(carry);
isOk = (row > 0); isOk = (row > 0);
if (!isOk) throw Oops.Oh(ErrorCode.COM1001); if (!isOk) throw Oops.Oh(ErrorCode.COM1001);
} }
else else
{ {
if (oldCarry == null) if (carry == null)
{ {
throw new AppFriendlyException("没有可用的旧载具", 500); throw new AppFriendlyException("没有可用的旧载具", 500);
} }
if (newCarry == null) if (feedBox == null)
{ {
throw new AppFriendlyException("没有可用的新载具", 500); throw new AppFriendlyException("没有可用的新载具", 500);
} }