xiongchao 3 years ago
parent
commit
0f3e62aeda

+ 78 - 9
platform-common/src/main/java/com/platform/common/util/DateUtils.java

@@ -7,10 +7,7 @@ import java.text.SimpleDateFormat;
 import java.time.*;
 import java.time.format.DateTimeFormatter;
 import java.time.format.DateTimeFormatterBuilder;
-import java.time.temporal.Temporal;
-import java.time.temporal.TemporalAdjusters;
-import java.time.temporal.TemporalUnit;
-import java.time.temporal.WeekFields;
+import java.time.temporal.*;
 import java.util.*;
 
 
@@ -24,7 +21,7 @@ import java.util.*;
 @UtilityClass
 public class DateUtils {
     public final static String PATTERN_YMD_HMS = "yyyy-MM-dd HH:mm:ss";
-
+    public final static String PATTERN_YM = "yyyy-MM";
     public final static String PATTERN_YMD = "yyyy-MM-dd";
     public final static String PATTERN_YMD_DOT = "yyyy.MM.dd";
     public final static String PATTERN_YMD_ZH = "yyyy年MM月dd日";
@@ -134,6 +131,17 @@ public class DateUtils {
         return firstday;
     }
 
+    /**
+     * 获取当前月第一天:00:00:00
+     *
+     * @return
+     */
+    public static LocalDateTime getFirstDayOfMonth(Integer year, Integer month) {
+        LocalDateTime now = LocalDateTime.now();
+        LocalDateTime firstday  =  now.withYear(year).withMonth(month).with(TemporalAdjusters.firstDayOfMonth()).withHour(0).withMinute(0).withSecond(0);
+        return firstday;
+    }
+
     /**
      * 获取当前月最后一天:23:59:59
      *
@@ -145,6 +153,38 @@ public class DateUtils {
         return lastDay ;
     }
 
+    /**
+     * 获取当前月最后一天:23:59:59
+     *
+     * @return
+     */
+    public static LocalDateTime getLastDayOfMonth(Integer year, Integer month) {
+        LocalDateTime now = LocalDateTime.now();
+        LocalDateTime lastDay  =  now.withYear(year).withMonth(month).with(TemporalAdjusters.lastDayOfMonth()).withHour(23).withMinute(59).withSecond(59);
+        return lastDay ;
+    }
+    /**
+     * 指定年月的最后一天开始时间
+     *
+     * @return
+     */
+    public static LocalDateTime getFirstDayOfMonth(LocalDate month) {
+        LocalDateTime day  =  month.atStartOfDay();
+        LocalDateTime firstday  =  day.with(TemporalAdjusters.firstDayOfMonth()).withHour(0).withMinute(0).withSecond(0);
+        return firstday;
+    }
+
+    /**
+     * 指定月份的第一天开始时间
+     *
+     * @return
+     */
+    public static LocalDateTime getLastDayOfMonth(LocalDate month) {
+        LocalDateTime day  =  month.atStartOfDay();
+        LocalDateTime lastDay  =  day.with(TemporalAdjusters.lastDayOfMonth()).withHour(23).withMinute(59).withSecond(59);
+        return lastDay;
+    }
+
     /**
      * 获取某年,某周的第一天
      *
@@ -381,10 +421,17 @@ public class DateUtils {
     }
 
     public static void main(String[] args) {
-        List<Map<String, LocalDateTime>>  monthStartAndEndList = getWeekStartAndEndByYear(2021);
+        //List<Map<String, LocalDateTime>>  monthStartAndEndList = getMonthStartAndEndByYear(2021);
+
+        List<Map<String, LocalDateTime>>  monthStartAndEndList = getMonthStartAndEndByYear(LocalDate.now().withYear(2020).withMonth(2), LocalDate.now().withYear(2021).withMonth(8));
         for(Map<String, LocalDateTime> map: monthStartAndEndList){
-            System.out.println(map.get("searchStartTimeWeek").toString() + " : " +  map.get("searchEndTimeWeek").toString());
+            System.out.println(map.get("searchStartTimeMonth").toString() + " : " +  map.get("searchEndTimeMonth").toString());
         }
+        /*LocalDate nowDate = LocalDate.now();
+        LocalDateTime time = getFirstDayOfMonth(nowDate);
+        System.out.println(time);
+        LocalDateTime time2 = getLastDayOfMonth(nowDate);
+        System.out.println(time2);*/
     }
     /**
      * date 转 LocalDate
@@ -408,8 +455,30 @@ public class DateUtils {
         // 每年的 一月一号,零时零分零秒
         for(int i = 1;i<month;i++){
             Map<String, LocalDateTime> dateTimeMap = new HashMap<String, LocalDateTime>();
-            LocalDateTime searchStartTimeMonth = getFirstDayOfMonth(i);
-            LocalDateTime searchEndTimeMonth = getLastDayOfMonth(i);
+            LocalDateTime searchStartTimeMonth = getFirstDayOfMonth(year, i);
+            LocalDateTime searchEndTimeMonth = getLastDayOfMonth(year, i);
+            dateTimeMap.put("searchStartTimeMonth", searchStartTimeMonth);
+            dateTimeMap.put("searchEndTimeMonth",searchEndTimeMonth);
+            monthStartAndEndList.add(dateTimeMap);
+        }
+        return  monthStartAndEndList;
+    }
+
+    /**
+     * 指定年份开始年月到结束年月,中间每个月的开始时间和结束时间
+     *
+     * @param startMonth
+     * @param endMonth
+     * @return
+     */
+    public static List<Map<String, LocalDateTime>> getMonthStartAndEndByYear(LocalDate startMonth, LocalDate endMonth) {
+        List<Map<String, LocalDateTime>> monthStartAndEndList = new ArrayList<Map<String,LocalDateTime>>();
+        int month = DateUtils.monthDiff(startMonth, endMonth);
+        for(int i = 0;i<=month;i++){
+            LocalDate date = DateUtils.plus(startMonth, i, ChronoUnit.MONTHS);
+            Map<String, LocalDateTime> dateTimeMap = new HashMap<String, LocalDateTime>();
+            LocalDateTime searchStartTimeMonth = getFirstDayOfMonth(date);
+            LocalDateTime searchEndTimeMonth = getLastDayOfMonth(date);
             dateTimeMap.put("searchStartTimeMonth", searchStartTimeMonth);
             dateTimeMap.put("searchEndTimeMonth",searchEndTimeMonth);
             monthStartAndEndList.add(dateTimeMap);

+ 24 - 10
platform-rest/src/main/java/com/platform/rest/controller/report/CheckJobReportController.java

@@ -2,6 +2,7 @@ package com.platform.rest.controller.report;
 
 import com.platform.common.bean.AbstractPageResultBean;
 import com.platform.common.util.BeanConverterUtil;
+import com.platform.common.util.DateUtils;
 import com.platform.common.util.R;
 import com.platform.common.validation.group.AddGroup;
 import com.platform.common.validation.group.UpdateGroup;
@@ -21,6 +22,7 @@ import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletResponse;
+import java.time.LocalDate;
 import java.util.List;
 
 /**
@@ -44,8 +46,8 @@ public class CheckJobReportController {
    */
   @SysLog("保养任务每月统计报表")
   @GetMapping("")
-  public R getMonthReportByYear(CheckJobDTO dto, @RequestParam(defaultValue = "2021") Integer year){
-      return new R(checkJobService.getMonthReport(dto, year));
+  public R getMonthReportByYear(CheckJobDTO dto, @RequestParam(required = false) Integer year, @RequestParam(required = false) LocalDate startMonth, @RequestParam(required = false) LocalDate endMonth){
+      return new R(checkJobService.getMonthReport(dto, year, startMonth, endMonth));
   }
 
     /**
@@ -56,9 +58,15 @@ public class CheckJobReportController {
      */
     @GetMapping("/export")
     @SysLog("保养任务每月统计报表导出")
-    public void export(HttpServletResponse response, CheckJobDTO dto, @RequestParam(defaultValue = "2021") Integer year) {
-        List<CheckJobReportVO> list = checkJobService.getMonthReport(dto, year);
-        ExcelUtil.exportResponseDict(response, CheckJobReportVO.class, list, year + "年-保养任务统计报表");
+    public void export(HttpServletResponse response, CheckJobDTO dto, @RequestParam(required = false) Integer year,@RequestParam(required = false) LocalDate startMonth, @RequestParam(required = false) LocalDate endMonth) {
+        List<CheckJobReportVO> list = checkJobService.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, CheckJobReportVO.class, list, fileName);
     }
 
     /**
@@ -69,8 +77,8 @@ public class CheckJobReportController {
      */
     @SysLog("保养任务周工作负荷统计报表")
     @GetMapping("week")
-    public R getWeekReportByYear(CheckJobDTO dto, @RequestParam(defaultValue = "2021") Integer year){
-        return new R(checkJobService.getWeekReport(dto, year));
+    public R getWeekReportByYear(CheckJobDTO dto, @RequestParam(required = false) Integer year,@RequestParam(required = false) LocalDate startMonth, @RequestParam(required = false) LocalDate endMonth){
+        return new R(checkJobService.getWeekReport(dto, year, startMonth, endMonth));
     }
 
     /**
@@ -81,8 +89,14 @@ public class CheckJobReportController {
      */
     @GetMapping("/week/export")
     @SysLog("保养任务周工作负荷统计报表")
-    public void exportWeekReportByYear(HttpServletResponse response, CheckJobDTO dto, @RequestParam(defaultValue = "2021") Integer year) {
-        List<CheckJobReportWeekHoursVO> list = checkJobService.getWeekReport(dto, year);
-        ExcelUtil.exportResponseDict(response, CheckJobReportWeekHoursVO.class, list, year + "年-保养任务每周工作负荷统计报表");
+    public void exportWeekReportByYear(HttpServletResponse response, CheckJobDTO dto, @RequestParam(required = false) Integer year, @RequestParam(required = false) LocalDate startMonth, @RequestParam(required = false) LocalDate endMonth) {
+        List<CheckJobReportWeekHoursVO> list = checkJobService.getWeekReport(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, CheckJobReportWeekHoursVO.class, list, fileName);
     }
 }

+ 24 - 10
platform-rest/src/main/java/com/platform/rest/controller/report/RepairReportController.java

@@ -1,6 +1,7 @@
 package com.platform.rest.controller.report;
 
 import com.platform.common.util.BeanConverterUtil;
+import com.platform.common.util.DateUtils;
 import com.platform.common.util.R;
 import com.platform.dao.dto.check.CheckJobDTO;
 import com.platform.dao.dto.repair.RepairApplicationFormDTO;
@@ -18,6 +19,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletResponse;
+import java.time.LocalDate;
 import java.util.List;
 
 /**
@@ -50,8 +52,8 @@ public class RepairReportController {
    */
   @GetMapping("")
   @SysLog(">24小时停机次数按月统计")
-  public R getMonthReportBig24(RepairApplicationFormDTO dto, @RequestParam(defaultValue = "2021") Integer year, @RequestParam(defaultValue = "1") Integer searchType){
-      return new R(repairApplicationFormService.getMonthReportBig24(dto, year, searchType));
+  public R getMonthReportBig24(RepairApplicationFormDTO dto, @RequestParam(required = false) Integer year, @RequestParam(required = false) LocalDate startMonth, @RequestParam(required = false) LocalDate endMonth, @RequestParam(defaultValue = "1") Integer searchType){
+      return new R(repairApplicationFormService.getMonthReportBig24(dto, year, startMonth, endMonth, searchType));
   }
 
     /**
@@ -70,9 +72,15 @@ public class RepairReportController {
      */
     @GetMapping("/export")
     @SysLog("24小时停机次数按月统计导出")
-    public void export(HttpServletResponse response, RepairApplicationFormDTO dto, @RequestParam(defaultValue = "2021") Integer year, @RequestParam(defaultValue = "1") Integer searchType) {
-        List<RepairReport24VO> list = repairApplicationFormService.getMonthReportBig24(dto, year, searchType);
-        ExcelUtil.exportResponseDict(response, RepairReport24VO.class, list, year + (searchType==1?"年-24小时停机次数按月统计表":"年-设备故障次数按月统计"));
+    public void export(HttpServletResponse response, RepairApplicationFormDTO dto, @RequestParam(required = false) Integer year, @RequestParam(required = false) LocalDate startMonth, @RequestParam(required = false) LocalDate endMonth, @RequestParam(defaultValue = "1") Integer searchType) {
+        List<RepairReport24VO> list = repairApplicationFormService.getMonthReportBig24(dto, year, startMonth, endMonth, searchType);
+        String fileName = "";
+        if(year == null){
+            fileName =  DateUtils.dateToString(startMonth, DateUtils.PATTERN_YMD) + "-" + DateUtils.dateToString(endMonth, DateUtils.PATTERN_YMD)  + (searchType==1?"-24小时停机次数按月统计表":"年-设备故障次数按月统计");
+        }else{
+            fileName =  year + (searchType==1?"年-24小时停机次数按月统计表":"年-设备故障次数按月统计");
+        }
+        ExcelUtil.exportResponseDict(response, RepairReport24VO.class, list, fileName);
     }
 
     /**
@@ -86,8 +94,8 @@ public class RepairReportController {
      */
     @GetMapping("mttr")
     @SysLog("MTTR月统计报表")
-    public R getMonthReportMttr(RepairApplicationFormDTO dto, @RequestParam(defaultValue = "2021") Integer year, @RequestParam(defaultValue = "1") Integer searchType){
-        return new R(repairApplicationFormService.getMonthReportMtrr(dto, year));
+    public R getMonthReportMttr(RepairApplicationFormDTO dto, @RequestParam(required = false) Integer year, @RequestParam(required = false) LocalDate startMonth, @RequestParam(required = false) LocalDate endMonth, @RequestParam(defaultValue = "1") Integer searchType){
+        return new R(repairApplicationFormService.getMonthReportMtrr(dto, year, startMonth, endMonth));
     }
 
     /**
@@ -102,8 +110,14 @@ public class RepairReportController {
      */
     @GetMapping("/mttr/export")
     @SysLog("MTTR月统计报表")
-    public void exportMttr(HttpServletResponse response, RepairApplicationFormDTO dto, @RequestParam(defaultValue = "2021") Integer year) {
-        List<RepairReportMttr> list = repairApplicationFormService.getMonthReportMtrr(dto, year);
-        ExcelUtil.exportResponseDict(response, RepairReportMttr.class, list, year + "年-MTTR月统计报表");
+    public void exportMttr(HttpServletResponse response, RepairApplicationFormDTO dto, @RequestParam(required = false) Integer year, @RequestParam(required = false) LocalDate startMonth, @RequestParam(required = false) LocalDate endMonth) {
+        List<RepairReportMttr> list = repairApplicationFormService.getMonthReportMtrr(dto, year, startMonth, endMonth);
+        String fileName = "";
+        if(year == null){
+            fileName =  DateUtils.dateToString(startMonth, DateUtils.PATTERN_YMD) + "-" + DateUtils.dateToString(endMonth, DateUtils.PATTERN_YMD)  + "-MTTR月统计报表";
+        }else{
+            fileName =  year + "年-MTTR月统计报表";
+        }
+        ExcelUtil.exportResponseDict(response, RepairReportMttr.class, list, fileName);
     }
 }

+ 3 - 2
platform-service/src/main/java/com/platform/service/check/CheckJobService.java

@@ -10,6 +10,7 @@ import com.platform.dao.vo.report.CheckJobReportWeekHoursVO;
 import com.platform.dao.vo.tuicalendar.TuiCalendar;
 import com.platform.service.base.IBaseService;
 
+import java.time.LocalDate;
 import java.util.List;
 
 /**
@@ -128,7 +129,7 @@ public interface CheckJobService extends IBaseService<CheckJob, CheckJobDTO> {
 
     int countTask(String sbId, String userId, Integer type, Integer searchType);
     int countSbUserTask(String sbId, String userId, Integer type);
-    List<CheckJobReportVO> getMonthReport(CheckJobDTO checkJobDTO, Integer month);
+    List<CheckJobReportVO> getMonthReport(CheckJobDTO checkJobDTO, Integer month, LocalDate startMonth, LocalDate endMonth);
 
-    List<CheckJobReportWeekHoursVO> getWeekReport(CheckJobDTO checkJobDTO, Integer month);
+    List<CheckJobReportWeekHoursVO> getWeekReport(CheckJobDTO checkJobDTO, Integer month, LocalDate startMonth, LocalDate endMonth);
 }

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

@@ -1185,22 +1185,28 @@ public class CheckJobServiceImpl extends BaseServiceImpl<CheckJobMapper, CheckJo
     }
 
     @Override
-    public List<CheckJobReportVO> getMonthReport(CheckJobDTO checkJobDTO, Integer searchYear) {
-        LocalDate localDate = LocalDate.now();
-        int year = localDate.getYear();
-
-        // 如2021-10-15号码,则month=10,需要计算到11月份,需要加1
-        int month = localDate.getMonthValue() + 1;
-        if(searchYear<year){
-            month = 12;
-            year = searchYear;
-        }
-        List<Map<String, LocalDateTime>> monthStartAndEndList = DateUtils.getMonthStartAndEndByYear(year, month);
+    public List<CheckJobReportVO> getMonthReport(CheckJobDTO checkJobDTO, Integer searchYear , LocalDate startMonth, LocalDate endMonth) {
+        List<Map<String, LocalDateTime>> monthStartAndEndList = new ArrayList<Map<String, LocalDateTime>>();
         LocalDateTime searchStartTime = null;
         LocalDateTime searchEndTime = null;
-        // 当前年份只统计到当前月,历史年份统计全年
-        searchStartTime = DateUtils.getFirstDayOfThisYear(year);
-        searchEndTime = DateUtils.getLastDayOfMonth(month);
+        if(searchYear != null){
+            LocalDate localDate = LocalDate.now();
+            int year = localDate.getYear();
+            // 如2021-10-15号码,则month=10,需要计算到11月份,需要加1
+            int month = localDate.getMonthValue() + 1;
+            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);
+        }
 
         // 总数
         checkJobDTO.setSearchStartTime(searchStartTime);
@@ -1240,7 +1246,7 @@ public class CheckJobServiceImpl extends BaseServiceImpl<CheckJobMapper, CheckJo
     }
 
     @Override
-    public List<CheckJobReportWeekHoursVO> getWeekReport(CheckJobDTO checkJobDTO, Integer searchYear) {
+    public List<CheckJobReportWeekHoursVO> getWeekReport(CheckJobDTO checkJobDTO, Integer searchYear, LocalDate startMonth, LocalDate endMonth) {
         List<Map<String, LocalDateTime>> monthStartAndEndList = DateUtils.getWeekStartAndEndByYear(searchYear);
         LocalDateTime searchStartTime = null;
         LocalDateTime searchEndTime = null;

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

@@ -13,6 +13,7 @@ import com.platform.dao.vo.report.RepairReport24VO;
 import com.platform.dao.vo.report.RepairReportMttr;
 import com.platform.service.base.IBaseService;
 
+import java.time.LocalDate;
 import java.util.List;
 
 /**
@@ -106,8 +107,8 @@ public interface RepairApplicationFormService extends IBaseService<RepairApplica
 
     void examine(String id);
 
-    List<RepairReport24VO> getMonthReportBig24(RepairApplicationFormDTO repairApplicationFormDTO, Integer year, Integer type);
+    List<RepairReport24VO> getMonthReportBig24(RepairApplicationFormDTO repairApplicationFormDTO, Integer year, LocalDate startMonth, LocalDate endMonth, Integer type);
 
-    List<RepairReportMttr> getMonthReportMtrr(RepairApplicationFormDTO repairApplicationFormDTO, Integer year);
+    List<RepairReportMttr> getMonthReportMtrr(RepairApplicationFormDTO repairApplicationFormDTO, Integer year, LocalDate startMonth, LocalDate endMonth);
 
 }

+ 41 - 39
platform-service/src/main/java/com/platform/service/repair/impl/RepairApplicationFormServiceImpl.java

@@ -694,32 +694,31 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
      * @return
      */
     @Override
-    public List<RepairReport24VO> getMonthReportBig24(RepairApplicationFormDTO repairApplicationFormDTO, Integer searchYear, Integer type) {
-        LocalDate localDate = LocalDate.now();
-        int year = localDate.getYear();
-
-        // 如2021-10-15号码,则month=10,需要计算到11月份,需要加1
-        int month = localDate.getMonthValue() + 1;
-        if(searchYear<year){
-            month = 12;
-            year = searchYear;
-        }
-        List<Map<String, LocalDateTime>> monthStartAndEndList = DateUtils.getMonthStartAndEndByYear(year, month);
+    public List<RepairReport24VO> getMonthReportBig24(RepairApplicationFormDTO repairApplicationFormDTO, Integer searchYear, LocalDate startMonth, LocalDate endMonth, Integer type) {
+        List<Map<String, LocalDateTime>> monthStartAndEndList = new ArrayList<Map<String, LocalDateTime>>();
         LocalDateTime searchStartTime = null;
         LocalDateTime searchEndTime = null;
-        // 当前年份只统计到当前月,历史年份统计全年
-        searchStartTime = DateUtils.getFirstDayOfThisYear(year);
-        searchEndTime = DateUtils.getLastDayOfMonth(month);
+        if(searchYear != null){
+            LocalDate localDate = LocalDate.now();
+            int year = localDate.getYear();
+            // 如2021-10-15号码,则month=10,需要计算到11月份,需要加1
+            int month = localDate.getMonthValue() + 1;
+            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);
+        }
 
         // 选择非计划性的订单
-       // if(type == 1){
-            repairApplicationFormDTO.setCategory(RepairApplicationFormCategoryEnum.PLAN_NOT.getValue());
-       /*}else if(type == 2){
-            List<Integer> categoryList = new ArrayList<Integer>();
-            categoryList.add(RepairApplicationFormCategoryEnum.PLAN_NOT.getValue());
-            categoryList.add(RepairApplicationFormCategoryEnum.PLAN.getValue());
-            repairApplicationFormDTO.setCategoryList(categoryList);
-        }*/
+        repairApplicationFormDTO.setCategory(RepairApplicationFormCategoryEnum.PLAN_NOT.getValue());
         repairApplicationFormDTO.setSearchStartTime(searchStartTime);
         repairApplicationFormDTO.setSearchEndTime(searchEndTime);
         List<RepairApplicationFormVO> list = mapper.selectPageList(repairApplicationFormDTO);
@@ -746,9 +745,6 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
             vo.setNum(i);
             result.add(vo);
         }
-  /*      for(RepairReport24VO r: result){
-            System.out.println(r.toString());
-        }*/
         return result;
     }
 
@@ -761,23 +757,29 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
      * @return
      */
     @Override
-    public List<RepairReportMttr> getMonthReportMtrr(RepairApplicationFormDTO repairApplicationFormDTO, Integer searchYear ) {
-        LocalDate localDate = LocalDate.now();
-        int year = localDate.getYear();
+    public List<RepairReportMttr> getMonthReportMtrr(RepairApplicationFormDTO repairApplicationFormDTO, Integer searchYear, LocalDate startMonth, LocalDate endMonth ) {
 
-        // 如2021-10-15号码,则month=10,需要计算到11月份,需要加1
-        int month = localDate.getMonthValue() + 1;
-        if(searchYear<year){
-            month = 12;
-            year = searchYear;
-        }
-        List<Map<String, LocalDateTime>> monthStartAndEndList = DateUtils.getMonthStartAndEndByYear(year, month);
+        List<Map<String, LocalDateTime>> monthStartAndEndList = new ArrayList<Map<String, LocalDateTime>>();
         LocalDateTime searchStartTime = null;
         LocalDateTime searchEndTime = null;
-        // 当前年份只统计到当前月,历史年份统计全年
-        searchStartTime = DateUtils.getFirstDayOfThisYear(year);
-        searchEndTime = DateUtils.getLastDayOfMonth(month);
-
+        if(searchYear != null){
+            LocalDate localDate = LocalDate.now();
+            int year = localDate.getYear();
+            // 如2021-10-15号码,则month=10,需要计算到11月份,需要加1
+            int month = localDate.getMonthValue() + 1;
+            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);
+        }
         // 选择非计划性的订单
         //List<Integer> categoryList = new ArrayList<Integer>();
         //categoryList.add(RepairApplicationFormCategoryEnum.PLAN_NOT.getValue());

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

@@ -7,6 +7,7 @@ import com.platform.common.util.IdGeneratorUtils;
 import com.platform.common.util.ListUtils;
 import com.platform.dao.bean.MyPage;
 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.upms.SysFile;
 import com.platform.dao.enums.SysFileTypeEnum;
@@ -112,7 +113,10 @@ public class RepairFeeServiceImpl extends BaseServiceImpl<RepairFeeMapper, Repai
         });
         model.setImageList(checkImgList);
         model.setFileList(checkFileList);
-        model.setRepairNo(repairApplicationFormMapper.selectById(model.getRepairId()).getNo());
+        RepairApplicationForm repairApplicationForm = repairApplicationFormMapper.selectById(model.getRepairId());
+        if(repairApplicationForm != null){
+            model.setRepairNo(repairApplicationFormMapper.selectById(model.getRepairId()).getNo());
+        }
         return model;
     }
 }