diff --git a/main/java/shkd/repc/recos/domain/Calculation.java b/main/java/shkd/repc/recos/domain/Calculation.java index 23aebff..7be7b97 100644 --- a/main/java/shkd/repc/recos/domain/Calculation.java +++ b/main/java/shkd/repc/recos/domain/Calculation.java @@ -11,36 +11,60 @@ public class Calculation { //科目名称 String entry_accountname; - //单位 - String entry_workloadunit; - - //调整系数 - Double entry_adjustcoefficient; - - //合价(含税) - Double entry_amount; - - //单价 - Double entry_price; - - //工程量 - Double entry_workload; + //财务预算分类 + String qeug_cwysfl; //估算口径 String entry_measureplanidx; + //单位 + String entry_workloadunit; + + //工程量基数 + Double qeug_gcljs; + + //工程量调整值 + Double qeug_gcltzz; + + //调整系数 + Double entry_adjustcoefficient; + + //工程量 + Double entry_workload; + + //单价基数 + Double qeug_djjs; + + //单价调整值 + Double qeug_djtzz; + + //单价 + Double entry_price; + + //合价(含税) + Double entry_amount; + + //明细 + String qeug_mx; + //备注 String entry_description; - public Calculation(String entry_longnumber, String entry_accountname, String entry_workloadunit, Double entry_adjustcoefficient, Double entry_amount,Double entry_price,Double entry_workload,String entry_measureplanidx,String entry_description) { + public Calculation(String entry_longnumber, String entry_accountname, String qeug_cwysfl, String entry_measureplanidx, String entry_workloadunit, Double qeug_gcljs, Double qeug_gcltzz, Double entry_adjustcoefficient, Double entry_workload, Double qeug_djjs, Double qeug_djtzz, Double entry_price, Double entry_amount, String qeug_mx, String entry_description) { this.entry_longnumber = entry_longnumber; this.entry_accountname = entry_accountname; - this.entry_workloadunit = entry_workloadunit; - this.entry_adjustcoefficient = entry_adjustcoefficient; - this.entry_amount = entry_amount; - this.entry_price = entry_price; - this.entry_workload = entry_workload; + this.qeug_cwysfl = qeug_cwysfl; this.entry_measureplanidx = entry_measureplanidx; + this.entry_workloadunit = entry_workloadunit; + this.qeug_gcljs = qeug_gcljs; + this.qeug_gcltzz = qeug_gcltzz; + this.entry_adjustcoefficient = entry_adjustcoefficient; + this.entry_workload = entry_workload; + this.qeug_djjs = qeug_djjs; + this.qeug_djtzz = qeug_djtzz; + this.entry_price = entry_price; + this.entry_amount = entry_amount; + this.qeug_mx = qeug_mx; this.entry_description = entry_description; } @@ -60,6 +84,22 @@ public class Calculation { this.entry_accountname = entry_accountname; } + public String getQeug_cwysfl() { + return qeug_cwysfl; + } + + public void setQeug_cwysfl(String qeug_cwysfl) { + this.qeug_cwysfl = qeug_cwysfl; + } + + public String getEntry_measureplanidx() { + return entry_measureplanidx; + } + + public void setEntry_measureplanidx(String entry_measureplanidx) { + this.entry_measureplanidx = entry_measureplanidx; + } + public String getEntry_workloadunit() { return entry_workloadunit; } @@ -68,6 +108,22 @@ public class Calculation { this.entry_workloadunit = entry_workloadunit; } + public Double getQeug_gcljs() { + return qeug_gcljs; + } + + public void setQeug_gcljs(Double qeug_gcljs) { + this.qeug_gcljs = qeug_gcljs; + } + + public Double getQeug_gcltzz() { + return qeug_gcltzz; + } + + public void setQeug_gcltzz(Double qeug_gcltzz) { + this.qeug_gcltzz = qeug_gcltzz; + } + public Double getEntry_adjustcoefficient() { return entry_adjustcoefficient; } @@ -76,14 +132,29 @@ public class Calculation { this.entry_adjustcoefficient = entry_adjustcoefficient; } - public Double getEntry_amount() { - return entry_amount; + public Double getEntry_workload() { + return entry_workload; } - public void setEntry_amount(Double entry_amount) { - this.entry_amount = entry_amount; + public void setEntry_workload(Double entry_workload) { + this.entry_workload = entry_workload; } + public Double getQeug_djjs() { + return qeug_djjs; + } + + public void setQeug_djjs(Double qeug_djjs) { + this.qeug_djjs = qeug_djjs; + } + + public Double getQeug_djtzz() { + return qeug_djtzz; + } + + public void setQeug_djtzz(Double qeug_djtzz) { + this.qeug_djtzz = qeug_djtzz; + } public Double getEntry_price() { return entry_price; @@ -93,20 +164,20 @@ public class Calculation { this.entry_price = entry_price; } - public Double getEntry_workload() { - return entry_workload; + public Double getEntry_amount() { + return entry_amount; } - public void setEntry_workload(Double entry_workload) { - this.entry_workload = entry_workload; + public void setEntry_amount(Double entry_amount) { + this.entry_amount = entry_amount; } - public String getEntry_measureplanidx() { - return entry_measureplanidx; + public String getQeug_mx() { + return qeug_mx; } - public void setEntry_measureplanidx(String entry_measureplanidx) { - this.entry_measureplanidx = entry_measureplanidx; + public void setQeug_mx(String qeug_mx) { + this.qeug_mx = qeug_mx; } public String getEntry_description() { diff --git a/main/java/shkd/repc/recos/formplugin/MeasureciFormPlugin.java b/main/java/shkd/repc/recos/formplugin/MeasureciFormPlugin.java index 9d0ba01..0ebce39 100644 --- a/main/java/shkd/repc/recos/formplugin/MeasureciFormPlugin.java +++ b/main/java/shkd/repc/recos/formplugin/MeasureciFormPlugin.java @@ -57,7 +57,8 @@ public class MeasureciFormPlugin extends AbstractFormPlugin { result.forEach((key, value) -> { for (DynamicObject dynamicObject : myList) { if (dynamicObject.getString("entry_accountname").equals(key)){ - this.getModel().setValue("entry_workload",value,(int)dynamicObject.get("seq")-1);//工程量 +// this.getModel().setValue("entry_workload",value,(int)dynamicObject.get("seq")-1);//工程量 + this.getModel().setValue("qeug_gcljs",value,(int)dynamicObject.get("seq")-1);//工程量 } } }); diff --git a/main/java/shkd/repc/recos/formplugin/RecosMeasurecosFormPlugin.java b/main/java/shkd/repc/recos/formplugin/RecosMeasurecosFormPlugin.java index b558513..0a588a6 100644 --- a/main/java/shkd/repc/recos/formplugin/RecosMeasurecosFormPlugin.java +++ b/main/java/shkd/repc/recos/formplugin/RecosMeasurecosFormPlugin.java @@ -39,6 +39,7 @@ import kd.repc.recos.formplugin.measure.base.ReMeasureEditTplPlugin; import kd.repc.recos.formplugin.measure.measureci.ReMeasureCIEditPlugin; import org.apache.poi.ss.usermodel.*; import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.ss.util.CellRangeAddressList; import org.apache.poi.xssf.usermodel.*; import shkd.repc.recos.domain.Calculation; @@ -92,11 +93,16 @@ public class RecosMeasurecosFormPlugin extends AbstractFormPlugin implements Upl listcaption.add("科目名称"); listcaption.add("财务预算分类"); listcaption.add("估算口径"); - listcaption.add("工程量单位"); - listcaption.add("工程量"); + listcaption.add("单位"); + listcaption.add("基数"); + listcaption.add("调差数"); listcaption.add("调整系数"); + listcaption.add("计价数量"); + listcaption.add("基数"); + listcaption.add("调差数"); listcaption.add("含调差指标单价"); listcaption.add("合价(含税)"); + listcaption.add("明细"); listcaption.add("备注"); list.add(listcaption); int sum=1; @@ -123,19 +129,27 @@ public class RecosMeasurecosFormPlugin extends AbstractFormPlugin implements Upl listvalue.add(dynamicObject.getString("entry_longnumber"));//科目编码 listvalue.add(dynamicObject.getString("entry_accountname"));//科目名称 - listvalue.add("");//财务预算分类 + listvalue.add(dynamicObject.getString("qeug_cwysfl"));//财务预算分类 listvalue.add(dynamicObject.getString("entry_measureplanidx.name"));//估算口径 - DynamicObject entry_workloadunit = dynamicObject.getDynamicObject("entry_workloadunit"); - if (entry_workloadunit!=null){ - listvalue.add(dynamicObject.getDynamicObject("entry_workloadunit").getString("name"));//单位 + DynamicObject entry_idxunit = dynamicObject.getDynamicObject("entry_idxunit"); + if (entry_idxunit!=null){ + listvalue.add(dynamicObject.getDynamicObject("entry_idxunit").getString("name"));//单位 }else { listvalue.add(""); } - listvalue.add(dynamicObject.getBigDecimal("entry_workload"));//工程量 + BigDecimal qeug_gcljs = dynamicObject.getBigDecimal("qeug_gcljs"); + listvalue.add(qeug_gcljs);//基数(工程量) + BigDecimal qeug_gcltzz = dynamicObject.getBigDecimal("qeug_gcltzz"); + listvalue.add(qeug_gcltzz);//调差数(工程量) BigDecimal entry_adjustcoefficient = dynamicObject.getBigDecimal("entry_adjustcoefficient"); listvalue.add(entry_adjustcoefficient);//调整系数 + listvalue.add((qeug_gcljs.add(qeug_gcltzz)).multiply(entry_adjustcoefficient));//计价数量 + + listvalue.add(dynamicObject.getBigDecimal("qeug_djjs"));//基数(单价) + listvalue.add(dynamicObject.getBigDecimal("qeug_djtzz"));//调整数(单价) listvalue.add(dynamicObject.getBigDecimal("entry_price"));//单价 listvalue.add(dynamicObject.getBigDecimal("entry_amount"));//合价(含税) + listvalue.add(dynamicObject.getString("qeug_mx"));//备注 listvalue.add(dynamicObject.getLocaleString("entry_description").getLocaleValue_zh_CN());//备注 list.add(listvalue); } @@ -162,7 +176,6 @@ public class RecosMeasurecosFormPlugin extends AbstractFormPlugin implements Upl String key = entry.getKey(); List> excel= entry.getValue(); - //创建工作表sheet XSSFSheet sheet = workbook.createSheet(); @@ -211,22 +224,57 @@ public class RecosMeasurecosFormPlugin extends AbstractFormPlugin implements Upl billFont.setFontHeight(15); billStyle.setFont(billFont); + //填写栏 + XSSFCellStyle titleStyle1 = workbook.createCellStyle(); + titleStyle1.setAlignment(HorizontalAlignment.LEFT); + + XSSFRow headRow1 = sheet.createRow(1); + headRow1.setRowStyle(titleStyle1); + XSSFCell headCell1 = headRow1.createCell(0); + headCell1.setCellValue("项目名称:"); + CellRangeAddress titleCellAddresses1 = new CellRangeAddress(1, 1, 1,6); + sheet.addMergedRegion(titleCellAddresses1); + + XSSFCell headCell2 = headRow1.createCell(7); + headCell2.setCellValue("本版填报日期:"); + CellRangeAddress titleCellAddresses2 = new CellRangeAddress(1, 1, 8,9); + sheet.addMergedRegion(titleCellAddresses2); + + XSSFCell headCell3 = headRow1.createCell(10); + headCell3.setCellValue("版次号:"); + CellRangeAddress titleCellAddresses3 = new CellRangeAddress(1, 1, 11,13); + sheet.addMergedRegion(titleCellAddresses3); + + XSSFCell headCell4 = headRow1.createCell(14); + headCell4.setCellValue("单位:"); + + + CellStyle style = workbook.createCellStyle(); + style.setAlignment(HorizontalAlignment.CENTER); + // 设置垂直居中 + style.setVerticalAlignment(VerticalAlignment.CENTER); + // 设置背景颜色为淡灰色 + style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex()); + style.setFillPattern(FillPatternType.SOLID_FOREGROUND); + //边框 + style.setBorderBottom(BorderStyle.THIN); + style.setBorderTop(BorderStyle.THIN); + style.setBorderLeft(BorderStyle.THIN); + style.setBorderRight(BorderStyle.THIN); + style.setBottomBorderColor(IndexedColors.BLACK.getIndex()); + style.setTopBorderColor(IndexedColors.BLACK.getIndex()); + style.setLeftBorderColor(IndexedColors.BLACK.getIndex()); + style.setRightBorderColor(IndexedColors.BLACK.getIndex()); + //写入单据列表数据 for (int i = 0; i < excel.size(); i++) { // i+1是因为前面第1行加了一个标题,单据列表数据是从Excel的第2行开始的,所以要+1 - XSSFRow nrow = sheet.createRow(i+1); + XSSFRow nrow = sheet.createRow(i+2); for (int u=0;u { + sheetNameView.getModel().setValue("qeug_cwysfl",value.getQeug_cwysfl(),key);//财务预算分类 + + DynamicObject measureidxexp = QueryServiceHelper.queryOne("recos_measureidxexp", "id,name,number", new QFilter("name", QCP.equals, value.getEntry_measureplanidx()).toArray()); + if (measureidxexp==null){ + sheetNameView.getModel().setValue("entry_measureplanidx",null,key); + }else { + DynamicObject recos_measureidxexp = BusinessDataServiceHelper.loadSingle(measureidxexp.getString("id"),"recos_measureidxexp"); + sheetNameView.getModel().setValue("entry_measureplanidx",recos_measureidxexp,key);//估算口径 + } + String entry_workloadunit = value.getEntry_workloadunit(); DynamicObject unit = QueryServiceHelper.queryOne("bd_measureunits", "id,name,number", new QFilter("name", QCP.equals, entry_workloadunit).toArray()); if (unit==null){ @@ -430,22 +547,24 @@ public class RecosMeasurecosFormPlugin extends AbstractFormPlugin implements Upl sheetNameView.getModel().setValue("entry_workloadunit",single,key);//单位 } - sheetNameView.getModel().setValue("entry_adjustcoefficient",value.getEntry_adjustcoefficient(),key);//调整系数 + sheetNameView.getModel().setValue("qeug_gcljs",value.getQeug_gcljs(),key);//工程量基数 - sheetNameView.getModel().setValue("entry_price",value.getEntry_price(),key);//单价 + sheetNameView.getModel().setValue("qeug_gcljs",value.getQeug_gcljs(),key);//工程量调整数 sheetNameView.getModel().setValue("entry_workload",value.getEntry_workload(),key);//工程量 - sheetNameView.getModel().setValue("entry_amount",value.getEntry_amount(),key);//合价(含税) + sheetNameView.getModel().setValue("entry_adjustcoefficient",value.getEntry_adjustcoefficient(),key);//调整系数 + + sheetNameView.getModel().setValue("qeug_djjs",value.getQeug_djjs(),key);//单价基数 + + sheetNameView.getModel().setValue("qeug_djtzz",value.getQeug_djtzz(),key);//单价调整值 + + sheetNameView.getModel().setValue("entry_price",value.getEntry_price(),key);//单价 - DynamicObject measureidxexp = QueryServiceHelper.queryOne("recos_measureidxexp", "id,name,number", new QFilter("name", QCP.equals, value.getEntry_measureplanidx()).toArray()); - if (measureidxexp==null){ - sheetNameView.getModel().setValue("entry_measureplanidx",null,key);//单位 - }else { - DynamicObject recos_measureidxexp = BusinessDataServiceHelper.loadSingle(measureidxexp.getString("id"),"recos_measureidxexp"); - sheetNameView.getModel().setValue("entry_measureplanidx",recos_measureidxexp,key);//估算口径 - } +// sheetNameView.getModel().setValue("entry_amount",value.getEntry_amount(),key);//合价(含税) + + sheetNameView.getModel().setValue("qeug_mx",value.getQeug_mx(),key);//明细 sheetNameView.getModel().setValue("entry_description",value.getEntry_description(),key);//备注 }); @@ -502,4 +621,55 @@ public class RecosMeasurecosFormPlugin extends AbstractFormPlugin implements Upl return numericCellValue; } } + + + //单独为某单元格设置样式 + public static void stylesforcells(Sheet sheet) { + //设置列宽 + int numColumns = sheet.getRow(4).getPhysicalNumberOfCells();//获取总列数 + for (int colIndex = 0; colIndex < numColumns; colIndex++) { + Cell cell = sheet.getRow(3).getCell(colIndex); + if (cell==null){ + cell=sheet.getRow(2).getCell(colIndex); + } + String stringCellValue = cell.getStringCellValue(); + switch (stringCellValue) { + case "基数": + sheet.setColumnWidth(colIndex, 10 * 256); // 10个字符的宽度 + break; + case "调差数": + sheet.setColumnWidth(colIndex, 10 * 256); // 10个字符的宽度 + break; + case "调整系数": + sheet.setColumnWidth(colIndex, 10 * 256); // 10个字符的宽度 + break; + case "计价数量": + sheet.setColumnWidth(colIndex, 10 * 256); // 10个字符的宽度 + break; + case "含调差指标单价": + sheet.setColumnWidth(colIndex, 10* 256); // 10个字符的宽度 + break; + case "科目名称": + sheet.setColumnWidth(colIndex, 42* 256); // 42个字符的宽度 + break; + case "财务预算分类": + // 1. 设置下拉项数据(产品列表) + String[] products = {"基础配套", "精装修", "设计亮点", "特殊项","其他费用"}; + DataValidationHelper helper = sheet.getDataValidationHelper(); + DataValidationConstraint constraint = helper.createExplicitListConstraint(products); + int totalRowCount = sheet.getLastRowNum() + 1; + System.out.println("总行数 (包括空行): " + totalRowCount); + CellRangeAddressList addressList = new CellRangeAddressList(4, totalRowCount-1, colIndex, colIndex); // 从 A2 到 A10 作为下拉列表范围 + DataValidation dataValidation = helper.createValidation(constraint, addressList); + // 添加数据验证规则 + sheet.addValidationData(dataValidation); + break; + default: + } + } + + + //设置下拉 + + } }