parent
0d894af3da
commit
4ed0a524fa
|
@ -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});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue