Ver Fonte

Merge branch 'develop' of http://132.232.206.88:3000/lift-manager/lift-server into huangyuan-user

黄远 há 5 anos atrás
pai
commit
0bde73620c

+ 2 - 2
lift-business-service/src/main/java/cn/com/ty/lift/business/contract/service/PaymentService.java

@@ -43,7 +43,7 @@ public class PaymentService extends ServiceImpl<PaymentMapper, Payment> {
      * @date 2020/2/20 3:10 下午
      */
     public IPage<PaymentListResponse> maintenanceList(PaymentRequest request) {
-        request.addDesc("work_date");
+        request.addDesc("c.end_date");
         return baseMapper.findProjectByCondition(request.getPage(), request);
     }
 
@@ -54,7 +54,7 @@ public class PaymentService extends ServiceImpl<PaymentMapper, Payment> {
      * @date 2020/4/27 11:15 上午
      */
     public IPage<PaymentListResponse> capitalList(PaymentRequest request) {
-        request.addDesc("work_date");
+        request.addDesc("c.end_date");
         return baseMapper.findCapitalByCondition(request.getPage(), request);
     }
 

+ 2 - 1
lift-business-service/src/main/java/cn/com/ty/lift/business/emergency/controller/EmergencyRepairController.java

@@ -114,7 +114,8 @@ public class EmergencyRepairController {
             //急修图片
             result.setErRecordImgs(erRecordImgService.listByErRecordId(id));
             //评价
-            result.setEvaluation(evaluationService.findByRecord(id, ValuePool.EVALUATE_SOURCE_EMERGENCY));
+            Evaluation byRecord = evaluationService.findByRecord(id, ValuePool.EVALUATE_SOURCE_EMERGENCY);
+            if (Objects.nonNull(byRecord)) result.setEvaluation(byRecord);
             //故障信息
             fillFault(result);
         }

+ 16 - 2
lift-business-service/src/main/java/cn/com/ty/lift/business/library/service/LiftService.java

@@ -271,8 +271,6 @@ public class LiftService extends ServiceImpl<LiftMapper, Lift> {
         //公司id
         Long mtCompanyId = request.getMtCompanyId();
         Lift lift = request.getLift();
-        if (maintenanceService.judge(mtCompanyId))
-            return RestResponse.fail(ApiConstants.RESULT_ERROR, MessageUtils.get("msg.limit.num"));
         RestResponse response = preJudgment(mtCompanyId, lift.getRegistrationCode());
         if (ApiConstants.RESULT_ERROR.equals(response.getStatusCode())) return response;
         //新增标记 (0:新增,1:查询后带入)
@@ -297,10 +295,26 @@ public class LiftService extends ServiceImpl<LiftMapper, Lift> {
         switch (source) {
             //电梯管理入口
             case "0":
+                if (maintenanceService.judge(mtCompanyId))
+                    return RestResponse.fail(MessageUtils.get("msg.limit.num"));
                 saveCompanyLiftInfo(id, mtCompanyId);
                 break;
             //项目管理入口
             case "1":
+                Long projectId = request.getProjectId();
+                Optional<Project> optional = projectService.getOne(projectId);
+                int num = 0;
+                if (optional.isPresent()) {
+                    Project project = optional.get();
+                    num = project.getNum();
+                }
+                //获取该公司企业电梯关联表的实际电梯台量
+                int currentNum = platformService.countLiftNum(mtCompanyId);
+                if (currentNum >= num) {
+                    return RestResponse.fail(MessageUtils.get("msg.project.limit.num"));
+                }
+                if (maintenanceService.judge(mtCompanyId))
+                    return RestResponse.fail(MessageUtils.get("msg.limit.num"));
                 //新增企业电梯关联表
                 PlatformCompanyLiftRelevance companyLiftEntry = platformService.save(id, mtCompanyId);
                 if (ObjectUtil.isEmpty(companyLiftEntry)) {

+ 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;
+    }
 }

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

@@ -40,11 +40,11 @@ public class ProjectResponse {
     /**
      * 台量
      */
-    private Integer num;
+    private int num;
     /**
      * 系统台量(实际台量)
      */
-    private Integer actualNum;
+    private int actualNum;
     /**
      * 项目地址
      */

+ 1 - 0
lift-business-service/src/main/resources/locale/response.properties

@@ -12,6 +12,7 @@ msg.modify.batch.success=\u6279\u91CF\u4FEE\u6539\u6210\u529F
 msg.modify.batch.fail=\u6279\u91CF\u4FEE\u6539\u5931\u8D25
 msg.delete.batch.fail=\u6279\u91CF\u5220\u9664\u5931\u8D25
 msg.limit.num=\u5F53\u524D\u7535\u68AF\u53F0\u91CF\u5927\u4E8E\u4F01\u4E1A\u8BBE\u7F6E\u7535\u68AF\u53F0\u91CF
+msg.project.limit.num=\u5F53\u524D\u7535\u68AF\u53F0\u91CF\u5927\u4E8E\u9879\u76EE\u53F0\u91CF
 msg.param.empty=\u53C2\u6570\u4E0D\u80FD\u4E3A\u7A7A
 msg.lift.exist=\u516C\u53F8\u4E0B\u5DF2\u6709\u6B64\u7535\u68AF\uFF0C\u4E0D\u80FD\u91CD\u590D\u6DFB\u52A0
 msg.lift.company.exist=\u5176\u4ED6\u516C\u53F8\u5DF2\u6709\u6B64\u7535\u68AF\uFF0C\u8FD4\u56DE\u7535\u68AF\u4FE1\u606F

+ 6 - 14
lift-business-service/src/main/resources/mapper/contract/PaymentMapper.xml

@@ -39,19 +39,15 @@
 		       c.id                            AS contractId,
 		       c.code                          AS contractCode,
 			   p.project_name                  AS projectName,
-			   pa.code                         AS paymentCode,
 			   c.plan_money_total              AS planMoney,
 			   c.work_money_total              AS workMoney,
-		       pa.plan_date                    AS planDate,
-		       pa.work_date                    AS workDate,
 		       c.end_date                      AS endDate,
 		       ui.name                         AS cashierUser
 		FROM contracts c
-				 LEFT JOIN payment pa ON c.id = pa.contracts_id
 				 LEFT JOIN project p ON c.project_id = p.id
-		         LEFT JOIN user_info ui on pa.cashier_user = ui.user_id
+		         LEFT JOIN user_info ui on c.update_id = ui.user_id
 		WHERE c.mt_company_id = #{request.mtCompanyId,jdbcType=BIGINT}
-		AND pa.type in('1','2','3','4')
+		AND c.type in('1','2','3','4')
 		<if test="request.projectName!=null and request.projectName!=''">
 			AND p.project_name LIKE CONCAT('%',#{request.projectName,jdbcType=VARCHAR},'%')
 		</if>
@@ -64,19 +60,15 @@
 			c.id                            AS contractId,
 			c.code                          AS contractCode,
 			cr.project_name                 AS projectName,
-			pa.code                         AS paymentCode,
-			pa.plan_money                   AS planMoney,
-			pa.work_money                   AS workMoney,
-			pa.plan_date                    AS planDate,
-			pa.work_date                    AS workDate,
+			c.plan_money_total              AS planMoney,
+			c.work_money_total              AS workMoney,
 			c.end_date                      AS endDate,
 			ui.name                         AS cashierUser
 		FROM contracts c
-			LEFT JOIN payment pa ON c.id = pa.contracts_id
 			LEFT JOIN capital_repair cr ON c.project_id = cr.id
-		    LEFT JOIN user_info ui on pa.cashier_user = ui.user_id
+		    LEFT JOIN user_info ui on c.update_id = ui.user_id
 		WHERE c.mt_company_id = #{request.mtCompanyId,jdbcType=BIGINT}
-		AND pa.type = '5'
+		AND c.type = '5'
 		<if test="request.projectName!=null and request.projectName!=''">
 			AND cr.project_name LIKE CONCAT('%',#{request.projectName,jdbcType=VARCHAR},'%')
 		</if>

+ 4 - 0
lift-business-service/src/main/resources/mapper/project/ProjectMapper.xml

@@ -73,7 +73,11 @@
 		LEFT JOIN contracts c ON p.id = c.project_id
 		LEFT JOIN (SELECT count(1) AS actualNum, project_id
 					FROM project_lift_relevance plr
+					LEFT JOIN platform_company_lift_relevance pclr
+					ON plr.lift_id = pclr.lift_id AND pclr.mt_company_id = plr.mt_company_id
 					WHERE plr.mt_company_id = #{request.mtCompanyId,jdbcType=BIGINT}
+					AND pclr.lift_company_status != '1'
+					AND pclr.delete_flag = '0'
 					GROUP BY project_id) plr ON plr.project_id = p.id
         WHERE p.mt_company_id = #{request.mtCompanyId,jdbcType=BIGINT}
 		<if test="request.provinceCode!=null and request.provinceCode!=''">

+ 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";
     }
 }