定额备用金初始台账优化人员初始化借款单数据
This commit is contained in:
parent
c49cb583e9
commit
f98c7ac70a
|
|
@ -3,10 +3,17 @@ package zcgj.zcdev.zcdev.fs.plugin.form;
|
||||||
import kd.bos.bill.AbstractBillPlugIn;
|
import kd.bos.bill.AbstractBillPlugIn;
|
||||||
import kd.bos.dataentity.entity.DynamicObject;
|
import kd.bos.dataentity.entity.DynamicObject;
|
||||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||||
|
import kd.bos.dataentity.resource.ResManager;
|
||||||
|
import kd.bos.entity.datamodel.events.ChangeData;
|
||||||
|
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
|
||||||
|
import kd.bos.form.ConfirmCallBackListener;
|
||||||
|
import kd.bos.form.MessageBoxOptions;
|
||||||
|
import kd.bos.form.MessageBoxResult;
|
||||||
import kd.bos.form.ShowType;
|
import kd.bos.form.ShowType;
|
||||||
import kd.bos.form.control.EntryGrid;
|
import kd.bos.form.control.EntryGrid;
|
||||||
import kd.bos.form.events.HyperLinkClickEvent;
|
import kd.bos.form.events.HyperLinkClickEvent;
|
||||||
import kd.bos.form.events.HyperLinkClickListener;
|
import kd.bos.form.events.HyperLinkClickListener;
|
||||||
|
import kd.bos.form.events.MessageBoxClosedEvent;
|
||||||
import kd.bos.list.ListShowParameter;
|
import kd.bos.list.ListShowParameter;
|
||||||
import kd.bos.orm.query.QCP;
|
import kd.bos.orm.query.QCP;
|
||||||
import kd.bos.orm.query.QFilter;
|
import kd.bos.orm.query.QFilter;
|
||||||
|
|
@ -14,7 +21,10 @@ import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.ZoneId;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.EventObject;
|
import java.util.EventObject;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
@ -89,4 +99,68 @@ public class QuotaImprestLedgerBillPlugin extends AbstractBillPlugIn implements
|
||||||
this.getView().showForm(listShowParameter);
|
this.getView().showForm(listShowParameter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void propertyChanged(PropertyChangedArgs e) {
|
||||||
|
super.propertyChanged(e);
|
||||||
|
String name = e.getProperty().getName();
|
||||||
|
if (name.equals("zcgj_person")) {
|
||||||
|
//人员
|
||||||
|
ChangeData changeData = e.getChangeSet()[0];
|
||||||
|
int rowIndex = changeData.getRowIndex();
|
||||||
|
String zcgj_currentyear = (String) this.getModel().getValue("zcgj_currentyear");//年度
|
||||||
|
if (StringUtils.isEmpty(zcgj_currentyear)) {
|
||||||
|
this.getView().showErrorNotification("请先填写年度!");
|
||||||
|
this.getModel().setValue("zcgj_person", null, rowIndex);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
DynamicObject newValue = (DynamicObject) changeData.getNewValue();//人员新值
|
||||||
|
if (newValue != null) {
|
||||||
|
QFilter qFilters = new QFilter("applier.number", QCP.equals, newValue.get("number"));
|
||||||
|
qFilters.and(new QFilter("billstatus", QCP.not_in, new String[]{"A"}));//单据状态不为暂存
|
||||||
|
qFilters.and(new QFilter("zcgj_impresttype", QCP.equals, "0"));//备用金类型为定额备用金
|
||||||
|
DynamicObject[] er_dailyLoanBills = BusinessDataServiceHelper.load("er_dailyloanbill",
|
||||||
|
"id,bizdate,loanamount,returnedamount,usedamount", new QFilter[]{qFilters});//借款单
|
||||||
|
List<Object> matchingIds = new ArrayList<>();
|
||||||
|
for (DynamicObject er_dailyLoanBill : er_dailyLoanBills) {
|
||||||
|
Date bizDate = er_dailyLoanBill.getDate("bizdate");//申请日期
|
||||||
|
LocalDate localDate = bizDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
|
||||||
|
String bizDateYear = String.valueOf(localDate.getYear());//申请日期年份
|
||||||
|
BigDecimal loanAmount = er_dailyLoanBill.getBigDecimal("loanamount");//借款金额
|
||||||
|
BigDecimal returnedAmount = er_dailyLoanBill.getBigDecimal("returnedamount");//还款金额
|
||||||
|
BigDecimal usedAmount = er_dailyLoanBill.getBigDecimal("usedamount");//已报销金额
|
||||||
|
BigDecimal remainingAmount = loanAmount.subtract(returnedAmount.add(usedAmount));//剩余待还金额
|
||||||
|
if (StringUtils.equals(bizDateYear, zcgj_currentyear) && remainingAmount.compareTo(BigDecimal.ZERO) > 0) {
|
||||||
|
//年份相同且剩余待还金额大于0
|
||||||
|
matchingIds.add(er_dailyLoanBill.getPkValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!matchingIds.isEmpty()) {
|
||||||
|
Object[] baseDataIds = matchingIds.toArray();
|
||||||
|
this.getModel().setValue("zcgj_dailyloanbilldatas", baseDataIds, rowIndex);//借款单
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.getModel().setValue("zcgj_dailyloanbilldatas", null, rowIndex);//清空借款单
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (name.equals("zcgj_currentyear")) {
|
||||||
|
//年度
|
||||||
|
DynamicObjectCollection entryEntityCollection = this.getModel().getDataEntity(true).getDynamicObjectCollection("zcgj_entryentity");
|
||||||
|
if (entryEntityCollection.size() > 0) {
|
||||||
|
this.getView().showConfirm(ResManager.loadKDString("更换年份后分录信息将会被清空!是否继续", "AimCostBoqEditPlugin_36", "ec-ecco-formplugin", new Object[0]), MessageBoxOptions.OKCancel, new ConfirmCallBackListener("zcgj_currentyear", this));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void confirmCallBack(MessageBoxClosedEvent messageBoxClosedEvent) {
|
||||||
|
super.confirmCallBack(messageBoxClosedEvent);
|
||||||
|
//判断是否是对应确认框的点击回调事件
|
||||||
|
if (("zcgj_currentyear").equals(messageBoxClosedEvent.getCallBackId())) {
|
||||||
|
if (MessageBoxResult.Yes.equals(messageBoxClosedEvent.getResult())) {
|
||||||
|
this.getModel().getDataEntity(true).getDynamicObjectCollection("zcgj_entryentity").clear();
|
||||||
|
this.getView().updateView("zcgj_entryentity");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue