收入合同结算单实际结算甲方插件

This commit is contained in:
zhangzhiguo 2025-02-27 13:59:38 +08:00
parent 04bd9e8a08
commit ec18a7a57b
1 changed files with 118 additions and 0 deletions

View File

@ -0,0 +1,118 @@
package zcgj.zcdev.zcdev.pr.plugin.form;
import kd.bos.db.DB;
import kd.bos.db.DBRoute;
import kd.bos.entity.EntityMetadataCache;
import kd.bos.entity.MainEntityType;
import kd.bos.ext.fi.ai.AbstractDapWriteBackImpl;
import kd.bos.ext.fi.ai.Voucher;
import kd.bos.ext.fi.ai.VoucherOperation;
import kd.bos.logging.Log;
import kd.bos.logging.LogFactory;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* 指出合同结算凭证反写插件
*/
public class EcContartVoucherPlugin extends AbstractDapWriteBackImpl {
public static final Log log = LogFactory.getLog(EcContartVoucherPlugin.class);
//采购申请单上要反写的凭证号字段名
public static final String voucherNoFile="fk_zcgj_voucherbillno";
@Override
protected DBRoute getDBRoute() {
// 扩展开发库的分库标识实际值可以查看mc分库标识
DBRoute DBR = DBRoute.of("scm");
return DBR;
}
// 删除凭证写入的值这里是复选框- 布尔false
@Override
protected Object getVchDisableStatus() {
Boolean disRchValue = false;
return disRchValue;
}
// 生成凭证时写入的值这里是复选框- 布尔 true
@Override
protected Object getVchEnableStatus() {
Boolean rchValue = true;
return rchValue;
}
// 要反写的字段,反写的是常量值反写凭证的一些其他信息回单据只能重写writeBack方法
@Override
protected String getVchStatusField() {
String vchField = "fisvoucher";
return vchField;
}
@Override
public void writeBack(VoucherOperation operation, String billEntityNumber, Map<Long, Voucher> billToVch) {
MainEntityType mt = EntityMetadataCache.getDataEntityType(billEntityNumber);
Set<Long> keySet = billToVch.keySet();
log.info("AbstractDapWriteBackImpl#keySet:" + keySet);
if (VoucherOperation.Create.equals(operation)) {
log.info("AbstractDapWriteBackImpl#开始执行生成凭证反写:" + operation);
Object vchStatusField = getVchEnableStatus();
List<Object[]> params = new ArrayList<>();
for (Long me : keySet) {
log.info("AbstractDapWriteBackImpl#生成凭证的单据ID" + me);
Voucher voucher=billToVch.get(me);//凭证
String voucherNo = voucher.getVoucherNo();
//这里处理的是一个单据只有一个凭证的时候如果是多个凭证可以先获取已经生成的凭证号再拼接上字符串
Object[] param = new Object[] { vchStatusField,voucherNo, me };//
params.add(param);
if (params.size() >= 10000) {
log.info("AbstractDapWriteBackImpl#开始执行生成凭证反写SQL");
log.info("AbstractDapWriteBackImpl#mt.getAlias()" + mt.getAlias());
log.info("AbstractDapWriteBackImpl#mt.getVchStatusField()" + getVchStatusField());
DB.executeBatch(getDBRoute(),
"update " + mt.getAlias() + " set " + getVchStatusField() + " = ? , "+voucherNoFile+" = ? where fid = ?", params);
log.info("AbstractDapWriteBackImpl#结束执行生成凭证反写SQL");
params.clear();
}
}
log.info("AbstractDapWriteBackImpl#最后#开始执行生成凭证反写SQL");
log.info("AbstractDapWriteBackImpl#最后#mt.getAlias()" + mt.getAlias());
log.info("AbstractDapWriteBackImpl#最后#mt.getVchStatusField()" + getVchStatusField());
if (params.size() > 0) {
DB.executeBatch(getDBRoute(),
"update " + mt.getAlias() + " set " + getVchStatusField() + " = ? , "+voucherNoFile+" = ? where fid = ?", params);
}
log.info("AbstractDapWriteBackImpl#最后#结束执行生成凭证反写SQL");
} else if (VoucherOperation.Delete.equals(operation)) {
log.info("AbstractDapWriteBackImpl#开始执行删除凭证反写:" + operation);
Object vchDisableStatus = getVchDisableStatus();
List<Object[]> params = new ArrayList<>();
for (Long me : keySet) {
log.info("AbstractDapWriteBackImpl#删除凭证的单据ID" + me);
//这里处理的是一个单据只有一个凭证的时候如果是多个凭证可以先获取已经生成的凭证号再去掉本凭证之后的凭证号
Object[] param = new Object[] {vchDisableStatus, "",me };// getVchDisableStatus
params.add(param);
if (params.size() >= 10000) {
log.info("AbstractDapWriteBackImpl#开始执行删除凭证反写SQL");
log.info("AbstractDapWriteBackImpl#mt.getAlias()" + mt.getAlias());
log.info("AbstractDapWriteBackImpl#mt.getVchStatusField()" + getVchStatusField());
DB.executeBatch(getDBRoute(),
"update " + mt.getAlias() + " set " + getVchStatusField() + " = ? , "+voucherNoFile+" = ? where fid = ?", params);
params.clear();
log.info("AbstractDapWriteBackImpl#结束执行删除凭证反写SQL");
}
}
log.info("AbstractDapWriteBackImpl#最后#开始执行删除凭证反写SQL");
log.info("AbstractDapWriteBackImpl#最后#mt.getAlias()" + mt.getAlias());
log.info("AbstractDapWriteBackImpl#最后#mt.getVchStatusField()" + getVchStatusField());
if (params.size() > 0) {
DB.executeBatch(getDBRoute(),
"update " + mt.getAlias() + " set " + getVchStatusField() + " = ? , "+voucherNoFile+" = ? where fid = ?", params);
}
log.info("AbstractDapWriteBackImpl#最后#结束执行删除凭证反写SQL");
}
}
}