Bläddra i källkod

新增考勤异常详情接口

wangliang 1 år sedan
förälder
incheckning
ef386fbb0d

+ 11 - 0
sop-business/src/main/java/com/qmth/sop/business/service/TFCustomFlowAllocationService.java

@@ -2,6 +2,9 @@ package com.qmth.sop.business.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.qmth.sop.business.entity.TFCustomFlowAllocation;
+import com.qmth.sop.common.enums.RoleTypeEnum;
+
+import java.util.List;
 
 /**
  * <p>
@@ -13,4 +16,12 @@ import com.qmth.sop.business.entity.TFCustomFlowAllocation;
  */
 public interface TFCustomFlowAllocationService extends IService<TFCustomFlowAllocation> {
 
+    /**
+     * 根据流程步骤获取审批角色
+     *
+     * @param roleAllocation
+     * @param setup
+     * @return
+     */
+    public List<RoleTypeEnum> getRoleTypes(String roleAllocation, Integer setup);
 }

+ 1 - 9
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBProjectExchangeServiceImpl.java

@@ -1,7 +1,5 @@
 package com.qmth.sop.business.service.impl;
 
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -89,13 +87,7 @@ public class TBProjectExchangeServiceImpl extends ServiceImpl<TBProjectExchangeM
         Optional.ofNullable(tfCustomFlowAllocation).orElseThrow(() -> ExceptionResultEnum.FLOW_ALLOCATION_NO_DATA.exception());
         Optional.ofNullable(tfCustomFlowAllocation.getRoleAllocation()).orElseThrow(() -> ExceptionResultEnum.FLOW_ALLOCATION_NO_DATA.exception());
 
-        JSONObject jsonObject = JSONObject.parseObject(tfCustomFlowAllocation.getRoleAllocation());
-        JSONArray jsonArray = jsonObject.getJSONArray("roleTypes");
-        List<RoleTypeEnum> roleTypeEnumList = new ArrayList<>(jsonArray.size());
-        for (int i = 0; i < jsonArray.size(); i++) {
-            JSONObject object = jsonArray.getJSONObject(i);
-            roleTypeEnumList.add(RoleTypeEnum.valueOf(object.getString("role")));
-        }
+        List<RoleTypeEnum> roleTypeEnumList = tfCustomFlowAllocationService.getRoleTypes(tfCustomFlowAllocation.getRoleAllocation(), 2);
         //查询所有审核角色
         List<UserDto> userDtoList = sysUserRoleService.userListByRoleType(roleTypeEnumList);
         if (CollectionUtils.isEmpty(userDtoList)) {

+ 1 - 7
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBQualityProblemApplyServiceImpl.java

@@ -118,13 +118,7 @@ public class TBQualityProblemApplyServiceImpl extends ServiceImpl<TBQualityProbl
         Optional.ofNullable(tfCustomFlowAllocation).orElseThrow(() -> ExceptionResultEnum.FLOW_ALLOCATION_NO_DATA.exception());
         Optional.ofNullable(tfCustomFlowAllocation.getRoleAllocation()).orElseThrow(() -> ExceptionResultEnum.FLOW_ALLOCATION_NO_DATA.exception());
 
-        JSONObject jsonObject = JSONObject.parseObject(tfCustomFlowAllocation.getRoleAllocation());
-        JSONArray jsonArray = jsonObject.getJSONArray("roleTypes");
-        List<RoleTypeEnum> roleTypeEnumList = new ArrayList<>(jsonArray.size());
-        for (int i = 0; i < jsonArray.size(); i++) {
-            JSONObject object = jsonArray.getJSONObject(i);
-            roleTypeEnumList.add(RoleTypeEnum.valueOf(object.getString("role")));
-        }
+        List<RoleTypeEnum> roleTypeEnumList = tfCustomFlowAllocationService.getRoleTypes(tfCustomFlowAllocation.getRoleAllocation(), 2);
         //查询所有审核角色
         List<UserDto> userDtoList = sysUserRoleService.userListByRoleType(roleTypeEnumList);
         if (CollectionUtils.isEmpty(userDtoList)) {

+ 32 - 0
sop-business/src/main/java/com/qmth/sop/business/service/impl/TFCustomFlowAllocationServiceImpl.java

@@ -1,11 +1,18 @@
 package com.qmth.sop.business.service.impl;
 
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qmth.sop.business.entity.TFCustomFlowAllocation;
 import com.qmth.sop.business.mapper.TFCustomFlowAllocationMapper;
 import com.qmth.sop.business.service.TFCustomFlowAllocationService;
+import com.qmth.sop.common.enums.RoleTypeEnum;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+
 /**
  * <p>
  * 流程角色分配表 服务实现类
@@ -17,4 +24,29 @@ import org.springframework.stereotype.Service;
 @Service
 public class TFCustomFlowAllocationServiceImpl extends ServiceImpl<TFCustomFlowAllocationMapper, TFCustomFlowAllocation> implements TFCustomFlowAllocationService {
 
+    /**
+     * 根据流程步骤获取审批角色
+     *
+     * @param roleAllocation
+     * @param setup
+     * @return
+     */
+    @Override
+    public List<RoleTypeEnum> getRoleTypes(String roleAllocation, Integer setup) {
+        JSONObject jsonObject = JSONObject.parseObject(roleAllocation);
+        JSONArray jsonArray = jsonObject.getJSONArray("approveConfig");
+        List<RoleTypeEnum> roleTypeEnumList = new ArrayList<>();
+        for (int i = 0; i < jsonArray.size(); i++) {
+            JSONObject object = jsonArray.getJSONObject(i);
+            Integer setupJs = object.getInteger("setup");
+            if (Objects.nonNull(setupJs) && Objects.nonNull(setup) && setupJs.intValue() == setup.intValue()) {
+                JSONArray jsonArrayRoleTypes = object.getJSONArray("roleTypes");
+                for (int y = 0; y < jsonArray.size(); y++) {
+                    JSONObject objectRole = jsonArrayRoleTypes.getJSONObject(y);
+                    roleTypeEnumList.add(RoleTypeEnum.valueOf(objectRole.getString("role")));
+                }
+            }
+        }
+        return roleTypeEnumList;
+    }
 }