|
@@ -1306,11 +1306,11 @@ public class TaskController extends BladeController {
|
|
|
MaterialMeterFormTask materialMeterFormTask = materialMeterFormServiceTask.getById(dataId);
|
|
|
MaterialMeterFormTaskVO materialMeterFormTaskVO = BeanUtil.copyProperties(materialMeterFormTask, MaterialMeterFormTaskVO.class);
|
|
|
if (materialMeterFormTaskVO != null) {
|
|
|
- if (materialMeterFormTaskVO.getMaterialConform() != null) {
|
|
|
- materialMeterFormTaskVO.setMaterialConformName(materialMeterFormTaskVO.getMaterialConform().equals(0) ? "不符合" : "符合");
|
|
|
+ if(materialMeterFormTaskVO.getMaterialConform()!=null){
|
|
|
+ materialMeterFormTaskVO.setMaterialConformName( materialMeterFormTaskVO.getMaterialConform().equals(0) ? "不符合" : "符合");
|
|
|
}
|
|
|
- if (materialMeterFormTaskVO.getStorageConform() != null) {
|
|
|
- materialMeterFormTaskVO.setStorageConformName(materialMeterFormTaskVO.getStorageConform() == 0 ? "不符合" : "符合");
|
|
|
+ if(materialMeterFormTaskVO.getStorageConform()!=null){
|
|
|
+ materialMeterFormTaskVO.setStorageConformName(materialMeterFormTaskVO.getStorageConform()==0 ? "不符合" : "符合");
|
|
|
}
|
|
|
vo.setBasicsInfo(materialMeterFormTaskVO);
|
|
|
}
|
|
@@ -2148,7 +2148,7 @@ public class TaskController extends BladeController {
|
|
|
data.setStatementName("材料预付款--" + me.getPeriodName());
|
|
|
|
|
|
//计量任务类型 1=中间计量申请,2=材料计量单,3=开工预付款计量单,4=变更令
|
|
|
- if (task.getMeterTaskType() == 2) {
|
|
|
+ if(task.getMeterTaskType()==2){
|
|
|
data.setType(1);
|
|
|
}
|
|
|
materialStartStatementService.addOrUpdate(data);
|
|
@@ -2157,7 +2157,7 @@ public class TaskController extends BladeController {
|
|
|
reportId = materialS.getId();
|
|
|
}
|
|
|
/**计量公式执行 0中间,1材料,2开工*/
|
|
|
- meterPdfInfo(reportId + "", 1);
|
|
|
+ meterPdfInfo(reportId+"",1);
|
|
|
|
|
|
/*复制业务数据状态>主任务状态>替换数据*/
|
|
|
updateCopyDataApproveStatus(task, dto).updateTaskStatus(task).displace(task, dto);
|
|
@@ -2667,12 +2667,12 @@ public class TaskController extends BladeController {
|
|
|
@GetMapping("/meterPdfInfo")
|
|
|
@ApiOperationSupport(order = 20)
|
|
|
@ApiOperation(value = "计量生成Pdf", notes = "计量生成Pdf")
|
|
|
- public R meterPdfInfo(@RequestParam String reportId, @RequestParam Integer type) {
|
|
|
- return R.data(calculate(reportId, type));
|
|
|
+ public R meterPdfInfo( @RequestParam String reportId, @RequestParam Integer type){
|
|
|
+ return R.data(calculate(reportId,type));
|
|
|
}
|
|
|
|
|
|
- public R<String> calculate(String reportId, Integer type) {
|
|
|
- if (BaseUtils.isNumber(reportId) && BaseUtils.isNumber(type)) {
|
|
|
+ public R<String> calculate(String reportId, Integer type){
|
|
|
+ if(BaseUtils.isNumber(reportId)&& BaseUtils.isNumber(type)) {
|
|
|
Report report = generateReport(Long.parseLong(reportId), type);
|
|
|
return R.data(generateReportsPdf(report));
|
|
|
}
|
|
@@ -2680,7 +2680,7 @@ public class TaskController extends BladeController {
|
|
|
}
|
|
|
|
|
|
/*中期支付证书报表、开工、材料手册报表*/
|
|
|
- public String generateReportsPdf(Report report) {
|
|
|
+ public String generateReportsPdf(Report report){
|
|
|
/*报表记录新增或者重算的时候会调用当前方法,生成PDF*/
|
|
|
/*保存两类PDF,一每种表独立一份用于浏览,二合成表用于电签*/
|
|
|
/*数据完全独立互不影响,可以并发生成,预估PDF的总大小来决定是否全部在内存中生成PDF*/
|
|
@@ -2688,30 +2688,30 @@ public class TaskController extends BladeController {
|
|
|
/*如果数据没有变化,则各表的PDF可以不用更新*/
|
|
|
List<ReportResult> reportResults = formulaClient.formulaExecute3(report.getContractId(), report.getId(), report.getType());
|
|
|
String fileUrl = null;
|
|
|
- if (Func.isNotEmpty(reportResults)) {
|
|
|
+ if(Func.isNotEmpty(reportResults)){
|
|
|
/*List<String> dataListPdf = new ArrayList<>();*/
|
|
|
String file_path = CollectionUtils.getSysLocalFileUrl();
|
|
|
- Map<String, Object> projectMap = jdbcTemplate.queryForMap("select b.project_name projectName from m_contract_info a join m_project_info b on a.p_id=b.id where a.id= " + report.getContractId());
|
|
|
- String projectName = projectMap.getOrDefault("projectName", StringPool.EMPTY).toString();
|
|
|
- /* String fileUrl = "";*/
|
|
|
- List<Map<String, Object>> excelInfo = jdbcTemplate.queryForList("SELECT id,file_url from m_excel_tab where id in(" + reportResults.stream().map(ReportResult::getExcelId).distinct().map(Objects::toString).collect(Collectors.joining(",")) + ")");
|
|
|
- if (Func.isNotEmpty(excelInfo)) {
|
|
|
+ Map<String,Object> projectMap=jdbcTemplate.queryForMap("select b.project_name projectName from m_contract_info a join m_project_info b on a.p_id=b.id where a.id= "+report.getContractId());
|
|
|
+ String projectName = projectMap.getOrDefault("projectName",StringPool.EMPTY).toString();
|
|
|
+ /* String fileUrl = "";*/
|
|
|
+ List<Map<String,Object>> excelInfo=jdbcTemplate.queryForList("SELECT id,file_url from m_excel_tab where id in("+reportResults.stream().map(ReportResult::getExcelId).distinct().map(Objects::toString).collect(Collectors.joining(","))+")");
|
|
|
+ if(Func.isNotEmpty(excelInfo)){
|
|
|
/*所有的Excel地址映射*/
|
|
|
- Map<String, String> fileUrlMapping = excelInfo.stream().collect(Collectors.toMap(m -> m.get("id").toString(), m -> m.get("file_url").toString(), (v1, v2) -> v1));
|
|
|
+ Map<String,String> fileUrlMapping = excelInfo.stream().collect(Collectors.toMap(m->m.get("id").toString(),m->m.get("file_url").toString(),(v1,v2)->v1));
|
|
|
/*把Excel缺失的移除*/
|
|
|
- reportResults.removeIf(rs -> !fileUrlMapping.containsKey(rs.getExcelId().toString()));
|
|
|
+ reportResults.removeIf(rs->!fileUrlMapping.containsKey(rs.getExcelId().toString()));
|
|
|
/*准备*/
|
|
|
- reportResults.forEach(rs -> {
|
|
|
+ reportResults.forEach(rs->{
|
|
|
/*初始化路径*/
|
|
|
- rs.pathInit(file_path);
|
|
|
- rs.setExcelUrl(fileUrlMapping.get(rs.getExcelId().toString()));
|
|
|
+ rs.pathInit(file_path);
|
|
|
+ rs.setExcelUrl(fileUrlMapping.get(rs.getExcelId().toString()));
|
|
|
/*删除已经存在的PDF*/
|
|
|
File tabPdf;
|
|
|
try {
|
|
|
tabPdf = ResourceUtil.getFile(rs.getPdfPath());
|
|
|
if (tabPdf.exists()) {
|
|
|
- if (tabPdf.delete()) {
|
|
|
- System.out.println(rs.getPdfPath() + "删除成功");
|
|
|
+ if(tabPdf.delete()){
|
|
|
+ System.out.println(rs.getPdfPath()+"删除成功");
|
|
|
}
|
|
|
}
|
|
|
} catch (FileNotFoundException e) {
|
|
@@ -2719,25 +2719,23 @@ public class TaskController extends BladeController {
|
|
|
}
|
|
|
});
|
|
|
/*每种表生成一份pdf*/
|
|
|
- reportResults.parallelStream().forEach(rs -> {
|
|
|
+ reportResults.parallelStream().forEach(rs->{
|
|
|
try {
|
|
|
byte[] excelByte = CommonUtil.InputStreamToBytes(CommonUtil.getOSSInputStream(rs.getExcelUrl()));
|
|
|
- if (Func.isNotEmpty(rs.getData())) {
|
|
|
+ if(Func.isNotEmpty(rs.getData())){
|
|
|
PdfReader reader = null;
|
|
|
Document doc = new Document();
|
|
|
- PdfCopy pdfCopy;
|
|
|
- pdfCopy = new PdfCopy(doc, new FileOutputStream(rs.getPdfPath()));
|
|
|
+ PdfCopy pdfCopy = new PdfCopy(doc, new FileOutputStream(rs.getPdfPath()));
|
|
|
int pageCount;
|
|
|
doc.open();
|
|
|
- String tile = projectName + StringPool.DASH + rs.getName();
|
|
|
- for (Map<String, Object> dataMap : rs.getData()) {
|
|
|
- if (Func.isNotEmpty(dataMap)) {
|
|
|
- try {
|
|
|
- Workbook workbook = WorkbookFactory.create(new ByteArrayInputStream(excelByte));
|
|
|
- //获取工作表
|
|
|
- Sheet sheet = workbook.getSheetAt(0);
|
|
|
- sheet.setForceFormulaRecalculation(true);
|
|
|
- // 循环Key
|
|
|
+ String tile=rs.getName().contains("封面")?projectName:projectName+StringPool.DASH+rs.getName();
|
|
|
+ for(Map<String,Object> dataMap:rs.getData()){
|
|
|
+ try {
|
|
|
+ Workbook workbook = WorkbookFactory.create(new ByteArrayInputStream(excelByte));
|
|
|
+ //获取工作表
|
|
|
+ Sheet sheet = workbook.getSheetAt(0);
|
|
|
+ sheet.setForceFormulaRecalculation(true);
|
|
|
+ if(Func.isNotEmpty(dataMap)) {
|
|
|
for (String keys : dataMap.keySet()) {
|
|
|
int y1 = Func.toInt(keys.split("_")[0]);
|
|
|
int x1 = Func.toInt(keys.split("_")[1]);
|
|
@@ -2751,118 +2749,108 @@ public class TaskController extends BladeController {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- /*设置表头*/
|
|
|
- setTitle(sheet, tile);
|
|
|
- /*输出到内存*/
|
|
|
- //去掉表格虚线
|
|
|
- sheet.setPrintGridlines(false);
|
|
|
- //设置 整个工作表为一页
|
|
|
- sheet.setFitToPage(true);
|
|
|
- sheet.getPrintSetup().setPaperSize(PrintSetup.A4_PAPERSIZE);
|
|
|
- ByteArrayOutputStream out = new ByteArrayOutputStream();
|
|
|
- workbook.write(out);
|
|
|
- //workbook.write(new FileOutputStream(rs.getExcelPath()));
|
|
|
- com.aspose.cells.Workbook wb = new com.aspose.cells.Workbook(new ByteArrayInputStream(out.toByteArray()));
|
|
|
- out.reset();
|
|
|
- wb.save(out, SaveFormat.PDF);
|
|
|
- reader = new PdfReader(new ByteArrayInputStream(out.toByteArray()));
|
|
|
- pageCount = reader.getNumberOfPages();
|
|
|
- for (int i = 1; i <= pageCount; ++i) {
|
|
|
- pdfCopy.addPage(pdfCopy.getImportedPage(reader, i));
|
|
|
- }
|
|
|
- out.close();
|
|
|
- workbook.close();
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
}
|
|
|
+ /*设置表头*/
|
|
|
+ setTitle(sheet,tile);
|
|
|
+ //去掉表格虚线
|
|
|
+ sheet.setPrintGridlines(false);
|
|
|
+ //设置 整个工作表为一页
|
|
|
+ sheet.setFitToPage(true);
|
|
|
+ sheet.getPrintSetup().setPaperSize(PrintSetup.A4_PAPERSIZE);
|
|
|
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
|
|
|
+ workbook.write(out);
|
|
|
+ workbook.write(new FileOutputStream(rs.getExcelPath()));
|
|
|
+ com.aspose.cells.Workbook wb = new com.aspose.cells.Workbook( new ByteArrayInputStream(out.toByteArray()));
|
|
|
+ out.reset();
|
|
|
+ wb.save(out, SaveFormat.PDF);
|
|
|
+ reader = new PdfReader(new ByteArrayInputStream(out.toByteArray()));
|
|
|
+ pageCount = reader.getNumberOfPages();
|
|
|
+ for (int i = 1; i <= pageCount; ++i) {
|
|
|
+ pdfCopy.addPage(pdfCopy.getImportedPage(reader, i));
|
|
|
+ }
|
|
|
+ out.close();
|
|
|
+ workbook.close();
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
pdfCopy.flush();
|
|
|
pdfCopy.close();
|
|
|
- if (reader != null) reader.close();
|
|
|
+ if(reader!=null)reader.close();
|
|
|
doc.close();
|
|
|
- rs.setPdfOssPath(CompletableFuture.supplyAsync(() -> {
|
|
|
- BladeFile bladeFile = newIOSSClient.uploadFile(rs.getName() + SnowFlakeUtil.getId() + ".pdf", rs.getPdfPath());
|
|
|
- String url = bladeFile.getLink();
|
|
|
- if (Func.isEmpty(url)) {
|
|
|
- url = "无效链接";
|
|
|
+ rs.setPdfOssPath(CompletableFuture.supplyAsync(()->{
|
|
|
+ BladeFile bladeFile = newIOSSClient.uploadFile(rs.getName()+SnowFlakeUtil.getId() + ".pdf", rs.getPdfPath());
|
|
|
+ String url=bladeFile.getLink();
|
|
|
+ if(Func.isEmpty(url)){
|
|
|
+ url="无效链接";
|
|
|
}
|
|
|
return url;
|
|
|
}));
|
|
|
}
|
|
|
- } catch (Exception e) {
|
|
|
+ }catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
});
|
|
|
/*合并所有表*/
|
|
|
- fileUrl = report.getReportPdf(file_path, reportResults);
|
|
|
+ fileUrl=report.getReportPdf(file_path,reportResults);
|
|
|
}
|
|
|
}
|
|
|
- return fileUrl;
|
|
|
+ return fileUrl;
|
|
|
}
|
|
|
|
|
|
|
|
|
- public void setTitle(Sheet sheet, String name) {
|
|
|
- if (name.contains("封面")) {
|
|
|
- return;
|
|
|
- }
|
|
|
+
|
|
|
+ public void setTitle(Sheet sheet,String name){
|
|
|
Row row = sheet.getRow(0);
|
|
|
Cell cell = row.getCell(0);
|
|
|
if (cell != null) {
|
|
|
- Workbook workbook = sheet.getWorkbook();
|
|
|
- Font font = workbook.createFont();
|
|
|
- font.setFontName("黑体"); // 设置字体名称
|
|
|
- font.setFontHeightInPoints((short) 20); // 设置字号为20
|
|
|
- CellStyle style = workbook.createCellStyle();
|
|
|
- style.setFont(font); // 将字体应用到样式中
|
|
|
+ /* Workbook workbook = sheet.getWorkbook();*/
|
|
|
+ /* Font font = workbook.createFont();*/
|
|
|
+ CellStyle style=cell.getCellStyle();
|
|
|
+/* font.setFontName("黑体"); // 设置字体名称
|
|
|
+ font.setFontHeightInPoints((short) 20); // 设置字号为20*/
|
|
|
+ /*CellStyle style = workbook.createCellStyle();*/
|
|
|
+ /*style.setFont(font); // 将字体应用到样式中*/
|
|
|
style.setAlignment(HorizontalAlignment.CENTER);
|
|
|
style.setVerticalAlignment(VerticalAlignment.CENTER);
|
|
|
cell.setCellValue(name);
|
|
|
- cell.setCellStyle(style);
|
|
|
+ /*cell.setCellStyle(style);*/
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Data
|
|
|
- class Report {
|
|
|
- public final String[] REPORT_TYPE = new String[]{"s_interim_pay_certificate", "s_material_start_statement", "s_material_start_statement"};
|
|
|
- public final String[] PERIOD_TYPE = new String[]{"s_contract_meter_period", "s_meter_period", "s_meter_period"};
|
|
|
- /**
|
|
|
- * 报表记录id
|
|
|
- */
|
|
|
+ class Report{
|
|
|
+ public final String[] REPORT_TYPE=new String[]{"s_interim_pay_certificate","s_material_start_statement","s_material_start_statement"};
|
|
|
+ public final String[] PERIOD_TYPE=new String[]{"s_contract_meter_period","s_meter_period","s_meter_period"};
|
|
|
+ /**报表记录id*/
|
|
|
private Long id;
|
|
|
- /**
|
|
|
- * 报表PDF地址
|
|
|
- */
|
|
|
+ /**报表PDF地址*/
|
|
|
private String pdfUrl;
|
|
|
/*报表对应计量期Id*/
|
|
|
private Long periodId;
|
|
|
- /**
|
|
|
- * 计量期ID
|
|
|
- */
|
|
|
+ /**计量期ID*/
|
|
|
private Long contractId;
|
|
|
- /**
|
|
|
- * 计量类型,0中间计量 1材料,2开工动员
|
|
|
- */
|
|
|
+ /**计量类型,0中间计量 1材料,2开工动员*/
|
|
|
private Integer type;
|
|
|
|
|
|
- /*上传并关联PDF,然后返回合并后的PDF链接*/
|
|
|
- public String getReportPdf(String file_path, List<ReportResult> reportResults) {
|
|
|
+ /*上传并关联PDF,然后返回合并后的PDF链接*/
|
|
|
+ public String getReportPdf(String file_path,List<ReportResult> reportResults){
|
|
|
Long dataId = SnowFlakeUtil.getId();
|
|
|
String lasPdf = file_path + "/pdf//" + dataId + "_last.pdf";
|
|
|
CollectionUtils.mergePdfPublicMethods(reportResults.stream().map(ReportResult::getPdfPath).collect(Collectors.toList()), lasPdf);
|
|
|
BladeFile bladeFile = newIOSSClient.uploadFile(dataId + "_last.pdf", lasPdf);
|
|
|
- this.pdfUrl = bladeFile.getLink();
|
|
|
- Map<String, String> fileListMap = reportResults.stream().collect(Collectors.toMap(ReportResult::getName, rs -> {
|
|
|
+ this.pdfUrl=bladeFile.getLink();
|
|
|
+ Map<String,String> fileListMap = reportResults.stream().collect(Collectors.toMap(ReportResult::getName, rs-> {
|
|
|
try {
|
|
|
return rs.getPdfOssPath().get();
|
|
|
} catch (InterruptedException | ExecutionException e) {
|
|
|
e.printStackTrace();
|
|
|
return "无效地址";
|
|
|
}
|
|
|
- }, (v1, v2) -> v1, LinkedHashMap::new));
|
|
|
- String upSql = "update " + REPORT_TYPE[this.type] + " set raw_url=?,file_url_list=? where id=" + this.id;
|
|
|
- jdbcTemplate.update(upSql, this.pdfUrl, JSON.toJSONString(fileListMap));
|
|
|
- return this.pdfUrl;
|
|
|
+ },(v1,v2)->v1,LinkedHashMap::new));
|
|
|
+ String upSql = "update "+REPORT_TYPE[this.type]+" set raw_url=?,file_url_list=? where id="+this.id;
|
|
|
+ jdbcTemplate.update(upSql,this.pdfUrl , JSON.toJSONString(fileListMap));
|
|
|
+ return this.pdfUrl;
|
|
|
}
|
|
|
|
|
|
public Report(Long id, Integer type) {
|
|
@@ -2871,18 +2859,18 @@ public class TaskController extends BladeController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public Report generateReport(Long reportId, Integer type) {
|
|
|
- Report report = new Report(reportId, type);
|
|
|
- Map<String, Object> map;
|
|
|
- if (type == 0) {
|
|
|
- map = this.jdbcTemplate.queryForMap("select id,contract_id ,contract_period_id period_id from s_interim_pay_certificate where id = " + reportId);
|
|
|
- } else {
|
|
|
- map = this.jdbcTemplate.queryForMap("select id,contract_id,meter_period_id period_id from s_material_start_statement where id = " + reportId);
|
|
|
+ public Report generateReport(Long reportId,Integer type){
|
|
|
+ Report report =new Report(reportId,type);
|
|
|
+ Map<String,Object> map;
|
|
|
+ if(type==0){
|
|
|
+ map = this.jdbcTemplate.queryForMap("select id,contract_id ,contract_period_id period_id from s_interim_pay_certificate where id = "+reportId);
|
|
|
+ }else{
|
|
|
+ map = this.jdbcTemplate.queryForMap("select id,contract_id,meter_period_id period_id from s_material_start_statement where id = "+reportId);
|
|
|
}
|
|
|
report.setContractId(Long.parseLong(map.get("contract_id").toString()));
|
|
|
report.setPeriodId(Long.parseLong(map.get("period_id").toString()));
|
|
|
return report;
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
@GetMapping("/getFixedFlowPage")
|
|
|
@ApiOperationSupport(order = 21)
|