Merge branch 'dev' of https://git.tuotong-tech.com/tnb/tnb.server into dev
This commit is contained in:
@@ -56,7 +56,6 @@ namespace Tnb.WarehouseMgr
|
||||
_prdInstockService = prdInstockService;
|
||||
OverideFuncs.CreateAsync = ScanInStock;
|
||||
}
|
||||
[HttpPost("xxx")]
|
||||
public async Task<dynamic> ScanInStock(VisualDevModelDataCrInput input)
|
||||
{
|
||||
try
|
||||
@@ -86,8 +85,8 @@ namespace Tnb.WarehouseMgr
|
||||
warehouse_id = "26103372441637",
|
||||
status = WmsWareHouseConst.BILLSTATUS_ADD_ID,
|
||||
generate_type = "0",
|
||||
sync_status = "",
|
||||
print_status = "0",
|
||||
sync_status = WmsWareHouseConst.SYNC_STATUS_NONEEDSYNC,
|
||||
print_status = WmsWareHouseConst.PRINT_STATUS_PRINTCOMPLETE,
|
||||
is_check = 1,
|
||||
create_id = _userManager.UserId,
|
||||
create_time = DateTime.Now,
|
||||
@@ -102,7 +101,7 @@ namespace Tnb.WarehouseMgr
|
||||
unit_id = mat.unit_id,
|
||||
pr_qty = item.codeqty,
|
||||
qty = 0,
|
||||
code_batch= item.code_batch,
|
||||
code_batch = item.code_batch,
|
||||
warehouse_id = "26103372441637",
|
||||
print_qty = item.codeqty,
|
||||
scan_qty = item.codeqty,
|
||||
@@ -184,7 +183,21 @@ namespace Tnb.WarehouseMgr
|
||||
preTask.create_time = DateTime.Now;
|
||||
return preTask;
|
||||
}).ToList();
|
||||
var isOk = await _wareHouseService.GenPreTask(preTasks, null!);
|
||||
List<WmsPretaskCode> pretaskCodes = new();
|
||||
foreach (var pt in preTasks)
|
||||
{
|
||||
WmsPretaskCode ptc = pt.Adapt<WmsPretaskCode>();
|
||||
ptc.id = SnowflakeIdHelper.NextId();
|
||||
ptc.bill_id = pt.id;
|
||||
ptc.material_id = instockCode.material_id;
|
||||
ptc.material_code = instockCode.material_code;
|
||||
ptc.barcode = instockCode.barcode;
|
||||
ptc.codeqty = instockCode.codeqty;
|
||||
ptc.unit_id = instockCode.unit_id;
|
||||
ptc.code_batch = instockCode.code_batch;
|
||||
pretaskCodes.Add(ptc);
|
||||
}
|
||||
var isOk = await _wareHouseService.GenPreTask(preTasks, pretaskCodes);
|
||||
if (isOk)
|
||||
{
|
||||
var preTaskUpInput = new GenPreTaskUpInput();
|
||||
@@ -225,70 +238,5 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
return Task.FromResult(true);
|
||||
}
|
||||
|
||||
public override async Task ModifyAsync(WareHouseUpInput input)
|
||||
{
|
||||
if (input == null) throw new ArgumentNullException(nameof(input));
|
||||
//更具distaskCode的barcode 更新 instockcode 的 is_end 为 1
|
||||
try
|
||||
{
|
||||
await _db.Ado.BeginTranAsync();
|
||||
|
||||
if (input.distaskCodes?.Count > 0)
|
||||
{
|
||||
var barCodes = input.distaskCodes.Select(x => x.barcode);
|
||||
await _db.Updateable<WmsInstockCode>().SetColumns(it => new WmsInstockCode { is_end = 1 }).Where(it => barCodes.Contains(it.barcode)).ExecuteCommandAsync();
|
||||
var instockCodes = await _db.Queryable<WmsInstockCode>().Where(it => barCodes.Contains(it.barcode)).Select(it => new
|
||||
{
|
||||
id = it.bill_d_id,
|
||||
barcode_qty = it.codeqty,
|
||||
}).ToListAsync();
|
||||
var dic = instockCodes.GroupBy(g => g.id).ToDictionary(x => x.Key, x => x.Select(d => d.barcode_qty).ToList());
|
||||
var ids = instockCodes.Select(it => it.id).ToList();
|
||||
var instockDetails = await _db.Queryable<WmsInstockD>().Where(it => ids.Contains(it.id)).ToListAsync();
|
||||
|
||||
foreach (var item in instockDetails)
|
||||
{
|
||||
if (dic.ContainsKey(item.id))
|
||||
{
|
||||
item.qty += dic[item.id].Sum(x => x);
|
||||
if (item.qty >= item.pr_qty)
|
||||
{
|
||||
item.line_status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID;
|
||||
}
|
||||
}
|
||||
}
|
||||
await _db.Updateable(instockDetails).ExecuteCommandAsync();
|
||||
var instock = await _db.Queryable<WmsInstockH>().SingleAsync(it => it.id == input.requireId);
|
||||
if (instock.IsNull()) ArgumentNullException.ThrowIfNull(nameof(instock));
|
||||
if (instock.sync_status != WmsWareHouseConst.SYNC_STATUS_NONEEDSYNC)
|
||||
{
|
||||
//如果是自动单据,需要回更上层系统
|
||||
Dictionary<string, string> pars = new() { { nameof(WmsInstockH.source_id), instock?.source_id ?? string.Empty } };
|
||||
var callBackRes = await _prdInstockService.SyncInstock(pars);
|
||||
instock!.sync_status = callBackRes == true ? WmsWareHouseConst.SYNC_STATUS__SYNCCOMPLETE : WmsWareHouseConst.SYNC_STATUS__SYNCFAILED;
|
||||
await _db.Updateable(instock).UpdateColumns(it => it.sync_status).ExecuteCommandAsync();
|
||||
}
|
||||
var allInstockDetails = await _db.Queryable<WmsInstockD>().Where(it => it.bill_id == input.requireId).ToListAsync();
|
||||
if (allInstockDetails.All(x => x.line_status == WmsWareHouseConst.BILLSTATUS_COMPLETE_ID))
|
||||
{
|
||||
instock.status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID;
|
||||
}
|
||||
else
|
||||
{
|
||||
//任务没有结束,更新状态为工作中
|
||||
instock.status = WmsWareHouseConst.BILLSTATUS_ON_ID;
|
||||
}
|
||||
await _db.Updateable(instock).UpdateColumns(it => it.status).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
await _db.Ado.CommitTranAsync();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
await _db.Ado.RollbackTranAsync();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user