From 7d03d9fe3714a10fdd51f24e3c84da31a36f4ad8 Mon Sep 17 00:00:00 2001 From: wzp <2040239371@qq.com> Date: 星期二, 15 七月 2025 14:28:14 +0800 Subject: [PATCH] fix:修复docker转化pdf文件卡顿和IO暴涨问题。 用单例控制docker转化,并监控docker状态 --- src/main/java/com/ots/project/tool/report/LAQ/chart/LAQChart.java | 81 +++++++++++++++++++++++++++++++--------- 1 files changed, 62 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/ots/project/tool/report/LAQ/chart/LAQChart.java b/src/main/java/com/ots/project/tool/report/LAQ/chart/LAQChart.java index 962ca37..fe67dd3 100644 --- a/src/main/java/com/ots/project/tool/report/LAQ/chart/LAQChart.java +++ b/src/main/java/com/ots/project/tool/report/LAQ/chart/LAQChart.java @@ -48,22 +48,34 @@ public static void main(String[] args) throws Exception { -/* String dataPath = "D:\\娴嬭瘎绯荤粺\\闇�姹俓\2023\\5.棰嗗娼滃姏鎶ュ憡\\report\\LAQ琛ㄥご鏁版嵁鏂囦欢.xlsx"; - // 鑾峰彇瀵煎叆鏁版嵁 - File file = new File(dataPath); - InputStream in = new FileInputStream(file); - ExcelUtil<LAQTemplate> util = new ExcelUtil<>(LAQTemplate.class); - List<LAQTemplate> laqTemplateList = util.importExcel(in); +// String dataPath = "D:\\娴嬭瘎绯荤粺\\闇�姹俓\LAQ\\report\\LAQ琛ㄥご鏁版嵁鏂囦欢.xlsx"; +// // 鑾峰彇瀵煎叆鏁版嵁 +// File file = new File(dataPath); +// InputStream in = new FileInputStream(file); +// ExcelUtil<LAQTemplate> util = new ExcelUtil<>(LAQTemplate.class); +// List<LAQTemplate> laqTemplateList = util.importExcel(in); // 鐢熸垚鏂囦欢闆嗗悎 List<String> fileNameList = new ArrayList<>(); List<String> deleteStrList = new ArrayList<>(); - for (int i = 0; i < laqTemplateList.size(); i++) { - LAQTemplate laqTemplate = laqTemplateList.get(i); + for (int i = 0; i < 1; i++) { +// LAQTemplate laqTemplate = laqTemplateList.get(i); //缁勮鎶ュ憡鎵�鐢ㄦ暟鎹� - Map<String, String> textMap = new HashMap<>(); - textMap.put("sendEmailFileName",laqTemplate.getName()); - textMap.put("nowDate", DateUtils.getDate()); - MapDataUtil.objectToMap(laqTemplate,textMap); + Map<String, Object> textMap = new HashMap<>(); +// textMap.put("sendEmailFileName",laqTemplate.getName()); +// textMap.put("nowDate", DateUtils.getDate()); +// MapDataUtil.objectToMap(laqTemplate,textMap); + textMap.put("olas","50"); + textMap.put("ca","32"); + textMap.put("bla","34"); + textMap.put("nr","3"); + textMap.put("ar","45"); + textMap.put("open","67"); + textMap.put("cons","12"); + textMap.put("extra","48"); + textMap.put("agree","90"); + textMap.put("emosta","23"); +// textMap.put("perfomance","0"); + LAQReport report = new LAQReport(); // ReportResultData resultData = report.getTemplateParameters(textMap, ReportTypeEnum.LAQ, LangTypeEnum.codeOf("English")); @@ -71,7 +83,7 @@ // String zipFileName = WordUtil.makeReportFile("D:\\娴嬭瘎绯荤粺\\闇�姹俓\LAQ\\report\\LAQ鑻辨枃鎶ュ憡-20230926.docx", template, textMap, new HashMap<>(), deleteStrList); // fileNameList.add(zipFileName); ZipSecureFile.setMinInflateRatio(0.001); - try (OutputStream os = new FileOutputStream("D:\\娴嬭瘎绯荤粺\\闇�姹俓\2023\\5.棰嗗娼滃姏鎶ュ憡\\report\\LAQ缂栬瘧鎶ュ憡.docx");XWPFDocument document = new XWPFDocument(POIXMLDocument.openPackage("D:\\娴嬭瘎绯荤粺\\闇�姹俓\2023\\5.棰嗗娼滃姏鎶ュ憡\\report\\LAQ涓枃妯℃澘.docx"))){ + try (OutputStream os = new FileOutputStream("D:\\TaiOS\\LAQ-1.docx");XWPFDocument document = new XWPFDocument(POIXMLDocument.openPackage("D:\\TaiOS\\LAQ.docx"))){ Map<Integer,List<SeriesData>> seriesDatas = initData(textMap); changeChart(document,seriesDatas,textMap); document.write(os); @@ -81,7 +93,7 @@ log.info("鍒犻櫎鐨勬枃浠跺悕:{}", JSON.toJSONString(deleteStrList)); WordUtil.deleteFileByStr(deleteStrList); - }*/ + } } /** @@ -112,6 +124,13 @@ Double extra = Double.valueOf((String)textMap.get("extra")); Double agree = Double.valueOf((String)textMap.get("agree")); Double emosta = Double.valueOf((String)textMap.get("emosta")); + Double perfomance; + if(textMap.get("perfomance") != null){ + perfomance = Double.valueOf((String)textMap.get("perfomance")); + }else{ + perfomance = -1D; + } + // 鍥捐〃1 List<SeriesData> seriesDatas = Arrays.asList( @@ -267,6 +286,17 @@ ); seriesDataMap.put(10,seriesDatas); + // 鍥捐〃11 + seriesDatas = Arrays.asList( + new SeriesData("X 鍊�", Arrays.asList( + new RowData("X 鍊�", perfomance.doubleValue() == -1 ? perfomance.doubleValue() : olas.doubleValue()) + )), + new SeriesData("Y 鍊�", Arrays.asList( + new RowData("Y 鍊�", perfomance.doubleValue()) + )) + ); + seriesDataMap.put(11,seriesDatas); + return seriesDataMap; } @@ -318,7 +348,7 @@ //鏁g偣鍥� if (!plot.getScatterChartList().isEmpty()) { - List<SeriesData> seriesDatas = seriesDataMap.get(10); + List<SeriesData> seriesDatas = seriesDataMap.get(barIndex); CTScatterChart scatterChart = plot.getScatterChartArray(0); //System.out.println("鏁g偣鍥緖"+plot.getScatterChartList().size()+"}"); //鍒锋柊鍐呯疆excel鏁版嵁 @@ -335,13 +365,14 @@ updateScatterChart(seriesDatas, ser.getXVal(), ser.getYVal()); ++i; } + barIndex++; } } } } catch (Exception e) { e.printStackTrace(); - log.error("MAQTR鏇挎崲word鍥捐〃 鏁g偣鍥惧浘褰㈠け璐ワ細{}",e); + log.error("LAQ.鏇挎崲word鍥捐〃 鏁g偣鍥惧浘褰㈠け璐ワ細{}",e); } } @@ -421,7 +452,11 @@ if(StringUtils.isNotEmpty(cellValu.valueStr)){ cell.setCellValue(cellValu.valueStr); }else{ - cell.setCellValue(cellValu.value); + if(cellValu.value != -1){ + cell.setCellValue(cellValu.value); + }else{ + cell.setCellValue((String) null); + } } } @@ -466,7 +501,11 @@ CTNumVal val = xNumCnt > i ? xDataSource.getNumRef().getNumCache().getPtArray(i) : xDataSource.getNumRef().getNumCache().addNewPt(); val.setIdx(i); - val.setV(String.format("%.0f", cellValu.value)); + if(cellValu.value == -1){ + val.setV(null); + }else { + val.setV(String.format("%.0f", cellValu.value)); + } } //鏇存柊Y鍧愭爣缂撳瓨 @@ -475,7 +514,11 @@ CTNumVal val = yNumCnt > i ? yDataSource.getNumRef().getNumCache().getPtArray(i) : yDataSource.getNumRef().getNumCache().addNewPt(); val.setIdx(i); - val.setV(String.format("%.0f", cellValu.value)); + if(cellValu.value == -1){ + val.setV(null); + }else { + val.setV(String.format("%.0f", cellValu.value)); + } } // 鏇存柊瀵瑰簲excel鐨勮寖鍥� -- Gitblit v1.9.1