瀏覽代碼

feat(check): 添加年度保养计划表功能

- 新增 CheckJobAnnualPlanVO 统计实体类,按设备类别/名称/保养负责人聚合
- 添加 ExportCheckJobAnnualPlanVO 导出实体类,支持Excel导出功能
- 在 CheckJobDTO 中新增 searchYear 字段用于年份查询
- 实现年度保养计划表查询接口,按月份统计已完成保养任务情况
- 添加年度保养计划表导出功能,支持Excel格式下载
- 实现后端服务层和数据访问层相关方法
- 配置 MyBatis 查询映射,实现按月份分组统计逻辑
dazhaxie 2 天之前
父節點
當前提交
8dafada4f8

+ 4 - 0
platform-dao/src/main/java/com/platform/dao/dto/check/CheckJobDTO.java

@@ -27,6 +27,10 @@ import java.util.List;
 @EqualsAndHashCode(callSuper = true)
 public class CheckJobDTO extends BaseDTO implements Serializable {
     private Integer sbNotStatus;
+    /**
+     * 年度计划表查询年份(为空时默认当前年)
+     */
+    private Integer searchYear;
     private Integer record;//1:代表保养记录
     private List<Integer> standardLevelList;
     private List<Integer> periodTypeList;

+ 11 - 0
platform-dao/src/main/java/com/platform/dao/mapper/check/CheckJobMapper.java

@@ -3,6 +3,7 @@ package com.platform.dao.mapper.check;
 import com.platform.dao.config.MyMapper;
 import com.platform.dao.dto.check.CheckJobDTO;
 import com.platform.dao.entity.check.CheckJob;
+import com.platform.dao.vo.query.check.CheckJobAnnualPlanVO;
 import com.platform.dao.vo.query.check.CheckJobVO;
 import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Component;
@@ -99,4 +100,14 @@ public interface CheckJobMapper extends MyMapper<CheckJob> {
                           @Param("status") Integer status,
                           @Param("checkUserId") String checkUserId,
                           @Param("checkDeptId") String checkDeptId);
+
+    /**
+     * 年度保养计划表:按设备类别/设备名称/保养负责人聚合,
+     * 统计当年每月是否有已完成(status=3)的保养任务,有则对应月份打勾√;
+     * 排除按天(standard.period_type=1)的保养。
+     *
+     * @param dto 需包含 searchYear(年份),可选 type(检查类型)
+     * @return 年度计划表行数据
+     */
+    List<CheckJobAnnualPlanVO> selectAnnualPlan(CheckJobDTO dto);
 }

+ 53 - 0
platform-dao/src/main/java/com/platform/dao/vo/export/check/ExportCheckJobAnnualPlanVO.java

@@ -0,0 +1,53 @@
+package com.platform.dao.vo.export.check;
+
+import com.platform.office.annotation.Excel;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+/**
+ * @Description 保养任务年度计划表导出VO
+ * @Version Copyright (c) 2020,北京乾元坤和科技有限公司 All rights reserved.
+ */
+@Data
+@Accessors(chain = true)
+public class ExportCheckJobAnnualPlanVO implements Serializable {
+
+    @Excel(name = "设备类别", orderNum = "1", width = 16)
+    private String category;
+
+    @Excel(name = "设备", orderNum = "2", width = 20)
+    private String sbName;
+
+    @Excel(name = "保养负责人", orderNum = "3", width = 14)
+    private String owner;
+
+    @Excel(name = "维保设备数量", orderNum = "4", width = 12)
+    private Integer sbNum;
+
+    @Excel(name = "1月", orderNum = "5", width = 5)
+    private String month1;
+    @Excel(name = "2月", orderNum = "6", width = 5)
+    private String month2;
+    @Excel(name = "3月", orderNum = "7", width = 5)
+    private String month3;
+    @Excel(name = "4月", orderNum = "8", width = 5)
+    private String month4;
+    @Excel(name = "5月", orderNum = "9", width = 5)
+    private String month5;
+    @Excel(name = "6月", orderNum = "10", width = 5)
+    private String month6;
+    @Excel(name = "7月", orderNum = "11", width = 5)
+    private String month7;
+    @Excel(name = "8月", orderNum = "12", width = 5)
+    private String month8;
+    @Excel(name = "9月", orderNum = "13", width = 5)
+    private String month9;
+    @Excel(name = "10月", orderNum = "14", width = 5)
+    private String month10;
+    @Excel(name = "11月", orderNum = "15", width = 5)
+    private String month11;
+    @Excel(name = "12月", orderNum = "16", width = 5)
+    private String month12;
+}

+ 50 - 0
platform-dao/src/main/java/com/platform/dao/vo/query/check/CheckJobAnnualPlanVO.java

@@ -0,0 +1,50 @@
+package com.platform.dao.vo.query.check;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+/**
+ * @Description 保养任务年度计划表统计VO
+ *              按设备类别/设备名称/保养负责人聚合,某设备当月做过保养(已完成)则对应月份打勾√;
+ *              按天(periodType=日)的保养不计入。
+ * @Version Copyright (c) 2020,北京乾元坤和科技有限公司 All rights reserved.
+ */
+@Data
+@Accessors(chain = true)
+public class CheckJobAnnualPlanVO implements Serializable {
+
+    /**
+     * 设备类别(设备类型名称)
+     */
+    private String category;
+    /**
+     * 设备名称
+     */
+    private String sbName;
+    /**
+     * 保养负责人(任务执行人/班组)
+     */
+    private String owner;
+    /**
+     * 维保设备数量(该分组下的设备台数)
+     */
+    private Integer sbNum;
+
+    /**
+     * 1月~12月:值为 √ 表示当月做过保养,空字符串表示未做
+     */
+    private String month1;
+    private String month2;
+    private String month3;
+    private String month4;
+    private String month5;
+    private String month6;
+    private String month7;
+    private String month8;
+    private String month9;
+    private String month10;
+    private String month11;
+    private String month12;
+}

+ 41 - 0
platform-dao/src/main/resources/mapper/check/CheckJobMapper.xml

@@ -1133,4 +1133,45 @@
         where standard_id = #{standardId}
           and status = #{status}
     </update>
+
+    <!-- 年度保养计划表:按设备类别/设备名称/保养负责人聚合,
+         当年每月只要有已完成(status=3)的保养任务则该月打勾√,排除按天(period_type=1)的保养 -->
+    <select id="selectAnnualPlan" parameterType="com.platform.dao.dto.check.CheckJobDTO"
+            resultType="com.platform.dao.vo.query.check.CheckJobAnnualPlanVO">
+        select
+            sbtype.name as category,
+            sbinfo.name as sbName,
+            coalesce(u.real_name, dept.name) as owner,
+            count(distinct sbinfo.id) as sbNum,
+            max(case when month(coalesce(checkjob.actual_end_time, checkjob.actual_start_time, checkjob.end_time)) = 1 then '√' else '' end) as month1,
+            max(case when month(coalesce(checkjob.actual_end_time, checkjob.actual_start_time, checkjob.end_time)) = 2 then '√' else '' end) as month2,
+            max(case when month(coalesce(checkjob.actual_end_time, checkjob.actual_start_time, checkjob.end_time)) = 3 then '√' else '' end) as month3,
+            max(case when month(coalesce(checkjob.actual_end_time, checkjob.actual_start_time, checkjob.end_time)) = 4 then '√' else '' end) as month4,
+            max(case when month(coalesce(checkjob.actual_end_time, checkjob.actual_start_time, checkjob.end_time)) = 5 then '√' else '' end) as month5,
+            max(case when month(coalesce(checkjob.actual_end_time, checkjob.actual_start_time, checkjob.end_time)) = 6 then '√' else '' end) as month6,
+            max(case when month(coalesce(checkjob.actual_end_time, checkjob.actual_start_time, checkjob.end_time)) = 7 then '√' else '' end) as month7,
+            max(case when month(coalesce(checkjob.actual_end_time, checkjob.actual_start_time, checkjob.end_time)) = 8 then '√' else '' end) as month8,
+            max(case when month(coalesce(checkjob.actual_end_time, checkjob.actual_start_time, checkjob.end_time)) = 9 then '√' else '' end) as month9,
+            max(case when month(coalesce(checkjob.actual_end_time, checkjob.actual_start_time, checkjob.end_time)) = 10 then '√' else '' end) as month10,
+            max(case when month(coalesce(checkjob.actual_end_time, checkjob.actual_start_time, checkjob.end_time)) = 11 then '√' else '' end) as month11,
+            max(case when month(coalesce(checkjob.actual_end_time, checkjob.actual_start_time, checkjob.end_time)) = 12 then '√' else '' end) as month12
+        from t_check_job checkjob
+        inner join t_sb_info sbinfo on sbinfo.id = checkjob.sb_id
+        inner join t_check_standard standard on standard.id = checkjob.standard_id
+        left join t_sb_type sbtype on sbtype.id = sbinfo.type_id
+        left join t_sys_user u on checkjob.check_user_id = u.user_id
+        left join t_sys_dept dept on checkjob.check_dept_id = dept.dept_id
+        <where>
+            checkjob.status = 3
+            and standard.period_type != 1
+            <if test="searchYear != null">
+                and year(coalesce(checkjob.actual_end_time, checkjob.actual_start_time, checkjob.end_time)) = #{searchYear}
+            </if>
+            <if test="type != null">
+                and checkjob.type = #{type}
+            </if>
+        </where>
+        group by sbtype.name, sbinfo.name, coalesce(u.real_name, dept.name)
+        order by sbtype.name asc, sbinfo.name asc
+    </select>
 </mapper>

+ 27 - 0
platform-rest/src/main/java/com/platform/rest/controller/check/CheckJobController.java

@@ -7,10 +7,12 @@ import com.platform.dao.dto.check.CheckJobDTO;
 import com.platform.dao.dto.check.CheckStandardDTO;
 import com.platform.dao.enums.CheckJobStatusEnum;
 import com.platform.dao.vo.query.check.CheckJobNum;
+import com.platform.dao.vo.query.check.CheckJobAnnualPlanVO;
 import com.platform.dao.vo.query.check.CheckJobVO;
 import com.platform.service.check.CheckJobService;
 import com.platform.dao.util.ExcelUtil;
 import com.platform.dao.vo.export.check.ExportCheckJobVO;
+import com.platform.dao.vo.export.check.ExportCheckJobAnnualPlanVO;
 import com.platform.common.util.BeanConverterUtil;
 import com.platform.common.validation.group.AddGroup;
 import com.platform.common.validation.group.UpdateGroup;
@@ -343,4 +345,29 @@ public class CheckJobController {
             }
         }
     }
+
+    /**
+     * 年度保养计划表(页面查看)
+     * 按设备名称/类别聚合,当年每月做过保养则打勾√,按天的保养不计入
+     *
+     * @param checkJobDTO 包含 searchYear(年份)、type(检查类型)
+     * @return R
+     */
+    @GetMapping("/annual-plan")
+    public R<List<CheckJobAnnualPlanVO>> annualPlan(CheckJobDTO checkJobDTO) {
+        return new R<>(checkJobService.getAnnualPlan(checkJobDTO));
+    }
+
+    /**
+     * 年度保养计划表导出 Excel
+     *
+     * @param checkJobDTO 包含 searchYear(年份)、type(检查类型)
+     */
+    @GetMapping("/annual-plan/export")
+    @SysLog("年度保养计划表导出")
+    public void exportAnnualPlan(HttpServletResponse response, CheckJobDTO checkJobDTO) {
+        List<CheckJobAnnualPlanVO> list = checkJobService.getAnnualPlan(checkJobDTO);
+        ExcelUtil.exportResponseDict(response, ExportCheckJobAnnualPlanVO.class,
+                BeanConverterUtil.copyListProperties(list, ExportCheckJobAnnualPlanVO.class), "年度保养计划表");
+    }
 }

+ 9 - 0
platform-service/src/main/java/com/platform/service/check/CheckJobService.java

@@ -9,6 +9,7 @@ import com.platform.dao.dto.check.CheckStandardDTO;
 import com.platform.dao.entity.check.CheckJob;
 import com.platform.dao.enums.CheckJobStatusEnum;
 import com.platform.dao.vo.query.check.CheckJobNum;
+import com.platform.dao.vo.query.check.CheckJobAnnualPlanVO;
 import com.platform.dao.vo.query.check.CheckJobScreenVO;
 import com.platform.dao.vo.query.check.CheckJobVO;
 import com.platform.dao.vo.report.CheckJobReportVO;
@@ -195,4 +196,12 @@ public interface CheckJobService extends IBaseService<CheckJob, CheckJobDTO> {
      * @param response HttpServletResponse
      */
     void downloadPdf(String id, HttpServletResponse response) throws IOException;
+
+    /**
+     * 年度保养计划表:按设备名称/类别聚合,当年每月做过保养则打勾,排除按天的保养。
+     *
+     * @param dto 需包含 searchYear(年份,为空默认当年)、可选 type(检查类型)
+     * @return 年度计划表行数据
+     */
+    List<CheckJobAnnualPlanVO> getAnnualPlan(CheckJobDTO dto);
 }

+ 12 - 0
platform-service/src/main/java/com/platform/service/check/impl/CheckJobServiceImpl.java

@@ -2991,4 +2991,16 @@ public class CheckJobServiceImpl extends BaseServiceImpl<CheckJobMapper, CheckJo
         }
     }
 
+    @Override
+    public List<CheckJobAnnualPlanVO> getAnnualPlan(CheckJobDTO dto) {
+        if (dto == null) {
+            dto = new CheckJobDTO();
+        }
+        // 年份为空时默认当前年
+        if (dto.getSearchYear() == null) {
+            dto.setSearchYear(LocalDate.now().getYear());
+        }
+        return checkJobMapper.selectAnnualPlan(dto);
+    }
+
 }