Sfoglia il codice sorgente

1、新增插件,处理费用申请单设置隐藏功能

wanghaiwu 3 giorni fa
parent
commit
66918bf249

+ 19 - 0
code/jyyy/nckd-jimin-jyyy-fi/src/main/java/nckd/jimin/jyyy/fi/plugin/form/DailyApplyBillFilterListPlugin.java

@@ -0,0 +1,19 @@
+package nckd.jimin.jyyy.fi.plugin.form;
+
+import kd.bos.form.events.SetFilterEvent;
+import kd.bos.list.plugin.AbstractListPlugin;
+import kd.bos.orm.query.QCP;
+import kd.bos.orm.query.QFilter;
+
+/**
+ * @author wanghaiwu_kd
+ * @date 2026/01/14
+ */
+public class DailyApplyBillFilterListPlugin extends AbstractListPlugin {
+    @Override
+    public void setFilter(SetFilterEvent e) {
+        super.setFilter(e);
+
+        e.addCustomQFilter(new QFilter("nckd_handhide", QCP.equals, "0"));
+    }
+}

+ 49 - 0
code/jyyy/nckd-jimin-jyyy-fi/src/main/java/nckd/jimin/jyyy/fi/plugin/form/DailyApplyBillSetHideListPlugin.java

@@ -0,0 +1,49 @@
+package nckd.jimin.jyyy.fi.plugin.form;
+
+import com.alibaba.druid.util.StringUtils;
+import kd.bos.entity.operate.result.IOperateInfo;
+import kd.bos.entity.operate.result.OperationResult;
+import kd.bos.form.events.AfterDoOperationEventArgs;
+import kd.bos.list.plugin.AbstractListPlugin;
+import java.util.List;
+
+/**
+ * 费用申请单
+ * @author wanghaiwu_kd
+ * @date 2026/01/14
+ */
+public class DailyApplyBillSetHideListPlugin extends AbstractListPlugin {
+    @Override
+    public void afterDoOperation(AfterDoOperationEventArgs afterDoOperationEventArgs) {
+        super.afterDoOperation(afterDoOperationEventArgs);
+
+        String operationKey = afterDoOperationEventArgs.getOperateKey();
+
+        if("nckd_hidebill".equals(operationKey) || "nckd_unhidebill".equals(operationKey)){
+            OperationResult operationResult = afterDoOperationEventArgs.getOperationResult();
+            operationResult.setShowMessage(false);
+
+            String message = operationResult.getMessage();
+
+            if(!StringUtils.isEmpty(message) && (message.contains("设置隐藏成功") || message.contains("取消隐藏成功"))){
+                this.getView().showSuccessNotification(message);
+                this.getView().invokeOperation("refresh");
+            } else {
+                List<IOperateInfo> errorInfos = operationResult.getAllErrorOrValidateInfo();
+                boolean isSuccess = operationResult.isSuccess();
+                if (errorInfos.size() > 0) {
+                    operationResult.setSuccess(false);
+                    StringBuffer msg = new StringBuffer();
+                    for (IOperateInfo errInfo : errorInfos) {
+                        msg.append(errInfo.getMessage()).append("\r\n");
+                    }
+                    message = message + "\r\n" + msg.toString();
+                }
+
+                if (!StringUtils.isEmpty(message)) {
+                    this.getView().showErrorNotification(message);
+                }
+            }
+        }
+    }
+}

+ 101 - 0
code/jyyy/nckd-jimin-jyyy-fi/src/main/java/nckd/jimin/jyyy/fi/plugin/operate/DailyApplyBillSetHideOpPlugin.java

@@ -0,0 +1,101 @@
+package nckd.jimin.jyyy.fi.plugin.operate;
+
+import com.alibaba.druid.util.StringUtils;
+import fi.cas.opplugin.PayBillToolUtil;
+import kd.bos.dataentity.entity.DynamicObject;
+import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
+import kd.bos.entity.plugin.PreparePropertysEventArgs;
+import kd.bos.entity.plugin.args.AfterOperationArgs;
+import kd.bos.entity.plugin.args.BeforeOperationArgs;
+import kd.bos.entity.plugin.args.BeginOperationTransactionArgs;
+import kd.bos.entity.plugin.args.EndOperationTransactionArgs;
+import kd.bos.logging.Log;
+import kd.bos.logging.LogFactory;
+import kd.bos.servicehelper.BusinessDataServiceHelper;
+import kd.bos.servicehelper.operation.SaveServiceHelper;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 费用申请:nckd_er_dailyapplybil_ext
+ * @author wanghaiwu_kd
+ * @date 2026/01/14
+ */
+public class DailyApplyBillSetHideOpPlugin extends AbstractOperationServicePlugIn {
+    private static final Log logger = LogFactory.getLog(DailyApplyBillSetHideOpPlugin.class);
+
+    public void onPreparePropertys(PreparePropertysEventArgs e) {
+        super.onPreparePropertys(e);
+
+        List<String> fieldKeys = e.getFieldKeys();
+    }
+
+    @Override
+    public void beforeExecuteOperationTransaction(BeforeOperationArgs e) {
+        super.beforeExecuteOperationTransaction(e);
+
+        String msg = "";
+        StringBuilder sb = new StringBuilder();
+
+        DynamicObject[] billEntities = e.getDataEntities();
+        String operationKey = e.getOperationKey();
+
+        //获取操作按钮操作编码
+        if ("nckd_hidebill".equals(operationKey) || "nckd_unhidebill".equals(operationKey)){
+            boolean isHide = false;
+            if("nckd_hidebill".equals(operationKey)){
+                isHide = true;
+            } else if("nckd_unhidebill".equals(operationKey)){
+                isHide = false;
+            }
+
+            List<DynamicObject> listObj = new ArrayList<>();
+
+            for (DynamicObject dataEntity : billEntities) {
+                DynamicObject payBillEntity = BusinessDataServiceHelper.loadSingle(dataEntity.getPkValue(), dataEntity.getDynamicObjectType().getName());
+
+                String billStatus = payBillEntity.getString("billstatus");
+                if("E".equals(billStatus)){
+                    sb.append((sb.length() > 0 ? "," : "")).append(payBillEntity.getString("billno"));
+
+                    continue;
+                }
+
+                payBillEntity.set("nckd_handhide", isHide);
+
+                listObj.add(payBillEntity);
+            }
+
+            if(sb.length() > 0) {
+                msg = "以下单据不是审核状态,请取消选择后再操作!\r\n" + sb.toString();
+            } else {
+                if (listObj.size() > 0) {
+                    SaveServiceHelper.update(listObj.toArray(new DynamicObject[]{}));
+
+                    msg = "nckd_hidebill".equals(operationKey) ? "设置隐藏成功" : "取消隐藏成功";
+                } else {
+                    msg = "无符合条件的记录!";
+                }
+            }
+        }
+
+        e.setCancelMessage(msg);
+        e.setCancel(true);
+    }
+
+    @Override
+    public void beginOperationTransaction(BeginOperationTransactionArgs e) {
+        super.beginOperationTransaction(e);
+    }
+
+    @Override
+    public void endOperationTransaction(EndOperationTransactionArgs e) {
+        super.endOperationTransaction(e);
+    }
+
+    @Override
+    public void afterExecuteOperationTransaction(AfterOperationArgs e) {
+        super.afterExecuteOperationTransaction(e);
+    }
+}