付款处理反写资金计划申请实付金额功能
This commit is contained in:
parent
a2588e7d6a
commit
9a2527d6f8
|
@ -0,0 +1,115 @@
|
||||||
|
package zcgj.zcdev.zcdev.fs.plugin.operate;
|
||||||
|
|
||||||
|
import com.grapecity.documents.excel.B;
|
||||||
|
import kd.bos.dataentity.entity.DynamicObject;
|
||||||
|
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||||
|
import kd.bos.db.tx.TX;
|
||||||
|
import kd.bos.db.tx.TXHandle;
|
||||||
|
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
||||||
|
import kd.bos.entity.plugin.args.AfterOperationArgs;
|
||||||
|
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.botp.BFTrackerServiceHelper;
|
||||||
|
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
||||||
|
import kd.bos.util.StringUtils;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 付款处理单反写资金计划申请实际付款
|
||||||
|
*/
|
||||||
|
public class CasPaybillToEcFundPlanApplyOp extends AbstractOperationServicePlugIn {
|
||||||
|
|
||||||
|
private static final Log log = LogFactory.getLog(CasPaybillToEcFundPlanApplyOp.class);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void endOperationTransaction(EndOperationTransactionArgs e) {
|
||||||
|
String operationKey = e.getOperationKey();
|
||||||
|
DynamicObject[] dataEntities = e.getDataEntities();
|
||||||
|
switch (operationKey) {
|
||||||
|
case "pay"://付款
|
||||||
|
log.info("执行CasPaybillToEcFundPlanApplyOp的付款操作,开始更资金计划申请,付款类型实付金额");
|
||||||
|
updateInApplyRealPayAmt(dataEntities, true);
|
||||||
|
break;
|
||||||
|
case "unpay"://取消付款
|
||||||
|
log.info("执行CasPaybillToEcFundPlanApplyOp的取消付款操作,开始更资金计划申请,付款类型实付金额");
|
||||||
|
updateInApplyRealPayAmt(dataEntities, false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*public void endOperationTransaction(EndOperationTransactionArgs e) {
|
||||||
|
}*/
|
||||||
|
|
||||||
|
protected void updateInApplyRealPayAmt(DynamicObject[] dataEntities, boolean isPay){
|
||||||
|
List<DynamicObject> updateData = new ArrayList<>();
|
||||||
|
for (DynamicObject dataEntity : dataEntities) {
|
||||||
|
long id = dataEntity.getLong("id");
|
||||||
|
// idList.add(id);
|
||||||
|
Map<String, HashSet<Long>> sourceBills = BFTrackerServiceHelper.findSourceBills("cas_paybill", new Long[]{id});
|
||||||
|
HashSet<Long> zcgjEcFundingplanapply = sourceBills.get("zcgj_ec_fundingplanapply");
|
||||||
|
if(zcgjEcFundingplanapply != null && !zcgjEcFundingplanapply.isEmpty()) {
|
||||||
|
Long dataId = (Long)zcgjEcFundingplanapply.toArray()[0];
|
||||||
|
|
||||||
|
//计算实际付款金额
|
||||||
|
DynamicObject paybill = BusinessDataServiceHelper.loadSingle(id, "cas_paybill");
|
||||||
|
DynamicObject settletype = paybill.getDynamicObject("settletype");
|
||||||
|
String typeString = "";
|
||||||
|
if(settletype!=null){
|
||||||
|
String type = settletype.getString("number");
|
||||||
|
if("002".equals(type)){ //司库-对公
|
||||||
|
//现金
|
||||||
|
typeString = "XJ";
|
||||||
|
}else if("JSFS07".equals(type)){ //银行承兑汇票
|
||||||
|
//银行承兑
|
||||||
|
typeString = "YHCD";
|
||||||
|
}else if("JSFS06".equals(type)){ //商业承兑汇票
|
||||||
|
//商业承兑
|
||||||
|
typeString = "SYCD";
|
||||||
|
}else if("JSFS26".equals(type)){ //供应链
|
||||||
|
//供应链
|
||||||
|
typeString = "GYL";
|
||||||
|
}else if("JSFS27".equals(type)){ //其他金融产品
|
||||||
|
//其他金融产品
|
||||||
|
typeString = "QTJRCP";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DynamicObjectCollection entryCpllection = paybill.getDynamicObjectCollection("entry");
|
||||||
|
BigDecimal allActamt = BigDecimal.ZERO;
|
||||||
|
for (DynamicObject entry : entryCpllection) {
|
||||||
|
BigDecimal eActamt = entry.getBigDecimal("e_actamt");//获取实付金额
|
||||||
|
allActamt = allActamt.add(eActamt);
|
||||||
|
}
|
||||||
|
|
||||||
|
//读取资金计划申请
|
||||||
|
DynamicObject fundingplanapply = BusinessDataServiceHelper.loadSingle(dataId, "zcgj_ec_fundingplanapply");
|
||||||
|
DynamicObjectCollection zcgjFinApprovedAmount = fundingplanapply.getDynamicObjectCollection("zcgj_fin_approved_amount");
|
||||||
|
for (DynamicObject dynamicObject : zcgjFinApprovedAmount) {
|
||||||
|
String zcgjSetttype = dynamicObject.getString("zcgj_setttype");
|
||||||
|
if(typeString.equals(zcgjSetttype)){
|
||||||
|
BigDecimal zcgjAmountRecommended = dynamicObject.getBigDecimal("zcgj_amountpaid");//实际付款金额
|
||||||
|
BigDecimal amountrecommended = BigDecimal.ZERO;
|
||||||
|
if(!isPay){
|
||||||
|
amountrecommended = allActamt;
|
||||||
|
allActamt = allActamt.multiply(BigDecimal.ZERO.subtract(BigDecimal.ONE));//取相反数
|
||||||
|
}
|
||||||
|
allActamt = allActamt.add(zcgjAmountRecommended);
|
||||||
|
dynamicObject.set("zcgj_amountpaid", allActamt);//实付金额
|
||||||
|
dynamicObject.set("zcgj_amount_inpayment",amountrecommended);//
|
||||||
|
}
|
||||||
|
}
|
||||||
|
updateData.add(fundingplanapply);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!updateData.isEmpty()){
|
||||||
|
try (TXHandle txType = TX.requiresNew("updateAmt")) {
|
||||||
|
SaveServiceHelper.save(updateData.toArray(new DynamicObject[0]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue