1.质检不合格,选择时间区间;2.生产入库记录增加工单类型及物料的查询条件;3.产成品入库同步BIP成功后,相关信息记录到生产入库记录

This commit is contained in:
2024-10-22 13:54:43 +08:00
parent 7c9a64e5eb
commit 48299687c2
7 changed files with 153 additions and 25 deletions

View File

@@ -18,6 +18,8 @@ using Tnb.WarehouseMgr.Entities;
using Tnb.BasicData.Entities.Dto;
using Tnb.ProductionMgr.Entities;
using Tnb.BasicData.Interfaces;
using Tnb.WarehouseMgr.Entities.Entity;
using JNPF.Common.Security;
namespace Tnb.BasicData
{
@@ -367,6 +369,85 @@ namespace Tnb.BasicData
Log.Error($"请求记录{record.id}更新失败");
}
}
//产成品入库的BIP调用完成之后自动新增生产入库记录
if(thirdResult.Code==200 && record.third_name=="BIP" && record.name == "产成品入库")
{
//根据生产提报记录的report_id与生产入库子表中的prd_report_id字段对应找到生产入库子表记录然后根据子表记录找到对应的主表记录
var requestDatas = JsonConvert.DeserializeObject<List<Dictionary<string, object>>>(record.request_data);
if (requestDatas == null || requestDatas.Count <= 0)
Log.Error($"产成品入库同步BIP后更新生产入库记录失败,请求数据为空:{record.request_data}");
foreach (var reqData in requestDatas)
{
var report_id = reqData["report_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
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;
}
var prdInstockH = new PrdInstockH();
prdInstockH.id = SnowflakeIdHelper.NextId();
prdInstockH.bill_type = wmsPrdInstockH.type;
prdInstockH.warehouse_id = wmsPrdInstockD.warehouse_id;
prdInstockH.carry_code = wmsPrdInstockD.carry_id;
prdInstockH.location_code = wmsPrdInstockD.startlocation_id;
prdInstockH.create_id = prdReport?.create_id ?? wmsPrdInstockD.create_id;
prdInstockH.org_id = wmsPrdInstockH.org_id;
prdInstockH.station_id = prdMoTask?.workstation_id;
prdInstockH.workline_id = prdMoTask?.workline_id;
//prdInstockH.workshop_id=
//prdInstockH.is_check=
//prdInstockH.status =
prdInstockH.mo_task_id = prdReport?.mo_task_id;
prdInstockH.code = wmsPrdInstockH.bill_code;
await db.Insertable(prdInstockH).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 = prdInstockH.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
}
}
}
if(tranFlag) await db.Ado.CommitTranAsync();