Prechádzať zdrojové kódy

LY 特种设备 报告

ly 1 rok pred
rodič
commit
ff5565185b

+ 1 - 1
master/pom.xml

@@ -6,7 +6,7 @@
     <groupId>com.cpms</groupId>
     <artifactId>cpms</artifactId>
     <version>3.2.0</version>
-    <packaging>war</packaging>
+    <packaging>jar</packaging>
 
     <name>cpms</name>
     <description>cpms管理系统</description>

+ 14 - 0
master/src/main/java/com/ruoyi/project/sems/mapper/TSpecReportMapper.java

@@ -34,6 +34,20 @@ public interface TSpecReportMapper
     public List<TSpecReport> selectExpriedDt(TSpecReport tSpecReport);
     public List<TSpecReport> selectExpriedDzsb(TSpecReport tSpecReport);
     public List<TSpecReport> selectExpriedCc(TSpecReport tSpecReport);
+
+    public List<TSpecReport> selectExpriedYlrq3(TSpecReport tSpecReport);
+    public List<TSpecReport> selectExpriedYlgd3(TSpecReport tSpecReport);
+    public List<TSpecReport> selectExpriedGl3(TSpecReport tSpecReport);
+    public List<TSpecReport> selectExpriedDt3(TSpecReport tSpecReport);
+    public List<TSpecReport> selectExpriedDzsb3(TSpecReport tSpecReport);
+    public List<TSpecReport> selectExpriedCc3(TSpecReport tSpecReport);
+
+    public List<TSpecReport> selectExpriedYlrqHi(TSpecReport tSpecReport);
+    public List<TSpecReport> selectExpriedYlgdHi(TSpecReport tSpecReport);
+    public List<TSpecReport> selectExpriedGlHi(TSpecReport tSpecReport);
+    public List<TSpecReport> selectExpriedDtHi(TSpecReport tSpecReport);
+    public List<TSpecReport> selectExpriedDzsbHi(TSpecReport tSpecReport);
+    public List<TSpecReport> selectExpriedCcHi(TSpecReport tSpecReport);
     /**
      * 新增特种设备报告
      *

+ 285 - 51
master/src/main/java/com/ruoyi/project/sems/service/impl/TSpecReportServiceImpl.java

@@ -5,7 +5,9 @@ import java.io.FileOutputStream;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.net.URLEncoder;
+import java.time.LocalDate;
 import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
@@ -13,6 +15,8 @@ import java.util.List;
 import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.ruoyi.common.constant.Constants;
+import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.framework.config.RuoYiConfig;
 import com.ruoyi.framework.web.controller.BaseController;
 import com.ruoyi.project.plant.domain.TStaffmgr;
@@ -41,8 +45,7 @@ import javax.servlet.http.HttpServletResponse;
  * @date 2024-07-17
  */
 @Service
-public class TSpecReportServiceImpl implements ITSpecReportService
-{
+public class TSpecReportServiceImpl implements ITSpecReportService {
     @Resource
     private TSpecReportMapper tSpecReportMapper;
     @Autowired
@@ -59,6 +62,7 @@ public class TSpecReportServiceImpl implements ITSpecReportService
     private ITSpecdevCcService tSpecdevCcService;
 
     protected final Logger logger = LoggerFactory.getLogger(BaseController.class);
+
     /**
      * 查询特种设备报告
      *
@@ -66,8 +70,7 @@ public class TSpecReportServiceImpl implements ITSpecReportService
      * @return 特种设备报告
      */
     @Override
-    public TSpecReport selectTSpecReportById(Long id)
-    {
+    public TSpecReport selectTSpecReportById(Long id) {
         return tSpecReportMapper.selectTSpecReportById(id);
     }
 
@@ -78,8 +81,7 @@ public class TSpecReportServiceImpl implements ITSpecReportService
      * @return 特种设备报告
      */
     @Override
-    public List<TSpecReport> selectTSpecReportList(TSpecReport tSpecReport)
-    {
+    public List<TSpecReport> selectTSpecReportList(TSpecReport tSpecReport) {
         return tSpecReportMapper.selectTSpecReportList(tSpecReport);
     }
 
@@ -91,20 +93,21 @@ public class TSpecReportServiceImpl implements ITSpecReportService
      */
     @Override
     @Transactional
-    public int insertTSpecReport(TSpecReport tSpecReport, HttpServletResponse response)
-    {
+    public int insertTSpecReport(TSpecReport tSpecReport, HttpServletResponse response) {
         tSpecReportMapper.insertTSpecReport(tSpecReport);
         try {
             String tempUrl = "static/word/sems/report/sems-report.xlsx"; // 模板文件
             // 生成的路径
-            String fileDir = RuoYiConfig.getProfile() + "/" + "sems/spec-sems";
+            String fileDir = RuoYiConfig.getProfile() + "/" + "sems/spec-report";
             InputStream is = null;
             is = Thread.currentThread().getContextClassLoader().getResourceAsStream(tempUrl);
             XSSFWorkbook wb1 = new XSSFWorkbook(is);
-
             SXSSFWorkbook wb = new SXSSFWorkbook(wb1, 1000);
             // 替换excel模板数据
             replaceExcel(wb);
+            //从下往上渲染
+            replaceExcelByHi(wb);
+            replaceExcelExpireByThreeMonth(wb);
             replaceExcelExpire(wb);
             // Save the generated file
             File dir = new File(fileDir);
@@ -113,16 +116,180 @@ public class TSpecReportServiceImpl implements ITSpecReportService
                 dir.mkdirs();
             }
             FileOutputStream fos = null;
-            String filePath = fileDir + "/" + tSpecReport.getId() + "semsReport.xlsx";
+            LocalDate currentDate = LocalDate.now();
+            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
+            String dateStr = currentDate.format(formatter);
+            String filePath = fileDir + "/" + dateStr + "Report" + tSpecReport.getId() +".xlsx";
             fos = new FileOutputStream(filePath);
             wb.write(fos);
-
+            //
+            int dirLastIndex = RuoYiConfig.getProfile().length() + 1;
+            String currentDir = StringUtils.substring(filePath, dirLastIndex);
+            String pathFileName = Constants.RESOURCE_PREFIX + "/" + currentDir ;
+            tSpecReport.setReportUrl(pathFileName);
+            tSpecReport.setReportName(dateStr + "报告");
+            tSpecReportMapper.updateTSpecReport(tSpecReport);
         } catch (Exception e) {
             e.printStackTrace();
         }
         return 1;
     }
 
+    //数量变更说明(基于与上一个月数据对比)渲染
+    private void replaceExcelByHi(SXSSFWorkbook wb) {
+        Sheet sheet;
+        if (wb instanceof SXSSFWorkbook) {
+            SXSSFWorkbook sxssfWorkbook = (SXSSFWorkbook) wb;
+            sheet = sxssfWorkbook.getXSSFWorkbook().getSheetAt(0);
+        } else {
+            sheet = wb.getSheetAt(0);
+        }
+        List<Integer> numArr = new ArrayList<>();
+        List<TSpecReport> ylrqList = tSpecReportMapper.selectExpriedYlrqHi(new TSpecReport());
+        numArr.add(ylrqList.size());
+        logger.info(JSON.toJSONString(ylrqList));
+        Row row = sheet.getRow(13);
+        Cell cell = row.getCell(1);
+        // 获取单元格样式
+        CellStyle originalStyle = cell.getCellStyle();
+        cell.setCellStyle(originalStyle);
+        cell.setCellValue(getDevTotal(ylrqList));
+
+        List<TSpecReport> ylgdList = tSpecReportMapper.selectExpriedYlgdHi(new TSpecReport());
+        numArr.add(ylgdList.size());
+        logger.info(JSON.toJSONString(ylgdList));
+        Row row2 = sheet.getRow(13);
+        Cell cell2 = row2.getCell(4);
+        cell2.setCellValue(getDevTotal(ylgdList));
+
+        List<TSpecReport> glList = tSpecReportMapper.selectExpriedGlHi(new TSpecReport());
+        numArr.add(glList.size());
+        logger.info(JSON.toJSONString(glList));
+        Row row3 = sheet.getRow(13);
+        Cell cell3 = row3.getCell(7);
+        cell3.setCellValue(getDevTotal(glList));
+
+        List<TSpecReport> dtList = tSpecReportMapper.selectExpriedDtHi(new TSpecReport());
+        numArr.add(dtList.size());
+        logger.info(JSON.toJSONString(dtList));
+        Row row4 = sheet.getRow(13);
+        Cell cell4 = row4.getCell(10);
+        cell4.setCellValue(getDevTotal(dtList));
+
+        List<TSpecReport> dzsbList = tSpecReportMapper.selectExpriedDzsbHi(new TSpecReport());
+        numArr.add(dzsbList.size());
+        logger.info(JSON.toJSONString(dzsbList));
+        Row row5 = sheet.getRow(13);
+        Cell cell5 = row5.getCell(13);
+        cell5.setCellValue(getDevTotal(dzsbList));
+
+        List<TSpecReport> ccList = tSpecReportMapper.selectExpriedCcHi(new TSpecReport());
+        numArr.add(ccList.size());
+        logger.info(JSON.toJSONString(ccList));
+        Row row6 = sheet.getRow(8);
+        Cell cell6 = row6.getCell(16);
+        cell6.setCellValue(getDevTotal(ccList));
+
+        int maxNum = findMaxValue(numArr);
+        int needNum = maxNum - 3 > 0 ? maxNum - 3 : 0;
+        for (int i = 0; i < needNum; i++) {
+            sheet.shiftRows(16, sheet.getLastRowNum(), 1);
+            cpoyRow(16, sheet);
+        }
+        // 合并区域从第0行第0列到第0行第3列
+        CellRangeAddress mergedRegion = new CellRangeAddress(
+                13, // 起始行
+                needNum + 17, // 结束行
+                0, // 起始列
+                0  // 结束列
+        );
+        sheet.addMergedRegion(mergedRegion);
+
+        renderCell(wb,sheet,ylrqList,14,1  );
+        renderCell(wb,sheet,ylgdList,14,4);
+        renderCell(wb,sheet,glList,14,7);
+        renderCell(wb,sheet,dtList,14,10);
+        renderCell(wb,sheet,dzsbList,14,13);
+        renderCell(wb,sheet,ccList,14,16);
+    }
+
+    //三个月到期渲染
+    private void replaceExcelExpireByThreeMonth(SXSSFWorkbook wb) {
+        Sheet sheet;
+        if (wb instanceof SXSSFWorkbook) {
+            SXSSFWorkbook sxssfWorkbook = (SXSSFWorkbook) wb;
+            sheet = sxssfWorkbook.getXSSFWorkbook().getSheetAt(0);
+        } else {
+            sheet = wb.getSheetAt(0);
+        }
+        List<Integer> numArr = new ArrayList<>();
+        List<TSpecReport> ylrqList = tSpecReportMapper.selectExpriedYlrq3(new TSpecReport());
+        numArr.add(ylrqList.size());
+        logger.info(JSON.toJSONString(ylrqList));
+        Row row = sheet.getRow(8);
+        Cell cell = row.getCell(1);
+        // 获取单元格样式
+        CellStyle originalStyle = cell.getCellStyle();
+        cell.setCellStyle(originalStyle);
+        cell.setCellValue(getDevTotal(ylrqList));
+
+        List<TSpecReport> ylgdList = tSpecReportMapper.selectExpriedYlgd3(new TSpecReport());
+        numArr.add(ylgdList.size());
+        logger.info(JSON.toJSONString(ylgdList));
+        Row row2 = sheet.getRow(8);
+        Cell cell2 = row2.getCell(4);
+        cell2.setCellValue(getDevTotal(ylgdList));
+
+        List<TSpecReport> glList = tSpecReportMapper.selectExpriedGl3(new TSpecReport());
+        numArr.add(glList.size());
+        logger.info(JSON.toJSONString(glList));
+        Row row3 = sheet.getRow(8);
+        Cell cell3 = row3.getCell(7);
+        cell3.setCellValue(getDevTotal(glList));
+
+        List<TSpecReport> dtList = tSpecReportMapper.selectExpriedDt3(new TSpecReport());
+        numArr.add(dtList.size());
+        logger.info(JSON.toJSONString(dtList));
+        Row row4 = sheet.getRow(8);
+        Cell cell4 = row4.getCell(10);
+        cell4.setCellValue(getDevTotal(dtList));
+
+        List<TSpecReport> dzsbList = tSpecReportMapper.selectExpriedDzsb3(new TSpecReport());
+        numArr.add(dzsbList.size());
+        logger.info(JSON.toJSONString(dzsbList));
+        Row row5 = sheet.getRow(8);
+        Cell cell5 = row5.getCell(13);
+        cell5.setCellValue(getDevTotal(dzsbList));
+
+        List<TSpecReport> ccList = tSpecReportMapper.selectExpriedCc3(new TSpecReport());
+        numArr.add(ccList.size());
+        logger.info(JSON.toJSONString(ccList));
+        Row row6 = sheet.getRow(8);
+        Cell cell6 = row6.getCell(16);
+        cell6.setCellValue(getDevTotal(ccList));
+
+        int maxNum = findMaxValue(numArr);
+        int needNum = maxNum - 3 > 0 ? maxNum - 3 : 0;
+        for (int i = 0; i < needNum; i++) {
+            sheet.shiftRows(11, sheet.getLastRowNum(), 1);
+            cpoyRow(11, sheet);
+        }
+        // 合并区域从第0行第0列到第0行第3列
+        CellRangeAddress mergedRegion = new CellRangeAddress(
+                8, // 起始行
+                needNum + 12, // 结束行
+                0, // 起始列
+                0  // 结束列
+        );
+        sheet.addMergedRegion(mergedRegion);
+
+        renderCell(wb,sheet,ylrqList,10,1  );
+        renderCell(wb,sheet,ylgdList,10,4);
+        renderCell(wb,sheet,glList,10,7);
+        renderCell(wb,sheet,dtList,10,10);
+        renderCell(wb,sheet,dzsbList,10,13);
+        renderCell(wb,sheet,ccList,10,16);
+    }
     //过期渲染
     private void replaceExcelExpire(SXSSFWorkbook wb) {
         Sheet sheet;
@@ -132,7 +299,9 @@ public class TSpecReportServiceImpl implements ITSpecReportService
         } else {
             sheet = wb.getSheetAt(0);
         }
-        List<TSpecReport> ylrqList =  tSpecReportMapper.selectExpriedYlrq(new TSpecReport());
+        List<Integer> numArr = new ArrayList<>();
+        List<TSpecReport> ylrqList = tSpecReportMapper.selectExpriedYlrq(new TSpecReport());
+        numArr.add(ylrqList.size());
         logger.info(JSON.toJSONString(ylrqList));
         Row row = sheet.getRow(3);
         Cell cell = row.getCell(1);
@@ -141,55 +310,64 @@ public class TSpecReportServiceImpl implements ITSpecReportService
         cell.setCellStyle(originalStyle);
         cell.setCellValue(getDevTotal(ylrqList));
 
-        List<TSpecReport> ylgdList =  tSpecReportMapper.selectExpriedYlgd(new TSpecReport());
+        List<TSpecReport> ylgdList = tSpecReportMapper.selectExpriedYlgd(new TSpecReport());
+        numArr.add(ylgdList.size());
         logger.info(JSON.toJSONString(ylgdList));
         Row row2 = sheet.getRow(3);
         Cell cell2 = row2.getCell(4);
         cell2.setCellValue(getDevTotal(ylgdList));
 
-        List<TSpecReport> glList =  tSpecReportMapper.selectExpriedGl(new TSpecReport());
+        List<TSpecReport> glList = tSpecReportMapper.selectExpriedGl(new TSpecReport());
+        numArr.add(glList.size());
         logger.info(JSON.toJSONString(glList));
         Row row3 = sheet.getRow(3);
         Cell cell3 = row3.getCell(7);
         cell3.setCellValue(getDevTotal(glList));
 
-        List<TSpecReport> dtList =  tSpecReportMapper.selectExpriedDt(new TSpecReport());
+        List<TSpecReport> dtList = tSpecReportMapper.selectExpriedDt(new TSpecReport());
+        numArr.add(dtList.size());
         logger.info(JSON.toJSONString(dtList));
         Row row4 = sheet.getRow(3);
         Cell cell4 = row4.getCell(10);
         cell4.setCellValue(getDevTotal(dtList));
 
-        List<TSpecReport> dzsbList =  tSpecReportMapper.selectExpriedDzsb(new TSpecReport());
+        List<TSpecReport> dzsbList = tSpecReportMapper.selectExpriedDzsb(new TSpecReport());
+        numArr.add(dzsbList.size());
         logger.info(JSON.toJSONString(dzsbList));
         Row row5 = sheet.getRow(3);
         Cell cell5 = row5.getCell(13);
         cell5.setCellValue(getDevTotal(dzsbList));
 
-        List<TSpecReport> ccList =  tSpecReportMapper.selectExpriedCc(new TSpecReport());
+        List<TSpecReport> ccList = tSpecReportMapper.selectExpriedCc(new TSpecReport());
+        numArr.add(ccList.size());
         logger.info(JSON.toJSONString(ccList));
         Row row6 = sheet.getRow(3);
         Cell cell6 = row6.getCell(16);
         cell6.setCellValue(getDevTotal(ccList));
 
-        sheet.shiftRows(6, sheet.getLastRowNum(), 1);
-        cpoyRow(6 ,sheet );
-        sheet.shiftRows(6, sheet.getLastRowNum(), 1);
-        cpoyRow(6 ,sheet );
-        sheet.shiftRows(6, sheet.getLastRowNum(), 1);
-        cpoyRow(6 ,sheet );
-        sheet.shiftRows(6, sheet.getLastRowNum(), 1);
-        cpoyRow(6 ,sheet );
-        sheet.shiftRows(6, sheet.getLastRowNum(), 1);
-        cpoyRow(6 ,sheet );
+        int maxNum = findMaxValue(numArr);
+        int needNum = maxNum - 3 > 0 ? maxNum - 3 : 0;
+        for (int i = 0; i < needNum; i++) {
+            sheet.shiftRows(6, sheet.getLastRowNum(), 1);
+            cpoyRow(6, sheet);
+        }
         // 合并区域从第0行第0列到第0行第3列
         CellRangeAddress mergedRegion = new CellRangeAddress(
                 3, // 起始行
-                12, // 结束行
+                needNum + 7, // 结束行
                 0, // 起始列
                 0  // 结束列
         );
         sheet.addMergedRegion(mergedRegion);
+
+        renderCell(wb,sheet,ylrqList,5,1  );
+        renderCell(wb,sheet,ylgdList,5,4);
+        renderCell(wb,sheet,glList,5,7);
+        renderCell(wb,sheet,dtList,5,10);
+        renderCell(wb,sheet,dzsbList,5,13);
+        renderCell(wb,sheet,ccList,5,16);
     }
+
     // Excel 渲染
     private void replaceExcel(SXSSFWorkbook wb) {
         Sheet sheet;
@@ -201,8 +379,8 @@ public class TSpecReportServiceImpl implements ITSpecReportService
         }
         //压力容器
         int ylrqAll = tSpecdevYlrqService.count(new QueryWrapper<TSpecdevYlrq>()
-                .eq("STATUS" , 1)
-                .eq("del_flag" , 0)
+                .eq("STATUS", 1)
+                .eq("del_flag", 0)
         );
         Row row = sheet.getRow(2);
         Cell cell = row.getCell(1);
@@ -213,8 +391,8 @@ public class TSpecReportServiceImpl implements ITSpecReportService
 
         //压力管道
         int ylgdAll = tSpecdevYlgdService.count(new QueryWrapper<TSpecdevYlgd>()
-                        .eq("STATUS" , 1)
-                        .eq("del_flag" , 0)
+                .eq("STATUS", 1)
+                .eq("del_flag", 0)
         );
         Row row2 = sheet.getRow(2);
         Cell cell2 = row2.getCell(4);
@@ -222,8 +400,8 @@ public class TSpecReportServiceImpl implements ITSpecReportService
         cell2.setCellValue(ylgdAll + "(条)");
         //锅炉
         int glAll = tSpecdevGlService.count(new QueryWrapper<TSpecdevGl>()
-                        .eq("STATUS" , 1)
-                        .eq("del_flag" , 0)
+                .eq("STATUS", 1)
+                .eq("del_flag", 0)
         );
         Row row3 = sheet.getRow(2);
         Cell cell3 = row3.getCell(7);
@@ -231,8 +409,8 @@ public class TSpecReportServiceImpl implements ITSpecReportService
         cell3.setCellValue(glAll + "(套)");
         //电梯
         int dtAll = tSpecdevDtService.count(new QueryWrapper<TSpecdevDt>()
-                        .eq("STATUS" , 1)
-                        .eq("del_flag" , 0)
+                .eq("STATUS", 1)
+                .eq("del_flag", 0)
         );
         Row row4 = sheet.getRow(2);
         Cell cell4 = row4.getCell(10);
@@ -240,8 +418,8 @@ public class TSpecReportServiceImpl implements ITSpecReportService
         cell4.setCellValue(dtAll + "(台)");
         //吊装设备
         int dzsbAll = tSpecdevDzsbService.count(new QueryWrapper<TSpecdevDzsb>()
-                        .eq("STATUS" , 1)
-                        .eq("del_flag" , 0)
+                .eq("STATUS", 1)
+                .eq("del_flag", 0)
         );
         Row row5 = sheet.getRow(2);
         Cell cell5 = row5.getCell(13);
@@ -249,8 +427,8 @@ public class TSpecReportServiceImpl implements ITSpecReportService
         cell5.setCellValue(dzsbAll + "(条)");
         //叉车
         int ccAll = tSpecdevCcService.count(new QueryWrapper<TSpecdevCc>()
-                        .eq("STATUS" , 1)
-                        .eq("del_flag" , 0)
+                .eq("STATUS", 1)
+                .eq("del_flag", 0)
         );
         Row row6 = sheet.getRow(2);
         Cell cell6 = row6.getCell(16);
@@ -259,17 +437,18 @@ public class TSpecReportServiceImpl implements ITSpecReportService
 
     }
 
-    private int getDevTotal (List<TSpecReport> list){
+    private int getDevTotal(List<TSpecReport> list) {
         int num = 0;
         for (TSpecReport t : list
-             ) {
+        ) {
             num = num + t.getDevNum();
         }
         return num;
     }
-    void cpoyRow (int rowNum ,Sheet sheet ){
+
+    void cpoyRow(int rowNum, Sheet sheet) {
         Row newRow = sheet.createRow(rowNum);
-        Row oldRow = sheet.getRow(rowNum+1);
+        Row oldRow = sheet.getRow(rowNum + 1);
         for (int i = 0; i < 22; i++) {
             Cell newCell = newRow.createCell(i);
             Cell oldCell = oldRow.getCell(i);
@@ -277,6 +456,64 @@ public class TSpecReportServiceImpl implements ITSpecReportService
             newCell.setCellStyle(originalStyle);
         }
     }
+
+    public int findMaxValue(List<Integer> list) {
+        // Assume the first element is the largest
+        int max = list.get(0);
+
+        // Loop through the list starting from the second element
+        for (int i = 1; i < list.size(); i++) {
+            if (list.get(i) > max) {
+                max = list.get(i);
+            }
+        }
+
+        return max;
+    }
+
+    public void renderCell(SXSSFWorkbook wb ,Sheet sheet,List<TSpecReport> list ,int startRow, int startCol ) {
+        int num = 0;
+        Font font = wb.createFont();
+        font.setFontHeightInPoints((short) 9); // 设置字体大小为12
+        font.setBold(false);
+        for (TSpecReport t: list
+             ) {
+            //装置
+            logger.info("开始渲染行:" + startRow +"开始渲染列:" + (startCol + num));
+            Row row = sheet.getRow(startRow + num);
+            Cell cell = row.getCell(startCol);
+            // 获取单元格样式
+            CellStyle originalStyle = cell.getCellStyle();
+            originalStyle.setFont(font);
+            cell.setCellStyle(originalStyle);
+            cell.setCellValue(t.getPlantCode());
+
+            //数量
+            logger.info("开始渲染行:" + startRow + num +"开始渲染列:" + startCol + 1);
+            Row row2 = sheet.getRow(startRow + num);
+            Cell cell2 = row2.getCell(startCol + 1);
+            // 获取单元格样式
+            originalStyle = cell2.getCellStyle();
+            originalStyle.setFont(font);
+            cell2.setCellStyle(originalStyle);
+            cell2.setCellValue(t.getDevNum());
+
+            //备注
+            logger.info("开始渲染行:" + startRow + num +"开始渲染列:" + startCol + 2 );
+            Row row3 = sheet.getRow(startRow + num);
+            Cell cell3 = row3.getCell(startCol + 2);
+            // 获取单元格样式
+            originalStyle = cell3.getCellStyle();
+            originalStyle.setFont(font);
+            cell3.setCellStyle(originalStyle);
+            if (t.getRemarks() != null) {
+                cell3.setCellValue(t.getRemarks().replace("-通过","").replace("批准",""));
+            }
+            num++;
+        }
+
+    };
+
     /**
      * 修改特种设备报告
      *
@@ -284,8 +521,7 @@ public class TSpecReportServiceImpl implements ITSpecReportService
      * @return 结果
      */
     @Override
-    public int updateTSpecReport(TSpecReport tSpecReport)
-    {
+    public int updateTSpecReport(TSpecReport tSpecReport) {
         return tSpecReportMapper.updateTSpecReport(tSpecReport);
     }
 
@@ -296,8 +532,7 @@ public class TSpecReportServiceImpl implements ITSpecReportService
      * @return 结果
      */
     @Override
-    public int deleteTSpecReportByIds(Long[] ids)
-    {
+    public int deleteTSpecReportByIds(Long[] ids) {
         return tSpecReportMapper.deleteTSpecReportByIds(ids);
     }
 
@@ -308,8 +543,7 @@ public class TSpecReportServiceImpl implements ITSpecReportService
      * @return 结果
      */
     @Override
-    public int deleteTSpecReportById(Long id)
-    {
+    public int deleteTSpecReportById(Long id) {
         return tSpecReportMapper.deleteTSpecReportById(id);
     }
 }

+ 6 - 1
master/src/main/java/com/ruoyi/project/training/elearn/controller/TElUserBookController.java

@@ -80,11 +80,16 @@ public class TElUserBookController extends BaseController
 
         if (book.getQuId() == null) { //答题第一题
 
+        }else {
+          List<TElUserBook> list =  tElUserBookMapper.selectTElUserBookList(book);
+            if (list.size() >0) {
+                book.setUpdatedate(list.get(0).getUpdatedate());
+            }
         }
         //继续答题
         TElUserBook userbook =  tElUserBookMapper.selectTElUserBookByLast(book);
         if (userbook == null) {
-            AjaxResult.error("已经是最后一题");
+            return  AjaxResult.error("已经是最后一题");
         }
         return AjaxResult.success(userbook.getQuId());
     }

+ 76 - 1
master/src/main/resources/mybatis/sems/TSpecReportMapper.xml

@@ -41,7 +41,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             and d.del_flag = 0
         </where>
         <!-- 数据范围过滤 -->
-        ${params.dataScope}
+        order by d.createdate desc
     </select>
 
     <select id="selectExpriedYlrq" parameterType="TSpecReport" resultMap="TSpecReportResult">
@@ -82,6 +82,81 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </select>
 
 
+    <select id="selectExpriedYlrq3" parameterType="TSpecReport" resultMap="TSpecReportResult">
+        SELECT plant_code as plantCode, COUNT(*) as devNum
+        FROM T_SPECDEV_YLRQ
+        WHERE SYSDATE + INTERVAL '3' MONTH   >  NEXT_WARN_DATE and DEL_FLAG = 0 and STATUS = 1
+        GROUP BY plant_code
+    </select>
+    <select id="selectExpriedYlgd3" parameterType="TSpecReport" resultMap="TSpecReportResult">
+        SELECT plant_code as plantCode, COUNT(*) as devNum
+        FROM T_SPECDEV_YLGD
+        WHERE SYSDATE + INTERVAL '3' MONTH   >  NEXT_WARN_DATE and DEL_FLAG = 0 and STATUS = 1
+        GROUP BY plant_code
+    </select>
+    <select id="selectExpriedGl3" parameterType="TSpecReport" resultMap="TSpecReportResult">
+        SELECT plant_code as plantCode, COUNT(*) as devNum
+        FROM T_SPECDEV_GL
+        WHERE SYSDATE+ INTERVAL '3' MONTH   >  NEXT_WARN_DATE and DEL_FLAG = 0 and STATUS = 1
+        GROUP BY plant_code
+    </select>
+    <select id="selectExpriedDt3" parameterType="TSpecReport" resultMap="TSpecReportResult">
+        SELECT plant_code as plantCode, COUNT(*) as devNum
+        FROM T_SPECDEV_DT
+        WHERE SYSDATE+ INTERVAL '3' MONTH   >  NEXT_WARN_DATE and DEL_FLAG = 0 and STATUS = 1
+        GROUP BY plant_code
+    </select>
+    <select id="selectExpriedDzsb3" parameterType="TSpecReport" resultMap="TSpecReportResult">
+        SELECT plant_code as plantCode, COUNT(*) as devNum
+        FROM T_SPECDEV_DZSB
+        WHERE SYSDATE+ INTERVAL '3' MONTH   >  NEXT_WARN_DATE and DEL_FLAG = 0 and STATUS = 1
+        GROUP BY plant_code
+    </select>
+    <select id="selectExpriedCc3" parameterType="TSpecReport" resultMap="TSpecReportResult">
+        SELECT plant_code as plantCode, COUNT(*) as devNum
+        FROM T_SPECDEV_CC
+        WHERE SYSDATE+ INTERVAL '3' MONTH   >  NEXT_WARN_DATE and DEL_FLAG = 0 and STATUS = 1
+        GROUP BY plant_code
+    </select>
+
+    <select id="selectExpriedYlrqHi" parameterType="TSpecReport" resultMap="TSpecReportResult">
+        SELECT plant_code AS plantCode, COUNT(*) AS devNum, OPER_TYPE AS remarks
+        FROM T_SPECHI_YLRQ
+        WHERE OPER_TIME >= SYSDATE - INTERVAL '1' MONTH and OPER_TYPE in ('新增-通过','删除-通过','停用批准','注销批准')
+        GROUP BY plant_code,OPER_TYPE
+    </select>
+    <select id="selectExpriedYlgdHi" parameterType="TSpecReport" resultMap="TSpecReportResult">
+        SELECT plant_code AS plantCode, COUNT(*) AS devNum, OPER_TYPE AS remarks
+        FROM T_SPECHI_YLGD
+        WHERE OPER_TIME >= SYSDATE - INTERVAL '1' MONTH and OPER_TYPE in ('新增-通过','删除-通过','停用批准','注销批准')
+        GROUP BY plant_code,OPER_TYPE
+    </select>
+    <select id="selectExpriedGlHi" parameterType="TSpecReport" resultMap="TSpecReportResult">
+        SELECT plant_code AS plantCode, COUNT(*) AS devNum, OPER_TYPE AS remarks
+        FROM T_SPECHI_GL
+        WHERE OPER_TIME >= SYSDATE - INTERVAL '1' MONTH and OPER_TYPE in ('新增-通过','删除-通过','停用批准','注销批准')
+        GROUP BY plant_code,OPER_TYPE
+    </select>
+    <select id="selectExpriedDtHi" parameterType="TSpecReport" resultMap="TSpecReportResult">
+        SELECT plant_code AS plantCode, COUNT(*) AS devNum, OPER_TYPE AS remarks
+        FROM T_SPECHI_DT
+        WHERE OPER_TIME >= SYSDATE - INTERVAL '1' MONTH and OPER_TYPE in ('新增-通过','删除-通过','停用批准','注销批准')
+        GROUP BY plant_code,OPER_TYPE
+    </select>
+    <select id="selectExpriedDzsbHi" parameterType="TSpecReport" resultMap="TSpecReportResult">
+        SELECT plant_code AS plantCode, COUNT(*) AS devNum, OPER_TYPE AS remarks
+        FROM T_SPECHI_DZSB
+        WHERE OPER_TIME >= SYSDATE - INTERVAL '1' MONTH and OPER_TYPE in ('新增-通过','删除-通过','停用批准','注销批准')
+        GROUP BY plant_code,OPER_TYPE
+    </select>
+    <select id="selectExpriedCcHi" parameterType="TSpecReport" resultMap="TSpecReportResult">
+        SELECT plant_code AS plantCode, COUNT(*) AS devNum, OPER_TYPE AS remarks
+        FROM T_SPECHI_CC
+        WHERE OPER_TIME >= SYSDATE - INTERVAL '1' MONTH and OPER_TYPE in ('新增-通过','删除-通过','停用批准','注销批准')
+        GROUP BY plant_code,OPER_TYPE
+    </select>
+
+
     <select id="selectTSpecReportById" parameterType="Long" resultMap="TSpecReportResult">
         <include refid="selectTSpecReportVo"/>
         where id = #{id}

+ 1 - 1
master/src/main/resources/mybatis/training/elearn/TElUserBookMapper.xml

@@ -51,7 +51,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <select id="selectTElUserBookByLast" parameterType="TElUserBook" resultMap="TElUserBookResult">
         select * from ( select d.id, d.user_id, d.exam_id, d.qu_id, d.wrong_count, d.title, d.del_flag, d.creater_code, d.createdate, d.updater_code, d.updatedate, d.sort  from t_el_user_book d
         <where>
-            <if test="quId != null ">and #{quId} > qu_id</if>
+            <if test="updatedate != null ">and #{updatedate} > updatedate</if>
             <if test="userId != null "> and user_id = #{userId}</if>
             and d.del_flag = 0
         </where>

BIN
master/src/main/resources/static/word/sems/report/sems-report.xlsx


+ 29 - 127
ui/src/views/sems/specReport/index.vue

@@ -10,81 +10,7 @@
           @keyup.enter.native="handleQuery"
         />
       </el-form-item>
-      <el-form-item label="报告url" prop="reportUrl">
-        <el-input
-          v-model="queryParams.reportUrl"
-          placeholder="请输入报告url"
-          clearable
-          size="small"
-          @keyup.enter.native="handleQuery"
-        />
-      </el-form-item>
-      <el-form-item label="明细URL" prop="detailUrl">
-        <el-input
-          v-model="queryParams.detailUrl"
-          placeholder="请输入明细URL"
-          clearable
-          size="small"
-          @keyup.enter.native="handleQuery"
-        />
-      </el-form-item>
-      <el-form-item label="类型" prop="reportType">
-        <el-select v-model="queryParams.reportType" placeholder="请选择类型" clearable size="small">
-          <el-option label="请选择字典生成" value="" />
-        </el-select>
-      </el-form-item>
-      <el-form-item label="创建人" prop="createrCode">
-        <el-input
-          v-model="queryParams.createrCode"
-          placeholder="请输入创建人"
-          clearable
-          size="small"
-          @keyup.enter.native="handleQuery"
-        />
-      </el-form-item>
-      <el-form-item label="创建时间" prop="createdate">
-        <el-date-picker clearable size="small" style="width: 200px"
-          v-model="queryParams.createdate"
-          type="date"
-          value-format="yyyy-MM-dd"
-          placeholder="选择创建时间">
-        </el-date-picker>
-      </el-form-item>
-      <el-form-item label="更新人" prop="updaterCode">
-        <el-input
-          v-model="queryParams.updaterCode"
-          placeholder="请输入更新人"
-          clearable
-          size="small"
-          @keyup.enter.native="handleQuery"
-        />
-      </el-form-item>
-      <el-form-item label="更新日期" prop="updatedate">
-        <el-date-picker clearable size="small" style="width: 200px"
-          v-model="queryParams.updatedate"
-          type="date"
-          value-format="yyyy-MM-dd"
-          placeholder="选择更新日期">
-        </el-date-picker>
-      </el-form-item>
-      <el-form-item label="所属部门" prop="deptId">
-        <el-input
-          v-model="queryParams.deptId"
-          placeholder="请输入所属部门"
-          clearable
-          size="small"
-          @keyup.enter.native="handleQuery"
-        />
-      </el-form-item>
-      <el-form-item label="备注" prop="remarks">
-        <el-input
-          v-model="queryParams.remarks"
-          placeholder="请输入备注"
-          clearable
-          size="small"
-          @keyup.enter.native="handleQuery"
-        />
-      </el-form-item>
+
       <el-form-item>
         <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
         <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
@@ -108,22 +34,20 @@
       <el-table-column type="selection" width="55" align="center" />
       <el-table-column label="id" align="center" prop="id" :show-overflow-tooltip="true"/>
       <el-table-column label="报告名" align="center" prop="reportName" :show-overflow-tooltip="true"/>
-      <el-table-column label="报告url" align="center" prop="reportUrl" :show-overflow-tooltip="true"/>
-      <el-table-column label="明细URL" align="center" prop="detailUrl" :show-overflow-tooltip="true"/>
-      <el-table-column label="类型" align="center" prop="reportType" :show-overflow-tooltip="true"/>
-      <el-table-column label="创建人" align="center" prop="createrCode" :show-overflow-tooltip="true"/>
-      <el-table-column label="创建时间" align="center" prop="createdate" width="100">
+      <el-table-column label="报告" align="center" prop="reportUrl" :show-overflow-tooltip="true">
         <template slot-scope="scope">
-          <span>{{ parseTime(scope.row.createdate, '{y}-{m}-{d}') }}</span>
+          <a  class="link-type"  @click="handleDownload(scope.row)">
+            <span>{{ getFileName(scope.row.reportUrl) }}</span>
+          </a>
         </template>
       </el-table-column>
-      <el-table-column label="更新人" align="center" prop="updaterCode" :show-overflow-tooltip="true"/>
-      <el-table-column label="更新日期" align="center" prop="updatedate" width="100">
+      <el-table-column label="明细" align="center" prop="detailUrl" :show-overflow-tooltip="true"/>
+      <el-table-column label="创建时间" align="center" prop="createdate" width="100">
         <template slot-scope="scope">
-          <span>{{ parseTime(scope.row.updatedate, '{y}-{m}-{d}') }}</span>
+          <span>{{ parseTime(scope.row.createdate, '{y}-{m}-{d}') }}</span>
         </template>
       </el-table-column>
-      <el-table-column label="所属部门" align="center" prop="deptId" :show-overflow-tooltip="true"/>
+
       <el-table-column label="备注" align="center" prop="remarks" :show-overflow-tooltip="true"/>
       <el-table-column label="操作" align="center" fixed="right" width="120" class-name="small-padding fixed-width">
         <template slot-scope="scope">
@@ -159,51 +83,10 @@
         <el-form-item label="报告名" prop="reportName">
           <el-input v-model="form.reportName" placeholder="请输入报告名" />
         </el-form-item>
-        <el-form-item label="报告url" prop="reportUrl">
-          <el-input v-model="form.reportUrl" placeholder="请输入报告url" />
-        </el-form-item>
-        <el-form-item label="明细URL" prop="detailUrl">
-          <el-input v-model="form.detailUrl" placeholder="请输入明细URL" />
-        </el-form-item>
-        <el-form-item label="类型" prop="reportType">
-          <el-select v-model="form.reportType" placeholder="请选择类型">
-            <el-option label="请选择字典生成" value="" />
-          </el-select>
-        </el-form-item>
-        <el-form-item label="删除" prop="delFlag">
-          <el-input v-model="form.delFlag" placeholder="请输入删除" />
-        </el-form-item>
-        <el-form-item label="创建人" prop="createrCode">
-          <el-input v-model="form.createrCode" placeholder="请输入创建人" />
-        </el-form-item>
-        <el-form-item label="创建时间" prop="createdate">
-          <el-date-picker clearable size="small" style="width: 200px"
-            v-model="form.createdate"
-            type="date"
-            value-format="yyyy-MM-dd"
-            placeholder="选择创建时间">
-          </el-date-picker>
-        </el-form-item>
-        <el-form-item label="更新人" prop="updaterCode">
-          <el-input v-model="form.updaterCode" placeholder="请输入更新人" />
-        </el-form-item>
-        <el-form-item label="更新日期" prop="updatedate">
-          <el-date-picker clearable size="small" style="width: 200px"
-            v-model="form.updatedate"
-            type="date"
-            value-format="yyyy-MM-dd"
-            placeholder="选择更新日期">
-          </el-date-picker>
-        </el-form-item>
-        <el-form-item label="所属部门" prop="deptId">
-          <el-input v-model="form.deptId" placeholder="请输入所属部门" />
-        </el-form-item>
         <el-form-item label="备注" prop="remarks">
           <el-input v-model="form.remarks" placeholder="请输入备注" />
         </el-form-item>
-          <el-form-item label="归属部门" prop="deptId">
-              <treeselect v-model="form.deptId" :options="deptOptions" :show-count="true" placeholder="请选择归属部门" />
-          </el-form-item>
+
       </el-form>
       <div slot="footer" class="dialog-footer">
         <el-button type="primary" @click="submitForm">确 定</el-button>
@@ -473,7 +356,26 @@ export default {
       // 提交上传文件
       submitFileForm() {
           this.$refs.upload.submit();
+      },
+    /** 文件下载处理 */
+    handleDownload(row) {
+      var name = this.getFileName(row.reportUrl)
+      var url = row.reportUrl
+      var suffix = url.substring(url.lastIndexOf("."), url.length);
+      const a = document.createElement('a')
+      a.setAttribute('download', name)
+      a.setAttribute('target', '_blank')
+      a.setAttribute('href', process.env.VUE_APP_BASE_API + url)
+      a.click()
+    },
+    getFileName(filePath) {
+      if (!filePath) {
+        // 如果文件路径为空或未定义,返回一个默认消息
+        return '';
       }
+      const parts = filePath.split('/');
+      return parts[parts.length - 1];
+    }
   }
 };
 </script>

+ 1 - 1
ui/src/views/training/elearn/userBook/train.vue

@@ -159,7 +159,7 @@ export default {
         this.fetchNextQu()
       } else {
         // 直接判断正确性
-        if (this.rightValues.join(',') === this.answerValues.join(',')) {
+        if (this.rightValues.join(',') === this.answerValues.sort((a, b) => a - b).join(',')) {
           this.$message({
             message: '回答正确,你好棒哦!',
             type: 'success'

+ 5 - 2
ui/src/views/training/elearn/userQu/train.vue

@@ -53,7 +53,7 @@
         <p style="color: #555;">{{ an.content }}:</p>
         <p style="color: #1890ff;">{{ an.analysis }}</p>
       </div>
-      <p v-if="analysisCount === 0">暂无选项解析</p>
+<!--      <p v-if="analysisCount === 0">暂无选项解析</p>-->
 
     </el-card>
 
@@ -160,7 +160,10 @@ export default {
         this.fetchNextQu()
       } else {
         // 直接判断正确性
-        if (this.rightValues.join(',') === this.answerValues.join(',')) {
+        console.log('=======================')
+        console.log(this.rightValues.join(','))
+        console.log(this.answerValues.join(','))
+        if (this.rightValues.join(',') === this.answerValues.sort((a, b) => a - b).join(',') ) {
           this.$message({
             message: '回答正确,你好棒哦!',
             type: 'success'

+ 0 - 3
ui/src/views/training/trainingbcc/index.vue

@@ -710,9 +710,6 @@ export default {
         trainer: [
           { required: true, message: this.$t('培训人') + this.$t('不能为空'), trigger: "blur" }
         ],
-        unit: [
-          { required: true, message: this.$t('部门') + this.$t('不能为空'), trigger: "blur" }
-        ],
         position: [
           { required: true, message: this.$t('培训岗位') + this.$t('不能为空'), trigger: "blur" }
         ],