|
@@ -2602,7 +2602,7 @@ public class TaskController extends BladeController {
|
|
|
/*List<String> dataListPdf = new ArrayList<>();*/
|
|
|
String file_path = CollectionUtils.getSysLocalFileUrl();
|
|
|
/* 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().collect(Collectors.toList()));
|
|
|
+ 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));
|
|
@@ -2631,7 +2631,7 @@ public class TaskController extends BladeController {
|
|
|
try {
|
|
|
byte[] excelByte = CommonUtil.InputStreamToBytes(CommonUtil.getOSSInputStream(rs.getExcelUrl()));
|
|
|
if(Func.isNotEmpty(rs.getData())){
|
|
|
- PdfReader reader;
|
|
|
+ PdfReader reader = null;
|
|
|
Document doc = new Document();
|
|
|
PdfCopy pdfCopy;
|
|
|
pdfCopy = new PdfCopy(doc, new FileOutputStream(rs.getPdfPath()));
|
|
@@ -2648,10 +2648,14 @@ public class TaskController extends BladeController {
|
|
|
for (String keys : dataMap.keySet()) {
|
|
|
int y1 = Func.toInt(keys.split("_")[0]);
|
|
|
int x1 = Func.toInt(keys.split("_")[1]);
|
|
|
- Row row = sheet.getRow(y1);
|
|
|
+ Row row = sheet.getRow(y1-1);
|
|
|
if (row != null) {
|
|
|
- Cell cell = row.getCell(x1);
|
|
|
- cell.setCellValue(dataMap.getOrDefault(keys,StringPool.EMPTY).toString());
|
|
|
+ Cell cell = row.getCell(x1-1);
|
|
|
+ if(cell!=null) {
|
|
|
+ cell.setCellValue(dataMap.getOrDefault(keys, StringPool.EMPTY).toString());
|
|
|
+ }else{
|
|
|
+ System.out.println(keys+"不存在");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
/*输出到内存*/
|
|
@@ -2662,6 +2666,7 @@ public class TaskController extends BladeController {
|
|
|
sheet.getPrintSetup().setPaperSize(PrintSetup.A4_PAPERSIZE);
|
|
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
|
|
workbook.write(out);
|
|
|
+ // workbook.write(new FileOutputStream(rs.getExcelPath()));
|
|
|
// ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(out.toByteArray());
|
|
|
com.aspose.cells.Workbook wb = new com.aspose.cells.Workbook( new ByteArrayInputStream(out.toByteArray()));
|
|
|
out.reset();
|
|
@@ -2676,13 +2681,13 @@ public class TaskController extends BladeController {
|
|
|
workbook.close();
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
- }finally {
|
|
|
- pdfCopy.flush();
|
|
|
- pdfCopy.close();
|
|
|
- doc.close();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ pdfCopy.flush();
|
|
|
+ pdfCopy.close();
|
|
|
+ if(reader!=null)reader.close();
|
|
|
+ doc.close();
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
@@ -2694,7 +2699,7 @@ public class TaskController extends BladeController {
|
|
|
CollectionUtils.mergePdfPublicMethods(reportResults.stream().map(ReportResult::getPdfPath).collect(Collectors.toList()), lasPdf);
|
|
|
BladeFile bladeFile = newIOSSClient.uploadFile(dataId + "_last.pdf", lasPdf);
|
|
|
fileUrl=bladeFile.getLink();
|
|
|
- String upSql = "update "+Report.REPORT_TYPE[report.getType()]+" set raw_url='" + fileUrl + "' where contract_id=" + report.getContractId() + " and type=1 and meter_period_id=" + report.getPeriodId() + "";
|
|
|
+ String upSql = "update "+Report.REPORT_TYPE[report.getType()]+" set raw_url='" + fileUrl + "' where id="+report.getId();
|
|
|
jdbcTemplate.execute(upSql);
|
|
|
}
|
|
|
}
|