Переглянути джерело

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

hfxc226 2 роки тому
батько
коміт
ebb1c12a2b

+ 40 - 0
platform-dao/src/main/java/com/platform/dao/vo/report/FillGatherTaskReportVO.java

@@ -0,0 +1,40 @@
+package com.platform.dao.vo.report;
+
+import com.platform.dao.vo.query.fill.FillGatherTaskVO;
+import com.platform.dao.vo.repair.RepairApplicationFormVO;
+import com.platform.office.annotation.Excel;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * @author cyz
+ */
+@Data
+@Accessors(chain = true)
+public class FillGatherTaskReportVO 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 Integer num;
+
+    /**
+     * 明细列表
+     */
+    List<FillGatherTaskVO> detailList;
+}

+ 1 - 1
platform-dao/src/main/resources/mapper/fill/FillGatherTaskMapper.xml

@@ -52,7 +52,7 @@
             and fill.created_time = #{createdTime}
         </if>
         <if test="updateTimeStart != null">
-            and fill.update_time <![CDATA[>=]]>; #{updateTimeStart}
+            and fill.update_time <![CDATA[>=]]> #{updateTimeStart}
         </if>
         <if test="updateTimeEnd != null">
             and fill.update_time <![CDATA[<=]]> #{updateTimeEnd}

+ 8 - 0
platform-rest/src/main/java/com/platform/rest/controller/fill/FillGatherTaskController.java

@@ -6,6 +6,7 @@ import com.platform.common.util.R;
 import com.platform.common.validation.group.AddGroup;
 import com.platform.common.validation.group.UpdateGroup;
 import com.platform.dao.dto.fill.FillGatherTaskDTO;
+import com.platform.dao.dto.repair.RepairApplicationFormDTO;
 import com.platform.dao.entity.fill.FillGatherTask;
 import com.platform.dao.util.ExcelUtil;
 import com.platform.dao.vo.export.fill.ExportFillGatherTaskVO;
@@ -18,6 +19,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;
 
 /**
@@ -242,4 +244,10 @@ public class FillGatherTaskController {
         return new R<>();
     }
 
+    @GetMapping("/report")
+    @SysLog("巡检任务报告")
+    public R getTaskReport(FillGatherTaskDTO dto, @RequestParam(required = false) Integer year, @RequestParam(required = false) LocalDate startMonth, @RequestParam(required = false) LocalDate endMonth, @RequestParam(defaultValue = "1") Integer searchType) {
+        return new R(fillGatherTaskService.getMonthReport(dto, year, startMonth, endMonth, searchType));
+    }
+
 }

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

@@ -72,7 +72,7 @@ public class RepairReportController {
     }
 
     /**
-     * 1: >24小时停机次数按月统计
+     * 1: >24小时停机次数按月统计g
      * 统计规则:
      * 1:非计划性维修
      * 2:报修和维修结束的时间大于24小时,即设备停机修复时间

+ 4 - 0
platform-service/src/main/java/com/platform/service/fill/FillGatherTaskService.java

@@ -4,8 +4,10 @@ import com.platform.common.bean.AbstractPageResultBean;
 import com.platform.dao.dto.fill.FillGatherTaskDTO;
 import com.platform.dao.entity.fill.FillGatherTask;
 import com.platform.dao.vo.query.fill.FillGatherTaskVO;
+import com.platform.dao.vo.report.FillGatherTaskReportVO;
 import com.platform.service.base.IBaseService;
 
+import java.time.LocalDate;
 import java.util.List;
 
 /**
@@ -15,6 +17,8 @@ import java.util.List;
  * @Version Copyright (c) 2020,北京乾元坤和科技有限公司 All rights reserved.
  */
 public interface FillGatherTaskService extends IBaseService<FillGatherTask, FillGatherTaskDTO> {
+
+ List<FillGatherTaskReportVO> getMonthReport(FillGatherTaskDTO dto, Integer year, LocalDate startMonth, LocalDate endMonth, Integer searchType);
  /**
   * 向已有的巡检任务中插入巡检明细
   * @param dto

+ 68 - 0
platform-service/src/main/java/com/platform/service/fill/impl/FillGatherTaskServiceImpl.java

@@ -26,6 +26,9 @@ import com.platform.dao.vo.SysRoleVO;
 import com.platform.dao.vo.query.fill.FillGatherTaskDetailVO;
 import com.platform.dao.vo.query.fill.FillGatherTaskVO;
 import com.platform.dao.vo.query.fill.FillInfoVO;
+import com.platform.dao.vo.repair.RepairApplicationFormVO;
+import com.platform.dao.vo.report.FillGatherTaskReportVO;
+import com.platform.dao.vo.report.RepairReport24VO;
 import com.platform.service.base.impl.BaseServiceImpl;
 import com.platform.service.event.WorkplaceBacklogEvent;
 import com.platform.service.fill.FillGatherTaskService;
@@ -36,9 +39,11 @@ import org.springframework.stereotype.Service;
 import tk.mybatis.mapper.weekend.Weekend;
 import tk.mybatis.mapper.weekend.WeekendCriteria;
 
+import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 import java.util.concurrent.TimeUnit;
 
 /**
@@ -67,6 +72,69 @@ public class FillGatherTaskServiceImpl extends BaseServiceImpl<FillGatherTaskMap
         }
 
     }
+
+    @Override
+    public List<FillGatherTaskReportVO> getMonthReport(FillGatherTaskDTO dto, Integer searchYear, LocalDate startMonth, LocalDate endMonth, Integer searchType) {
+        List<Map<String, LocalDateTime>> monthStartAndEndList = new ArrayList<Map<String, LocalDateTime>>();
+        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);
+        }
+
+        // 选择非计划性的订单
+        dto.setStatus(2);//已完成
+        dto.setUpdateTimeStart(searchStartTime);
+        dto.setUpdateTimeEnd(searchEndTime);
+        List<FillGatherTaskVO> list = mapper.selectList(dto);
+        List<FillGatherTaskReportVO> result = new ArrayList();
+
+        for (Map<String, LocalDateTime> map : monthStartAndEndList) {
+            int i = 0;
+            FillGatherTaskReportVO vo = new FillGatherTaskReportVO();
+            List<FillGatherTaskVO> detailList = new ArrayList();
+            vo.setYear(map.get("searchStartTimeMonth").getYear());
+            vo.setMonth(map.get("searchStartTimeMonth").getMonthValue());
+            for (FillGatherTaskVO fillGatherTaskVO : list) {
+//                if (repairApplicationForm.getDealMinutes() == null) {
+//                    continue;
+//                }
+              /*  if (type == 1) {
+                    double minutes = repairApplicationForm.getDealMinutes();
+                    if (minutes < 24.0) {
+                        continue;
+                    }
+                }*/
+                if (fillGatherTaskVO.getUpdateTime().isAfter(map.get("searchStartTimeMonth")) && fillGatherTaskVO.getUpdateTime().isBefore(map.get("searchEndTimeMonth"))) {
+                    i++;
+                    detailList.add(fillGatherTaskVO);
+                }
+            }
+            vo.setNum(i);
+            vo.setDetailList(detailList);
+            result.add(vo);
+            /*if (type == 2) {
+                i = 0;
+            }*/
+        }
+        return result;
+    }
+
     @Override
     public int updateDetails(FillGatherTaskDTO dto) {
         //先获取勾选设备,更新