1.合同结算审核时,将结算日期按照合同保证金年限计算合同最终付款日期反写合同

S
This commit is contained in:
weiyunlong 2024-12-19 14:56:38 +08:00
parent 0d894af3da
commit 4ed0a524fa
1 changed files with 64 additions and 0 deletions

View File

@ -0,0 +1,64 @@
package shkd.repc.recon.opplugin;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
import kd.bos.entity.plugin.args.AfterOperationArgs;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Date;
/**
* 合同结算审核
*/
public class ConsettlebillAuditOPPlugin extends AbstractOperationServicePlugIn {
@Override
public void afterExecuteOperationTransaction(AfterOperationArgs e) {
super.afterExecuteOperationTransaction(e);
//合同结算审核时,将结算日期按照合同保证金年限计算合同最终付款日期反写合同
DynamicObject[] dataEntities = e.getDataEntities();
DynamicObject dataEntity = dataEntities[0];//合同结算
Date bizdate = dataEntity.getDate("bizdate");//结算日期
DynamicObject contractbill = dataEntity.getDynamicObject("contractbill");//合同f7
if (null != contractbill) {
DynamicObject contractbills = BusinessDataServiceHelper.loadSingle(contractbill.getPkValue(), "recon_contractbill");
if (null != contractbills) {
//保证金明细
DynamicObjectCollection qeug_bondentrys = contractbills.getDynamicObjectCollection("qeug_bondentry");
for (DynamicObject qeugBondentry : qeug_bondentrys) {
String qeugYear = qeugBondentry.getString("qeug_year");//年限
switch (qeugYear){
case "A":
//1年
if (null !=bizdate) {
// Date 转换为 LocalDate
LocalDate localBizDate = bizdate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
// 加上一年
LocalDate newBizDate = localBizDate.plusYears(1);
//转换回 Date 类型
Date updatedBizDate = Date.from(newBizDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
qeugBondentry.set("qeug_finalpaymentdate",updatedBizDate);//最终付款日期
}
break;
case "B":
//半年
if (null !=bizdate) {
LocalDate localBizDate = bizdate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
// 加上六个月
LocalDate newBizDate = localBizDate.plusMonths(6);
Date updatedBizDate = Date.from(newBizDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
qeugBondentry.set("qeug_finalpaymentdate",updatedBizDate);//最终付款日期
}
default:
break;
}
}
SaveServiceHelper.save(new DynamicObject[]{contractbills});
}
}
}
}