Compare commits

...

2 Commits

Author SHA1 Message Date
陈绍鑫 bfabc43b14 Merge remote-tracking branch 'origin/main' into main 2024-11-20 18:14:45 +08:00
陈绍鑫 902802a93d 代码提交
提交人:陈绍鑫
时间:2024/11/19  17:00
内容:成本测算插件
2024-11-20 18:14:36 +08:00
2 changed files with 49 additions and 22 deletions

View File

@ -16,6 +16,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
public class MeasureciFormPlugin extends AbstractFormPlugin {
@Override
@ -28,17 +29,11 @@ public class MeasureciFormPlugin extends AbstractFormPlugin {
Object measurecostid = this.getModel().getValue("measurecostid");//成本测算ID
DynamicObject measurecost = BusinessDataServiceHelper.loadSingle(measurecostid,"recos_measurecost");
DynamicObject project = measurecost.getDynamicObject("project");
String number = project.getString("number");//项目编码
QFilter filter = new QFilter("qeug_cpmc.id", QCP.equals, producttypeid).
and(new QFilter("qeug_xmnumber", QCP.equals, number));
DynamicObject queryone = QueryServiceHelper.queryOne("qeug_gcl", "id", filter.toArray());
if (queryone==null){
this.getView().showSuccessNotification("请维护项目面积数据");
return;
}
DynamicObject repmd_projectbill = BusinessDataServiceHelper.loadSingle(project.getPkValue(),"repmd_projectbill");//获取项目
DynamicObjectCollection productentry = repmd_projectbill.getDynamicObjectCollection("productentry");//获取对应产品
List<DynamicObject> children = productentry .stream().filter(e -> e.getDynamicObject("productentry_producttype").getString("id").equals(producttypeid.toString())).collect(Collectors.toList());
DynamicObjectCollection qeug_entryentity = children.get(0).getDynamicObjectCollection("qeug_subentryentity");//子单据体
Map<String, BigDecimal> result = new HashMap<>();
DynamicObject gcl = BusinessDataServiceHelper.loadSingle(queryone.get("id"),"qeug_gcl");
DynamicObjectCollection qeug_entryentity = gcl.getDynamicObjectCollection("qeug_entryentity");//面积
for (int i = 0; i <qeug_entryentity.size() ; i++) {
DynamicObject dynamicObject = qeug_entryentity.get(i);
BigDecimal sum = dynamicObject.getBigDecimal("qeug_hjs");

View File

@ -12,8 +12,10 @@ import kd.bos.entity.plugin.Plugin;
import kd.bos.fileservice.FileItem;
import kd.bos.fileservice.FileService;
import kd.bos.fileservice.FileServiceFactory;
import kd.bos.form.ConfirmTypes;
import kd.bos.form.FormShowParameter;
import kd.bos.form.IFormView;
import kd.bos.form.MessageBoxOptions;
import kd.bos.form.control.AttachmentPanel;
import kd.bos.form.control.Control;
import kd.bos.form.control.events.BeforeItemClickEvent;
@ -187,6 +189,19 @@ public class RecosMeasurecosFormPlugin extends AbstractFormPlugin implements Upl
// 单据列表数据风格样式设置字体为黑体字号15
XSSFCellStyle billStyle = workbook.createCellStyle();
// 设置边框
billStyle.setBorderBottom(BorderStyle.THIN);
billStyle.setBorderTop(BorderStyle.THIN);
billStyle.setBorderLeft(BorderStyle.THIN);
billStyle.setBorderRight(BorderStyle.THIN);
// 设置边框颜色
billStyle.setBottomBorderColor(IndexedColors.BLACK.getIndex());
billStyle.setTopBorderColor(IndexedColors.BLACK.getIndex());
billStyle.setLeftBorderColor(IndexedColors.BLACK.getIndex());
billStyle.setRightBorderColor(IndexedColors.BLACK.getIndex());
// 设置水平居中
billStyle.setAlignment(HorizontalAlignment.CENTER);
// 设置垂直居中
@ -203,6 +218,17 @@ public class RecosMeasurecosFormPlugin extends AbstractFormPlugin implements Upl
for (int u=0;u<excel.get(i).size();u++){
XSSFCell ncell = nrow.createCell(u);
ncell.setCellStyle(billStyle);
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);
}
Object s = excel.get(i).get(u);
if (s instanceof BigDecimal) {
BigDecimal b=(BigDecimal)s;
@ -315,19 +341,25 @@ public class RecosMeasurecosFormPlugin extends AbstractFormPlugin implements Upl
break;
}
}
for (int j = rowNum; j <= rowCountsheet - 2; j++){//序号行至最后一行总计前一行
for (int j = rowNum; j <= rowCountsheet - 1; j++){//序号行至最后一行
Row row = sheet.getRow(j);
Calculation calculation = new Calculation(
row.getCell(6).getStringCellValue(),//科目编码
row.getCell(7).getStringCellValue(),//科目名称
row.getCell(10).getStringCellValue(),//单位
row.getCell(12).getNumericCellValue(),// 调整系数
row.getCell(14).getNumericCellValue(),//合价含税
row.getCell(13).getNumericCellValue(),//单价
row.getCell(11).getNumericCellValue(),//工程量
row.getCell(9).getStringCellValue(),//估算口径
String.valueOf(getcellvallue(row.getCell(15)))//备注
);
Calculation calculation = null;
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)))//备注
);
} catch (Exception e) {
this.getView().showConfirm("导入功能失败", e.getMessage()+"原因:"+sheetName+""+(j+1)+"行获取数据格式有误,请检查", MessageBoxOptions.OK, ConfirmTypes.Default, null);
return;
}
arrayList.add(calculation);
}
String res = updateRecosMeasurecos(arrayList, sheetName,result);