Browse Source

物业维保任务更新

wanghaicheng 5 years ago
parent
commit
4e7446cb6e

+ 31 - 9
lift-business-service/src/main/java/cn/com/ty/lift/business/maintenance/controller/PropertyMaintenanceController.java

@@ -1,10 +1,11 @@
 package cn.com.ty.lift.business.maintenance.controller;
 
-import cn.com.ty.lift.business.maintenance.dao.entity.model.request.PropertyMtRequest;
+import cn.com.ty.lift.business.maintenance.dao.entity.model.request.PropertyMaintenanceVO;
 import cn.com.ty.lift.business.maintenance.dao.entity.model.response.PropertyMtResponse;
 import cn.com.ty.lift.business.maintenance.dao.mapper.MaintenancePlanMapper;
 import cn.com.ty.lift.business.maintenance.dao.mapper.MaintenanceRecordMapper;
 import cn.com.ty.lift.business.maintenance.dao.mapper.PropertyMaintenanceMapper;
+import cn.com.ty.lift.common.constants.ApiConstants;
 import cn.com.xwy.boot.web.dto.RestResponse;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import lombok.AllArgsConstructor;
@@ -13,8 +14,6 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
-import java.util.List;
-
 @RestController
 @AllArgsConstructor
 @RequestMapping("property")
@@ -24,15 +23,38 @@ public class PropertyMaintenanceController {
     private final PropertyMaintenanceMapper propertyMaintenanceMapper;
 
     @PostMapping("maintenance")
-    public RestResponse maintenance(@RequestBody PropertyMtRequest propertyMtRequest) {
-        Page<PropertyMtResponse> propertyMtResponsePage = new Page<>(propertyMtRequest.getPageNum(), propertyMtRequest.getPageSize());
+    public RestResponse maintenance(@RequestBody PropertyMaintenanceVO propertyMaintenanceVO) {
+        Page<PropertyMtResponse> propertyMtResponsePage = new Page<>(propertyMaintenanceVO.getPageNum(), propertyMaintenanceVO.getPageSize());
         //todo
         return RestResponse.success("待实现");
     }
 
-    public Page<PropertyMtResponse> propertyMtResponsePage(Page<PropertyMtResponse> propertyMtResponsePage, PropertyMtRequest propertyMtRequest) {
-        Page<PropertyMtResponse> propertyMtResponses =
-                propertyMaintenanceMapper.queryMaintenance(propertyMtResponsePage, propertyMtRequest.getUserId());
-        return propertyMtResponses;
+    public Page<PropertyMtResponse> propertyMtResponsePage(Page<PropertyMtResponse> propertyMtResponsePage, PropertyMaintenanceVO propertyMaintenanceVO) {
+        Page<PropertyMtResponse> page;
+        switch (propertyMaintenanceVO.getType()) {
+            case 1:
+                page = propertyMaintenanceMapper
+                        .queryMaintenanceEveryDay(propertyMtResponsePage, ApiConstants.Maintenance.STATUS_UNFINISHED, propertyMaintenanceVO.getPlanDate(), propertyMaintenanceVO.getUserId());
+                break;
+            case 2:
+                //todo
+                page = new Page<>();
+                break;
+            case 3:
+                page = propertyMaintenanceMapper
+                        .queryMaintenanceEveryDay(propertyMtResponsePage, ApiConstants.Maintenance.STATUS_COMPLETED, propertyMaintenanceVO.getPlanDate(), propertyMaintenanceVO.getUserId());
+                break;
+            case 4:
+                page = propertyMaintenanceMapper
+                        .queryMaintenanceEveryDay(propertyMtResponsePage, ApiConstants.Maintenance.STATUS_EXCEED, propertyMaintenanceVO.getPlanDate(), propertyMaintenanceVO.getUserId());
+                break;
+            case 5:
+                //todo
+                page = new Page<>();
+                break;
+            default:
+                page = new Page<>();
+        }
+        return page;
     }
 }

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

@@ -2,9 +2,15 @@ package cn.com.ty.lift.business.maintenance.dao.entity.model.request;
 
 import lombok.Data;
 
+import java.time.LocalDateTime;
+
 @Data
-public class PropertyMtRequest {
+public class PropertyMaintenanceVO {
 
+    /**
+     * 计划时间
+     */
+    private LocalDateTime planDate;
     /**
      * 列表数据类型
      * 1、待保养

+ 4 - 3
lift-business-service/src/main/java/cn/com/ty/lift/business/maintenance/dao/mapper/PropertyMaintenanceMapper.java

@@ -5,9 +5,10 @@ import cn.com.ty.lift.common.constants.ApiConstants;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import org.apache.ibatis.annotations.Select;
 
+import java.time.LocalDateTime;
 import java.util.List;
 
 public interface PropertyMaintenanceMapper {
-    @Select(ApiConstants.SQL.QUERY_MAINTENANCE)
-    Page<PropertyMtResponse> queryMaintenance(Page<PropertyMtResponse> page, Long userId);
-}
+    @Select(ApiConstants.SQL.QUERY_MAINTENANCE_EVERYDAY)
+    Page<PropertyMtResponse> queryMaintenanceEveryDay(Page<PropertyMtResponse> page,Integer type, LocalDateTime planDate, Long userId);
+}

+ 54 - 19
lift-common/src/main/java/cn.com.ty.lift.common/constants/ApiConstants.java

@@ -336,27 +336,62 @@ public class ApiConstants {
     }
 
     public interface Maintenance {
-        Integer STATUS_UNFINISHED = 1;
+        Integer STATUS_UNFINISHED = 0;
+        Integer STATUS_COMPLETED = 1;
+        Integer STATUS_EXCEED = 2;
+        Integer STATUS_IN_MAINTENANCE = 1;
     }
 
     public interface SQL {
-        String QUERY_MAINTENANCE = "select p.project_name projectName," +
-                "       l.registration_code registrationCode," +
-                "       l.device_position devicePosition," +
-                "       l.lift_type liftType," +
-                "       l.category category," +
-                "       ui.name workerName," +
-                "       mp.plan_date planDate," +
-                "       from maintenance_plan mp" +
-                "         left join lift l on mp.lift_id = l.id" +
-                "         left join project_lift_relevance plr" +
-                "                   on l.id = plr.lift_id" +
-                "                       and plr.project_id in (select project_id" +
-                "                                              from project_user" +
-                "                                              where user_id = #{userId})" +
-                "         left join project p on mp.project_id = p.id" +
-                "         left join user_info ui on ui.user_id = mp.worker_id" +
-                "        where DATE_FORMAT(mp.plan_date, '%Y%m') = DATE_FORMAT(CURDATE(), '%Y%m')" +
-                "  and mp.status = '1'";
+        String QUERY_MAINTENANCE_EVERYDAY =
+                "select p.project_name projectName," +
+                        "       l.registration_code registrationCode," +
+                        "       l.device_position devicePosition," +
+                        "       l.lift_type liftType," +
+                        "       l.category category," +
+                        "       ui.name workerName," +
+                        "       mp.plan_date planDate," +
+                        "          from maintenance_plan mp" +
+                        "           left join lift l on mp.lift_id = l.id" +
+                        "           left join user_info ui on mp.worker_id = ui.user_id" +
+                        "           left join project p on p.id in (select project_id from project_user where user_id = #{userId})" +
+                        "          where DATE_FORMAT(mp.plan_date, '%Y%m%d') = #{planDate}" +
+                        "       and mp.status = #{type}";
     }
+    
+    String QUERY_MAINTENANCE_RECORD = 
+            "select p.project_name," +
+                    "       l.registration_code," +
+                    "       l.device_position," +
+                    "       l.lift_type," +
+                    "       l.category," +
+                    "       ui.name," +
+                    "       mr.plan_date," +
+                    "       mr.type" +
+                    "       from maintenance_record mr" +
+                    "         left join lift l on mr.lift_id = l.id" +
+                    "         left join user_info ui on mr.worker_id = ui.user_id" +
+                    "         left join project p on p.id in (select project_id from project_user where user_id = '1001101134377')" +
+                    "where DATE_FORMAT(mr.plan_date, '%Y-%m-%d') ='2020-05-08'" +
+                    "  and mr.status = 1";
+
+    String QUERY_MAINTENANCE_MONTH =
+            "select p.project_name projectName," +
+                    "       l.registration_code registrationCode," +
+                    "       l.device_position devicePosition," +
+                    "       l.lift_type liftType," +
+                    "       l.category category," +
+                    "       ui.name workerName," +
+                    "       mp.plan_date planDate," +
+                    "       from maintenance_plan mp" +
+                    "         left join lift l on mp.lift_id = l.id" +
+                    "         left join project_lift_relevance plr" +
+                    "                   on l.id = plr.lift_id" +
+                    "                       and plr.project_id in (select project_id" +
+                    "                                              from project_user" +
+                    "                                              where user_id = #{userId})" +
+                    "         left join project p on mp.project_id = p.id" +
+                    "         left join user_info ui on ui.user_id = mp.worker_id" +
+                    "        where DATE_FORMAT(mp.plan_date, '%Y%m') = DATE_FORMAT(CURDATE(), '%Y%m')" +
+                    "  and mp.status = '1' order by mp.plan_date";
 }