Forráskód Böngészése

Merge branch 'develop' of http://132.232.206.88:3000/lift-manager/lift-server into feature-bieao

别傲 5 éve
szülő
commit
2d149bb4e6

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

@@ -2,8 +2,6 @@ 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.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;
@@ -18,8 +16,6 @@ import org.springframework.web.bind.annotation.RestController;
 @AllArgsConstructor
 @RequestMapping("property")
 public class PropertyMaintenanceController {
-    private final MaintenancePlanMapper maintenancePlanMapper;
-    private final MaintenanceRecordMapper maintenanceRecordMapper;
     private final PropertyMaintenanceMapper propertyMaintenanceMapper;
 
     @PostMapping("maintenance")
@@ -31,22 +27,18 @@ public class PropertyMaintenanceController {
 
     public Page<PropertyMtResponse> propertyMtResponsePage(Page<PropertyMtResponse> propertyMtResponsePage, PropertyMaintenanceVO propertyMaintenanceVO) {
         Page<PropertyMtResponse> page;
+        Integer maintenanceStatus = ApiConstants.Maintenance.WAITING_MAINTENANCE;
         switch (propertyMaintenanceVO.getType()) {
             case 1:
-                page = propertyMaintenanceMapper
-                        .queryMaintenancePlanEveryDay(propertyMtResponsePage, ApiConstants.Maintenance.STATUS_UNFINISHED, propertyMaintenanceVO.getPlanDate(), propertyMaintenanceVO.getUserId());
                 break;
             case 2:
-                page = propertyMaintenanceMapper
-                        .queryMaintenanceRecordEveryDay(propertyMtResponsePage, propertyMaintenanceVO.getPlanDate(), propertyMaintenanceVO.getUserId());
+                maintenanceStatus = ApiConstants.Maintenance.MAINTENANCE_DOING;
                 break;
             case 3:
-                page = propertyMaintenanceMapper
-                        .queryMaintenancePlanEveryDay(propertyMtResponsePage, ApiConstants.Maintenance.STATUS_COMPLETED, propertyMaintenanceVO.getPlanDate(), propertyMaintenanceVO.getUserId());
+                maintenanceStatus = ApiConstants.Maintenance.COMPLETE;
                 break;
             case 4:
-                page = propertyMaintenanceMapper
-                        .queryMaintenancePlanEveryDay(propertyMtResponsePage, ApiConstants.Maintenance.STATUS_EXCEED, propertyMaintenanceVO.getPlanDate(), propertyMaintenanceVO.getUserId());
+                maintenanceStatus = ApiConstants.Maintenance.OVERDUE;
                 break;
             case 5:
                 //todo
@@ -55,6 +47,12 @@ public class PropertyMaintenanceController {
             default:
                 page = new Page<>();
         }
+        page = propertyMaintenanceMapper
+                .queryMaintenancePlanEveryDay(
+                        propertyMtResponsePage,
+                        maintenanceStatus,
+                        propertyMaintenanceVO.getPlanDate(),
+                        propertyMaintenanceVO.getUserId());
         return page;
     }
 }

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

@@ -6,14 +6,10 @@ 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_PLAN_EVERYDAY)
-    Page<PropertyMtResponse> queryMaintenancePlanEveryDay(Page<PropertyMtResponse> page, Integer type, LocalDateTime planDate, Long userId);
-
-    @Select(ApiConstants.SQL.QUERY_MAINTENANCE_RECORD_EVERYDAY)
-    Page<PropertyMtResponse> queryMaintenanceRecordEveryDay(Page<PropertyMtResponse> page, LocalDateTime planDate, Long userId);
+    Page<PropertyMtResponse> queryMaintenancePlanEveryDay(Page<PropertyMtResponse> page, Integer status, LocalDateTime planDate, Long userId);
 
     @Select(ApiConstants.SQL.SELECT_COUNT_FROM_TABLE)
     Integer selectCount(String table, String condition);

+ 6 - 22
lift-common/src/main/java/cn.com.ty.lift.common/constants/ApiConstants.java

@@ -337,10 +337,10 @@ public class ApiConstants {
     }
 
     public interface Maintenance {
-        Integer STATUS_UNFINISHED = 0;
-        Integer STATUS_COMPLETED = 1;
-        Integer STATUS_EXCEED = -1;
-        Integer STATUS_IN_MAINTENANCE = 1;
+        Integer WAITING_MAINTENANCE = 0;
+        Integer MAINTENANCE_DOING = 2;
+        Integer COMPLETE = 1;
+        Integer OVERDUE = -1;
     }
 
     public interface SQL {
@@ -356,27 +356,11 @@ public class ApiConstants {
                         "           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}";
+                        "          where mp.plan_date = #{planDate}" +
+                        "       and mp.status = #{status}";
 
         String SELECT_COUNT_FROM_TABLE = "select count(*) from #{table} where ${condition}";
 
-        String QUERY_MAINTENANCE_RECORD_EVERYDAY =
-                "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 = #{userId})" +
-                        "   where DATE_FORMAT(mr.plan_date, '%Y%m%d') = #{planDate}" +
-                        "  and mr.status = '1";
-
         String QUERY_MAINTENANCE_MONTH =
                 "select p.project_name projectName," +
                         "       l.registration_code registrationCode," +

+ 1 - 1
lift-system-service/src/main/java/cn/com/ty/lift/system/constants/CommonConstants.java

@@ -243,7 +243,7 @@ public class CommonConstants {
          * 9.年检完成电梯
          */
         int[] LIFT_STATUS_ARRAY = {
-                1, 2, 3,
+                -1, 1, 2, 3,
                 4, 5, 6,
                 7, 8, 9
         };

+ 25 - 44
lift-system-service/src/main/java/cn/com/ty/lift/system/homepage/service/PlatformCalendarService.java

@@ -8,7 +8,6 @@ import cn.com.ty.lift.system.homepage.dao.mapper.CommonDataMapper;
 import cn.com.ty.lift.system.homepage.dao.model.*;
 import cn.com.ty.lift.system.utils.CommonUtil;
 import cn.com.xwy.boot.web.dto.RestResponse;
-import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -102,8 +101,6 @@ public class PlatformCalendarService {
         //时间转化
         CommonUtil.setMonthDate(platformCalendarRequest);
         Map<Integer, Map<Integer, List<CalendarLiftDataModel>>> dayToCalendarLift = new HashMap<>();
-        //获取维保记录数据,并将维保记录数据转化为 天 -> 维保记录(电梯id -> 维保记录)
-        Map<Integer, Map<Long, List<MtRecordDataModel>>> dayToMtRecord = getDayToMtRecord(platformCalendarRequest);
         //获取维保计划,并将维保计划信息转化为 天 -> 维保计划(电梯id -> 维保计划)
         Map<Integer, Map<Long, List<MtPlanDataModel>>> dayToMtPlan = getDayToMtPlan(platformCalendarRequest);
         //获取急修记录,并将急修记录转化为 天 -> 急修数据(电梯id -> 急修数据)
@@ -117,7 +114,7 @@ public class PlatformCalendarService {
                 platformCalendarRequest.getRequestDateStr(), CommonConstants.PlatformCalendarConstants.REQUEST_DATE_FORMAT);
         //循环设置每日的数据
         for (int day = 1; day <= monthDayNum; day++) {
-            addCalendarLift(dayToCalendarLift, dayToMtRecord, dayToMtPlan, dayToEmergencyRecord, dayToAnnualInspection, day);
+            addCalendarLift(dayToCalendarLift, dayToMtPlan, dayToEmergencyRecord, dayToAnnualInspection, day);
         }
         return dayToCalendarLift;
     }
@@ -129,12 +126,9 @@ public class PlatformCalendarService {
      * @date 2020/2/21 3:05 下午
      */
     private void addCalendarLift(Map<Integer, Map<Integer, List<CalendarLiftDataModel>>> dayToCalendarLift,
-                                 Map<Integer, Map<Long, List<MtRecordDataModel>>> dayToMtRecord,
                                  Map<Integer, Map<Long, List<MtPlanDataModel>>> dayToMtPlan,
                                  Map<Integer, Map<Long, List<EmergencyRecordDataModel>>> dayToEmergencyRecord,
                                  Map<Integer, Map<Long, List<AnnualInspectionDataModel>>> dayToAnnualInspection, int day) {
-        //获取每天的维保记录数据
-        Map<Long, List<MtRecordDataModel>> liftIdToMtRecord = dayToMtRecord.get(day);
         //获取每天的维保计划数据
         Map<Long, List<MtPlanDataModel>> liftIdToMtPlan = dayToMtPlan.get(day);
         //获取每天的急修记录数据
@@ -142,8 +136,7 @@ public class PlatformCalendarService {
         //获取每天的年检记录数据
         Map<Long, List<AnnualInspectionDataModel>> liftIdToAnnualInspection = dayToAnnualInspection.get(day);
         //获取电梯id集合
-        Set liftIdSet = getLiftIdSet(liftIdToMtRecord, liftIdToMtPlan, liftIdToEmergencyRecord,
-                liftIdToAnnualInspection);
+        Set liftIdSet = getLiftIdSet(liftIdToMtPlan, liftIdToEmergencyRecord, liftIdToAnnualInspection);
         //状态 -> 电梯列表
         Map<Integer, List<CalendarLiftDataModel>> statusToCalendarLift = new HashMap<>();
         if (liftIdSet.size() > 0) {
@@ -151,7 +144,7 @@ public class PlatformCalendarService {
             liftIdSet.forEach(liftId -> {
                 long liftIdLong = Long.parseLong(liftId.toString());
                 //封装维保的电梯信息
-                addMaintenanceStatusLift(liftIdToMtRecord, liftIdToMtPlan, calendarLiftDataModelList, liftIdLong);
+                addMaintenanceStatusLift(liftIdToMtPlan, calendarLiftDataModelList, liftIdLong);
                 //封装急修信息
                 addEmergencyStatusLift(liftIdToEmergencyRecord, calendarLiftDataModelList, liftIdLong);
                 //封装年检信息
@@ -207,48 +200,38 @@ public class PlatformCalendarService {
      * @description 封装维保的电梯信息
      * @date 2020/2/21 2:55 下午
      */
-    private void addMaintenanceStatusLift(Map<Long, List<MtRecordDataModel>> liftIdToMtRecord,
-                                          Map<Long, List<MtPlanDataModel>> liftIdToMtPlan,
+    private void addMaintenanceStatusLift(Map<Long, List<MtPlanDataModel>> liftIdToMtPlan,
                                           List<CalendarLiftDataModel> calendarLiftDataModelList,
                                           Long liftId) {
-        if (liftIdToMtRecord != null) {
-            //获取保养记录数据
-            List<MtRecordDataModel> mtRecordDataModelList = liftIdToMtRecord.get(liftId);
-            if (mtRecordDataModelList != null && mtRecordDataModelList.size() > 0) {
-                MtRecordDataModel mtRecordDataModel = mtRecordDataModelList.get(0);
+        if (liftIdToMtPlan != null) {
+            //获取保养计划数据
+            List<MtPlanDataModel> mtPlanDataModelList = liftIdToMtPlan.get(liftId);
+            if (mtPlanDataModelList != null && mtPlanDataModelList.size() > 0) {
+                MtPlanDataModel mtPlanDataModel = mtPlanDataModelList.get(0);
                 CalendarLiftDataModel calendarLiftDataModel = new CalendarLiftDataModel(
-                        mtRecordDataModel.getLiftId(), mtRecordDataModel.getProjectName(),
-                        mtRecordDataModel.getRegistrationCode(), mtRecordDataModel.getLiftCode(),
-                        mtRecordDataModel.getWorkerName());
+                        mtPlanDataModel.getLiftId(), mtPlanDataModel.getProjectName(),
+                        mtPlanDataModel.getRegistrationCode(), mtPlanDataModel.getLiftCode(),
+                        mtPlanDataModel.getWorkerName());
                 //默认是维保已完成
                 calendarLiftDataModel.setMaintenanceStatus(3);
-                if (StringUtils.isNotBlank(mtRecordDataModel.getStatus())) {
-                    switch (mtRecordDataModel.getStatus()) {
-                        case "-2":
-                        case "-1":
-                        case "0":
+                if (mtPlanDataModel.getStatus() != null) {
+                    switch (mtPlanDataModel.getStatus()) {
+                        case 0:
+                            //待完成
                             calendarLiftDataModel.setMaintenanceStatus(1);
                             break;
-                        case "1":
+                        case 2:
+                            //维保中
                             calendarLiftDataModel.setMaintenanceStatus(2);
                             break;
+                        case -1:
+                            calendarLiftDataModel.setMaintenanceStatus(-1);
+                            break;
                     }
                 }
                 calendarLiftDataModelList.add(calendarLiftDataModel);
             }
-        } else if (liftIdToMtPlan != null) {
-            //获取保养计划数据
-            List<MtPlanDataModel> mtPlanDataModelList = liftIdToMtPlan.get(liftId);
-            if (mtPlanDataModelList != null && mtPlanDataModelList.size() > 0) {
-                //有计划 则说明有待保养的电梯
-                MtPlanDataModel mtPlanDataModel = mtPlanDataModelList.get(0);
-                CalendarLiftDataModel calendarLiftDataModel = new CalendarLiftDataModel(
-                        mtPlanDataModel.getLiftId(), mtPlanDataModel.getProjectName(),
-                        mtPlanDataModel.getRegistrationCode(), mtPlanDataModel.getLiftCode(),
-                        mtPlanDataModel.getWorkerName());
-                calendarLiftDataModel.setMaintenanceStatus(1);
-                calendarLiftDataModelList.add(calendarLiftDataModel);
-            }
+
         }
     }
 
@@ -405,13 +388,11 @@ public class PlatformCalendarService {
      * @description 获取电梯id集合
      * @date 2020/2/21 1:16 下午
      */
-    private Set getLiftIdSet(Map<Long, List<MtRecordDataModel>> liftIdToMtRecord,
-                                   Map<Long, List<MtPlanDataModel>> liftIdToMtPlan,
-                                   Map<Long, List<EmergencyRecordDataModel>> liftIdToEmergencyRecord,
-                                   Map<Long, List<AnnualInspectionDataModel>> liftIdToAnnualInspection) {
+    private Set getLiftIdSet(Map<Long, List<MtPlanDataModel>> liftIdToMtPlan,
+                             Map<Long, List<EmergencyRecordDataModel>> liftIdToEmergencyRecord,
+                             Map<Long, List<AnnualInspectionDataModel>> liftIdToAnnualInspection) {
         //数据集合数组
         Map[] dataMapArray = {
-                liftIdToMtRecord,
                 liftIdToMtPlan,
                 liftIdToEmergencyRecord,
                 liftIdToAnnualInspection

+ 1 - 0
lift-system-service/src/main/resources/mapper/CommonDataMapper.xml

@@ -155,6 +155,7 @@
         lift l
         on
         mp.lift_id = l.id
+
         <include refid="liftInfoJoinSql"/>
         where
         mp.mt_company_id = #{mtCompanyId}

+ 1 - 1
lift-system-service/src/main/resources/mapper/TodoDataMapper.xml

@@ -83,7 +83,7 @@
 		LEFT JOIN lift l ON plr.lift_id = l.id
 		LEFT JOIN project p ON plr.mt_company_id = p.mt_company_id AND plr.project_id = p.id
 		LEFT JOIN maintenance_plan mp ON plr.mt_company_id = mp.mt_company_id AND plr.project_id = mp.project_id
-		AND mp.status = 0 AND mp.plan_date = (SELECT MIN(plan_date) FROM maintenance_plan WHERE status = 0
+		AND mp.status = -1 AND mp.plan_date = (SELECT MIN(plan_date) FROM maintenance_plan WHERE status = -1
 		AND mt_company_id = #{mtCompanyId,jdbcType=VARCHAR} AND lift_id = plr.lift_id) AND plr.lift_id = mp.lift_id
 		LEFT JOIN user_info ui ON plr.worker_id = ui.user_id
 		LEFT JOIN region r ON p.region_id = r.id