parent
e7e7682a23
commit
92059e36b1
|
@ -67,7 +67,6 @@ public class ContractFormPlugin extends AbstractFormPlugin implements UploadLis
|
||||||
private static final String BASEDATA_FIELD = "multitypepartya";
|
private static final String BASEDATA_FIELD = "multitypepartya";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
super.initialize();
|
super.initialize();
|
||||||
|
@ -164,6 +163,7 @@ public class ContractFormPlugin extends AbstractFormPlugin implements UploadLis
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除汇总明细并且删除清单明细
|
* 删除汇总明细并且删除清单明细
|
||||||
*/
|
*/
|
||||||
|
@ -287,6 +287,7 @@ public class ContractFormPlugin extends AbstractFormPlugin implements UploadLis
|
||||||
InputStream in = urlConnection.getInputStream();
|
InputStream in = urlConnection.getInputStream();
|
||||||
// FileInputStream in = new FileInputStream(fileUrl);
|
// FileInputStream in = new FileInputStream(fileUrl);
|
||||||
Workbook workbook = WorkbookFactory.create(in);
|
Workbook workbook = WorkbookFactory.create(in);
|
||||||
|
FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------明细------------------------------------------------
|
* --------------------------------------明细------------------------------------------------
|
||||||
|
@ -357,93 +358,90 @@ public class ContractFormPlugin extends AbstractFormPlugin implements UploadLis
|
||||||
contractsummarylist.set("qeug_unit", cell);//计量单位
|
contractsummarylist.set("qeug_unit", cell);//计量单位
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
if (StringUtils.isNotEmpty(cell.toString())) {
|
String value6 = getCellValueAsString(cell, evaluator);
|
||||||
String expression = cell.toString();
|
if (StringUtils.isNotEmpty(value6)) {
|
||||||
ScriptEngine engine = new ScriptEngineManager().getEngineByName("JavaScript");
|
|
||||||
try {
|
try {
|
||||||
BigDecimal results =BigDecimal.valueOf(Double.parseDouble(engine.eval(expression).toString()));
|
BigDecimal results = new BigDecimal(value6);
|
||||||
contractsummarylist.set("qeug_decimalqty", results);
|
contractsummarylist.set("qeug_decimalqty", results);
|
||||||
} catch (Exception e) {
|
} catch (NumberFormatException e) {
|
||||||
this.getView().showErrorNotification("清单汇总识别--生成明细失败:"+e.getMessage());
|
this.getView().showErrorNotification("清单汇总识别--生成明细失败: 数量列格式错误");
|
||||||
return;
|
return;
|
||||||
// 处理计算失败的情况
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
if (StringUtils.isNotEmpty(cell.toString())) {
|
String value7 = getCellValueAsString(cell, evaluator);
|
||||||
String expression = cell.toString();
|
if (StringUtils.isNotEmpty(value7)) {
|
||||||
ScriptEngine engine = new ScriptEngineManager().getEngineByName("JavaScript");
|
|
||||||
try {
|
try {
|
||||||
BigDecimal results =BigDecimal.valueOf(Double.parseDouble(engine.eval(expression).toString()));
|
BigDecimal results = new BigDecimal(value7);
|
||||||
contractsummarylist.set("qeug_unitprice", results);// 综合单价
|
contractsummarylist.set("qeug_unitprice", results);// 综合单价
|
||||||
} catch (Exception e) {
|
} catch (NumberFormatException e) {
|
||||||
this.getView().showErrorNotification("清单汇总识别--生成明细失败:"+e.getMessage());
|
this.getView().showErrorNotification("清单汇总识别--生成明细失败: 单价列格式错误");
|
||||||
return;
|
return;
|
||||||
// 处理计算失败的情况
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
//todo:保留几位有效数字
|
String value8 = getCellValueAsString(cell, evaluator);
|
||||||
Cell cell1 = row.getCell(6);
|
if (StringUtils.isNotEmpty(value8)) {
|
||||||
Cell cell2 = row.getCell(7);
|
|
||||||
if (cell1 != null && cell2 != null && StringUtils.isNotEmpty(cell1.toString()) && StringUtils.isNotEmpty(cell2.toString())) {
|
|
||||||
BigDecimal results = BigDecimal.ZERO;
|
|
||||||
try {
|
try {
|
||||||
double value1 = cell1.getNumericCellValue();
|
BigDecimal results = new BigDecimal(value8);
|
||||||
double value2 = cell2.getNumericCellValue();
|
// 保留三位小数,采用四舍五入的舍入模式
|
||||||
results = BigDecimal.valueOf(value1 * value2).setScale(3, RoundingMode.HALF_UP);
|
results = results.setScale(3, RoundingMode.HALF_UP);
|
||||||
contractsummarylist.set("qeug_amounttotal", results); // 合计金额
|
contractsummarylist.set("qeug_amounttotal", results); // 合计金额
|
||||||
} catch (Exception e) {
|
amounttotal = amounttotal.add(results);
|
||||||
this.getView().showErrorNotification("清单汇总识别--生成明细失败:" + e.getMessage());
|
} catch (NumberFormatException e) {
|
||||||
|
this.getView().showErrorNotification("清单汇总识别--生成明细失败: 合计金额列格式错误");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
amounttotal = amounttotal.add(results);
|
|
||||||
}
|
}
|
||||||
break;
|
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:
|
case 9:
|
||||||
if (StringUtils.isNotEmpty(cell.toString())) {
|
String value9 = getCellValueAsString(cell, evaluator);
|
||||||
contractsummarylist.set("qeug_artificial",BigDecimal.valueOf(Double.parseDouble(cell.toString())));//人工单价
|
if (StringUtils.isNotEmpty(value9)) {
|
||||||
|
try {
|
||||||
|
contractsummarylist.set("qeug_artificial", new BigDecimal(value9));// 人工单价
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
this.getView().showErrorNotification("清单汇总识别--生成明细失败: 人工单价列格式错误");
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 10:
|
case 10:
|
||||||
if (StringUtils.isNotEmpty(cell.toString())) {
|
String value10 = getCellValueAsString(cell, evaluator);
|
||||||
contractsummarylist.set("qeug_provisional",BigDecimal.valueOf(Double.parseDouble(cell.toString())));//辅材单价
|
if (StringUtils.isNotEmpty(value10)) {
|
||||||
|
try {
|
||||||
|
contractsummarylist.set("qeug_provisional", new BigDecimal(value10));// 辅材单价
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
this.getView().showErrorNotification("清单汇总识别--生成明细失败: 辅材单价列格式错误");
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 11:
|
case 11:
|
||||||
if (StringUtils.isNotEmpty(cell.toString())) {
|
String value11 = getCellValueAsString(cell, evaluator);
|
||||||
contractsummarylist.set("qeug_unitpriceofmainmater",BigDecimal.valueOf(Double.parseDouble(cell.toString())));//主材单价
|
if (StringUtils.isNotEmpty(value11)) {
|
||||||
|
try {
|
||||||
|
contractsummarylist.set("qeug_unitpriceofmainmater", new BigDecimal(value11));// 主材单价
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
this.getView().showErrorNotification("清单汇总识别--生成明细失败: 主材单价列格式错误");
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 12:
|
case 12:
|
||||||
if (StringUtils.isNotEmpty(cell.toString())) {
|
String value12 = getCellValueAsString(cell, evaluator);
|
||||||
contractsummarylist.set("qeug_mechanicalunitprice",BigDecimal.valueOf(Double.parseDouble(cell.toString())));//机械,设备单价
|
if (StringUtils.isNotEmpty(value12)) {
|
||||||
|
try {
|
||||||
|
contractsummarylist.set("qeug_mechanicalunitprice", new BigDecimal(value12));// 机械,设备单价
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
this.getView().showErrorNotification("清单汇总识别--生成明细失败: 机械设备单价列格式错误");
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 13:
|
case 13:
|
||||||
if (StringUtils.isNotEmpty(cell.toString())) {
|
contractsummarylist.set("qeug_remarks", getCellValueAsString(cell, evaluator));// 备注
|
||||||
contractsummarylist.set("qeug_remarks",cell);//备注
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -510,6 +508,39 @@ public class ContractFormPlugin extends AbstractFormPlugin implements UploadLis
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getCellValueAsString(Cell cell, FormulaEvaluator evaluator) {
|
||||||
|
if (cell == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
switch (cell.getCellType()) {
|
||||||
|
case STRING:
|
||||||
|
return cell.getStringCellValue();
|
||||||
|
case NUMERIC:
|
||||||
|
if (DateUtil.isCellDateFormatted(cell)) {
|
||||||
|
// 如果是日期格式,可根据需要进行处理
|
||||||
|
return cell.getDateCellValue().toString();
|
||||||
|
} else {
|
||||||
|
return String.valueOf(cell.getNumericCellValue());
|
||||||
|
}
|
||||||
|
case BOOLEAN:
|
||||||
|
return String.valueOf(cell.getBooleanCellValue());
|
||||||
|
case FORMULA:
|
||||||
|
CellValue cellValue = evaluator.evaluate(cell);
|
||||||
|
switch (cellValue.getCellType()) {
|
||||||
|
case NUMERIC:
|
||||||
|
return String.valueOf(cellValue.getNumberValue());
|
||||||
|
case STRING:
|
||||||
|
return cellValue.getStringValue();
|
||||||
|
case BOOLEAN:
|
||||||
|
return String.valueOf(cellValue.getBooleanValue());
|
||||||
|
default:
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static boolean isRowEmpty(Row row) {
|
private static boolean isRowEmpty(Row row) {
|
||||||
if (row == null) {
|
if (row == null) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -604,6 +635,7 @@ public class ContractFormPlugin extends AbstractFormPlugin implements UploadLis
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 打开列表展示清单详情页
|
* 打开列表展示清单详情页
|
||||||
|
*
|
||||||
* @param formView 页面
|
* @param formView 页面
|
||||||
* @param model 模型
|
* @param model 模型
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue