소스 검색

feature(服务权限注销修改): 服务权限注销修改

服务权限注销修改
mazq 3 년 전
부모
커밋
2d4bd83cfe

+ 1 - 0
dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/auth/business/impl/ServiceAuthBusinessImpl.java

@@ -86,6 +86,7 @@ public class ServiceAuthBusinessImpl implements IServiceAuthBusiness {
         flow.setRemark(dto.getRemark());
         flow.setRemark(dto.getRemark());
         flow.setFlowStatus(dto.getApproveResult());
         flow.setFlowStatus(dto.getApproveResult());
         flow.setFlowId(flowId);
         flow.setFlowId(flowId);
+        flow.setMessageId(messageId);
         //处理服务授权结果
         //处理服务授权结果
         authResultService.dealAuthFlowResult(flow);
         authResultService.dealAuthFlowResult(flow);
         //更新工作单状态
         //更新工作单状态

+ 2 - 1
dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/auth/service/impl/ServiceAuthResultServiceImpl.java

@@ -168,7 +168,8 @@ public class ServiceAuthResultServiceImpl implements IServiceAuthResultService {
             for (ServiceAuthResult serviceAuthResult : result) {
             for (ServiceAuthResult serviceAuthResult : result) {
                 serviceAuthResult.setDeleted(BooleanEnum.TRUE.getValue());
                 serviceAuthResult.setDeleted(BooleanEnum.TRUE.getValue());
                 serviceAuthResult.setDeleteTime(date);
                 serviceAuthResult.setDeleteTime(date);
-                serviceAuthFlow.setFlowId(serviceAuthFlow.getFlowId());
+                serviceAuthResult.setFlowId(serviceAuthFlow.getFlowId());
+                serviceAuthResult.setMessageId(serviceAuthFlow.getMessageId());
                 serviceAuthResultBPO.update(serviceAuthResult);
                 serviceAuthResultBPO.update(serviceAuthResult);
                 if(!ResourceTypeEnum.BU_SERVICE.getResourceId().equals(serviceAuthResult.getServiceResourceId())) {
                 if(!ResourceTypeEnum.BU_SERVICE.getResourceId().equals(serviceAuthResult.getServiceResourceId())) {
                     cancelList.add(serviceAuthResult.getServiceCode());
                     cancelList.add(serviceAuthResult.getServiceCode());

+ 0 - 1
dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/msg/WorkFlowResultListener.java

@@ -109,7 +109,6 @@ public class WorkFlowResultListener {
         if(!messageId.contains(StrUtil.COLON)) {
         if(!messageId.contains(StrUtil.COLON)) {
             serviceAuthBusiness.dealAuthFlowResult(dto);
             serviceAuthBusiness.dealAuthFlowResult(dto);
         } else {
         } else {
-            aprResultBusiness.dealAuthFlowResult(dto);
             String[] arr = messageId.split(StrUtil.COLON);
             String[] arr = messageId.split(StrUtil.COLON);
             String workFlowType = arr[1];
             String workFlowType = arr[1];
             logger.info("workFlowType:{}", workFlowType);
             logger.info("workFlowType:{}", workFlowType);

+ 116 - 1
dcuc-auth-service/src/test/java/com/dragoninfo/dcuc/auth/auth/service/IAuthFlowServiceTest.java

@@ -1,12 +1,21 @@
 package com.dragoninfo.dcuc.auth.auth.service;
 package com.dragoninfo.dcuc.auth.auth.service;
 
 
+import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson.TypeReference;
+import com.dragoninfo.dcuc.auth.DcucAuthApplication;
+import com.dragoninfo.dcuc.auth.auth.business.IAuthAprResultBusiness;
 import com.dragoninfo.dcuc.auth.auth.business.IServiceAuthBusiness;
 import com.dragoninfo.dcuc.auth.auth.business.IServiceAuthBusiness;
+import com.dragoninfo.dcuc.auth.auth.dto.ApprovalWorkFlowDTO;
 import com.dragoninfo.dcuc.auth.auth.dto.WorkFlowResutlAcceptDTO;
 import com.dragoninfo.dcuc.auth.auth.dto.WorkFlowResutlAcceptDTO;
 import com.dragoninfo.dcuc.auth.auth.entity.ServiceAuthFlow;
 import com.dragoninfo.dcuc.auth.auth.entity.ServiceAuthFlow;
 import com.dragoninfo.dcuc.auth.auth.enumresources.WorkFlowStatusEnum;
 import com.dragoninfo.dcuc.auth.auth.enumresources.WorkFlowStatusEnum;
+import com.dragoninfo.dcuc.auth.config.DcucAuthConfig;
+import com.dragoninfo.dcuc.duceap.enums.AuthApplyTypeEnum;
+import com.dragonsoft.duceap.commons.util.collections.CollectionUtils;
+import com.dragonsoft.duceap.commons.util.string.StringUtils;
 import org.junit.Assert;
 import org.junit.Assert;
 import org.junit.Test;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runner.RunWith;
@@ -14,12 +23,15 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.junit4.SpringRunner;
 import org.springframework.test.context.junit4.SpringRunner;
 
 
+import java.util.List;
+import java.util.Map;
+
 /**
 /**
  * @author huangzqa
  * @author huangzqa
  * @date 2021/2/28
  * @date 2021/2/28
  **/
  **/
 @RunWith(SpringRunner.class)
 @RunWith(SpringRunner.class)
-@SpringBootTest
+@SpringBootTest(classes = DcucAuthApplication.class)
 public class IAuthFlowServiceTest {
 public class IAuthFlowServiceTest {
 
 
     @Autowired
     @Autowired
@@ -28,6 +40,12 @@ public class IAuthFlowServiceTest {
     @Autowired
     @Autowired
     private IServiceAuthBusiness serviceAuthBusiness;
     private IServiceAuthBusiness serviceAuthBusiness;
 
 
+    @Autowired
+    private IAuthAprResultBusiness aprResultBusiness;
+
+    @Autowired
+    private DcucAuthConfig config;
+
     @Test
     @Test
     public void getByFlowId() {
     public void getByFlowId() {
 
 
@@ -56,4 +74,101 @@ public class IAuthFlowServiceTest {
 
 
     }
     }
 
 
+    @Test
+    public void dealApprovalResult() {
+        List<Map<String, String>> infoSet = getInfoSet();
+        if (CollectionUtils.isEmpty(infoSet)) {
+            return;
+        }
+        Map<String, String> map = infoSet.get(0);
+        if (null == map) {
+            return;
+        }
+        String approveResult = map.get("approveResult");
+        WorkFlowStatusEnum statusEnum = WorkFlowStatusEnum.getStatusByApproveResult(approveResult);
+        if(null == statusEnum){
+            return;
+        }
+        String messageId = map.get("messageId");
+        String appCode = map.get("sourceAppCode");
+        WorkFlowResutlAcceptDTO dto = new WorkFlowResutlAcceptDTO();
+        dto.setMessageId(messageId);
+        dto.setProcessInstanceId(map.get("processInstanceId"));
+        dto.setApproveResult(statusEnum.getValue());
+        dto.setAppCode(appCode);
+        dto.setApproveNo(map.get("approveNo"));
+
+        //兼容历史未处理过的服务授权的appCode和messageId
+        if(StringUtils.isBlank(appCode) || config.getAppCode().equals(appCode)) {
+            dealAuthCenterAuthFlow(messageId, dto);
+        } else {
+            String approveInfo = map.get("approveInfo");
+            ApprovalWorkFlowDTO approvalWorkFlowDTO = JSON.parseObject(approveInfo, ApprovalWorkFlowDTO.class);
+            dealApprovalCenterAuthFlow(dto, approvalWorkFlowDTO);
+        }
+    }
+
+    private List<Map<String, String>> getInfoSet() {
+        String value = "{\n" +
+                "    \"appKey\": \"dcuc69000787\",\n" +
+                "    \"appSecret\": \"dcuc01494668\",\n" +
+                "    \"messages\": [\n" +
+                "        {\n" +
+                "            \"content\": \"91526\",\n" +
+                "            \"createTime\": \"20210728110526\",\n" +
+                "            \"infoSet\": [\n" +
+                "                {\n" +
+                "                    \"approveNo\": \"20210728-00006\",\n" +
+                "                    \"processInstanceId\": \"91526\",\n" +
+                "                    \"messageId\": \"20c3fdbe11044c2aa91dc0f928d2ae19:SERVICE_AUTH_CANCEL\",\n" +
+                "                    \"approveInfo\": \"{\\\"appCode\\\":\\\"QXXT0000000000000001\\\",\\\"applicantIdcard\\\":\\\"460004197411064109\\\",\\\"applicantName\\\":\\\"吉晓竹\\\",\\\"applicantOrgCode\\\":\\\"120000000000\\\",\\\"applicantOrgName\\\":\\\"天津市公安局\\\",\\\"applicantPhoneNo\\\":\\\"13923213222\\\",\\\"applyContent\\\":\\\"{\\\\\\\"visitResourceCode\\\\\\\":\\\\\\\"S-360000000000-0100-00056\\\\\\\",\\\\\\\"visitResourceName\\\\\\\":\\\\\\\"江西省公安厅查询检索类服务00056\\\\\\\",\\\\\\\"visitorCode\\\\\\\":\\\\\\\"Y-120000000000-0037\\\\\\\",\\\\\\\"visitorName\\\\\\\":\\\\\\\"大数据智能服务运营平台\\\\\\\"}\\\",\\\"applyReason\\\":\\\"1111\\\",\\\"approveTaskIdentifier\\\":\\\"service-auth-apply\\\",\\\"businessCode\\\":\\\"service-auth-apply\\\",\\\"createTime\\\":\\\"2021-07-28 11:04:53\\\",\\\"endTime\\\":null,\\\"permissionValidType\\\":\\\"02\\\",\\\"processName\\\":\\\"权限申请审批\\\",\\\"processTitle\\\":\\\"权限申请审批-吉晓竹-2021-07-28\\\",\\\"processType\\\":\\\"auth-update\\\",\\\"processTypeName\\\":\\\"权限变更\\\",\\\"resourceInfo\\\":{\\\"visitResourceCode\\\":\\\"S-360000000000-0100-00056\\\",\\\"visitResourceName\\\":\\\"江西省公安厅查询检索类服务00056\\\",\\\"visitorCode\\\":\\\"Y-120000000000-0037\\\",\\\"visitorName\\\":\\\"大数据智能服务运营平台\\\"},\\\"startTime\\\":null,\\\"taskId\\\":\\\"91540\\\",\\\"taskName\\\":\\\"科信管理员审批\\\"}\",\n" +
+                "                    \"sourceAppCode\": \"QXXT0000000000000001\",\n" +
+                "                    \"approveResult\": \"complete-agree\"\n" +
+                "                }\n" +
+                "            ],\n" +
+                "            \"infoType\": \"10000027\",\n" +
+                "            \"messageId\": \"389579be6e5f40a38bdfee19abb9d2d7\",\n" +
+                "            \"title\": \"审批系统-权限申请审批\",\n" +
+                "            \"userName\": \"审批系统\",\n" +
+                "            \"userSystem\": \"审批系统\",\n" +
+                "            \"userSystemCode\": \"Y-120000000000-0043\"\n" +
+                "        }\n" +
+                "    ],\n" +
+                "    \"topic\": \"10000027\"\n" +
+                "}";
+        JSONObject result = JSON.parseObject(value);
+        JSONArray messages = result.getJSONArray("messages");
+        JSONObject jsonObject = messages.getJSONObject(0);
+        String info = jsonObject.getJSONArray("infoSet").toJSONString();
+        return JSON.parseObject(info, new TypeReference<List<Map<String, String>>>(){{}});
+    }
+
+
+    private void dealAuthCenterAuthFlow(String messageId, WorkFlowResutlAcceptDTO dto) {
+        //历史服务授权消息处理
+        if(!messageId.contains(StrUtil.COLON)) {
+            serviceAuthBusiness.dealAuthFlowResult(dto);
+        } else {
+            String[] arr = messageId.split(StrUtil.COLON);
+            String workFlowType = arr[1];
+            //处理服务授权结果
+            if(AuthApplyTypeEnum.APP_FUN_AUTH.getValue().equals(workFlowType)) {
+                aprResultBusiness.dealAuthFlowResult(dto);
+            } else if(AuthApplyTypeEnum.SERVICE_AUTH.getValue().equals(workFlowType) ||
+                    AuthApplyTypeEnum.SERVICE_AUTH_CANCEL.getValue().equals(workFlowType)) {
+                //因服务授权后续需要改造
+                //TODO
+                // 改造后删除
+                serviceAuthBusiness.dealAuthFlowResult(dto);
+            }
+
+        }
+    }
+
+
+    private void dealApprovalCenterAuthFlow(WorkFlowResutlAcceptDTO resultDTO, ApprovalWorkFlowDTO approvalWorkFlowDTO) {
+        aprResultBusiness.dealApprovalFlowResult(resultDTO, approvalWorkFlowDTO);
+    }
+
+
 }
 }