代码提交

提交人:陈绍鑫
时间:2024/12/11  18:00
内容:成本测算插件
This commit is contained in:
陈绍鑫 2024-12-11 18:05:16 +08:00
parent 4c90cc0883
commit aaeaf11689
3 changed files with 310 additions and 68 deletions

View File

@ -11,36 +11,60 @@ public class Calculation {
//科目名称 //科目名称
String entry_accountname; String entry_accountname;
//单位 //财务预算分类
String entry_workloadunit; String qeug_cwysfl;
//调整系数
Double entry_adjustcoefficient;
//合价含税
Double entry_amount;
//单价
Double entry_price;
//工程量
Double entry_workload;
//估算口径 //估算口径
String entry_measureplanidx; 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; 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_longnumber = entry_longnumber;
this.entry_accountname = entry_accountname; this.entry_accountname = entry_accountname;
this.entry_workloadunit = entry_workloadunit; this.qeug_cwysfl = qeug_cwysfl;
this.entry_adjustcoefficient = entry_adjustcoefficient;
this.entry_amount = entry_amount;
this.entry_price = entry_price;
this.entry_workload = entry_workload;
this.entry_measureplanidx = entry_measureplanidx; 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; this.entry_description = entry_description;
} }
@ -60,6 +84,22 @@ public class Calculation {
this.entry_accountname = entry_accountname; 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() { public String getEntry_workloadunit() {
return entry_workloadunit; return entry_workloadunit;
} }
@ -68,6 +108,22 @@ public class Calculation {
this.entry_workloadunit = entry_workloadunit; 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() { public Double getEntry_adjustcoefficient() {
return entry_adjustcoefficient; return entry_adjustcoefficient;
} }
@ -76,14 +132,29 @@ public class Calculation {
this.entry_adjustcoefficient = entry_adjustcoefficient; this.entry_adjustcoefficient = entry_adjustcoefficient;
} }
public Double getEntry_amount() { public Double getEntry_workload() {
return entry_amount; return entry_workload;
} }
public void setEntry_amount(Double entry_amount) { public void setEntry_workload(Double entry_workload) {
this.entry_amount = entry_amount; 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() { public Double getEntry_price() {
return entry_price; return entry_price;
@ -93,20 +164,20 @@ public class Calculation {
this.entry_price = entry_price; this.entry_price = entry_price;
} }
public Double getEntry_workload() { public Double getEntry_amount() {
return entry_workload; return entry_amount;
} }
public void setEntry_workload(Double entry_workload) { public void setEntry_amount(Double entry_amount) {
this.entry_workload = entry_workload; this.entry_amount = entry_amount;
} }
public String getEntry_measureplanidx() { public String getQeug_mx() {
return entry_measureplanidx; return qeug_mx;
} }
public void setEntry_measureplanidx(String entry_measureplanidx) { public void setQeug_mx(String qeug_mx) {
this.entry_measureplanidx = entry_measureplanidx; this.qeug_mx = qeug_mx;
} }
public String getEntry_description() { public String getEntry_description() {

View File

@ -57,7 +57,8 @@ public class MeasureciFormPlugin extends AbstractFormPlugin {
result.forEach((key, value) -> { result.forEach((key, value) -> {
for (DynamicObject dynamicObject : myList) { for (DynamicObject dynamicObject : myList) {
if (dynamicObject.getString("entry_accountname").equals(key)){ 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);//工程量
} }
} }
}); });

View File

@ -39,6 +39,7 @@ import kd.repc.recos.formplugin.measure.base.ReMeasureEditTplPlugin;
import kd.repc.recos.formplugin.measure.measureci.ReMeasureCIEditPlugin; import kd.repc.recos.formplugin.measure.measureci.ReMeasureCIEditPlugin;
import org.apache.poi.ss.usermodel.*; import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.ss.util.CellRangeAddressList;
import org.apache.poi.xssf.usermodel.*; import org.apache.poi.xssf.usermodel.*;
import shkd.repc.recos.domain.Calculation; 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("调差数");
listcaption.add("含调差指标单价"); listcaption.add("含调差指标单价");
listcaption.add("合价(含税)"); listcaption.add("合价(含税)");
listcaption.add("明细");
listcaption.add("备注"); listcaption.add("备注");
list.add(listcaption); list.add(listcaption);
int sum=1; 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_longnumber"));//科目编码
listvalue.add(dynamicObject.getString("entry_accountname"));//科目名称 listvalue.add(dynamicObject.getString("entry_accountname"));//科目名称
listvalue.add("");//财务预算分类 listvalue.add(dynamicObject.getString("qeug_cwysfl"));//财务预算分类
listvalue.add(dynamicObject.getString("entry_measureplanidx.name"));//估算口径 listvalue.add(dynamicObject.getString("entry_measureplanidx.name"));//估算口径
DynamicObject entry_workloadunit = dynamicObject.getDynamicObject("entry_workloadunit"); DynamicObject entry_idxunit = dynamicObject.getDynamicObject("entry_idxunit");
if (entry_workloadunit!=null){ if (entry_idxunit!=null){
listvalue.add(dynamicObject.getDynamicObject("entry_workloadunit").getString("name"));//单位 listvalue.add(dynamicObject.getDynamicObject("entry_idxunit").getString("name"));//单位
}else { }else {
listvalue.add(""); 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"); BigDecimal entry_adjustcoefficient = dynamicObject.getBigDecimal("entry_adjustcoefficient");
listvalue.add(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_price"));//单价
listvalue.add(dynamicObject.getBigDecimal("entry_amount"));//合价(含税) listvalue.add(dynamicObject.getBigDecimal("entry_amount"));//合价(含税)
listvalue.add(dynamicObject.getString("qeug_mx"));//备注
listvalue.add(dynamicObject.getLocaleString("entry_description").getLocaleValue_zh_CN());//备注 listvalue.add(dynamicObject.getLocaleString("entry_description").getLocaleValue_zh_CN());//备注
list.add(listvalue); list.add(listvalue);
} }
@ -162,7 +176,6 @@ public class RecosMeasurecosFormPlugin extends AbstractFormPlugin implements Upl
String key = entry.getKey(); String key = entry.getKey();
List<List<String>> excel= entry.getValue(); List<List<String>> excel= entry.getValue();
//创建工作表sheet //创建工作表sheet
XSSFSheet sheet = workbook.createSheet(); XSSFSheet sheet = workbook.createSheet();
@ -211,22 +224,57 @@ public class RecosMeasurecosFormPlugin extends AbstractFormPlugin implements Upl
billFont.setFontHeight(15); billFont.setFontHeight(15);
billStyle.setFont(billFont); 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++) { for (int i = 0; i < excel.size(); i++) {
// i+1是因为前面第1行加了一个标题单据列表数据是从Excel的第2行开始的所以要+1 // i+1是因为前面第1行加了一个标题单据列表数据是从Excel的第2行开始的所以要+1
XSSFRow nrow = sheet.createRow(i+1); XSSFRow nrow = sheet.createRow(i+2);
for (int u=0;u<excel.get(i).size();u++){ for (int u=0;u<excel.get(i).size();u++){
XSSFCell ncell = nrow.createCell(u); XSSFCell ncell = nrow.createCell(u);
ncell.setCellStyle(billStyle); ncell.setCellStyle(billStyle);//单元格格式
if (i==0){ if (i==0){
// 创建单元格样式 // 创建单元格样式
CellStyle style = workbook.createCellStyle();
style.setAlignment(HorizontalAlignment.CENTER);
// 设置垂直居中
style.setVerticalAlignment(VerticalAlignment.CENTER);
// 设置背景颜色为淡灰色
style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
ncell.setCellStyle(style); ncell.setCellStyle(style);
} }
Object s = excel.get(i).get(u); Object s = excel.get(i).get(u);
@ -236,9 +284,46 @@ public class RecosMeasurecosFormPlugin extends AbstractFormPlugin implements Upl
}else { }else {
ncell.setCellValue(excel.get(i).get(u)); ncell.setCellValue(excel.get(i).get(u));
} }
} }
} }
sheet.shiftRows(3, sheet.getPhysicalNumberOfRows(), 1); //从第三行插入一行
Row newRow = sheet.createRow(3);
for (int i = 0; i < 11; i++) {
CellRangeAddress titleCellAddresses4 = new CellRangeAddress(2, 3, i,i);
sheet.addMergedRegion(titleCellAddresses4);
}
Row currentRow = sheet.getRow(2);
for (int i = 11; i < 15; i++) {
Cell cell = newRow.createCell(i);
cell.setCellStyle(style);
String stringCellValue = currentRow.getCell(i).getStringCellValue();
cell.setCellValue(stringCellValue);
}
currentRow.getCell(11).setCellValue("数量/基价");
CellRangeAddress titleCellAddresses5 = new CellRangeAddress(2, 2, 11,14);
sheet.addMergedRegion(titleCellAddresses5);
for (int i = 15; i < 18; i++) {
Cell cell = newRow.createCell(i);
cell.setCellStyle(style);
String stringCellValue = currentRow.getCell(i).getStringCellValue();
cell.setCellValue(stringCellValue);
}
currentRow.getCell(15).setCellValue("指标单价");
CellRangeAddress titleCellAddresses6 = new CellRangeAddress(2, 2, 15,17);
sheet.addMergedRegion(titleCellAddresses6);
for (int i = 18; i < 21; i++) {
CellRangeAddress titleCellAddresses4 = new CellRangeAddress(2, 3, i,i);
sheet.addMergedRegion(titleCellAddresses4);
}
// 调整列宽
stylesforcells(sheet);
workbook.setSheetName(index,key); workbook.setSheetName(index,key);
index++; index++;
} }
@ -332,7 +417,12 @@ public class RecosMeasurecosFormPlugin extends AbstractFormPlugin implements Upl
int rowNum = 0; int rowNum = 0;
int rowCountsheet = sheet.getPhysicalNumberOfRows();//总行数 int rowCountsheet = sheet.getPhysicalNumberOfRows();//总行数
for (Row cells : sheet) { for (Row cells : sheet) {
String billno = cells.getCell(0).toString(); String billno = null;
try {
billno = cells.getCell(0).toString();
} catch (Exception e) {
billno="";
}
//第一列属于数字 //第一列属于数字
Pattern pattern = Pattern.compile("^-?\\d+(\\.\\d+)?$"); Pattern pattern = Pattern.compile("^-?\\d+(\\.\\d+)?$");
boolean matches = pattern.matcher(billno).matches(); boolean matches = pattern.matcher(billno).matches();
@ -345,16 +435,33 @@ public class RecosMeasurecosFormPlugin extends AbstractFormPlugin implements Upl
Row row = sheet.getRow(j); Row row = sheet.getRow(j);
Calculation calculation = null; Calculation calculation = null;
try { try {
// calculation = new Calculation(
// String.valueOf(getcellvallue(row.getCell(6))),//科目编码
// String.valueOf(getcellvallue(row.getCell(7))),//科目名称
// String.valueOf(getcellvallue(row.getCell(10))),//单位
// (double)getcellvallue(row.getCell(12)),// 调整系数
// (double)getcellvallue(row.getCell(14)),//合价含税
// (double)getcellvallue(row.getCell(13)),//单价
// (double)getcellvallue(row.getCell(11)),//工程量
// String.valueOf(getcellvallue(row.getCell(9))),//估算口径
// String.valueOf(getcellvallue(row.getCell(15)))//备注
// );
calculation = new Calculation( calculation = new Calculation(
String.valueOf(getcellvallue(row.getCell(6))),//科目编码 String.valueOf(getcellvallue(row.getCell(6))),//科目编码
String.valueOf(getcellvallue(row.getCell(7))),//科目名称 String.valueOf(getcellvallue(row.getCell(7))),//科目名称
String.valueOf(getcellvallue(row.getCell(10))),//单位 String.valueOf(getcellvallue(row.getCell(8))),//财务预算分类
(double)getcellvallue(row.getCell(12)),// 调整系数
(double)getcellvallue(row.getCell(14)),//合价含税
(double)getcellvallue(row.getCell(13)),//单价
(double)getcellvallue(row.getCell(11)),//工程量
String.valueOf(getcellvallue(row.getCell(9))),//估算口径 String.valueOf(getcellvallue(row.getCell(9))),//估算口径
String.valueOf(getcellvallue(row.getCell(15)))//备注 String.valueOf(getcellvallue(row.getCell(10))),//单位
(double)getcellvallue(row.getCell(11)),//工程量基数
(double)getcellvallue(row.getCell(12)),//工程量调整值
(double)getcellvallue(row.getCell(13)),//调整系数
(double)getcellvallue(row.getCell(11))+(double)getcellvallue(row.getCell(12)),//工程量
(double)getcellvallue(row.getCell(15)),//单价基数
(double)getcellvallue(row.getCell(16)),//单价调整值
(double)getcellvallue(row.getCell(17)),//单价
(double)getcellvallue(row.getCell(18)),//合价含税
String.valueOf(getcellvallue(row.getCell(19))),//明细
String.valueOf(getcellvallue(row.getCell(20)))//备注
); );
} catch (Exception e) { } catch (Exception e) {
this.getView().showConfirm("导入功能失败", e.getMessage()+"原因:"+sheetName+""+(j+1)+"行获取数据格式有误,请检查", MessageBoxOptions.OK, ConfirmTypes.Default, null); this.getView().showConfirm("导入功能失败", e.getMessage()+"原因:"+sheetName+""+(j+1)+"行获取数据格式有误,请检查", MessageBoxOptions.OK, ConfirmTypes.Default, null);
@ -421,6 +528,16 @@ public class RecosMeasurecosFormPlugin extends AbstractFormPlugin implements Upl
} }
hashMap.forEach((key, value) -> { hashMap.forEach((key, value) -> {
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(); String entry_workloadunit = value.getEntry_workloadunit();
DynamicObject unit = QueryServiceHelper.queryOne("bd_measureunits", "id,name,number", new QFilter("name", QCP.equals, entry_workloadunit).toArray()); DynamicObject unit = QueryServiceHelper.queryOne("bd_measureunits", "id,name,number", new QFilter("name", QCP.equals, entry_workloadunit).toArray());
if (unit==null){ 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_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_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()); // sheetNameView.getModel().setValue("entry_amount",value.getEntry_amount(),key);//合价(含税)
if (measureidxexp==null){
sheetNameView.getModel().setValue("entry_measureplanidx",null,key);//单位 sheetNameView.getModel().setValue("qeug_mx",value.getQeug_mx(),key);//明细
}else {
DynamicObject recos_measureidxexp = BusinessDataServiceHelper.loadSingle(measureidxexp.getString("id"),"recos_measureidxexp");
sheetNameView.getModel().setValue("entry_measureplanidx",recos_measureidxexp,key);//估算口径
}
sheetNameView.getModel().setValue("entry_description",value.getEntry_description(),key);//备注 sheetNameView.getModel().setValue("entry_description",value.getEntry_description(),key);//备注
}); });
@ -502,4 +621,55 @@ public class RecosMeasurecosFormPlugin extends AbstractFormPlugin implements Upl
return numericCellValue; 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:
}
}
//设置下拉
}
} }