diff --git a/ProductionMgr/Tnb.ProductionMgr/MesForErpService.cs b/ProductionMgr/Tnb.ProductionMgr/MesForErpService.cs index 967b01f1..62b3c216 100644 --- a/ProductionMgr/Tnb.ProductionMgr/MesForErpService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/MesForErpService.cs @@ -132,12 +132,20 @@ namespace Tnb.ProductionMgr } DictionaryDataEntity unitDic = await _db.Queryable().Where(x=>x.DictionaryTypeId==WmsWareHouseConst.UNITTYPEID && x.EnCode==item.unit_id).FirstAsync(); - + + 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) + { + Log.Error($"【SavePrdMo】生产工单{mocode}状态不是待下发无法覆盖"); + throw Oops.Bah($"【SavePrdMo】生产工单{mocode}状态不是待下发无法覆盖"); + } + item.id = SnowflakeIdHelper.NextId(); item.material_id = basMaterial.id; item.mo_source = "1"; item.mo_type = moTypeDic[item.mo_type]; - item.mo_code = item.mo_code+"-"+item.erp_lineno; + item.mo_code = mocode; item.create_id = WmsWareHouseConst.AdministratorUserId; item.create_time = DateTime.Now; item.mo_status = DictConst.ToBeScheduledId; diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseService.cs index e49c2b64..24c7a9e4 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseService.cs @@ -242,7 +242,8 @@ namespace Tnb.WarehouseMgr ["pk_psfinanceorg"] = erpOrg.corpoid, ["pk_psfinanceorg_v"] = erpOrg.corpvid, // ["pk_receivestore"] = erpExtendFields.Find(x=>x.table_id==purchase.warehouse_id)?.cotherwhid ?? "", - ["pk_receivestore"] = erpWarehouserelaHs.Find(x => x.erp_warehousecode == item.erp_wh_type)?.erp_warehouseid ?? "", + // ["pk_receivestore"] = erpWarehouserelaHs.Find(x => x.erp_warehousecode == item.erp_wh_type)?.erp_warehouseid ?? "", + ["pk_receivestore"] = item.erp_wh_type, ["pk_reqstoorg"] = erpOrg.pk_org, ["pk_reqstoorg_v"] = erpOrg.pk_org_v, ["pk_srcmaterial"] = erpExtendFields.Find(x=>x.table_id==item.material_id)?.cmaterialoid ?? "",