|
@@ -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());
|