瀏覽代碼

Merge branch 'feature-bieao' of lift-manager/lift-server into develop

bieao 5 年之前
父節點
當前提交
50e7dd7134

+ 4 - 1
lift-business-service/src/main/java/cn/com/ty/lift/business/maintenance/dao/entity/MaintenancePlan.java

@@ -2,8 +2,10 @@ package cn.com.ty.lift.business.maintenance.dao.entity;
 
 import java.util.Date;
 
+import cn.com.ty.lift.business.common.BaseEntity;
 import com.baomidou.mybatisplus.annotation.TableId;
 import lombok.Data;
+import lombok.EqualsAndHashCode;
 
 /**
  * 实体类 - 表:maintenance_plan
@@ -11,7 +13,8 @@ import lombok.Data;
  * @since 2019-12-12 11:27:30
  */
 @Data
-public class MaintenancePlan {
+@EqualsAndHashCode(callSuper = true)
+public class MaintenancePlan extends BaseEntity {
 
     /**
      * 维保计划ID

+ 0 - 19
lift-business-service/src/main/java/cn/com/ty/lift/business/maintenance/dao/entity/model/BatchMaintenancePlanRequest.java

@@ -1,19 +0,0 @@
-package cn.com.ty.lift.business.maintenance.dao.entity.model;
-
-import lombok.Data;
-
-import java.util.List;
-
-/**
- * @author bieao
- * @date 2019/12/17
- * @description 维保计划请求
- */
-@Data
-public class BatchMaintenancePlanRequest {
-
-    /**
-     * 维保计划id列表
-     */
-    private List<Long> ids;
-}

+ 14 - 1
lift-business-service/src/main/java/cn/com/ty/lift/business/maintenance/dao/entity/model/MaintenancePlanRequest.java

@@ -1,8 +1,11 @@
 package cn.com.ty.lift.business.maintenance.dao.entity.model;
 
+import cn.com.ty.lift.business.library.dao.entity.ProjectLiftRelevance;
 import cn.com.ty.lift.business.maintenance.dao.entity.MaintenancePlan;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
 
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -16,6 +19,11 @@ public class MaintenancePlanRequest {
      * 电梯列表
      */
     private List<MaintenancePlan> planList;
+
+    /**
+     * 项目电梯关联id列表
+     */
+    private List<ProjectLiftRelevance> relevanceList;
     /**
      * 项目id
      */
@@ -32,6 +40,10 @@ public class MaintenancePlanRequest {
      * 维保公司id
      */
     private String mtCompanyId;
+    /**
+     * 电梯id
+     */
+    private String liftId;
     /**
      * 维保间隔 1-15
      */
@@ -52,7 +64,8 @@ public class MaintenancePlanRequest {
     /**
      * 首保时间
      */
-    private String firstTime;
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    private Date firstTime;
     /**
      * 期数 1-24
      */

+ 20 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/maintenance/dao/entity/model/MaintenancePlanResponse.java

@@ -17,6 +17,26 @@ public class MaintenancePlanResponse {
      * 电梯id
      */
     private Long liftId;
+    /**
+     * 项目id
+     */
+    private Long projectId;
+    /**
+     * 维保公司id
+     */
+    private Long mtCompanyId;
+    /**
+     * 维保工id
+     */
+    private Long workerId;
+    /**
+     * 项目电梯关联id
+     */
+    private Long relevanceId;
+    /**
+     * 维保间隔
+     */
+    private Long planInterval;
     /**
      * 计划保养时间
      */

+ 28 - 12
lift-business-service/src/main/java/cn/com/ty/lift/business/maintenance/service/MaintenancePlanService.java

@@ -1,7 +1,8 @@
 package cn.com.ty.lift.business.maintenance.service;
 
+import cn.com.ty.lift.business.library.dao.entity.ProjectLiftRelevance;
+import cn.com.ty.lift.business.library.service.ProjectLiftRelevanceService;
 import cn.com.ty.lift.business.maintenance.dao.entity.MaintenancePlan;
-import cn.com.ty.lift.business.maintenance.dao.entity.model.BatchMaintenancePlanRequest;
 import cn.com.ty.lift.business.maintenance.dao.entity.model.MaintenancePlanRequest;
 import cn.com.ty.lift.business.maintenance.dao.entity.model.UpdateMaintenancePlanReq;
 import cn.com.ty.lift.business.maintenance.dao.mapper.MaintenancePlanMapper;
@@ -32,6 +33,9 @@ public class MaintenancePlanService extends ServiceImpl<MaintenancePlanMapper, M
     @Resource
     private MaintenancePlanMapper planMapper;
 
+    @Resource
+    private ProjectLiftRelevanceService projectLiftRelevanceService;
+
 
     private Map<String, String> paramMap = new HashMap<String, String>() {{
         put("projectCode", "项目编号");
@@ -83,12 +87,14 @@ public class MaintenancePlanService extends ServiceImpl<MaintenancePlanMapper, M
         //保养类型 1.半月,2.季度,3.半年,4.全年
         int[] maintenanceType = {1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 4};
         int times = 0;
+        //获取从第几期开始
+        int periods = request.getPeriods();
+        //获取保养间隔
+        int interval = request.getInterval();
         for (MaintenancePlan plan : plans) {
-            //获取从第几期开始
-            int periods = request.getPeriods();
-            //获取保养间隔
-            int interval = request.getInterval();
-            Project project = projectService.detail(plan.getProjectId());
+            //获取项目id
+            Long projectId = plan.getProjectId();
+            Project project = projectService.detail(projectId);
             if (project != null) {
                 Date beginTime = project.getStartDate();
                 Date endTime = project.getEndDate();
@@ -100,7 +106,7 @@ public class MaintenancePlanService extends ServiceImpl<MaintenancePlanMapper, M
                 //设置维保计划电梯ID,维保公司ID,项目ID,维保工ID,维保类型
                 entry.setLiftId(plan.getLiftId());
                 entry.setMtCompanyId(plan.getMtCompanyId());
-                entry.setProjectId(plan.getProjectId());
+                entry.setProjectId(projectId);
                 entry.setWorkerId(plan.getWorkerId());
                 entry.setType(maintenanceType[periods - 1]);
                 if (i == 0) {
@@ -119,6 +125,13 @@ public class MaintenancePlanService extends ServiceImpl<MaintenancePlanMapper, M
                 planList.add(entry);
             }
         }
+        //更新项目电梯关联表中电梯的首保时间和保养间隔
+        List<ProjectLiftRelevance> entryList = request.getRelevanceList();
+        for (ProjectLiftRelevance entry : entryList) {
+            entry.setPlanInterval(interval);
+            entry.setFirstTime(request.getFirstTime());
+        }
+        projectLiftRelevanceService.updateBatchById(entryList);
         return planList;
     }
 
@@ -155,14 +168,17 @@ public class MaintenancePlanService extends ServiceImpl<MaintenancePlanMapper, M
     }
 
     /**
-     * @param request ids 维保计划id列表
+     * @param mtCompanyId 公司id
+     * @param liftId 电梯id
      * @return 是否成功
      * @description 清空维保计划
-     * @date 2019/12/17 3:14 PM
+     * @date 2019/12/21 3:39 PM
      */
-    public boolean deleteByIds(BatchMaintenancePlanRequest request) {
-        log.info("批量清空维保计划");
-        return removeByIds(request.getIds());
+    public boolean cleanPlan(String mtCompanyId, String liftId) {
+        Map<String, Object> columnMap = new HashMap<>(2);
+        columnMap.put("mt_company_id", mtCompanyId);
+        columnMap.put("lift_id", liftId);
+        return planMapper.deleteByMap(columnMap) > 0;
     }
 
     /**

+ 13 - 11
lift-business-service/src/main/resources/mapper/maintenance/MaintenancePlanMapper.xml

@@ -23,25 +23,27 @@
 		SELECT
 		  mp.id                    AS id,
 		  mp.plan_date             AS planDate,
-		  l.id                     AS liftId,
+		  mp.id                    AS liftId,
 		  l.registration_code      AS registrationCode,
 		  l.device_position        AS devicePosition,
+		  plr.id                   AS relevanceId,
+          plr.company_id           AS mtCompanyId,
+          plr.worker_id            AS workerId,
+		  plr.plan_interval        AS planInterval,
+          p.id                     AS projectId,
 		  p.project_name           AS projectName,
 		  p.project_code           AS projectCode,
 		  pclr.lift_company_status AS liftStatus,
 		  r.area_name              AS regionName,
 		  ui.name                  AS workerName
-		FROM platform_company_lift_relevance pclr
-		LEFT JOIN maintenance_plan mp ON pclr.lift_id = mp.lift_id AND pclr.company_id = mp.mt_company_id
-		LEFT JOIN lift l ON l.id = pclr.lift_id AND l.id = mp.lift_id
-		LEFT JOIN lift_extension le ON l.id = le.id AND pclr.company_id = le.mt_company_id
-		LEFT JOIN project p ON pclr.company_id = p.mt_company_id AND mp.project_id = p.id
-		LEFT JOIN user_info ui ON le.worker_id = ui.user_id
+		FROM maintenance_plan mp
+		left join platform_company_lift_relevance pclr ON mp.mt_company_id = pclr.company_id AND mp.lift_id = pclr.lift_id
+		LEFT JOIN lift l ON mp.lift_id = l.id
+		left join project_lift_relevance plr ON mp.mt_company_id = plr.company_id AND mp.project_id = plr.project_id AND mp.lift_id = plr.lift_id
+		LEFT JOIN project p ON mp.mt_company_id = p.mt_company_id AND plr.project_id = p.id
+		LEFT JOIN user_info ui ON plr.worker_id = ui.user_id
 		LEFT JOIN region r ON p.region_id = r.id
-		WHERE 1=1
-		<if test="request.mtCompanyId!=null and request.mtCompanyId!=''">
-			AND mp.mt_company_id = #{request.mtCompanyId,jdbcType=VARCHAR}
-		</if>
+		WHERE mp.mt_company_id = #{request.mtCompanyId,jdbcType=VARCHAR}
 		<if test="request.projectId!=null and request.projectId!=''">
 			AND p.id = #{request.projectId,jdbcType=BIGINT}
 		</if>