Selaa lähdekoodia

Merge remote-tracking branch 'origin/demo_' into demo_

hfxc226 3 vuotta sitten
vanhempi
commit
b831696eea
41 muutettua tiedostoa jossa 1054 lisäystä ja 82 poistoa
  1. 28 0
      platform-common/src/main/java/com/platform/common/constant/CommonConstants.java
  2. 13 3
      platform-common/src/main/java/com/platform/common/util/DateUtils.java
  3. 6 0
      platform-dao/src/main/java/com/platform/dao/dto/repair/RepairApplicationFormDTO.java
  4. 4 0
      platform-dao/src/main/java/com/platform/dao/dto/repair/RepairFeeDTO.java
  5. 2 0
      platform-dao/src/main/java/com/platform/dao/dto/sb/SbModelSpareBomDTO.java
  6. 6 0
      platform-dao/src/main/java/com/platform/dao/dto/sqarepartmanage/SparePartInfoDTO.java
  7. 15 0
      platform-dao/src/main/java/com/platform/dao/dto/sqarepartmanage/SparePartUsedDTO.java
  8. 5 0
      platform-dao/src/main/java/com/platform/dao/dto/store/SpareStoreDTO.java
  9. 7 1
      platform-dao/src/main/java/com/platform/dao/entity/sqarepartmanage/SparePartUsed.java
  10. 27 0
      platform-dao/src/main/java/com/platform/dao/enums/SparePartUsedSourceEnum.java
  11. 1 1
      platform-dao/src/main/java/com/platform/dao/enums/SparePartUsedStatusEnum.java
  12. 1 0
      platform-dao/src/main/java/com/platform/dao/enums/SysConfigEnum.java
  13. 9 0
      platform-dao/src/main/java/com/platform/dao/mapper/repair/RepairApplicationFormMapper.java
  14. 8 0
      platform-dao/src/main/java/com/platform/dao/mapper/repair/RepairFeeMapper.java
  15. 7 0
      platform-dao/src/main/java/com/platform/dao/mapper/sqarepartmanage/SparePartInfoMapper.java
  16. 7 0
      platform-dao/src/main/java/com/platform/dao/mapper/sqarepartmanage/SparePartUsedMapper.java
  17. 83 0
      platform-dao/src/main/java/com/platform/dao/vo/export/sqarepartmanage/ExportSparePartUsedReportVO.java
  18. 94 0
      platform-dao/src/main/java/com/platform/dao/vo/query/repair/RepairFeeVO.java
  19. 17 0
      platform-dao/src/main/java/com/platform/dao/vo/query/sparepartmanage/SparePartInfoVO.java
  20. 86 0
      platform-dao/src/main/java/com/platform/dao/vo/query/workplace/WorkplaceRepairVO.java
  21. 12 0
      platform-dao/src/main/java/com/platform/dao/vo/repair/RepairApplicationFormVO.java
  22. 45 0
      platform-dao/src/main/java/com/platform/dao/vo/report/SparePartInfoReportVO.java
  23. 12 0
      platform-dao/src/main/java/com/platform/dao/vo/spare/SparePartUsedVO.java
  24. 36 0
      platform-dao/src/main/resources/mapper/repair/RepairApplicationFormMapper.xml
  25. 16 0
      platform-dao/src/main/resources/mapper/repair/RepairFeeMapper.xml
  26. 18 1
      platform-dao/src/main/resources/mapper/sqarepartmanage/SparePartInfoMapper.xml
  27. 27 2
      platform-dao/src/main/resources/mapper/sqarepartmanage/SparePartUsedMapper.xml
  28. 4 1
      platform-rest/src/main/java/com/platform/rest/controller/repair/RepairFeeController.java
  29. 88 0
      platform-rest/src/main/java/com/platform/rest/controller/report/SparePartInfoReportController.java
  30. 23 16
      platform-rest/src/main/java/com/platform/rest/controller/sqarepartmanage/SparePartInfoController.java
  31. 4 4
      platform-rest/src/main/java/com/platform/rest/controller/sqarepartmanage/SparePartUsedController.java
  32. 13 0
      platform-service/src/main/java/com/platform/service/repair/RepairApplicationFormService.java
  33. 3 2
      platform-service/src/main/java/com/platform/service/repair/RepairFeeService.java
  34. 111 24
      platform-service/src/main/java/com/platform/service/repair/impl/RepairApplicationFormServiceImpl.java
  35. 46 0
      platform-service/src/main/java/com/platform/service/repair/impl/RepairFeeServiceImpl.java
  36. 6 0
      platform-service/src/main/java/com/platform/service/sb/SbModelSpareBomService.java
  37. 17 0
      platform-service/src/main/java/com/platform/service/sb/impl/SbModelSpareBomServiceImpl.java
  38. 10 0
      platform-service/src/main/java/com/platform/service/sqarepartmanage/SparePartInfoService.java
  39. 21 1
      platform-service/src/main/java/com/platform/service/sqarepartmanage/SparePartUsedService.java
  40. 38 17
      platform-service/src/main/java/com/platform/service/sqarepartmanage/impl/SparePartInfoServiceImpl.java
  41. 78 9
      platform-service/src/main/java/com/platform/service/sqarepartmanage/impl/SparePartUsedServiceImpl.java

+ 28 - 0
platform-common/src/main/java/com/platform/common/constant/CommonConstants.java

@@ -197,4 +197,32 @@ public interface CommonConstants {
      * 工作流历史记录
      */
     String ACT_AUDIT_RECORD = "ACT_AUDIT_RECORD";
+
+    /**
+     * 维修状态
+     */
+    /**
+     * 待接收
+     */
+    int NOT_ALLOCATED = 1;
+    /**
+     * 维修中
+     */
+    int PROCESSING = 2;
+    /**
+     * 待审核
+     */
+    int WAIT_SUBMIT = 3;
+    /**
+     * 审核中
+     */
+    int NOT_ACCEPTANCE = 4;
+    /**
+     * 已驳回
+     */
+    int REBACK = 5;
+    /**
+     * 	已完成
+     */
+    int FINISHED = 6;
 }

+ 13 - 3
platform-common/src/main/java/com/platform/common/util/DateUtils.java

@@ -476,7 +476,7 @@ public class DateUtils {
     }
 
     /**
-     * 指定年份,一直到指定月份的每个月的开始时间和结束时间
+     * 指定年份,一直到指定月份的每个月的开始时间和结束时间:
      *
      * @param year
      * @param month
@@ -487,8 +487,8 @@ public class DateUtils {
         // 每年的 一月一号,零时零分零秒
         for(int i = 1;i<month;i++){
             Map<String, LocalDateTime> dateTimeMap = new HashMap<String, LocalDateTime>();
-            LocalDateTime searchStartTimeMonth = getFirstDayOfMonth(year, i);
-            LocalDateTime searchEndTimeMonth = getLastDayOfMonth(year, i);
+            LocalDateTime searchStartTimeMonth = getFirstDayOfMonth(year, i).plusDays(-1);
+            LocalDateTime searchEndTimeMonth = getLastDayOfMonth(year, i).plusDays(1);
             dateTimeMap.put("searchStartTimeMonth", searchStartTimeMonth);
             dateTimeMap.put("searchEndTimeMonth",searchEndTimeMonth);
             monthStartAndEndList.add(dateTimeMap);
@@ -572,6 +572,16 @@ public class DateUtils {
         return  weekStartAndEndList;
     }
 
+    public static List<LocalDateTime> currentWeek(){
+        List<LocalDateTime> list = new ArrayList<>();
+        LocalDateTime now = LocalDateTime.now();
+        for(int i=-6;i<0;i++){
+            list.add(now.plusDays(i));
+        }
+        list.add(now);
+        return list;
+    }
+
 
 }
 

+ 6 - 0
platform-dao/src/main/java/com/platform/dao/dto/repair/RepairApplicationFormDTO.java

@@ -317,4 +317,10 @@ public class RepairApplicationFormDTO extends BaseDTO implements Serializable {
      * 搜索结束时间:报修时间
      */
     private LocalDateTime searchEndTime;
+
+    private String searchTime;
+
+    private LocalDateTime searchTimeStart;
+
+    private LocalDateTime searchTimeEnd;
 }

+ 4 - 0
platform-dao/src/main/java/com/platform/dao/dto/repair/RepairFeeDTO.java

@@ -138,4 +138,8 @@ public class RepairFeeDTO extends BaseDTO implements Serializable {
      */
     private LocalDateTime searchEndTime;
 
+    private String repairUserId;
+
+    private String searchTime;
+
 }

+ 2 - 0
platform-dao/src/main/java/com/platform/dao/dto/sb/SbModelSpareBomDTO.java

@@ -119,4 +119,6 @@ public class SbModelSpareBomDTO extends BaseDTO implements Serializable {
      */
     private List<SparePartInfoDTO> sparePartInfoList;
 
+    private String oldSpareId;
+
 }

+ 6 - 0
platform-dao/src/main/java/com/platform/dao/dto/sqarepartmanage/SparePartInfoDTO.java

@@ -293,4 +293,10 @@ public class SparePartInfoDTO extends BaseDTO implements Serializable {
      * 设备列表
      */
     private List<SbModelSpareBomDTO> detailList;
+
+    /**
+     * 请求来源
+     * 参照SparePartUsedSourceEnum
+     */
+    private Integer usedSource;
 }

+ 15 - 0
platform-dao/src/main/java/com/platform/dao/dto/sqarepartmanage/SparePartUsedDTO.java

@@ -125,5 +125,20 @@ public class SparePartUsedDTO extends BaseDTO implements Serializable {
 
     private String spareName;
 
+    /**
+     * 搜索开始时间
+     */
+    private LocalDate searchStartTime;
+
+    /**
+     * 搜索结束时间
+     */
+    private LocalDate searchEndTime;
+
+    /**
+     * 消耗来源
+     * 参照SparePartUsedSourceEnum
+     */
+    private Integer usedSource;
 
 }

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

@@ -177,4 +177,9 @@ public class SpareStoreDTO extends BaseDTO implements Serializable {
      */
     private String typeNameLike;
 
+    /**
+     * 设备ID
+     */
+    private String sbId;
+
 }

+ 7 - 1
platform-dao/src/main/java/com/platform/dao/entity/sqarepartmanage/SparePartUsed.java

@@ -73,7 +73,7 @@ public class SparePartUsed implements Serializable {
      */
     private LocalDate startDate;
     /**
-     * 使用状态:1-未出库;2-已出库
+     * 使用状态: 2 已废弃 1 使用中
      */
     private Integer status;
     /**
@@ -105,6 +105,12 @@ public class SparePartUsed implements Serializable {
      */
     private LocalDateTime updateTime;
 
+    /**
+     * 消耗来源
+     * 参照SparePartUsedSourceEnum
+     */
+    private Integer usedSource;
+
     /**
      * 创建人
      */

+ 27 - 0
platform-dao/src/main/java/com/platform/dao/enums/SparePartUsedSourceEnum.java

@@ -0,0 +1,27 @@
+package com.platform.dao.enums;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * @Description 设备状态
+ * @Author liuyu
+ * @Date 2020/05/05
+ * @Version Copyright (c) 2019,安徽阡陌网络科技有限公司 All rights reserved.
+ */
+@Getter
+@AllArgsConstructor
+public enum SparePartUsedSourceEnum {
+
+    /**
+     * 维修
+     */
+    REPAIR(1),
+    /**
+     * 保养
+     */
+    POLLING_CHECK(2)
+    ;
+    private final Integer value;
+
+}

+ 1 - 1
platform-dao/src/main/java/com/platform/dao/enums/SparePartUsedStatusEnum.java

@@ -17,7 +17,7 @@ public enum SparePartUsedStatusEnum {
      */
     IN_USE(1),
     /**
-     * 已废弃
+     * 已废弃 (历史数据)
      */
     REPLACEMENTED(2),
     /**

+ 1 - 0
platform-dao/src/main/java/com/platform/dao/enums/SysConfigEnum.java

@@ -40,6 +40,7 @@ public enum SysConfigEnum {
     REPAIR_OVERTIME_MINUTE_THIRD("维修超时预警第三阶段"),
     CHECK_JOB_WORK("每周工作负荷"),
     SPARE_WARN_EMAIL("最低库存邮箱"),
+    REPAIR_FEE_TYPE_MAPS("维修费用类别集合"),
     SPARE_WARN_FORREST_EMAIL("保养库存邮件邮箱");
     private final String typeName;
 

+ 9 - 0
platform-dao/src/main/java/com/platform/dao/mapper/repair/RepairApplicationFormMapper.java

@@ -36,4 +36,13 @@ public interface RepairApplicationFormMapper extends MyMapper<RepairApplicationF
      * @return
      */
     String selectNoById(Object id);
+
+    List<RepairApplicationFormVO> getWorkplaceRepairData(RepairApplicationFormDTO model);
+
+    /**
+     * 获取近一段时间的维修数据
+     * @param model
+     * @return
+     */
+    List<RepairApplicationFormVO> getCurrentlyList(RepairApplicationFormDTO model);
 }

+ 8 - 0
platform-dao/src/main/java/com/platform/dao/mapper/repair/RepairFeeMapper.java

@@ -3,6 +3,7 @@ package com.platform.dao.mapper.repair;
 import com.platform.dao.config.MyMapper;
 import com.platform.dao.dto.repair.RepairFeeDTO;
 import com.platform.dao.entity.repair.RepairFee;
+import com.platform.dao.vo.query.repair.RepairFeeVO;
 import org.springframework.stereotype.Component;
 import java.util.List;
 
@@ -28,4 +29,11 @@ public interface RepairFeeMapper extends MyMapper<RepairFee> {
      * @return
      */
     RepairFee selectById(Object id);
+
+    /**
+     * 获取工作台的饼状图data
+     * @param model
+     * @return
+     */
+    List<RepairFeeVO> listForWorkplacePie(RepairFeeDTO model);
 }

+ 7 - 0
platform-dao/src/main/java/com/platform/dao/mapper/sqarepartmanage/SparePartInfoMapper.java

@@ -50,4 +50,11 @@ public interface SparePartInfoMapper extends MyMapper<SparePartInfo> {
     List<SparePartInfoVO> selectSpareInfoListBySbId(String sbId);
 
     String selectMaxNo(String typeId);
+
+    /**
+     * 查询设备关联的备件信息
+     * @param model
+     * @return
+     */
+    List<SparePartInfoVO> getSpareListBySbInfo(SparePartInfoDTO model);
 }

+ 7 - 0
platform-dao/src/main/java/com/platform/dao/mapper/sqarepartmanage/SparePartUsedMapper.java

@@ -57,4 +57,11 @@ public interface SparePartUsedMapper extends MyMapper<SparePartUsed> {
      * @return
      */
     List<SparePartUsedVO> selectSparePartUsedListByRepairId(String repairId);
+
+    /**
+     * 根据条件获取单条记录
+     * @param model
+     * @return
+     */
+    SparePartUsedVO selectSpecialOne(SparePartUsedDTO model);
 }

+ 83 - 0
platform-dao/src/main/java/com/platform/dao/vo/export/sqarepartmanage/ExportSparePartUsedReportVO.java

@@ -0,0 +1,83 @@
+package com.platform.dao.vo.export.sqarepartmanage;
+
+import com.platform.office.annotation.Excel;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+
+/**
+ * @Description 备件使用表导出VO
+ * @Author liuyu
+ * @Date 2020-05-03 13:02:01
+ * @Version Copyright (c) 2019,北京乾元坤和科技有限公司 All rights reserved.
+ */
+@Data
+@Accessors(chain = true)
+public class ExportSparePartUsedReportVO implements Serializable {
+
+  /**
+   * 设备
+   */
+  @Excel(name = "设备名称", orderNum = "1")
+  private String sbName;
+
+  /**
+   * 部件
+   */
+  @Excel(name = "部件", orderNum = "2")
+  private String partName;
+
+  /**
+   * 备件
+   */
+  @Excel(name = "备件名称", orderNum = "3")
+  private String spareName;
+
+  /**
+   * 投用日期
+   */
+  @Excel(name = "投用日期", orderNum = "4")
+  private LocalDate startDate;
+
+  /**
+   * 预计报废日期
+   */
+  @Excel(name = "预计报废日期", orderNum = "5")
+  private LocalDate changeDate;
+
+  /**
+   * 更换数目
+   */
+  @Excel(name = "更换数目", orderNum = "6")
+  private Integer num;
+
+  /**
+   * 备件价值(元)
+   */
+  @Excel(name = "备件价值(元)", orderNum = "7")
+  private BigDecimal price;
+
+    /**
+   * 当前状态:1-使用中;2-已替换
+   */
+  @Excel(name = "当前状态:1-使用中;2-已替换", orderNum = "8")
+  private Integer status;
+
+  /**
+   * 更换场景
+   */
+  @Excel(name = "更换场景: 1-维修 2-保养", orderNum = "9")
+  private String usedSource;
+
+  /**
+   * 备注
+   */
+  @Excel(name = "备注", orderNum = "10")
+  private String remark;
+
+
+}

+ 94 - 0
platform-dao/src/main/java/com/platform/dao/vo/query/repair/RepairFeeVO.java

@@ -0,0 +1,94 @@
+package com.platform.dao.vo.query.repair;
+
+import com.platform.common.bean.BaseVO;
+import com.platform.dao.entity.upms.SysFile;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.time.LocalDate;
+import java.util.List;
+
+@Data
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = true)
+public class RepairFeeVO extends BaseVO implements Serializable {
+    /**
+     * 设备id
+     */
+    private String sbId;
+    /**
+     * 维修单id
+     */
+    private String repairId;
+    /**
+     * 设备id
+     */
+    private String sbNo;
+    /**
+     * 设备id
+     */
+    private String sbName;
+    /**
+     * 设备id
+     */
+    private String typeId;
+    /**
+     * 设备id
+     */
+    private String sbTypeName;
+    /**
+     * 设备id
+     */
+    private String sbLevel;
+    /**
+     * 工单类型
+     */
+    private Integer category;
+    /**
+     * 费用金额
+     */
+    private Double fee;
+    /**
+     * 费用类别
+     */
+    private Integer type;
+    /**
+     * 费用原因
+     */
+    private String reason;
+    /**
+     * 费用描述
+     */
+    private String descripition;
+    /**
+     * 备注
+     */
+    private String remark;
+    /**
+     * 货币类型
+     */
+    private Integer moneyType;
+    /**
+     * 费用日期
+     */
+    private LocalDate feeDate;
+    /**
+     * 单号:系统内部的单号,不是维修单号或者其他的单号
+     */
+    private String no;
+    /**
+     * 委外单号
+     */
+    private String repairNo;
+
+    private List<SysFile> imageList;
+
+    private List<SysFile> fileList;
+
+    private String typeName;
+
+    private BigDecimal repairNum;
+}

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

@@ -14,6 +14,7 @@ import javax.persistence.Transient;
 import javax.validation.constraints.NotNull;
 import java.io.Serializable;
 import java.math.BigDecimal;
+import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.util.List;
 
@@ -306,4 +307,20 @@ public class SparePartInfoVO extends BaseVO implements Serializable {
      * 备件出库信息列表
      */
     private List<OutStoreDetailVO> outStoreList;
+
+    /**
+     * 备件使用状态
+     * SparePartUsedStatusEnum
+     */
+    private Integer usedStatus;
+
+    /**
+     * 备件投入使用日期
+     */
+    private LocalDate startDate;
+
+    /**
+     * 备件下一次更换日期
+     */
+    private LocalDate changeDate;
 }

+ 86 - 0
platform-dao/src/main/java/com/platform/dao/vo/query/workplace/WorkplaceRepairVO.java

@@ -0,0 +1,86 @@
+package com.platform.dao.vo.query.workplace;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * 维修工作台数据返回VO
+ */
+@Data
+public class WorkplaceRepairVO implements Serializable {
+    /**
+     * 待维修工单数
+     */
+    private BigDecimal waitForRepairNum;
+
+    /**
+     * 审核工单数
+     */
+    private BigDecimal verifyRepairNum;
+
+    /**
+     * 已完成工单数
+     */
+    private BigDecimal completedRepairNum;
+    /**
+     * 驳回工单数
+     */
+    private BigDecimal refusedRepairNum;
+
+    /**
+     * 维修工单总数
+     */
+    private BigDecimal repairTotalNum;
+
+    /**
+     * 委外待维修工单数
+     */
+    private BigDecimal outWaitForRepairNum;
+
+    /**
+     * 委外审核工单数
+     */
+    private BigDecimal outVerifyRepairNum;
+    /**
+     * 委外驳回工单数
+     */
+    private BigDecimal outRefusedRepairNum;
+
+    /**
+     * 委外已完成工单数
+     */
+    private BigDecimal outCompletedRepairNum;
+
+    /**
+     * 委外维修工单总数
+     */
+    private BigDecimal outRepairTotalNum;
+
+    /**
+     * 普通维修费用
+     */
+    private BigDecimal repairFee;
+
+    /**
+     * 委外维修费用
+     */
+    private BigDecimal outRepairFee;
+
+    /**
+     * 总工单数
+     */
+    private BigDecimal totalNum;
+    /**
+     * 总维修费
+     */
+    private BigDecimal totalFee;
+
+    public WorkplaceRepairVO(){
+        this.waitForRepairNum = this.verifyRepairNum = this.completedRepairNum = this.refusedRepairNum = this.repairTotalNum
+                = this.outRepairTotalNum = this.outCompletedRepairNum = this.outRefusedRepairNum = this.outVerifyRepairNum
+                = this.outWaitForRepairNum = this.outRepairFee = this.repairFee = this.totalFee = this.totalNum = new BigDecimal(0);
+    }
+
+}

+ 12 - 0
platform-dao/src/main/java/com/platform/dao/vo/repair/RepairApplicationFormVO.java

@@ -351,4 +351,16 @@ public class RepairApplicationFormVO extends BaseVO implements Serializable {
      * 其他
      */
     private String otherChangeContent;
+
+    /**
+     * 统计维修次数值
+     */
+    private BigDecimal tempTotalNum;
+
+    private BigDecimal tempTotalFee;
+
+    /**
+     * 星期几名称
+     */
+    private String weekDayName;
 }

+ 45 - 0
platform-dao/src/main/java/com/platform/dao/vo/report/SparePartInfoReportVO.java

@@ -0,0 +1,45 @@
+package com.platform.dao.vo.report;
+
+import com.platform.dao.vo.query.check.CheckJobVO;
+import com.platform.dao.vo.spare.SparePartUsedVO;
+import com.platform.office.annotation.Excel;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.List;
+
+/**
+ * @author cyz
+ */
+@Data
+@Accessors(chain = true)
+public class SparePartInfoReportVO implements Serializable {
+    private static final long serialVersionUID = 1L;
+    /**
+     * 月份
+     */
+    @Excel(name = "年", orderNum = "1")
+    private Integer year;
+    /**
+     * 月份
+     */
+    @Excel(name = "月份", orderNum = "2")
+    private Integer month;
+    /**
+     * 每月总数
+     */
+    @Excel(name = "总数", orderNum = "3")
+    private BigDecimal totalNum;
+    /**
+     * 每月总金额
+     */
+    @Excel(name = "总金额", orderNum = "4")
+    private BigDecimal totalPrice;
+
+    /**
+     * 明细列表
+     */
+    List<SparePartUsedVO> detailList;
+}

+ 12 - 0
platform-dao/src/main/java/com/platform/dao/vo/spare/SparePartUsedVO.java

@@ -130,4 +130,16 @@ public class SparePartUsedVO extends BaseVO implements Serializable {
 
     private Integer month;
 
+    /**
+     * 消耗来源
+     * 参照SparePartUsedSourceEnum
+     */
+    private Integer usedSource;
+
+    /**
+     * 消耗来源
+     */
+    private String usedSourceName;
+
+
 }

+ 36 - 0
platform-dao/src/main/resources/mapper/repair/RepairApplicationFormMapper.xml

@@ -113,4 +113,40 @@
         from t_repair_application_form
         where id = #{id,jdbcType=VARCHAR}
     </select>
+
+    <!-- 维修统计数据 -->
+    <select id="getWorkplaceRepairData" parameterType="com.platform.dao.dto.repair.RepairApplicationFormDTO"
+            resultType="com.platform.dao.vo.repair.RepairApplicationFormVO">
+        select count(1) as tempTotalNum,sum(fee.fee) as tempTotalFee,rf.status from t_repair_application_form rf
+        join t_repair_fee fee on fee.repair_id = rf.id
+        <where>
+            <if test="repairUserId != null">
+                and rf.repair_user_id = #{repairUserId}
+            </if>
+            <if test="searchTime != null">
+                and rf.repair_start_time like concat('',#{searchTime},'%')
+            </if>
+            <if test="type != null">
+                and rf.type = #{type}
+            </if>
+        </where>
+        group by rf.status
+    </select>
+
+    <!-- 维修统计数据 -->
+    <select id="getCurrentlyList" parameterType="com.platform.dao.dto.repair.RepairApplicationFormDTO"
+            resultType="com.platform.dao.vo.repair.RepairApplicationFormVO">
+        select * from t_repair_application_form
+        <where>
+            <if test="repairUserId != null">
+                and repair_user_id = #{repairUserId}
+            </if>
+            <if test="searchTimeStart != null">
+                and repair_start_time <![CDATA[>]]> #{searchTimeStart}
+            </if>
+            <if test="searchTimeEnd != null">
+                and repair_start_time <![CDATA[<]]> #{searchTimeEnd}
+            </if>
+        </where>
+    </select>
 </mapper>

+ 16 - 0
platform-dao/src/main/resources/mapper/repair/RepairFeeMapper.xml

@@ -86,4 +86,20 @@
         from t_repair_fee
         where id = #{id,jdbcType=VARCHAR}
     </select>
+
+    <!-- 维修费用数据 -->
+    <select id="listForWorkplacePie" parameterType="com.platform.dao.dto.repair.RepairFeeDTO"
+            resultType="com.platform.dao.vo.query.repair.RepairFeeVO">
+        select count(1) as repairNum,sum(fee.fee) as fee,fee.type from t_repair_application_form rf
+        join t_repair_fee fee on fee.repair_id = rf.id
+        <where>
+            <if test="repairUserId != null">
+                and rf.repair_user_id = #{repairUserId}
+            </if>
+            <if test="searchTime != null">
+                and rf.repair_start_time like concat('',#{searchTime},'%')
+            </if>
+        </where>
+        group by fee.type
+    </select>
 </mapper>

+ 18 - 1
platform-dao/src/main/resources/mapper/sqarepartmanage/SparePartInfoMapper.xml

@@ -230,7 +230,7 @@ warn_status,forecast_status,
         from t_spare_part_info spare
         left join t_sb_model_spare_bom tcpsr on tcpsr.spare_id=spare.id
         LEFT JOIN t_part_info part on tcpsr.sb_part_id = part.id
-        where tcpsr.model_id = #{id}
+        where tcpsr.sb_id = #{id}
     </select>
 
     <select id="selectSpareInfoListBySbId" resultType="com.platform.dao.vo.query.sparepartmanage.SparePartInfoVO">
@@ -322,4 +322,21 @@ warn_status,forecast_status,
             where id = #{item.id}
         </foreach>
     </update>
+
+    <!-- 维修和保养获取备件信息List -->
+    <select id="getSpareListBySbInfo" parameterType="com.platform.dao.dto.sqarepartmanage.SparePartInfoDTO"
+            resultType="com.platform.dao.vo.query.sparepartmanage.SparePartInfoVO">
+        select spi.* from t_sb_model_spare_bom sm left join t_spare_part_info spi on sm.spare_id = spi.id
+        <where>
+            <if test="sbId != null">
+                and sm.sb_id = #{sbId}
+            </if>
+            <if test="name != null and name != ''">
+                and spi.name like concat('%',#{name},'%')
+            </if>
+            <if test="isSpecial != null">
+                and spi.is_special = #{isSpecial}
+            </if>
+        </where>
+    </select>
 </mapper>

+ 27 - 2
platform-dao/src/main/resources/mapper/sqarepartmanage/SparePartUsedMapper.xml

@@ -11,6 +11,7 @@
         <result column="repair_no" jdbcType="VARCHAR" property="repairNo"/>
         <result column="start_date" jdbcType="DATE" property="startDate"/>
         <result column="status" jdbcType="SMALLINT" property="status"/>
+        <result column="used_source" jdbcType="SMALLINT" property="usedSource"/>
         <result column="num" jdbcType="DECIMAL" property="num"/>
         <result column="price" jdbcType="DECIMAL" property="price"/>
         <result column="total_price" jdbcType="DECIMAL" property="totalPrice"/>
@@ -39,10 +40,10 @@
         repair_no
     </sql>
     <sql id="Left_Column">
-        used.id, used.store_id, used.sb_id,
+        used.id, used.store_id, used.sb_id,used.price,
         used.part_id, used.spare_id, used.start_date,
         used.status, used.change_date,
-        used.num,
+        used.num,used.used_source,
         used.real_change_date,
         used.repair_id,
         used.repair_no,
@@ -79,6 +80,16 @@
             <if test="partId != null and partId != ''">
                 and used.part_id = #{partId}
             </if>
+            <!-- 新增报表查询条件 -->
+            <if test="searchStartTime != null">
+                and used.start_date <![CDATA[ >= ]]> #{searchStartTime}
+            </if>
+            <if test="searchEndTime != null">
+                and used.start_date <![CDATA[ <= ]]> #{searchEndTime}
+            </if>
+            <if test="usedSource != null">
+                and used.used_source = #{usedSource}
+            </if>
         </where>
     </select>
     <select id="selectById" parameterType="java.lang.Object" resultType="com.platform.dao.vo.spare.SparePartUsedVO">
@@ -124,4 +135,18 @@
         group by YEAR(used.real_change_date), MONTH(used.real_change_date), used.spare_id
         order by YEAR(used.real_change_date) DESC, MONTH(used.real_change_date) DESC
     </select>
+
+    <select id="selectSpecialOne" parameterType="com.platform.dao.dto.sqarepartmanage.SparePartUsedDTO"
+            resultType="com.platform.dao.vo.spare.SparePartUsedVO">
+        select * from t_spare_part_used
+        <where>
+            <if test="sbId != null and sbId != ''">
+                and sb_id = #{sbId}
+            </if>
+            <if test="spareId != null and spareId != ''">
+                and spare_id = #{spareId}
+            </if>
+        </where>
+        order by created_time desc limit 1
+    </select>
 </mapper>

+ 4 - 1
platform-rest/src/main/java/com/platform/rest/controller/repair/RepairFeeController.java

@@ -1,5 +1,6 @@
 package com.platform.rest.controller.repair;
 
+import com.platform.common.util.JsonUtils;
 import com.platform.common.util.R;
 import com.platform.dao.dto.repair.RepairFeeDTO;
 import com.platform.dao.entity.repair.RepairFee;
@@ -52,7 +53,9 @@ public class RepairFeeController {
   @PostMapping
   @PreAuthorize("@pms.hasPermission('repair-fees-add')")
   public R save(@Validated({AddGroup.class}) @RequestBody RepairFeeDTO repairFeeDTO) {
-      return new R<>(repairFeeService.saveModelByDTO(repairFeeDTO));
+    System.out.println("---------------------------------"+JsonUtils.objectToJson(repairFeeDTO));
+    return new R<>(null);
+    //return new R<>(repairFeeService.saveModelByDTO(repairFeeDTO));
   }
 
   /**

+ 88 - 0
platform-rest/src/main/java/com/platform/rest/controller/report/SparePartInfoReportController.java

@@ -0,0 +1,88 @@
+package com.platform.rest.controller.report;
+
+import cn.hutool.core.collection.CollectionUtil;
+import com.platform.common.util.BeanConverterUtil;
+import com.platform.common.util.DateUtils;
+import com.platform.common.util.R;
+import com.platform.dao.dto.sqarepartmanage.SparePartUsedDTO;
+import com.platform.dao.util.ExcelUtil;
+import com.platform.dao.vo.export.sqarepartmanage.ExportSparePartUsedReportVO;
+import com.platform.dao.vo.report.SparePartInfoReportVO;
+import com.platform.dao.vo.spare.SparePartUsedVO;
+import com.platform.rest.log.annotation.SysLog;
+import com.platform.service.sqarepartmanage.SparePartUsedService;
+import lombok.AllArgsConstructor;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpServletResponse;
+import java.time.LocalDate;
+import java.util.List;
+
+/**
+ * @Description 备件报表 控制器
+ * @Author liuyu
+ * @Date 2020-05-29 10:39:40
+ * @Version Copyright (c) 2020,北京乾元坤和科技有限公司 All rights reserved.
+ */
+@RestController
+@AllArgsConstructor
+@RequestMapping("/report/spare-part/infos")
+public class SparePartInfoReportController {
+
+    private final SparePartUsedService sparePartUsedService;
+
+    /**
+     * 备件每月统计报表导出
+     *
+     * @param dto  查询条件
+     * @param year 查询年份
+     * @return R
+     */
+    @SysLog("备件月度报表")
+    @GetMapping("")
+    public R getMonthReportByYear(SparePartUsedDTO dto, @RequestParam(required = false) Integer year, @RequestParam(required = false) LocalDate startMonth, @RequestParam(required = false) LocalDate endMonth) {
+        return new R(sparePartUsedService.getMonthReport(dto, year, startMonth, endMonth));
+    }
+
+    /**
+     * 备件每月统计报表导出
+     *
+     * @param dto  查询条件
+     * @param year 查询年份
+     * @return R
+     */
+    @GetMapping("/export")
+    @SysLog("备件月度报表导出")
+    public void export(HttpServletResponse response, SparePartUsedDTO dto, @RequestParam(required = false) Integer year, @RequestParam(required = false) LocalDate startMonth, @RequestParam(required = false) LocalDate endMonth) {
+        List<SparePartInfoReportVO> list = sparePartUsedService.getMonthReport(dto, year, startMonth, endMonth);
+        String fileName = "";
+        if (year == null) {
+            fileName = DateUtils.dateToString(startMonth, DateUtils.PATTERN_YMD) + "-" + DateUtils.dateToString(endMonth, DateUtils.PATTERN_YMD) + "-备件统计报表";
+        } else {
+            fileName = year + "年-备件统计报表";
+        }
+        ExcelUtil.exportResponseDict(response, SparePartInfoReportVO.class, list, fileName);
+    }
+
+    /**
+     * 备件每月统计报表导出
+     *
+     * @param dto  查询条件
+     * @param year 查询年份
+     * @return R
+     */
+    @GetMapping("/export/month")
+    @SysLog("备件每月明细导出")
+    public void export(HttpServletResponse response, SparePartUsedDTO dto, @RequestParam(required = false) Integer year,
+                       @RequestParam(required = false) Integer month) {
+        List<SparePartUsedVO> list = sparePartUsedService.getMonthReportMonth(dto,year,month);
+        String fileName = "";
+        fileName = year + "-" + month + "-备件统计明细";
+        if (CollectionUtil.isNotEmpty(list)) {
+            ExcelUtil.exportResponseDict(response, ExportSparePartUsedReportVO.class, BeanConverterUtil.copyListProperties(list, ExportSparePartUsedReportVO.class), fileName);
+        }
+    }
+}

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

@@ -1,39 +1,33 @@
 package com.platform.rest.controller.sqarepartmanage;
 
+import com.platform.common.bean.AbstractPageResultBean;
 import com.platform.common.exception.BusinessException;
+import com.platform.common.util.BeanConverterUtil;
 import com.platform.common.util.R;
 import com.platform.common.util.StringUtils;
-import com.platform.dao.dto.sb.SbModelDTO;
-import com.platform.dao.dto.sb.SbModelSpareBomDTO;
+import com.platform.common.validation.group.AddGroup;
+import com.platform.common.validation.group.UpdateGroup;
 import com.platform.dao.dto.sqarepartmanage.SparePartInfoDTO;
-import com.platform.dao.entity.sb.SbModel;
 import com.platform.dao.entity.sqarepartmanage.SparePartInfo;
-import com.platform.dao.entity.sqarepartmanage.SpareType;
+import com.platform.dao.util.ExcelUtil;
 import com.platform.dao.util.SelectUtil;
-import com.platform.dao.vo.query.check.CheckStandardSpareVO;
+import com.platform.dao.vo.export.sqarepartmanage.ExportSparePartInfoVO;
+import com.platform.dao.vo.query.sparepartmanage.SparePartInfoVO;
 import com.platform.dao.vo.sb.SbModelSpareBomVO;
-import com.platform.dao.vo.sb.SbModelVO;
+import com.platform.rest.log.annotation.SysLog;
 import com.platform.service.check.CheckStandardService;
 import com.platform.service.sb.SbModelService;
 import com.platform.service.sb.SbModelSpareBomService;
 import com.platform.service.sqarepartmanage.SparePartInfoService;
-import com.platform.dao.util.ExcelUtil;
-import com.platform.dao.vo.export.sqarepartmanage.ExportSparePartInfoVO;
-import com.platform.common.util.BeanConverterUtil;
-import com.platform.common.validation.group.AddGroup;
-import com.platform.common.validation.group.UpdateGroup;
-import com.platform.service.sqarepartmanage.SpareTypeService;
+import lombok.AllArgsConstructor;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
-import lombok.AllArgsConstructor;
-import com.platform.common.bean.AbstractPageResultBean;
-import com.platform.rest.log.annotation.SysLog;
 import org.springframework.web.multipart.MultipartFile;
 
+import javax.servlet.http.HttpServletResponse;
 import java.util.Arrays;
 import java.util.List;
-import javax.servlet.http.HttpServletResponse;
 
 /**
  * @Description 备件基础信息 控制器
@@ -286,4 +280,17 @@ public class SparePartInfoController {
         String result = sparePartInfoService.importListByUpdate(file);
         return new R<>(result);
     }
+
+    /**
+     * 根据设备的操作场景获取备件信息
+     * 比如 维修,保养
+     * @param pageNum 当前页码
+     * @param pageSize 每页条数
+     * @param sparePartInfoDTO 备件DTO
+     * @return R
+     */
+    @GetMapping("/usedSource/page")
+    public R<AbstractPageResultBean<SparePartInfoVO>> queryByUsedSource(SparePartInfoDTO sparePartInfoDTO, @RequestParam(defaultValue = "1") int pageNum, @RequestParam(defaultValue = "20") int pageSize) {
+        return new R<>(sparePartInfoService.getSpareList(sparePartInfoDTO,pageNum,pageSize));
+    }
 }

+ 4 - 4
platform-rest/src/main/java/com/platform/rest/controller/sqarepartmanage/SparePartUsedController.java

@@ -71,17 +71,17 @@ public class SparePartUsedController {
     @SysLog("新增维修单-维修项目关联")
     @PostMapping("/batch")
     public R save(@Validated({AddGroup.class}) @RequestBody List<SparePartUsedDTO> sparePartUsedDTOList) throws Exception {
-        for(SparePartUsedDTO sparePartUsedDTO:sparePartUsedDTOList ){
-          /*  SparePartUsedDTO d = new SparePartUsedDTO();
+        /*for(SparePartUsedDTO sparePartUsedDTO:sparePartUsedDTOList ){
+            SparePartUsedDTO d = new SparePartUsedDTO();
             d.setRepairId(sparePartUsedDTO.getRepairId());
             d.setSpareId(sparePartUsedDTO.getSpareId());
             d.setSbId(sparePartUsedDTO.getSbId());
             int count = sparePartUsedService.getCountByDTO(d);
             if(count != 0){
                 throw new BusinessException("已经存在该备件,修改即可,无需添加");
-            }*/
+            }
             sparePartUsedDTO.setId(IdGeneratorUtils.getObjectId());
-        }
+        }*/
         sparePartUsedService.saveModelListByDTO(sparePartUsedDTOList);
         return new R<>("添加成功");
     }

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

@@ -8,6 +8,7 @@ import com.platform.dao.dto.repair.RepairFormDTO;
 import com.platform.dao.entity.repair.RepairApplicationForm;
 import com.platform.dao.entity.repair.RepairForm;
 import com.platform.dao.vo.query.check.CheckJobVO;
+import com.platform.dao.vo.query.workplace.WorkplaceRepairVO;
 import com.platform.dao.vo.repair.RepairApplicationFormVO;
 import com.platform.dao.vo.repair.RepairFormVO;
 import com.platform.dao.vo.report.RepairReport24VO;
@@ -121,4 +122,16 @@ public interface RepairApplicationFormService extends IBaseService<RepairApplica
     List<RepairReportMttr> getMonthReportMtrr(RepairApplicationFormDTO repairApplicationFormDTO, Integer year, LocalDate startMonth, LocalDate endMonth);
 
     List<RepairSbInfoReport>  getSbInfoReport(RepairApplicationFormDTO dto, Integer year);
+
+    /**
+     * 获取维修工作台数据
+     * @return
+     */
+    WorkplaceRepairVO getWorkplaceRepairData(String userId,String searchTime);
+
+    /**
+     * 维修近一周数据
+     * @return
+     */
+    List<RepairApplicationFormVO> getCurrentlyList(String userId);
 }

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

@@ -1,10 +1,9 @@
 package com.platform.service.repair;
 
-import com.platform.dao.dto.repair.RepairApplicationFormDTO;
 import com.platform.dao.dto.repair.RepairFeeDTO;
 import com.platform.dao.entity.repair.RepairFee;
+import com.platform.dao.vo.query.repair.RepairFeeVO;
 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;
 
@@ -30,4 +29,6 @@ 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);
+
+    List<RepairFeeVO> listForWorkplacePie(String userId,String searchTime);
 }

+ 111 - 24
platform-service/src/main/java/com/platform/service/repair/impl/RepairApplicationFormServiceImpl.java

@@ -2,13 +2,13 @@ package com.platform.service.repair.impl;
 
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollectionUtil;
-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.CommonConstants;
 import com.platform.common.constant.RedisKeyConstants;
 import com.platform.common.enums.DataFilterTypeEnum;
 import com.platform.common.exception.BusinessException;
@@ -16,20 +16,11 @@ import com.platform.common.model.UserInfo;
 import com.platform.common.util.*;
 import com.platform.dao.bean.MyVOPage;
 import com.platform.dao.dto.repair.RepairApplicationFormDTO;
-import com.platform.dao.dto.repair.RepairCheckDTO;
-import com.platform.dao.dto.repair.RepairFormDTO;
 import com.platform.dao.dto.sb.SbInfoDTO;
-import com.platform.dao.dto.store.InStoreDetailDTO;
 import com.platform.dao.dto.upms.SysUserDTO;
-import com.platform.dao.entity.check.CheckJob;
 import com.platform.dao.entity.repair.RepairApplicationForm;
-import com.platform.dao.entity.repair.RepairCheck;
-import com.platform.dao.entity.repair.RepairForm;
 import com.platform.dao.entity.repair.RepairReason;
 import com.platform.dao.entity.sb.SbInfo;
-import com.platform.dao.entity.sb.SbInspectionFill;
-import com.platform.dao.entity.store.InStoreDetail;
-import com.platform.dao.entity.upms.SysConfig;
 import com.platform.dao.entity.upms.SysFile;
 import com.platform.dao.entity.upms.SysUser;
 import com.platform.dao.enums.*;
@@ -40,17 +31,13 @@ import com.platform.dao.mapper.repair.RepairReasonMapper;
 import com.platform.dao.mapper.upms.SysFileMapper;
 import com.platform.dao.mapper.upms.SysUserMapper;
 import com.platform.dao.util.MessageTemplateUtil;
-import com.platform.dao.util.UserUtil;
 import com.platform.dao.vo.SysUserVO;
-import com.platform.dao.vo.query.upms.SysDeptVO;
+import com.platform.dao.vo.query.workplace.WorkplaceRepairVO;
 import com.platform.dao.vo.repair.RepairApplicationFormVO;
-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;
 import com.platform.service.event.WorkplaceBacklogEvent;
 import com.platform.service.repair.RepairApplicationFormService;
@@ -60,23 +47,16 @@ import com.platform.service.upms.SysUserDeptService;
 import com.platform.service.upms.SysUserService;
 import com.platform.service.util.SysFileUtils;
 import com.platform.service.wechat.util.WeChatMessageUtil;
-import freemarker.template.Configuration;
-import freemarker.template.Template;
-import freemarker.template.TemplateException;
 import lombok.AllArgsConstructor;
-import org.springframework.core.io.ClassPathResource;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import tk.mybatis.mapper.weekend.Weekend;
 import tk.mybatis.mapper.weekend.WeekendCriteria;
 
-import javax.annotation.Resource;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.StringWriter;
-import java.lang.reflect.Array;
+import java.math.BigDecimal;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
+import java.time.format.TextStyle;
 import java.time.temporal.ChronoUnit;
 import java.util.*;
 import java.util.concurrent.TimeUnit;
@@ -870,6 +850,113 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
         return result;
     }
 
+    @Override
+    public WorkplaceRepairVO getWorkplaceRepairData(String userId,String searchTime) {
+        WorkplaceRepairVO vo = new WorkplaceRepairVO();
+        // 获取内部维修数据
+        RepairApplicationFormDTO queryDTO = new RepairApplicationFormDTO();
+        queryDTO.setType(RepairApplicationFormTypeEnum.IN.getValue());
+        queryDTO.setSearchTime(searchTime);
+        queryDTO.setRepairUserId(userId);
+        List<RepairApplicationFormVO> list = mapper.getWorkplaceRepairData(queryDTO);
+        if(list != null && list.size() > 0){
+            for(RepairApplicationFormVO result : list){
+                packageInfo(RepairApplicationFormTypeEnum.IN.getValue(),result,vo);
+            }
+        }
+        queryDTO.setType(RepairApplicationFormTypeEnum.OUT.getValue());
+        list = mapper.getWorkplaceRepairData(queryDTO);
+        if(list != null && list.size() > 0){
+            for(RepairApplicationFormVO result : list){
+                packageInfo(RepairApplicationFormTypeEnum.OUT.getValue(),result,vo);
+            }
+        }
+        // 统计总和数据
+        vo.setTotalFee(vo.getRepairFee().add(vo.getOutRepairFee()));
+        vo.setTotalNum(vo.getRepairTotalNum().add(vo.getOutRepairTotalNum()));
+        return vo;
+    }
+
+    @Override
+    public List<RepairApplicationFormVO> getCurrentlyList(String userId) {
+        LocalDateTime now = LocalDateTime.now();
+        List<LocalDateTime> currentWeekStartAndEndList = DateUtils.currentWeek();
+        LocalDateTime searchStartTime = now.plusDays(-6).withHour(0).withMinute(0).withSecond(0);
+        LocalDateTime searchEndTime = now.withHour(23).withMinute(59).withSecond(59);
+        // 总数
+        RepairApplicationFormDTO queryDTO = new RepairApplicationFormDTO();
+        queryDTO.setSearchStartTime(searchStartTime);
+        queryDTO.setSearchEndTime(searchEndTime);
+        queryDTO.setRepairUserId(userId);
+        List<RepairApplicationFormVO> list = mapper.getCurrentlyList(queryDTO) == null ? new ArrayList<>() : mapper.getCurrentlyList(queryDTO);
+
+        List<RepairApplicationFormVO> result = new ArrayList<>();
+        for(LocalDateTime tempDate: currentWeekStartAndEndList){
+            RepairApplicationFormVO vo = new RepairApplicationFormVO();
+            int tempTotalNum = 0;
+            vo.setWeekDayName(tempDate.getDayOfWeek().getDisplayName(TextStyle.FULL, Locale.CHINA));
+            for(RepairApplicationFormVO useVO: list){
+                if(useVO.getRepairStartTime().toLocalDate().isEqual(tempDate.toLocalDate())){
+                    tempTotalNum+=1;
+                }
+            }
+            vo.setTempTotalNum(new BigDecimal(tempTotalNum));
+            result.add(vo);
+        }
+        return result;
+    }
+
+    /**
+     * 数据封装
+     * @param type  工单维修类型 内部还是外部
+     * @param result 结果数据
+     * @param vo 返回数据
+     */
+    private void packageInfo(Integer type,RepairApplicationFormVO result,WorkplaceRepairVO vo){
+        BigDecimal tempNum = result.getTempTotalNum();
+        if(RepairApplicationFormTypeEnum.IN.getValue() == type){
+            vo.setRepairFee(vo.getRepairFee().add(result.getTempTotalFee()));
+            vo.setRepairTotalNum(vo.getRepairTotalNum().add(tempNum));
+            // 内部维修
+            switch (result.getStatus().intValue()){
+                case CommonConstants.NOT_ALLOCATED:
+                case CommonConstants.PROCESSING:
+                    vo.setWaitForRepairNum(vo.getWaitForRepairNum().add(tempNum));
+                    break;
+                case CommonConstants.WAIT_SUBMIT:
+                case CommonConstants.NOT_ACCEPTANCE:
+                    vo.setVerifyRepairNum(vo.getVerifyRepairNum().add(tempNum));
+                    break;
+                case CommonConstants.REBACK:
+                    vo.setRefusedRepairNum(vo.getRefusedRepairNum().add(tempNum));
+                    break;
+                case CommonConstants.FINISHED:
+                    vo.setCompletedRepairNum(vo.getCompletedRepairNum().add(tempNum));
+                    break;
+            }
+        }else if(RepairApplicationFormTypeEnum.OUT.getValue() == type) {
+            vo.setOutRepairFee(vo.getOutRepairFee().add(result.getTempTotalFee()));
+            vo.setOutRepairTotalNum(vo.getOutRepairTotalNum().add(tempNum));
+            // 委外
+            switch (result.getStatus()){
+                case CommonConstants.NOT_ALLOCATED:
+                case CommonConstants.PROCESSING:
+                    vo.setOutWaitForRepairNum(vo.getOutWaitForRepairNum().add(tempNum));
+                    break;
+                case CommonConstants.WAIT_SUBMIT:
+                case CommonConstants.NOT_ACCEPTANCE:
+                    vo.setOutVerifyRepairNum(vo.getOutVerifyRepairNum().add(tempNum));
+                    break;
+                case CommonConstants.REBACK:
+                    vo.setOutRefusedRepairNum(vo.getOutRefusedRepairNum().add(tempNum));
+                    break;
+                case CommonConstants.FINISHED:
+                    vo.setOutCompletedRepairNum(vo.getOutCompletedRepairNum().add(tempNum));
+                    break;
+            }
+        }
+    }
+
     /**
      * 1: 如果年份是当前年份,则统计到当前月份
      * 2:如果不是当前年份,则统计全年的

+ 46 - 0
platform-service/src/main/java/com/platform/service/repair/impl/RepairFeeServiceImpl.java

@@ -1,6 +1,7 @@
 package com.platform.service.repair.impl;
 
 import cn.hutool.core.collection.CollectionUtil;
+import com.alibaba.fastjson.JSONArray;
 import com.github.pagehelper.PageHelper;
 import com.platform.common.bean.AbstractPageResultBean;
 import com.platform.common.bean.DictVO;
@@ -17,25 +18,31 @@ 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.SysConfig;
 import com.platform.dao.entity.upms.SysFile;
 import com.platform.dao.enums.RepairApplicationFormCategoryEnum;
+import com.platform.dao.enums.SysConfigEnum;
 import com.platform.dao.enums.SysFileTypeEnum;
 import com.platform.dao.mapper.repair.RepairApplicationFormMapper;
 import com.platform.dao.mapper.repair.RepairFeeMapper;
 import com.platform.dao.mapper.upms.SysFileMapper;
+import com.platform.dao.vo.query.repair.RepairFeeVO;
 import com.platform.dao.vo.repair.RepairApplicationFormVO;
+import com.platform.dao.vo.report.CheckJobReportWeekHoursVO;
 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.upms.SysConfigService;
 import com.platform.service.util.SysFileUtils;
 import lombok.AllArgsConstructor;
 import org.springframework.stereotype.Service;
 import tk.mybatis.mapper.weekend.Weekend;
 import tk.mybatis.mapper.weekend.WeekendCriteria;
 
+import java.math.BigDecimal;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.util.ArrayList;
@@ -58,6 +65,8 @@ public class RepairFeeServiceImpl extends BaseServiceImpl<RepairFeeMapper, Repai
 
     private final SbInfoService sbInfoService;
 
+    private final SysConfigService sysConfigService;
+
     @Override
     public int batchDelete(List<String> ids) {
         Weekend<RepairFee> weekend = new Weekend<>(RepairFee.class);
@@ -288,4 +297,41 @@ public class RepairFeeServiceImpl extends BaseServiceImpl<RepairFeeMapper, Repai
         }
         return result;
     }
+
+    @Override
+    public List<RepairFeeVO> listForWorkplacePie(String userId,String searchTime) {
+        // 查询统计费用类别数据
+        RepairFeeDTO queryDTO = new RepairFeeDTO();
+        queryDTO.setSearchTime(searchTime);
+        queryDTO.setRepairUserId(userId);
+        List<RepairFeeVO> list = mapper.listForWorkplacePie(queryDTO) == null ? new ArrayList<>() : mapper.listForWorkplacePie(queryDTO);
+        SysConfig sysConfig = sysConfigService.getByCode(SysConfigEnum.REPAIR_FEE_TYPE_MAPS.toString());
+        if(sysConfig != null) {
+            List<RepairFeeVO> voList = JSONArray.parseArray(sysConfig.getContent(), RepairFeeVO.class);
+            BigDecimal defaultNum = new BigDecimal(0);
+            double defaultFee = 0.0;
+            for(RepairFeeVO vo: voList){
+                Integer type = vo.getType();
+                vo.setFee(defaultFee);
+                vo.setRepairNum(defaultNum);
+                for(RepairFeeVO result : list){
+                    if(type == result.getType()){
+                        vo.setFee(result.getFee());
+                        vo.setRepairNum(result.getRepairNum());
+                        break;
+                    }
+                }
+            }
+            return voList;
+        }
+        return null;
+    }
+
+    public static void main(String[] args) {
+        String content = "[{\"typeName\":\"维修-配件\",\"type\":1},{\"typeName\":\"维修-人工\",\"type\":2},{\"typeName\":\"备件费用\",\"type\":3},{\"typeName\":\"维护保养费用\",\"type\":4},{\"typeName\":\"改造费用\",\"type\":5}]";
+        List<RepairFeeVO> voList = JSONArray.parseArray(content, RepairFeeVO.class);
+        for(RepairFeeVO vo : voList){
+            System.out.println(vo.getTypeName()+"=="+vo.getType());
+        }
+    }
 }

+ 6 - 0
platform-service/src/main/java/com/platform/service/sb/SbModelSpareBomService.java

@@ -72,4 +72,10 @@ public interface SbModelSpareBomService extends IBaseService<SbModelSpareBom, Sb
     List<SbModelSpareBomVO> selectExportList(SparePartInfoDTO sparePartInfoDTO);
 
     String copyFormSb(SbModelSpareBomDTO dto);
+
+    /**
+     * 修改BOM
+     * @param sbModelSpareBomDTO
+     */
+    void modModelByDTO(SbModelSpareBomDTO sbModelSpareBomDTO);
 }

+ 17 - 0
platform-service/src/main/java/com/platform/service/sb/impl/SbModelSpareBomServiceImpl.java

@@ -8,6 +8,7 @@ import com.platform.common.model.UserInfo;
 import com.platform.common.util.BeanConverterUtil;
 import com.platform.common.util.IdGeneratorUtils;
 import com.platform.common.util.SecurityUtils;
+import com.platform.common.util.StringUtils;
 import com.platform.dao.bean.MyPage;
 import com.platform.dao.dto.check.CheckProjectStandardRelationDTO;
 import com.platform.dao.dto.check.CheckStandardDTO;
@@ -208,4 +209,20 @@ public class SbModelSpareBomServiceImpl extends BaseServiceImpl<SbModelSpareBomM
         return new MyPage(mapper.selectVOList(record));
     }
 
+    @Override
+    public void modModelByDTO(SbModelSpareBomDTO model) {
+        // 校验
+        if(!model.getSpareId().equals(model.getOldSpareId())){
+            SbModelSpareBomDTO queryDTO = new SbModelSpareBomDTO();
+            queryDTO.setSpareId(model.getSpareId());
+            if(StringUtils.isNotBlank(model.getSbId())){
+                queryDTO.setSbId(model.getSbId());
+            }
+            int count = this.getCountByDTO(queryDTO);
+            if(count != 0){
+                throw new BusinessException("您将要修改的备件BOM,已经存在,请检查!备件名称: " + model.getSpareName());
+            }
+        }
+        super.modModelByDTO(model);
+    }
 }

+ 10 - 0
platform-service/src/main/java/com/platform/service/sqarepartmanage/SparePartInfoService.java

@@ -2,6 +2,7 @@ package com.platform.service.sqarepartmanage;
 
 import com.platform.common.bean.AbstractPageResultBean;
 import com.platform.dao.dto.sqarepartmanage.SparePartInfoDTO;
+import com.platform.dao.dto.store.SpareStoreDTO;
 import com.platform.dao.entity.sqarepartmanage.SparePartInfo;
 import com.platform.dao.vo.query.sparepartmanage.SparePartInfoVO;
 import com.platform.dao.vo.sb.SbInfoVO;
@@ -79,4 +80,13 @@ public interface SparePartInfoService extends IBaseService<SparePartInfo, SpareP
     void generateQrCodeAll();
 
     void modImagesByDTO(SparePartInfoDTO sbInfoDTO);
+
+    /**
+     * 根据sbId来获取设备的备件信息list
+     * @param record
+     * @param pageNum
+     * @param pageSize
+     * @return
+     */
+    AbstractPageResultBean<SparePartInfoVO> getSpareList(SparePartInfoDTO record, int pageNum, int pageSize);
 }

+ 21 - 1
platform-service/src/main/java/com/platform/service/sqarepartmanage/SparePartUsedService.java

@@ -2,11 +2,12 @@ package com.platform.service.sqarepartmanage;
 
 import com.platform.dao.bean.MyVOPage;
 import com.platform.dao.dto.sqarepartmanage.SparePartUsedDTO;
-import com.platform.dao.dto.store.OutStoreFormDTO;
 import com.platform.dao.entity.sqarepartmanage.SparePartUsed;
+import com.platform.dao.vo.report.SparePartInfoReportVO;
 import com.platform.dao.vo.spare.SparePartUsedVO;
 import com.platform.service.base.IBaseService;
 
+import java.time.LocalDate;
 import java.util.List;
 
 /**
@@ -65,4 +66,23 @@ public interface SparePartUsedService extends IBaseService<SparePartUsed, SpareP
     MyVOPage<SparePartUsedVO> statisticsByGroupBySparePage(SparePartUsedDTO model, int pageNum, int pageSize);
 
     List<SparePartUsedVO> selectSparePartUsedListByRepairId(String repairId);
+
+    /**
+     * 报表数据
+     * @param sparePartUsedDTO
+     * @param searchYear
+     * @param startMonth
+     * @param endMonth
+     * @return
+     */
+    List<SparePartInfoReportVO> getMonthReport(SparePartUsedDTO sparePartUsedDTO, Integer searchYear, LocalDate startMonth, LocalDate endMonth);
+
+    /**
+     * 每月详细数据
+     * @param sparePartUsedDTO
+     * @param year
+     * @param month
+     * @return
+     */
+    List<SparePartUsedVO> getMonthReportMonth(SparePartUsedDTO sparePartUsedDTO, Integer year, Integer month);
 }

+ 38 - 17
platform-service/src/main/java/com/platform/service/sqarepartmanage/impl/SparePartInfoServiceImpl.java

@@ -7,31 +7,22 @@ import com.platform.common.bean.AbstractPageResultBean;
 import com.platform.common.cache.ConfigCache;
 import com.platform.common.constant.CommonConstants;
 import com.platform.common.exception.BusinessException;
+import com.platform.common.exception.DeniedException;
 import com.platform.common.model.UserInfo;
 import com.platform.common.util.*;
 import com.platform.dao.bean.MyPage;
-import com.platform.dao.dto.check.CheckStandardDTO;
 import com.platform.dao.dto.check.CheckStandardSpareDTO;
-import com.platform.dao.dto.repair.RepairApplicationFormDTO;
-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.store.InStoreDetailDTO;
-import com.platform.dao.dto.store.SpareStoreDTO;
+import com.platform.dao.dto.sqarepartmanage.SparePartUsedDTO;
 import com.platform.dao.entity.check.CheckJob;
-import com.platform.dao.entity.check.CheckStandard;
-import com.platform.dao.entity.check.CheckStandardSpare;
-import com.platform.dao.entity.sb.SbInfo;
 import com.platform.dao.entity.sb.SbModel;
 import com.platform.dao.entity.sb.SbModelSpareBom;
 import com.platform.dao.entity.sqarepartmanage.SparePartInfo;
 import com.platform.dao.entity.sqarepartmanage.SpareType;
-import com.platform.dao.entity.store.InStoreDetail;
 import com.platform.dao.entity.store.SpareStore;
 import com.platform.dao.entity.store.Store;
-import com.platform.dao.entity.upms.SysDept;
 import com.platform.dao.entity.upms.SysFile;
-import com.platform.dao.entity.upms.SysUser;
 import com.platform.dao.enums.*;
 import com.platform.dao.mapper.check.CheckJobMapper;
 import com.platform.dao.mapper.check.CheckStandardSpareMapper;
@@ -39,6 +30,7 @@ import com.platform.dao.mapper.sb.SbInfoMapper;
 import com.platform.dao.mapper.sb.SbModelMapper;
 import com.platform.dao.mapper.sb.SbModelSpareBomMapper;
 import com.platform.dao.mapper.sqarepartmanage.SparePartInfoMapper;
+import com.platform.dao.mapper.sqarepartmanage.SparePartUsedMapper;
 import com.platform.dao.mapper.sqarepartmanage.SpareTypeMapper;
 import com.platform.dao.mapper.store.SpareStoreMapper;
 import com.platform.dao.mapper.store.StoreMapper;
@@ -47,27 +39,24 @@ import com.platform.dao.util.CustomExcelImportUtil;
 import com.platform.dao.util.MessageTemplateUtil;
 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.dao.vo.spare.SparePartUsedVO;
+import com.platform.service.base.impl.BaseServiceImpl;
 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;
 import com.platform.service.util.SysFileUtils;
+import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.boot.autoconfigure.session.StoreType;
 import org.springframework.core.env.Environment;
 import org.springframework.stereotype.Service;
-import com.platform.service.base.impl.BaseServiceImpl;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 import org.springframework.web.multipart.MultipartFile;
 import tk.mybatis.mapper.weekend.Weekend;
 import tk.mybatis.mapper.weekend.WeekendCriteria;
-import lombok.AllArgsConstructor;
 
 import java.math.BigDecimal;
 import java.time.LocalDate;
@@ -95,6 +84,7 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
     private final SpareStoreMapper spareStoreMapper;
     private final Environment environment;
     private final SysFileMapper sysFileMapper;
+    private final SparePartUsedMapper sparePartUsedMapper;
     private CheckJobMapper checkJobMapper;
     private CheckStandardSpareMapper checkStandardSpareMapper;
     private CheckStandardService checkStandardService;
@@ -1212,4 +1202,35 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
         sparePartInfo.setImage(sparePartInfoDTO.getImage());
         mapper.updateByPrimaryKeySelective(sparePartInfo);
     }
+
+    @Override
+    public AbstractPageResultBean<SparePartInfoVO> getSpareList(SparePartInfoDTO record, int pageNum, int pageSize) {
+        // 根据设备ID判断
+        if(StringUtils.isBlank(record.getSbId())){
+            // 走基础备件信息
+            record.setIsSpecial(0);
+        }
+        PageHelper.startPage(pageNum, pageSize);
+        AbstractPageResultBean<SparePartInfoVO> pageInfos = new MyPage(mapper.getSpareListBySbInfo(record));
+        if(record.getUsedSource() == null){
+            throw new DeniedException("请求数据,请注明备件使用场景!");
+        }
+        if(record.getUsedSource() == SparePartUsedSourceEnum.POLLING_CHECK.getValue()){
+            // 保养,关联使用记录
+            if(pageInfos != null && pageInfos.getRows() != null && pageInfos.getRows().size() > 1){
+                SparePartUsedDTO queryDTO = new SparePartUsedDTO();
+                queryDTO.setSbId(record.getSbId());
+                for(SparePartInfoVO vo : pageInfos.getRows()){
+                    queryDTO.setSpareId(vo.getId());
+                    SparePartUsedVO usedVO = sparePartUsedMapper.selectSpecialOne(queryDTO);
+                    if(usedVO != null){
+                        vo.setUsedStatus(usedVO.getStatus());
+                        vo.setStartDate(usedVO.getStartDate());
+                        vo.setChangeDate(usedVO.getChangeDate());
+                    }
+                }
+            }
+        }
+        return pageInfos;
+    }
 }

+ 78 - 9
platform-service/src/main/java/com/platform/service/sqarepartmanage/impl/SparePartUsedServiceImpl.java

@@ -4,32 +4,30 @@ import cn.hutool.core.util.ObjectUtil;
 import com.github.pagehelper.PageHelper;
 import com.platform.common.exception.BusinessException;
 import com.platform.common.model.UserInfo;
-import com.platform.common.util.BeanConverterUtil;
-import com.platform.common.util.BigDecimalUtil;
-import com.platform.common.util.IdGeneratorUtils;
-import com.platform.common.util.SecurityUtils;
+import com.platform.common.util.*;
 import com.platform.dao.bean.MyVOPage;
 import com.platform.dao.dto.sqarepartmanage.SparePartUsedDTO;
-import com.platform.dao.dto.store.OutStoreFormDTO;
 import com.platform.dao.entity.sqarepartmanage.SparePartUsed;
 import com.platform.dao.entity.store.SpareStore;
-import com.platform.dao.enums.DelFlagEnum;
 import com.platform.dao.enums.SparePartUsedStatusEnum;
 import com.platform.dao.mapper.sqarepartmanage.SparePartUsedMapper;
 import com.platform.dao.mapper.store.SpareStoreMapper;
 import com.platform.dao.mapper.store.SpareStoreSecondMapper;
+import com.platform.dao.vo.report.SparePartInfoReportVO;
 import com.platform.dao.vo.spare.SparePartUsedVO;
 import com.platform.service.base.impl.BaseServiceImpl;
 import com.platform.service.sqarepartmanage.SparePartUsedService;
-import com.platform.service.store.SpareStoreService;
 import lombok.AllArgsConstructor;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 import tk.mybatis.mapper.weekend.Weekend;
 
+import java.math.BigDecimal;
+import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 
 /**
  * @Description 备件使用表 service 实现类
@@ -133,7 +131,7 @@ public class SparePartUsedServiceImpl extends BaseServiceImpl<SparePartUsedMappe
             setCreateUserInfo(sparePartUsedDTO);
             sparePartUsedDTO.setId(IdGeneratorUtils.getObjectId());
             list.add(BeanConverterUtil.copyObjectProperties(sparePartUsedDTO, getEntityClass()));
-            // 更新库存信息
+            /*// 更新库存信息  该部分功能,放在领用单模块
             Weekend<SpareStore> spareStoreWeekend = new Weekend<>(SpareStore.class);
             spareStoreWeekend.weekendCriteria().andEqualTo(SpareStore::getSpareId, sparePartUsedDTO.getSpareId())
                     .andEqualTo(SpareStore::getStoreId, sparePartUsedDTO.getStoreId());
@@ -146,7 +144,7 @@ public class SparePartUsedServiceImpl extends BaseServiceImpl<SparePartUsedMappe
             spareStore.setUpdateUserId(userInfo.getUserId());
             spareStore.setUpdateUserName(userInfo.getRealName());
             spareStore.setNum(BigDecimalUtil.sub(spareStore.getNum(), sparePartUsedDTO.getNum()));
-            spareStoreMapper.updateByPrimaryKeySelective(spareStore);
+            spareStoreMapper.updateByPrimaryKeySelective(spareStore);*/
         }
         mapper.insertListforComplex(list);
     }
@@ -155,4 +153,75 @@ public class SparePartUsedServiceImpl extends BaseServiceImpl<SparePartUsedMappe
     public List<SparePartUsedVO> selectSparePartUsedListByRepairId(String repairId) {
         return mapper.selectSparePartUsedListByRepairId(repairId);
     }
+
+    @Override
+    public List<SparePartInfoReportVO> getMonthReport(SparePartUsedDTO sparePartUsedDTO, Integer searchYear, LocalDate startMonth, LocalDate endMonth) {
+        List<Map<String, LocalDateTime>> monthStartAndEndList = null;
+        LocalDateTime searchStartTime = null;
+        LocalDateTime searchEndTime = null;
+        if(searchYear != null){
+            LocalDate localDate = LocalDate.now();
+            int year = localDate.getYear();
+            // 如2021-10-15号码,则month=10,需要计算到11月份,需要加1
+            int month = localDate.getMonthValue();
+            if(searchYear<year){
+                month = 12;
+                year = searchYear;
+            }
+            monthStartAndEndList = DateUtils.getMonthStartAndEndByYear(year, month);
+            // 当前年份只统计到当前月,历史年份统计全年
+            searchStartTime = DateUtils.getFirstDayOfThisYear(year);
+            searchEndTime = DateUtils.getLastDayOfMonth(year, month);
+        }else{
+            monthStartAndEndList = DateUtils.getMonthStartAndEndByYear(startMonth, endMonth);
+            searchStartTime = DateUtils.getFirstDayOfMonth(startMonth);
+            searchEndTime = DateUtils.getLastDayOfMonth(endMonth);
+        }
+
+        // 总数
+        sparePartUsedDTO.setSearchStartTime(searchStartTime.toLocalDate());
+        sparePartUsedDTO.setSearchEndTime(searchEndTime.toLocalDate());
+        List<SparePartUsedVO> list = mapper.selectVOList(sparePartUsedDTO);
+
+        List<SparePartInfoReportVO> result = new ArrayList<>();
+        for(Map<String, LocalDateTime> map: monthStartAndEndList){
+            SparePartInfoReportVO vo = new SparePartInfoReportVO();
+            List<SparePartUsedVO> detailList = new ArrayList<>();
+            vo.setYear(map.get("searchStartTimeMonth").getYear());
+            vo.setMonth(map.get("searchStartTimeMonth").getMonthValue());
+            BigDecimal totalNum = new BigDecimal(0);  // 更换数目
+            BigDecimal totalPrice = new BigDecimal(0.0); // 更换金额
+            for(SparePartUsedVO useVO: list){
+                if(useVO.getStartDate().isAfter(map.get("searchStartTimeMonth").toLocalDate()) &&
+                        useVO.getStartDate().isBefore(map.get("searchEndTimeMonth").toLocalDate())){
+                    totalNum = totalNum.add(useVO.getNum());
+                    totalPrice = totalPrice.add(useVO.getPrice());
+                    detailList.add(useVO);
+                }
+            }
+            vo.setTotalNum(totalNum);
+            vo.setTotalPrice(totalPrice);
+            vo.setDetailList(detailList);
+            result.add(vo);
+        }
+        return result;
+    }
+
+    @Override
+    public List<SparePartUsedVO> getMonthReportMonth(SparePartUsedDTO sparePartUsedDTO, Integer year, Integer month) {
+        LocalDateTime searchStartTimeMonth = DateUtils.getFirstDayOfMonth(year, month);
+        LocalDateTime searchEndTimeMonth = DateUtils.getLastDayOfMonth(year, month);
+        // 总数
+        sparePartUsedDTO.setSearchStartTime(searchStartTimeMonth.toLocalDate());
+        sparePartUsedDTO.setSearchEndTime(searchEndTimeMonth.toLocalDate());
+        return mapper.selectVOList(sparePartUsedDTO);
+    }
+
+    public static void main(String[] args) {
+        LocalDate localDate = LocalDate.now();
+        int year = localDate.getYear();
+        // 如2021-10-15号码,则month=10,需要计算到11月份,需要加1
+        int month = localDate.getMonthValue();
+        System.out.println(month);
+    }
 }