|
@@ -1,13 +1,23 @@
|
|
package fi.em.formPlugin;
|
|
package fi.em.formPlugin;
|
|
|
|
|
|
import com.alibaba.druid.util.StringUtils;
|
|
import com.alibaba.druid.util.StringUtils;
|
|
|
|
+import com.alibaba.dubbo.common.utils.CollectionUtils;
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
import kd.bos.dataentity.entity.DynamicObject;
|
|
import kd.bos.dataentity.entity.DynamicObject;
|
|
|
|
+import kd.bos.dataentity.entity.DynamicObjectCollection;
|
|
|
|
+import kd.bos.entity.datamodel.events.BeforeImportEntryEventArgs;
|
|
import kd.bos.entity.datamodel.events.ChangeData;
|
|
import kd.bos.entity.datamodel.events.ChangeData;
|
|
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
|
|
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
|
|
|
|
+import kd.bos.exception.KDBizException;
|
|
import kd.bos.form.plugin.AbstractFormPlugin;
|
|
import kd.bos.form.plugin.AbstractFormPlugin;
|
|
|
|
+import kd.bos.form.plugin.importentry.resolving.ImportEntryData;
|
|
import kd.bos.orm.query.QCP;
|
|
import kd.bos.orm.query.QCP;
|
|
import kd.bos.orm.query.QFilter;
|
|
import kd.bos.orm.query.QFilter;
|
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
|
|
|
+import scala.Int;
|
|
|
|
+
|
|
|
|
+import java.util.*;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
public class BusinessProcessingSplitPlugin extends AbstractFormPlugin {
|
|
public class BusinessProcessingSplitPlugin extends AbstractFormPlugin {
|
|
|
|
|
|
@@ -42,4 +52,44 @@ public class BusinessProcessingSplitPlugin extends AbstractFormPlugin {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void beforeImportEntry(BeforeImportEntryEventArgs e) {
|
|
|
|
+ Map source = (Map) e.getSource();
|
|
|
|
+ Set<Map.Entry<String, List<ImportEntryData>>> entries = source.entrySet();
|
|
|
|
+ for (Map.Entry<String, List<ImportEntryData>> entry : entries) {
|
|
|
|
+ String entryName = entry.getKey();
|
|
|
|
+ if (StringUtils.equals(entryName, "nckd_entryentity61121")) {
|
|
|
|
+ List<ImportEntryData> entryEntityImportDataList = entry.getValue();
|
|
|
|
+ if (CollectionUtils.isEmpty(entryEntityImportDataList)) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ DynamicObject nckd_orgfield = (DynamicObject) this.getModel().getValue("nckd_orgfield");
|
|
|
|
+ Long orgId = nckd_orgfield.getLong("id");
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ DynamicObjectCollection nckd_entryentity61121s = this.getModel().getEntryEntity("nckd_entryentity61121");
|
|
|
|
+ Map<String, DynamicObject> entryMap = new HashMap<>();
|
|
|
|
+ for (DynamicObject dynamicObject : nckd_entryentity61121s) {
|
|
|
|
+ entryMap.put(dynamicObject.getDynamicObject("nckd_basedatafield18").getString("number"), dynamicObject);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Iterator<ImportEntryData> iterator = entryEntityImportDataList.iterator();
|
|
|
|
+ while (iterator.hasNext()) {
|
|
|
|
+ ImportEntryData entryData = iterator.next();
|
|
|
|
+ JSONObject jsonObject = entryData.getData();
|
|
|
|
+ String importNumber = jsonObject.getJSONObject("nckd_basedatafield18").getString("number");
|
|
|
|
+ DynamicObject dynamicObject = entryMap.get(importNumber);
|
|
|
|
+ QFilter cardFilter = new QFilter("number", QCP.equals, importNumber);
|
|
|
|
+ cardFilter.and("org", QCP.equals, orgId);
|
|
|
|
+ DynamicObject[] card = BusinessDataServiceHelper.load("fa_card_fin","id",new QFilter[] {cardFilter});
|
|
|
|
+ if (card.length == 0) {
|
|
|
|
+ iterator.remove();
|
|
|
|
+ }else if (card.length > 0 && dynamicObject != null){
|
|
|
|
+ nckd_entryentity61121s.remove(dynamicObject);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|