Browse Source

维修工单后端调整

lipenghui 4 months ago
parent
commit
78474b9731

+ 12 - 10
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/maintain/IotMaintainServiceImpl.java

@@ -25,6 +25,8 @@ import cn.iocoder.yudao.module.pms.dal.mysql.iotoutbound.IotOutboundMapper;
 import cn.iocoder.yudao.module.pms.dal.mysql.maintain.IotMaintainMapper;
 import cn.iocoder.yudao.module.pms.dal.mysql.maintain.material.IotMaintainMaterialMapper;
 import cn.iocoder.yudao.module.pms.enums.common.FailureAuditStatusEnum;
+import cn.iocoder.yudao.module.system.api.dept.DeptApi;
+import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
 import cn.iocoder.yudao.module.system.api.dingtalk.DingtalkSendApi;
 import cn.iocoder.yudao.module.system.api.notify.NotifyMessageSendApi;
 import cn.iocoder.yudao.module.system.api.notify.dto.NotifySendSingleToUserReqDTO;
@@ -69,7 +71,7 @@ public class IotMaintainServiceImpl implements IotMaintainService {
     @Autowired
     private IotFailureReportMapper iotFailureReportMapper;
     @Resource
-    private DeptService deptService;
+    private DeptApi deptApi;
     @Resource
     private AdminUserApi adminUserApi;
     @Resource
@@ -106,9 +108,9 @@ public class IotMaintainServiceImpl implements IotMaintainService {
         }).collect(Collectors.toList());
         iotMaintainMaterialMapper.insertBatch(collect);
         //本地库存减少且记录出库
-        if ("finished".equals(createReqVO.getMaintain().getStatus())&&"in".equals(createReqVO.getMaintain().getType())) {
+//        if ("finished".equals(createReqVO.getMaintain().getStatus())&&"in".equals(createReqVO.getMaintain().getType())) {
             localStockAndOut(createReqVO);
-        }
+//        }
         //如果委外发起流程
         if ("out".equals(createReqVO.getMaintain().getType())){
             String processInstanceId = processInstanceApi.createProcessInstance(SecurityFrameworkUtils.getLoginUserId(),
@@ -196,31 +198,31 @@ public class IotMaintainServiceImpl implements IotMaintainService {
             }
         }
         //异步发送消息
-        CompletableFuture.runAsync(()->{
+//        CompletableFuture.runAsync(()->{
             sendMessage(BeanUtils.toBean(iotMaintain, IotMaintainDO.class));
-        });
+//        });
     }
 
 
     private void sendMessage(IotMaintainDO iotMaintainDO) {
         Long loginUserDeptId = SecurityFrameworkUtils.getLoginUserDeptId();
-        DeptDO dept = deptService.getDept(loginUserDeptId);
-        DeptDO parentDept = deptService.getDept(dept.getParentId());
+        DeptRespDTO dept = deptApi.getDept(loginUserDeptId);
+        DeptRespDTO parentDept = deptApi.getDeptNoPermission(dept.getParentId());
         String templateCode = "maintain-report";
         Map<String, Object> templateParams = new HashMap<>();
         templateParams.put("name", iotMaintainDO.getDeviceName());
-        CompletableFuture.runAsync(() ->{
+//        CompletableFuture.runAsync(() ->{
             if (Objects.nonNull(parentDept.getLeaderUserId())){
                 notifyMessageSendApi.sendSingleMessageToAdmin(new NotifySendSingleToUserReqDTO()
                         .setUserId(parentDept.getLeaderUserId()).setTemplateCode(templateCode).setTemplateParams(templateParams));
                 String msg = "【PMS】维修工单 - "+iotMaintainDO.getFailureName()+"已处理。"+"["+new Date()+"]";
-                AdminUserRespDTO user = adminUserApi.getUser(parentDept.getParentId());
+                AdminUserRespDTO user = adminUserApi.getUser(parentDept.getLeaderUserId());
                 if (Objects.nonNull(user)) {
                     dingtalkSendApi.send(user.getMobile(), msg);
                 }
             }
 
-        });
+//        });
     }
 
     @Override

+ 1 - 1
yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dept/DeptApi.java

@@ -13,7 +13,7 @@ import java.util.Map;
  * @author 芋道源码
  */
 public interface DeptApi {
-
+    DeptRespDTO getDeptNoPermission(Long id);
     /**
      * 获得部门信息
      *

+ 6 - 0
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/dept/DeptApiImpl.java

@@ -28,6 +28,12 @@ public class DeptApiImpl implements DeptApi {
         return BeanUtils.toBean(dept, DeptRespDTO.class);
     }
 
+    @Override
+    public DeptRespDTO getDeptNoPermission(Long id) {
+        DeptDO dept = deptService.getDeptNoPermission(id);
+        return BeanUtils.toBean(dept, DeptRespDTO.class);
+    }
+
     @Override
     public List<DeptRespDTO> getDeptList(Collection<Long> ids) {
         List<DeptDO> depts = deptService.getDeptList(ids);

+ 1 - 1
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dept/DeptService.java

@@ -35,7 +35,7 @@ public interface DeptService {
      * @param id 部门编号
      */
     void deleteDept(Long id);
-
+    DeptDO getDeptNoPermission(Long id);
     /**
      * 获得部门信息
      *

+ 6 - 0
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dept/DeptServiceImpl.java

@@ -229,6 +229,12 @@ public class DeptServiceImpl implements DeptService {
         return deptMapper.selectById(id);
     }
 
+    @Override
+    @DataPermission(enable = false)
+    public DeptDO getDeptNoPermission(Long id) {
+        return deptMapper.selectById(id);
+    }
+
     @Override
     public List<DeptDO> getDeptList(Collection<Long> ids) {
         if (CollUtil.isEmpty(ids)) {