dobe_comic8/main/java/shkd/repc/recon/opplugin/WorkloadcfSubmitOPPlugin.java

36 lines
1.7 KiB
Java

package shkd.repc.recon.opplugin;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
import kd.bos.entity.plugin.args.AfterOperationArgs;
import kd.bos.servicehelper.operation.SaveServiceHelper;
import java.math.BigDecimal;
import java.math.RoundingMode;
public class WorkloadcfSubmitOPPlugin extends AbstractOperationServicePlugIn {
@Override
public void afterExecuteOperationTransaction(AfterOperationArgs e) {
super.afterExecuteOperationTransaction(e);
String operationKey = e.getOperationKey();
if ("submit".equals(operationKey)){
DynamicObject[] dataEntities = e.getDataEntities();
DynamicObject dataEntity = dataEntities[0];
BigDecimal latestoriprice = dataEntity.getBigDecimal("latestoriprice"); // 合同最新造价
BigDecimal sumworkloadamt = dataEntity.getBigDecimal("sumworkloadamt"); // 累计已完成产值(含税)
BigDecimal result = BigDecimal.ZERO; // 初始化结果
if (latestoriprice != null && latestoriprice.compareTo(BigDecimal.ZERO) != 0) { // 确保价格不为0且不为null
if (sumworkloadamt != null && sumworkloadamt.compareTo(BigDecimal.ZERO) != 0) { // 确保累计已完成产值不为0且不为null
// 计算: (sumworkloadamt / latestoriprice) * 100
result = sumworkloadamt.divide(latestoriprice, 2, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); // 四舍五入到10位小数, 乘以100
}
}
dataEntity.set("qeug_czzb", result); // 累计已完成产值占比
SaveServiceHelper.save(new DynamicObject[]{dataEntity});
}
}
}