Эх сурвалжийг харах

feature(服务授权详情列表新增权限状态字段): 服务授权详情列表新增权限状态字段

服务授权详情列表新增权限状态字段
mazq 4 жил өмнө
parent
commit
02cda976ae

+ 11 - 1
dcuc-auth-api/src/main/java/com/dragoninfo/dcuc/auth/auth/facade/IServiceAuthFacade.java → dcuc-auth-api/src/main/java/com/dragoninfo/dcuc/auth/auth/facade/IServiceAuthFlowFacade.java

@@ -8,6 +8,7 @@ import com.dragonsoft.duceap.base.entity.http.ResponseDTO;
 import com.dragonsoft.duceap.base.entity.search.SearchDTO;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.data.domain.Page;
+import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestParam;
@@ -21,7 +22,7 @@ import java.util.Map;
  * @create 2020-11-25 14:21
  */
 @FeignClient(name = "dcuc-auth", path = "/dcuc/auth/serviceAuthFacade")
-public interface IServiceAuthFacade {
+public interface IServiceAuthFlowFacade {
 
     /**
      * 服务授权查询
@@ -68,4 +69,13 @@ public interface IServiceAuthFacade {
     @PostMapping(value = "checkApplicantId")
     boolean checkApplicantId(@RequestParam("applicantId")String applicantId);
 
+    /**
+     * 服务授权申请查询是否有重复的授权申请
+     * @param appCode
+     * @param serviceCodes
+     * @return 存在申请中的重复授权单 返回响应状态'300' 内容为重复的服务code集合
+     *         存在申请中的重复授权单 返回响应状态'200'
+     */
+    @GetMapping("authRepeatCheck")
+    ResponseDTO authFlowRepeatCheck(@RequestParam("appCode") String appCode, @RequestParam("serviceCodes") List<String> serviceCodes);
 }

+ 1 - 3
dcuc-auth-model/src/main/java/com/dragoninfo/dcuc/auth/auth/dto/ServiceAuthResultDTO.java

@@ -83,9 +83,7 @@ public class ServiceAuthResultDTO implements Serializable {
     private String serviceStatus;
 
     /**
-     * 授权状态-取决于应用和服务共同作用的状态
-     * 暂时不维护这个字段
-     * 不要使用
+     * 服务授权状态
      */
     private String authStatus;
 

+ 51 - 0
dcuc-auth-model/src/main/java/com/dragoninfo/dcuc/auth/auth/enumresources/ServiceAuthStatusEnum.java

@@ -0,0 +1,51 @@
+package com.dragoninfo.dcuc.auth.auth.enumresources;
+
+/**
+ * 服务授权结果状态枚举类
+ * @author mazq
+ * @date 2021/5/12
+ */
+public enum  ServiceAuthStatusEnum {
+
+    /**
+     * 服务授权申请审批通过后权限有效期时间未到启用时间
+     */
+    NOT_START("未到启动时间","0"),
+    /**
+     * 正常启用状态
+     */
+    START("正常","1"),
+    /**
+     * 授权被回收
+     */
+    CANCEL("回收","2"),
+    /**
+     * 权限超过有效期
+     */
+    OVER_DUE("过期","4");
+
+    private String label;
+
+    private String value;
+
+    ServiceAuthStatusEnum(String label, String value) {
+        this.label = label;
+        this.value = value;
+    }
+
+    public String getLable() {
+        return label;
+    }
+
+    public void setLable(String lable) {
+        this.label = lable;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public void setValue(String value) {
+        this.value = value;
+    }
+}

+ 5 - 0
dcuc-auth-model/src/main/java/com/dragoninfo/dcuc/auth/auth/po/ServiceAuthResultPO.java

@@ -151,4 +151,9 @@ public class ServiceAuthResultPO {
      */
     private String applicantOrgCode;
 
+    /**
+     * 服务授权状态
+     */
+    private String authStatus;
+
 }

+ 5 - 5
dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/auth/bpo/ServiceAuthResultBPO.java

@@ -67,16 +67,16 @@ public class ServiceAuthResultBPO extends BaseBPO<ServiceAuthResult,String> {
     }
 
     public Page<ServiceAuthResultPO> serviceResultPageJoinFlow(Searchable searchable) {
-        String sql = "SELECT t.app_code, t.service_code, t.create_time as auth_time,t.deleted as deleted," +
+        String sql = "SELECT t.app_code, t.service_code, t.auth_status, t.create_time as auth_time, t.deleted as deleted," +
                      "a.apply_name as app_name, a.apply_status as app_status, a.org_name as app_org_name, a.manager_org_name as app_manager_org_name," +
                      "f.applicant_name, f.applicant_org_code, f.create_time as apply_time, f.applicant_org_name, f.applicant_idcard, f.applicant_phone_no," +
                      "f.app_org_code as app_org_code, f.app_manager_org_code as app_manager_org_code," +
                      "s.service_name, s.service_status, s.build_unit as service_org_name, s.manager_unit as service_manager_org_name, " +
                      "s.manager_unit_code as service_manager_org_code, s.build_unit_code as service_org_code," +
-                     "t.app_code as appCode, t.service_code as serviceCode, a.apply_name as appName," +
-                     "a.org_name as appOrgName, f.applicant_name as applicantName, s.service_name as serviceName, s.manager_unit as serviceManagerOrgName," +
-                     "f.app_org_code as appOrgCode, a.apply_status as appStatus, a.manager_org_name as appManagerOrgName, s.service_status as serviceStatus, a.deleted as app_deleted, " +
-                     "s.manager_unit_code as serviceManagerOrgCode, s.deleted as service_deleted" +
+                     "t.app_code as appCode, t.service_code as serviceCode," +
+                     "a.org_name as appOrgName, a.apply_status as appStatus, a.manager_org_name as appManagerOrgName, a.apply_name as appName, a.deleted as app_deleted," +
+                     "f.app_org_code as appOrgCode, f.applicant_name as applicantName," +
+                     "s.service_status as serviceStatus, s.service_name as serviceName, s.manager_unit as serviceManagerOrgName, s.manager_unit_code as serviceManagerOrgCode, s.deleted as service_deleted" +
                      " FROM T_SERVICE_AUTH_RESULT t" +
                      " INNER JOIN T_SERVICE_RESOURCE s ON t.service_id = s.id" +
                      " INNER JOIN T_APPLY_INFO a ON t.app_id = a.id" +

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

@@ -25,6 +25,7 @@ import com.dragoninfo.dcuc.org.facade.IOrgInfoFacade;
 import com.dragonsoft.duceap.base.entity.http.ResponseDTO;
 import com.dragonsoft.duceap.base.entity.http.ResponseStatus;
 import com.dragonsoft.duceap.commons.util.UUIDUtils;
+import com.dragonsoft.duceap.commons.util.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.http.Header;
 import org.apache.http.message.BasicHeader;
@@ -108,6 +109,11 @@ public class ServiceAuthBusinessImpl implements IServiceAuthBusiness {
                 return ResponseDTO.fail(ResponseStatus.FAIL_CODE ,String.format("服务代码 %s 不存在", serviceCode),null);
             }
         }
+        //校验服务授权是否存在重复申请
+        List<String> exitstServiceCodes = authFlowService.authFlowRepeatCheck(dto.getAppCode(), Arrays.asList(serviceCodArray));
+        if(!CollectionUtils.isEmpty(exitstServiceCodes)) {
+            return ResponseDTO.fail(ResponseStatus.FAIL_CODE, String.format("服务授权申请中,服务code: %s ", exitstServiceCodes), exitstServiceCodes);
+        }
         String flowStatus = WorkFlowStatusEnum.APPLYING.getValue();
         //生成消息id
         dto.setMessageId(UUIDUtils.getUUID());

+ 13 - 2
dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/auth/facade/ServiceAuthFacade.java

@@ -7,10 +7,11 @@ import com.dragoninfo.dcuc.auth.auth.dto.ServiceAuthFlowDTO;
 import com.dragoninfo.dcuc.auth.auth.dto.WorkFlowResutlAcceptDTO;
 import com.dragoninfo.dcuc.auth.auth.entity.ServiceAuthResult;
 import com.dragoninfo.dcuc.auth.auth.service.IAuthFlowService;
-import com.dragoninfo.dcuc.auth.auth.service.IPermissionUpdateService;
 import com.dragoninfo.dcuc.auth.auth.service.IServiceAuthResultService;
 import com.dragonsoft.duceap.base.entity.http.ResponseDTO;
+import com.dragonsoft.duceap.base.entity.http.ResponseStatus;
 import com.dragonsoft.duceap.base.entity.search.SearchDTO;
+import com.dragonsoft.duceap.commons.util.collections.CollectionUtils;
 import com.dragonsoft.duceap.core.search.Searchable;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Page;
@@ -23,7 +24,7 @@ import java.util.Map;
 
 @RestController
 @RequestMapping(value = "/dcuc/auth/serviceAuthFacade")
-public class ServiceAuthFacade implements IServiceAuthFacade {
+public class ServiceAuthFacade implements IServiceAuthFlowFacade {
 
     @Autowired
     private IAuthFlowService authFlowService;
@@ -103,4 +104,14 @@ public class ServiceAuthFacade implements IServiceAuthFacade {
     public boolean checkApplicantId(String applicantId) {
         return authFlowService.checkApplicantId(applicantId);
     }
+
+    @Override
+    public ResponseDTO authFlowRepeatCheck(String appCode, List<String> serviceCodes) {
+        List<String> list = authFlowService.authFlowRepeatCheck(appCode, serviceCodes);
+        if(CollectionUtils.isEmpty(list)){
+            return ResponseDTO.success(ResponseStatus.SUCCESS_CODE,null);
+        }else {
+            return ResponseDTO.fail(ResponseStatus.FAIL_CODE,list);
+        }
+    }
 }

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

@@ -64,4 +64,12 @@ public interface IAuthFlowService {
      * @return
      */
     boolean checkApplicantId(String applicantId);
+
+    /**
+     * 服务授权申请查询是否有重复的授权申请
+     * @param appCode
+     * @param serviceCodes
+     * @return
+     */
+    List<String> authFlowRepeatCheck(String appCode, List<String> serviceCodes);
 }

+ 20 - 0
dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/auth/service/impl/AuthFlowServiceImpl.java

@@ -2,14 +2,17 @@ package com.dragoninfo.dcuc.auth.auth.service.impl;
 
 
 import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.util.StrUtil;
 import com.dragoninfo.dcuc.auth.auth.bpo.ServiceAuthFlowBPO;
 import com.dragoninfo.dcuc.auth.auth.dto.ServiceAuthFlowDTO;
 import com.dragoninfo.dcuc.auth.auth.entity.ServiceAuthFlow;
+import com.dragoninfo.dcuc.auth.auth.enumresources.WorkFlowStatusEnum;
 import com.dragoninfo.dcuc.auth.auth.enumresources.WorkFlowTypeEnum;
 import com.dragoninfo.dcuc.auth.auth.service.IAuthFlowService;
 import com.dragonsoft.duceap.base.enums.BooleanEnum;
 import com.dragonsoft.duceap.commons.util.collections.CollectionUtils;
 import com.dragonsoft.duceap.commons.util.json.JsonUtils;
+import com.dragonsoft.duceap.commons.util.string.StringUtils;
 import com.dragonsoft.duceap.core.entity.page.PageImpl;
 import com.dragonsoft.duceap.core.entity.page.PageRequest;
 import com.dragonsoft.duceap.core.search.Searchable;
@@ -24,8 +27,10 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Date;
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * @author mazq
@@ -119,4 +124,19 @@ public class AuthFlowServiceImpl implements IAuthFlowService {
         return serviceAuthFlowBPO.checkApplicantId(applicantId);
     }
 
+    @Override
+    public List<String> authFlowRepeatCheck(String appCode, List<String> serviceCodes) {
+        Searchable searchable = Searchable.newSearchable();
+        searchable.addSearchFilter("app_code",SearchOperator.eq,appCode);
+        searchable.addSearchFilter("flow_status",SearchOperator.eq, WorkFlowStatusEnum.APPLYING.getValue());
+        searchable.addSearchFilter("deleted",SearchOperator.eq, WorkFlowStatusEnum.APPLYING.getValue());
+        List<ServiceAuthFlow> existFlows = serviceAuthFlowBPO.find(ServiceAuthFlow.class, searchable);
+        List<String> existServiceCodes = existFlows.stream()
+                .filter(item -> StringUtils.isNotBlank(item.getServiceCodes()))
+                .flatMap(item -> Arrays.stream(item.getServiceCodes().split(StrUtil.COMMA)))
+                .filter(item -> serviceCodes.contains(item))
+                .collect(Collectors.toList());
+        return existServiceCodes;
+    }
+
 }

+ 7 - 4
dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/auth/service/impl/ServiceAuthResultServiceImpl.java

@@ -12,6 +12,7 @@ import com.dragoninfo.dcuc.auth.auth.dto.AppServiceCodeDto;
 import com.dragoninfo.dcuc.auth.auth.dto.ServiceAuthResultDTO;
 import com.dragoninfo.dcuc.auth.auth.entity.ServiceAuthFlow;
 import com.dragoninfo.dcuc.auth.auth.entity.ServiceAuthResult;
+import com.dragoninfo.dcuc.auth.auth.enumresources.ServiceAuthStatusEnum;
 import com.dragoninfo.dcuc.auth.auth.enumresources.WokrFlowPermissionTypeEnum;
 import com.dragoninfo.dcuc.auth.auth.enumresources.WorkFlowStatusEnum;
 import com.dragoninfo.dcuc.auth.auth.enumresources.WorkFlowTypeEnum;
@@ -165,14 +166,17 @@ public class ServiceAuthResultServiceImpl implements IServiceAuthResultService {
             //判断工作单是长期还是自定义
             Date startTime = null;
             Date endTime = null;
-            String authStatus = BooleanEnum.TRUE.getValue();
+            String authStatus = ServiceAuthStatusEnum.START.getValue();
             String permissionValidType = serviceAuthFlow.getPermissionValidType();
             if (StringUtils.isNotBlank(permissionValidType)
                     && WokrFlowPermissionTypeEnum.TEMP.getValue().equals(permissionValidType)) {
                 startTime = serviceAuthFlow.getStartTime();
                 endTime = serviceAuthFlow.getEndTime();
-                if (date.before(startTime) || date.after(endTime)) {
-                    authStatus = BooleanEnum.FALSE.getValue();
+                if (date.before(startTime)) {
+                    authStatus = ServiceAuthStatusEnum.NOT_START.getValue();
+                }
+                if (date.after(endTime)) {
+                    authStatus = ServiceAuthStatusEnum.OVER_DUE.getValue();
                 }
             }
             //授权工作单
@@ -483,7 +487,6 @@ public class ServiceAuthResultServiceImpl implements IServiceAuthResultService {
         paging.forEach(item->{
             ServiceAuthResultDTO dto=new ServiceAuthResultDTO();
             BeanUtils.copyProperties(item,dto);
-            dto.setAuthStatus(item.getServiceStatus());
             dtos.add(dto);
         });
         Pageable newPageable = new PageRequest(paging.getNumber(), paging.getSize());