hfxc226 2 years ago
parent
commit
70a1647d3f
32 changed files with 761 additions and 88 deletions
  1. 27 0
      platform-common/src/main/java/com/platform/common/util/DateUtils.java
  2. 5 0
      platform-dao/src/main/java/com/platform/dao/dto/check/CheckStandardDTO.java
  3. 26 1
      platform-dao/src/main/java/com/platform/dao/dto/repair/RepairFeeDTO.java
  4. 15 0
      platform-dao/src/main/java/com/platform/dao/dto/sb/SbInfoDTO.java
  5. 15 2
      platform-dao/src/main/java/com/platform/dao/dto/sqarepartmanage/SparePartInfoDTO.java
  6. 6 0
      platform-dao/src/main/java/com/platform/dao/dto/store/SpareStoreDTO.java
  7. 25 10
      platform-dao/src/main/java/com/platform/dao/entity/repair/RepairFee.java
  8. 4 1
      platform-dao/src/main/java/com/platform/dao/entity/sqarepartmanage/SparePartInfo.java
  9. 26 14
      platform-dao/src/main/java/com/platform/dao/vo/export/repair/ExportRepairFeeVO.java
  10. 2 2
      platform-dao/src/main/java/com/platform/dao/vo/export/sb/ExportSbInfoVO.java
  11. 4 0
      platform-dao/src/main/java/com/platform/dao/vo/query/sparepartmanage/SparePartInfoVO.java
  12. 49 0
      platform-dao/src/main/java/com/platform/dao/vo/report/RepairSbInfoReport.java
  13. 54 0
      platform-dao/src/main/java/com/platform/dao/vo/report/RepairSbInfoReportFee.java
  14. 1 1
      platform-dao/src/main/resources/mapper/check/CheckJobMapper.xml
  15. 5 2
      platform-dao/src/main/resources/mapper/check/CheckStandardMapper.xml
  16. 4 1
      platform-dao/src/main/resources/mapper/operate/ArticleMapper.xml
  17. 30 10
      platform-dao/src/main/resources/mapper/repair/RepairFeeMapper.xml
  18. 17 0
      platform-dao/src/main/resources/mapper/sb/SbInfoMapper.xml
  19. 8 0
      platform-dao/src/main/resources/mapper/sb/SbModelSpareBomMapper.xml
  20. 19 2
      platform-dao/src/main/resources/mapper/sqarepartmanage/SparePartInfoMapper.xml
  21. 6 0
      platform-dao/src/main/resources/mapper/store/SpareStoreMapper.xml
  22. 16 4
      platform-rest/src/main/java/com/platform/rest/controller/check/CheckJobController.java
  23. 2 1
      platform-rest/src/main/java/com/platform/rest/controller/operate/ArticleController.java
  24. 157 4
      platform-rest/src/main/java/com/platform/rest/controller/report/RepairReportController.java
  25. 22 16
      platform-rest/src/main/java/com/platform/rest/controller/sqarepartmanage/SparePartInfoController.java
  26. 1 1
      platform-service/src/main/java/com/platform/service/check/impl/CheckJobServiceImpl.java
  27. 2 0
      platform-service/src/main/java/com/platform/service/repair/RepairApplicationFormService.java
  28. 2 0
      platform-service/src/main/java/com/platform/service/repair/RepairFeeService.java
  29. 86 11
      platform-service/src/main/java/com/platform/service/repair/impl/RepairApplicationFormServiceImpl.java
  30. 86 1
      platform-service/src/main/java/com/platform/service/repair/impl/RepairFeeServiceImpl.java
  31. 26 0
      platform-service/src/main/java/com/platform/service/sqarepartmanage/impl/SparePartInfoServiceImpl.java
  32. 13 4
      platform-service/src/main/java/com/platform/service/store/impl/SpareStoreServiceImpl.java

+ 27 - 0
platform-common/src/main/java/com/platform/common/util/DateUtils.java

@@ -496,6 +496,33 @@ public class DateUtils {
         return  monthStartAndEndList;
     }
 
+    /**
+     * 指定年份,一直到现在时间的年份的开始到结束时间
+     *
+     * @param startYear:默认从2020年开始
+     * @param endYear:默认当前年份
+     * @return
+     */
+    public static List<Map<String, LocalDateTime>> getYearStartAndEndByYear(int startYear, int endYear) {
+        if(startYear < 2020){
+            startYear = 2020;
+        }
+        if(endYear == 2021){
+            endYear = LocalDate.now().getYear();
+        }
+        List<Map<String, LocalDateTime>> startAndEndList = new ArrayList<Map<String,LocalDateTime>>();
+        // 每年的 一月一号,零时零分零秒
+        for(int i = startYear;i<=endYear;i++){
+            Map<String, LocalDateTime> dateTimeMap = new HashMap<String, LocalDateTime>();
+            LocalDateTime searchStartTimeMonth = getFirstDayOfThisYear(i);
+            LocalDateTime searchEndTimeMonth = getLastDayOfThisYear(i);
+            dateTimeMap.put("searchStartTime", searchStartTimeMonth);
+            dateTimeMap.put("searchEndTime",searchEndTimeMonth);
+            startAndEndList.add(dateTimeMap);
+        }
+        return  startAndEndList;
+    }
+
     /**
      * 指定年份开始年月到结束年月,中间每个月的开始时间和结束时间
      *

+ 5 - 0
platform-dao/src/main/java/com/platform/dao/dto/check/CheckStandardDTO.java

@@ -25,6 +25,11 @@ import java.util.List;
 @EqualsAndHashCode(callSuper = true)
 public class CheckStandardDTO extends BaseDTO implements Serializable {
 
+    /**
+     * 设备id
+     */
+    @Transient
+    private String typeId;
     /**
      * 主键
      */

+ 26 - 1
platform-dao/src/main/java/com/platform/dao/dto/repair/RepairFeeDTO.java

@@ -7,6 +7,7 @@ import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
 
+import javax.persistence.Transient;
 import javax.validation.constraints.*;
 import java.io.Serializable;
 import java.time.LocalDate;
@@ -44,6 +45,26 @@ public class RepairFeeDTO extends BaseDTO implements Serializable {
      * 设备id
      */
     private String sbId;
+    /**
+     * 设备id
+     */
+    @Transient
+    private String sbNo;
+    /**
+     * 设备id
+     */
+    @Transient
+    private String sbName;
+    /**
+     * 设备id
+     */
+    @Transient
+    private String typeId;
+    /**
+     * 设备id
+     */
+    @Transient
+    private String sbLevel;
     /**
      * 维修单id
      */
@@ -58,7 +79,11 @@ public class RepairFeeDTO extends BaseDTO implements Serializable {
      * 费用类别
      */
     private Integer type;
-
+    /**
+     * 费用类别
+     */
+    @Transient
+    private Integer category;
     /**
      * 费用原因
      */

+ 15 - 0
platform-dao/src/main/java/com/platform/dao/dto/sb/SbInfoDTO.java

@@ -154,6 +154,21 @@ public class SbInfoDTO extends BaseDTO implements Serializable {
      * 生产商
      */
     private String producerId;
+    /**
+     * 生产商名称:模糊查询
+     */
+    @Transient
+    private String producerName;
+    /**
+     * 第一维修人:模糊查询
+     */
+    @Transient
+    private String repairUserName;
+    /**
+     * 第二维修人:模糊查询
+     */
+    @Transient
+    private String repairUserSecondName;
 
     /**
      * 设备来源方式

+ 15 - 2
platform-dao/src/main/java/com/platform/dao/dto/sqarepartmanage/SparePartInfoDTO.java

@@ -27,7 +27,16 @@ import java.util.List;
 @Accessors(chain = true)
 @EqualsAndHashCode(callSuper = true)
 public class SparePartInfoDTO extends BaseDTO implements Serializable {
-
+    /**
+     * 是否专用备件
+     */
+    private Integer isSpecial;
+    /**
+     * 设备名称或者型号,新号或者旧号,用于查询或者筛选
+     */
+    @Transient
+    private String model;
+    List<String> spareIdList;
     /**
      * 指标参数
      */
@@ -70,7 +79,11 @@ public class SparePartInfoDTO extends BaseDTO implements Serializable {
      * 名称编码
      */
     private String nameNo;
-
+    /**
+     * 查询类型为null的,之前删掉类型,但是有备件关联的
+     */
+    @Transient
+    private Boolean searchType;
     /**
      * 规格编码
      */

+ 6 - 0
platform-dao/src/main/java/com/platform/dao/dto/store/SpareStoreDTO.java

@@ -24,6 +24,11 @@ import java.util.List;
 @Accessors(chain = true)
 @EqualsAndHashCode(callSuper = true)
 public class SpareStoreDTO extends BaseDTO implements Serializable {
+    /**
+     * 设备名称或者型号,新号或者旧号,用于查询或者筛选
+     */
+    @Transient
+    private String model;
     /**
      * 库存价格
      */
@@ -33,6 +38,7 @@ public class SpareStoreDTO extends BaseDTO implements Serializable {
      */
     private BigDecimal initNum;
 
+    List<String> spareIdList;
     /**
      * 预设采购价
      */

+ 25 - 10
platform-dao/src/main/java/com/platform/dao/entity/repair/RepairFee.java

@@ -36,6 +36,31 @@ public class RepairFee implements Serializable {
      * 维修单id
      */
     private String repairId;
+    /**
+     * 设备id
+     */
+    @Transient
+    private String sbNo;
+    /**
+     * 设备id
+     */
+    @Transient
+    private String sbName;
+    /**
+     * 设备id
+     */
+    @Transient
+    private String typeId;
+    /**
+     * 设备id
+     */
+    @Transient
+    private String sbLevel;
+    /**
+     * 工单类型
+     */
+    @Transient
+    private Integer category;
     /**
      * 费用金额
      */
@@ -94,16 +119,6 @@ public class RepairFee implements Serializable {
      * 单号:系统内部的单号,不是维修单号或者其他的单号
      */
     private String no;
-    /**
-     * 设备名称
-     */
-    @Transient
-    private String sbName;
-    /**
-     * 设备编号
-     */
-    @Transient
-    private String sbNo;
     /**
      * 委外单号
      */

+ 4 - 1
platform-dao/src/main/java/com/platform/dao/entity/sqarepartmanage/SparePartInfo.java

@@ -26,7 +26,10 @@ import javax.persistence.Transient;
 @Data
 @Accessors(chain = true)
 public class SparePartInfo implements Serializable {
-
+    /**
+     * 是否专用备件
+     */
+    private Integer isSpecial;
     /**
      * 主键
      */

+ 26 - 14
platform-dao/src/main/java/com/platform/dao/vo/export/repair/ExportRepairFeeVO.java

@@ -10,7 +10,7 @@ import java.time.LocalDate;
 import java.time.LocalDateTime;
 
 /**
- * @Description 维修费用单导出VO
+ * @Description 工单费用单导出VO
  * @Author liuyu
  * @Date 2020-05-12 10:01:21
  * @Version Copyright (c) 2019,北京乾元坤和科技有限公司 All rights reserved.
@@ -28,63 +28,75 @@ public class ExportRepairFeeVO implements Serializable {
     /**
      * 设备编号
      */
-    @Excel(name = "设备编号", orderNum = "3")
+    @Excel(name = "设备编号", orderNum = "2")
     private String sbNo;
-
     /**
      * 设备名称
      */
     @Excel(name = "设备名称", orderNum = "3")
     private String sbName;
-
+    /**
+     * 设备名称
+     */
+    @Excel(name = "设备等级", orderNum = "4", dicCode="SBINFO_LEVEL")
+    private String sbLevel;
+    /**
+     * 设备名称
+     */
+    @Excel(name = "设备类型", orderNum = "5")
+    private String sbTypeName;
     /**
      * 委外单号
      */
-    @Excel(name = "维修单号", orderNum = "4")
+    @Excel(name = "工单单号", orderNum = "6")
     private String repairNo;
-
+    /**
+     * 委外单号
+     */
+    @Excel(name = "工单类型", orderNum = "7", dicCode = "REPAIR_APPLICATION_FORM_CATEGORY")
+    private String category;
     /**
      * 费用金额
      */
-    @Excel(name = "费用金额", orderNum = "5")
+    @Excel(name = "费用金额", orderNum = "8")
     private Double fee;
     /**
      * 费用类别
      */
-    @Excel(name = "费用类别", orderNum = "6", dicCode = "REPAIR_FEE_TYPE")
+    @Excel(name = "费用类别", orderNum = "9", dicCode = "REPAIR_FEE_TYPE")
     private Integer type;
     /**
      * 货币类型
      */
-    @Excel(name = "货币类型", orderNum = "7", dicCode = "MONEY_TYPE")
+    @Excel(name = "货币类型", orderNum = "10", dicCode = "MONEY_TYPE")
     private Integer moneyType;
     /**
      * 费用日期
      */
-    @Excel(name = "费用日期", orderNum = "8")
+    @Excel(name = "费用日期", orderNum = "11")
     private LocalDate feeDate;
     /**
      * 费用原因
      */
-    @Excel(name = "费用原因", orderNum = "9")
+    @Excel(name = "费用原因", orderNum = "12")
     private String reason;
 
     /**
      * 费用描述
      */
-    @Excel(name = "费用描述", orderNum = "10")
+    @Excel(name = "费用描述", orderNum = "13")
     private String descripition;
 
     /**
      * 备注
      */
-    @Excel(name = "备注", orderNum = "11")
+    @Excel(name = "备注", orderNum = "14")
     private String remark;
 
     /**
      * 创建日期
      */
-    @Excel(name = "创建日期", orderNum = "12")
+    @Excel(name = "创建日期", orderNum = "15")
     private LocalDateTime createdTime;
 
 }

+ 2 - 2
platform-dao/src/main/java/com/platform/dao/vo/export/sb/ExportSbInfoVO.java

@@ -132,9 +132,9 @@ public class ExportSbInfoVO implements Serializable {
     @Excel(name = "是否大屏显示", orderNum = "22", dicCode="SB_IS_SHOW")
     private Integer isShow;
     /**
-     * 存放位置
+     * 存放位置和所属车间是同一个
      */
-    @Excel(name = "存放位置", orderNum = "23")
+    @Excel(name = "所属车间", orderNum = "23")
     private String positionName;
     /**
      * 财务编码/固定资产编号

+ 4 - 0
platform-dao/src/main/java/com/platform/dao/vo/query/sparepartmanage/SparePartInfoVO.java

@@ -27,6 +27,10 @@ import java.util.List;
 @Accessors(chain = true)
 @EqualsAndHashCode(callSuper = true)
 public class SparePartInfoVO extends BaseVO implements Serializable {
+    /**
+     * 是否专用备件
+     */
+    private Integer isSpecial;
     /**
      * 指标参数
      */

+ 49 - 0
platform-dao/src/main/java/com/platform/dao/vo/report/RepairSbInfoReport.java

@@ -0,0 +1,49 @@
+package com.platform.dao.vo.report;
+
+import com.platform.dao.vo.repair.RepairApplicationFormVO;
+import com.platform.office.annotation.Excel;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ *
+ * 平均修复时间(Mean time to repair,MTTR)
+ *
+ * @author cyz
+ */
+@Data
+@Accessors(chain = true)
+public class RepairSbInfoReport implements Serializable {
+    private static final long serialVersionUID = 1L;
+    /**
+     * 年
+     */
+    @Excel(name = "年", orderNum = "1")
+    private Integer year;
+    /**
+     * 故障总次数
+     */
+    @Excel(name = "故障次数", orderNum = "2")
+    private Integer num;
+    /**
+     * 故障类别
+     */
+    @Excel(name = "故障类别", orderNum = "3", dicCode="REPAIR_APPLICATION_FORM_CATEGORY")
+    private Integer category;
+    /**
+     * 故障类别
+     */
+    private String name;
+    /**
+     * 设备寿命
+     */
+    @Excel(name = "设备寿命", orderNum = "4")
+    private Double workYear;
+    /**
+     * 明细列表
+     */
+    List<RepairApplicationFormVO> detailList;
+}

+ 54 - 0
platform-dao/src/main/java/com/platform/dao/vo/report/RepairSbInfoReportFee.java

@@ -0,0 +1,54 @@
+package com.platform.dao.vo.report;
+
+import com.platform.dao.entity.repair.RepairFee;
+import com.platform.office.annotation.Excel;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ *
+ * 设备费用统计报表
+ *
+ * @author cyz
+ */
+@Data
+@Accessors(chain = true)
+public class RepairSbInfoReportFee implements Serializable {
+    private static final long serialVersionUID = 1L;
+    /**
+     * 年
+     */
+    @Excel(name = "年", orderNum = "1")
+    private Integer year;
+    /**
+     * 次数
+     */
+    @Excel(name = "费用次数", orderNum = "2")
+    private Integer num;
+    /**
+     * 次数
+     */
+    @Excel(name = "费用总额", orderNum = "3")
+    private Double totalFee;
+    /**
+     * 费用类别
+     */
+    @Excel(name = "费用类别", orderNum = "4", dicCode="REPAIR_FEE_TYPE")
+    private Integer type;
+    /**
+     * 费用类别
+     */
+    private String name;
+    /**
+     * 设备寿命
+     */
+    @Excel(name = "设备寿命", orderNum = "5")
+    private Double workYear;
+    /**
+     * 明细列表
+     */
+    List<RepairFee> detailList;
+}

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

@@ -276,7 +276,7 @@
         <foreach collection="list" item="item" index="index" open="" close="" separator=";">
             update t_check_job
             <set>
-                <if test="item.receiveOvertime != null and item.receiveOvertime != ''">
+                <if test="item.receiveOvertime != null">
                     receive_overtime = #{item.receiveOvertime}
                 </if>
                 <if test="item.startTime != null">

+ 5 - 2
platform-dao/src/main/resources/mapper/check/CheckStandardMapper.xml

@@ -152,8 +152,11 @@ checkstandard.last_date,
             <if test="sbNo != null and sbNo != ''">
                 and sbInfo.no like concat('%',#{sbNo},'%')
             </if>
-            <if test="level != null and level != ''">
-                and sbInfo.level = #{level}
+            <if test="typeId != null and typeId != ''">
+                and sbInfo.type_id  = #{typeId}
+            </if>
+            <if test="sbLevel != null and sbLevel != ''">
+                and sbInfo.level = #{sbLevel}
             </if>
         </where>
         Order By

+ 4 - 1
platform-dao/src/main/resources/mapper/operate/ArticleMapper.xml

@@ -6,7 +6,7 @@
         select * from(
             <foreach collection="types" item="item" index="index" separator="union all">
                 (select
-                id, type, title, introduction, picture, created_Time, update_time
+                id, type, parent_id, title, introduction, picture, created_Time, update_time
                 from
                 t_article where type = ${item} order by update_time DESC limit 0,6)
             </foreach>
@@ -15,5 +15,8 @@
         <if test="keyword != null and keyword != ''">
         and A.title like concat('%',#{keyword},'%')
         </if>
+        <if test="parentId != null and parentId != ''">
+            and A.parent_id = parentId
+        </if>
     </select>
 </mapper>

+ 30 - 10
platform-dao/src/main/resources/mapper/repair/RepairFeeMapper.xml

@@ -23,30 +23,50 @@
                      select="com.platform.dao.mapper.repair.RepairFormMapper.selectNoById"/>
     </resultMap>
     <sql id="Base_Column_List">
-        id, sb_id, no, repair_id, fee, type, reason,
-        fee_date,money_type,
-        descripition, remark, created_time, update_time,
-        created_user_id, update_user_id
+        fee.id, fee.sb_id, fee.no, fee.repair_id, fee.fee, fee.type, fee.reason,
+        fee.fee_date,fee.money_type,
+        fee.descripition, fee.remark, fee.created_time, fee.update_time,
+        fee.created_user_id, fee.update_user_id
     </sql>
     <select id="selectPageList" parameterType="com.platform.dao.dto.repair.RepairFeeDTO" resultMap="BaseResultMap">
         select
         <include refid="Base_Column_List"/>
-        from t_repair_fee
+        from t_repair_fee fee
+        LEFT JOIN t_sb_info sbInfo on fee.sb_id = sbInfo.id
+        LEFT JOIN t_repair_application_form application on fee.repair_id = application.id
         <where>
             <if test="keyword != null and keyword != ''">
-                and reason like concat('%',#{keyword},'%')
+                and fee.reason like concat('%',#{keyword},'%')
             </if>
             <if test="repairId != null and repairId != ''">
-                and repair_id = #{repairId}
+                and fee.repair_id = #{repairId}
             </if>
             <if test="sbId != null and sbId != ''">
-                and sb_id = #{sbId}
+                and fee.sb_id = #{sbId}
             </if>
             <if test="searchStartTime != null">
-                and fee_date <![CDATA[ >= ]]> #{searchStartTime}
+                and fee.fee_date <![CDATA[ >= ]]> #{searchStartTime}
+            </if>
+            <if test="searchEndTime != null">
+                and fee.fee_date <![CDATA[ <= ]]> #{searchEndTime}
             </if>
             <if test="searchEndTime != null">
-                and fee_date <![CDATA[ <= ]]> #{searchEndTime}
+                and fee.fee_date <![CDATA[ <= ]]> #{searchEndTime}
+            </if>
+            <if test="sbName != null and sbName != ''">
+                and sbInfo.name like concat('%',#{sbName},'%')
+            </if>
+            <if test="sbNo != null and sbNo != ''">
+                and sbInfo.no like concat('%',#{sbNo},'%')
+            </if>
+            <if test="typeId != null and typeId != ''">
+                and sbInfo.type_id  = #{typeId}
+            </if>
+            <if test="sbLevel != null and sbLevel != ''">
+                and sbInfo.level = #{sbLevel}
+            </if>
+            <if test="category != null and category != ''">
+                and application.category = #{category}
             </if>
         </where>
     </select>

+ 17 - 0
platform-dao/src/main/resources/mapper/sb/SbInfoMapper.xml

@@ -191,6 +191,8 @@ user.real_name as saveUserName
         left join t_firm_producer producer on sb.producer_id = producer.id
         left join t_sb_position position on sb.position_id = position.id
         left join t_sys_user user on sb.save_user = user.user_id
+        left join t_sys_user user2 on sb.repair_user = user2.user_id
+        left join t_sys_user user3 on sb.repair_user_second = user3.user_id
         left join t_sys_dept sdDept on sb.save_dept = sdDept.dept_id
         where
         1 = 1
@@ -204,6 +206,18 @@ user.real_name as saveUserName
         <if test="zbh != null and zbh!=''">
             and sb.zbh like concat('%',#{zbh},'%')
         </if>
+        <if test="repairUserName != null and repairUserName!=''">
+            and user2.real_name like concat('%',#{repairUserName},'%')
+        </if>
+        <if test="repairUserSecondName != null and repairUserSecondName!=''">
+            and user3.real_name like concat('%',#{repairUserSecondName},'%')
+        </if>
+        <if test="producerName != null and producerName!=''">
+            and producer.name like concat('%',#{producerName},'%')
+        </if>
+        <if test="positionId != null and positionId!=''">
+            and sb.position_id  = #{positionId}
+        </if>
         <if test="likeDeptCode != null and likeDeptCode!=''">
             and sdDept.dept_code like concat(#{likeDeptCode},'%')
         </if>
@@ -252,6 +266,9 @@ user.real_name as saveUserName
         <if test="model != null">
             and sb.model like concat('%',#{model},'%')
         </if>
+        <if test="cph != null">
+            and sb.model like concat('%',#{cph},'%')
+        </if>
         <if test="useDept != null">
             and sb.use_dept = #{useDept}
         </if>

+ 8 - 0
platform-dao/src/main/resources/mapper/sb/SbModelSpareBomMapper.xml

@@ -41,6 +41,14 @@
             <if test="sbId != null">
                 and bom.sb_id = #{sbId}
             </if>
+            <if test="keyword != null and keyword != ''">
+                and (
+                    sbInfo.no like concat('%',#{keyword},'%')
+                    or sbInfo.name like concat('%',#{keyword},'%')
+                    or sbInfo.model like concat('%',#{keyword},'%')
+                    or sbInfo.zbh like concat('%',#{keyword},'%')
+                    )
+            </if>
         </where>
     </select>
 

+ 19 - 2
platform-dao/src/main/resources/mapper/sqarepartmanage/SparePartInfoMapper.xml

@@ -19,10 +19,11 @@
         <result column="image" jdbcType="VARCHAR" property="image"/>
         <result column="qr_code" jdbcType="VARCHAR" property="qrCode"/>
         <result column="level" jdbcType="SMALLINT" property="level"/>
+        <result column="is_special" jdbcType="SMALLINT" property="isSpecial"/>
         <result column="initial_value" jdbcType="DOUBLE" property="initialValue"/>
         <result column="producer_id" jdbcType="VARCHAR" property="producerId"/>
         <result column="supplier_id" jdbcType="VARCHAR" property="supplierId"/>
-        <result column="unit" jdbcType="SMALLINT" property="unit"/>
+        <result column="unit" jdbcType="VARCHAR" property="unit"/>
         <result column="warn_status" jdbcType="SMALLINT" property="warnStatus"/>
         <result column="forecast_status" jdbcType="SMALLINT" property="forecastStatus"/>
         <result column="unit_bz" jdbcType="SMALLINT" property="unitBz"/>
@@ -55,6 +56,7 @@
     <sql id="Base_Column_List">
         id, no, unite_no, gg_no, name_no, name, type_id, level, initial_value, producer_id,
     unit,
+is_special,
     purchase_period,
     use_period,age_period,
     unit_bz,
@@ -89,6 +91,12 @@ warn_status,forecast_status,
             LEFT JOIN t_supplier supplier on supplier.id = info.supplier_id
         </if>
         <where>
+            <if test="spareIdList != null and spareIdList.size > 0">
+                and sparestore.spare_id in
+                <foreach item="item" index="index" collection="spareIdList" open="(" close=")" separator=",">
+                    #{item}
+                </foreach>
+            </if>
             <if test="warnStatusList != null and warnStatusList.size > 0">
                 AND info.warn_status in
                 <foreach item="item" index="index" collection="warnStatusList" open="(" close=")" separator=",">
@@ -105,6 +113,9 @@ warn_status,forecast_status,
             <if test="typeId != null and typeId != ''">
                 and info.type_id = #{typeId}
             </if>
+            <if test="isSpecial != null and isSpecial != ''">
+                and info.is_special = #{isSpecial}
+            </if>
             <if test="producerName != null and producerName != ''">
                 AND producer.name like concat('%',#{producerName},'%')
             </if>
@@ -169,6 +180,9 @@ warn_status,forecast_status,
             <if test="searchMinStockWarn">
                 AND info.warn_status = 0
             </if>
+            <if test="searchType">
+                AND info.type_id not in (select id from t_spare_type)
+            </if>
         </where>
         group by info.id
         <if test="searchMinStockWarn">
@@ -278,7 +292,10 @@ warn_status,forecast_status,
                     warn_status = #{item.warnStatus},
                 </if>
                 <if test="item.forecastStatus != null">
-                    info.forecast_status = #{item.forecastStatus},
+                    forecast_status = #{item.forecastStatus},
+                </if>
+                <if test="item.isSpecial != null">
+                    is_special = #{item.isSpecial},
                 </if>
                 <if test="item.unit != null">
                     child_no = #{item.childNo},

+ 6 - 0
platform-dao/src/main/resources/mapper/store/SpareStoreMapper.xml

@@ -166,6 +166,12 @@
                     or spareinfo.ggxh like concat('%',#{keyword},'%')
                 )
             </if>
+            <if test="spareIdList != null and spareIdList.size > 0">
+                and sparestore.spare_id in
+                <foreach item="item" index="index" collection="spareIdList" open="(" close=")" separator=",">
+                    #{item}
+                </foreach>
+            </if>
             <if test="typeId != null and typeId != ''">
                 and spareinfo.type_id = #{typeId}
             </if>

+ 16 - 4
platform-rest/src/main/java/com/platform/rest/controller/check/CheckJobController.java

@@ -1,10 +1,12 @@
 package com.platform.rest.controller.check;
 
 import cn.hutool.core.collection.CollectionUtil;
+import com.platform.common.util.BigDecimalUtil;
 import com.platform.common.util.R;
 import com.platform.dao.dto.check.CheckJobDTO;
 import com.platform.dao.dto.sb.SbInfoDTO;
 import com.platform.dao.entity.check.CheckJob;
+import com.platform.dao.enums.CheckJobStatusEnum;
 import com.platform.dao.vo.query.check.CheckJobVO;
 import com.platform.service.check.CheckJobService;
 import com.platform.dao.util.ExcelUtil;
@@ -12,6 +14,7 @@ import com.platform.dao.vo.export.check.ExportCheckJobVO;
 import com.platform.common.util.BeanConverterUtil;
 import com.platform.common.validation.group.AddGroup;
 import com.platform.common.validation.group.UpdateGroup;
+import javafx.scene.layout.BackgroundImage;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
@@ -20,6 +23,7 @@ import com.platform.common.bean.AbstractPageResultBean;
 import com.platform.rest.log.annotation.SysLog;
 import org.springframework.web.multipart.MultipartFile;
 
+import java.math.BigDecimal;
 import java.util.List;
 import javax.servlet.http.HttpServletResponse;
 
@@ -183,7 +187,16 @@ public class CheckJobController {
     @PreAuthorize("@pms.hasPermission('check-polling-jobs-export')")
     public void export(HttpServletResponse response, CheckJobDTO checkJobDTO) {
         List<CheckJobVO> list = checkJobService.getVOListByDTO(checkJobDTO);
-        ExcelUtil.exportResponseDict(response, ExportCheckJobVO.class, BeanConverterUtil.copyListProperties(list, ExportCheckJobVO.class), "保养任务");
+        list.forEach(item->{
+            if(item.getRealHours() != null){
+                item.setRealHours(BigDecimalUtil.div(new BigDecimal(item.getRealHours()), new BigDecimal(60)).setScale(2).toString());
+            }
+        });
+        if (checkJobDTO.getStatus() != null && checkJobDTO.getStatus().equals(CheckJobStatusEnum.NOT_EXECUTE.getValue())) {
+            ExcelUtil.exportResponseDict(response, ExportCheckJobVO.class, BeanConverterUtil.copyListProperties(list, ExportCheckJobVO.class), "保养任务");
+        } else {
+            ExcelUtil.exportResponseDict(response, ExportCheckJobVO.class, BeanConverterUtil.copyListProperties(list, ExportCheckJobVO.class), "保养记录");
+        }
     }
 
     /**
@@ -247,12 +260,11 @@ public class CheckJobController {
      * 导入保养标准
      *
      * @param file bom excel文件
-     *
      * @return R
      */
     @SysLog("修改导入保养任务执行时间")
-    @PostMapping(value="/import/update",headers = "content-type=multipart/form-data")
-    public R importListByUpdate( @RequestParam("file") MultipartFile file) throws Exception {
+    @PostMapping(value = "/import/update", headers = "content-type=multipart/form-data")
+    public R importListByUpdate(@RequestParam("file") MultipartFile file) throws Exception {
         String result = checkJobService.importListByUpdate(file);
         return new R<>(result);
     }

+ 2 - 1
platform-rest/src/main/java/com/platform/rest/controller/operate/ArticleController.java

@@ -50,7 +50,8 @@ public class ArticleController {
       BeanConverterUtil.copyObjectProperties(article, vo);
       if(ArticleTypeEnum.CPFW.getValue().equals(article.getType())){
           ArticleDTO dto = new ArticleDTO();
-          dto.setKeyword(article.getTitle());
+          // dto.setKeyword(article.getTitle());
+          dto.setParentId(id);
           ArticleVO voList = articleService.selectCPRelateInfo(dto);
           vo.setList3(voList.getList3());
           vo.setList4(voList.getList4());

+ 157 - 4
platform-rest/src/main/java/com/platform/rest/controller/report/RepairReportController.java

@@ -1,6 +1,8 @@
 package com.platform.rest.controller.report;
 
 import cn.hutool.core.collection.CollectionUtil;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.platform.common.util.BeanConverterUtil;
 import com.platform.common.util.DateUtils;
 import com.platform.common.util.R;
@@ -15,20 +17,21 @@ import com.platform.dao.vo.export.repair.ExportRepairApplicationFormVO;
 import com.platform.dao.vo.export.repair.ExportRepairFeeVO;
 import com.platform.dao.vo.query.check.CheckJobVO;
 import com.platform.dao.vo.repair.RepairApplicationFormVO;
-import com.platform.dao.vo.report.CheckJobReportVO;
-import com.platform.dao.vo.report.RepairReport24VO;
-import com.platform.dao.vo.report.RepairReportFee;
-import com.platform.dao.vo.report.RepairReportMttr;
+import com.platform.dao.vo.report.*;
 import com.platform.rest.log.annotation.SysLog;
 import com.platform.service.check.CheckJobService;
 import com.platform.service.repair.RepairApplicationFormService;
 import com.platform.service.repair.RepairFeeService;
 import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletResponse;
 import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 
 /**
@@ -39,6 +42,7 @@ import java.util.List;
  */
 @RestController
 @AllArgsConstructor
+@Slf4j
 @RequestMapping("/report/repair")
 public class RepairReportController {
 
@@ -262,4 +266,153 @@ public class RepairReportController {
             }
         }
     }
+
+    /**
+     * 1:某个设备一年的故障统计仪表盘,多少次维修。非计划性维修多少次,计划性维修多少次,柱状图,按照年统计:2021,2022.
+     * 统计规则:
+     * 1:堆垛累加
+     * 2:总次数,计划性和非计划性各多少个
+     * 3:寿命曲线图,从哪一年开始的,到结束。如寿命5年,从2019年开始,则2019 5,2020 4,2021 3,2022 2,2023 1, 2024 0
+     *
+     * @param dto 查询条件
+     * @return R
+     */
+    @GetMapping("sbInfo")
+    @SysLog("设备维修统计")
+    public R getSbInfoReport(RepairApplicationFormDTO dto, @RequestParam(required = false) Integer year) {
+        List<RepairSbInfoReport> repairSbInfoReports = repairApplicationFormService.getSbInfoReport(dto, year);
+        JSONObject result = new JSONObject();
+        // 转化列表为叠装柱状图需要的数据形式
+        JSONArray jsonArray = new JSONArray();
+        if (CollectionUtil.isNotEmpty(repairSbInfoReports)) {
+            JSONObject plan = new JSONObject();
+            plan.put("name", "计划性");
+            JSONObject planNot = new JSONObject();
+            planNot.put("name", "非计划性");
+            List<Integer> yearList = new ArrayList<>();
+            for (RepairSbInfoReport repairSbInfoReport : repairSbInfoReports) {
+                plan.put(repairSbInfoReport.getYear() + "", repairSbInfoReport.getNum());
+                planNot.put(repairSbInfoReport.getYear() + "", repairSbInfoReport.getNum());
+                yearList.add(repairSbInfoReport.getYear());
+            }
+            jsonArray.add(plan);
+            jsonArray.add(planNot);
+            result.put("data", jsonArray);
+            result.put("fields", yearList);
+            result.put("dataTable", repairSbInfoReports);
+        }
+        // log.info(result.toJSONString());
+        return new R(result);
+    }
+
+    @GetMapping("/sbInfo/export")
+    @SysLog("设备维修统计导出")
+    public void exportSbInfo(HttpServletResponse response, RepairApplicationFormDTO dto, @RequestParam(required = false) Integer year) {
+        List<RepairSbInfoReport> list = repairApplicationFormService.getSbInfoReport(dto, year);
+        ExcelUtil.exportResponseDict(response, RepairSbInfoReport.class, list, "设备维修统计导出");
+    }
+
+    @GetMapping("/sbInfo/export/year")
+    @SysLog("设备维修统计明细导出")
+    public void exportSbInfoYear(HttpServletResponse response, RepairApplicationFormDTO dto, @RequestParam(required = false) Integer year) {
+        List<RepairSbInfoReport> list = repairApplicationFormService.getSbInfoReport(dto, year);
+        String fileName = "";
+        fileName = year + "-设备维修统计明细导出";
+        if (CollectionUtil.isNotEmpty(list)) {
+            for (RepairSbInfoReport vo : list) {
+                if (vo.getYear().equals(year)) {
+                    List<RepairApplicationFormVO> detailList = vo.getDetailList();
+                    if (CollectionUtil.isNotEmpty(detailList)) {
+                        ExcelUtil.exportResponseDict(response, ExportRepairApplicationFormVO.class, BeanConverterUtil.copyListProperties(detailList, ExportRepairApplicationFormVO.class), fileName);
+                    }
+                }
+            }
+        }
+    }
+
+    public static void main(String[] args) {
+        Integer year = 2021;
+        Integer ss = 2021;
+        System.out.println(year == ss);
+    }
+
+    /**
+     * 费用月统计报表
+     * 统计规则:
+     * 1:所有费用
+     *
+     * @param dto  查询条件
+     * @param year 查询年份
+     * @return R
+     */
+    @GetMapping("/sbInfo/fee")
+    @SysLog("设备费用统计报表")
+    public R getSbInfoReportFee(RepairFeeDTO dto, @RequestParam(required = false) Integer year) {
+        List<RepairSbInfoReportFee> repairSbInfoReports = repairFeeService.getSbInfoReport(dto, year);
+        JSONObject result = new JSONObject();
+        // 转化列表为叠装柱状图需要的数据形式
+        JSONArray jsonArray = new JSONArray();
+        if (CollectionUtil.isNotEmpty(repairSbInfoReports)) {
+            JSONObject plan = new JSONObject();
+            plan.put("name", "计划性");
+            JSONObject planNot = new JSONObject();
+            planNot.put("name", "非计划性");
+            List<Integer> yearList = new ArrayList<>();
+            for (RepairSbInfoReportFee repairSbInfoReport : repairSbInfoReports) {
+                plan.put(repairSbInfoReport.getYear() + "", repairSbInfoReport.getNum());
+                planNot.put(repairSbInfoReport.getYear() + "", repairSbInfoReport.getNum());
+                yearList.add(repairSbInfoReport.getYear());
+            }
+            jsonArray.add(plan);
+            jsonArray.add(planNot);
+            result.put("data", jsonArray);
+            result.put("fields", yearList);
+            result.put("dataTable", repairSbInfoReports);
+        }
+        //log.info(result.toJSONString());
+        return new R(result);
+    }
+
+    /**
+     * 费用月统计报表
+     * 统计规则:
+     * 1:所有费用
+     *
+     * @param dto  查询条件
+     * @param year 查询年份
+     * @return R
+     */
+    @GetMapping("/sbInfo/fee/export")
+    @SysLog("设备费用统计报表导出")
+    public void exportSbInfoFee(HttpServletResponse response, RepairFeeDTO dto, @RequestParam(required = false) Integer year) {
+        List<RepairSbInfoReportFee> list = repairFeeService.getSbInfoReport(dto, year);
+        String fileName = "设备费用统计报表";
+        ExcelUtil.exportResponseDict(response, RepairSbInfoReportFee.class, list, fileName);
+    }
+
+    /**
+     * 费用统计报表
+     * 统计规则:
+     * 1:所有费用
+     *
+     * @param dto  查询条件
+     * @param year 查询年份
+     * @return R
+     */
+    @GetMapping("/sbInfo/fee/export/year")
+    @SysLog("费用月明细导出")
+    public void exportSbInfoFeeYear(HttpServletResponse response, RepairFeeDTO dto, @RequestParam(required = false) Integer year) {
+        List<RepairSbInfoReportFee> list = repairFeeService.getSbInfoReport(dto, year);
+        String fileName = year + "-费用月明细";
+        if (CollectionUtil.isNotEmpty(list)) {
+            for (RepairSbInfoReportFee vo : list) {
+                if (vo.getYear().equals(year)) {
+                    List<RepairFee> detailList = vo.getDetailList();
+                    if (CollectionUtil.isNotEmpty(detailList)) {
+                        ExcelUtil.exportResponseDict(response, ExportRepairFeeVO.class, BeanConverterUtil.copyListProperties(detailList, ExportRepairFeeVO.class), fileName);
+                    }
+                }
+            }
+        }
+    }
 }

+ 22 - 16
platform-rest/src/main/java/com/platform/rest/controller/sqarepartmanage/SparePartInfoController.java

@@ -1,5 +1,6 @@
 package com.platform.rest.controller.sqarepartmanage;
 
+import com.platform.common.exception.BusinessException;
 import com.platform.common.util.R;
 import com.platform.common.util.StringUtils;
 import com.platform.dao.dto.sb.SbModelDTO;
@@ -186,6 +187,7 @@ public class SparePartInfoController {
 
     /**
      * 获取分页
+     *
      * @param pageNum  当前页码
      * @param pageSize 每页条数
      * @param month    查询最近几个月的-距离当前系统时间
@@ -218,26 +220,30 @@ public class SparePartInfoController {
     @SysLog("备件基础信息导出")
     @PreAuthorize("@pms.hasPermission('sqarepartmanage-spare-part-info-export')")
     public void export(HttpServletResponse response, SparePartInfoDTO sparePartInfoDTO) {
-        List<SparePartInfo> list = sparePartInfoService.getModelListByDTO(sparePartInfoDTO);
-        // 如果没有编码先更新编码
-        for (SparePartInfo sparePartInfo : list) {
-            if (StringUtils.isBlank(sparePartInfo.getNo())) {
-                sparePartInfoService.updateSpareNo(sparePartInfo);
+        try {
+            List<SparePartInfo> list = sparePartInfoService.getModelListByDTO(sparePartInfoDTO);
+            // 如果没有编码先更新编码
+            for (SparePartInfo sparePartInfo : list) {
+                if (StringUtils.isBlank(sparePartInfo.getNo())) {
+                    sparePartInfoService.updateSpareNo(sparePartInfo);
+                }
             }
-        }
-        // 查询备件关联的设备型号信息
-        List<SbModelVO> modelList = sbModelService.selectVOList(new SbModelDTO());
-        List<SbModelSpareBomVO> bomList = sbModelSpareBomService.selectExportList(sparePartInfoDTO);
-        for (SparePartInfo sparePartInfo : list) {
-            for (SbModelSpareBomVO sbModelSpareBomVO : bomList) {
-                if (sparePartInfo.getId().equals(sbModelSpareBomVO.getSpareId())) {
-                    sparePartInfo.setModelName(sbModelSpareBomVO.getName());
-                    sparePartInfo.setModelModel(sbModelSpareBomVO.getModel());
-                    break;
+            // 查询备件关联的设备型号信息
+            List<SbModelSpareBomVO> bomList = sbModelSpareBomService.selectExportList(sparePartInfoDTO);
+            for (SparePartInfo sparePartInfo : list) {
+                for (SbModelSpareBomVO sbModelSpareBomVO : bomList) {
+                    if (sparePartInfo.getId().equals(sbModelSpareBomVO.getSpareId())) {
+                        sparePartInfo.setModelName(sbModelSpareBomVO.getName());
+                        sparePartInfo.setModelModel(sbModelSpareBomVO.getModel());
+                        break;
+                    }
                 }
             }
+            ExcelUtil.exportResponseDict(response, ExportSparePartInfoVO.class, BeanConverterUtil.copyListProperties(list, ExportSparePartInfoVO.class), "备件基础信息");
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw new BusinessException("导出出错," + e.getMessage());
         }
-        ExcelUtil.exportResponseDict(response, ExportSparePartInfoVO.class, BeanConverterUtil.copyListProperties(list, ExportSparePartInfoVO.class), "备件基础信息");
     }
 
     /**

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

@@ -647,7 +647,7 @@ public class CheckJobServiceImpl extends BaseServiceImpl<CheckJobMapper, CheckJo
         // 2.判断当前时间是否大于结束时间是则设置状态未已过期
         LocalDate now = LocalDate.now();
         checkJobs.forEach(job -> {
-            LocalDate endTime = job.getEndTime();
+            LocalDate endTime = job.getStartTime();
             if (now.isAfter(endTime)) {
                 CheckJob updateJob = new CheckJob();
                 updateJob.setId(job.getId());

+ 2 - 0
platform-service/src/main/java/com/platform/service/repair/RepairApplicationFormService.java

@@ -12,6 +12,7 @@ import com.platform.dao.vo.repair.RepairApplicationFormVO;
 import com.platform.dao.vo.repair.RepairFormVO;
 import com.platform.dao.vo.report.RepairReport24VO;
 import com.platform.dao.vo.report.RepairReportMttr;
+import com.platform.dao.vo.report.RepairSbInfoReport;
 import com.platform.service.base.IBaseService;
 
 import java.time.LocalDate;
@@ -119,4 +120,5 @@ public interface RepairApplicationFormService extends IBaseService<RepairApplica
 
     List<RepairReportMttr> getMonthReportMtrr(RepairApplicationFormDTO repairApplicationFormDTO, Integer year, LocalDate startMonth, LocalDate endMonth);
 
+    List<RepairSbInfoReport>  getSbInfoReport(RepairApplicationFormDTO dto, Integer year);
 }

+ 2 - 0
platform-service/src/main/java/com/platform/service/repair/RepairFeeService.java

@@ -5,6 +5,7 @@ import com.platform.dao.dto.repair.RepairFeeDTO;
 import com.platform.dao.entity.repair.RepairFee;
 import com.platform.dao.vo.report.RepairReportFee;
 import com.platform.dao.vo.report.RepairReportMttr;
+import com.platform.dao.vo.report.RepairSbInfoReportFee;
 import com.platform.service.base.IBaseService;
 
 import java.time.LocalDate;
@@ -28,4 +29,5 @@ public interface RepairFeeService extends IBaseService<RepairFee, RepairFeeDTO>
 
     List<RepairReportFee> getMonthReport(RepairFeeDTO repairFeeDTO, Integer year, LocalDate startMonth, LocalDate endMonth);
 
+    List<RepairSbInfoReportFee> getSbInfoReport(RepairFeeDTO dto, Integer year);
 }

+ 86 - 11
platform-service/src/main/java/com/platform/service/repair/impl/RepairApplicationFormServiceImpl.java

@@ -6,7 +6,9 @@ import cn.hutool.core.util.ObjectUtil;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.github.pagehelper.PageHelper;
+import com.platform.common.bean.DictVO;
 import com.platform.common.cache.ConfigCache;
+import com.platform.common.cache.DictCache;
 import com.platform.common.constant.RedisKeyConstants;
 import com.platform.common.enums.DataFilterTypeEnum;
 import com.platform.common.exception.BusinessException;
@@ -46,6 +48,7 @@ import com.platform.dao.vo.repair.RepairCheckVO;
 import com.platform.dao.vo.repair.RepairFormVO;
 import com.platform.dao.vo.report.RepairReport24VO;
 import com.platform.dao.vo.report.RepairReportMttr;
+import com.platform.dao.vo.report.RepairSbInfoReport;
 import com.platform.dao.vo.sb.SbInfoVO;
 import com.platform.office.annotation.Excel;
 import com.platform.service.base.impl.BaseServiceImpl;
@@ -103,7 +106,7 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
     public List<RepairApplicationFormVO> getVOListByDTO(RepairApplicationFormDTO model) {
         List<RepairApplicationFormVO> list = mapper.selectPageList(model);
 
-        if(CollectionUtil.isNotEmpty(list)){
+        if (CollectionUtil.isNotEmpty(list)) {
             List<String> ids = list.stream().map(RepairApplicationFormVO::getId).collect(Collectors.toList());
             Weekend<RepairReason> detailWeekend = new Weekend<>(RepairReason.class);
             detailWeekend.weekendCriteria().andIn(RepairReason::getRepairId, ids);
@@ -619,9 +622,10 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
     /**
      * 完成为待验收状态,此时需要再次编辑维修内容,最终提交审核
      * 完成同时将设备状态为使用中
-     *  需要记录
-     *  1:维修时间=维修结束-维修开始
-     *  2:停机时间=维修结束-报修开始
+     * 需要记录
+     * 1:维修时间=维修结束-维修开始
+     * 2:停机时间=维修结束-报修开始
+     *
      * @param dto
      */
     @Override
@@ -779,8 +783,8 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
                     continue;
                 }
                 if (type == 1) {
-                    double minites = repairApplicationForm.getDealMinutes();
-                    if (minites / 60.0 < 24.0) {
+                    double minutes = repairApplicationForm.getDealMinutes();
+                    if (minutes < 24.0) {
                         continue;
                     }
                 }
@@ -792,6 +796,76 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
             vo.setNum(i);
             vo.setDetailList(detailList);
             result.add(vo);
+            if (type == 2) {
+                i = 0;
+            }
+        }
+        return result;
+    }
+
+    /**
+     * @param repairApplicationFormDTO
+     * @param year
+     * @return
+     */
+    @Override
+    public List<RepairSbInfoReport> getSbInfoReport(RepairApplicationFormDTO repairApplicationFormDTO, Integer year) {
+        // 查询设备信息
+        SbInfo sbInfo = sbInfoService.getModelById(repairApplicationFormDTO.getSbId());
+        if (sbInfo == null) {
+            throw new BusinessException("设备不存在,请重新选择");
+        }
+        if (sbInfo.getWorkYear() == null) {
+            throw new BusinessException("请设置使用寿命");
+        }
+        if (sbInfo.getStartDate() == null) {
+            throw new BusinessException("请设置设备投用日期");
+        }
+        Double sbWorkYear = sbInfo.getWorkYear();
+        int sbStartYear = sbInfo.getStartDate().getYear();
+        int startYear = sbInfo.getStartDate().getYear();
+        int endYear = LocalDate.now().getYear();
+        if (year != null) {
+            startYear = year;
+            endYear = year;
+        }
+        List<Map<String, LocalDateTime>> monthStartAndEndList = new ArrayList<Map<String, LocalDateTime>>();
+        LocalDateTime searchStartTime = null;
+        LocalDateTime searchEndTime = null;
+        monthStartAndEndList = DateUtils.getYearStartAndEndByYear(startYear, endYear);
+        searchStartTime = DateUtils.getFirstDayOfThisYear(startYear);
+        searchEndTime = DateUtils.getLastDayOfThisYear(endYear);
+
+        // 选择订单时间
+        repairApplicationFormDTO.setSearchStartTime(searchStartTime);
+        repairApplicationFormDTO.setSearchEndTime(searchEndTime);
+        List<RepairApplicationFormVO> list = mapper.selectPageList(repairApplicationFormDTO);
+        List<RepairSbInfoReport> result = new ArrayList<>();
+        List<DictVO> children = DictCache.getChildren("REPAIR_APPLICATION_FORM_CATEGORY");
+        if (CollectionUtil.isNotEmpty(children)) {
+            for (DictVO dictVO : children) {
+                for (Map<String, LocalDateTime> map : monthStartAndEndList) {
+                    int num = 0;
+                    RepairSbInfoReport vo = new RepairSbInfoReport();
+                    List<RepairApplicationFormVO> detailList = new ArrayList<>();
+                    vo.setYear(map.get("searchStartTime").getYear());
+                    double workYear = sbWorkYear - (map.get("searchStartTime").getYear() - sbStartYear);
+                    for (RepairApplicationFormVO repairApplicationForm : list) {
+                        if (repairApplicationForm.getApplyTime().isAfter(map.get("searchStartTime")) && repairApplicationForm.getApplyTime().isBefore(map.get("searchEndTime"))) {
+                            if (repairApplicationForm.getCategory() != null && dictVO.getValue().equals(repairApplicationForm.getCategory())) {
+                               num++;
+                               detailList.add(repairApplicationForm);
+                            }
+                        }
+                    }
+                    vo.setWorkYear(workYear);
+                    vo.setNum(num);
+                    vo.setCategory(Integer.valueOf(dictVO.getValue().toString()));
+                    vo.setName(dictVO.getLabel());
+                    vo.setDetailList(detailList);
+                    result.add(vo);
+                }
+            }
         }
         return result;
     }
@@ -845,7 +919,7 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
             double meanMinuties = 0.0;
             int i = 0;
             for (RepairApplicationFormVO repairApplicationForm : list) {
-                if (repairApplicationForm.getDealMinutes() == null || ((repairApplicationForm.getDealMinutes() / 60.0) > 24.0)) {
+                if (repairApplicationForm.getDealMinutes() == null || (repairApplicationForm.getDealMinutes() > 24.0)) {
                     continue;
                 }
                 if (repairApplicationForm.getApplyTime().isAfter(map.get("searchStartTimeMonth")) && repairApplicationForm.getApplyTime().isBefore(map.get("searchEndTimeMonth"))) {
@@ -874,10 +948,11 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
 
     /**
      * 修改维修单时间
-     *  需要重新记录实际
-     *   1:接收时间=维修开始-报修开始
-     *  2:维修时间=维修结束-维修开始
-     *  3:停机时间=维修结束-报修开始
+     * 需要重新记录实际
+     * 1:接收时间=维修开始-报修开始
+     * 2:维修时间=维修结束-维修开始
+     * 3:停机时间=维修结束-报修开始
+     *
      * @param dto
      */
     @Override

+ 86 - 1
platform-service/src/main/java/com/platform/service/repair/impl/RepairFeeServiceImpl.java

@@ -3,6 +3,9 @@ package com.platform.service.repair.impl;
 import cn.hutool.core.collection.CollectionUtil;
 import com.github.pagehelper.PageHelper;
 import com.platform.common.bean.AbstractPageResultBean;
+import com.platform.common.bean.DictVO;
+import com.platform.common.cache.DictCache;
+import com.platform.common.exception.BusinessException;
 import com.platform.common.util.BigDecimalUtil;
 import com.platform.common.util.DateUtils;
 import com.platform.common.util.IdGeneratorUtils;
@@ -13,6 +16,7 @@ import com.platform.dao.dto.repair.RepairApplicationFormDTO;
 import com.platform.dao.dto.repair.RepairFeeDTO;
 import com.platform.dao.entity.repair.RepairApplicationForm;
 import com.platform.dao.entity.repair.RepairFee;
+import com.platform.dao.entity.sb.SbInfo;
 import com.platform.dao.entity.upms.SysFile;
 import com.platform.dao.enums.RepairApplicationFormCategoryEnum;
 import com.platform.dao.enums.SysFileTypeEnum;
@@ -22,8 +26,10 @@ import com.platform.dao.mapper.upms.SysFileMapper;
 import com.platform.dao.vo.repair.RepairApplicationFormVO;
 import com.platform.dao.vo.report.RepairReportFee;
 import com.platform.dao.vo.report.RepairReportMttr;
+import com.platform.dao.vo.report.RepairSbInfoReportFee;
 import com.platform.service.base.impl.BaseServiceImpl;
 import com.platform.service.repair.RepairFeeService;
+import com.platform.service.sb.SbInfoService;
 import com.platform.service.util.SysFileUtils;
 import lombok.AllArgsConstructor;
 import org.springframework.stereotype.Service;
@@ -50,6 +56,8 @@ public class RepairFeeServiceImpl extends BaseServiceImpl<RepairFeeMapper, Repai
 
     private final RepairApplicationFormMapper repairApplicationFormMapper;
 
+    private final SbInfoService sbInfoService;
+
     @Override
     public int batchDelete(List<String> ids) {
         Weekend<RepairFee> weekend = new Weekend<>(RepairFee.class);
@@ -178,7 +186,7 @@ public class RepairFeeServiceImpl extends BaseServiceImpl<RepairFeeMapper, Repai
             double meanFee = 0.0;
             int i = 0;
             for (RepairFee fee : list) {
-                if ((fee.getFeeDate().compareTo(map.get("searchStartTimeMonth").toLocalDate())>=0) && (fee.getFeeDate().compareTo(map.get("searchEndTimeMonth").toLocalDate())<=0)) {
+                if ((fee.getFeeDate().compareTo(map.get("searchStartTimeMonth").toLocalDate()) >= 0) && (fee.getFeeDate().compareTo(map.get("searchEndTimeMonth").toLocalDate()) <= 0)) {
                     i++;
                     detailList.add(fee);
                     totalFee = totalFee + fee.getFee();
@@ -198,4 +206,81 @@ public class RepairFeeServiceImpl extends BaseServiceImpl<RepairFeeMapper, Repai
         }
         return result;
     }
+
+    /**
+     * 1: 如果年份是当前年份,则统计到当前月份
+     * 2:如果不是当前年份,则统计全年的
+     *
+     * @param repairApplicationFormDTO
+     * @param year                     查询年份
+     * @return
+     */
+    @Override
+    public List<RepairSbInfoReportFee> getSbInfoReport(RepairFeeDTO repairApplicationFormDTO, Integer year) {
+        // 查询设备信息
+        SbInfo sbInfo = sbInfoService.getModelById(repairApplicationFormDTO.getSbId());
+        if (sbInfo == null) {
+            throw new BusinessException("设备不存在,请重新选择");
+        }
+        if (sbInfo.getWorkYear() == null) {
+            throw new BusinessException("请设置使用寿命");
+        }
+        if (sbInfo.getStartDate() == null) {
+            throw new BusinessException("请设置设备投用日期");
+        }
+        Double sbWorkYear = sbInfo.getWorkYear();
+        int sbStartYear = sbInfo.getStartDate().getYear();
+        int startYear = sbInfo.getStartDate().getYear();
+        int endYear = LocalDate.now().getYear();
+        if (year != null) {
+            startYear = year;
+            endYear = year;
+        }
+        List<Map<String, LocalDateTime>> monthStartAndEndList = new ArrayList<Map<String, LocalDateTime>>();
+        LocalDateTime searchStartTime = null;
+        LocalDateTime searchEndTime = null;
+        monthStartAndEndList = DateUtils.getYearStartAndEndByYear(startYear, endYear);
+        searchStartTime = DateUtils.getFirstDayOfThisYear(startYear);
+        searchEndTime = DateUtils.getLastDayOfThisYear(endYear);
+
+        repairApplicationFormDTO.setSearchStartTime(searchStartTime);
+        repairApplicationFormDTO.setSearchEndTime(searchEndTime);
+        List<RepairFee> list = mapper.selectPageList(repairApplicationFormDTO);
+        List<RepairSbInfoReportFee> result = new ArrayList<RepairSbInfoReportFee>();
+        List<DictVO> children = DictCache.getChildren("REPAIR_FEE_TYPE");
+        if (CollectionUtil.isNotEmpty(children)) {
+            for (DictVO dictVO : children) {
+                for (Map<String, LocalDateTime> map : monthStartAndEndList) {
+                    RepairSbInfoReportFee vo = new RepairSbInfoReportFee();
+                    List<RepairFee> detailList = new ArrayList<RepairFee>();
+                    vo.setYear(map.get("searchStartTime").getYear());
+                    double workYear = sbWorkYear - (map.get("searchStartTime").getYear() - sbStartYear);
+                    double totalFee = 0.0;
+                    double meanFee = 0.0;
+                    int i = 0;
+                    for (RepairFee fee : list) {
+                        if ((fee.getFeeDate().compareTo(map.get("searchStartTime").toLocalDate()) >= 0) && (fee.getFeeDate().compareTo(map.get("searchEndTime").toLocalDate()) <= 0)) {
+                            if (fee.getType() != null && dictVO.getValue().equals(fee.getType())) {
+                                i++;
+                                detailList.add(fee);
+                                totalFee = totalFee + fee.getFee();
+                            }
+                        }
+                    }
+                    if (totalFee == 0.0) {
+                    } else {
+                        totalFee = BigDecimalUtil.decimal(totalFee, 2);
+                    }
+                    vo.setWorkYear(workYear);
+                    vo.setTotalFee(totalFee);
+                    vo.setNum(i);
+                    vo.setType(Integer.valueOf(dictVO.getValue().toString()));
+                    vo.setName(dictVO.getLabel());
+                    vo.setDetailList(detailList);
+                    result.add(vo);
+                }
+            }
+        }
+        return result;
+    }
 }

+ 26 - 0
platform-service/src/main/java/com/platform/service/sqarepartmanage/impl/SparePartInfoServiceImpl.java

@@ -49,8 +49,10 @@ import com.platform.dao.vo.query.check.CheckStandardSpareVO;
 import com.platform.dao.vo.query.sparepartmanage.SparePartInfoVO;
 import com.platform.dao.vo.query.store.SpareStoreVO;
 import com.platform.dao.vo.sb.SbInfoVO;
+import com.platform.dao.vo.sb.SbModelSpareBomVO;
 import com.platform.service.check.CheckStandardService;
 import com.platform.service.event.WorkplaceBacklogEvent;
+import com.platform.service.sb.SbModelSpareBomService;
 import com.platform.service.sqarepartmanage.SparePartInfoService;
 import com.platform.service.sqarepartmanage.SpareTypeService;
 import com.platform.service.util.CodeFileUtils;
@@ -96,6 +98,7 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
     private CheckJobMapper checkJobMapper;
     private CheckStandardSpareMapper checkStandardSpareMapper;
     private CheckStandardService checkStandardService;
+
     @Override
     public int batchDelete(List<String> ids) {
 
@@ -281,6 +284,20 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
 
     @Override
     public List<SparePartInfo> getModelListByDTO(SparePartInfoDTO sparePartInfoDTO) {
+        if (sparePartInfoDTO.getTypeId() != null) {
+            Weekend<SpareType> weekend = new Weekend<>(SpareType.class);
+            WeekendCriteria<SpareType, Object> weekendCriteria = weekend.weekendCriteria();
+            weekendCriteria.andEqualTo(SpareType::getParentId, sparePartInfoDTO.getTypeId());
+            List<SpareType> childList = spareTypeMapper.selectByExample(weekend);
+            List<String> typeIds = new ArrayList<String>();
+            typeIds.add(sparePartInfoDTO.getTypeId());
+            if (!CollectionUtils.isEmpty(childList)) {
+                childList.forEach(item -> {
+                    typeIds.add(item.getId());
+                });
+            }
+            sparePartInfoDTO.setTypeIds(typeIds);
+        }
         if (sparePartInfoDTO.getTypeId() != null) {
             Weekend<SpareType> weekend = new Weekend<>(SpareType.class);
             WeekendCriteria<SpareType, Object> weekendCriteria = weekend.weekendCriteria();
@@ -324,6 +341,15 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
 
     @Override
     public AbstractPageResultBean<SparePartInfo> selectPageInfo(SparePartInfoDTO record, int pageNum, int pageSize) {
+
+        if(StringUtils.isNotEmpty(record.getModel())){
+            SbModelSpareBomDTO sbModelDTO = new SbModelSpareBomDTO();
+            sbModelDTO.setKeyword(record.getModel());
+            List<SbModelSpareBomVO> modelList = sbModelSpareBomMapper.selectVOList(sbModelDTO);
+            List<String> spareList = modelList.stream().map(item -> item.getSpareId()).distinct().collect(Collectors.toList());
+            record.setSpareIdList(spareList);
+        }
+
         // 选择设备对应的备件bom列表
         if (record.getSbId() != null) {
             SbInfoVO sbInfo = sbInfoMapper.getById(record.getSbId());

+ 13 - 4
platform-service/src/main/java/com/platform/service/store/impl/SpareStoreServiceImpl.java

@@ -7,14 +7,12 @@ import com.platform.common.constant.CommonConstants;
 import com.platform.common.enums.DataFilterTypeEnum;
 import com.platform.common.exception.BusinessException;
 import com.platform.common.model.UserInfo;
-import com.platform.common.util.BeanConverterUtil;
-import com.platform.common.util.BeanUtils;
-import com.platform.common.util.IdGeneratorUtils;
-import com.platform.common.util.SecurityUtils;
+import com.platform.common.util.*;
 import com.platform.dao.bean.MyPage;
 import com.github.pagehelper.PageHelper;
 import com.platform.dao.bean.MyVOPage;
 import com.platform.dao.dto.sb.SbInfoDTO;
+import com.platform.dao.dto.sb.SbModelSpareBomDTO;
 import com.platform.dao.dto.sqarepartmanage.SparePartInfoDTO;
 import com.platform.dao.dto.sqarepartmanage.SpareTypeDTO;
 import com.platform.dao.dto.store.SpareStoreDTO;
@@ -36,6 +34,8 @@ import com.platform.dao.util.CustomExcelImportUtil;
 import com.platform.dao.vo.query.store.SpareStoreVO;
 import com.platform.dao.vo.query.store.StoreVO;
 import com.platform.dao.vo.query.upms.SysDeptVO;
+import com.platform.dao.vo.sb.SbModelSpareBomVO;
+import com.platform.service.sb.SbModelSpareBomService;
 import com.platform.service.sqarepartmanage.SpareTypeService;
 import com.platform.service.store.SpareStoreService;
 import com.platform.service.store.StoreService;
@@ -71,6 +71,7 @@ public class SpareStoreServiceImpl extends BaseServiceImpl<SpareStoreMapper, Spa
     private final Environment environment;
     private SysUserDeptService sysUserDeptService;
     private SysDeptService sysDeptService;
+    private SbModelSpareBomService sbModelSpareBomService;
 
     @Override
     public SpareStoreVO getDetail(Object id) {
@@ -173,6 +174,14 @@ public class SpareStoreServiceImpl extends BaseServiceImpl<SpareStoreMapper, Spa
             }
             model.setUseCompany(list.get(0).getDeptId());
         }*/
+        // 查询设备型号下面的备件
+        if(StringUtils.isNotEmpty(model.getModel())){
+            SbModelSpareBomDTO sbModelDTO = new SbModelSpareBomDTO();
+            sbModelDTO.setKeyword(model.getModel());
+            List<SbModelSpareBomVO> modelList = sbModelSpareBomService.selectVOList(sbModelDTO);
+            List<String> spareList = modelList.stream().map(item -> item.getSpareId()).distinct().collect(Collectors.toList());
+            model.setSpareIdList(spareList);
+        }
         PageHelper.startPage(pageNum, pageSize);
         return new MyPage<>(mapper.selectList(model));
     }