入库单关联付款申请单
This commit is contained in:
parent
983f92a0d3
commit
8b911d3a83
|
|
@ -0,0 +1,85 @@
|
|||
package zcgj.zcdev.zcdev.pr.plugin.operate;
|
||||
|
||||
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.PreparePropertysEventArgs;
|
||||
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.operation.SaveServiceHelper;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 入库单审核时反写付款申请单付款分录冲销金额
|
||||
*/
|
||||
public class MaterialinbillReversalamountOp extends AbstractOperationServicePlugIn {
|
||||
|
||||
private static final Log log = LogFactory.getLog(MaterialinbillReversalamountOp.class);
|
||||
|
||||
public void onPreparePropertys(PreparePropertysEventArgs e) {
|
||||
e.getFieldKeys().add("zcgj_prepayentry");
|
||||
e.getFieldKeys().add("zcgj_prepayentry.zcgj_sourceapplybillid");
|
||||
e.getFieldKeys().add("zcgj_prepayentry.zcgj_sourceapplyentryid");
|
||||
e.getFieldKeys().add("zcgj_prepayentry.zcgj_boltamount");
|
||||
|
||||
}
|
||||
@Override
|
||||
public void endOperationTransaction(EndOperationTransactionArgs e) {
|
||||
String operationKey = e.getOperationKey();
|
||||
DynamicObject[] dataEntities = e.getDataEntities();
|
||||
switch (operationKey) {
|
||||
case "audit"://审核
|
||||
log.info("执行OutFinaceconfirmReversalamountOp的提交操作,开始更新付款申请单付款信息分录冲销金额");
|
||||
updateInApplyReversaAmt(dataEntities, true);
|
||||
break;
|
||||
case "unaudit"://反审核
|
||||
log.info("执行OutFinaceconfirmReversalamountOp的撤销操作,开始更新付款申请单付款信息分录冲销金额");
|
||||
updateInApplyReversaAmt(dataEntities, false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
/*public void endOperationTransaction(EndOperationTransactionArgs e) {
|
||||
}*/
|
||||
|
||||
protected void updateInApplyReversaAmt(DynamicObject[] dataEntities, boolean isSubmit){
|
||||
List<DynamicObject> updateData = new ArrayList<>();
|
||||
for (DynamicObject dataEntity : dataEntities) {
|
||||
long id = dataEntity.getLong("id");
|
||||
DynamicObjectCollection prepayentryCollection = dataEntity.getDynamicObjectCollection("zcgj_prepayentry");//冲销预付分录
|
||||
for (DynamicObject prepay : prepayentryCollection) {
|
||||
long sourceapplybillid = prepay.getLong("zcgj_sourceapplybillid");
|
||||
long sourceapplyentryid = prepay.getLong("zcgj_sourceapplyentryid");
|
||||
BigDecimal boltamount = prepay.getBigDecimal("zcgj_boltamount");//支出财务确认单冲销金额
|
||||
DynamicObject paymentapply = BusinessDataServiceHelper.loadSingle(sourceapplybillid, "ec_paymentapply");//工程资金付款申请单
|
||||
if (paymentapply != null) {
|
||||
DynamicObjectCollection entryentityCollection = paymentapply.getDynamicObjectCollection("entryentity");
|
||||
for (DynamicObject dynamicObject : entryentityCollection) {
|
||||
BigDecimal thisrealpayamt = dynamicObject.getBigDecimal("thisrealpayamt");//付款申请单本次实付金额
|
||||
long pkValue = (long)dynamicObject.getPkValue();
|
||||
if(pkValue==sourceapplyentryid){
|
||||
BigDecimal zcgjYreversalamount = dynamicObject.getBigDecimal("zcgj_yreversalamount");
|
||||
if(!isSubmit){
|
||||
boltamount = boltamount.multiply(BigDecimal.ZERO.subtract(BigDecimal.ONE));//取相反数
|
||||
}
|
||||
zcgjYreversalamount = zcgjYreversalamount.add(boltamount);
|
||||
dynamicObject.set("zcgj_yreversalamount",zcgjYreversalamount);
|
||||
}
|
||||
}
|
||||
}
|
||||
updateData.add(paymentapply);
|
||||
}
|
||||
if(!updateData.isEmpty()){
|
||||
try (TXHandle txType = TX.requiresNew("updateAmt")) {
|
||||
SaveServiceHelper.save(updateData.toArray(new DynamicObject[0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
package zcgj.zcdev.zcdev.pr.plugin.other;
|
||||
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||
import kd.bos.entity.botp.plugin.AbstractConvertPlugIn;
|
||||
import kd.bos.entity.botp.plugin.args.AfterBuildDrawFilterEventArgs;
|
||||
import kd.bos.orm.query.QCP;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 入库单上拉付款申请单botp插件
|
||||
*/
|
||||
public class MaterialinbillGetPaymentapplyBotpPlugin extends AbstractConvertPlugIn {
|
||||
|
||||
@Override
|
||||
public void afterBuildDrawFilter(AfterBuildDrawFilterEventArgs e) {
|
||||
//选单过滤
|
||||
super.afterBuildDrawFilter(e);
|
||||
System.out.println("afterBuildDrawFilter——>");
|
||||
QFilter plugFilter = e.getPlugFilter();//插件追加的选单条件
|
||||
String sourceLayout = e.getSourceLayout();//获取插件设置的选单时打开的源单列表布局
|
||||
DynamicObject targetDataEntity = e.getTargetDataEntity();//当前数据包
|
||||
DynamicObjectCollection prepayentryCollection = targetDataEntity.getDynamicObjectCollection("zcgj_prepayentry");
|
||||
List<Long> ids = new ArrayList<>();
|
||||
for (DynamicObject dynamicObject : prepayentryCollection) {
|
||||
long aLong = dynamicObject.getLong("zcgj_sourceapplybillid");
|
||||
ids.add(aLong);
|
||||
}
|
||||
QFilter filter = new QFilter("id", QCP.not_in, ids);
|
||||
DynamicObject contract = targetDataEntity.getDynamicObject("contract");
|
||||
if(contract != null) {
|
||||
long contractId = contract.getLong("id");
|
||||
filter = filter.and(new QFilter("entryentity.contract", QCP.equals, contractId));
|
||||
}
|
||||
filter = filter.and(new QFilter("entryentity.paymenttype", QCP.equals, "PREPAYMENT"));
|
||||
e.setPlugFilter(filter);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue