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_bcdecimalqty = (String) data.get("qeug_bcdecimalqty");//本次完工量
|
|
|
|
String qeug_decimalqty = (String) data.get("qeug_decimalqty");//工程量
|
2024-11-09 02:35:26 +00:00
|
|
|
String qeug_preofpro = (String) data.get("qeug_preofpro");//进度百分比
|
2024-11-07 09:31:20 +00:00
|
|
|
double bcdecimalqty = 0;
|
|
|
|
double decimalqty =0;
|
2024-11-09 02:35:26 +00:00
|
|
|
double preofpro =0;
|
|
|
|
if (qeug_decimalqty != null && qeug_preofpro!= null) {
|
|
|
|
//校验 工程量&进度百分比 数据格式是否正确
|
|
|
|
try {
|
|
|
|
decimalqty = Double.parseDouble(qeug_decimalqty);
|
|
|
|
preofpro = Double.parseDouble(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);
|
|
|
|
result = result.setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
data.put("qeug_bcdecimalqty",result);
|
|
|
|
if (StringUtils.isNotEmpty(qeug_preofpro)) {
|
|
|
|
preofpro = Double.parseDouble(qeug_preofpro);
|
|
|
|
}
|
|
|
|
if (preofpro>1){
|
|
|
|
logger.log(importBillData.getStartIndex(),"进度百分比不能大于1").fail();
|
|
|
|
iterator.remove();
|
|
|
|
}
|
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);
|
|
|
|
}
|
|
|
|
}
|