Sfoglia il codice sorgente

对公/差旅操作插件

徐昊 9 mesi fa
parent
commit
642239d496

+ 157 - 0
src/main/java/fi/em/EditPlugin/MotivationParameterEditPlugin.java

@@ -0,0 +1,157 @@
+package fi.em.EditPlugin;
+
+import kd.bos.exception.KDBizException;
+import kd.bos.form.CloseCallBack;
+import kd.bos.form.FormShowParameter;
+import kd.bos.form.ShowType;
+import kd.bos.form.events.AfterDoOperationEventArgs;
+import kd.bos.form.events.ClosedCallBackEvent;
+import kd.bos.list.plugin.AbstractListPlugin;
+import kd.sdk.plugin.Plugin;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import kd.bos.bill.BillShowParameter;
+import kd.bos.context.RequestContext;
+import kd.bos.dataentity.entity.DynamicObject;
+import kd.bos.dataentity.entity.DynamicObjectCollection;
+import kd.bos.servicehelper.BusinessDataServiceHelper;
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
+
+public class MotivationParameterEditPlugin extends AbstractListPlugin implements Plugin {
+    public static String btn_NOTICE = "donothing";
+    public static String FORMID_NOTICEMODAL = "nckd_agentparameterf7";
+    public static String FORMID = "ztjg_postcertapply";
+    public static String FORMID_NOTICE = "ztjg_postcertifynotice";
+    private static String FORMID_USER = "bos_user";
+
+    @Override
+    public void afterDoOperation(AfterDoOperationEventArgs e) {
+        if (btn_NOTICE.equals(e.getOperateKey())) {
+            Object value = this.getModel().getValue("costcompany");
+            DynamicObject costcompany = (DynamicObject) value;
+            String orgnumber = costcompany.getString("number");
+            if (orgnumber == null){
+                throw new KDBizException("付费承担公司为空!");
+            }
+            showParameter(FORMID_NOTICEMODAL, btn_NOTICE,orgnumber);
+        }
+    }
+
+    @Override
+    public void closedCallBack(ClosedCallBackEvent e) {
+        super.closedCallBack(e);
+        if (StringUtils.equals(btn_NOTICE, e.getActionId()) && null != e.getReturnData()) {
+            HashMap<String, String> returnData = (HashMap<String, String>) e.getReturnData();
+            String reJaStr = returnData.get("reJaStr");
+            if (StringUtils.isNotBlank(reJaStr)) {
+                JSONArray reJa = JSONArray.parseArray(reJaStr);
+                JSONObject reJo = reJa.getJSONObject(0);
+                DynamicObject userInfo = BusinessDataServiceHelper.loadSingle(RequestContext.get().getCurrUserId(), FORMID_USER);
+
+                String noticeId = reJo.getString("ztjg_id");
+                DynamicObject noticeInfo = BusinessDataServiceHelper.loadSingle(Long.valueOf(noticeId), FORMID_NOTICE);
+                DynamicObjectCollection entryCo = noticeInfo.getDynamicObjectCollection("ztjg_entryentity");
+                Predicate<DynamicObject> userFilter = (entryInfo) -> entryInfo.getDynamicObject("ztjg_canposteename").getPkValue().equals(userInfo.getPkValue());
+                List<DynamicObject> list = entryCo.stream().filter(userFilter).collect(Collectors.toList());
+                if (list == null || list.size() <= 0) {
+                    this.getView().showMessage("未匹配到认证通知!");
+                    return;
+                }
+                DynamicObject entryInfo = list.get(0);
+                String status = entryInfo.getString("ztjg_statuscan");
+                if (StringUtils.isNotBlank(status) && !"0".equals(status)) {
+                    this.getView().showMessage("未匹配到可请假认证通知!");
+                    return;
+                }
+
+                DynamicObject info = BusinessDataServiceHelper.newDynamicObject(FORMID);
+                info.set("billstatus", "A");
+                info.set("ztjg_aplydate", new Date());
+                info.set("ztjg_applier", userInfo);
+                info.set("ztjg_idno", entryInfo.getString("ztjg_canidno"));
+                info.set("ztjg_postnumber", noticeInfo.getString("billno"));
+                info.set("ztjg_postname", noticeInfo.getString("ztjg_postname"));
+                info.set("ztjg_postdate", noticeInfo.getDate("ztjg_postdate"));
+                info.set("ztjg_address", noticeInfo.getString("ztjg_address"));
+                info.set("ztjg_demand", noticeInfo.getString("ztjg_demand"));
+                info.set("ztjg_mainnotice", noticeInfo.getString("ztjg_mainnotice"));
+                info.set("ztjg_postcontent", noticeInfo.getString("ztjg_postcontent"));
+                info.set("ztjg_integralitem", noticeInfo.getDynamicObject("ztjg_integralitem"));
+                info.set("ztjg_org", noticeInfo.getDynamicObject("ztjg_org"));
+                info.set("ztjg_dept", noticeInfo.getDynamicObject("ztjg_dept"));
+
+                String postnamestr = noticeInfo.getString("ztjg_postnamestr");
+                String datastr = noticeInfo.getString("ztjg_datastr");
+                String address = noticeInfo.getString("ztjg_address");
+                String customize1 = noticeInfo.getString("ztjg_customize1");
+                String customize2 = noticeInfo.getString("ztjg_customize2");
+                String customize3 = noticeInfo.getString("ztjg_customize3");
+
+                info.set("ztjg_postnamestr", postnamestr);
+                info.set("ztjg_datastr", datastr);
+                info.set("ztjg_address", address);
+                info.set("ztjg_customize1", customize1);
+                info.set("ztjg_customize2", customize2);
+                info.set("ztjg_customize3", customize3);
+                info.set("ztjg_postmore", noticeInfo.getBoolean("ztjg_postmore"));
+                info.set("ztjg_datemore", noticeInfo.getBoolean("ztjg_datemore"));
+                info.set("ztjg_addressmore", noticeInfo.getBoolean("ztjg_addressmore"));
+                info.set("ztjg_itemmore1", noticeInfo.getBoolean("ztjg_itemmore1"));
+                info.set("ztjg_itemmore2", noticeInfo.getBoolean("ztjg_itemmore2"));
+                info.set("ztjg_itemmore3", noticeInfo.getBoolean("ztjg_itemmore3"));
+
+                if (StringUtils.isNotBlank(postnamestr) && postnamestr.split(";").length <= 1) {
+                    info.set("ztjg_datastrmy", postnamestr);
+                }
+                if (StringUtils.isNotBlank(datastr) && datastr.split(";").length <= 1) {
+                    info.set("ztjg_datastrmy", datastr);
+                }
+                if (StringUtils.isNotBlank(address) && address.split(";").length <= 1) {
+                    info.set("ztjg_addressmy", address);
+                }
+                if (StringUtils.isNotBlank(customize1) && customize1.split(";").length <= 1) {
+                    info.set("ztjg_customize1my", customize1);
+                }
+                if (StringUtils.isNotBlank(customize2) && customize2.split(";").length <= 1) {
+                    info.set("ztjg_customize2my", customize2);
+                }
+                if (StringUtils.isNotBlank(customize3) && customize3.split(";").length <= 1) {
+                    info.set("ztjg_customize3my", customize3);
+                }
+
+                //OperationResult saveOperate = OperationServiceHelper.executeOperate("save", FORMID, new DynamicObject[] { info }, CommonUtils.getOprateOption());
+
+                BillShowParameter billShowParameter = new BillShowParameter();
+                billShowParameter.getOpenStyle().setShowType(ShowType.Modal);
+                billShowParameter.setFormId(FORMID);
+                billShowParameter.setPkId(info.getPkValue());
+                getView().showForm(billShowParameter);
+            }
+        }
+    }
+
+    public void showParameter(String formId, String actionId,String orgnumber) {
+        //创建弹出页面对象,FormShowParameter表示弹出页面为动态表单
+        FormShowParameter ShowParameter = new FormShowParameter();
+        //ListShowParameter ShowParameter = new ListShowParameter();
+        ShowParameter.setCustomParam("orgnumber", orgnumber);
+        //设置弹出页面的编码
+        ShowParameter.setFormId(formId);
+//        ShowParameter.setCaption();
+        //设置弹出页面标题
+        ShowParameter.setCaption("动因参数选择");
+        //设置页面关闭回调方法
+        //CloseCallBack参数:回调插件,回调标识  btnok
+        ShowParameter.setCloseCallBack(new CloseCallBack(this, actionId));
+        //设置弹出页面打开方式,支持模态,新标签等
+        ShowParameter.getOpenStyle().setShowType(ShowType.Modal);
+        //弹出页面对象赋值给父页面
+        this.getView().showForm(ShowParameter);
+    }
+}

+ 230 - 0
src/main/java/fi/em/FormPlugin/PostModalFormPlugin.java

@@ -0,0 +1,230 @@
+package fi.em.FormPlugin;
+
+import kd.bos.exception.KDBizException;
+import kd.bos.form.plugin.AbstractFormPlugin;
+import kd.sdk.plugin.Plugin;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import kd.bos.context.RequestContext;
+import kd.bos.dataentity.entity.DynamicObject;
+import kd.bos.dataentity.serialization.SerializationUtils;
+import kd.bos.form.control.Control;
+import kd.bos.form.control.EntryGrid;
+import kd.bos.form.events.AfterDoOperationEventArgs;
+import kd.bos.orm.query.QCP;
+import kd.bos.orm.query.QFilter;
+import kd.bos.servicehelper.BusinessDataServiceHelper;
+import org.apache.commons.lang3.StringUtils;
+
+import java.math.BigDecimal;
+import java.util.*;
+public class PostModalFormPlugin extends AbstractFormPlugin implements Plugin {
+    private final static String KEY_OK = "btnok";
+    //页面取消按钮标识
+    private final static String KEY_CANCEL = "btncancel";
+    //页面取消按钮标识
+    private final static String KEY_SEARCH = "search";
+
+    private final static String FORMID_ENTRY = "ztjg_entryentity";
+
+    private final static String FORMID = "ztjg_postcertifynotice";
+
+    private static String FORMID_USER = "bos_user";
+
+    private static String nckd_agentparameter = "nckd_agentparameter";
+    /**
+     * 页面点击事件
+     *
+     * @param evt
+     */
+    @Override
+    public void click(EventObject evt) {
+        super.click(evt);
+        //获取被点击的控件对象
+        Control source = (Control) evt.getSource();
+        String pageId = this.getView().getPageId();
+        if (StringUtils.equals(source.getKey(), KEY_OK)) {
+            String listStr = this.getPageCache().get(pageId);
+            if (StringUtils.isNotBlank(listStr)){
+                JSONArray reJa = new JSONArray();
+                EntryGrid entryGrid = this.getView().getControl(FORMID_ENTRY);
+                int[] selectRows = entryGrid.getSelectRows();
+                if (selectRows.length<=0){
+                    this.getView().showMessage("请先选择一条数据!");
+                    return;
+                }
+
+                JSONArray infoJa = SerializationUtils.fromJsonString(listStr, JSONArray.class);
+                for(int i=0;i<selectRows.length;i++){
+                    JSONObject reJo = infoJa.getJSONObject(selectRows[i]);
+                    reJa.add(reJo);
+                }
+                HashMap<String, String> map = new HashMap<>();
+                map.put("reJaStr", reJa.toJSONString());
+
+                this.getView().returnDataToParent(map);
+            }
+
+            this.getView().close();
+        } else if (StringUtils.equals(source.getKey(), KEY_CANCEL)) {
+            //被点击控件为取消则设置返回值为空并关闭页面(在页面关闭回调方法中必须验证返回值不为空,否则会报空指针)
+            this.getView().returnDataToParent(null);
+            this.getView().close();
+        } else {
+            this.getView().returnDataToParent(null);
+            this.getView().close();
+        }
+    }
+
+    @Override
+    public void registerListener(EventObject e) {
+        super.registerListener(e);
+        //页面确认按钮和取消按钮添加监听
+        this.addClickListeners(KEY_OK, KEY_CANCEL);
+    }
+
+    @Override
+    public void afterCreateNewData(EventObject e) {
+        super.afterBindData(e);
+        DynamicObject period = (DynamicObject) this.getModel().getValue("nckd_agentparameter");
+        //获取父页面传入数据
+        Map<String, Object> customParams = this.getView().getFormShowParameter().getCustomParams();
+        String orgnumber = (String) customParams.get("orgnumber");
+        if (orgnumber == null){
+            throw new KDBizException("付费承担公司为空!");
+        }
+        QFilter nckd_orgamountFilter = new QFilter("nckd_unappliedorg.number", QCP.equals,orgnumber);
+        if(period !=null){
+            String nckd_sole = period.getString("nckd_sole");
+            if(nckd_sole!=null && !nckd_sole.isEmpty()){
+                nckd_orgamountFilter.and("nckd_typeagent.nckd_sole", QCP.equals,"A");
+            }
+        }
+        nckd_orgamountFilter.and("enable", QCP.equals,"1");
+        DynamicObject[] nckd_orgamountaccount = BusinessDataServiceHelper.load(nckd_agentparameter,"id",new QFilter[] {nckd_orgamountFilter});
+        for (int c=0;c<nckd_orgamountaccount.length;c++){
+            DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle(nckd_orgamountaccount[c].getPkValue(), nckd_orgamountaccount[c].getDynamicObjectType().getName());
+            for (DynamicObject entryentity : dynamicObject.getDynamicObjectCollection("nckd_sharemessage")) {
+                DynamicObject nckdShareorg = entryentity.getDynamicObject("nckd_shareorg");
+                BigDecimal nckdAgentvalue = entryentity.getBigDecimal("nckd_agentvalue");
+            }
+        }
+
+        //initTable(isInform,isForce,startDate,endDate,null);
+    }
+
+    @Override
+    public void afterDoOperation(AfterDoOperationEventArgs e) {
+        if (KEY_SEARCH.equals(e.getOperateKey())) {
+            Date startDate = (Date) this.getModel().getValue("ztjg_startdate");
+            Date endDate = (Date) this.getModel().getValue("ztjg_enddate");
+            Boolean isForce = (Boolean) this.getModel().getValue("ztjg_isforce");
+            Boolean isInform = (Boolean) this.getModel().getValue("ztjg_isinform");
+            String likeName = (String) this.getModel().getValue("ztjg_likename");
+            if (isForce == null){
+                isForce = false;
+            }
+            if (isInform == null){
+                isInform = false;
+            }
+
+            if (startDate == null){
+                this.getView().showMessage("请选择开始日期!");
+                return;
+            }else if (endDate == null){
+                this.getView().showMessage("请选择结束日期!");
+                return;
+            }
+
+            initTable(isInform,isForce,startDate,endDate,likeName);
+        }
+    }
+
+    public void initTable(Boolean isInform,Boolean isForce,Date startdate,Date etartdate,String likeName){
+        //历史数据清除
+        this.getModel().deleteEntryData(FORMID_ENTRY);
+
+        JSONArray reJa = getInitData(isInform,isForce,startdate,etartdate,likeName);
+        for (int i=0;i<reJa.size();i++){
+            JSONObject processJo = reJa.getJSONObject(i);
+            int rowIndex = this.getModel().createNewEntryRow(FORMID_ENTRY);
+            this.getModel().setValue("ztjg_id", processJo.getString("ztjg_id"), rowIndex);
+            this.getModel().setValue("ztjg_noticeno", processJo.getString("ztjg_noticeno"), rowIndex);
+            this.getModel().setValue("ztjg_noticedate", processJo.getDate("ztjg_noticedate"), rowIndex);
+            this.getModel().setValue("ztjg_org", processJo.getObject("ztjg_org", DynamicObject.class), rowIndex);
+            this.getModel().setValue("ztjg_dept", processJo.getObject("ztjg_dept",DynamicObject.class), rowIndex);
+            this.getModel().setValue("ztjg_postname", processJo.getString("ztjg_postname"), rowIndex);
+            this.getModel().setValue("ztjg_postdate", processJo.getDate("ztjg_postdate"), rowIndex);
+            this.getModel().setValue("ztjg_address", processJo.getString("ztjg_address"), rowIndex);
+            this.getModel().setValue("ztjg_postcontent", processJo.getString("ztjg_postcontent"), rowIndex);
+            this.getModel().setValue("ztjg_demand", processJo.getString("ztjg_demand"), rowIndex);
+            this.getModel().setValue("ztjg_mainnotice", processJo.getString("ztjg_mainnotice"), rowIndex);
+            this.getModel().setValue("ztjg_integralitem", processJo.getObject("ztjg_integralitem",DynamicObject.class), rowIndex);
+            this.getModel().setValue("ztjg_retakes", processJo.getBoolean("ztjg_retakes"), rowIndex);
+            this.getModel().setValue("ztjg_datastr", processJo.getString("ztjg_datastr"), rowIndex);
+            this.getModel().setValue("ztjg_customize1", processJo.getString("ztjg_customize1"), rowIndex);
+            this.getModel().setValue("ztjg_customize2", processJo.getString("ztjg_customize2"), rowIndex);
+            this.getModel().setValue("ztjg_customize3", processJo.getString("ztjg_customize3"), rowIndex);
+            this.getModel().setValue("ztjg_postnamestr", processJo.getString("ztjg_postnamestr"), rowIndex);
+        }
+        String pageId = this.getView().getPageId();
+        String listStr = SerializationUtils.toJsonString(reJa);
+        this.getPageCache().put(pageId,listStr);
+    }
+
+    public static JSONArray getInitData(Boolean isInform,Boolean isForce, Date startdate,Date enddate,String likeName){
+        JSONArray reJa = new JSONArray();
+        DynamicObject userInfo =  BusinessDataServiceHelper.loadSingle(RequestContext.get().getCurrUserId(),FORMID_USER);
+        QFilter[] filters = null;
+        QFilter personQFilter = null;
+        QFilter statusQFilter = null;
+        if (isForce){
+            personQFilter = new QFilter("entryentity.ztjg_posteename.id", QCP.equals, userInfo.getPkValue());
+            statusQFilter = new QFilter("entryentity.ztjg_ispushforce", QCP.equals, false);
+        }else {
+            personQFilter = new QFilter("ztjg_entryentity.ztjg_canposteename.id", QCP.equals, userInfo.getPkValue());
+            statusQFilter = new QFilter("ztjg_entryentity.ztjg_ispushcan", QCP.equals, false);
+        }
+        QFilter qFilter1 = new QFilter("billstatus", QCP.equals, "C");
+        QFilter qFilter2 = new QFilter("ztjg_bizdate", QCP.large_equals, startdate);
+        QFilter qFilter3 = new QFilter("ztjg_bizdate", QCP.less_equals, enddate);
+        QFilter qFilter4 = new QFilter("ztjg_postname", QCP.like, "%"+likeName+"%");
+
+        if (!isInform){
+            if (StringUtils.isNotBlank(likeName)){
+                filters = new QFilter[]{personQFilter,statusQFilter,qFilter1,qFilter2,qFilter3,qFilter4};
+            }else {
+                filters = new QFilter[]{personQFilter,statusQFilter,qFilter1,qFilter2,qFilter3};
+            }
+        }
+
+        DynamicObject[] conObjects = BusinessDataServiceHelper.load(FORMID,"id,billno,ztjg_bizdate,ztjg_org,ztjg_dept,ztjg_postname,ztjg_postdate,ztjg_address,ztjg_postcontent,ztjg_demand,ztjg_mainnotice,ztjg_integralitem,ztjg_retakes,ztjg_postnamestr,ztjg_datastr,ztjg_customize1,ztjg_customize2,ztjg_customize3",filters);
+        for (DynamicObject obj:conObjects){
+            JSONObject itemJo = new JSONObject();
+            itemJo.put("ztjg_id",obj.getPkValue().toString());
+            itemJo.put("ztjg_noticeno",obj.getString("billno"));
+            itemJo.put("ztjg_noticedate",obj.getDate("ztjg_bizdate"));
+            itemJo.put("ztjg_org",obj.getDynamicObject("ztjg_org"));
+            itemJo.put("ztjg_dept",obj.getDynamicObject("ztjg_dept"));
+            itemJo.put("ztjg_postname",obj.getString("ztjg_postname"));
+            itemJo.put("ztjg_postdate",obj.getDate("ztjg_postdate"));
+            itemJo.put("ztjg_address",obj.getString("ztjg_address"));
+            itemJo.put("ztjg_postcontent",obj.getString("ztjg_postcontent"));
+            itemJo.put("ztjg_demand",obj.getString("ztjg_demand"));
+            itemJo.put("ztjg_mainnotice",obj.getString("ztjg_mainnotice"));
+            itemJo.put("ztjg_integralitem",obj.getDynamicObject("ztjg_integralitem"));
+            itemJo.put("ztjg_retakes",obj.getBoolean("ztjg_retakes"));
+            itemJo.put("ztjg_postnamestr",obj.getString("ztjg_postnamestr"));
+            itemJo.put("ztjg_datastr",obj.getString("ztjg_datastr"));
+            itemJo.put("ztjg_customize1",obj.getString("ztjg_customize1"));
+            itemJo.put("ztjg_customize2",obj.getString("ztjg_customize2"));
+            itemJo.put("ztjg_customize3",obj.getString("ztjg_customize3"));
+
+            reJa.add(itemJo);
+        }
+
+        return reJa;
+    }
+
+
+}

+ 1 - 1
src/main/java/fi/em/opplugin/PublicExpenseOpPlugin.java

@@ -58,7 +58,7 @@ public class PublicExpenseOpPlugin extends AbstractOperationServicePlugIn {
                 //循环数组获取组织金额标准数据包  默认取组织,没有取集团
                 for (int c=0;c<nckd_orgamountaccount.length;c++){
                     //组织金额标准数据包
-                    DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle(nckd_orgamountaccount[i].getPkValue(), nckd_orgamountaccount[i].getDynamicObjectType().getName());
+                    DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle(nckd_orgamountaccount[c].getPkValue(), nckd_orgamountaccount[c].getDynamicObjectType().getName());
                    //获取标准金额
                     BigDecimal nckdAmountfield = dynamicObject.getBigDecimal("nckd_amountfield");
                     String enable = dynamicObject.getString("enable");