Selaa lähdekoodia

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

wang-hai-cheng 5 vuotta sitten
vanhempi
commit
508802d5f9

+ 1 - 1
lift-business-service/src/main/java/cn/com/ty/lift/business/annualinspection/controller/AnnualInspectionController.java

@@ -152,7 +152,7 @@ public class AnnualInspectionController {
     @Validation(fields = {"mtCompanyId"})
     public RestResponse toConfirm(@Val @RequestBody InspectionRequest request){
         request.addAsc("annual_inspection_date");
-        IPage<LiftAnnualInspectionResponse> pages = liftService.toConfirmAnnualInspection(request.getPage(), request.getMtCompanyId(), request.getUserId(), request.getCurrentRoleCode(), 45);
+        IPage<LiftAnnualInspectionResponse> pages = liftService.toConfirmAnnualInspection(request.getPage(), request);
         return RestResponse.success(pages);
     }
 

+ 2 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/annualinspection/service/AnnualInspectionService.java

@@ -66,6 +66,8 @@ public class AnnualInspectionService extends ServiceImpl<AnnualInspectionMapper,
 
     public InspectionCount count(InspectionRequest request) {
         InspectionCount inspectionCount = baseMapper.countInspectionByUserId(request);
+        if (Objects.isNull(inspectionCount))
+            inspectionCount = new InspectionCount();
         int toConfirm = baseMapper.countInspectionConfirmByUserId(request);
         inspectionCount.setToConfirm(toConfirm);
         return inspectionCount;

+ 21 - 6
lift-business-service/src/main/java/cn/com/ty/lift/business/framework/job/BusinessJob.java

@@ -10,6 +10,7 @@ import cn.com.ty.lift.business.push.entity.InspectionTips;
 import cn.com.ty.lift.business.push.entity.RepairTips;
 import cn.com.ty.lift.business.push.entity.TaskTips;
 import cn.com.ty.lift.business.push.service.PushUserService;
+import cn.com.ty.lift.common.constants.CommonEnum;
 import cn.com.ty.lift.common.constants.WebSocketConstants;
 import cn.com.ty.lift.common.model.PushMessage;
 import cn.com.ty.lift.common.model.PushUserInfo;
@@ -90,19 +91,33 @@ public class BusinessJob {
 
 
     /**
-     * 批量更新项目状态
+     * 批量更新项目状态为逾期,并发送提醒消息
      */
     @Scheduled(cron = "0 0 0 * * ?")
-    public void sendMessageModifyStatus() {
-        log.info("开始执行批量更新项目状态");
-        List<Project> projects = projectService.queryProjectList();
-        projectService.updateBatch(projects);
-        log.info("批量更新项目状态执行成功");
+    public void updateProjectOverdueJob() {
+        log.info("开始执行批量更新项目状态为逾期批处理");
+        List<Project> projects = projectService.queryInServiceProjectList();
+        projectService.updateBatch(projects, CommonEnum.ProjectStatus.OVERDUE.getCode());
+        log.info("批量更新项目状态为逾期批处理执行成功");
         for (Project entry : projects) {
             projectService.sendOverdueMessage(entry.getId(), entry.getMtCompanyId());
         }
     }
 
+    /**
+     * 批量更新项目状态为服务中,并发送提醒消息
+     */
+    @Scheduled(cron = "0 0 1 * * ?")
+    public void updateProjectInServiceJob() {
+        log.info("开始执行批量更新项目状态为服务中批处理");
+        List<Project> projects = projectService.queryNotStartProjectList();
+        projectService.updateBatch(projects, CommonEnum.ProjectStatus.IN_SERVICE.getCode());
+        log.info("批量更新项目状态为服务中批处理执行成功");
+        for (Project entry : projects) {
+            projectService.sendMessage(entry.getId(), entry.getMtCompanyId(), entry.getProjectStatus());
+        }
+    }
+
     /**
      * 年检到期提前45天提醒
      */

+ 2 - 1
lift-business-service/src/main/java/cn/com/ty/lift/business/library/dao/mapper/LiftMapper.java

@@ -1,5 +1,6 @@
 package cn.com.ty.lift.business.library.dao.mapper;
 
+import cn.com.ty.lift.business.annualinspection.dto.InspectionRequest;
 import cn.com.ty.lift.business.library.dao.entity.Lift;
 import cn.com.ty.lift.business.library.dao.entity.model.LiftProjectModel;
 import cn.com.ty.lift.business.library.dao.entity.model.request.LiftRequest;
@@ -43,7 +44,7 @@ public interface LiftMapper extends BaseMapper<Lift> {
     /**
      * 查询待确认的年检信息
      */
-    IPage<LiftAnnualInspectionResponse> toConfirmAnnualInspection(IPage<LiftAnnualInspectionResponse> page, @Param("mtCompanyId") Long mtCompanyId, @Param("userId") Long userId, @Param("days") int days);
+    IPage<LiftAnnualInspectionResponse> toConfirmAnnualInspection(IPage<LiftAnnualInspectionResponse> page, @Param("request") InspectionRequest request);
 
     List<Lift> groupByRegistrationCode();
 

+ 5 - 4
lift-business-service/src/main/java/cn/com/ty/lift/business/library/service/LiftService.java

@@ -1,5 +1,6 @@
 package cn.com.ty.lift.business.library.service;
 
+import cn.com.ty.lift.business.annualinspection.dto.InspectionRequest;
 import cn.com.ty.lift.business.capital.dao.mapper.CommonMapper;
 import cn.com.ty.lift.business.capital.service.CapitalRepairLiftRelevanceService;
 import cn.com.ty.lift.business.framework.util.MessageUtils;
@@ -656,11 +657,11 @@ public class LiftService extends ServiceImpl<LiftMapper, Lift> {
      *
      * @return
      */
-    public IPage<LiftAnnualInspectionResponse> toConfirmAnnualInspection(IPage<LiftAnnualInspectionResponse> page, Long mtCompanyId, Long userId, String currentRoleCode, int days) {
-        if (Objects.equals(currentRoleCode, CommonEnum.DefaultRole.HIGH_DIRECTOR.getCode())) {
-            userId = 0L;
+    public IPage<LiftAnnualInspectionResponse> toConfirmAnnualInspection(IPage<LiftAnnualInspectionResponse> page, InspectionRequest request) {
+        if (Objects.equals(request.getCurrentRoleCode(), CommonEnum.DefaultRole.HIGH_DIRECTOR.getCode())) {
+            request.setUserId(0L);
         }
-        return baseMapper.toConfirmAnnualInspection(page, mtCompanyId, userId, days);
+        return baseMapper.toConfirmAnnualInspection(page, request);
     }
 
     /**

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

@@ -96,5 +96,5 @@ public class MtRecordRequest extends PageRequest {
      */
     private String liftCodeQuery;
 
-    private Long userId;
+    private Long areaDirectorId;
 }

+ 22 - 5
lift-business-service/src/main/java/cn/com/ty/lift/business/project/service/ProjectService.java

@@ -111,23 +111,35 @@ public class ProjectService extends ServiceImpl<ProjectMapper, Project> {
 
     /**
      * @return 项目列表
-     * @description 查询项目列表
+     * @description 查询服务中项目列表
      * @date 2020/2/9 4:02 下午
      */
-    public List<Project> queryProjectList() {
+    public List<Project> queryInServiceProjectList() {
         LambdaQueryWrapper<Project> lambdaQueryWrapper = new QueryWrapper<Project>().lambda();
         lambdaQueryWrapper.lt(Project::getEndDate, LocalDate.now());
         lambdaQueryWrapper.eq(Project::getProjectStatus, ProjectStatus.IN_SERVICE.getCode());
         return list(lambdaQueryWrapper);
     }
 
+    /**
+     * @return 项目列表
+     * @description 查询尚未开始项目列表
+     * @date 2020/6/3 22:32 下午
+     */
+    public List<Project> queryNotStartProjectList() {
+        LambdaQueryWrapper<Project> lambdaQueryWrapper = new QueryWrapper<Project>().lambda();
+        lambdaQueryWrapper.eq(Project::getStartDate, LocalDate.now());
+        lambdaQueryWrapper.eq(Project::getProjectStatus, ProjectStatus.NOT_START.getCode());
+        return list(lambdaQueryWrapper);
+    }
+
     /**
      * @param list 项目列表
      * @description 更新项目状态
      * @date 2020/2/10 4:16 下午
      */
-    public void updateBatch(List<Project> list) {
-        list.forEach(project -> project.setProjectStatus(CommonEnum.ProjectStatus.OVERDUE.getCode()));
+    public void updateBatch(List<Project> list, String projectStatus) {
+        list.forEach(project -> project.setProjectStatus(projectStatus));
         updateBatchById(list, list.size());
         log.info("批量更新项目状态" + list.size() + "条");
     }
@@ -313,7 +325,12 @@ public class ProjectService extends ServiceImpl<ProjectMapper, Project> {
         //按当前日期时间戳自动生成项目编号
         String projectCode = DateUtils.generateCode();
         project.setProjectCode("XM" + projectCode);
-        project.setProjectStatus(project.getStartDate().isAfter(LocalDate.now()) ? "1" : "2");
+        LocalDate now = LocalDate.now();
+        LocalDate startDate = project.getStartDate();
+        LocalDate endDate = project.getEndDate();
+        if (startDate.isEqual(now) || startDate.isBefore(now) && endDate.isAfter(now)) {
+            project.setProjectStatus("2");
+        }
         return save(project);
     }
 

+ 2 - 3
lift-business-service/src/main/resources/mapper/annualinspection/AnnualInspectionMapper.xml

@@ -278,14 +278,13 @@
             parameterType="cn.com.ty.lift.business.annualinspection.dto.InspectionRequest">
         SELECT count(1) toConfirm
         FROM lift li
-        LEFT JOIN platform_company_lift_relevance pclr ON li.id = pclr.lift_id AND pclr.lift_company_status!=1
         LEFT JOIN project_lift_relevance plr ON li.id = plr.lift_id AND plr.delete_flag = '0'
+        LEFT JOIN project_user pu ON pu.project_id = plr.project_id
         LEFT JOIN annual_inspection ai ON ai.lift_id = li.id AND ai.plan_date = li.annual_inspection_date
         AND ai.mt_company_id = plr.mt_company_id
-        LEFT JOIN project_user pu ON pu.project_id = plr.project_id AND pu.mt_company_id = ai.mt_company_id
         WHERE <![CDATA[li.annual_inspection_date <= date_add(curdate(), INTERVAL 45 DAY)]]>
         AND <![CDATA[li.annual_inspection_date >= curdate() AND isnull(ai.id)]]>
-        AND pclr.mt_company_id = #{request.mtCompanyId}
+        AND plr.mt_company_id = #{request.mtCompanyId}
         <choose>
             <when test="request.currentRoleCode == 'REGION_DIRECTOR' or request.currentRoleCode == 'CLERK' ">
                 AND pu.user_id = #{request.userId,jdbcType=BIGINT}

+ 3 - 4
lift-business-service/src/main/resources/mapper/emergency/EmergencyRepairMapper.xml

@@ -346,11 +346,10 @@
                 SELECT count(1) total,
                 status
         FROM emergency_repair e
-             LEFT JOIN platform_company_lift_relevance pc
-        ON e.lift_id = pc.lift_id AND pc.lift_company_status !=1 AND e.mt_company_id = pc.mt_company_id
+        LEFT JOIN project pr ON e.project_id = pr.id AND pr.mt_company_id = e.mt_company_id
         <if test="request.currentRoleCode == 'REGION_DIRECTOR' or request.currentRoleCode == 'CLERK' ">
-            LEFT JOIN project_lift_relevance pl ON pl.mt_company_id = pc.mt_company_id AND pl.lift_id = e.lift_id
-            LEFT JOIN project_user pu ON pl.project_id = pu.project_id AND pu.mt_company_id = pl.mt_company_id
+            LEFT JOIN project_user pu ON pr.id = pu.project_id AND pu.mt_company_id = pr.mt_company_id
+            LEFT JOIN project_lift_relevance plr ON plr.mt_company_id = pu.mt_company_id AND plr.lift_id = e.lift_id
         </if>
         WHERE e.mt_company_id = #{request.mtCompanyId}
         AND e.status != -1 and e.`status` != 3

+ 17 - 8
lift-business-service/src/main/resources/mapper/lift/LiftMapper.xml

@@ -229,7 +229,8 @@
     </select>
 
     <!--lift中的年检时间都是月初, 所以相隔时间(45)-->
-    <select id="toConfirmAnnualInspection" parameterType="java.lang.Long" resultType="cn.com.ty.lift.business.library.dao.entity.model.response.LiftAnnualInspectionResponse">
+    <select id="toConfirmAnnualInspection" parameterType="cn.com.ty.lift.business.annualinspection.dto.InspectionRequest"
+            resultType="cn.com.ty.lift.business.library.dao.entity.model.response.LiftAnnualInspectionResponse">
         SELECT DISTINCT
             li.id                     AS lift_id,
             li.registration_code,
@@ -248,16 +249,24 @@
         LEFT JOIN project pr ON plr.project_id = pr.id
         LEFT JOIN region re ON re.id = pr.region_id
         LEFT JOIN user_info ui ON re.user_id = ui.user_id
-        LEFT JOIN annual_inspection ai ON ai.lift_id = li.id AND ai.mt_company_id = plr.mt_company_id AND ai.plan_date = li.annual_inspection_date
-        AND pu.mt_company_id = ai.mt_company_id
+        LEFT JOIN annual_inspection ai ON ai.lift_id = li.id AND ai.mt_company_id = plr.mt_company_id
+                 AND ai.plan_date = li.annual_inspection_date AND pu.mt_company_id = ai.mt_company_id
         WHERE
-            li.annual_inspection_date &lt;= date_add(curdate(), INTERVAL #{days} DAY)
+            li.annual_inspection_date &lt;= date_add(curdate(), INTERVAL 45 DAY)
         AND li.annual_inspection_date &gt;= curdate() AND isnull(ai.id)
-        <if test="mtCompanyId != null and mtCompanyId > 0">
-            AND plr.mt_company_id = #{mtCompanyId}
+        <if test="request.mtCompanyId != null and request.mtCompanyId > 0">
+            AND plr.mt_company_id = #{request.mtCompanyId}
         </if>
-        <if test="userId != null and userId > 0">
-            AND pu.user_id = #{userId}
+        <if test="request.userId != null and request.userId > 0">
+            <choose>
+                <when test="request.currentRoleCode == 'REGION_DIRECTOR' or request.currentRoleCode == 'CLERK' ">
+                    AND pu.user_id = #{request.userId,jdbcType=BIGINT}
+                </when>
+                <when test="request.currentRoleCode == 'ROLEMTWORK' ">
+                    AND plr.worker_id = #{request.userId,jdbcType=BIGINT}
+                </when>
+                <otherwise/>
+            </choose>
         </if>
     </select>
     <select id="groupByRegistrationCode" resultType="cn.com.ty.lift.business.library.dao.entity.Lift">

+ 2 - 2
lift-business-service/src/main/resources/mapper/maintenance/MaintenanceRecordMapper.xml

@@ -240,8 +240,8 @@
             <if test="cond.projectId != null and cond.projectId > 0">
                 AND pr.id = #{cond.projectId}
             </if>
-            <if test="cond.userId != null and cond.userId > 0">
-                AND r.user_id = #{cond.userId}
+            <if test="cond.areaDirectorId != null and cond.areaDirectorId > 0">
+                AND r.user_id = #{cond.areaDirectorId}
             </if>
             <if test="cond.workerId != null and cond.workerId > 0">
                 AND mr.worker_id1 = #{cond.workerId}