diff --git a/main/java/shkd/repc/recon/formplugin/ContractFormPlugin.java b/main/java/shkd/repc/recon/formplugin/ContractFormPlugin.java index 4102c7b..89ad1ae 100644 --- a/main/java/shkd/repc/recon/formplugin/ContractFormPlugin.java +++ b/main/java/shkd/repc/recon/formplugin/ContractFormPlugin.java @@ -362,8 +362,9 @@ public class ContractFormPlugin extends AbstractFormPlugin implements UploadLis try { BigDecimal results =BigDecimal.valueOf(Double.parseDouble(engine.eval(expression).toString())); contractsummarylist.set("qeug_decimalqty", results); - } catch (ScriptException e) { - e.printStackTrace(); + } catch (Exception e) { + this.getView().showErrorNotification("清单汇总识别--生成明细失败:"+e.getMessage()); + return ; // 处理计算失败的情况 } } @@ -375,27 +376,48 @@ public class ContractFormPlugin extends AbstractFormPlugin implements UploadLis try { BigDecimal results =BigDecimal.valueOf(Double.parseDouble(engine.eval(expression).toString())); contractsummarylist.set("qeug_unitprice",results);//综合单价 - } catch (ScriptException e) { - e.printStackTrace(); + } catch (Exception e) { + this.getView().showErrorNotification("清单汇总识别--生成明细失败:"+e.getMessage()); + return ; // 处理计算失败的情况 } } break; case 8: - if (StringUtils.isNotEmpty(cell.toString())) { - String expression = cell.toString(); - ScriptEngine engine = new ScriptEngineManager().getEngineByName("JavaScript"); + Cell cell1 = row.getCell(6); + Cell cell2 = row.getCell(7); + if (cell1 != null && cell2 != null && StringUtils.isNotEmpty(cell1.toString()) && StringUtils.isNotEmpty(cell2.toString())) { BigDecimal results = BigDecimal.ZERO; try { - results =BigDecimal.valueOf(Double.parseDouble(engine.eval(expression).toString())); - contractsummarylist.set("qeug_amounttotal",results);//综合单价 - } catch (ScriptException e) { - e.printStackTrace(); - // 处理计算失败的情况 + double value1 = cell1.getNumericCellValue(); + double value2 = cell2.getNumericCellValue(); + results = BigDecimal.valueOf(value1 * value2); + contractsummarylist.set("qeug_amounttotal", results); // 合计金额 + } catch (Exception e) { + this.getView().showErrorNotification("清单汇总识别--生成明细失败:" + e.getMessage()); + return; } amounttotal = amounttotal.add(results); } break; +// case 8: +// Cell cell1 = row.getCell(6); +// Cell cell2 = row.getCell(7); +// 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 (Exception e) { +// this.getView().showErrorNotification("清单汇总识别--生成明细失败:"+e.getMessage()); +// return ; +// // 处理计算失败的情况 +// } +// amounttotal = amounttotal.add(results); +// } +// break; case 9: if (StringUtils.isNotEmpty(cell.toString())) { contractsummarylist.set("qeug_artificial",BigDecimal.valueOf(Double.parseDouble(cell.toString())));//人工单价