2024-11-07 09:31:20 +00:00
|
|
|
package shkd.repc.recon.opplugin;
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import kd.bos.entity.api.ApiResult;
|
|
|
|
import kd.bos.entity.plugin.ImportLogger;
|
|
|
|
import kd.bos.form.plugin.impt.BatchImportPlugin;
|
|
|
|
import kd.bos.form.plugin.impt.ImportBillData;
|
2024-11-09 02:35:26 +00:00
|
|
|
import kd.bos.util.StringUtils;
|
2024-11-07 09:31:20 +00:00
|
|
|
|
2024-11-09 02:35:26 +00:00
|
|
|
import java.math.BigDecimal;
|
2024-11-07 09:31:20 +00:00
|
|
|
import java.util.Iterator;
|
|
|
|
import java.util.List;
|
|
|
|
|
2024-11-09 02:35:26 +00:00
|
|
|
/**
|
|
|
|
* 合同清单导入功能(校验)
|
|
|
|
*/
|
2024-11-07 09:31:20 +00:00
|
|
|
public class IntroduceContractPlugin extends BatchImportPlugin {
|
|
|
|
@Override
|
|
|
|
protected ApiResult save(List<ImportBillData> rowdatas, ImportLogger logger) {
|
|
|
|
Iterator<ImportBillData> iterator = rowdatas.iterator();
|
|
|
|
while (iterator.hasNext()){
|
|
|
|
ImportBillData importBillData = iterator.next();
|
|
|
|
JSONObject data = importBillData.getData();
|
|
|
|
String qeug_decimalqty = (String) data.get("qeug_decimalqty");//工程量
|
2024-11-15 12:11:12 +00:00
|
|
|
String qeug_preofpro = (String) data.get("qeug_preofpro");//当前进度百分比
|
|
|
|
String qeug_cumulativepreofpro = (String) data.get("qeug_cumulativepreofpro");//累计进度百分比
|
2024-11-12 04:09:33 +00:00
|
|
|
BigDecimal decimalqty =null;
|
|
|
|
BigDecimal preofpro =null;
|
2024-11-09 02:35:26 +00:00
|
|
|
if (qeug_decimalqty != null && qeug_preofpro!= null) {
|
|
|
|
//校验 工程量&进度百分比 数据格式是否正确
|
|
|
|
try {
|
2024-11-12 04:09:33 +00:00
|
|
|
decimalqty = new BigDecimal(qeug_decimalqty);
|
|
|
|
preofpro = new BigDecimal(qeug_preofpro);
|
2024-11-09 02:35:26 +00:00
|
|
|
} catch (NumberFormatException e) {
|
|
|
|
logger.log(importBillData.getStartIndex(),"工程量数据格式有误").fail();
|
|
|
|
iterator.remove();
|
|
|
|
}
|
2024-11-15 12:11:12 +00:00
|
|
|
// 本次完工量 = 工程量 * (当前进度百分比-累计完成百分比)
|
2024-11-09 02:35:26 +00:00
|
|
|
BigDecimal bd1 = new BigDecimal(qeug_decimalqty);
|
|
|
|
BigDecimal bd2 = new BigDecimal(qeug_preofpro);
|
2024-11-15 12:11:12 +00:00
|
|
|
BigDecimal bd3;
|
|
|
|
if (StringUtils.isEmpty(qeug_cumulativepreofpro)) {
|
|
|
|
bd3 = BigDecimal.ZERO; // 如果 qeug_cumulativepreofpro 为空,则赋值为 0
|
|
|
|
} else {
|
|
|
|
bd3 = new BigDecimal(qeug_cumulativepreofpro);
|
|
|
|
}
|
|
|
|
BigDecimal bd4 = bd2.subtract(bd3);
|
2024-11-16 09:23:49 +00:00
|
|
|
data.put("qeug_thisprogress",bd4);//本次进度百分比(%)
|
2024-11-15 12:11:12 +00:00
|
|
|
BigDecimal result = bd1.multiply(bd4).multiply(BigDecimal.valueOf(0.01));
|
2024-11-16 09:23:49 +00:00
|
|
|
data.put("qeug_bcdecimalqtys",result);//本次完工量
|
2024-11-09 02:35:26 +00:00
|
|
|
if (StringUtils.isNotEmpty(qeug_preofpro)) {
|
2024-11-12 04:09:33 +00:00
|
|
|
preofpro = new BigDecimal(qeug_preofpro);
|
2024-11-09 02:35:26 +00:00
|
|
|
}
|
2024-11-12 04:09:33 +00:00
|
|
|
if (preofpro != null && preofpro.compareTo(BigDecimal.valueOf(100)) > 0) {
|
|
|
|
|
|
|
|
logger.log(importBillData.getStartIndex(), "进度百分比不能大于100").fail();
|
2024-11-09 02:35:26 +00:00
|
|
|
iterator.remove();
|
|
|
|
}
|
2024-11-15 12:11:12 +00:00
|
|
|
if (bd3.compareTo(bd2) > 0) {
|
|
|
|
logger.log(importBillData.getStartIndex(), "当前进度百分比不能小于累计完成百分比").fail();
|
|
|
|
iterator.remove();
|
|
|
|
}
|
|
|
|
data.put("qeug_cumulativepreofpro",bd2);
|
2024-11-07 09:31:20 +00:00
|
|
|
}
|
2024-11-09 02:35:26 +00:00
|
|
|
|
2024-11-07 09:31:20 +00:00
|
|
|
}
|
|
|
|
return super.save(rowdatas, logger);
|
|
|
|
}
|
|
|
|
}
|