bip调拨入库单类型修改;产成品入库生产入库子表数据

This commit is contained in:
2024-11-13 16:25:39 +08:00
parent 41dc9ab807
commit ac3797e374
4 changed files with 40 additions and 91 deletions

View File

@@ -379,56 +379,10 @@ namespace Tnb.BasicData
Log.Error($"产成品入库同步BIP后更新生产入库记录失败,请求数据为空:{record.request_data}");
foreach (var reqData in requestDatas)
{
var report_id = reqData["report_id"].ToString();
var prd_instock_h_id = reqData["prd_instock_h_id"].ToString();
if (string.IsNullOrEmpty(report_id))
{
Log.Error($"请求记录id{record.id}生产提报记录id为空");
continue;
}
PrdReport prdReport = await db.Queryable<PrdReport>().SingleAsync(r => r.id == report_id);
#region bip
var wmsPrdInstockD = await db.Queryable<WmsPrdInstockD>().SingleAsync(r => r.prd_report_id == report_id);
if(wmsPrdInstockD==null)
{
Log.Error($"请求记录id{record.id}提报记录id{report_id}未找到对应的wms_prd_instock_d表中记录");
continue;
}
WmsPrdInstockH wmsPrdInstockH = await db.Queryable<WmsPrdInstockH>().SingleAsync(r => r.id == wmsPrdInstockD.prd_instock_id);
PrdMoTask prdMoTask = await db.Queryable<PrdMoTask>().SingleAsync(x => x.id == prdReport.mo_task_id);
if(prdMoTask==null)
{
Log.Error($"请求记录id{record.id}生产任务id{prdReport.mo_task_id}未找到对应的生产任务信息数据");
continue;
}
await db.Updateable<PrdInstockH>().SetColumns(r => r.is_sync_bip == 1).Where(r => r.id == prd_instock_h_id).ExecuteCommandAsync();
#endregion
#region
List<WmsPrdInstockCode> allInstockDetails = await db.Queryable<WmsPrdInstockCode>().Where(it => it.prd_instockD_id == wmsPrdInstockD.id).OrderBy(x => x.id).ToListAsync();
if (allInstockDetails == null)
continue;
foreach(var _detail in allInstockDetails)
{
PrdInstockD prdInstockD = new PrdInstockD();
prdInstockD.id = SnowflakeIdHelper.NextId();
prdInstockD.instock_id = prd_instock_h_id;
prdInstockD.material_id = wmsPrdInstockH.material_id;
prdInstockD.material_code= wmsPrdInstockH.material_code;
prdInstockD.unit_id = _detail.unit_id;
prdInstockD.quantity = _detail.pqty.HasValue ? Convert.ToInt32(_detail.pqty) : 0;
prdInstockD.code_batch= _detail.code_batch;
prdInstockD.barcode=prdReport.barcode;
prdInstockD.report_id = report_id;
prdInstockD.mo_task_code = prdMoTask?.mo_task_code;
await db.Insertable(prdInstockD).ExecuteCommandAsync();
}
#endregion
}
}
}