parent
7b551b4920
commit
6e18060411
|
@ -41,6 +41,9 @@ import org.apache.poi.ss.usermodel.Row;
|
|||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
|
||||
import javax.script.ScriptEngine;
|
||||
import javax.script.ScriptEngineManager;
|
||||
import javax.script.ScriptException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.math.BigDecimal;
|
||||
|
@ -289,7 +292,7 @@ public class ContractFormPlugin extends AbstractFormPlugin implements UploadLis
|
|||
* 获取数据首行根据每个sheet页第一列属不属于数字判断
|
||||
* 第一列不属于数字的行跳过
|
||||
*/
|
||||
|
||||
ArrayList<DynamicObject> dynamicObjects = new ArrayList<>();
|
||||
Map<String, BigDecimal> amounttotalMap = new HashMap<>();
|
||||
for (Sheet sheet : workbook) {
|
||||
int rowNum = 0;
|
||||
|
@ -307,7 +310,7 @@ public class ContractFormPlugin extends AbstractFormPlugin implements UploadLis
|
|||
}
|
||||
}
|
||||
BigDecimal amounttotal =BigDecimal.ZERO;
|
||||
for (int j = rowNum; j <= rowCountsheet - 1; j++) {
|
||||
for (int j = rowNum; j <= rowCountsheet - 2; j++) {
|
||||
Row row = sheet.getRow(j);
|
||||
//第一列断号
|
||||
String seq = row.getCell(0).toString();
|
||||
|
@ -354,42 +357,66 @@ public class ContractFormPlugin extends AbstractFormPlugin implements UploadLis
|
|||
break;
|
||||
case 6:
|
||||
if (StringUtils.isNotEmpty(cell.toString())) {
|
||||
contractsummarylist.set("qeug_decimalqty",BigDecimal.valueOf(Double.parseDouble(cell.toString())));//工程量
|
||||
String expression = cell.toString();
|
||||
ScriptEngine engine = new ScriptEngineManager().getEngineByName("JavaScript");
|
||||
try {
|
||||
BigDecimal results =BigDecimal.valueOf(Double.parseDouble(engine.eval(expression).toString()));
|
||||
contractsummarylist.set("qeug_decimalqty", results);
|
||||
} catch (ScriptException e) {
|
||||
e.printStackTrace();
|
||||
// 处理计算失败的情况
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 7:
|
||||
if (StringUtils.isNotEmpty(cell.toString())) {
|
||||
contractsummarylist.set("qeug_unitprice",BigDecimal.valueOf(Double.parseDouble(cell.toString())));//综合单价
|
||||
String expression = cell.toString();
|
||||
ScriptEngine engine = new ScriptEngineManager().getEngineByName("JavaScript");
|
||||
try {
|
||||
BigDecimal results =BigDecimal.valueOf(Double.parseDouble(engine.eval(expression).toString()));
|
||||
contractsummarylist.set("qeug_unitprice",results);//综合单价
|
||||
} catch (ScriptException e) {
|
||||
e.printStackTrace();
|
||||
// 处理计算失败的情况
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
if (StringUtils.isNotEmpty(cell.toString())) {
|
||||
String expression = cell.toString();
|
||||
ScriptEngine engine = new ScriptEngineManager().getEngineByName("JavaScript");
|
||||
BigDecimal results = BigDecimal.ZERO;
|
||||
try {
|
||||
results =BigDecimal.valueOf(Double.parseDouble(engine.eval(expression).toString()));
|
||||
contractsummarylist.set("qeug_amounttotal",results);//综合单价
|
||||
} catch (ScriptException e) {
|
||||
e.printStackTrace();
|
||||
// 处理计算失败的情况
|
||||
}
|
||||
amounttotal = amounttotal.add(results);
|
||||
}
|
||||
break;
|
||||
case 9:
|
||||
if (StringUtils.isNotEmpty(cell.toString())) {
|
||||
BigDecimal bigDecimal = BigDecimal.valueOf(Double.parseDouble(cell.toString()));
|
||||
contractsummarylist.set("qeug_amounttotal",bigDecimal);//合计
|
||||
amounttotal = amounttotal.add(bigDecimal);
|
||||
contractsummarylist.set("qeug_artificial",BigDecimal.valueOf(Double.parseDouble(cell.toString())));//人工单价
|
||||
}
|
||||
break;
|
||||
case 10:
|
||||
if (StringUtils.isNotEmpty(cell.toString())) {
|
||||
contractsummarylist.set("qeug_artificial",BigDecimal.valueOf(Double.parseDouble(cell.toString())));//人工单价
|
||||
}
|
||||
break;
|
||||
case 12:
|
||||
if (StringUtils.isNotEmpty(cell.toString())) {
|
||||
contractsummarylist.set("qeug_provisional",BigDecimal.valueOf(Double.parseDouble(cell.toString())));//辅材单价
|
||||
}
|
||||
break;
|
||||
case 13:
|
||||
case 11:
|
||||
if (StringUtils.isNotEmpty(cell.toString())) {
|
||||
contractsummarylist.set("qeug_unitpriceofmainmater",BigDecimal.valueOf(Double.parseDouble(cell.toString())));//主材单价
|
||||
}
|
||||
break;
|
||||
case 14:
|
||||
case 12:
|
||||
if (StringUtils.isNotEmpty(cell.toString())) {
|
||||
contractsummarylist.set("qeug_mechanicalunitprice",BigDecimal.valueOf(Double.parseDouble(cell.toString())));//机械,设备单价
|
||||
}
|
||||
break;
|
||||
case 15:
|
||||
case 13:
|
||||
if (StringUtils.isNotEmpty(cell.toString())) {
|
||||
contractsummarylist.set("qeug_remarks",cell);//备注
|
||||
}
|
||||
|
@ -398,12 +425,14 @@ public class ContractFormPlugin extends AbstractFormPlugin implements UploadLis
|
|||
break;
|
||||
}
|
||||
}
|
||||
SaveServiceHelper.save(new DynamicObject[]{contractsummarylist});
|
||||
dynamicObjects.add(contractsummarylist);
|
||||
}
|
||||
amounttotalMap.put(sheet.getSheetName(),amounttotal);//一个sheet一个总金额
|
||||
// this.getView().showSuccessNotification("清单汇总识别--生产明细成功");
|
||||
}
|
||||
|
||||
for (DynamicObject dynamicObject : dynamicObjects) {
|
||||
SaveServiceHelper.save(new DynamicObject[]{dynamicObject});
|
||||
}
|
||||
/**
|
||||
* --------------------------------------汇总------------------------------------------------
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue