导入物料新增分类关联关系

This commit is contained in:
李贵强 2025-03-15 17:00:00 +08:00
parent 9b874d45cd
commit 5eed27267e
1 changed files with 15 additions and 17 deletions

View File

@ -52,6 +52,8 @@ public class ContractMaterialImportPlugin extends AbstractFormPlugin {
//只针对物料
if ("bd_material".equals(entityNumber)){
Long materialId = newMaterial(entry.getKey().getSearchValue(),materialList);
//存物料分类
this.newMaterialType(materialId);
basedata.add(materialId);
}
} else {
@ -83,23 +85,6 @@ public class ContractMaterialImportPlugin extends AbstractFormPlugin {
if (null != org) {
bd_material.set("createorg",org);
}
//物料分类
DynamicObject materialGroup = BusinessDataServiceHelper.loadSingle("bd_materialgroup",(new QFilter("name", QCP.equals, materialByNumber.getMaterialType())).toArray());
if (null==materialGroup){
materialGroup=BusinessDataServiceHelper.loadSingle("bd_materialgroup",(new QFilter("number", QCP.equals, "gc-tlfs")).toArray());
}
//物料分组
bd_material.set("group",materialGroup);
//分类标准
DynamicObjectCollection groupStandard = bd_material.getDynamicObjectCollection("entry_groupstandard");
DynamicObject newEntry = groupStandard.addNew();
QFilter qFilter = new QFilter("name", QCP.equals, "物料基本分类标准");
DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle("bd_materialgroupstandard", qFilter.toArray());
if (null!=dynamicObject){
newEntry.set("standardid",dynamicObject);
}
//分类
newEntry.set("groupid",materialGroup.getLong("id"));
//物料单位
QFilter unit = new QFilter("name", QCP.equals, materialByNumber.getMaterialUnit());
DynamicObject measureUnits = BusinessDataServiceHelper.loadSingle("bd_measureunits",unit.toArray());
@ -121,6 +106,19 @@ public class ContractMaterialImportPlugin extends AbstractFormPlugin {
return bd_material.getLong("id");
}
private void newMaterialType(Long materialId){
DynamicObject materialType = BusinessDataServiceHelper.newDynamicObject("bd_materialgroupdetail");
//分类标准
DynamicObject standard = BusinessDataServiceHelper.loadSingle("bd_materialgroupstandard", (new QFilter("number", QCP.equals, "JBFLBZ")).toArray());
materialType.set("standard",standard);
//分类
DynamicObject group=BusinessDataServiceHelper.loadSingle("bd_materialgroup",(new QFilter("number", QCP.equals, "waitgroup")).toArray());
materialType.set("group",group);
//物料
materialType.set("material",materialId);
SaveServiceHelper.save(new DynamicObject[]{materialType});
}
@Override
public void beforeImportEntry(BeforeImportEntryEventArgs e) {
super.beforeImportEntry(e);