合同导入触发报错bug

This commit is contained in:
李贵强 2025-02-18 16:01:30 +08:00
parent db2fbda76f
commit 99659e0273
1 changed files with 23 additions and 13 deletions

View File

@ -4,10 +4,13 @@ import com.alibaba.dubbo.common.utils.CollectionUtils;
import com.alibaba.fastjson.JSONObject;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.dataentity.metadata.IDataEntityType;
import kd.bos.dataentity.utils.StringUtils;
import kd.bos.entity.datamodel.BasedataItem;
import kd.bos.entity.datamodel.events.BeforeImportEntryEventArgs;
import kd.bos.entity.datamodel.events.QueryImportBasedataEventArgs;
import kd.bos.entity.plugin.ImportLogger;
import kd.bos.form.operate.webapi.RowMapper;
import kd.bos.form.plugin.AbstractFormPlugin;
import kd.bos.form.plugin.importentry.resolving.ImportEntryData;
import kd.bos.form.plugin.impt.BatchImportPlugin;
@ -35,19 +38,26 @@ public class ContractMaterialImportPlugin extends AbstractFormPlugin {
@Override
public void queryImportBasedata(QueryImportBasedataEventArgs e) {
super.queryImportBasedata(e);
Map<BasedataItem, List<Object>> searchResult = e.getSearchResult();
for (Map.Entry<BasedataItem, List<Object>> entry : searchResult.entrySet()) {
List<Object> basedata = entry.getValue();
if (basedata.isEmpty()) { // 查不到基础资料数据
Long materialId = newMaterial(entry.getKey().getSearchValue(),materialList);
basedata.add(materialId);
} else {
// 查到多个基础资料数据
// 业务场景应根据需求剔除不合法的基础资料数据最终保留一个
Iterator it = basedata.iterator();
it.next();
while (it.hasNext()) {
it.remove();
DynamicObject targetObj = ((RowMapper) e.getSource()).getTargetObj();
IDataEntityType dataEntityType = targetObj.getDataEntityType();
if (null!=dataEntityType){
String name = dataEntityType.getName();
if (StringUtils.equals("qeug_orderformentry",name)){
Map<BasedataItem, List<Object>> searchResult = e.getSearchResult();
for (Map.Entry<BasedataItem, List<Object>> entry : searchResult.entrySet()) {
List<Object> basedata = entry.getValue();
if (basedata.isEmpty()) { // 查不到基础资料数据
Long materialId = newMaterial(entry.getKey().getSearchValue(),materialList);
basedata.add(materialId);
} else {
// 查到多个基础资料数据
// 业务场景应根据需求剔除不合法的基础资料数据最终保留一个
Iterator it = basedata.iterator();
it.next();
while (it.hasNext()) {
it.remove();
}
}
}
}
}