diff --git a/ProductionMgr/Tnb.ProductionMgr/MesForErpService.cs b/ProductionMgr/Tnb.ProductionMgr/MesForErpService.cs index 62b3c216..20f6b006 100644 --- a/ProductionMgr/Tnb.ProductionMgr/MesForErpService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/MesForErpService.cs @@ -135,7 +135,7 @@ namespace Tnb.ProductionMgr string mocode = item.mo_code+"-"+item.erp_lineno; PrdMo existMo = await _db.Queryable().Where(x => x.mo_code == mocode).FirstAsync(); - if (existMo.mo_status != DictConst.ToBeScheduledId) + if (existMo!=null && existMo.mo_status != DictConst.ToBeScheduledId) { Log.Error($"【SavePrdMo】生产工单{mocode}状态不是待下发无法覆盖"); throw Oops.Bah($"【SavePrdMo】生产工单{mocode}状态不是待下发无法覆盖"); diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs index 841d3e30..b6699c5f 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs @@ -2539,28 +2539,20 @@ namespace Tnb.ProductionMgr { ["cbdeptid"] = "1001A1100000001JFOPQ", //部门先写死 ["cbdeptvid"] = "0001A1100000000AOMIQ", //部门先写死 - ["cbmainmaterialid"] = - erpExtendFields.Find(x => x.table_id == report.material_id)?.cmaterialoid ?? "", - ["cbmainmaterialvid"] = - erpExtendFields.Find(x => x.table_id == report.material_id)?.cmaterialvid ?? "", - ["cbmaterialid"] = erpExtendFields.Find(x => x.table_id == report.material_id)?.cmaterialvid ?? - "", - ["cbmaterialvid"] = erpExtendFields.Find(x => x.table_id == report.material_id)?.cmaterialvid ?? - "", + ["cbmainmaterialid"] = erpExtendFields.Find(x => x.table_id == report.material_id)?.cmaterialoid ?? "", + ["cbmainmaterialvid"] = erpExtendFields.Find(x => x.table_id == report.material_id)?.cmaterialvid ?? "", + ["cbmaterialid"] = erpExtendFields.Find(x => x.table_id == report.material_id)?.cmaterialvid ?? "", + ["cbmaterialvid"] = erpExtendFields.Find(x => x.table_id == report.material_id)?.cmaterialvid ?? "", ["cbmobid"] = prdMo.erp_line_pk, ["cbmoid"] = prdMo.erp_mo_pk, // ["cbunitid"] = erpExtendFields.Find(x=>x.table_id==report.unit_id)?.cunitid ?? "", // ["cbastunitid"] = erpExtendFields.Find(x=>x.table_id==report.unit_id)?.cunitid ?? "", - ["cbunitid"] = erpExtendFields.Find(x => - x.table_id == (unitDatas.Find(x => x.EnCode == report.unit_id)?.Id ?? ""))?.cunitid ?? "", - ["cbastunitid"] = erpExtendFields.Find(x => - x.table_id == (unitDatas.Find(x => x.EnCode == report.unit_id)?.Id ?? ""))?.cunitid ?? "", + ["cbunitid"] = erpExtendFields.Find(x => x.table_id == (unitDatas.Find(x => x.EnCode == report.unit_id)?.Id ?? ""))?.cunitid ?? "", + ["cbastunitid"] = erpExtendFields.Find(x =>x.table_id == (unitDatas.Find(x => x.EnCode == report.unit_id)?.Id ?? ""))?.cunitid ?? "", ["nbplanwrnum"] = report.reported_qty, ["nbwrnum"] = report.reported_qty, ["tbendtime"] = nowStr, - ["tbstarttime"] = prdMoTask.act_start_date != null - ? prdMoTask.act_start_date.Value.ToString("yyyy-MM-dd HH:mm:ss") - : "", + ["tbstarttime"] = prdMoTask.act_start_date != null ? prdMoTask.act_start_date.Value.ToString("yyyy-MM-dd HH:mm:ss") : "", ["vbinbatchcode"] = report.batch, ["vbmobillcode"] = prdMo.mo_code, ["vbmorowno"] = prdMo.erp_lineno,