Bläddra i källkod

质量月报 - word下载表格部分

wangggziwen 1 år sedan
förälder
incheckning
2d99d931bb

+ 176 - 8
master/src/main/java/com/ruoyi/project/production/controller/TMonthlyQualityReportController.java

@@ -13,9 +13,7 @@ import com.ruoyi.project.system.service.ISysUserService;
 import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
 import org.apache.poi.ss.usermodel.*;
 import org.apache.poi.util.Units;
-import org.apache.poi.xwpf.usermodel.XWPFDocument;
-import org.apache.poi.xwpf.usermodel.XWPFParagraph;
-import org.apache.poi.xwpf.usermodel.XWPFRun;
+import org.apache.poi.xwpf.usermodel.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
@@ -2485,13 +2483,183 @@ public class TMonthlyQualityReportController extends BaseController
             byte[] decode = Base64.getDecoder().decode(base64Image[i]);
             // 在段落中添加图片
             run.addPicture(new ByteArrayInputStream(decode), XWPFDocument.PICTURE_TYPE_PNG, "chart"+ (i + 1) +".png", Units.toEMU(400), Units.toEMU(200));
-            // 换行
-            run.addBreak();
-            if (i == 9) {
-                // todo:c2 table
+            if (i == 0) {
+
+            } else if (i == 1) {
+
+            } else if (i == 2) {
+
+            } else if (i == 3) {
+
+            } else if (i == 4) {
+
+            } else if (i == 5) {
+
+            } else if (i == 6) {
+
+            } else if (i == 7) {
+
+            } else if (i == 8) {
+
+            } else if (i == 9) {
+                // 创建一个新的表格
+                XWPFTable table = document.createTable();
+
+                // 添加表格头行
+                XWPFTableRow headerRow = table.getRow(0);
+                headerRow.getCell(0).setText("BYC performance of C2 reactor");
+                headerRow.addNewTableCell().setText("");
+                headerRow.addNewTableCell().setText("");
+                headerRow.addNewTableCell().setText("");
+                headerRow.addNewTableCell().setText("");
+
+                // 添加表格数据行
+                XWPFTableRow dataRow1 = table.createRow();
+                dataRow1.getCell(0).setText("");
+                dataRow1.getCell(1).setText("1st inlet");
+                dataRow1.getCell(2).setText("2nd inlet");
+                dataRow1.getCell(3).setText("3rd inlet");
+                dataRow1.getCell(4).setText("3rd outlet");
+
+                XWPFTableRow dataRow2 = table.createRow();
+                dataRow2.getCell(0).setText("ethane");
+                dataRow2.getCell(1).setText(c2ReactorTableVO.getEthane1InAvg().toString());
+                dataRow2.getCell(2).setText(c2ReactorTableVO.getEthane2InAvg().toString());
+                dataRow2.getCell(3).setText(c2ReactorTableVO.getEthane3InAvg().toString());
+                dataRow2.getCell(4).setText(c2ReactorTableVO.getEthane3OutAvg().toString());
+
+                XWPFTableRow dataRow3 = table.createRow();
+                dataRow3.getCell(0).setText("ethylene");
+                dataRow3.getCell(1).setText(c2ReactorTableVO.getEthylene1InAvg().toString());
+                dataRow3.getCell(2).setText(c2ReactorTableVO.getEthylene2InAvg().toString());
+                dataRow3.getCell(3).setText(c2ReactorTableVO.getEthylene3InAvg().toString());
+                dataRow3.getCell(4).setText(c2ReactorTableVO.getEthylene3OutAvg().toString());
+
+                XWPFTableRow dataRow4 = table.createRow();
+                dataRow4.getCell(0).setText("acetylene");
+                dataRow4.getCell(1).setText(c2ReactorTableVO.getAcetylene1InAvg().toString());
+                dataRow4.getCell(2).setText(c2ReactorTableVO.getAcetylene2InAvg().toString());
+                dataRow4.getCell(3).setText(c2ReactorTableVO.getAcetylene3InAvg().toString());
+                dataRow4.getCell(4).setText(c2ReactorTableVO.getAcetylene3OutAvg().toString());
+
+                XWPFTableRow dataRow5 = table.createRow();
+                dataRow5.getCell(0).setText("propane");
+                dataRow5.getCell(1).setText(c2ReactorTableVO.getPropane1InAvg().toString());
+                dataRow5.getCell(2).setText(c2ReactorTableVO.getPropane2InAvg().toString());
+                dataRow5.getCell(3).setText(c2ReactorTableVO.getPropane3InAvg().toString());
+                dataRow5.getCell(4).setText(c2ReactorTableVO.getPropane3OutAvg().toString());
+
+                XWPFTableRow dataRow6 = table.createRow();
+                dataRow6.getCell(0).setText("propylene");
+                dataRow6.getCell(1).setText(c2ReactorTableVO.getPropylene1InAvg().toString());
+                dataRow6.getCell(2).setText(c2ReactorTableVO.getPropylene2InAvg().toString());
+                dataRow6.getCell(3).setText(c2ReactorTableVO.getPropylene3InAvg().toString());
+                dataRow6.getCell(4).setText(c2ReactorTableVO.getPropylene3OutAvg().toString());
+
+                XWPFTableRow dataRow7 = table.createRow();
+                dataRow7.getCell(0).setText("PD");
+                dataRow7.getCell(1).setText(c2ReactorTableVO.getPd1InAvg().toString());
+                dataRow7.getCell(2).setText(c2ReactorTableVO.getPd2InAvg().toString());
+                dataRow7.getCell(3).setText(c2ReactorTableVO.getPd3InAvg().toString());
+                dataRow7.getCell(4).setText(c2ReactorTableVO.getPd3OutAvg().toString());
+
+                XWPFTableRow dataRow8 = table.createRow();
+                dataRow8.getCell(0).setText("MA");
+                dataRow8.getCell(1).setText(c2ReactorTableVO.getMa1InAvg().toString());
+                dataRow8.getCell(2).setText(c2ReactorTableVO.getMa2InAvg().toString());
+                dataRow8.getCell(3).setText(c2ReactorTableVO.getMa3InAvg().toString());
+                dataRow8.getCell(4).setText(c2ReactorTableVO.getMa3OutAvg().toString());
+
+                XWPFTableRow dataRow9 = table.createRow();
+                dataRow9.getCell(0).setText("acetylene Conversion");
+                dataRow9.getCell(1).setText(c2ReactorTableVO.getAcetyleneConversion1stIn().toString());
+                dataRow9.getCell(2).setText(c2ReactorTableVO.getAcetyleneConversion2ndIn().toString());
+                dataRow9.getCell(3).setText(c2ReactorTableVO.getAcetyleneConversion3rdIn().toString());
+                dataRow9.getCell(4).setText(c2ReactorTableVO.getAcetyleneConversion3rdOut().toString());
+
+                XWPFTableRow dataRow10 = table.createRow();
+                dataRow10.getCell(0).setText("Conversion load%");
+                dataRow10.getCell(1).setText(c2ReactorTableVO.getConversionLoad1stIn().toString());
+                dataRow10.getCell(2).setText(c2ReactorTableVO.getConversionLoad2ndIn().toString());
+                dataRow10.getCell(3).setText(c2ReactorTableVO.getConversionLoad3rdIn().toString());
+                dataRow10.getCell(4).setText("");
+
+                XWPFTableRow dataRow11 = table.createRow();
+                dataRow11.getCell(0).setText("Ethylene Selectivity");
+                dataRow11.getCell(1).setText(c2ReactorTableVO.getEthyleneSelectivity1stIn().toString());
+                dataRow11.getCell(2).setText(c2ReactorTableVO.getEthyleneSelectivity2ndIn().toString());
+                dataRow11.getCell(3).setText(c2ReactorTableVO.getEthyleneSelectivity3rdIn().toString());
+                dataRow11.getCell(4).setText(c2ReactorTableVO.getEthyleneSelectivity3rdOut().toString());
+
+                XWPFTableRow dataRow12 = table.createRow();
+                dataRow12.getCell(0).setText("MAPD Conversion");
+                dataRow12.getCell(1).setText(c2ReactorTableVO.getMapdConversion1stIn().toString() + "%");
+                dataRow12.getCell(2).setText(c2ReactorTableVO.getMapdConversion2ndIn().toString() + "%");
+                dataRow12.getCell(3).setText(c2ReactorTableVO.getMapdConversion3rdIn().toString() + "%");
+                dataRow12.getCell(4).setText(c2ReactorTableVO.getMapdConversion3rdOut().toString() + "%");
+
+                XWPFTableRow dataRow13 = table.createRow();
+                dataRow13.getCell(0).setText("Propylene Selectivity");
+                dataRow13.getCell(1).setText(c2ReactorTableVO.getPropyleneSelectivity1stIn().toString() + "%");
+                dataRow13.getCell(2).setText(c2ReactorTableVO.getPropyleneSelectivity2ndIn().toString() + "%");
+                dataRow13.getCell(3).setText(c2ReactorTableVO.getPropyleneSelectivity3rdIn().toString() + "%");
+                dataRow13.getCell(4).setText(c2ReactorTableVO.getPropyleneSelectivity3rdOut().toString() + "%");
             } else if (i == 10) {
-                // todo:c3 table
+                // 创建一个新的表格
+                XWPFTable table = document.createTable();
+
+                // 添加表格头行
+                XWPFTableRow headerRow = table.getRow(0);
+                headerRow.getCell(0).setText("BYC performance of C3 reactor");
+                headerRow.addNewTableCell().setText("");
+                headerRow.addNewTableCell().setText("R520B");
+
+                // 添加表格数据行
+                XWPFTableRow dataRow1 = table.createRow();
+                dataRow1.getCell(0).setText("");
+                dataRow1.getCell(1).setText("reactor inlet");
+                dataRow1.getCell(2).setText("reactor outlet");
+
+                XWPFTableRow dataRow2 = table.createRow();
+                dataRow2.getCell(0).setText("propane");
+                dataRow2.getCell(1).setText(c3ReactorTableVO.getPropaneInAvg().toString());
+                dataRow2.getCell(2).setText(c3ReactorTableVO.getPropaneOutAvg().toString());
+
+                XWPFTableRow dataRow3 = table.createRow();
+                dataRow3.getCell(0).setText("propylene");
+                dataRow3.getCell(1).setText(c3ReactorTableVO.getPropyleneInAvg().toString());
+                dataRow3.getCell(2).setText(c3ReactorTableVO.getPropyleneOutAvg().toString());
+
+                XWPFTableRow dataRow4 = table.createRow();
+                dataRow4.getCell(0).setText("PD");
+                dataRow4.getCell(1).setText(c3ReactorTableVO.getPdInAvg().toString());
+                dataRow4.getCell(2).setText(c3ReactorTableVO.getPdOutAvg().toString());
+
+                XWPFTableRow dataRow5 = table.createRow();
+                dataRow5.getCell(0).setText("MA");
+                dataRow5.getCell(1).setText(c3ReactorTableVO.getMaInAvg().toString());
+                dataRow5.getCell(2).setText(c3ReactorTableVO.getMaOutAvg().toString());
+
+                XWPFTableRow dataRow6 = table.createRow();
+                dataRow6.getCell(0).setText("conversion");
+                dataRow6.getCell(1).setText(c3ReactorTableVO.getConversion().toString() + "%");
+                dataRow6.getCell(2).setText("");
+
+                XWPFTableRow dataRow7 = table.createRow();
+                dataRow7.getCell(0).setText("Propylene Selectivity");
+                dataRow7.getCell(1).setText(c3ReactorTableVO.getPropyleneSelectivity().toString() + "%");
+                dataRow7.getCell(2).setText("");
+            } else if (i == 11) {
+
+            } else if (i == 12) {
+
+            } else if (i == 13) {
+
+            } else if (i == 14) {
+
             }
+            // 换行
+//            run.addBreak();
         }
         // 保存文档
         String fileName = UUID.randomUUID().toString() + "_" + "质量月报.docx";