瀏覽代碼

项目管理维保计划打印返回格式修改,按年月日查询

别傲 5 年之前
父節點
當前提交
cf02481ccb

+ 9 - 1
lift-business-service/src/main/java/cn/com/ty/lift/business/maintenance/dao/entity/model/request/MaintenancePlanPrintRequest.java

@@ -4,6 +4,8 @@ import cn.com.ty.lift.business.maintenance.dao.entity.MaintenancePlan;
 import lombok.Data;
 
 import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
+import java.time.LocalDate;
 import java.util.List;
 
 /**
@@ -17,7 +19,7 @@ public class MaintenancePlanPrintRequest {
     /**
      * 公司id
      */
-    @NotEmpty(message = "notEmpty")
+    @NotNull(message = "notEmpty")
     private Long mtCompanyId;
 
     /**
@@ -26,4 +28,10 @@ public class MaintenancePlanPrintRequest {
     @NotEmpty(message = "notEmpty")
     private List<MaintenancePlan> liftList;
 
+    /**
+     * 当前年月日
+     */
+    @NotNull(message = "notEmpty")
+    private LocalDate beginTime;
+
 }

+ 3 - 3
lift-business-service/src/main/java/cn/com/ty/lift/business/maintenance/dao/entity/model/response/LiftPrintResponse.java

@@ -1,9 +1,9 @@
 package cn.com.ty.lift.business.maintenance.dao.entity.model.response;
 
-import cn.com.ty.lift.business.maintenance.dao.entity.MaintenancePlan;
 import lombok.Data;
 
-import java.util.Collection;
+import java.util.List;
+import java.util.Map;
 
 /**
  * @author bieao
@@ -35,5 +35,5 @@ public class LiftPrintResponse {
     /**
      * 维保计划列表
      */
-    private Collection<MaintenancePlan> planList;
+    private List<Map<String,Object>> planList;
 }

+ 5 - 1
lift-business-service/src/main/java/cn/com/ty/lift/business/maintenance/dao/entity/model/response/MaintenanceRecordResponse.java

@@ -20,10 +20,14 @@ public class MaintenanceRecordResponse {
      * 上次保养类型
      */
     private String type;
+    /**
+     * 项目id
+     */
+    private Long projectId;
     /**
      * 电梯id
      */
-    private String liftId;
+    private Long liftId;
     /**
      * 电梯位置
      */

+ 14 - 4
lift-business-service/src/main/java/cn/com/ty/lift/business/maintenance/service/MaintenancePlanService.java

@@ -25,7 +25,9 @@ import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
 import java.time.LocalDate;
+import java.time.Month;
 import java.time.temporal.ChronoUnit;
+import java.time.temporal.TemporalAdjusters;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -377,28 +379,35 @@ public class MaintenancePlanService extends ServiceImpl<MaintenancePlanMapper, M
     /**
      * @param mtCompanyId 公司id
      * @param liftIdList 电梯id列表
+     * @param beginTime 开始时间
      * @return List<LiftPrintResponse> 电梯维保计划列表
      * @description 根据公司id和电梯id列表查询维保计划列表,并组装电梯列表数据
      * @date 2020/3/2 4:39 下午
      */
-    public List<LiftPrintResponse> getLiftMaintenancePlanList(Long mtCompanyId, List<Long> liftIdList) {
+    public List<LiftPrintResponse> getLiftMaintenancePlanList(Long mtCompanyId, List<Long> liftIdList, LocalDate beginTime) {
         //根据电梯id列表查询电梯列表
         List<LiftPrintResponse> liftList = liftService.queryLiftListByIdList(liftIdList);
 
+        LocalDate endTime = beginTime.with(TemporalAdjusters.lastDayOfMonth());
         Map<String, Object> paramMap = new HashMap<>();
         paramMap.put("mtCompanyId", mtCompanyId);
         paramMap.put("liftIdList", liftIdList);
+        paramMap.put("beginTime", beginTime);
+        paramMap.put("endTime", endTime);
         //根据电梯id、公司id查询维保计划列表
         List<MaintenancePlan> planList = baseMapper.queryPlanListByIds(paramMap);
 
         //组装电梯列表中的维保计划数据
         for (LiftPrintResponse entry : liftList) {
-            List<MaintenancePlan> plans = new ArrayList<>();
+            List<Map<String,Object>> plans = new ArrayList<>();
             for (MaintenancePlan plan : planList) {
                 if (entry.getProjectId().equals(plan.getProjectId())
                         && entry.getLiftId().equals(plan.getLiftId())
                         && entry.getMtCompanyId().equals(plan.getMtCompanyId())){
-                    plans.add(plan);
+                    Map<String,Object> map = new HashMap<>();
+                    map.put("planDate",plan.getPlanDate());
+                    map.put("type",plan.getType());
+                    plans.add(map);
                 }
             }
             entry.setPlanList(plans);
@@ -420,7 +429,7 @@ public class MaintenancePlanService extends ServiceImpl<MaintenancePlanMapper, M
         //根据项目id列表查询项目列表
         List<MaintenancePlanPrintResponse> projectList = projectService.queryProjectListByIdList(projectIdList);
 
-        List<LiftPrintResponse> liftList = getLiftMaintenancePlanList(request.getMtCompanyId(), liftIdList);
+        List<LiftPrintResponse> liftList = getLiftMaintenancePlanList(request.getMtCompanyId(), liftIdList, request.getBeginTime());
         //组装项目列表中的电梯数据
         for (MaintenancePlanPrintResponse project : projectList) {
             List<LiftPrintResponse> liftPrintResponses = new ArrayList<>();
@@ -431,6 +440,7 @@ public class MaintenancePlanService extends ServiceImpl<MaintenancePlanMapper, M
                 }
             }
             project.setLiftList(liftPrintResponses);
+            project.setNum(project.getLiftList().size());
         }
      return projectList;
     }

+ 6 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/project/dao/entity/model/request/ProjectPrintRequest.java

@@ -3,6 +3,7 @@ package cn.com.ty.lift.business.project.dao.entity.model.request;
 import lombok.Data;
 
 import javax.validation.constraints.NotNull;
+import java.time.LocalDate;
 
 /**
  * @author bieao
@@ -22,4 +23,9 @@ public class ProjectPrintRequest {
      */
     @NotNull(message = "notEmpty")
     private Long id;
+
+    /**
+     * 当前年月日
+     */
+    private LocalDate beginTime;
 }

+ 2 - 1
lift-business-service/src/main/java/cn/com/ty/lift/business/project/service/ProjectService.java

@@ -312,8 +312,9 @@ public class ProjectService extends ServiceImpl<ProjectMapper,Project> {
 
         List<Long> liftIdList = liftList.stream().map(ProjectLiftRelevance::getLiftId).collect(Collectors.toList());
         //根据公司id和电梯id列表查询维保计划列表
-        List<LiftPrintResponse> liftMaintenancePlanList = maintenancePlanService.getLiftMaintenancePlanList(request.getMtCompanyId(), liftIdList);
+        List<LiftPrintResponse> liftMaintenancePlanList = maintenancePlanService.getLiftMaintenancePlanList(request.getMtCompanyId(), liftIdList,request.getBeginTime());
         project.setLiftList(liftMaintenancePlanList);
+        project.setNum(liftList.size());
         return project;
     }
 

+ 1 - 0
lift-business-service/src/main/resources/mapper/maintenance/MaintenancePlanMapper.xml

@@ -94,6 +94,7 @@
         SELECT <include refid="Base_Column_List"/>
 			  FROM maintenance_plan
 		WHERE mt_company_id = #{paramMap.mtCompanyId,jdbcType=VARCHAR}
+		  AND plan_date BETWEEN #{paramMap.beginTime} AND #{paramMap.endTime}
 		  AND lift_id IN
 		<foreach collection="paramMap.liftIdList" item="id" index="index" open="(" close=")" separator=",">
 			#{id}

+ 2 - 1
lift-business-service/src/main/resources/mapper/maintenance/MaintenanceRecordMapper.xml

@@ -57,7 +57,8 @@
 				mr.type               AS type,
 				mr.lift_id            AS liftId,
 				l.device_position     AS devicePosition,
-				p.project_name        AS projectName
+				p.project_name        AS projectName,
+		        p.id                  AS projectId
 		FROM maintenance_record mr
 				LEFT JOIN project p ON mr.project_id = p.id
 				LEFT JOIN lift l ON mr.lift_id = l.id