parent
e14e64e967
commit
21477001ff
|
@ -54,11 +54,12 @@ public class MeasureciFormPlugin extends AbstractFormPlugin {
|
|||
myList.add(cientrydata);
|
||||
}
|
||||
}
|
||||
//遍历赋值工程量基数
|
||||
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("qeug_gcljs",value,(int)dynamicObject.get("seq")-1);//工程量
|
||||
this.getModel().setValue("qeug_gcljs",value,(int)dynamicObject.get("seq")-1);//工程量基数
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -33,6 +33,7 @@ import kd.bos.servicehelper.AttachmentServiceHelper;
|
|||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.bos.servicehelper.QueryServiceHelper;
|
||||
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
||||
import kd.bos.servicehelper.org.OrgUnitServiceHelper;
|
||||
import kd.repc.rebas.common.util.ReDigitalUtil;
|
||||
import kd.repc.recos.business.measure.ReMeasureIdxUtil;
|
||||
import kd.repc.recos.formplugin.measure.base.ReMeasureEditTplPlugin;
|
||||
|
@ -203,6 +204,8 @@ public class RecosMeasurecosFormPlugin extends AbstractFormPlugin implements Upl
|
|||
// 单据列表数据风格样式,设置字体为黑体,字号15
|
||||
XSSFCellStyle billStyle = workbook.createCellStyle();
|
||||
|
||||
billStyle.setLocked(false);//解锁单元格
|
||||
|
||||
// 设置边框
|
||||
billStyle.setBorderBottom(BorderStyle.THIN);
|
||||
billStyle.setBorderTop(BorderStyle.THIN);
|
||||
|
@ -227,6 +230,7 @@ public class RecosMeasurecosFormPlugin extends AbstractFormPlugin implements Upl
|
|||
//填写栏
|
||||
XSSFCellStyle titleStyle1 = workbook.createCellStyle();
|
||||
titleStyle1.setAlignment(HorizontalAlignment.LEFT);
|
||||
titleStyle1.setLocked(false);//解锁单元格
|
||||
|
||||
XSSFRow headRow1 = sheet.createRow(1);
|
||||
headRow1.setRowStyle(titleStyle1);
|
||||
|
@ -248,8 +252,17 @@ public class RecosMeasurecosFormPlugin extends AbstractFormPlugin implements Upl
|
|||
XSSFCell headCell4 = headRow1.createCell(14);
|
||||
headCell4.setCellValue("单位:");
|
||||
|
||||
XSSFCell headCell5 = headRow1.createCell(17);
|
||||
headCell5.setCellValue("总计:");
|
||||
headCell5.setCellStyle(billStyle);
|
||||
XSSFCell headCell6 = headRow1.createCell(18);
|
||||
String formula = String.format("SUM(S%d:S%d)", 4, 1000);//合计sum(s5:s1000)
|
||||
headCell6.setCellFormula(formula); // F列是公式列
|
||||
headCell6.setCellStyle(billStyle);
|
||||
|
||||
|
||||
CellStyle style = workbook.createCellStyle();
|
||||
style.setLocked(false);//解锁单元格
|
||||
style.setAlignment(HorizontalAlignment.CENTER);
|
||||
// 设置垂直居中
|
||||
style.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||
|
@ -277,6 +290,15 @@ public class RecosMeasurecosFormPlugin extends AbstractFormPlugin implements Upl
|
|||
// 创建单元格样式
|
||||
ncell.setCellStyle(style);
|
||||
}
|
||||
if (u==13){//调整系数
|
||||
// 设置单元格格式为百分比
|
||||
DataFormat dataFormat = workbook.createDataFormat();
|
||||
XSSFCellStyle cellStyle = ncell.getCellStyle();
|
||||
XSSFCellStyle clonedStyle = (XSSFCellStyle) workbook.createCellStyle();
|
||||
clonedStyle.cloneStyleFrom(cellStyle);
|
||||
clonedStyle.setDataFormat(dataFormat.getFormat("0.00%"));
|
||||
ncell.setCellStyle(clonedStyle);
|
||||
}
|
||||
Object s = excel.get(i).get(u);
|
||||
if (s instanceof BigDecimal) {
|
||||
BigDecimal b=(BigDecimal)s;
|
||||
|
@ -322,7 +344,7 @@ public class RecosMeasurecosFormPlugin extends AbstractFormPlugin implements Upl
|
|||
}
|
||||
|
||||
// 调整列宽
|
||||
stylesforcells(sheet);
|
||||
stylesforcells(sheet,workbook);
|
||||
|
||||
workbook.setSheetName(index,key);
|
||||
index++;
|
||||
|
@ -541,15 +563,15 @@ public class RecosMeasurecosFormPlugin extends AbstractFormPlugin implements Upl
|
|||
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){
|
||||
sheetNameView.getModel().setValue("entry_workloadunit",null,key);//单位
|
||||
sheetNameView.getModel().setValue("entry_idxunit",null,key);//单位
|
||||
}else {
|
||||
DynamicObject single = BusinessDataServiceHelper.loadSingle(unit.getString("id"),"bd_measureunits");
|
||||
sheetNameView.getModel().setValue("entry_workloadunit",single,key);//单位
|
||||
sheetNameView.getModel().setValue("entry_idxunit",single,key);//单位
|
||||
}
|
||||
|
||||
sheetNameView.getModel().setValue("qeug_gcljs",value.getQeug_gcljs(),key);//工程量基数
|
||||
|
||||
sheetNameView.getModel().setValue("qeug_gcljs",value.getQeug_gcljs(),key);//工程量调整数
|
||||
sheetNameView.getModel().setValue("qeug_gcltzz",value.getQeug_gcltzz(),key);//工程量调整数
|
||||
|
||||
sheetNameView.getModel().setValue("entry_workload",value.getEntry_workload(),key);//工程量
|
||||
|
||||
|
@ -624,7 +646,7 @@ public class RecosMeasurecosFormPlugin extends AbstractFormPlugin implements Upl
|
|||
|
||||
|
||||
//单独为某单元格设置样式
|
||||
public static void stylesforcells(Sheet sheet) {
|
||||
public static void stylesforcells(Sheet sheet,Workbook workbook) {
|
||||
//设置列宽
|
||||
int numColumns = sheet.getRow(4).getPhysicalNumberOfCells();//获取总列数
|
||||
for (int colIndex = 0; colIndex < numColumns; colIndex++) {
|
||||
|
@ -641,19 +663,19 @@ public class RecosMeasurecosFormPlugin extends AbstractFormPlugin implements Upl
|
|||
sheet.setColumnWidth(colIndex, 10 * 256); // 10个字符的宽度
|
||||
break;
|
||||
case "调整系数":
|
||||
sheet.setColumnWidth(colIndex, 10 * 256); // 10个字符的宽度
|
||||
sheet.setColumnWidth(colIndex, 15 * 256); // 10个字符的宽度
|
||||
break;
|
||||
case "计价数量":
|
||||
sheet.setColumnWidth(colIndex, 10 * 256); // 10个字符的宽度
|
||||
break;
|
||||
case "含调差指标单价":
|
||||
sheet.setColumnWidth(colIndex, 10* 256); // 10个字符的宽度
|
||||
sheet.setColumnWidth(colIndex, 15* 256); // 10个字符的宽度
|
||||
break;
|
||||
case "科目名称":
|
||||
sheet.setColumnWidth(colIndex, 42* 256); // 42个字符的宽度
|
||||
break;
|
||||
case "财务预算分类":
|
||||
// 1. 设置下拉项数据(产品列表)
|
||||
// 1. 设置下拉项数据
|
||||
String[] products = {"基础配套", "精装修", "设计亮点", "特殊项","其他费用"};
|
||||
DataValidationHelper helper = sheet.getDataValidationHelper();
|
||||
DataValidationConstraint constraint = helper.createExplicitListConstraint(products);
|
||||
|
@ -664,12 +686,66 @@ public class RecosMeasurecosFormPlugin extends AbstractFormPlugin implements Upl
|
|||
// 添加数据验证规则
|
||||
sheet.addValidationData(dataValidation);
|
||||
break;
|
||||
case "估算口径":
|
||||
// 1. 设置下拉项数据
|
||||
String[] products1 = {"按建筑面积指标", "按施工面积指标", "按项估入", "其他计算口径","个/套/组/件/点位"};
|
||||
DataValidationHelper helper1 = sheet.getDataValidationHelper();
|
||||
DataValidationConstraint constraint1 = helper1.createExplicitListConstraint(products1);
|
||||
int totalRowCount1 = sheet.getLastRowNum() + 1;
|
||||
System.out.println("总行数 (包括空行): " + totalRowCount1);
|
||||
CellRangeAddressList addressList1 = new CellRangeAddressList(4, totalRowCount1-1, colIndex, colIndex); // 从 A2 到 A10 作为下拉列表范围
|
||||
DataValidation dataValidation1 = helper1.createValidation(constraint1, addressList1);
|
||||
// 添加数据验证规则
|
||||
sheet.addValidationData(dataValidation1);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
// 设置冻结前4行
|
||||
sheet.createFreezePane(0, 4); // 0列, 4行
|
||||
|
||||
//设置下拉
|
||||
//设置公式
|
||||
for (int rowNum =5 ; rowNum < sheet.getPhysicalNumberOfRows(); rowNum++) {
|
||||
for (int i = 0; i < numColumns; i++) {
|
||||
Cell cell = sheet.getRow(3).getCell(i);
|
||||
if (cell==null){
|
||||
cell=sheet.getRow(2).getCell(i);
|
||||
}
|
||||
String stringCellValue = cell.getStringCellValue();
|
||||
switch (stringCellValue) {
|
||||
case "计价数量":
|
||||
String formula = "(L" + (rowNum) + "+M" + (rowNum) + ")*N" + (rowNum);
|
||||
sheet.getRow(rowNum-1).getCell(i).setCellFormula(formula); // 设置公式
|
||||
CellStyle cellStyle = sheet.getRow(rowNum - 1).getCell(i).getCellStyle();//获取Style
|
||||
XSSFCellStyle clonedStyle = (XSSFCellStyle) workbook.createCellStyle();
|
||||
clonedStyle.cloneStyleFrom(cellStyle);
|
||||
clonedStyle.setLocked(true); // 锁定单元格
|
||||
sheet.getRow(rowNum-1).getCell(i).setCellStyle(clonedStyle);
|
||||
break;
|
||||
case "含调差指标单价":
|
||||
String formula1 = "(P" + (rowNum) + "+Q" + (rowNum) + ")";
|
||||
sheet.getRow(rowNum-1).getCell(i).setCellFormula(formula1); // 设置公式
|
||||
CellStyle cellStyle1 = sheet.getRow(rowNum - 1).getCell(i).getCellStyle();//获取Style
|
||||
XSSFCellStyle clonedStyle1 = (XSSFCellStyle) workbook.createCellStyle();
|
||||
clonedStyle1.cloneStyleFrom(cellStyle1);
|
||||
clonedStyle1.setLocked(true); // 锁定单元格
|
||||
sheet.getRow(rowNum-1).getCell(i).setCellStyle(clonedStyle1);
|
||||
break;
|
||||
case "合价(含税)":
|
||||
String formula2 = "(O" + (rowNum) + "*R" + (rowNum) + ")";
|
||||
sheet.getRow(rowNum-1).getCell(i).setCellFormula(formula2); // 设置公式
|
||||
CellStyle cellStyle2 = sheet.getRow(rowNum - 1).getCell(i).getCellStyle();//获取Style
|
||||
XSSFCellStyle clonedStyle2 = (XSSFCellStyle) workbook.createCellStyle();
|
||||
clonedStyle2.cloneStyleFrom(cellStyle2);
|
||||
clonedStyle2.setLocked(true); // 锁定单元格
|
||||
sheet.getRow(rowNum-1).getCell(i).setCellStyle(clonedStyle2);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sheet.protectSheet("password");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue