60 lines
2.6 KiB
Java
60 lines
2.6 KiB
Java
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;
|
|
import kd.bos.util.StringUtils;
|
|
|
|
import java.math.BigDecimal;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
|
|
/**
|
|
* 合同清单导入功能(校验)
|
|
*/
|
|
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_bcdecimalqtys = (String) data.get("qeug_bcdecimalqtys");//本次完工量
|
|
String qeug_decimalqty = (String) data.get("qeug_decimalqty");//工程量
|
|
String qeug_preofpro = (String) data.get("qeug_preofpro");//进度百分比
|
|
String qeug_workloadcfmid = (String) data.get("qeug_workloadcfmid");//产值确认id
|
|
BigDecimal bcdecimalqty = null;
|
|
BigDecimal decimalqty =null;
|
|
BigDecimal preofpro =null;
|
|
if (qeug_decimalqty != null && qeug_preofpro!= null) {
|
|
//校验 工程量&进度百分比 数据格式是否正确
|
|
try {
|
|
decimalqty = new BigDecimal(qeug_decimalqty);
|
|
preofpro = new BigDecimal(qeug_preofpro);
|
|
} catch (NumberFormatException e) {
|
|
logger.log(importBillData.getStartIndex(),"工程量数据格式有误").fail();
|
|
iterator.remove();
|
|
}
|
|
// 本次完工量 = 工程量 * 进度百分比
|
|
BigDecimal bd1 = new BigDecimal(qeug_decimalqty);
|
|
BigDecimal bd2 = new BigDecimal(qeug_preofpro);
|
|
BigDecimal result = bd1.multiply(bd2).multiply(BigDecimal.valueOf(0.01));
|
|
// result = result.setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
data.put("qeug_bcdecimalqtys",result);
|
|
if (StringUtils.isNotEmpty(qeug_preofpro)) {
|
|
preofpro = new BigDecimal(qeug_preofpro);
|
|
}
|
|
if (preofpro != null && preofpro.compareTo(BigDecimal.valueOf(100)) > 0) {
|
|
|
|
logger.log(importBillData.getStartIndex(), "进度百分比不能大于100").fail();
|
|
iterator.remove();
|
|
}
|
|
}
|
|
|
|
}
|
|
return super.save(rowdatas, logger);
|
|
}
|
|
}
|