diff --git a/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs b/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs index a843929e..1fb34736 100644 --- a/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs @@ -807,19 +807,38 @@ namespace Tnb.ProductionMgr string[] unitArr = erpBdMaterial.MEASRATE.Split("/"); if (erpExtendFields.All(x => x.cmaterialoid != erpBdMaterial.ID)) { - BasMaterial basMaterial = new BasMaterial() + BasMaterial basMaterial = null; + ErpExtendField tempExtendField = insertExtendFields.Find(x => x.cmaterialoid == erpBdMaterial.ID); + if (tempExtendField!=null) { - id = SnowflakeIdHelper.NextId(), - name = erpBdMaterial.NAME, - code = erpBdMaterial.CODE, - org_id = WmsWareHouseConst.AdministratorOrgId, - material_specification = erpBdMaterial.MATERIALSPEC, - material_standard = erpBdMaterial.MATERIALTYPE, - category_id = "[\"CGJCJ\"]", - unit_id = unitId, - create_time = DateTime.Now - }; - insertMaterial.Add(basMaterial); + basMaterial = insertMaterial.Find(x => x.id == tempExtendField.table_id); + } + else + { + basMaterial = new BasMaterial() + { + id = SnowflakeIdHelper.NextId(), + name = erpBdMaterial.NAME, + code = erpBdMaterial.CODE, + org_id = WmsWareHouseConst.AdministratorOrgId, + material_specification = erpBdMaterial.MATERIALSPEC, + material_standard = erpBdMaterial.MATERIALTYPE, + category_id = "[\"CGJCJ\"]", + unit_id = unitId, + create_time = DateTime.Now + }; + insertMaterial.Add(basMaterial); + + ErpExtendField erpExtendField = new ErpExtendField() + { + table_name = "bas_material", + table_id = basMaterial.id, + cmaterialoid = erpBdMaterial.ID, + cmaterialvid = erpBdMaterial.VID, + + }; + insertExtendFields.Add(erpExtendField); + } if (unitId != auxiliaryUnitId) { @@ -892,6 +911,7 @@ namespace Tnb.ProductionMgr await _db.Insertable(insertMaterial).ExecuteCommandAsync(); await _db.Insertable(insertMaterialUnits).ExecuteCommandAsync(); + await _db.Insertable(insertExtendFields).ExecuteCommandAsync(); //物料清单开始同步 materials = await _db.Queryable().ToListAsync();