From 9b93abc6806085134976f815baab398eca3a2d12 Mon Sep 17 00:00:00 2001 From: weiyunlong Date: Thu, 5 Jun 2025 17:39:57 +0800 Subject: [PATCH] ### MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - [x] 认领处理单收款类型选了退预付款,但是没有关联预付款单也能提交,需要增加限制不能提交 - [x] 关联预付款单的供应商默认带出来后不允许修改 - [x] 处理排程退单报错 - [x] 排程单据合并/解除(根据规则合并,日期为毫秒舍去后再参与规则比较) - [x] 认领单选员工还款时默认带出客户 --s --- .../plugin/form/ClaimBillButtonAssPlugin.java | 14 +++++ .../fi/fi/plugin/form/ScheduleListPlugin.java | 12 ++--- .../fi/fi/plugin/form/TextFieldDemo.java | 14 +++-- .../operate/ClaimbillSubmitOperation.java | 53 +++++++++++++++++++ .../operate/SchedulebillMergeOperation.java | 9 ++-- 5 files changed, 89 insertions(+), 13 deletions(-) diff --git a/main/java/shjh/jhzj7/fi/fi/plugin/form/ClaimBillButtonAssPlugin.java b/main/java/shjh/jhzj7/fi/fi/plugin/form/ClaimBillButtonAssPlugin.java index 1d61954..6e32147 100644 --- a/main/java/shjh/jhzj7/fi/fi/plugin/form/ClaimBillButtonAssPlugin.java +++ b/main/java/shjh/jhzj7/fi/fi/plugin/form/ClaimBillButtonAssPlugin.java @@ -3,6 +3,7 @@ package shjh.jhzj7.fi.fi.plugin.form; import kd.bos.dataentity.entity.DynamicObject; import kd.bos.dataentity.entity.DynamicObjectCollection; import kd.bos.entity.datamodel.IDataModel; +import kd.bos.entity.datamodel.events.PropertyChangedArgs; import kd.bos.form.CloseCallBack; import kd.bos.form.FormShowParameter; import kd.bos.form.ShowType; @@ -236,4 +237,17 @@ public class ClaimBillButtonAssPlugin extends AbstractFormPlugin implements Plug } } + @Override + public void propertyChanged(PropertyChangedArgs e) { + super.propertyChanged(e); + String name = e.getProperty().getName(); + if ("recpaytype".equals(name)) { + DynamicObject value = (DynamicObject)this.getModel().getValue(name); + //员工还款时,付款人类型,客户 + if (null != value && "109".equals(value.getString("number"))) { + this.getModel().setValue("paymenttype","bd_customer"); + this.getView().updateView("paymenttype"); + } + } + } } \ No newline at end of file diff --git a/main/java/shjh/jhzj7/fi/fi/plugin/form/ScheduleListPlugin.java b/main/java/shjh/jhzj7/fi/fi/plugin/form/ScheduleListPlugin.java index c4cff48..17dceca 100644 --- a/main/java/shjh/jhzj7/fi/fi/plugin/form/ScheduleListPlugin.java +++ b/main/java/shjh/jhzj7/fi/fi/plugin/form/ScheduleListPlugin.java @@ -137,7 +137,7 @@ public class ScheduleListPlugin extends AbstractListPlugin { JSONObject jsonObject = new JSONObject(); String CompanyCode = ""; String CompanyName = ""; - DynamicObject openorg = bill.getDynamicObject("openorg");//核算组织 + DynamicObject openorg = bill.getDynamicObject("company");//资金组织 if (null != openorg) { CompanyCode = openorg.getString("number"); CompanyName = openorg.getString("name"); @@ -147,21 +147,21 @@ public class ScheduleListPlugin extends AbstractListPlugin { jsonObject.put("BillHeaderID", bill.getString("shjh_fkbillid"));//费控单据头ID jsonObject.put("DetailID", bill.getString("shjh_fkentryid"));//费控分录明细ID String PaymentBank = ""; - DynamicObject payerbank = bill.getDynamicObject("payerbank"); - if (null != payerbank) { - PaymentBank = payerbank.getString("name"); + DynamicObject acctbank = bill.getDynamicObject("acctbank"); + if (null != acctbank) { + PaymentBank = acctbank.getString("name"); } jsonObject.put("PaymentBank", PaymentBank);//付款银行 //付款状态 (败笔退回:-5、取消付款:-20、付款失败:-10、部分付款失败:30、付款成功:20、部分付款成功:25、 // 处理中:15、待付款:10、未付款:0、未推送:-99、已修改:-100) jsonObject.put("PaymentStatus", "-5"); String PaymentAccNum = ""; - DynamicObject payeracctbank = bill.getDynamicObject("payeracctbank");//银行账号 + DynamicObject payeracctbank = bill.getDynamicObject("accountbanks");//银行账号 if (null != payeracctbank) { PaymentAccNum = payeracctbank.getString("bankaccountnumber"); } jsonObject.put("PaymentAccNum", PaymentAccNum);//付款账号 - Date paydate = bill.getDate("paydate"); + Date paydate = bill.getDate("paytime"); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); String PaymentDate = format.format(paydate); jsonObject.put("PaymentDate", PaymentDate);//付款时间 diff --git a/main/java/shjh/jhzj7/fi/fi/plugin/form/TextFieldDemo.java b/main/java/shjh/jhzj7/fi/fi/plugin/form/TextFieldDemo.java index da19d74..bfefbc1 100644 --- a/main/java/shjh/jhzj7/fi/fi/plugin/form/TextFieldDemo.java +++ b/main/java/shjh/jhzj7/fi/fi/plugin/form/TextFieldDemo.java @@ -46,21 +46,24 @@ public class TextFieldDemo extends AbstractFormPlugin { BasedataEdit shjh_profitcenter = this.getView().getControl("shjh_pc"); //根据业务小类设置 成本中心,利润中心是否必填 DynamicObject shjhBizsmall = (DynamicObject)this.getView().getModel().getValue("shjh_bizsmall"); + BasedataProp tp = (BasedataProp) shjh_costcenter.getProperty(); + BasedataProp td = (BasedataProp) shjh_profitcenter.getProperty(); + if (null != shjhBizsmall) { shjhBizsmall = BusinessDataServiceHelper.loadSingle(shjhBizsmall.getPkValue(),"shjh_bizsmalltype"); // 获取成本中心的必填配置 boolean shjhCc = shjhBizsmall.getBoolean("shjh_cc"); - BasedataProp tp = (BasedataProp) shjh_costcenter.getProperty(); shjh_costcenter.setMustInput(shjhCc); tp.setMustInput(shjhCc); // 获取利润中心的必填配置 boolean shjhPc = shjhBizsmall.getBoolean("shjh_pc"); - BasedataProp td = (BasedataProp) shjh_profitcenter.getProperty(); shjh_profitcenter.setMustInput(shjhPc); td.setMustInput(shjhPc); }else { shjh_costcenter.setMustInput(false); + tp.setMustInput(false); shjh_profitcenter.setMustInput(false); + td.setMustInput(false); } //赋值结算方式 this.getView().getModel().setValue("shjh_jsfs",this.getView().getModel().getValue("settletype")); @@ -75,21 +78,24 @@ public class TextFieldDemo extends AbstractFormPlugin { BasedataEdit shjh_profitcenter = this.getView().getControl("shjh_pc"); //根据业务小类设置 成本中心,利润中心是否必填 DynamicObject shjhBizsmall = (DynamicObject)this.getView().getModel().getValue("shjh_bizsmall"); + BasedataProp tp = (BasedataProp) shjh_costcenter.getProperty(); + BasedataProp td = (BasedataProp) shjh_profitcenter.getProperty(); + if (null != shjhBizsmall) { shjhBizsmall = BusinessDataServiceHelper.loadSingle(shjhBizsmall.getPkValue(),"shjh_bizsmalltype"); // 获取成本中心的必填配置 boolean shjhCc = shjhBizsmall.getBoolean("shjh_cc"); - BasedataProp tp = (BasedataProp) shjh_costcenter.getProperty(); shjh_costcenter.setMustInput(shjhCc); tp.setMustInput(shjhCc); // 获取利润中心的必填配置 boolean shjhPc = shjhBizsmall.getBoolean("shjh_pc"); - BasedataProp td = (BasedataProp) shjh_profitcenter.getProperty(); shjh_profitcenter.setMustInput(shjhPc); td.setMustInput(shjhPc); }else { shjh_costcenter.setMustInput(false); + tp.setMustInput(false); shjh_profitcenter.setMustInput(false); + td.setMustInput(false); } //赋值结算方式 diff --git a/main/java/shjh/jhzj7/fi/fi/plugin/operate/ClaimbillSubmitOperation.java b/main/java/shjh/jhzj7/fi/fi/plugin/operate/ClaimbillSubmitOperation.java index e1730c8..deac9e6 100644 --- a/main/java/shjh/jhzj7/fi/fi/plugin/operate/ClaimbillSubmitOperation.java +++ b/main/java/shjh/jhzj7/fi/fi/plugin/operate/ClaimbillSubmitOperation.java @@ -2,19 +2,72 @@ package shjh.jhzj7.fi.fi.plugin.operate; import kd.bos.dataentity.entity.DynamicObject; import kd.bos.dataentity.entity.DynamicObjectCollection; +import kd.bos.entity.ExtendedDataEntity; import kd.bos.entity.plugin.AbstractOperationServicePlugIn; +import kd.bos.entity.plugin.AddValidatorsEventArgs; import kd.bos.entity.plugin.args.BeforeOperationArgs; import kd.bos.entity.plugin.args.BeginOperationTransactionArgs; +import kd.bos.entity.validate.AbstractValidator; import kd.bos.servicehelper.BusinessDataServiceHelper; import kd.bos.servicehelper.operation.SaveServiceHelper; import kd.sdk.plugin.Plugin; +import java.math.BigDecimal; + /** * 认领处理单提交操作 * shjh_cas_claimbill_ext */ public class ClaimbillSubmitOperation extends AbstractOperationServicePlugIn implements Plugin { + @Override + public void onAddValidators(AddValidatorsEventArgs e) { + //预付款退回时预付款金额大于0 + //员工还款时借款金额大于0 + super.onAddValidators(e); + e.addValidator(new AbstractValidator() { + @Override + public void validate() { + String operateKey = this.getOperateKey(); + if ("submit".equals(operateKey)) { + ExtendedDataEntity[] entities = this.getDataEntities(); + for (ExtendedDataEntity entity : entities) { + DynamicObject bill = entity.getDataEntity(); + DynamicObject recpaytype = null; + try{ + recpaytype = bill.getDynamicObject("recpaytype"); + }catch(Exception e){ + bill = BusinessDataServiceHelper.loadSingle(bill.getPkValue(), "cas_claimbill"); + recpaytype = bill.getDynamicObject("recpaytype"); + } + + DynamicObjectCollection entryentity = bill.getDynamicObjectCollection("entryentity"); + DynamicObject dynamicObject = null; + if (!entryentity.isEmpty()) { + dynamicObject = entryentity.get(0); + } + //预付款退回时预付款金额大于0 + if (null != recpaytype && "103".equals(recpaytype.getString("number")) && null != dynamicObject) { + BigDecimal shjh_paymentamount = dynamicObject.getBigDecimal("shjh_paymentamount"); + boolean isLessOrEqualZero = shjh_paymentamount != null && shjh_paymentamount.compareTo(BigDecimal.ZERO) <= 0; + if (isLessOrEqualZero) { + this.addErrorMessage(entity, "预付款退回时预付款金额需大于0"); + } + } + //员工还款时借款金额大于0 + if (null != recpaytype && "109".equals(recpaytype.getString("number")) && null != dynamicObject) { + BigDecimal shjh_loanamount = dynamicObject.getBigDecimal("shjh_loanamount"); + boolean isLessOrEqualZero = shjh_loanamount != null && shjh_loanamount.compareTo(BigDecimal.ZERO) <= 0; + if (isLessOrEqualZero) { + this.addErrorMessage(entity, "员工还款时借款金额需大于0"); + } + } + } + } + } + }); + } + @Override public void beforeExecuteOperationTransaction(BeforeOperationArgs e) { super.beforeExecuteOperationTransaction(e); diff --git a/main/java/shjh/jhzj7/fi/fi/plugin/operate/SchedulebillMergeOperation.java b/main/java/shjh/jhzj7/fi/fi/plugin/operate/SchedulebillMergeOperation.java index 803412a..698a94d 100644 --- a/main/java/shjh/jhzj7/fi/fi/plugin/operate/SchedulebillMergeOperation.java +++ b/main/java/shjh/jhzj7/fi/fi/plugin/operate/SchedulebillMergeOperation.java @@ -18,6 +18,7 @@ import kd.bos.servicehelper.operation.SaveServiceHelper; import kd.sdk.plugin.Plugin; import java.math.BigDecimal; +import java.text.SimpleDateFormat; import java.util.*; import java.util.concurrent.atomic.AtomicInteger; @@ -252,9 +253,11 @@ public class SchedulebillMergeOperation extends AbstractOperationServicePlugIn i } else if (o instanceof String) { String str = (String) o; rule.append(str); - } else if (o instanceof BigDecimal) { - BigDecimal bigDecimal = (BigDecimal) o; - rule.append(bigDecimal); + } else if (o instanceof Date) { + Date date = (Date) o; + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + String formattedDate = sdf.format(date); + rule.append(formattedDate); } else if (o instanceof Date) { long time = ((Date) o).getTime(); rule.append(time);