Quellcode durchsuchen

1、费用申请提交校验额度

wanghaiwu vor 1 Woche
Ursprung
Commit
f1226e6968

+ 32 - 28
code/jyyy/nckd-jimin-jyyy-fi/src/main/java/nckd/jimin/jyyy/fi/plugin/form/DailyApplyBillAmountEditPlugin.java

@@ -69,25 +69,27 @@ public class DailyApplyBillAmountEditPlugin extends AbstractBillPlugIn {
 
     private void showHeadBalanceAmount(){
         ((Label)this.getControl("nckd_reimbursecontrolinfo")).setText("");
-        DynamicObject dataEntity = this.getModel().getDataEntity(true);
-        DynamicObjectCollection expenseEntries = dataEntity.getDynamicObjectCollection("expenseentryentity");
-        String rowIndexStr = this.getPageCache().get("currentExpenseEntryIndex");
-        int currentRowIndex;
-        if (StringUtils.isNotBlank(rowIndexStr)) {
-            currentRowIndex = Integer.parseInt(rowIndexStr);
-        } else {
-            currentRowIndex = this.getModel().getEntryCurrentRowIndex("expenseentryentity");
-        }
+        this.getModel().setValue("nckd_limitamount", BigDecimal.ZERO);
 
-        if (currentRowIndex >= 0 && expenseEntries.size() > 0) {
-            if (currentRowIndex >= expenseEntries.size()) {
-                currentRowIndex = 0;
-            }
-
-            DynamicObject expenseEntry = (DynamicObject)expenseEntries.get(currentRowIndex);
-            if (!this.validRow(expenseEntry)) {
-                ((Label)this.getControl("nckd_reimbursecontrolinfo")).setText("");
-            } else {
+        DynamicObject dataEntity = this.getModel().getDataEntity(true);
+//        DynamicObjectCollection expenseEntries = dataEntity.getDynamicObjectCollection("expenseentryentity");
+//        String rowIndexStr = this.getPageCache().get("currentExpenseEntryIndex");
+//        int currentRowIndex;
+//        if (StringUtils.isNotBlank(rowIndexStr)) {
+//            currentRowIndex = Integer.parseInt(rowIndexStr);
+//        } else {
+//            currentRowIndex = this.getModel().getEntryCurrentRowIndex("expenseentryentity");
+//        }
+
+//        if (currentRowIndex >= 0 && expenseEntries.size() > 0) {
+//            if (currentRowIndex >= expenseEntries.size()) {
+//                currentRowIndex = 0;
+//            }
+
+//            DynamicObject expenseEntry = (DynamicObject)expenseEntries.get(currentRowIndex);
+//            if (!this.validRow(expenseEntry)) {
+//                ((Label)this.getControl("nckd_reimbursecontrolinfo")).setText("");
+//            } else {
                 IDataModel model = this.getModel();
                 Long companyId = ErCommonUtils.getPk((DynamicObject)model.getValue("company"));
                 String personCtrlCurrency = (String)ErCommonUtils.getEMParameter(companyId, "personctlcurrency");
@@ -102,7 +104,7 @@ public class DailyApplyBillAmountEditPlugin extends AbstractBillPlugIn {
                 reimAmountBO.setCompanyId((Long)amountControlCompanyDO.getPkValue());
                 reimAmountBO.setEmpCtlBill(empCltList);
                 reimAmountBO.setDeptCtlBill(deptCltList);
-                DynamicObject expenseitem = expenseEntry.getDynamicObject("expenseitem");
+                DynamicObject expenseitem = dataEntity.getDynamicObject("nckd_expenseitem");
 
                 expenseitem = BusinessDataServiceHelper.loadSingle(expenseitem.getPkValue(), expenseitem.getDynamicObjectType().getName());
 
@@ -122,15 +124,15 @@ public class DailyApplyBillAmountEditPlugin extends AbstractBillPlugIn {
 
                 reimAmountBO.setCtrlMode(isreimburseamountctl);
 
-                Long oriCurrencyId = (Long)expenseEntry.getDynamicObject("entrycurrency").getPkValue();
+                Long oriCurrencyId = (Long)dataEntity.getDynamicObject("currency").getPkValue();
                 reimAmountBO.setUserOrDeptId((Long)dataEntity.getDynamicObject("applier").getPkValue());
                 QuotaCtrlUtil.genQuotaCurrency(reimAmountBO, personCtrlCurrency, oriCurrencyId, currencyId);
                 String showName = dataEntity.getDynamicObject("applier").getLocaleString("name").getLocaleValue();
 
-                Date date = expenseEntry.getDate("happendate");
-                if ("2".equals(this.quotaDateField)) {
-                    date = (Date)model.getValue("bizdate");
-                }
+                Date date = (Date)model.getValue("bizdate");
+//                if ("2".equals(this.quotaDateField)) {
+//                    date = (Date)model.getValue("bizdate");
+//                }
 
                 Calendar calendar = Calendar.getInstance();
                 calendar.setTime(date);
@@ -162,11 +164,13 @@ public class DailyApplyBillAmountEditPlugin extends AbstractBillPlugIn {
                     String template = ResManager.loadKDString("可用额度: %1$s|%2$s|%3$s", "ReimburseAmountControlFormPlugin_0", "fi-er-formplugin", new Object[0]);
                     String reimburseControlInfo = String.format(template, showName, expenseItemName, balanceAmountStr);
                     ((Label)this.getControl("nckd_reimbursecontrolinfo")).setText(reimburseControlInfo);
+
+                    this.getModel().setValue("nckd_limitamount", balanceAmount);
                 }
-            }
-        } else {
-            ((Label)this.getControl("nckd_reimbursecontrolinfo")).setText("");
-        }
+//            }
+//        } else {
+//            ((Label)this.getControl("nckd_reimbursecontrolinfo")).setText("");
+//        }
     }
 
     private boolean validRow(DynamicObject entry) {

+ 73 - 0
code/jyyy/nckd-jimin-jyyy-fi/src/main/java/nckd/jimin/jyyy/fi/plugin/operate/DailyApplyBillAmountOpPlugin.java

@@ -0,0 +1,73 @@
+package nckd.jimin.jyyy.fi.plugin.operate;
+
+import kd.bos.dataentity.entity.DynamicObject;
+import kd.bos.dataentity.resource.ResManager;
+import kd.bos.entity.ExtendedDataEntity;
+import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
+import kd.bos.entity.plugin.AddValidatorsEventArgs;
+import kd.bos.entity.plugin.PreparePropertysEventArgs;
+import kd.bos.entity.validate.AbstractValidator;
+import kd.bos.logging.Log;
+import kd.bos.logging.LogFactory;
+import java.math.BigDecimal;
+import java.util.List;
+
+/**
+ * 费用申请:nckd_er_dailyapplybil_ext
+ * @author wanghaiwu_kd
+ * @date 2025/09/26
+ */
+public class DailyApplyBillAmountOpPlugin extends AbstractOperationServicePlugIn {
+    private static final Log logger = LogFactory.getLog(DailyApplyBillAmountOpPlugin.class);
+
+    @Override
+    public void onPreparePropertys(PreparePropertysEventArgs e) {
+        super.onPreparePropertys(e);
+
+        List<String> fieldKeys = e.getFieldKeys();
+
+        fieldKeys.add("applyamount");
+        fieldKeys.add("nckd_expenseitem");
+        fieldKeys.add("nckd_limitamount");
+    }
+
+    @Override
+    public void onAddValidators(AddValidatorsEventArgs e) {
+        this.addDailyApplyAmountValidator(e);
+    }
+
+    protected void addDailyApplyAmountValidator(AddValidatorsEventArgs e) {
+        e.addValidator(new DailyApplyAmountValiator());
+    }
+
+    private static class DailyApplyAmountValiator extends AbstractValidator {
+        private DailyApplyAmountValiator() {
+        }
+
+        public void validate() {
+            ExtendedDataEntity[] dataEntities = this.getDataEntities();
+            ExtendedDataEntity[] var2 = dataEntities;
+            int var3 = dataEntities.length;
+
+            for(int var4 = 0; var4 < var3; ++var4) {
+                ExtendedDataEntity dataEntity = var2[var4];
+                DynamicObject billObj = dataEntity.getDataEntity();
+
+                BigDecimal applyAmount = billObj.getBigDecimal("applyamount");
+                BigDecimal limitAmount = billObj.getBigDecimal("nckd_limitamount");
+
+                DynamicObject expenseItem = billObj.getDynamicObject("nckd_expenseitem");
+                if(expenseItem != null){
+                    String number = expenseItem.getString("number");
+                    String name = expenseItem.getString("name");
+
+                    if("FYXM02.01.01".equals(number) || "业务招待费-个人".equals(name)){
+                        if(applyAmount.compareTo(limitAmount) > 0){
+                            this.addErrorMessage(dataEntity, ResManager.loadKDString("申请金额不能超过可用额度", "DailyApplyBillAmountOpPlugin_1", "fi-er-opplugin", new Object[0]));
+                        }
+                    }
+                }
+            }
+        }
+    }
+}