员工借款单提交操作插件:校验借款金额不可超过部门可用借款额度
This commit is contained in:
parent
f2dd45b9fb
commit
b425cea10c
|
@ -0,0 +1,76 @@
|
||||||
|
package shkd.fi.er.plugin.opplugin;
|
||||||
|
|
||||||
|
import kd.bos.dataentity.entity.DynamicObject;
|
||||||
|
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.form.control.Label;
|
||||||
|
import kd.bos.orm.query.QCP;
|
||||||
|
import kd.bos.orm.query.QFilter;
|
||||||
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||||
|
import kd.sdk.plugin.Plugin;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单据操作插件
|
||||||
|
* 员工借款单提交校验部门可用借款
|
||||||
|
*/
|
||||||
|
public class DailyLoanBillSubmitOrgAmountAvailableCheckPlugin extends AbstractOperationServicePlugIn implements Plugin {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 加载所有字段
|
||||||
|
* @param e
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void onPreparePropertys(PreparePropertysEventArgs e) {
|
||||||
|
super.onPreparePropertys(e);
|
||||||
|
List<String> fieldKeys = e.getFieldKeys();
|
||||||
|
fieldKeys.addAll(this.billEntityType.getAllFields().keySet());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAddValidators(AddValidatorsEventArgs e) {
|
||||||
|
super.onAddValidators(e);
|
||||||
|
e.addValidator(
|
||||||
|
new AbstractValidator(){
|
||||||
|
@Override
|
||||||
|
public void validate() {
|
||||||
|
String operateKey = this.getOperateKey();
|
||||||
|
ExtendedDataEntity[] dataEntities = this.getDataEntities();
|
||||||
|
for (ExtendedDataEntity extendedDataEntity : dataEntities) {
|
||||||
|
DynamicObject dynamicObject = extendedDataEntity.getDataEntity();//获取单据对象
|
||||||
|
BigDecimal loanAmount = dynamicObject.getBigDecimal("loanamount");
|
||||||
|
|
||||||
|
//1、、计算借款可用额度
|
||||||
|
BigDecimal bigDecimal = new BigDecimal(0);
|
||||||
|
//查询审批未放款的当前部门的数据(已提交、审核中、审核通过、等待放款)
|
||||||
|
QFilter qf = new QFilter("billstatus", QCP.in, new String[]{"B", "C", "E", "F"});
|
||||||
|
DynamicObject[] bills = BusinessDataServiceHelper.load("er_dailyloanbill", "id.number,loanamount,balanceamount", qf.toArray());
|
||||||
|
for (DynamicObject bill : bills) {
|
||||||
|
BigDecimal loanamount = bill.getBigDecimal("loanamount");//获取借款金额
|
||||||
|
bigDecimal = bigDecimal.add(loanamount);
|
||||||
|
}
|
||||||
|
//查询审批已放款的当前部门的数据(已付款)
|
||||||
|
QFilter aqf = new QFilter("billstatus", QCP.in, new String[]{"G"});
|
||||||
|
DynamicObject[] abills = BusinessDataServiceHelper.load("er_dailyloanbill", "id.number,loanamount,balanceamount", aqf.toArray());
|
||||||
|
for (DynamicObject abill : abills) {
|
||||||
|
BigDecimal balanceamount = abill.getBigDecimal("balanceamount");//获取待还款金额
|
||||||
|
bigDecimal = bigDecimal.add(balanceamount);
|
||||||
|
}
|
||||||
|
// 计算可借款金额
|
||||||
|
BigDecimal bigDecimal1 = new BigDecimal(300000);
|
||||||
|
BigDecimal subtract = bigDecimal1.subtract(bigDecimal);
|
||||||
|
if(subtract.compareTo(loanAmount) < 0 ){
|
||||||
|
this.addMessage(extendedDataEntity, "部门借款可用额度不足,不允许提交");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue