Bladeren bron

检定完善

xiongchao 3 jaren geleden
bovenliggende
commit
e20a0710bf

+ 5 - 1
platform-dao/src/main/java/com/platform/dao/enums/RepairApplicationFormStatusEnum.java

@@ -24,6 +24,10 @@ public enum RepairApplicationFormStatusEnum {
      * 已接收处理中
      */
     PROCESSING(3),
+    /**
+     * 完成待提交
+     */
+    WAIT_SUBMIT(31),
     /**
      * 待验收
      */
@@ -33,7 +37,7 @@ public enum RepairApplicationFormStatusEnum {
      */
     REBACK(5),
     /**
-     * 已完成
+     * 已关闭
      */
     FINISHED(6),
     /**

+ 2 - 2
platform-rest/src/main/java/com/platform/rest/controller/repair/RepairApplicationFormController.java

@@ -179,13 +179,13 @@ public class RepairApplicationFormController {
      * @param id 维修单DTO
      * @return R
      */
-    @SysLog("完成审核维修单")
+   /* @SysLog("完成审核维修单")
     @PutMapping("/examined/{id}/{result}")
     @PreAuthorize("@pms.hasPermission('repair-application-forms-finish')")
     public R examined(@PathVariable("id") String id, @PathVariable("result") Integer result, @Validated({UpdateGroup.class}) @RequestBody RepairApplicationFormDTO repairCheckDTO) {
         repairApplicationFormService.examined(id, result, repairCheckDTO);
         return new R<>();
-    }
+    }*/
 
     /**
      * 修改记录

+ 32 - 0
platform-rest/src/main/resources/templates/repairCheckEmail.ftl

@@ -0,0 +1,32 @@
+<div>维修完成验收通知</div>
+<div>有新的报修单已经完成,等待您的审批处理:
+    <table border="1">
+        <tr>
+            <td>维修单号</td>
+            <td>${no}</td>
+        </tr>
+        <tr>
+            <td>设备名称</td>
+            <td>${sbName}</td>
+        </tr>
+        <tr>
+            <td>设备编号</td>
+            <td>${sbNo}</td>
+        </tr>
+        <tr>
+            <td>设备使用位置</td>
+            <td>${sbCph}</td>
+        </tr>
+        <tr>
+            <td>报修人</td>
+            <td>${actualUser}</td>
+        </tr>
+        <tr>
+            <td>故障描述</td>
+            <td>${repairDesc}</td>
+        </tr>
+    </table>
+</div>
+<div>
+    <a href="${url}">点击链接跳转处理报修单</a>
+</div>

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

@@ -107,5 +107,5 @@ public interface RepairApplicationFormService extends IBaseService<RepairApplica
      * @param id
      * @param result 0 拒绝,1通过
      */
-    void examined(String id, Integer result, RepairApplicationFormDTO dto );
+    /*void examined(String id, Integer result, RepairApplicationFormDTO dto );*/
 }

+ 96 - 20
platform-service/src/main/java/com/platform/service/repair/impl/RepairApplicationFormServiceImpl.java

@@ -192,7 +192,18 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
         int count = mapper.selectCountByExample(weekend);
         UserInfo userInfo = SecurityUtils.getUserInfo();
         model.setUserId(userInfo.getUserId());
-        //model.setCheckUserId(userInfo.getUserId());
+
+        // 设置维修审批人为验收人,进行最终验收
+        SysUserDTO query = new SysUserDTO();
+        query.setRoleCode(SysRoleCodeEnum.REPAIR_EXAMINE.name());
+        List<SysUserVO> users = userMapper.selectDeptRoleUser(query);
+        SysUserVO userVO = null;
+        if (CollectionUtil.isNotEmpty(users)) {
+            userVO = users.get(0);
+        }else{
+            throw new BusinessException("审核角色:REPAIR_EXAMINE未绑定用户,请设置用户");
+        }
+        model.setCheckUserId(userVO.getUserId());
         // 查询对应的维修人,保存维修单
         String sbId = model.getSbId();
         SbInfoVO sb = sbInfoService.getById(sbId);
@@ -248,10 +259,10 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
         }
         String repairUrl = domain + "repair/form?no=" + model.getNo();
         if (StringUtils.isEmpty(repairUserId)) {
-            List<SysUser> users = sysUserService.getRepairUser(new SysUserDTO());
-            List<SysUser> filterUsers = users.stream().filter(item -> item.getWorkFlag()).collect(Collectors.toList());
+            List<SysUser> userList = sysUserService.getRepairUser(new SysUserDTO());
+            List<SysUser> filterUsers = userList.stream().filter(item -> item.getWorkFlag()).collect(Collectors.toList());
             if (CollectionUtil.isEmpty(filterUsers)) {
-                filterUsers = users.stream().filter(item -> item.getIdentityType().equals(SysUserIdentityType.WXZG.getValue())).collect(Collectors.toList());
+                filterUsers = userList.stream().filter(item -> item.getIdentityType().equals(SysUserIdentityType.WXZG.getValue())).collect(Collectors.toList());
             }
             filterUsers.forEach(item -> {
                 userIds.add(item.getUserId());
@@ -276,6 +287,14 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
         return form;
     }
 
+    /**
+     * 获取维修通知
+     *
+     * @param url
+     * @param model
+     * @param vo
+     * @return
+     */
     private String getFreemarkerHtmlContent(String url, RepairApplicationFormDTO model, SbInfoVO vo){
         // 首先配置 FreeMarker 模版位置
         Configuration configuration = new Configuration(Configuration.VERSION_2_3_0);
@@ -307,6 +326,45 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
         }
     }
 
+    /**
+     * 获取维修完成审核通知
+     *
+     * @param url
+     * @param model
+     * @param vo
+     * @return
+     */
+    private String getFreemarkerHtmlContentCheck(String url, RepairApplicationFormDTO model, SbInfoVO vo){
+        // 首先配置 FreeMarker 模版位置
+        Configuration configuration = new Configuration(Configuration.VERSION_2_3_0);
+        ClassLoader loader = RepairApplicationFormServiceImpl.class.getClassLoader();
+        configuration.setClassLoaderForTemplateLoading(loader,"templates");
+
+        // 配置模版文件
+        try {
+            Template template = configuration.getTemplate("repairCheckEmail.ftl");
+            StringWriter mail = new StringWriter();
+            //构造填充数据的Map
+            Map map = new HashMap();
+            map.put("no", model.getNo());
+            map.put("sbName", vo.getName());
+            map.put("sbNo", vo.getNo());
+            map.put("sbCph", model.getSbCph());
+            map.put("actualUser", model.getActualUser());
+            if(StringUtils.isBlank(model.getContent())){
+                map.put("repairDesc", "无法断定,请维修人员现场检查");
+            }else{
+                map.put("repairDesc", model.getContent());
+            }
+            map.put("url", url);
+            template.process(map,mail);
+            System.out.println(map.toString());
+            return mail.toString();
+        } catch (IOException | TemplateException e) {
+            throw new BusinessException("报修邮件模板解析出错。" + e.getMessage());
+        }
+    }
+
     @Override
     public void modModelByDTO(RepairApplicationFormDTO model) {
         if(StringUtils.isBlank(model.getSbId())){
@@ -381,9 +439,7 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
         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.setRepairUserId(SecurityUtils.getUserInfo().getUserId());
         applicationForm.setStatus(RepairApplicationFormStatusEnum.PROCESSING.getValue());
         applicationForm.setRepairStartTime(LocalDateTime.now());
         applicationForm.setUpdateTime(LocalDateTime.now());
@@ -397,17 +453,19 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
 
     /**
      * 发起审核给领导人,必须完成后的报修单才可以提交审核
+     * 给领导发邮件,领导通过邮件跳转到审核页面
      *
      * @param id :
      */
     @Override
     public void examine(String id) {
         RepairApplicationForm applicationForm = mapper.selectById(id);
-        if (!RepairApplicationFormStatusEnum.NOT_ACCEPTANCE.getValue().equals(applicationForm.getStatus())) {
+        if (!RepairApplicationFormStatusEnum.WAIT_SUBMIT.getValue().equals(applicationForm.getStatus())) {
             throw new BusinessException("未完成的不允许提交审核");
         }
-        applicationForm.setStatus(RepairApplicationFormStatusEnum.EXAMINING.getValue());
-        applicationForm.setUpdateTime(LocalDateTime.now());
+        applicationForm.setStatus(RepairApplicationFormStatusEnum.NOT_ACCEPTANCE.getValue());
+        applicationForm.setCheckStartTime(LocalDateTime.now());
+        applicationForm.setUpdateTime(applicationForm.getCheckStartTime());
         super.modModelByPrimaryKey(applicationForm);
         SysUserDTO query = new SysUserDTO();
         query.setRoleCode(SysRoleCodeEnum.REPAIR_EXAMINE.name());
@@ -418,8 +476,18 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
         }else{
             throw new BusinessException("审核角色为绑定用户,请设置用户");
         }
+
+        String domain = ConfigCache.getLabelByValueAllowNull(SysConfigEnum.SYSTEM_DOMAIN.name());
+        if(StringUtils.isBlank(domain)){
+            throw new BusinessException("请先设置系统域名地址,系统管理-》系统参数配置-》SYSTEM_DOMAIN");
+        }
+        if(!domain.endsWith("/")){
+            domain = domain + "/";
+        }
+        String repairUrl = domain + "repair/application/form/check?no=" + applicationForm.getNo();
+        SbInfoVO sbInfoVO = sbInfoService.getById(applicationForm.getSbId());
         SpringContextHolder.publishEvent(new WorkplaceBacklogEvent(WorkplaceBacklogTypeEnum.RECEIVE.getValue(), WorkplaceBacklogDetailTypeEnum.REPAIR_EXAMINE.getValue(),
-                applicationForm.getId(), MessageTemplateUtil.getReceiveExamine(applicationForm.getNo()),
+                applicationForm.getId(), getFreemarkerHtmlContent(repairUrl,BeanConverterUtil.copyObjectProperties(applicationForm, RepairApplicationFormDTO.class), sbInfoVO),
                 applicationForm.getId(), ListUtils.newArrayList(userVO.getUserId()), ListUtils.newArrayList(userVO.getEmail())));}
 
     /**
@@ -427,7 +495,7 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
      *
      * @param id :
      */
-    @Override
+    /*@Override
     public void examined(String id, Integer result, RepairApplicationFormDTO dto) {
         RepairApplicationForm applicationForm = mapper.selectById(id);
         if (!RepairApplicationFormStatusEnum.EXAMINING.getValue().equals(applicationForm.getStatus())) {
@@ -441,7 +509,7 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
         applicationForm.setUpdateTime(LocalDateTime.now());
         applicationForm.setExamineContent(dto.getExamineContent());
         super.modModelByPrimaryKey(applicationForm);
-    }
+    }*/
 
     /**
      * 派工,更新维修人的id
@@ -487,6 +555,11 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
                 applicationForm.getId(), ListUtils.newArrayList(model.getRepairUserId()), ListUtils.newArrayList(repairUser.getEmail())));
     }
 
+    /**
+     * 完成为待验收状态,此时需要再次编辑维修内容,最终提交审核
+     *
+     * @param dto
+     */
     @Override
     @Transactional(rollbackFor = Exception.class)
     public void finish(RepairApplicationFormDTO dto) {
@@ -495,12 +568,10 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
         RepairApplicationForm applicationForm = mapper.selectById(dto.getId());
         RepairForm repairForm = new RepairForm();
         repairForm.setId(dto.getId());
-        applicationForm.setStatus(RepairApplicationFormStatusEnum.FINISHED.getValue());
-
+        applicationForm.setStatus(RepairApplicationFormStatusEnum.WAIT_SUBMIT.getValue());
         applicationForm.setRepairEndTime(LocalDateTime.now());
         applicationForm.setRepairMinutes(DateUtils.dateDiff(applicationForm.getRepairEndTime(), applicationForm.getRepairStartTime()));
-        applicationForm.setCheckStartTime(applicationForm.getRepairEndTime());
-        applicationForm.setCheckEndTime(applicationForm.getRepairEndTime());
+
         applicationForm.setRepairContent(dto.getRepairContent());
         applicationForm.setNeedStop(dto.getNeedStop());
         //applicationForm.setLevel(dto.getLevel());
@@ -553,6 +624,11 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
         }*/
     }
 
+    /**
+     * 领导最终验收,进行数据项目的验收
+     *
+     * @param dto
+     */
     @Transactional(rollbackFor = Exception.class)
     @Override
     public void approve(RepairApplicationFormDTO dto) {
@@ -560,7 +636,7 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
         RepairApplicationForm applicationForm = mapper.selectById(dto.getId());
         applicationForm.setCheckEndTime(LocalDateTime.now());
         applicationForm.setStatus(RepairApplicationFormStatusEnum.FINISHED.getValue());
-        applicationForm.setUpdateTime(LocalDateTime.now());
+        applicationForm.setUpdateTime(applicationForm.getCheckEndTime());
         super.modModelByPrimaryKey(applicationForm);
 
         // 如果选择了设备停机,则要修改设备状态
@@ -569,10 +645,10 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
         info.setStatus(SbInfoStatusEnum.IN_USE.getValue());
         sbInfoService.modModelByPrimaryKey(info);
 
-        SysUser noticeUser = userMapper.selectByPrimaryKey(applicationForm.getRepairUserId());
+        /*SysUser noticeUser = userMapper.selectByPrimaryKey(applicationForm.getRepairUserId());
         SpringContextHolder.publishEvent(new WorkplaceBacklogEvent(WorkplaceBacklogTypeEnum.REPAIR.getValue(), WorkplaceBacklogDetailTypeEnum.REPAIR_OK.getValue(),
                 applicationForm.getId(), MessageTemplateUtil.getRepairOk(applicationForm.getNo()),
-                applicationForm.getId(), ListUtils.newArrayList(applicationForm.getRepairUserId()), ListUtils.newArrayList(noticeUser.getEmail())));
+                applicationForm.getId(), ListUtils.newArrayList(applicationForm.getRepairUserId()), ListUtils.newArrayList(noticeUser.getEmail())));*/
     }
 
     @Transactional(rollbackFor = Exception.class)