浏览代码

Merge branch 'wanghaicheng' of lift-manager/lift-server into develop

wanghaicheng 5 年之前
父节点
当前提交
b12f535460

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

@@ -2,10 +2,9 @@ package cn.com.ty.lift.business.maintenance.controller;
 
 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.PropertyMaintenanceMapper;
 import cn.com.ty.lift.business.maintenance.service.PropertyMaintenanceService;
-import cn.com.ty.lift.common.constants.ApiConstants;
 import cn.com.xwy.boot.web.dto.RestResponse;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import lombok.AllArgsConstructor;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -17,45 +16,12 @@ import org.springframework.web.bind.annotation.RestController;
 @AllArgsConstructor
 @RequestMapping("property")
 public class PropertyMaintenanceController {
-    private final PropertyMaintenanceMapper propertyMaintenanceMapper;
     private final PropertyMaintenanceService propertyMaintenanceService;
 
     @PostMapping("maintenance")
-    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, PropertyMaintenanceVO propertyMaintenanceVO) {
-        Page<PropertyMtResponse> page;
-        Integer maintenanceStatus = ApiConstants.Maintenance.WAITING_MAINTENANCE;
-        switch (propertyMaintenanceVO.getType()) {
-            case 1:
-                break;
-            case 2:
-                maintenanceStatus = ApiConstants.Maintenance.MAINTENANCE_DOING;
-                break;
-            case 3:
-                maintenanceStatus = ApiConstants.Maintenance.COMPLETE;
-                break;
-            case 4:
-                maintenanceStatus = ApiConstants.Maintenance.OVERDUE;
-                break;
-            case 5:
-                //todo
-                page = new Page<>();
-                break;
-            default:
-                page = new Page<>();
-        }
-        page = propertyMaintenanceMapper
-                .queryMaintenancePlanEveryDay(
-                        propertyMtResponsePage,
-                        maintenanceStatus,
-                        propertyMaintenanceVO.getPlanDate(),
-                        propertyMaintenanceVO.getUserId());
-        return page;
+    public RestResponse<?> maintenance(@RequestBody PropertyMaintenanceVO propertyMaintenanceVO) {
+        IPage<PropertyMtResponse> propertyMtResponsePage = new Page<>(propertyMaintenanceVO.getPageNum(), propertyMaintenanceVO.getPageSize());
+        return RestResponse.success(propertyMaintenanceService.propertyMtResponsePage(propertyMtResponsePage, propertyMaintenanceVO));
     }
 
     @PostMapping("maintenance/num/month")

+ 4 - 4
lift-business-service/src/main/java/cn/com/ty/lift/business/maintenance/dao/entity/model/request/PropertyMaintenanceVO.java

@@ -2,7 +2,7 @@ package cn.com.ty.lift.business.maintenance.dao.entity.model.request;
 
 import lombok.Data;
 
-import java.time.LocalDateTime;
+import java.time.LocalDate;
 
 @Data
 public class PropertyMaintenanceVO {
@@ -10,7 +10,7 @@ public class PropertyMaintenanceVO {
     /**
      * 计划时间
      */
-    private LocalDateTime planDate;
+    private LocalDate planDate;
     /**
      * 列表数据类型
      * 1、待保养
@@ -26,8 +26,8 @@ public class PropertyMaintenanceVO {
     /**
      * 分页
      */
-    private Long pageNum = 1L;
-    private Long pageSize = 10L;
+    private long pageNum = 1L;
+    private long pageSize = 10L;
 
     /**
      * 年月  例 202005  2020年5月

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

@@ -2,7 +2,7 @@ package cn.com.ty.lift.business.maintenance.dao.entity.model.response;
 
 import lombok.Data;
 
-import java.time.LocalDateTime;
+import java.time.LocalDate;
 
 @Data
 public class PropertyMtResponse {
@@ -12,5 +12,5 @@ public class PropertyMtResponse {
     private Object liftType;
     private Object category;
     private String workerName;
-    private LocalDateTime planDate;
+    private LocalDate planDate;
 }

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

@@ -3,19 +3,20 @@ package cn.com.ty.lift.business.maintenance.dao.mapper;
 import cn.com.ty.lift.business.maintenance.dao.entity.model.dto.MaintenancePlanMonthTaskNum;
 import cn.com.ty.lift.business.maintenance.dao.entity.model.response.PropertyMtResponse;
 import cn.com.ty.lift.common.constants.ApiConstants;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import org.apache.ibatis.annotations.Select;
 
-import java.time.LocalDateTime;
+import java.time.LocalDate;
 import java.util.List;
 
 public interface PropertyMaintenanceMapper {
     @Select(ApiConstants.SQL.QUERY_MAINTENANCE_PLAN_EVERYDAY)
-    Page<PropertyMtResponse> queryMaintenancePlanEveryDay(Page<PropertyMtResponse> page, Integer status, LocalDateTime planDate, Long userId);
+    IPage<PropertyMtResponse> queryMaintenancePlanEveryDay(IPage<PropertyMtResponse> page, Integer status, LocalDate planDate, Long userId);
+
+    @Select(ApiConstants.SQL.QUERY_MAINTENANCE_PLAN_EVERYDAY_OVERDUE)
+    IPage<PropertyMtResponse> queryMaintenancePlanEveryDayOverdue(IPage<PropertyMtResponse> page, LocalDate planDate, Long userId);
 
     @Select(ApiConstants.SQL.QUERY_MAINTENANCE_PLAN_MONTH_TASK_NUM)
     List<MaintenancePlanMonthTaskNum> queryMaintenancePlanMonth(Long userId, String yearMonth);
-
-    @Select(ApiConstants.SQL.SELECT_COUNT_FROM_TABLE)
-    Integer selectCount(String table, String condition);
 }

+ 45 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/maintenance/service/PropertyMaintenanceService.java

@@ -3,8 +3,11 @@ package cn.com.ty.lift.business.maintenance.service;
 import cn.com.ty.lift.business.maintenance.dao.entity.model.dto.MaintenancePlanMonthTaskNum;
 import cn.com.ty.lift.business.maintenance.dao.entity.model.request.PropertyMaintenanceVO;
 import cn.com.ty.lift.business.maintenance.dao.entity.model.response.PropertyCalendarResponse;
+import cn.com.ty.lift.business.maintenance.dao.entity.model.response.PropertyMtResponse;
 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.core.metadata.IPage;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
@@ -78,4 +81,46 @@ public class PropertyMaintenanceService {
             calendar.add(day);
         }
     }
+
+    /**
+     * @param propertyMtResponsePage 页码,页大小
+     * @param propertyMaintenanceVO  请求参数
+     * @return 分页查询某人加入的项目下电梯某天(待保养 / 保养中 / 已完成 / 超期 / 法规超期)的维保任务
+     */
+    public IPage<PropertyMtResponse> propertyMtResponsePage(IPage<PropertyMtResponse> propertyMtResponsePage, PropertyMaintenanceVO propertyMaintenanceVO) {
+        IPage<PropertyMtResponse> page;
+        Integer maintenanceStatus = ApiConstants.Maintenance.WAITING_MAINTENANCE;
+        switch (propertyMaintenanceVO.getType()) {
+            case 1:
+                maintenanceStatus = ApiConstants.Maintenance.WAITING_MAINTENANCE;
+                break;
+            case 2:
+                maintenanceStatus = ApiConstants.Maintenance.MAINTENANCE_DOING;
+                break;
+            case 3:
+                maintenanceStatus = ApiConstants.Maintenance.COMPLETE;
+                break;
+            case 4:
+                maintenanceStatus = ApiConstants.Maintenance.OVERDUE;
+                break;
+            case 5:
+                maintenanceStatus = ApiConstants.Maintenance.LAWS_STIPULATION_OVERDUE;
+                break;
+        }
+        if (maintenanceStatus.equals(ApiConstants.Maintenance.LAWS_STIPULATION_OVERDUE)) {
+            page = propertyMaintenanceMapper
+                    .queryMaintenancePlanEveryDayOverdue(
+                            propertyMtResponsePage,
+                            propertyMaintenanceVO.getPlanDate(),
+                            propertyMaintenanceVO.getUserId());
+        } else {
+            page = propertyMaintenanceMapper
+                    .queryMaintenancePlanEveryDay(
+                            propertyMtResponsePage,
+                            maintenanceStatus,
+                            propertyMaintenanceVO.getPlanDate(),
+                            propertyMaintenanceVO.getUserId());
+        }
+        return page;
+    }
 }

+ 25 - 27
lift-common/src/main/java/cn.com.ty.lift.common/constants/ApiConstants.java

@@ -337,12 +337,14 @@ public class ApiConstants {
     }
 
     public interface Maintenance {
-        Integer WAITING_MAINTENANCE = 0;
-        Integer MAINTENANCE_DOING = 2;
-        Integer COMPLETE = 1;
-        Integer OVERDUE = -1;
+        Integer WAITING_MAINTENANCE = 0;//待保养
+        Integer MAINTENANCE_DOING = 2;//保养中
+        Integer COMPLETE = 1;//已完成
+        Integer OVERDUE = -1;//超期
+        Integer LAWS_STIPULATION_OVERDUE = 10;//自定义的法规超期,非数据库状态
     }
 
+    //根据用户id和维保计划时间和状态查询用户那一天的各种类型维保任务(待保养/保养中/已完成/计划超期)
     public interface SQL {
         String QUERY_MAINTENANCE_PLAN_EVERYDAY =
                 "select p.project_name projectName," +
@@ -351,35 +353,31 @@ public class ApiConstants {
                         "       l.lift_type liftType," +
                         "       l.category category," +
                         "       ui.name workerName," +
-                        "       mp.plan_date planDate," +
+                        "       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})" +
+                        "           left join project p on mp.project_id = p.id" +
                         "          where mp.plan_date = #{planDate}" +
-                        "       and mp.status = #{status}";
+                        "       and mp.status = #{status}" +
+                        "   and mp.project_id in (select project_id from project_user where user_id = #{userId})";
 
-        String SELECT_COUNT_FROM_TABLE = "select count(*) from #{table} where ${condition}";
-
-        String QUERY_MAINTENANCE_MONTH =
-                "select p.project_name projectName," +
+        String QUERY_MAINTENANCE_PLAN_EVERYDAY_OVERDUE =
+                "select mp.status           planStatus," +
+                        "       l.id                liftId," +
+                        "       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" +
+                        "       l.device_position   devicePosition," +
+                        "       l.lift_type         liftType," +
+                        "       l.category          category," +
+                        "       ui.name             name" +
+                        "   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 user_info ui on mp.worker_id = ui.user_id" +
                         "         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";
+                        "   where plan_date = #{planDate}" +
+                        "  and TimeStampDiff(DAY, DATE_FORMAT(plan_date, '%Y%m%d'), DATE_FORMAT(work_date, '%Y%m%d')) > 15" +
+                        "  and mp.project_id in (select project_id from project_user where user_id = #{userId})";
 
         //扫码,查询电梯信息
         String QUERY_LIFT_INFO_BY_LIFT_ID =
@@ -419,10 +417,10 @@ public class ApiConstants {
 
         //物管,根据用户id和月份,查询那一月每天的(待保养/保养中/已完成/计划超期/法规超期)的数量
         String QUERY_MAINTENANCE_PLAN_MONTH_TASK_NUM =
-                "select DATE_FORMAT(plan_date, '%d') day, status, count(status) count" +
+                "select DATE_FORMAT(plan_date, '%d') day, status status, count(status) count" +
                         "   from maintenance_plan" +
                         "   where project_id in (select project_id from project_user where user_id = #{userId})" +
-                        "  and DATE_FORMAT(plan_date, '%Y%m') = #{yearMonth}" +
+                        "  and DATE_FORMAT(plan_date, '%Y-%m') = #{yearMonth}" +
                         "   group by plan_date, status";
     }
 }