guarantee-lsq 2 年之前
父节点
当前提交
6eb2bc048c

+ 2 - 2
platform-service/src/main/java/com/platform/service/repair/strategy/AbstractRepairBaseStrategy.java

@@ -222,11 +222,10 @@ public abstract class AbstractRepairBaseStrategy implements RepairBaseStrategy{
 
     @Override
     public RepairApplicationFormDTO dispatchRepair(RepairApplicationFormDTO model) {
-        RepairApplicationForm applicationForm = repairApplicationFormMapper.selectById(model.getId());
+        /*RepairApplicationForm applicationForm = repairApplicationFormMapper.selectById(model.getId());
         if (!RepairApplicationFormStatusEnum.NOT_ALLOCATED.getValue().equals(applicationForm.getStatus()) && !RepairApplicationFormStatusEnum.REBACK.getValue().equals(applicationForm.getStatus())) {
             throw new BusinessException("该状态不允许派工任务, id, status:" + applicationForm.getId() + "," + applicationForm.getStatus());
         }
-
         if (StringUtils.isBlank(applicationForm.getRepairDispatchList())) {
             JSONObject jsonObject = new JSONObject();
             jsonObject.put("userId", applicationForm.getRepairUserId());
@@ -259,6 +258,7 @@ public abstract class AbstractRepairBaseStrategy implements RepairBaseStrategy{
         SpringContextHolder.publishEvent(new WorkplaceBacklogEvent(WorkplaceBacklogTypeEnum.REPAIR.getValue(), WorkplaceBacklogDetailTypeEnum.REPAIR_DISPATCH.getValue(),
                 applicationForm.getId(), MessageTemplateUtil.getRepairDispatch(applicationForm.getNo()),
                 applicationForm.getId(), ListUtils.newArrayList(model.getRepairUserId()), ListUtils.newArrayList(repairUser.getEmail())));
+        */
         return model;
     }
 

+ 48 - 0
platform-service/src/main/java/com/platform/service/repair/strategy/impl/AllocateRepairBaseStrategy.java

@@ -1,6 +1,8 @@
 package com.platform.service.repair.strategy.impl;
 
 import cn.hutool.core.collection.CollectionUtil;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.platform.common.cache.ConfigCache;
 import com.platform.common.exception.BusinessException;
 import com.platform.common.exception.DeniedException;
@@ -169,4 +171,50 @@ public class AllocateRepairBaseStrategy extends AbstractRepairBaseStrategy {
                 dto.getId(), ListUtils.newArrayList(dto.getRepairUserId()), ListUtils.newArrayList(noticeUser.getEmail())));
         return dto;
     }
+
+    @Override
+    public RepairApplicationFormDTO dispatchRepair(RepairApplicationFormDTO model) {
+        super.dispatchRepair(model);
+        RepairApplicationForm applicationForm = repairApplicationFormMapper.selectById(model.getId());
+        if (!RepairApplicationFormStatusEnum.NOT_ALLOCATED.getValue().equals(applicationForm.getStatus()) && !RepairApplicationFormStatusEnum.REBACK.getValue().equals(applicationForm.getStatus())) {
+            throw new BusinessException("该状态不允许派工任务, id, status:" + applicationForm.getId() + "," + applicationForm.getStatus());
+        }
+        // 当前用户不是派工人,不可进行派工
+        if(!SecurityUtils.getUserInfo().getUserId().equals(applicationForm.getDispatchUserId())){
+           throw new DeniedException("您不是该单的派工主管,无法进行派单,请见谅");
+        }
+        if (StringUtils.isBlank(applicationForm.getRepairDispatchList())) {
+            JSONObject jsonObject = new JSONObject();
+            jsonObject.put("userId", applicationForm.getRepairUserId());
+            jsonObject.put("username", applicationForm.getRepairUserName());
+            jsonObject.put("remark", model.getRepairDispatchRemark());
+            jsonObject.put("time", LocalDateTime.now());
+            JSONArray jsonArray = new JSONArray();
+            jsonArray.add(jsonObject);
+            applicationForm.setRepairDispatchList(jsonArray.toJSONString());
+        } else {
+            JSONArray jsonArray = JSONArray.parseArray(applicationForm.getRepairDispatchList());
+            JSONObject jsonObject = new JSONObject();
+            jsonObject.put("userId", applicationForm.getRepairUserId());
+            jsonObject.put("username", applicationForm.getRepairUserName());
+            jsonObject.put("remark", applicationForm.getRepairDispatchRemark());
+            jsonObject.put("time", LocalDateTime.now());
+            jsonArray.add(jsonObject);
+            applicationForm.setRepairDispatchList(jsonArray.toJSONString());
+        }
+        applicationForm.setId(model.getId());
+        applicationForm.setRepairUserId(model.getRepairUserId());
+        applicationForm.setRepairDispatchRemark(model.getRepairDispatchRemark());
+        applicationForm.setStatus(RepairApplicationFormStatusEnum.PROCESSING.getValue());
+        applicationForm.setRepairStartTime(LocalDateTime.now());
+        applicationForm.setUpdateTime(LocalDateTime.now());
+        // 转派其他人要将维修结束时间置空'
+        repairApplicationFormMapper.updateForRepairDispatch(applicationForm);
+
+        SysUser repairUser = sysUserService.getModelById(model.getRepairUserId());
+        SpringContextHolder.publishEvent(new WorkplaceBacklogEvent(WorkplaceBacklogTypeEnum.REPAIR.getValue(), WorkplaceBacklogDetailTypeEnum.REPAIR_DISPATCH.getValue(),
+                applicationForm.getId(), MessageTemplateUtil.getRepairDispatch(applicationForm.getNo()),
+                applicationForm.getId(), ListUtils.newArrayList(model.getRepairUserId()), ListUtils.newArrayList(repairUser.getEmail())));
+        return model;
+    }
 }

+ 44 - 0
platform-service/src/main/java/com/platform/service/repair/strategy/impl/BaseRepairBaseStrategy.java

@@ -1,6 +1,8 @@
 package com.platform.service.repair.strategy.impl;
 
 import cn.hutool.core.collection.CollectionUtil;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.platform.common.cache.ConfigCache;
 import com.platform.common.exception.BusinessException;
 import com.platform.common.model.UserInfo;
@@ -147,6 +149,48 @@ public class BaseRepairBaseStrategy extends AbstractRepairBaseStrategy {
         return dto;
     }
 
+    @Override
+    public RepairApplicationFormDTO dispatchRepair(RepairApplicationFormDTO model) {
+        super.dispatchRepair(model);
+        RepairApplicationForm applicationForm = repairApplicationFormMapper.selectById(model.getId());
+        if (!RepairApplicationFormStatusEnum.NOT_ALLOCATED.getValue().equals(applicationForm.getStatus()) && !RepairApplicationFormStatusEnum.REBACK.getValue().equals(applicationForm.getStatus())) {
+            throw new BusinessException("该状态不允许派工任务, id, status:" + applicationForm.getId() + "," + applicationForm.getStatus());
+        }
+        if (StringUtils.isBlank(applicationForm.getRepairDispatchList())) {
+            JSONObject jsonObject = new JSONObject();
+            jsonObject.put("userId", applicationForm.getRepairUserId());
+            jsonObject.put("username", applicationForm.getRepairUserName());
+            jsonObject.put("remark", model.getRepairDispatchRemark());
+            jsonObject.put("time", LocalDateTime.now());
+            JSONArray jsonArray = new JSONArray();
+            jsonArray.add(jsonObject);
+            applicationForm.setRepairDispatchList(jsonArray.toJSONString());
+        } else {
+            JSONArray jsonArray = JSONArray.parseArray(applicationForm.getRepairDispatchList());
+            JSONObject jsonObject = new JSONObject();
+            jsonObject.put("userId", applicationForm.getRepairUserId());
+            jsonObject.put("username", applicationForm.getRepairUserName());
+            jsonObject.put("remark", applicationForm.getRepairDispatchRemark());
+            jsonObject.put("time", LocalDateTime.now());
+            jsonArray.add(jsonObject);
+            applicationForm.setRepairDispatchList(jsonArray.toJSONString());
+        }
+        applicationForm.setId(model.getId());
+        applicationForm.setRepairUserId(model.getRepairUserId());
+        applicationForm.setRepairDispatchRemark(model.getRepairDispatchRemark());
+        applicationForm.setStatus(RepairApplicationFormStatusEnum.PROCESSING.getValue());
+        applicationForm.setRepairStartTime(LocalDateTime.now());
+        applicationForm.setUpdateTime(LocalDateTime.now());
+        // 转派其他人要将维修结束时间置空'
+        repairApplicationFormMapper.updateForRepairDispatch(applicationForm);
+
+        SysUser repairUser = sysUserService.getModelById(model.getRepairUserId());
+        SpringContextHolder.publishEvent(new WorkplaceBacklogEvent(WorkplaceBacklogTypeEnum.REPAIR.getValue(), WorkplaceBacklogDetailTypeEnum.REPAIR_DISPATCH.getValue(),
+                applicationForm.getId(), MessageTemplateUtil.getRepairDispatch(applicationForm.getNo()),
+                applicationForm.getId(), ListUtils.newArrayList(model.getRepairUserId()), ListUtils.newArrayList(repairUser.getEmail())));
+        return model;
+    }
+
     public static void main(String[] args) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
         RepairApplicationFormDTO dto = new RepairApplicationFormDTO();
         RepairBaseStrategy tt = new BaseRepairBaseStrategy();