Browse Source

维修优化

chenyuehu 3 năm trước cách đây
mục cha
commit
ea6003a6d6
17 tập tin đã thay đổi với 307 bổ sung33 xóa
  1. 2 0
      platform-common/src/main/java/com/platform/common/model/UserInfo.java
  2. 5 0
      platform-dao/src/main/java/com/platform/dao/dto/repair/RepairApplicationFormDTO.java
  3. 2 0
      platform-dao/src/main/java/com/platform/dao/dto/upms/SysUserDTO.java
  4. 2 0
      platform-dao/src/main/java/com/platform/dao/dto/upms/UserInfoDTO.java
  5. 4 0
      platform-dao/src/main/java/com/platform/dao/entity/upms/SysUser.java
  6. 5 0
      platform-dao/src/main/java/com/platform/dao/enums/SysUserIdentityType.java
  7. 4 0
      platform-dao/src/main/java/com/platform/dao/enums/WorkplaceBacklogTypeEnum.java
  8. 8 0
      platform-dao/src/main/java/com/platform/dao/util/MessageTemplateUtil.java
  9. 2 0
      platform-dao/src/main/java/com/platform/dao/vo/SysUserVO.java
  10. 6 1
      platform-dao/src/main/resources/mapper/repair/RepairApplicationFormMapper.xml
  11. 24 0
      platform-rest/src/main/java/com/platform/rest/controller/upms/SysUserController.java
  12. 34 0
      platform-rest/src/main/java/com/platform/rest/task/RepairTask.java
  13. 1 0
      platform-rest/src/main/resources/application-dev.yml
  14. 10 0
      platform-service/src/main/java/com/platform/service/repair/RepairApplicationFormService.java
  15. 152 32
      platform-service/src/main/java/com/platform/service/repair/impl/RepairApplicationFormServiceImpl.java
  16. 16 0
      platform-service/src/main/java/com/platform/service/upms/SysUserService.java
  17. 30 0
      platform-service/src/main/java/com/platform/service/upms/impl/SysUserServiceImpl.java

+ 2 - 0
platform-common/src/main/java/com/platform/common/model/UserInfo.java

@@ -168,4 +168,6 @@ public class UserInfo implements Serializable {
      * 审批延迟周期
      */
     private BigDecimal auditDelayPeriod;
+
+    private Boolean workFlag;
 }

+ 5 - 0
platform-dao/src/main/java/com/platform/dao/dto/repair/RepairApplicationFormDTO.java

@@ -119,6 +119,11 @@ public class RepairApplicationFormDTO extends BaseDTO implements Serializable {
      */
     private String repairUserId;
 
+    /**
+     * 包含 未分配的
+     */
+    private Boolean repairUserIdOrNoAssignFlag;
+
     /**
      * 维修描述
      */

+ 2 - 0
platform-dao/src/main/java/com/platform/dao/dto/upms/SysUserDTO.java

@@ -230,4 +230,6 @@ public class SysUserDTO extends BaseDTO implements Serializable {
      * 审批延迟周期
      */
     private BigDecimal auditDelayPeriod;
+
+    private Boolean workFlag;
 }

+ 2 - 0
platform-dao/src/main/java/com/platform/dao/dto/upms/UserInfoDTO.java

@@ -218,4 +218,6 @@ public class UserInfoDTO implements Serializable {
      */
     private BigDecimal auditDelayPeriod;
 
+    private Boolean workFlag;
+
 }

+ 4 - 0
platform-dao/src/main/java/com/platform/dao/entity/upms/SysUser.java

@@ -2,6 +2,7 @@ package com.platform.dao.entity.upms;
 
 import com.platform.common.bean.DataScope;
 import lombok.Data;
+import lombok.experimental.Accessors;
 
 import javax.persistence.Id;
 import javax.persistence.Table;
@@ -18,6 +19,7 @@ import java.time.LocalDateTime;
  */
 @Data
 @Table(name = "t_sys_user")
+@Accessors(chain = true)
 public class SysUser implements Serializable {
 
     private static final long serialVersionUID = 1L;
@@ -199,6 +201,8 @@ public class SysUser implements Serializable {
      */
     private BigDecimal auditDelayPeriod;
 
+    private Boolean workFlag;
+
     /**
      * 数据权限
      */

+ 5 - 0
platform-dao/src/main/java/com/platform/dao/enums/SysUserIdentityType.java

@@ -40,6 +40,11 @@ public enum SysUserIdentityType {
     JT_SB_ZG(40, "集团/区域总设备主管"),
     JT_SB_FG_LD(41, "集团/区域总分管领导"),
 
+    WXJL(50, "维修经理"),
+    SCJL(51, "生产经理"),
+    YYJL(52, "运营经理"),
+    ZJL(53, "总经理"),
+
 
     ;
     private final Integer value;

+ 4 - 0
platform-dao/src/main/java/com/platform/dao/enums/WorkplaceBacklogTypeEnum.java

@@ -29,6 +29,10 @@ public enum WorkplaceBacklogTypeEnum {
      * 接收维修单提醒
      */
     RECEIVE(21),
+    /**
+     * 维修未完成提醒
+     */
+    REPAIR_NOT_FINISH(22),
 
     /**
      * 任务提醒

+ 8 - 0
platform-dao/src/main/java/com/platform/dao/util/MessageTemplateUtil.java

@@ -60,6 +60,14 @@ public class MessageTemplateUtil {
         return String.format("您有新的报修【%s】待处理,请处理", id);
     }
 
+    public static String getRepairApplicationForReceive(String id) {
+        return String.format("有新的报修【%s】待认领", id);
+    }
+
+    public static String getRepairApplicationForNotFinishNotic(String id, int hour) {
+        return String.format("报修【%s】已超过%d小时未完成", id);
+    }
+
     public static String getRepairCheck(String id) {
         return String.format("报修【%s】已完成,请验收", id);
     }

+ 2 - 0
platform-dao/src/main/java/com/platform/dao/vo/SysUserVO.java

@@ -178,4 +178,6 @@ public class SysUserVO implements Serializable {
      * 审批延迟周期
      */
     private BigDecimal auditDelayPeriod;
+
+    private Boolean workFlag;
 }

+ 6 - 1
platform-dao/src/main/resources/mapper/repair/RepairApplicationFormMapper.xml

@@ -34,7 +34,12 @@
                 and application.user_id = #{userId}
             </if>
             <if test="repairUserId != null and repairUserId != ''">
-                and application.repair_user_id = #{repairUserId}
+                <if test="repairUserIdOrNoAssignFlag != null and repairUserIdOrNoAssignFlag == true">
+                    and (application.repair_user_id = #{repairUserId} or application.repair_user_id is null)
+                </if>
+                <if test="repairUserIdOrNoAssignFlag == null || repairUserIdOrNoAssignFlag == false">
+                    and application.repair_user_id = #{repairUserId}
+                </if>
             </if>
             <if test="checkUserId != null and checkUserId != ''">
                 and application.check_user_id = #{checkUserId}

+ 24 - 0
platform-rest/src/main/java/com/platform/rest/controller/upms/SysUserController.java

@@ -143,6 +143,30 @@ public class SysUserController {
         return new R<>(sysUserService.selectUserVO(userId));
     }
 
+    /**
+     * 扫描用户
+     *
+     * @param userId :
+     * @return R
+     */
+    @GetMapping("/work/{userId}")
+    @SysLog("扫描用户")
+    public R<SysUserVO> work(@PathVariable("userId") String userId) {
+        return new R<>(sysUserService.selectUserVO(userId));
+    }
+
+    /**
+     * 修改用户工作状态
+     *
+     * @return R
+     */
+    @PutMapping("/work/{userId}/{workFlag}")
+    @SysLog("修改用户工作状态")
+    public R updateWork(@PathVariable("userId") String userId, @PathVariable("workFlag") Integer workFlag, @RequestBody SysUserDTO sysUserDTO) {
+        sysUserService.updateUserWorkStatus(userId, workFlag, sysUserDTO);
+        return new R<>();
+    }
+
     /**
      * 新增记录
      *

+ 34 - 0
platform-rest/src/main/java/com/platform/rest/task/RepairTask.java

@@ -0,0 +1,34 @@
+package com.platform.rest.task;
+
+import com.platform.service.repair.RepairApplicationFormService;
+import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+/**
+ * @Description 维修任务处理
+ * @Author liuyu
+ * @Date 2020-05-09 16:40:01
+ * @Version Copyright (c) 2019,北京乾元坤和科技有限公司 All rights reserved.
+ */
+@Slf4j
+@Component("repairTask")
+@AllArgsConstructor
+public class RepairTask {
+    private final RepairApplicationFormService repairService;
+
+    /**
+     * 维修任务 10分钟未认领 分配给维修主管
+     */
+    public void updateEnquiryAuditForTimer() {
+        repairService.autoAssignTaskForTimer();
+    }
+
+    /**
+     * 维修任务 超时通知
+     */
+    public void unFinishNoticeForTimer() {
+        repairService.unFinishNoticeForTimer();
+    }
+
+}

+ 1 - 0
platform-rest/src/main/resources/application-dev.yml

@@ -57,6 +57,7 @@ ignore:
     - /upms/logs/**
     - /operate/**
     - /users/**
+    - /users/work/**
     - /druid/**
     - app-versions/**
     - /files/**

+ 10 - 0
platform-service/src/main/java/com/platform/service/repair/RepairApplicationFormService.java

@@ -90,4 +90,14 @@ public interface RepairApplicationFormService extends IBaseService<RepairApplica
      */
     int countUserTask(String userId);
 
+    /**
+     * 自动分配任务
+     */
+    void autoAssignTaskForTimer();
+
+    /**
+     * 未完成维修提醒
+     */
+    void unFinishNoticeForTimer();
+
 }

+ 152 - 32
platform-service/src/main/java/com/platform/service/repair/impl/RepairApplicationFormServiceImpl.java

@@ -14,16 +14,19 @@ import com.platform.dao.dto.repair.RepairApplicationFormDTO;
 import com.platform.dao.dto.repair.RepairCheckDTO;
 import com.platform.dao.dto.repair.RepairFormDTO;
 import com.platform.dao.dto.sb.SbInfoDTO;
+import com.platform.dao.dto.upms.SysUserDTO;
 import com.platform.dao.entity.repair.RepairApplicationForm;
 import com.platform.dao.entity.repair.RepairCheck;
 import com.platform.dao.entity.repair.RepairForm;
 import com.platform.dao.entity.sb.SbInfo;
 import com.platform.dao.entity.upms.SysFile;
+import com.platform.dao.entity.upms.SysUser;
 import com.platform.dao.enums.*;
 import com.platform.dao.mapper.repair.RepairApplicationFormMapper;
 import com.platform.dao.mapper.repair.RepairCheckMapper;
 import com.platform.dao.mapper.repair.RepairFormMapper;
 import com.platform.dao.mapper.upms.SysFileMapper;
+import com.platform.dao.mapper.upms.SysUserMapper;
 import com.platform.dao.util.MessageTemplateUtil;
 import com.platform.dao.util.UserUtil;
 import com.platform.dao.vo.SysUserVO;
@@ -47,8 +50,13 @@ import tk.mybatis.mapper.weekend.Weekend;
 import tk.mybatis.mapper.weekend.WeekendCriteria;
 
 import javax.annotation.Resource;
+import java.lang.reflect.Array;
 import java.time.LocalDateTime;
+import java.time.temporal.ChronoUnit;
+import java.util.Arrays;
+import java.util.Calendar;
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * @Description 保修单 service 实现类
@@ -67,6 +75,9 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
     private final SysUserDeptService sysUserDeptService;
     private final SbInfoService sbInfoService;
     private final SysFileMapper sysFileMapper;
+    private final SysUserMapper userMapper;
+
+
     @Override
     public int batchDelete(List<String> ids) {
         // 判断是否允许删除
@@ -138,7 +149,7 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
             if (item.getType().equals(SysFileTypeEnum.REPAIR_APPLICATION_IMGS.getValue())) {
                 applicationFileList.add(item);
             }
-            if (item.getType() .equals(SysFileTypeEnum.REPAIR_REPAIR_IMGS.getValue())) {
+            if (item.getType().equals(SysFileTypeEnum.REPAIR_REPAIR_IMGS.getValue())) {
                 repairFileList.add(item);
             }
             if (item.getType().equals(SysFileTypeEnum.REPAIR_CHECK_IMGS.getValue())) {
@@ -172,7 +183,7 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
         // 保存报修单
         model.setModelId(sb.getModelId());
         model.setNo(IdGeneratorUtils.getRepairApplicaitonFormNo(++count));
-        model.setStatus(RepairApplicationFormStatusEnum.ALLOCATED.getValue());
+        model.setStatus(RepairApplicationFormStatusEnum.NOT_ALLOCATED.getValue());
         model.setApplyTime(LocalDateTime.now());
         model.setCreatedTime(model.getApplyTime());
         model.setUpdateTime(model.getApplyTime());
@@ -190,20 +201,26 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
         if (sb.getUseGroup() == null) {
             throw new BusinessException("找不到设备对应的使用工作组,无法指派维修单,请先设置设备的归属组,sbId" + model.getSbId());
         }
-        List<SysUserVO> userList = sysUserService.selectDeptManager(sb.getUseGroup(), SysDeptManagerType.REPAIR.getValue());
-        if (userList == null || userList.size() == 0) {
-            throw new BusinessException("找不到设备对应的维修员,无法指派维修单,请先设置设备的归属组,sbId" + model.getSbId());
-        }
-        model.setRepairUserId(userList.get(0).getUserId());
-
+//        List<SysUserVO> userList = sysUserService.selectDeptManager(sb.getUseGroup(), SysDeptManagerType.REPAIR.getValue());
+//        if (userList == null || userList.size() == 0) {
+//            throw new BusinessException("找不到设备对应的维修员,无法指派维修单,请先设置设备的归属组,sbId" + model.getSbId());
+//        }
+//        model.setRepairUserId(userList.get(0).getUserId());
 
 
         model.setId(IdGeneratorUtils.getObjectId());
         this.saveFile(model);
         RepairApplicationForm form = super.saveModelHaveCreateInfo(model);
+
+        List<SysUser> users = sysUserService.getRepairUser(new SysUserDTO());
+        List<String> userIds = users.stream().filter(item -> item.getWorkFlag()).map(item -> item.getUserId()).collect(Collectors.toList());
+        if (CollectionUtil.isEmpty(userIds)) {
+            userIds = users.stream().filter(item -> item.getIdentityType().equals(SysUserIdentityType.WXZG.getValue())).map(item -> item.getUserId()).collect(Collectors.toList());
+        }
+        // 通过给当天值班维修人员
         SpringContextHolder.publishEvent(new WorkplaceBacklogEvent(WorkplaceBacklogTypeEnum.REPAIR.getValue(), WorkplaceBacklogDetailTypeEnum.REPAIR_APPLICATION.getValue(),
-                model.getId(), MessageTemplateUtil.getRepairApplication(model.getId()),
-                model.getId(), ListUtils.newArrayList(model.getRepairUserId())));
+                model.getId(), MessageTemplateUtil.getRepairApplicationForReceive(model.getId()),
+                model.getId(), userIds));
         return form;
     }
 
@@ -258,9 +275,12 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
     @Override
     public void receive(String id) {
         RepairApplicationForm applicationForm = mapper.selectById(id);
-        if (!RepairApplicationFormStatusEnum.ALLOCATED.getValue().equals(applicationForm.getStatus()) && !RepairApplicationFormStatusEnum.REBACK.getValue().equals(applicationForm.getStatus())) {
+        if (!RepairApplicationFormStatusEnum.NOT_ALLOCATED.getValue().equals(applicationForm.getStatus()) && !RepairApplicationFormStatusEnum.ALLOCATED.getValue().equals(applicationForm.getStatus()) && !RepairApplicationFormStatusEnum.REBACK.getValue().equals(applicationForm.getStatus())) {
             throw new BusinessException("该状态不允许接收任务");
         }
+        if (!RepairApplicationFormStatusEnum.NOT_ALLOCATED.getValue().equals(applicationForm.getStatus())) {
+            applicationForm.setRepairUserId(SecurityUtils.getUserInfo().getUserId());
+        }
         applicationForm.setStatus(RepairApplicationFormStatusEnum.PROCESSING.getValue());
         applicationForm.setRepairStartTime(LocalDateTime.now());
         applicationForm.setUpdateTime(LocalDateTime.now());
@@ -279,7 +299,7 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
     @Override
     public void dispatchModelByDTO(RepairApplicationFormDTO model) {
         RepairApplicationForm applicationForm = mapper.selectById(model.getId());
-        if (!RepairApplicationFormStatusEnum.ALLOCATED.getValue().equals(applicationForm.getStatus()) && !RepairApplicationFormStatusEnum.REBACK.getValue().equals(applicationForm.getStatus())) {
+        if (!RepairApplicationFormStatusEnum.NOT_ALLOCATED.getValue().equals(applicationForm.getStatus()) && !RepairApplicationFormStatusEnum.ALLOCATED.getValue().equals(applicationForm.getStatus()) && !RepairApplicationFormStatusEnum.REBACK.getValue().equals(applicationForm.getStatus())) {
             throw new BusinessException("该状态不允许派工任务, id, status:" + applicationForm.getId() + "," + applicationForm.getStatus());
         }
 
@@ -326,32 +346,47 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
         applicationForm.setStatus(RepairApplicationFormStatusEnum.NOT_ACCEPTANCE.getValue());
 
         applicationForm.setRepairEndTime(LocalDateTime.now());
-        applicationForm.setRepairMinutes(DateUtils.dateDiff(applicationForm.getRepairEndTime(),applicationForm.getRepairStartTime()));
+        applicationForm.setRepairMinutes(DateUtils.dateDiff(applicationForm.getRepairEndTime(), applicationForm.getRepairStartTime()));
         applicationForm.setCheckStartTime(applicationForm.getRepairEndTime());
         applicationForm.setRepairContent(dto.getRepairContent());
         applicationForm.setRepairErrorTypeId(dto.getRepairErrorTypeId());
         applicationForm.setUpdateTime(LocalDateTime.now());
 
-        // 获取部门的项目部
-        SysDeptVO natureDept = UserUtil.getUserNatureDept(DeptNatureEnum.XIANG_MU_BU, userInfo);
-        // 获取项目部设备主管
-        List<SysUserVO> users = UserUtil.selectUserByIdentityTypeLikeDeptCode(natureDept.getDeptCode(),
-                SysUserIdentityType.WXZG.getValue());
-        SysUserVO checkUser = null;
-        if (CollectionUtil.isNotEmpty(users)) {
-            checkUser = users.get(0);
-        }
-
-        if(checkUser == null){
-            throw new BusinessException("找不到该项目部的维修主管,项目部名称:"+natureDept.getName());
+//        // 获取部门的项目部
+//        SysDeptVO natureDept = UserUtil.getUserNatureDept(DeptNatureEnum.XIANG_MU_BU, userInfo);
+//        // 获取项目部设备主管
+//        List<SysUserVO> users = UserUtil.selectUserByIdentityTypeLikeDeptCode(natureDept.getDeptCode(),
+//                SysUserIdentityType.WXZG.getValue());
+//        SysUserVO checkUser = null;
+//        if (CollectionUtil.isNotEmpty(users)) {
+//            checkUser = users.get(0);
+//        }
+//
+//        if (checkUser == null) {
+//            throw new BusinessException("找不到该项目部的维修主管,项目部名称:" + natureDept.getName());
+//        }
+        String userId = applicationForm.getUserId();
+        applicationForm.setCheckUserId(userId);
+        // 维修人自己发起报修自己验收
+        if (userId.equals(applicationForm.getRepairUserId())) {
+            // 1.修改验收单状态和验收验收时间
+            applicationForm.setCheckEndTime(LocalDateTime.now());
+            applicationForm.setStatus(RepairApplicationFormStatusEnum.FINISHED.getValue());
+            applicationForm.setUpdateTime(LocalDateTime.now());
+            super.modModelByPrimaryKey(applicationForm);
+
+            // 如果选择了设备停机,则要修改设备状态
+            SbInfo info = new SbInfo();
+            info.setId(applicationForm.getSbId());
+            info.setStatus(SbInfoStatusEnum.IN_USE.getValue());
+            sbInfoService.modModelByPrimaryKey(info);
+        } else {
+            super.modModelByPrimaryKey(applicationForm);
+            // 发送通知给主管,主管是验收人,他收到通知,进行调拨给使用人员
+            SpringContextHolder.publishEvent(new WorkplaceBacklogEvent(WorkplaceBacklogTypeEnum.REPAIR.getValue(), WorkplaceBacklogDetailTypeEnum.REPAIR_FINISH.getValue(),
+                    applicationForm.getId(), MessageTemplateUtil.getRepairCheck(applicationForm.getId()),
+                    applicationForm.getId(), ListUtils.newArrayList(applicationForm.getCheckUserId())));
         }
-        applicationForm.setCheckUserId(checkUser.getUserId());
-        super.modModelByPrimaryKey(applicationForm);
-        // 发送通知给主管,主管是验收人,他收到通知,进行调拨给使用人员
-        SpringContextHolder.publishEvent(new WorkplaceBacklogEvent(WorkplaceBacklogTypeEnum.REPAIR.getValue(), WorkplaceBacklogDetailTypeEnum.REPAIR_FINISH.getValue(),
-                applicationForm.getId(), MessageTemplateUtil.getRepairCheck(applicationForm.getId()),
-                applicationForm.getId(), ListUtils.newArrayList(applicationForm.getCheckUserId())));
-
     }
 
     @Transactional(rollbackFor = Exception.class)
@@ -396,4 +431,89 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
         weekend.weekendCriteria().andEqualTo(RepairApplicationForm::getRepairUserId, userId);
         return mapper.selectCountByExample(weekend);
     }
+
+    @Override
+    public void autoAssignTaskForTimer() {
+        LocalDateTime minutesAgo = DateUtils.minus(LocalDateTime.now(), 10, ChronoUnit.MINUTES);
+        Weekend<RepairApplicationForm> weekend = new Weekend<>(RepairApplicationForm.class);
+        weekend.weekendCriteria().andEqualTo(RepairApplicationForm::getStatus, RepairApplicationFormStatusEnum.NOT_ALLOCATED.getValue())
+                .andLessThan(RepairApplicationForm::getCreatedTime, minutesAgo);
+        List<RepairApplicationForm> tasks = mapper.selectByExample(weekend);
+        List<SysUser> users = userMapper.select(new SysUser().setIdentityType(SysUserIdentityType.WXZG.getValue()));
+        if (CollectionUtil.isEmpty(users)) {
+            throw new BusinessException("维修主管不存在");
+        }
+        SysUser repairManager = users.get(0);
+        if (CollectionUtil.isNotEmpty(tasks)) {
+            tasks.forEach(item -> {
+                RepairApplicationForm update = new RepairApplicationForm();
+                update.setId(item.getId());
+                update.setRepairUserId(repairManager.getUserId());
+                update.setStatus(RepairApplicationFormStatusEnum.ALLOCATED.getValue());
+                mapper.updateByPrimaryKeySelective(update);
+                SpringContextHolder.publishEvent(new WorkplaceBacklogEvent(WorkplaceBacklogTypeEnum.REPAIR.getValue(), WorkplaceBacklogDetailTypeEnum.REPAIR_APPLICATION.getValue(),
+                        item.getId(), MessageTemplateUtil.getRepairApplicationForReceive(item.getId()),
+                        item.getId(), Arrays.asList(repairManager.getUserId())));
+            });
+        }
+    }
+
+    @Override
+    public void unFinishNoticeForTimer() {
+        // 3小时通知
+        List<RepairApplicationForm> tasks = getOverTimeTask(3);
+        List<SysUser> users = getUsersByIdentity(Arrays.asList(new Integer[]{SysUserIdentityType.WXJL.getValue(), SysUserIdentityType.SCJL.getValue()}));
+        sendOverTimeNotice(users, tasks);
+        // 8小时通知
+        tasks = getOverTimeTask(8);
+        users = getUsersByIdentity(Arrays.asList(new Integer[]{SysUserIdentityType.YYJL.getValue()}));
+        sendOverTimeNotice(users, tasks);
+        // 24小时通知
+        tasks = getOverTimeTask(24);
+        users = getUsersByIdentity(Arrays.asList(new Integer[]{SysUserIdentityType.ZJL.getValue()}));
+        sendOverTimeNotice(users, tasks);
+    }
+
+    /**
+     * 超时任务
+     *
+     * @param hour
+     * @return
+     */
+    private List<RepairApplicationForm> getOverTimeTask(int hour) {
+        LocalDateTime threeHourAgo = DateUtils.minus(LocalDateTime.now(), hour, ChronoUnit.HOURS);
+        Weekend<RepairApplicationForm> weekend = new Weekend<>(RepairApplicationForm.class);
+        weekend.weekendCriteria().andNotIn(RepairApplicationForm::getStatus, Arrays.asList(new Integer[]{RepairApplicationFormStatusEnum.NOT_ACCEPTANCE.getValue(), RepairApplicationFormStatusEnum.FINISHED.getValue()}))
+                .andLessThan(RepairApplicationForm::getCreatedTime, threeHourAgo);
+        return mapper.selectByExample(weekend);
+    }
+
+    /**
+     * 超时消息推送
+     *
+     * @param users
+     * @param tasks
+     */
+    private void sendOverTimeNotice(List<SysUser> users, List<RepairApplicationForm> tasks) {
+        if (CollectionUtil.isNotEmpty(users) && CollectionUtil.isNotEmpty(tasks)) {
+            List<String> userIds = users.stream().map(item -> item.getUserId()).collect(Collectors.toList());
+            tasks.forEach(item -> {
+                SpringContextHolder.publishEvent(new WorkplaceBacklogEvent(WorkplaceBacklogTypeEnum.REPAIR_NOT_FINISH.getValue(), WorkplaceBacklogDetailTypeEnum.REPAIR_APPLICATION.getValue(),
+                        item.getId(), MessageTemplateUtil.getRepairApplicationForNotFinishNotic(item.getId(), 3),
+                        item.getId(), userIds));
+            });
+        }
+    }
+
+    /**
+     * 根据身份获取用户
+     *
+     * @param identities
+     * @return
+     */
+    private List<SysUser> getUsersByIdentity(List<Integer> identities) {
+        Weekend<SysUser> w = new Weekend<>(SysUser.class);
+        w.weekendCriteria().andIn(SysUser::getIdentityType, identities);
+        return userMapper.selectByExample(w);
+    }
 }

+ 16 - 0
platform-service/src/main/java/com/platform/service/upms/SysUserService.java

@@ -184,4 +184,20 @@ public interface SysUserService extends IBaseService<SysUser, SysUserDTO> {
      * @return :
      */
     ImportResultVO importUsers(String deptId, List<ImportSysUserVO> users);
+
+    /**
+     * 修改工作状态
+     *
+     * @param userId
+     * @param workStatus
+     */
+    void updateUserWorkStatus(String userId, Integer workStatus, SysUserDTO sysUserDTO);
+
+    /**
+     * 获取维修人员
+     *
+     * @param sysUserDTO
+     * @return
+     */
+    List<SysUser> getRepairUser(SysUserDTO sysUserDTO);
 }

+ 30 - 0
platform-service/src/main/java/com/platform/service/upms/impl/SysUserServiceImpl.java

@@ -19,6 +19,7 @@ import com.platform.dao.bean.MyPage;
 import com.platform.dao.dto.upms.*;
 import com.platform.dao.entity.upms.*;
 import com.platform.dao.enums.DeptNatureEnum;
+import com.platform.dao.enums.SysUserIdentityType;
 import com.platform.dao.mapper.upms.SysDeptManagerMapper;
 import com.platform.dao.mapper.upms.SysDeptMapper;
 import com.platform.dao.mapper.upms.SysDeptRelationMapper;
@@ -716,4 +717,33 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserMapper, SysUser,
         }
         return result;
     }
+
+    @Override
+    public void updateUserWorkStatus(String userId, Integer workStatus, SysUserDTO userDTO) {
+        SysUser user = mapper.selectByPrimaryKey(userId);
+        if (user == null) {
+            throw new BusinessException("用户不存在");
+        }
+        if (!PasswordUtil.matches(userDTO.getPassword(), user.getPassword())) {
+            // 当前密码错误
+            throw new BusinessException(ResultCode.USER_PASSWORD_MATCH);
+        }
+        SysUser update = new SysUser();
+        update.setUserId(user.getUserId());
+        update.setWorkFlag(workStatus == 1);
+        mapper.updateByPrimaryKeySelective(update);
+
+    }
+
+    @Override
+    public List<SysUser> getRepairUser(SysUserDTO sysUserDTO) {
+        Weekend<SysUser> weekend = new Weekend<>(SysUser.class);
+        WeekendCriteria<SysUser, Object> weekendCriteria = weekend.weekendCriteria();
+        Boolean workStatus = sysUserDTO.getWorkFlag();
+        if (workStatus != null) {
+            weekendCriteria.andEqualTo(SysUser::getWorkFlag, workStatus);
+        }
+        weekendCriteria.andIn(SysUser::getIdentityType, Arrays.asList(new Integer[]{SysUserIdentityType.WXY.getValue(), SysUserIdentityType.WXZG.getValue()}));
+        return mapper.selectByExample(weekend);
+    }
 }