Ver Fonte

Merge branch 'mazq-bug-fix-0816' into 'release/v2.4.0'

feature(机构配额角色数量统计修改): 机构配额角色数量统计修改

See merge request dcuc-tjdsj/auth-service!108
马志强 há 3 anos atrás
pai
commit
c3a05d5da8
26 ficheiros alterados com 349 adições e 317 exclusões
  1. 0 10
      dcuc-auth-api/src/main/java/com/dragoninfo/dcuc/auth/auth/facade/IAuthApplyFacade.java
  2. 8 0
      dcuc-auth-api/src/main/java/com/dragoninfo/dcuc/auth/power/facade/IApplicationInfoFacade.java
  3. 6 1
      dcuc-auth-model/src/main/java/com/dragoninfo/dcuc/auth/auth/dto/AppFunApplyUpdateDTO.java
  4. 5 0
      dcuc-auth-model/src/main/java/com/dragoninfo/dcuc/auth/auth/dto/AppFunAuthApplyDTO.java
  5. 9 0
      dcuc-auth-model/src/main/java/com/dragoninfo/dcuc/auth/auth/dto/AppFunAuthResourceDTO.java
  6. 10 0
      dcuc-auth-model/src/main/java/com/dragoninfo/dcuc/auth/auth/dto/FunApplyDetailDTO.java
  7. 4 0
      dcuc-auth-model/src/main/java/com/dragoninfo/dcuc/auth/auth/entity/AppFunApplyContent.java
  8. 1 1
      dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/audit/service/log/DataAuthLogHandler.java
  9. 1 1
      dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/audit/service/log/FunAuthLogHandler.java
  10. 1 1
      dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/audit/service/log/ServiceAuthLogHandler.java
  11. 6 2
      dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/auth/bpo/RoleInfoBPO.java
  12. 0 8
      dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/auth/business/IAuthApplyBusiness.java
  13. 168 137
      dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/auth/business/impl/AuthApplyBusiness.java
  14. 5 0
      dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/auth/facade/ApplicationInfoFacade.java
  15. 0 5
      dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/auth/facade/AuthApplyFacade.java
  16. 7 2
      dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/auth/service/IAppFunAuthApplyService.java
  17. 1 0
      dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/auth/service/IApplicationInfoService.java
  18. 0 9
      dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/auth/service/IWorkFlowService.java
  19. 37 52
      dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/auth/service/impl/AppFunAuthApplyServiceImpl.java
  20. 46 59
      dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/auth/service/impl/AppFunAuthResultServiceImpl.java
  21. 10 1
      dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/auth/service/impl/ApplicationInfoService.java
  22. 2 2
      dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/auth/service/impl/DataAuthServiceImpl.java
  23. 15 10
      dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/auth/service/impl/RoleService.java
  24. 0 16
      dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/auth/service/impl/WorkFlowServiceImpl.java
  25. 4 0
      dcuc-auth-service/src/main/resources/config/mysql/V4_3_0017__AddOperate.sql
  26. 3 0
      dcuc-auth-service/src/main/resources/config/sql/V4_3_0017__AddOperate.sql

+ 0 - 10
dcuc-auth-api/src/main/java/com/dragoninfo/dcuc/auth/auth/facade/IAuthApplyFacade.java

@@ -114,14 +114,4 @@ public interface IAuthApplyFacade {
      */
     @GetMapping("getFlowDefineInfo")
     ResponseDTO<FlowDefineInfoDTO> getFlowDefineInfo(@RequestParam(value = "applyType") String applyType);
-
-    /**
-     * 功能菜单权限重复申请校验
-     * @param applicantIdcard
-     * @param applyType
-     * @return
-     */
-    @GetMapping("funAuthRepeatCheck")
-    ResponseStatus funAuthRepeatCheck(@RequestParam("applicantIdcard") String applicantIdcard,
-                                      @RequestParam("applyType") String applyType);
 }

+ 8 - 0
dcuc-auth-api/src/main/java/com/dragoninfo/dcuc/auth/power/facade/IApplicationInfoFacade.java

@@ -26,4 +26,12 @@ public interface IApplicationInfoFacade {
     //DTO待设计
     @PostMapping(value = "addCountInfo")
     List<ApplicationInfoVO> addCountInfo(@RequestBody List<ApplicationInfoVO> apps);
+
+    /**
+     *
+     * @param apps
+     * @return
+     */
+    @PostMapping(value = "addCountInLimit")
+    List<ApplicationInfoVO> addCountInfoInLimitRole(List<ApplicationInfoVO> apps);
 }

+ 6 - 1
dcuc-auth-model/src/main/java/com/dragoninfo/dcuc/auth/auth/dto/AppFunApplyUpdateDTO.java

@@ -60,9 +60,14 @@ public class AppFunApplyUpdateDTO {
     private String operateType;
 
     /**
-     * 修改后的应用菜单和功能集合
+     * 修改后需要申请的应用菜单和功能集合
      */
     private List<AppFunAuthResourceDTO> resourceInfos;
 
+    /**
+     * 修改后的需要撤销的应用菜单和功能集合
+     */
+    private List<AppFunAuthResourceDTO> delResourceInfos;
+
 
 }

+ 5 - 0
dcuc-auth-model/src/main/java/com/dragoninfo/dcuc/auth/auth/dto/AppFunAuthApplyDTO.java

@@ -21,4 +21,9 @@ public class AppFunAuthApplyDTO {
      */
     private List<AppFunAuthResourceDTO> resourceInfos;
 
+    /**
+     * 需要撤销的应用菜单和功能集合
+     */
+    private List<AppFunAuthResourceDTO> delResourceInfos;
+
 }

+ 9 - 0
dcuc-auth-model/src/main/java/com/dragoninfo/dcuc/auth/auth/dto/AppFunAuthResourceDTO.java

@@ -19,6 +19,11 @@ public class AppFunAuthResourceDTO {
      */
     private String appName;
 
+    /**
+     * 应用code
+     */
+    private String appCode;
+
     /**
      * 功能id
      */
@@ -39,4 +44,8 @@ public class AppFunAuthResourceDTO {
      */
     private String userId;
 
+    /**
+     * 功能菜单操作类型
+     */
+    private String operateType;
 }

+ 10 - 0
dcuc-auth-model/src/main/java/com/dragoninfo/dcuc/auth/auth/dto/FunApplyDetailDTO.java

@@ -22,6 +22,16 @@ public class FunApplyDetailDTO {
      */
     private List<AppFunAuthResourceDTO> resourceInfos;
 
+    /**
+     * 申请撤销授权资源集合
+     */
+    private List<AppFunAuthResourceDTO> delResourceInfos;
+
+    /**
+     * 已通过授权的资源集合
+     */
+    private List<AppFunAuthResourceDTO> existResourceInfos;
+
     /**
      * 工作流流程图详情 由审批中心提供
      */

+ 4 - 0
dcuc-auth-model/src/main/java/com/dragoninfo/dcuc/auth/auth/entity/AppFunApplyContent.java

@@ -61,6 +61,10 @@ public class AppFunApplyContent implements LogicDeleteable,IdEntity<String> {
     @Column(name = "USER_ID")
     private String userId;
 
+    /**功能菜单操作类型*/
+    @Column(name = "OPERATE_TYPE")
+    private String operateType;
+
     /** 是否删除 */
     @Column(name = "DELETED")
     private String deleted;

+ 1 - 1
dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/audit/service/log/DataAuthLogHandler.java

@@ -200,7 +200,7 @@ public class DataAuthLogHandler {
         authenticationLogDto.setRequesterId(dataItemsCheckDto.getCurrentAppCode());
         authenticationLogDto.setRequesterName(app.getApplyName());
 
-        authenticationLogDto.setTerminalId(ip.replaceAll("\\.",""));
+        authenticationLogDto.setTerminalId(ip);
         authenticationLogDto.setUserToken(userToken);
         authenticationLogDto.setUserOrgCode(userInfo.getOrgCode());
         authenticationLogDto.setUserOrgName(userInfo.getOrgName());

+ 1 - 1
dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/audit/service/log/FunAuthLogHandler.java

@@ -66,7 +66,7 @@ public class FunAuthLogHandler {
         authenticationLogDto.setAuthenticationType(AuthenticationTypeEnum.GNJJQ.getValue());
         authenticationLogDto.setState(state.getValue());
         authenticationLogDto.setContent(contentDtos);
-        authenticationLogDto.setTerminalId(ip.replaceAll("\\.",""));
+        authenticationLogDto.setTerminalId(ip);
         authenticationLogDto.setUserToken(userToken);
         authenticationLogDto.setUserOrgCode(userInfo.getOrgCode());
         authenticationLogDto.setUserOrgName(userInfo.getOrgName());

+ 1 - 1
dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/audit/service/log/ServiceAuthLogHandler.java

@@ -109,7 +109,7 @@ public class ServiceAuthLogHandler {
         authenticationLogDto.setAuthenticationType(AuthenticationTypeEnum.FWJJQ.getValue());
         authenticationLogDto.setState(state.getValue());
         authenticationLogDto.setContent(contentDtos);
-        authenticationLogDto.setTerminalId(ip.replaceAll("\\.",""));
+        authenticationLogDto.setTerminalId(ip);
         authenticationLogDto.setUserToken(userToken);
         authenticationLogDto.setAppToken(appToken);
         authenticationLogDto.setUserOrgCode(userInfo.getOrgCode());

+ 6 - 2
dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/auth/bpo/RoleInfoBPO.java

@@ -291,8 +291,12 @@ public class RoleInfoBPO extends BaseBPO<RoleInfo, String> {
         return PersistentFactory.getJdbcDao().paging(sql.toString(), searchable, RoleInfoVO.class, params.toArray());
     }
 
-    public List<CountVO> getRoleCount(String appIds) {
-        String sql = "SELECT new com.dragoninfo.dcuc.auth.auth.vo.CountVO(appId as id,count(appId) as item,sum(initNumber) as item2) from RoleInfo where isNotLimitCount = '1' and appId in (" + appIds + ") group by appId";
+    public List<CountVO> getRoleCount(String appIds, boolean countLimitRole) {
+        String sql = "SELECT new com.dragoninfo.dcuc.auth.auth.vo.CountVO(appId as id,count(appId) as item,sum(initNumber) as item2) from RoleInfo where ";
+                if(countLimitRole) {
+                   sql+= "isNotLimitCount = '1' and ";
+                }
+               sql+= "appId in (" + appIds + ") group by appId";
         return PersistentFactory.getHibernateDao().find(sql);
     }
 }

+ 0 - 8
dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/auth/business/IAuthApplyBusiness.java

@@ -105,12 +105,4 @@ public interface IAuthApplyBusiness {
      * @return
      */
     ResponseDTO<FlowDefineInfoDTO> getFlowDefineInfo(String applyType);
-
-    /**
-     * 功能菜单权限重复申请校验
-     * @param applicantIdcard
-     * @param applyType
-     * @return
-     */
-    ResponseStatus funAuthRepeatCheck(String applicantIdcard, String applyType);
 }

+ 168 - 137
dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/auth/business/impl/AuthApplyBusiness.java

@@ -12,6 +12,7 @@ import com.dragoninfo.dcuc.auth.auth.constance.AuthFlowOpeCons;
 import com.dragoninfo.dcuc.auth.auth.dto.*;
 import com.dragoninfo.dcuc.auth.auth.entity.AppFunApplyContent;
 import com.dragoninfo.dcuc.auth.auth.entity.AppFunAuthResult;
+import com.dragoninfo.dcuc.auth.auth.entity.AppFunInfo;
 import com.dragoninfo.dcuc.auth.auth.entity.WorkFlow;
 import com.dragoninfo.dcuc.auth.auth.enumresources.WorkFlowPermissionTypeEnum;
 import com.dragoninfo.dcuc.auth.auth.enumresources.WorkFlowStatusEnum;
@@ -32,6 +33,7 @@ import com.dragoninfo.dcuc.common.entity.ApiSearchReq;
 import com.dragoninfo.dcuc.common.entity.SearchParam;
 import com.dragoninfo.dcuc.common.http.HttpUtil;
 import com.dragoninfo.dcuc.duceap.enums.AuthApplyTypeEnum;
+import com.dragoninfo.dcuc.duceap.enums.AuthorizeTypeEnum;
 import com.dragoninfo.dcuc.duceap.enums.SelfAuthApplyTypeEnum;
 import com.dragoninfo.duceap.core.response.Result;
 import com.dragonsoft.duceap.base.entity.http.ResponseDTO;
@@ -71,8 +73,7 @@ import java.util.stream.Collectors;
  */
 @Slf4j
 @Component
-public class AuthApplyBusiness implements IAuthApplyBusiness
-{
+public class AuthApplyBusiness implements IAuthApplyBusiness {
 
     @Autowired
     private DcucAuthConfig authConfig;
@@ -98,14 +99,23 @@ public class AuthApplyBusiness implements IAuthApplyBusiness
     @Autowired
     private IAppFunInfoService appFunInfoService;
 
+
     @Override
     public ResponseStatus funApplySave(AppFunAuthApplyDTO authApplyDTO) {
         WorkFlowDTO workFlowDTO = authApplyDTO.getWorkFlow();
         String applicantIdcard = workFlowDTO.getApplicantIdcard();
+        List<AppFunAuthResourceDTO> resourceInfos = authApplyDTO.getResourceInfos();
+        List<AppFunAuthResourceDTO> delResourceInfos = authApplyDTO.getDelResourceInfos();
+
         AuthUserInfo userInfo = userInfoService.findByIdcard(applicantIdcard);
         if(null == userInfo) {
             return ResponseStatus.fail("用户身份证号错误");
         }
+        if(CollectionUtils.isEmpty(resourceInfos) && CollectionUtils.isEmpty(delResourceInfos)) {
+            return ResponseStatus.fail("申请单内容为空");
+        }
+        List<AppFunAuthResourceDTO> list = fillResourceInfo(resourceInfos, delResourceInfos, userInfo);
+
         workFlowDTO.setUserId(userInfo.getId());
         String applyType = AuthApplyTypeEnum.APP_FUN_AUTH.getValue();
         String operateType = workFlowDTO.getOperateType();
@@ -120,14 +130,14 @@ public class AuthApplyBusiness implements IAuthApplyBusiness
 
         //保存工单
         WorkFlow workFlow = workFlowService.saveWorkFlow(workFlowDTO);
-        List<AppFunAuthResourceDTO> authResources = authApplyDTO.getResourceInfos();
+
         //保存授权相关信息
-        authResources.forEach(e->e.setUserId(userInfo.getId()));
-        List<AppFunApplyContent> contentList = funAuthApplyService.saveAuthApplyDetail(workFlow, authResources);
+        funAuthApplyService.saveAuthApplyDetail(workFlow, list);
+
         String url = authConfig.getApprovalCenterUrl();
         String api = ApprovalApiConstance.APPROVAL_CREATE_API;
         url = Joiner.on("").join(url, api);
-        ResponseDTO status = funApplyPushToApproval(url, authApplyDTO, contentList);
+        ResponseDTO status = funApplyPushToApproval(url, authApplyDTO, list);
         //推送不成功删除工单
         if(!ResponseStatus.SUCCESS_CODE.equals(status.getStatusCode())){
             workFlowService.delById(workFlow.getId());
@@ -140,6 +150,55 @@ public class AuthApplyBusiness implements IAuthApplyBusiness
 
     }
 
+    private List<AppFunAuthResourceDTO> fillResourceInfo(List<AppFunAuthResourceDTO> resourceInfos,
+                                                         List<AppFunAuthResourceDTO> delResourceInfos,
+                                                         AuthUserInfo userInfo) {
+        resourceInfos.forEach(e->{
+            e.setUserId(userInfo.getId());
+            e.setOperateType(AuthorizeTypeEnum.GNSQ.getValue());
+        });
+        delResourceInfos.forEach(e->{
+            e.setUserId(userInfo.getId());
+            e.setOperateType(AuthorizeTypeEnum.GNXQ.getValue());
+        });
+        List<AppFunAuthResourceDTO> list = new ArrayList<>();
+        list.addAll(resourceInfos);
+        list.addAll(delResourceInfos);
+        setAppNameAndFunName(list);
+        return list;
+    }
+
+    private void setAppNameAndFunName(List<AppFunAuthResourceDTO> list) {
+        List<String> appIds = list.stream()
+                .map(AppFunAuthResourceDTO::getAppId)
+                .distinct()
+                .collect(Collectors.toList());
+        for (AppFunAuthResourceDTO resourceDTO : list) {
+            List<ApplyInfo> appList = applyInfoFacade.getAppById(appIds);
+            Map<String, ApplyInfo> appIdMap = appList
+                    .stream()
+                    .collect(Collectors.toMap(ApplyInfo::getId, item -> item, (old, last) -> last));
+            List<AppFunInfo> funInfos = appFunInfoService.getByAppIds(appIds);
+            Map<String, AppFunInfo> funInfoMap = funInfos
+                    .stream()
+                    .collect(Collectors.toMap(AppFunInfo::getId, item -> item, (old, last) -> last));
+            String appId = resourceDTO.getAppId();
+            ApplyInfo applyInfo = appIdMap.get(appId);
+            if(null == applyInfo) {
+                continue;
+            }
+            String funId = resourceDTO.getFunId();
+            AppFunInfo funInfo = funInfoMap.get(funId);
+            if(null == funInfo) {
+                continue;
+            }
+            resourceDTO.setAppCode(applyInfo.getApplyCode());
+            resourceDTO.setAppName(applyInfo.getApplyName());
+            resourceDTO.setFunCode(funInfo.getCode());
+            resourceDTO.setFunName(funInfo.getName());
+        }
+    }
+
     @Override
     public Page<WorkFlowPageViewDTO> authApplySearch(SearchDTO searchDTO) {
         Searchable searchable = Searchable.toSearchable(searchDTO);
@@ -477,16 +536,6 @@ public class AuthApplyBusiness implements IAuthApplyBusiness
         return ResponseDTO.success(ResponseStatus.SUCCESS_CODE, dto);
     }
 
-    @Override
-    public ResponseStatus funAuthRepeatCheck(String applicantIdcard, String applyType) {
-        List<WorkFlow> flows = workFlowService.getApplicantWorkFlow(applicantIdcard, applyType, WorkFlowStatusEnum.APPLYING.getValue());
-        if (CollectionUtils.isEmpty(flows)) {
-            return ResponseStatus.success();
-        }
-        String orderNums = flows.stream().map(WorkFlow::getApplicantOrdNo).collect(Collectors.joining(","));
-        return ResponseStatus.fail(orderNums);
-    }
-
     private String getApprovalUrl(String applyOrdNo, String approvalApi) {
         String url = authConfig.getApprovalCenterUrl();
         approvalApi = approvalApi.replace("{approveNo}", applyOrdNo);
@@ -542,9 +591,42 @@ public class AuthApplyBusiness implements IAuthApplyBusiness
             AppFunAuthResourceDTO resourceDTO = new AppFunAuthResourceDTO();
             resourceDTO.setAppId(item.getAppId());
             resourceDTO.setFunId(item.getFunId());
+            resourceDTO.setOperateType(item.getOperateType());
             return resourceDTO;
         }).collect(Collectors.toList());
         detailDTO.setResourceInfos(collect);
+
+        //查询授权申请已通过的功能菜单
+        List<AppFunAuthResult> authResults = funAuthResultService.getAppFunAuthResults(contentList.get(0).getUserId());
+        Set<String> existFunIds = authResults.stream().map(AppFunAuthResult::getFunId).collect(Collectors.toSet());
+
+        Map<String, List<AppFunAuthResourceDTO>> map = collect
+                .stream()
+                .collect(Collectors.groupingBy(AppFunAuthResourceDTO::getOperateType));
+        List<AppFunAuthResourceDTO> addList = map.get(AuthorizeTypeEnum.GNSQ.getValue());
+        List<AppFunAuthResourceDTO> delList = map.get(AuthorizeTypeEnum.GNXQ.getValue());
+
+        //前端要求返回空数组
+        if(CollectionUtils.isNotEmpty(addList)) {
+            addList = addList.stream().filter(e->!existFunIds.contains(e.getFunId())).collect(Collectors.toList());
+            detailDTO.setResourceInfos(addList);
+        } else {
+            detailDTO.setResourceInfos(new ArrayList<>());
+        }
+
+        if(CollectionUtils.isNotEmpty(delList)) {
+            delList = delList.stream().filter(e->existFunIds.contains(e.getFunId())).collect(Collectors.toList());
+            detailDTO.setDelResourceInfos(delList);
+        } else {
+            detailDTO.setDelResourceInfos(new ArrayList<>());
+        }
+        List<AppFunAuthResourceDTO> existList = authResults.stream().map(e -> {
+            AppFunAuthResourceDTO resourceDTO = new AppFunAuthResourceDTO();
+            resourceDTO.setAppId(e.getAppId());
+            resourceDTO.setFunId(e.getFunId());
+            return resourceDTO;
+        }).collect(Collectors.toList());
+        detailDTO.setExistResourceInfos(existList);
         return detailDTO;
     }
 
@@ -562,6 +644,15 @@ public class AuthApplyBusiness implements IAuthApplyBusiness
             return ResponseStatus.fail("用户身份证号错误");
         }
 
+        List<AppFunAuthResourceDTO> resourceInfos = updateDTO.getResourceInfos();
+        List<AppFunAuthResourceDTO> delResourceInfos = updateDTO.getDelResourceInfos();
+        if(CollectionUtils.isEmpty(resourceInfos) && CollectionUtils.isEmpty(delResourceInfos)) {
+            return ResponseStatus.fail("申请单内容为空");
+        }
+
+        List<AppFunAuthResourceDTO> updateList = fillResourceInfo(resourceInfos, delResourceInfos, userInfo);
+
+
         workFlow.setApplicantPhoneNo(updateDTO.getApplicantPhoneNo());
         workFlow.setFlowContent(updateDTO.getFlowContent());
         workFlow.setApplyReason(updateDTO.getApplyReason());
@@ -580,169 +671,109 @@ public class AuthApplyBusiness implements IAuthApplyBusiness
         } else {
             workFlow.setFlowStatus(WorkFlowStatusEnum.APPLYING.getValue());
         }
-        //更新工单
-        workFlowService.update(workFlow);
-
-        //更新申请内容
-        List<AppFunAuthResourceDTO> resourceInfos = updateDTO.getResourceInfos();
-        List<AppFunApplyContent> existContent = funAuthApplyService.getByAuthApplyId(workFlow.getId());
-        Set<String> existFunIds = existContent.stream()
-                .map(AppFunApplyContent::getFunId)
-                .collect(Collectors.toSet());
-        List<AppFunAuthResourceDTO> addList = resourceInfos.stream()
-                .filter(item -> !existFunIds.contains(item.getFunId())).collect(Collectors.toList());
-        addList.forEach(e->e.setUserId(userInfo.getId()));
-        List<AppFunApplyContent> addContentList = funAuthApplyService.saveAuthApplyDetail(workFlow, addList);
-        Set<String> updateFunIds = resourceInfos.stream()
-                .map(AppFunAuthResourceDTO::getFunId)
-                .collect(Collectors.toSet());
-        List<AppFunApplyContent> delList = existContent.stream()
-                .filter(item -> !updateFunIds.contains(item.getFunId()))
-                .collect(Collectors.toList());
-        funAuthApplyService.batchDel(delList);
-
         AppFunAuthApplyDTO appFunAuthApplyDTO = new AppFunAuthApplyDTO();
         WorkFlowDTO workFlowDTO = new WorkFlowDTO();
         BeanUtils.copyProperties(workFlow, workFlowDTO);
         workFlowDTO.setUserId(userInfo.getId());
         appFunAuthApplyDTO.setWorkFlow(workFlowDTO);
-        appFunAuthApplyDTO.setResourceInfos(resourceInfos);
-        getUpdateContent(existContent, addContentList, delList);
+        appFunAuthApplyDTO.setResourceInfos(updateList);
         String url = authConfig.getApprovalCenterUrl();
         String api = ApprovalApiConstance.APPROVAL_UPDATE_API;
         url = Joiner.on("").join(url, api);
-        return funApplyPushToApproval(url, appFunAuthApplyDTO, addContentList);
-    }
 
-    private void getUpdateContent(List<AppFunApplyContent> existContent, List<AppFunApplyContent> addContentList, List<AppFunApplyContent> delList) {
-        Set<String> delIdsSet = delList
-                .stream()
-                .map(AppFunApplyContent::getId)
-                .collect(Collectors.toSet());
-        List<AppFunApplyContent> updateContent = existContent
-                .stream()
-                .filter(item -> !delIdsSet.contains(item.getId()))
-                .collect(Collectors.toList());
-        addContentList.addAll(updateContent);
-    }
+        ResponseDTO responseDTO = funApplyPushToApproval(url, appFunAuthApplyDTO, updateList);
+        if(ResponseStatus.SUCCESS_CODE.equals(responseDTO.getStatusCode())){
+            //更新工单
+            workFlowService.update(workFlow);
+            //更新申请内容
+            funAuthApplyService.updateAuthApplyDetail(workFlow, updateList);
+            return ResponseStatus.success();
+        } else {
+            return ResponseStatus.fail("推送审批失败");
+        }
 
+    }
 
-    private ResponseDTO funApplyPushToApproval(String url, AppFunAuthApplyDTO authApplyDTO, List<AppFunApplyContent> contentList) {
+    private ResponseDTO funApplyPushToApproval(String url, AppFunAuthApplyDTO authApplyDTO, List<AppFunAuthResourceDTO> contentList) {
         ApprovalWorkFlowDTO approvalWorkFlowDTO = prepareFunApplyApprovalWorkFlow(authApplyDTO, contentList);
         return dealPush(url, approvalWorkFlowDTO);
     }
 
-    private ApprovalWorkFlowDTO prepareFunApplyApprovalWorkFlow(AppFunAuthApplyDTO authApplyDTO, List<AppFunApplyContent> contentList) {
+    private ApprovalWorkFlowDTO prepareFunApplyApprovalWorkFlow(AppFunAuthApplyDTO authApplyDTO, List<AppFunAuthResourceDTO> contentList) {
         WorkFlowDTO workFlowDTO = authApplyDTO.getWorkFlow();
         ApprovalWorkFlowDTO approvalWorkFlowDTO = new ApprovalWorkFlowDTO();
         BeanUtils.copyProperties(workFlowDTO, approvalWorkFlowDTO, "resourceInfoDTO", "startTime", "endTime");
         setDifferentField(workFlowDTO, approvalWorkFlowDTO);
-        setResourceInfo(workFlowDTO.getUserId(), authApplyDTO, contentList, approvalWorkFlowDTO);
+        setResourceInfo(authApplyDTO, contentList, approvalWorkFlowDTO);
         WorkFlowTimeUtil.setApprovalSETime(workFlowDTO, approvalWorkFlowDTO);
         approvalWorkFlowDTO.setBusinessCode(approvalConfig.getFunAuthBusCode());
         approvalWorkFlowDTO.setProcessType(approvalConfig.getAuthProcessType());
         return approvalWorkFlowDTO;
     }
 
-    private void setResourceInfo(String userId, AppFunAuthApplyDTO authApplyDTO, List<AppFunApplyContent> contentList, ApprovalWorkFlowDTO approvalWorkFlowDTO) {
+    private void setResourceInfo(AppFunAuthApplyDTO authApplyDTO, List<AppFunAuthResourceDTO> contentList, ApprovalWorkFlowDTO approvalWorkFlowDTO) {
         String applicantIdcard = authApplyDTO.getWorkFlow().getApplicantIdcard();
         String applicantName = authApplyDTO.getWorkFlow().getApplicantName();
         ResourceInfoDTO resourceInfoDTO = new ResourceInfoDTO();
         resourceInfoDTO.setVisitorName(applicantName);
         resourceInfoDTO.setVisitorCode(applicantIdcard);
-        List<AppFunAuthResult> exist = funAuthResultService.getAppFunAuthResults(userId);
         //拼接funCodes和appCode成json数组
-        setAddResourceInfo(contentList, exist,resourceInfoDTO);
-        //已有授权结果的自助授权相比获得哪些功能菜单权限需要撤销
-        setRemoveResourceInfo(contentList, exist,resourceInfoDTO);
+        setAddAndCancelResourceInfo(contentList, resourceInfoDTO);
         approvalWorkFlowDTO.setResourceInfo(resourceInfoDTO);
     }
 
-    private void setRemoveResourceInfo(List<AppFunApplyContent> contentList, List<AppFunAuthResult> exist, ResourceInfoDTO resourceInfoDTO) {
-        Set<String> funIds = contentList.stream().map(AppFunApplyContent::getFunId).collect(Collectors.toSet());
-        List<AppFunAuthResult> delExistFuns = exist.stream().filter(e -> !funIds.contains(e.getFunId())).collect(Collectors.toList());
-        //拼接需要撤销的内容
-        if(CollectionUtils.isNotEmpty(delExistFuns)) {
-            List<String> delFunIds = delExistFuns.stream().map(AppFunAuthResult::getFunId).collect(Collectors.toList());
-            List<String> delAppIds = delExistFuns.stream().map(AppFunAuthResult::getAppId).collect(Collectors.toList());
-            List<ApplyInfo> appInfos = applyInfoFacade.getAppById(delAppIds);
-            Map<String, ApplyInfo> applyInfoMap = appInfos.stream()
-                    .collect(Collectors.toMap(ApplyInfo::getId, e -> e));
-            List<AppFunInfoDTO> funInfos = appFunInfoService.getByIds(delFunIds);
-            Map<String, AppFunInfoDTO> funInfoDTOMap = funInfos.stream()
-                    .collect(Collectors.toMap(AppFunInfoDTO::getId, e -> e));
-            Map<String, List<AppFunAuthResult>> delMap = delExistFuns.stream()
-                    .collect(Collectors.groupingBy(AppFunAuthResult::getAppId));
-            JSONArray delCodeArray = new JSONArray();
-            JSONArray delNameArray = new JSONArray();
-            for (Map.Entry<String, List<AppFunAuthResult>> entry : delMap.entrySet()) {
-                String appId = entry.getKey();
-                List<AppFunAuthResult> value = entry.getValue();
-                ApplyInfo applyInfo = applyInfoMap.get(appId);
-                if(null == applyInfo) {
-                    continue;
-                }
+
+    private void setAddAndCancelResourceInfo(List<AppFunAuthResourceDTO> contentList, ResourceInfoDTO resourceInfoDTO) {
+        Map<String, List<AppFunAuthResourceDTO>> collect = contentList
+                .stream()
+                .collect(Collectors.groupingBy(AppFunAuthResourceDTO::getAppId));
+        JSONArray addCodeArray = new JSONArray();
+        JSONArray addNameArray = new JSONArray();
+        JSONArray delCodeArray = new JSONArray();
+        JSONArray delNameArray = new JSONArray();
+        for (Map.Entry<String, List<AppFunAuthResourceDTO>> entry : collect.entrySet()) {
+            List<AppFunAuthResourceDTO> value = entry.getValue();
+            Map<String, List<AppFunAuthResourceDTO>> operateTypeList = value
+                    .stream()
+                    .collect(Collectors.groupingBy(AppFunAuthResourceDTO::getOperateType));
+            for (Map.Entry<String, List<AppFunAuthResourceDTO>> listEntry : operateTypeList.entrySet()) {
+                List<AppFunAuthResourceDTO> list = listEntry.getValue();
+                AppFunAuthResourceDTO applyContent = list.get(0);
+                String appName = applyContent.getAppName();
+                String operateType = applyContent.getOperateType();
                 JSONObject codeJson = new JSONObject();
-                codeJson.put("appCode", applyInfo.getApplyCode());
-                List<String> funCodes = value.stream()
-                        .map(AppFunAuthResult::getFunCode)
-                        .distinct()
-                        .collect(Collectors.toList());
-                codeJson.put("functionCode", funCodes);
-                delCodeArray.add(codeJson);
                 JSONObject nameJson = new JSONObject();
-                nameJson.put("appName", applyInfo.getApplyName());
-                List<String> funNames = value.stream()
-                        .map(e -> {
-                            String funId = e.getFunId();
-                            AppFunInfoDTO appFunInfoDTO = funInfoDTOMap.get(funId);
-                            if (null == appFunInfoDTO) {
-                                return null;
-                            }
-                            return appFunInfoDTO.getName();
-                        }).filter(Objects::nonNull).filter(String::isEmpty).collect(Collectors.toList());
-                nameJson.put("functionName", funNames);
-                delNameArray.add(nameJson);
+                codeJson.put("appCode", applyContent.getAppCode());
+                nameJson.put("appName", appName);
+
+                List<String> functionCodesList = list
+                        .stream()
+                        .map(AppFunAuthResourceDTO::getFunCode)
+                        .distinct().collect(Collectors.toList());
+                codeJson.put("functionCode", functionCodesList);
+                List<String> functionNameList = list.stream()
+                        .map(AppFunAuthResourceDTO::getFunName)
+                        .collect(Collectors.toList());
+                nameJson.put("functionName", functionNameList);
+                if(AuthorizeTypeEnum.GNSQ.getValue().equals(operateType)) {
+                    addCodeArray.add(codeJson);
+                    addNameArray.add(nameJson);
+                } else {
+                    delCodeArray.add(codeJson);
+                    delNameArray.add(nameJson);
+                }
             }
+        }
+        if(addCodeArray.size() >0) {
+            resourceInfoDTO.setVisitResourceCode(addCodeArray.toJSONString());
+            resourceInfoDTO.setVisitResourceName(addNameArray.toJSONString());
+        }
+        if(delCodeArray.size() >0) {
             resourceInfoDTO.setRemoveVisitResourceCode(delCodeArray.toJSONString());
             resourceInfoDTO.setRemoveVisitResourceName(delNameArray.toJSONString());
         }
     }
 
-    private void setAddResourceInfo(List<AppFunApplyContent> contentList, List<AppFunAuthResult> exist, ResourceInfoDTO resourceInfoDTO) {
-        //推送审批将已存在的权限排除掉
-        Set<String> existFunIds = exist.stream().map(AppFunAuthResult::getFunId).collect(Collectors.toSet());
-        Map<String, List<AppFunApplyContent>> collect = contentList
-                .stream()
-                .filter(e->!existFunIds.contains(e.getFunId()))
-                .collect(Collectors.groupingBy(AppFunApplyContent::getAppId));
-        JSONArray codeArray = new JSONArray();
-        JSONArray nameArray = new JSONArray();
-        for (Map.Entry<String, List<AppFunApplyContent>> entry : collect.entrySet()) {
-            List<AppFunApplyContent> value = entry.getValue();
-            AppFunApplyContent applyContent = value.get(0);
-            JSONObject codeJson = new JSONObject();
-            codeJson.put("appCode", applyContent.getAppCode());
-            List<String> functionCodesList = value
-                    .stream()
-                    .map(AppFunApplyContent::getFunCode)
-                    .distinct().collect(Collectors.toList());
-            codeJson.put("functionCode", functionCodesList);
-            codeArray.add(codeJson);
-
-            String appName = applyContent.getAppName();
-            JSONObject nameJson = new JSONObject();
-            nameJson.put("appName", appName);
-            List<String> functionNameList = value.stream()
-                    .map(AppFunApplyContent::getFunName)
-                    .collect(Collectors.toList());
-            nameJson.put("functionName", functionNameList);
-            nameArray.add(nameJson);
-        }
-        resourceInfoDTO.setVisitResourceCode(codeArray.toJSONString());
-        resourceInfoDTO.setVisitResourceName(nameArray.toJSONString());
-    }
-
     private void setDifferentField(WorkFlowDTO workFlowDTO, ApprovalWorkFlowDTO approvalWorkFlowDTO) {
         approvalWorkFlowDTO.setApplyContent(workFlowDTO.getFlowContent());
         approvalWorkFlowDTO.setApplyAppCode(authConfig.getAppCode());

+ 5 - 0
dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/auth/facade/ApplicationInfoFacade.java

@@ -27,4 +27,9 @@ public class ApplicationInfoFacade implements IApplicationInfoFacade {
     public List<ApplicationInfoVO> addCountInfo(List<ApplicationInfoVO> apps) {
         return applicationInfoService.addCountInfo(apps);
     }
+
+    @Override
+    public List<ApplicationInfoVO> addCountInfoInLimitRole(List<ApplicationInfoVO> apps) {
+        return applicationInfoService.addCountInfoInLimitRole(apps);
+    }
 }

+ 0 - 5
dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/auth/facade/AuthApplyFacade.java

@@ -81,9 +81,4 @@ public class AuthApplyFacade implements IAuthApplyFacade {
     public ResponseDTO<FlowDefineInfoDTO> getFlowDefineInfo(String applyType) {
         return authApplyBusiness.getFlowDefineInfo(applyType);
     }
-
-    @Override
-    public ResponseStatus funAuthRepeatCheck(String applicantIdcard, String applyType) {
-        return authApplyBusiness.funAuthRepeatCheck(applicantIdcard, applyType);
-    }
 }

+ 7 - 2
dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/auth/service/IAppFunAuthApplyService.java

@@ -17,9 +17,8 @@ public interface IAppFunAuthApplyService {
      * 申请内容详细信息保存
      * @param workFlow
      * @param authResources
-     * @return
      */
-    List<AppFunApplyContent> saveAuthApplyDetail(WorkFlow workFlow, List<AppFunAuthResourceDTO> authResources);
+    void saveAuthApplyDetail(WorkFlow workFlow, List<AppFunAuthResourceDTO> authResources);
 
     /**
      * 根据工单id查询授权内容
@@ -55,4 +54,10 @@ public interface IAppFunAuthApplyService {
      */
     void batchSave(List<AppFunApplyContent> contentList);
 
+    /**
+     * 更新申请单内容
+     * @param workFlow
+     * @param updateList
+     */
+    void updateAuthApplyDetail(WorkFlow workFlow, List<AppFunAuthResourceDTO> updateList);
 }

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

@@ -13,4 +13,5 @@ public interface IApplicationInfoService {
 	 */
 	List<ApplicationInfoVO> addCountInfo(List<ApplicationInfoVO> apps);
 
+    List<ApplicationInfoVO> addCountInfoInLimitRole(List<ApplicationInfoVO> apps);
 }

+ 0 - 9
dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/auth/service/IWorkFlowService.java

@@ -67,13 +67,4 @@ public interface IWorkFlowService {
      * @return
      */
     WorkFlow getByApplyOrdNo(String applyOrdNo);
-
-    /**
-     * 获取申请人的申请单
-     * @param applicantIdcard
-     * @param applyType
-     * @param status
-     * @return
-     */
-    List<WorkFlow> getApplicantWorkFlow(String applicantIdcard, String applyType, String status);
 }

+ 37 - 52
dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/auth/service/impl/AppFunAuthApplyServiceImpl.java

@@ -1,24 +1,22 @@
 package com.dragoninfo.dcuc.auth.auth.service.impl;
 
-import com.dragoninfo.dcuc.app.entity.ApplyInfo;
-import com.dragoninfo.dcuc.app.facade.IApplyInfoFacade;
 import com.dragoninfo.dcuc.auth.auth.dto.AppFunAuthResourceDTO;
 import com.dragoninfo.dcuc.auth.auth.entity.AppFunApplyContent;
-import com.dragoninfo.dcuc.auth.auth.entity.AppFunInfo;
 import com.dragoninfo.dcuc.auth.auth.entity.WorkFlow;
 import com.dragoninfo.dcuc.auth.auth.repo.AppFunApplyContentRepository;
 import com.dragoninfo.dcuc.auth.auth.service.IAppFunAuthApplyService;
-import com.dragoninfo.dcuc.auth.auth.service.IAppFunInfoService;
 import com.dragonsoft.duceap.base.enums.BooleanEnum;
 import com.dragonsoft.duceap.commons.util.collections.CollectionUtils;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Example;
 import org.springframework.data.jpa.domain.Specification;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Map;
+import java.util.Set;
 import java.util.stream.Collectors;
 
 /**
@@ -28,61 +26,23 @@ import java.util.stream.Collectors;
 @Service
 public class AppFunAuthApplyServiceImpl implements IAppFunAuthApplyService {
 
-    @Autowired
-    private IApplyInfoFacade applyInfoFacade;
-
-    @Autowired
-    private IAppFunInfoService appFunInfoService;
-
     @Autowired
     private AppFunApplyContentRepository applyRepository;
 
-
+    @Transactional(rollbackFor = RuntimeException.class)
     @Override
-    public List<AppFunApplyContent> saveAuthApplyDetail(WorkFlow workFlow, List<AppFunAuthResourceDTO> authResources) {
-        List<AppFunApplyContent> contentList = new ArrayList<>();
+    public void saveAuthApplyDetail(WorkFlow workFlow, List<AppFunAuthResourceDTO> authResources) {
         if(CollectionUtils.isEmpty(authResources)) {
-            return contentList;
+            return ;
         }
-        List<String> appIds = authResources.stream()
-                .map(AppFunAuthResourceDTO::getAppId)
-                .distinct()
-                .collect(Collectors.toList());
-        List<ApplyInfo> appList = applyInfoFacade.getAppById(appIds);
-        Map<String, ApplyInfo> appIdMap = appList
-                .stream()
-                .collect(Collectors.toMap(ApplyInfo::getId, item -> item, (old, last) -> last));
-        List<AppFunInfo> funInfos = appFunInfoService.getByAppIds(appIds);
-        Map<String, AppFunInfo> funInfoMap = funInfos
-                .stream()
-                .collect(Collectors.toMap(AppFunInfo::getId, item -> item, (old, last) -> last));
-
-        for (AppFunAuthResourceDTO resourceDTO : authResources) {
-            String appId = resourceDTO.getAppId();
-            ApplyInfo applyInfo = appIdMap.get(appId);
-            if(null == applyInfo) {
-                continue;
-            }
-            String funId = resourceDTO.getFunId();
-            AppFunInfo funInfo = funInfoMap.get(funId);
-            if(null == funInfo) {
-                continue;
-            }
+        List<AppFunApplyContent> collect = authResources.stream().map(e -> {
             AppFunApplyContent applyContent = new AppFunApplyContent();
-            applyContent.setAppId(appId);
-            applyContent.setAppCode(applyInfo.getApplyCode());
-            applyContent.setAppName(applyInfo.getApplyName());
-            applyContent.setFunId(funId);
-            applyContent.setFunCode(funInfo.getCode());
-            applyContent.setFunName(funInfo.getName());
-            applyContent.setAuthApplyId(workFlow.getId());
+            BeanUtils.copyProperties(e, applyContent);
             applyContent.setDeleted(BooleanEnum.FALSE.value);
-            applyContent.setUserId(resourceDTO.getUserId());
-
-            applyRepository.save(applyContent);
-            contentList.add(applyContent);
-        }
-        return contentList;
+            applyContent.setAuthApplyId(workFlow.getId());
+            return applyContent;
+        }).collect(Collectors.toList());
+        applyRepository.saveAll(collect);
     }
 
     @Override
@@ -103,6 +63,7 @@ public class AppFunAuthApplyServiceImpl implements IAppFunAuthApplyService {
         return applyRepository.findAll(specification);
     }
 
+    @Transactional(rollbackFor = RuntimeException.class)
     @Override
     public void batchDel(List<AppFunApplyContent> delList) {
         applyRepository.deleteInBatch(delList);
@@ -118,4 +79,28 @@ public class AppFunAuthApplyServiceImpl implements IAppFunAuthApplyService {
     public void batchSave(List<AppFunApplyContent> contentList) {
         applyRepository.saveAll(contentList);
     }
+
+    @Transactional(rollbackFor = RuntimeException.class)
+    @Override
+    public void updateAuthApplyDetail(WorkFlow workFlow, List<AppFunAuthResourceDTO> updateList) {
+        if(CollectionUtils.isEmpty(updateList)) {
+            return ;
+        }
+        List<AppFunApplyContent> applyContents = getByAuthApplyId(workFlow.getId());
+        Set<String> existSet = applyContents.stream()
+                .map(AppFunApplyContent::getFunId)
+                .collect(Collectors.toSet());
+        List<AppFunAuthResourceDTO> addList = updateList.stream()
+                .filter(e -> !existSet.contains(e.getFunId()))
+                .collect(Collectors.toList());
+        Set<String> updateSet = updateList
+                .stream()
+                .map(AppFunAuthResourceDTO::getFunId)
+                .collect(Collectors.toSet());
+        List<AppFunApplyContent> delList = applyContents.stream()
+                .filter(e -> !updateSet.contains(e.getFunId()))
+                .collect(Collectors.toList());
+        saveAuthApplyDetail(workFlow, addList);
+        batchDel(delList);
+    }
 }

+ 46 - 59
dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/auth/service/impl/AppFunAuthResultServiceImpl.java

@@ -8,6 +8,7 @@ import com.dragoninfo.dcuc.auth.auth.enumresources.WorkFlowPermissionTypeEnum;
 import com.dragoninfo.dcuc.auth.auth.enumresources.WorkFlowStatusEnum;
 import com.dragoninfo.dcuc.auth.auth.repo.AppFunAuthResultRepository;
 import com.dragoninfo.dcuc.auth.auth.service.IAppFunAuthResultService;
+import com.dragoninfo.dcuc.duceap.enums.AuthorizeTypeEnum;
 import com.dragonsoft.duceap.base.enums.BooleanEnum;
 import com.dragonsoft.duceap.commons.util.collections.CollectionUtils;
 import com.dragonsoft.duceap.commons.util.string.StringUtils;
@@ -17,10 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Example;
 import org.springframework.stereotype.Service;
 
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -38,8 +36,13 @@ public class AppFunAuthResultServiceImpl implements IAppFunAuthResultService {
         if(WorkFlowStatusEnum.SUCCESS.getValue().equals(flow.getFlowStatus())) {
             List<AppFunAuthResult> exist = getAppFunAuthResults(applyInfos.get(0).getUserId());
             //因为每次申请都包括已存在的功能,每次审批通过还要删除没被选中的功能
-            approvalResult(flow, applyInfos , exist);
-            cancelResult(flow, applyInfos, exist);
+            Map<String, List<AppFunApplyContent>> collect = applyInfos
+                    .stream()
+                    .collect(Collectors.groupingBy(AppFunApplyContent::getOperateType));
+            List<AppFunApplyContent> addList = collect.get(AuthorizeTypeEnum.GNSQ.getValue());
+            List<AppFunApplyContent> delList = collect.get(AuthorizeTypeEnum.GNXQ.getValue());
+            addResult(flow, addList , exist);
+            cancelResult(flow, delList, exist);
 
         }
     }
@@ -52,61 +55,50 @@ public class AppFunAuthResultServiceImpl implements IAppFunAuthResultService {
         return getResultList(searchable);
     }
 
-    private void cancelResult(WorkFlow flow, List<AppFunApplyContent> applyInfos, List<AppFunAuthResult> exist) {
-        List<String> applyFunIds = applyInfos.stream()
+    private void cancelResult(WorkFlow flow, List<AppFunApplyContent> delList, List<AppFunAuthResult> exist) {
+        if(CollectionUtils.isEmpty(delList)) {
+            return;
+        }
+        Set<String> delFunIds = delList.stream()
                 .map(AppFunApplyContent::getFunId)
-                .distinct()
-                .collect(Collectors.toList());
-        delAuthExist(flow, exist, applyFunIds);
-
-    }
-
-    private void delAuthExist(WorkFlow flow, List<AppFunAuthResult> exist, List<String> applyFunIds) {
+                .collect(Collectors.toSet());
         List<AppFunAuthResult> delResultList = exist
                 .stream()
-                .filter(item -> {
-                    String funId = item.getFunId();
-                    return !applyFunIds.contains(funId);
-                }).collect(Collectors.toList());
+                .filter(e -> delFunIds.contains(e.getFunId())).collect(Collectors.toList());
         authResultRepository.deleteInBatch(delResultList);
     }
 
-    private void approvalResult(WorkFlow flow, List<AppFunApplyContent> applyInfos, List<AppFunAuthResult> exist) {
-        if(CollectionUtils.isEmpty(applyInfos)) {
+    private void addResult(WorkFlow flow, List<AppFunApplyContent> addList, List<AppFunAuthResult> exist) {
+        if(CollectionUtils.isEmpty(addList)) {
             return;
         }
         Map<String, AppFunAuthResult> resultMap = exist.stream()
                 .collect(Collectors.toMap(AppFunAuthResult::getFunId, item -> item, (old, last) -> last));
-        for (AppFunApplyContent applyInfo : applyInfos) {
-            addAuthApply(flow, applyInfo, resultMap);
-        }
-
-    }
-
-
-    private void addAuthApply(WorkFlow flow, AppFunApplyContent applyInfo, Map<String, AppFunAuthResult> resultMap) {
-        Set<String> existFunIds = resultMap.keySet();
-        String userId = applyInfo.getUserId();
-        String appId = applyInfo.getAppId();
-        Date startTime = null;
-        Date endTime = null;
-        Date date = new Date();
-        String authStatus = AuthStatusEnum.START.getValue();
-        String permissionValidType = flow.getPermissionValidType();
-        if (StringUtils.isNotBlank(permissionValidType)
-                && WorkFlowPermissionTypeEnum.TEMP.getValue().equals(permissionValidType)) {
-            startTime = flow.getStartTime();
-            endTime = flow.getEndTime();
-            if (date.before(startTime)) {
-                authStatus = AuthStatusEnum.NOT_START.getValue();
+        List<AppFunAuthResult> addResult = new ArrayList<>();
+        for (AppFunApplyContent applyInfo : addList) {
+            if(resultMap.keySet().contains(applyInfo.getFunId())) {
+                continue;
             }
-            if (date.after(endTime)) {
-                authStatus = AuthStatusEnum.OVER_DUE.getValue();
+            String userId = applyInfo.getUserId();
+            String appId = applyInfo.getAppId();
+            Date startTime = null;
+            Date endTime = null;
+            Date date = new Date();
+            String authStatus = AuthStatusEnum.START.getValue();
+            String permissionValidType = flow.getPermissionValidType();
+            if (StringUtils.isNotBlank(permissionValidType)
+                    && WorkFlowPermissionTypeEnum.TEMP.getValue().equals(permissionValidType)) {
+                startTime = flow.getStartTime();
+                endTime = flow.getEndTime();
+                if (date.before(startTime)) {
+                    authStatus = AuthStatusEnum.NOT_START.getValue();
+                }
+                if (date.after(endTime)) {
+                    authStatus = AuthStatusEnum.OVER_DUE.getValue();
+                }
             }
-        }
-        String funId = applyInfo.getFunId();
-        String funCode = applyInfo.getFunCode();
-        if(!existFunIds.contains(funId)) {
+            String funId = applyInfo.getFunId();
+            String funCode = applyInfo.getFunCode();
             AppFunAuthResult authResult = new AppFunAuthResult();
             authResult.setAppId(appId);
             authResult.setAppCode(applyInfo.getAppCode());
@@ -118,19 +110,14 @@ public class AppFunAuthResultServiceImpl implements IAppFunAuthResultService {
             authResult.setAuthStatus(authStatus);
             authResult.setStartTime(startTime);
             authResult.setEndTime(endTime);
-            save(authResult);
-        } else {
-            AppFunAuthResult authResult = resultMap.get(funId);
-            authResult.setAuthSource(flow.getApplySource());
-            authResult.setSourceId(flow.getApplicantOrdNo());
-            authResult.setAuthStatus(authStatus);
-            authResult.setStartTime(startTime);
-            authResult.setEndTime(endTime);
-            authResultRepository.update(authResult);
+            addResult.add(authResult);
+        }
+        if(addResult.size() >0) {
+            authResultRepository.saveAll(addResult);
         }
-
     }
 
+
     @Override
     public void save(AppFunAuthResult authResult) {
         authResult.setDeleted(BooleanEnum.FALSE.value);

+ 10 - 1
dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/auth/service/impl/ApplicationInfoService.java

@@ -27,6 +27,15 @@ public class ApplicationInfoService implements IApplicationInfoService {
 
     @Override
     public List<ApplicationInfoVO> addCountInfo(List<ApplicationInfoVO> apps) {
+        return addCountInfo(apps, false);
+    }
+
+    @Override
+    public List<ApplicationInfoVO> addCountInfoInLimitRole(List<ApplicationInfoVO> apps) {
+        return addCountInfo(apps, true);
+    }
+
+    private List<ApplicationInfoVO> addCountInfo(List<ApplicationInfoVO> apps, boolean countLimitRole) {
         String appIds = "";
         if (CollectionUtils.isEmpty(apps)){
             return new ArrayList<>();
@@ -38,7 +47,7 @@ public class ApplicationInfoService implements IApplicationInfoService {
             appIds = appIds.substring(0, appIds.length() - 1);
         }
         List<CountVO> menus = appFunInfoBPO.getMenuCount(appIds);
-        List<CountVO> roles = roleInfoBPO.getRoleCount(appIds);
+        List<CountVO> roles = roleInfoBPO.getRoleCount(appIds, countLimitRole);
         List<CountVO> qutos = orgQuotaAuthInfoBpo.getQutoCount(appIds);
         for (ApplicationInfoVO app : apps) {
             String appId = app.getId();

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

@@ -255,8 +255,8 @@ public class DataAuthServiceImpl implements IDataAuthService {
                 dataAuth.setInnerId(dto.getInnerId());
                 dataAuth.setDeleted(YesNotEnum.NO.getValue());
                 dataAuthBPO.save(dataAuth);
-                logInfoFillService.sendDataAuthLog(AuthResultEnum.SUC, subId, subType, addList, RequestIpUtil.getRealIp());
             }
+            logInfoFillService.sendDataAuthLog(AuthResultEnum.SUC, subId, subType, addList, RequestIpUtil.getRealIp());
         } catch (Exception e) {
             log.error("数据授权保存失败", e);
             logInfoFillService.sendDataAuthLog(AuthResultEnum.FAIL, subId, subType, addList, RequestIpUtil.getRealIp());
@@ -270,8 +270,8 @@ public class DataAuthServiceImpl implements IDataAuthService {
                 dataAuth.setDeleteTime(date);
                 dataAuth.setDeleted(BooleanEnum.TRUE.getValue());
                 dataAuthBPO.update(dataAuth);
-                logInfoFillService.sendDataDelAuthLog(AuthResultEnum.SUC,delList, RequestIpUtil.getRealIp());
             }
+            logInfoFillService.sendDataDelAuthLog(AuthResultEnum.SUC,delList, RequestIpUtil.getRealIp());
         } catch (Exception e) {
             log.error("数据授权删除失败", e);
             logInfoFillService.sendDataDelAuthLog(AuthResultEnum.FAIL,delList, RequestIpUtil.getRealIp());

+ 15 - 10
dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/auth/service/impl/RoleService.java

@@ -105,24 +105,29 @@ public class RoleService implements IRoleService {
             throw new ApplicationException("appCode does not exist");
         }
         //普通角色
+        List<String> roleRs = new ArrayList<>();
+        long startTime = System.currentTimeMillis();
         List<String> roleIds = staffAssignAuthInfoService.getRoleIds(userId, appId);
-
-        if (roleIds == null || roleIds.isEmpty()) {
-            return new ArrayList<>();
+        if(CollectionUtils.isNotEmpty(roleIds)) {
+            List<String> funsByRoles = roleFunRsRlService.getFunsByRoles(roleIds.toString());
+            if(CollectionUtils.isNotEmpty(funsByRoles)) {
+                roleRs.addAll(funsByRoles);
+            }
+            logger.info("根据角色id集合查找权限耗时:{}s , function size:{}",
+                    (System.currentTimeMillis() - startTime) / 1000,
+                    funsByRoles.size());
         }
-        long startTime = System.currentTimeMillis();
-        List<String> roleRs = roleFunRsRlService.getFunsByRoles(roleIds.toString());
-        logger.info("根据角色id集合查找权限耗时:{}s ", (System.currentTimeMillis() - startTime) / 1000);
-
-        List<AppFunAuthResult> resultList = getSelfAuthByAppCodeAndUserId(appCode, userId);
-        if (CollectionUtils.isNotEmpty(resultList)) {
+        List<AppFunAuthResult> resultList = getSelfAuthByAppCodeAndUserId(appCode,userId);
+        if(CollectionUtils.isNotEmpty(resultList)) {
             List<String> funCodes = resultList
                     .stream()
                     .map(AppFunAuthResult::getFunCode)
                     .distinct()
                     .collect(Collectors.toList());
             roleRs.addAll(funCodes);
-            logger.info("自助授权查询耗时:{}", (System.currentTimeMillis() - startTime) / 1000);
+            logger.info("自助授权查询耗时:{}, function size:{}",
+                    (System.currentTimeMillis() - startTime) / 1000,
+                    funCodes.size());
         }
         return roleRs;
     }

+ 0 - 16
dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/auth/service/impl/WorkFlowServiceImpl.java

@@ -31,12 +31,6 @@ public class WorkFlowServiceImpl implements IWorkFlowService {
     @Autowired
     private WorkFlowRepository workFlowRepository;
 
-    @Autowired
-    private DcucAuthApprovalConfig approvalConfig;
-
-    @Autowired
-    private DcucAuthConfig authConfig;
-
     @Override
     public WorkFlow saveWorkFlow(WorkFlowDTO dto) {
         WorkFlow workFlow = new WorkFlow();
@@ -96,14 +90,4 @@ public class WorkFlowServiceImpl implements IWorkFlowService {
         return workFlowRepository.findOne(example).orElse(null);
     }
 
-    @Override
-    public List<WorkFlow> getApplicantWorkFlow(String applicantIdcard, String applyType, String status) {
-        WorkFlow query = new WorkFlow();
-        query.setApplyType(applyType);
-        query.setFlowStatus(status);
-        query.setApplicantIdcard(applicantIdcard);
-        Example<WorkFlow> example = Example.of(query);
-        return workFlowRepository.findAll(example);
-    }
-
 }

+ 4 - 0
dcuc-auth-service/src/main/resources/config/mysql/V4_3_0017__AddOperate.sql

@@ -0,0 +1,4 @@
+ALTER TABLE `t_auth_app_fun_apply_content` ADD `OPERATE_TYPE` VARCHAR(32) DEFAULT NULL COMMENT '权限操作类型';
+UPDATE `t_auth_app_fun_apply_content` SET `OPERATE_TYPE` = 'GNSQ';
+
+

+ 3 - 0
dcuc-auth-service/src/main/resources/config/sql/V4_3_0017__AddOperate.sql

@@ -0,0 +1,3 @@
+ALTER TABLE "T_AUTH_APP_FUN_APPLY_CONTENT" ADD "OPERATE_TYPE" VARCHAR2(32) DEFAULT NULL;
+UPDATE "T_AUTH_APP_FUN_APPLY_CONTENT" SET "OPERATE_TYPE" = 'GNSQ';
+COMMENT ON COLUMN T_AUTH_APP_FUN_APPLY_CONTENT.OPERATE_TYPE is '权限操作类型';