Преглед изворни кода

周期运行情况-样式优化

wanglt пре 3 месеци
родитељ
комит
de24fc2f12

+ 1 - 2
ygtx-gxt/src/main/java/com/ygtx/gxt/controller/GxtFanInspectionScoreController.java

@@ -253,7 +253,6 @@ public class GxtFanInspectionScoreController extends BaseController
     @PostMapping("/importTemplate")
     public void importTemplate(HttpServletResponse response)
     {
-        ExcelUtil<GxtFanInspectionScoreVo> util = new ExcelUtil<GxtFanInspectionScoreVo>(GxtFanInspectionScoreVo.class);
-        util.importTemplateExcel(response, "风机类型检查分值数据");
+        gxtFanInspectionScoreService.importTemplate(response);
     }
 }

+ 4 - 0
ygtx-gxt/src/main/java/com/ygtx/gxt/service/IGxtFanInspectionScoreService.java

@@ -3,6 +3,8 @@ package com.ygtx.gxt.service;
 import java.util.List;
 import com.ygtx.gxt.domain.GxtFanInspectionScore;
 
+import javax.servlet.http.HttpServletResponse;
+
 /**
  * 风机类型检查分值Service接口
  * 
@@ -76,4 +78,6 @@ public interface IGxtFanInspectionScoreService
      * @return 结果
      */
     public String importFanInspectionScoreList(List<GxtFanInspectionScore> fanInspectionScoreList, Boolean updateSupport, String operName);
+
+    public void importTemplate(HttpServletResponse response);
 }

+ 89 - 0
ygtx-gxt/src/main/java/com/ygtx/gxt/service/impl/GxtFanInspectionScoreServiceImpl.java

@@ -1,6 +1,10 @@
 package com.ygtx.gxt.service.impl;
 
+import java.io.IOException;
 import java.util.List;
+
+import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.ygtx.gxt.mapper.GxtFanInspectionScoreMapper;
@@ -9,6 +13,8 @@ import com.ygtx.gxt.service.IGxtFanInspectionScoreService;
 import com.ygtx.common.exception.ServiceException;
 import com.ygtx.common.utils.StringUtils;
 
+import javax.servlet.http.HttpServletResponse;
+
 /**
  * 风机类型检查分值Service业务层处理
  * 
@@ -199,4 +205,87 @@ public class GxtFanInspectionScoreServiceImpl implements IGxtFanInspectionScoreS
         }
         return resultMsg.toString();
     }
+
+    public void importTemplate(HttpServletResponse response) {
+        try {
+            Workbook workbook = new XSSFWorkbook();
+            Sheet sheet = workbook.createSheet("风机类型检查分值数据");
+
+            // 表头行
+            Row headerRow = sheet.createRow(0);
+
+            // 表头和注释
+            String[] headers = { "机型", "维保类型", "分值" };
+            String[] comments = { "单位管理员:\n必填", "单位管理员:\n必填", "单位管理员:\n必填" };
+
+            // 创建字体(普通和加粗)
+            Font commentFont = workbook.createFont();
+            commentFont.setFontHeightInPoints((short) 9); // 默认字体大小
+
+            Font boldFont = workbook.createFont();
+            boldFont.setFontHeightInPoints((short) 9);
+            boldFont.setBold(true); // 加粗
+
+            // 1. 创建表头样式(灰色背景 + 白色字体 + 居中)
+            CellStyle headerStyle = workbook.createCellStyle();
+            headerStyle.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex()); // 浅灰色背景
+            headerStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
+            headerStyle.setAlignment(HorizontalAlignment.CENTER); // 水平居中
+            headerStyle.setVerticalAlignment(VerticalAlignment.CENTER); // 垂直居中
+
+            // 2. 设置字体(白色 + 加粗)
+            Font font = workbook.createFont();
+            font.setColor(IndexedColors.WHITE.getIndex()); // 白色字体
+            font.setBold(true); // 加粗
+            font.setFontHeightInPoints((short) 10); // 字体大小
+            headerStyle.setFont(font);
+
+            // 创建注释绘图对象(只需一次)
+            Drawing<?> drawing = sheet.createDrawingPatriarch();
+            CreationHelper factory = workbook.getCreationHelper();
+
+            for (int i = 0; i < headers.length; i++) {
+                Cell cell = headerRow.createCell(i);
+                cell.setCellValue(headers[i]);
+                cell.setCellStyle(headerStyle); // 应用样式
+
+                // 固定列宽 200
+                sheet.setColumnWidth(i, 20 * 256);
+
+                // 添加注释
+                if (comments[i] != null) {
+                    // 1. 创建 RichTextString 并设置文本
+                    RichTextString richText = factory.createRichTextString(comments[i]);
+
+                    // 2. 设置 "单位管理员:" 为加粗
+                    richText.applyFont(0, 5, boldFont); // 索引 0-5("单位管理员:")
+
+                    // 3. 设置 "\n必填" 为默认字体(可选)
+                    richText.applyFont(5, comments[i].length(), commentFont); // 索引 5 到末尾
+
+                    // 4. 创建注释并应用 RichTextString
+                    ClientAnchor anchor = factory.createClientAnchor();
+                    anchor.setCol1(i);
+                    anchor.setCol2(i + 1);
+                    anchor.setRow1(0);
+                    anchor.setRow2(2);
+
+                    Comment comment = drawing.createCellComment(anchor);
+                    comment.setString(richText); // 使用 RichTextString 代替普通字符串
+                    comment.setAuthor("系统提示");
+                    cell.setCellComment(comment);
+                }
+            }
+
+            // 输出到响应流
+            response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
+            response.setHeader("Content-Disposition", "attachment; filename=风机类型检查分值数据导入模版.xlsx");
+            workbook.write(response.getOutputStream());
+            workbook.close();
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        } catch (Exception err) {
+            throw new ServiceException(err.toString());
+        }
+    }
 }

+ 9 - 1
ygtx-gxt/src/main/java/com/ygtx/gxt/service/impl/GxtMonthScoreServiceImpl.java

@@ -115,7 +115,15 @@ public class GxtMonthScoreServiceImpl implements IGxtMonthScoreService
         workOrder.setMonthPeriod(monthPeriod);
         workOrder.setWorkOrderStatus("archived");
         addBusinessDataScopeFilter(workOrder);
-        return gxtWorkOrderMapper.selectGxtWorkOrderListByMonth(workOrder);
+        List<GxtWorkOrder> list = gxtWorkOrderMapper.selectGxtWorkOrderListByMonth(workOrder);
+        if (!list.isEmpty()) {
+            for (GxtWorkOrder order:list) {
+                if (order.getPauseTime()==null) {
+                    order.setPauseTime(order.getRealStartTime());
+                }
+            }
+        }
+        return list;
     }
 
 

+ 20 - 16
ygtx-gxt/src/main/resources/mapper/gxt/GxtWorkOrderMapper.xml

@@ -921,29 +921,33 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             t.model,
             t.work_order_project_no,
             t.restart_time,
-            t.pause_time,
+            COALESCE ( t.pause_time, t.real_start_time ) AS pause_time,
             t.pcs_station_pid,
             1 AS order_type,
             t.pcs_device_id,t.gxt_center,t.pcs_station_name,d.dept_name,
-            DATEDIFF( t.restart_time, t.pause_time ) AS stop_days,
-            DATEDIFF( NOW(), t.restart_time ) AS running_days
+            DATEDIFF( t.restart_time, COALESCE ( t.pause_time, t.real_start_time ) ) AS stop_days,
+            DATEDIFF( NOW(), DATE(t.restart_time) + INTERVAL 1 DAY ) AS running_days
         FROM
             gxt_work_order t
-            INNER JOIN ( 
-                SELECT 
-                    pcs_device_id, 
-                    MAX( pause_time ) AS latest_pause_time 
-                FROM 
-                    gxt_work_order 
-                WHERE 
-                    pause_time IS NOT NULL AND restart_time IS NOT NULL 
-                GROUP BY 
-                    pcs_device_id 
+            INNER JOIN (
+                SELECT
+                    pcs_device_id,
+                    MAX( COALESCE ( pause_time, real_start_time )) AS latest_time,
+                    MAX( CASE WHEN pause_time IS NOT NULL THEN 1 ELSE 0 END ) AS is_pause_time
+                FROM
+                    gxt_work_order
+                WHERE
+                    ( pause_time IS NOT NULL OR real_start_time IS NOT NULL )
+                    AND restart_time IS NOT NULL
+                GROUP BY
+                    pcs_device_id
             ) latest ON t.pcs_device_id = latest.pcs_device_id
-            AND t.pause_time = latest.latest_pause_time
+            AND ( ( latest.is_pause_time = 1 AND t.pause_time = latest.latest_time )
+                OR
+                ( latest.is_pause_time = 0 AND t.pause_time IS NULL AND t.real_start_time = latest.latest_time ) )
             LEFT JOIN sys_dept d ON d.dept_id=t.pcs_station_pid
         WHERE
-            t.pause_time IS NOT NULL
+            latest.pcs_device_id IS NOT NULL
             AND t.restart_time IS NOT NULL
         <if test="deptName != null  and deptName != ''"> and d.dept_name like concat('%', #{deptName}, '%')</if>
         <if test="pcsStationPid != null"> and t.pcs_station_pid = #{pcsStationPid}</if>
@@ -963,7 +967,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         2 AS order_type,
         t.pcs_device_id,t.gxt_center,t.pcs_station_name,d.dept_name,
         DATEDIFF( t.restart_time, t.occur_time ) AS stop_days,
-        DATEDIFF( NOW(), t.restart_time ) AS running_days
+        DATEDIFF( NOW(), DATE(t.restart_time) + INTERVAL 1 DAY ) AS running_days
         FROM
         gxt_repair_order t
         INNER JOIN (

+ 1 - 1
ygtx-ui/src/views/gxt/monthRuntime/index.vue

@@ -66,8 +66,8 @@
             <el-button link type="primary" @click="handleWorkOrderClick(scope.row)">{{ scope.row.workOrderProjectNo }}</el-button>
           </template>
         </el-table-column>
+        <el-table-column v-if="isStop" prop="pauseTime" label="停机时间" width="150" />
         <el-table-column prop="restartTime" label="复运时间" width="150" />
-        <el-table-column prop="pauseTime" label="停机时间" width="150" />
         <el-table-column v-if="isStop" prop="stopDays" label="停机天数" />
         <el-table-column v-if="!isStop" prop="runningDays" label="安全运行天数" />
       </el-table>

+ 1 - 1
ygtx-ui/src/views/gxt/monthScore/index.vue

@@ -110,7 +110,7 @@
               </el-table-column>
               <el-table-column prop="leader" label="工作负责人"></el-table-column>
               <el-table-column prop="acceptUserName" label="接单人"></el-table-column>
-              <el-table-column prop="realStartTime" label="停机时间"></el-table-column>
+              <el-table-column prop="pauseTime" label="停机时间"></el-table-column>
               <el-table-column prop="restartTime" label="恢复运行时间"></el-table-column>
             </el-table>
             <pagination style="margin-top: 20px;"

+ 1 - 1
ygtx-ui/src/views/gxt/monthScore/info.vue

@@ -45,7 +45,7 @@
               </el-table-column>
               <el-table-column prop="leader" label="工作负责人"></el-table-column>
               <el-table-column prop="acceptUserName" label="接单人"></el-table-column>
-              <el-table-column prop="realStartTime" label="停机时间"></el-table-column>
+              <el-table-column prop="pauseTime" label="停机时间"></el-table-column>
               <el-table-column prop="restartTime" label="恢复运行时间"></el-table-column>
             </el-table>
             <pagination style="margin-top: 20px;"