分拣、工位bom、现场问题处理

This commit is contained in:
2024-09-29 10:20:22 +08:00
parent cd06d414bc
commit b44b349544
26 changed files with 701 additions and 288 deletions

View File

@@ -431,6 +431,7 @@ namespace Tnb.WarehouseMgr
wmsPurchaseOrderD.actual_quantity = 0;
wmsPurchaseOrderD.lineno = detail.lineno;
wmsPurchaseOrderD.gift = detail.gift;
wmsPurchaseOrderD.production_unit = detail.production_unit;
var material = await db.Queryable<BasMaterial>().Where(p => p.code == detail.material_code).FirstAsync();
if (material != null)
@@ -647,6 +648,7 @@ namespace Tnb.WarehouseMgr
wmsOutsourceOrderD.matcode_id = material.id;
wmsOutsourceOrderD.matspecification = material.material_specification;
}
wmsOutsourceOrderD.auxprop_gys = detail.auxprop_gys;
wmsOutsourceOrderDs.Add(wmsOutsourceOrderD);
}
@@ -991,44 +993,38 @@ namespace Tnb.WarehouseMgr
}
string transfer_type = "";
// 中储仓到暂存仓
#region
// 齐套出入库
if (warehouse_outstock.id == WmsWareHouseConst.WAREHOUSE_ZC_ID
&& (warehouse_instock.id == WmsWareHouseConst.WAREHOUSE_ZCC_ID || warehouse_instock.id == WmsWareHouseConst.WAREHOUSE_HCC_ID))
{
int count = input.details.Where(r => string.IsNullOrEmpty(r.station_code)).Count();
if (count > 0)
{
_LoggerErp2Mes.LogWarning($@"【MaterialTransfer】表体存在未填写工位的明细");
throw new AppFriendlyException($@"表体存在未填写工位的明细!", 500);
}
transfer_type = WmsWareHouseConst.MATERIALTRANSFER_CGCK_CODE;
}
else if (warehouse_outstock.id == WmsWareHouseConst.WAREHOUSE_CPCRK_ID && warehouse_instock.id == WmsWareHouseConst.WAREHOUSE_CP_ID)
{
transfer_type = WmsWareHouseConst.MATERIALTRANSFER_WXDBRK_CODE;
}
else if (warehouse_outstock.id == WmsWareHouseConst.WAREHOUSE_YCL_ID && warehouse_instock.id == WmsWareHouseConst.WAREHOUSE_JZGL_ID)
{
transfer_type = WmsWareHouseConst.MATERIALTRANSFER_JZGLRK_CODE;
}
else if (warehouse_outstock.id == WmsWareHouseConst.WAREHOUSE_YCL_ID && warehouse_instock.id == WmsWareHouseConst.WAREHOUSE_ZZXBK_ID)
{
transfer_type = WmsWareHouseConst.MATERIALTRANSFER_CROSSLAYER_CODE;
}
// 暂时其他情况都算齐套出入库类型(未定)
else
{
int count = input.details.Where(r => string.IsNullOrEmpty(r.station_code)).Count();
if (count > 0)
{
_LoggerErp2Mes.LogWarning($@"【MaterialTransfer】表体存在未填写工位的明细");
throw new AppFriendlyException($@"表体存在未填写工位的明细!", 500);
}
//int count = input.details.Where(r => string.IsNullOrEmpty(r.station_code)).Count();
//if (count > 0)
//{
// _LoggerErp2Mes.LogWarning($@"【MaterialTransfer】表体存在未填写工位的明细");
// throw new AppFriendlyException($@"表体存在未填写工位的明细!", 500);
//}
transfer_type = WmsWareHouseConst.MATERIALTRANSFER_QTCRK_CODE;
}
// 外协调拨入库
else if (warehouse_outstock.id == WmsWareHouseConst.WAREHOUSE_YCL_ID && warehouse_instock.id == WmsWareHouseConst.WAREHOUSE_ZC_ID)
transfer_type = WmsWareHouseConst.MATERIALTRANSFER_WXDBRK_CODE;
// 集中供料入库
else if (warehouse_outstock.id == WmsWareHouseConst.WAREHOUSE_YCL_ID && warehouse_instock.id == WmsWareHouseConst.WAREHOUSE_JZGL_ID)
transfer_type = WmsWareHouseConst.MATERIALTRANSFER_JZGLRK_CODE;
// 跨层外协件出入库
else if (warehouse_outstock.id == WmsWareHouseConst.WAREHOUSE_YCL_ID && warehouse_instock.id == WmsWareHouseConst.WAREHOUSE_ZZXBK_ID)
transfer_type = WmsWareHouseConst.MATERIALTRANSFER_CROSSLAYER_CODE;
// 包材出库
else if (warehouse_outstock.id == WmsWareHouseConst.WAREHOUSE_BCK_ID && warehouse_instock.id == WmsWareHouseConst.WAREHOUSE_F2BCQ_ID)
transfer_type = WmsWareHouseConst.MATERIALTRANSFER_PACKING_CODE;
// 长管出库
else if (warehouse_outstock.id == WmsWareHouseConst.WAREHOUSE_HCC_ID && warehouse_instock.id == WmsWareHouseConst.WAREHOUSE_ZZXBK_ID)
transfer_type = WmsWareHouseConst.MATERIALTRANSFER_CGCK_CODE;
// 外协调拨出库
else if (warehouse_outstock.id == WmsWareHouseConst.WAREHOUSE_ZC_ID && warehouse_instock.id == WmsWareHouseConst.WAREHOUSE_YCL_ID)
transfer_type = WmsWareHouseConst.MATERIALTRANSFER_WXDBOUTWAREHOUSE_CODE;
#endregion
//var wmsMaterialTransferdsDistinct = input.details.Select(r => new
@@ -1774,6 +1770,78 @@ namespace Tnb.WarehouseMgr
//break;
}
case WmsWareHouseConst.WAREHOUSE_BCK_ID:
{
WmsPackInstockH wmsPackInstockH = new WmsPackInstockH();
Code = await _billRuleService.GetBillNumber("WMSPACKINSTOCK");
wmsPackInstockH.bill_code = Code;
wmsPackInstockH.erp_bill_code = input.transfer_order;
var org_erpExtendField = await db.Queryable<ErpExtendField>().Where(a => a.pk_org == input.outstockorg_id).FirstAsync();
if (org_erpExtendField != null)
{
wmsPackInstockH.outstockorg_id = org_erpExtendField.pk_org_v;
wmsPackInstockH.outstockorg_code = org_erpExtendField.pk_org;
}
else
{
_LoggerErp2Mes.LogWarning($@"【TransferOutstock】表头明细中组织{input.outstockorg_id}在wms系统中未找到");
throw new AppFriendlyException($@"表头明细中组织{input.outstockorg_id}在wms系统中未找到", 500);
}
wmsPackInstockH.incoming_ware = warehouse_instock.id;
wmsPackInstockH.org_id = WmsWareHouseConst.AdministratorOrgId;
wmsPackInstockH.erp_pk = input.erp_pk;
wmsPackInstockH.create_id = WmsWareHouseConst.ErpUserId;
wmsPackInstockH.bill_date = DateTime.Now;
wmsPackInstockH.create_time = DateTime.Now;
wmsPackInstockH.erp_wh_type = input.warehouse_instock;
await db.Insertable(wmsPackInstockH).ExecuteCommandAsync();
List<WmsPackInstockD> wmsPackInstockDs = new List<WmsPackInstockD>();
foreach (var detail in input.details)
{
WmsPackInstockD wmsPackInstockD = new WmsPackInstockD();
wmsPackInstockD.bill_id = wmsPackInstockH.id;
wmsPackInstockD.material_code = detail.material_code;
var erpExtendField = await db.Queryable<ErpExtendField>().InnerJoin<DictionaryDataEntity>((a, b) => a.table_id == b.Id).Where((a, b) => b.EnCode == detail.unit_code).Select((a, b) => b).FirstAsync();
if (erpExtendField != null)
{
wmsPackInstockD.unit_id = erpExtendField.Id;
wmsPackInstockD.unit_code = erpExtendField.EnCode;
}
else
{
_LoggerErp2Mes.LogWarning($@"【TransferOutstock】表体明细中单位{detail.unit_code}在wms系统中未找到");
throw new AppFriendlyException($@"表体明细中单位{detail.unit_code}在wms系统中未找到", 500);
}
wmsPackInstockD.pr_qty = detail.qty;
wmsPackInstockD.pi_code = detail.code_batch;
wmsPackInstockD.erp_line_pk = detail.erp_line_pk;
wmsPackInstockD.create_id = WmsWareHouseConst.ErpUserId;
wmsPackInstockD.create_time = DateTime.Now;
wmsPackInstockD.xf_qty = 0;
wmsPackInstockD.qty = 0;
wmsPackInstockD.lineno = detail.lineno;
var material = await db.Queryable<BasMaterial>().Where(p => p.code == detail.material_code).FirstAsync();
if (material != null)
{
wmsPackInstockD.material_id = material.id;
wmsPackInstockD.material_code = material.code;
wmsPackInstockD.material_desc = material.material_specification;
}
wmsPackInstockD.auxprop_gys = detail.auxprop_gys;
wmsPackInstockD.auxprop_xph = detail.auxprop_xph;
wmsPackInstockDs.Add(wmsPackInstockD);
}
await db.Insertable(wmsPackInstockDs).ExecuteCommandAsync();
break;
}
}
await db.Ado.CommitTranAsync();
@@ -2420,16 +2488,16 @@ namespace Tnb.WarehouseMgr
throw new AppFriendlyException($@"子表主键不能为空!", 500);
}
var wmsInventorychecksDistinct = input.details.Select(r => new
{
material_id = r.material_code,
code_batch = r.code_batch,
}).Distinct();
if (wmsInventorychecksDistinct.Count() < input.details.Count)
{
_LoggerErp2Mes.LogWarning($@"【Inventorycheck】表体存在物料和批号重复的明细");
throw new AppFriendlyException($@"表体存在物料和批号重复的明细!", 500);
}
//var wmsInventorychecksDistinct = input.details.Select(r => new
//{
// material_id = r.material_code,
// code_batch = r.code_batch,
//}).Distinct();
//if (wmsInventorychecksDistinct.Count() < input.details.Count)
//{
// _LoggerErp2Mes.LogWarning($@"【Inventorycheck】表体存在物料和批号重复的明细");
// throw new AppFriendlyException($@"表体存在物料和批号重复的明细!", 500);
//}
WmsErpWarehouserelaH wmsErpWarehouserelaH = await db.Queryable<WmsErpWarehouserelaH>().Where(r => r.erp_warehousecode == input.warehouse_code).FirstAsync();
if (wmsErpWarehouserelaH == null)