Selaa lähdekoodia

报销单支付组织过滤

xuhao 6 kuukautta sitten
vanhempi
säilyke
72e1de040c
1 muutettua tiedostoa jossa 61 lisäystä ja 0 poistoa
  1. 61 0
      src/main/java/fi/em/formPlugin/BxdF7ListtenerFromPlugin.java

+ 61 - 0
src/main/java/fi/em/formPlugin/BxdF7ListtenerFromPlugin.java

@@ -0,0 +1,61 @@
+package fi.em.formPlugin;
+
+import kd.bos.bill.AbstractBillPlugIn;
+import kd.bos.dataentity.entity.DynamicObject;
+import kd.bos.exception.KDBizException;
+import kd.bos.form.field.BasedataEdit;
+import kd.bos.form.field.events.BeforeF7SelectEvent;
+import kd.bos.form.field.events.BeforeF7SelectListener;
+import kd.bos.list.ListShowParameter;
+import kd.bos.orm.query.QCP;
+import kd.bos.orm.query.QFilter;
+import kd.bos.servicehelper.BusinessDataServiceHelper;
+import kd.sdk.plugin.Plugin;
+import org.apache.commons.lang.StringUtils;
+
+import java.util.EventObject;
+import java.util.HashSet;
+import java.util.Map;
+
+public class BxdF7ListtenerFromPlugin extends AbstractBillPlugIn implements Plugin, BeforeF7SelectListener {
+    private final static String paycompany="paycompany";//支付组织
+
+    @Override
+    public void registerListener(EventObject e) {
+        super.registerListener(e);
+        // 侦听基础资料字段的事件
+        BasedataEdit fieldEdit1 = this.getView().getControl(paycompany);
+        fieldEdit1.addBeforeF7SelectListener(this);
+    }
+    @Override
+    public void beforeF7Select(BeforeF7SelectEvent beforeF7SelectEvent) {
+        String fieldKey = beforeF7SelectEvent.getProperty().getName();
+        int row = beforeF7SelectEvent.getRow();
+        if (StringUtils.equals(fieldKey, paycompany)){
+            this.getQFilter(beforeF7SelectEvent,paycompany);
+        }
+    }
+    private void getQFilter(BeforeF7SelectEvent arg0, String type) {
+        if (type.equals(paycompany)) {
+            DynamicObject fkdata = (DynamicObject)this.getModel().getValue("costcompany") ;
+            if(fkdata ==null){
+                throw new KDBizException("费用承担组织为空!");
+            }
+            long orgid = fkdata.getLong("id");
+            QFilter banks = new QFilter("fromorg.id", QCP.equals, orgid);
+            banks.and("typerelation.id", QCP.equals, Long.valueOf("633138469186574336"));
+            Map<Object, DynamicObject> nckd_cas_arbilMap = BusinessDataServiceHelper.loadFromCache("bos_org_orgrelation", new QFilter[]{banks});
+            HashSet<Long> objects = new HashSet<>();
+            for (Object idkey:nckd_cas_arbilMap.keySet()) {
+                //当前单头
+                DynamicObject dynamicObject = nckd_cas_arbilMap.get(idkey);
+                DynamicObject fromorg1 = dynamicObject.getDynamicObject("toorg");
+                long id = fromorg1.getLong("id");
+                objects.add(id);
+            }
+            QFilter nckd_skzjFilter = new QFilter("id", QCP.in,objects);
+            ListShowParameter showParameter = (ListShowParameter)arg0.getFormShowParameter();
+            showParameter.getListFilterParameter().setFilter(nckd_skzjFilter);
+        }
+    }
+}