Browse Source

Merge remote-tracking branch 'origin/master'

tags/24080901
CMM 1 year ago
parent
commit
fd1a98b5aa
5 changed files with 66 additions and 26 deletions
  1. +5
    -2
      pmapi/src/main/java/com/ningdatech/pmapi/irs/controller/ApplicationController.java
  2. +2
    -2
      pmapi/src/main/java/com/ningdatech/pmapi/irs/controller/IrsController.java
  3. +45
    -13
      pmapi/src/main/java/com/ningdatech/pmapi/irs/manage/AppIrsManage.java
  4. +1
    -2
      pmapi/src/main/java/com/ningdatech/pmapi/irs/model/dto/ApiDTO.java
  5. +13
    -7
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/IrsManage.java

+ 5
- 2
pmapi/src/main/java/com/ningdatech/pmapi/irs/controller/ApplicationController.java View File

@@ -1,5 +1,8 @@
package com.ningdatech.pmapi.irs.controller; package com.ningdatech.pmapi.irs.controller;


import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ningdatech.log.annotation.WebLog; import com.ningdatech.log.annotation.WebLog;
import com.ningdatech.pmapi.irs.manage.AppIrsManage; import com.ningdatech.pmapi.irs.manage.AppIrsManage;
import com.ningdatech.pmapi.irs.model.dto.ApiApplyDTO; import com.ningdatech.pmapi.irs.model.dto.ApiApplyDTO;
@@ -34,12 +37,12 @@ public class ApplicationController {
} }


@GetMapping("/sreach-app") @GetMapping("/sreach-app")
public ApiApplySearchResult searchApp(ApiApplyDTO apply) throws NoSuchAlgorithmException {
public JSONObject searchApp(ApiApplyDTO apply) throws NoSuchAlgorithmException {
return appIrsManage.searchApp(apply); return appIrsManage.searchApp(apply);
} }


@GetMapping("/sreach-apps") @GetMapping("/sreach-apps")
public List<ApiApplySearchResult> searchApps(ApiApplyDTO apply) throws NoSuchAlgorithmException {
public JSONArray searchApps(ApiApplyDTO apply) throws NoSuchAlgorithmException {
return appIrsManage.searchApps(apply); return appIrsManage.searchApps(apply);
} }
} }

+ 2
- 2
pmapi/src/main/java/com/ningdatech/pmapi/irs/controller/IrsController.java View File

@@ -31,8 +31,8 @@ public class IrsController {
@ApiOperation(value = "irs应用列表", notes = "irs应用列表") @ApiOperation(value = "irs应用列表", notes = "irs应用列表")
@WebLog("irs应用列表") @WebLog("irs应用列表")
@GetMapping("/application-list") @GetMapping("/application-list")
public List<IrsApplicationVO> applicationList() {
return irsManage.applicationList();
public List<IrsApplicationVO> applicationList(@RequestParam(required = false) String areaCode) {
return irsManage.applicationList(areaCode);
} }


@ApiOperation(value = "试点任务列表", notes = "试点任务列表") @ApiOperation(value = "试点任务列表", notes = "试点任务列表")


+ 45
- 13
pmapi/src/main/java/com/ningdatech/pmapi/irs/manage/AppIrsManage.java View File

@@ -2,6 +2,8 @@ package com.ningdatech.pmapi.irs.manage;


import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ningdatech.basic.function.VUtils; import com.ningdatech.basic.function.VUtils;
import com.ningdatech.pmapi.common.enumeration.CommonEnum; import com.ningdatech.pmapi.common.enumeration.CommonEnum;
@@ -83,8 +85,11 @@ public class AppIrsManage {


ApiApplyDTO apiApply = new ApiApplyDTO(); ApiApplyDTO apiApply = new ApiApplyDTO();
apiApply.setAppId(appCode); apiApply.setAppId(appCode);
ApiApplySearchResult apiApplySearchResult = this.searchApp(apiApply);

JSONObject jsonObject = this.searchApp(apiApply);
VUtils.isTrue(Objects.isNull(jsonObject)).throwMessage("应用在IRS不存在!");
JSONArray data = jsonObject.getJSONArray("data");
VUtils.isTrue(CollUtil.isNotEmpty(data)).throwMessage("应用在IRS不存在!");
ApiApplySearchResult apiApplySearchResult = JSON.parseObject(JSON.toJSONString(data.get(0)),ApiApplySearchResult.class);
VUtils.isTrue(Objects.isNull(apiApplySearchResult)).throwMessage("应用在IRS不存在!"); VUtils.isTrue(Objects.isNull(apiApplySearchResult)).throwMessage("应用在IRS不存在!");


long timestamp = System.currentTimeMillis(); long timestamp = System.currentTimeMillis();
@@ -149,7 +154,7 @@ public class AppIrsManage {
* @return * @return
* @throws NoSuchAlgorithmException * @throws NoSuchAlgorithmException
*/ */
public ApiApplySearchResult searchApp(ApiApplyDTO apply) throws NoSuchAlgorithmException {
public JSONObject searchApp(ApiApplyDTO apply) throws NoSuchAlgorithmException {
long timestamp = System.currentTimeMillis(); long timestamp = System.currentTimeMillis();
String appCode = apply.getAppId(); String appCode = apply.getAppId();
String requestSecret = RefreshKeyUtil.getRequestSecret(searchAppKey, searchAppScret); String requestSecret = RefreshKeyUtil.getRequestSecret(searchAppKey, searchAppScret);
@@ -160,18 +165,33 @@ public class AppIrsManage {
"&areaCode=&deptCode=&name="; "&areaCode=&deptCode=&name=";
log.info("url : {}",url); log.info("url : {}",url);
RestTemplate restTemplate = new RestTemplate(); RestTemplate restTemplate = new RestTemplate();
ResponseEntity<ApiDTO> forEntity = restTemplate.getForEntity(url, ApiDTO.class);
ResponseEntity<String> forEntity = restTemplate.getForEntity(url, String.class);


log.info("查询应用目录 : {}",JSON.toJSONString(forEntity)); log.info("查询应用目录 : {}",JSON.toJSONString(forEntity));


if(Objects.nonNull(forEntity.getBody()) && Objects.nonNull(forEntity.getBody().getDatas())
&& CollUtil.isNotEmpty(forEntity.getBody().getDatas().getApiApplySearchResult())){
return forEntity.getBody().getDatas().getApiApplySearchResult().get(0);
if(Objects.nonNull(forEntity.getBody()) && Objects.nonNull(forEntity.getBody())){
JSONObject body = JSON.parseObject(forEntity.getBody());
if(Objects.isNull(body)){
return null;
}
JSONObject datas = body.getJSONObject("datas");
if(Objects.isNull(datas)){
return null;
}
JSONObject data = datas.getJSONObject("data");
if(Objects.isNull(data)){
return null;
}
JSONArray apiApplySearchResult = data.getJSONArray("apiApplySearchResult");
if(CollUtil.isEmpty(apiApplySearchResult)){
return null;
}
return apiApplySearchResult.getJSONObject(0);
} }
return null; return null;
} }


public List<ApiApplySearchResult> searchApps(ApiApplyDTO apply) throws NoSuchAlgorithmException {
public JSONArray searchApps(ApiApplyDTO apply) throws NoSuchAlgorithmException {
long timestamp = System.currentTimeMillis(); long timestamp = System.currentTimeMillis();
String areaCode = StringUtils.isNotBlank(apply.getAreaCode()) ? String areaCode = StringUtils.isNotBlank(apply.getAreaCode()) ?
apply.getAreaCode() : null; apply.getAreaCode() : null;
@@ -182,14 +202,26 @@ public class AppIrsManage {
"pageNum=1&areaCode=" + areaCode + "pageNum=1&areaCode=" + areaCode +
"&deptCode=&name="; "&deptCode=&name=";
RestTemplate restTemplate = new RestTemplate(); RestTemplate restTemplate = new RestTemplate();
ResponseEntity<ApiDTO> forEntity = restTemplate.getForEntity(url, ApiDTO.class);
ResponseEntity<String> forEntity = restTemplate.getForEntity(url, String.class);


log.info("查询应用目录 : {}",JSON.toJSONString(forEntity)); log.info("查询应用目录 : {}",JSON.toJSONString(forEntity));


if(Objects.nonNull(forEntity.getBody()) && Objects.nonNull(forEntity.getBody().getDatas())
&& CollUtil.isNotEmpty(forEntity.getBody().getDatas().getApiApplySearchResult())){
return forEntity.getBody().getDatas().getApiApplySearchResult();
if(Objects.nonNull(forEntity.getBody())){
JSONObject body = JSON.parseObject(forEntity.getBody());
if(Objects.isNull(body)){
return null;
}
JSONObject datas = body.getJSONObject("datas");
if(Objects.isNull(datas)){
return null;
}
JSONObject data = datas.getJSONObject("data");
if(Objects.isNull(data)){
return null;
}
JSONArray apiApplySearchResult = data.getJSONArray("apiApplySearchResult");
return apiApplySearchResult;
} }
return Collections.emptyList();
return null;
} }
} }

+ 1
- 2
pmapi/src/main/java/com/ningdatech/pmapi/irs/model/dto/ApiDTO.java View File

@@ -22,6 +22,5 @@ public class ApiDTO implements Serializable {


private String code; private String code;
private String msg; private String msg;
private String data;
private ApiSearchResult datas;
private ApiSearchResult data;
} }

+ 13
- 7
pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/IrsManage.java View File

@@ -2,10 +2,12 @@ package com.ningdatech.pmapi.projectdeclared.manage;


import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ningdatech.basic.util.CollUtils; import com.ningdatech.basic.util.CollUtils;
import com.ningdatech.pmapi.irs.manage.AppIrsManage; import com.ningdatech.pmapi.irs.manage.AppIrsManage;
import com.ningdatech.pmapi.irs.model.dto.ApiApplyDTO; import com.ningdatech.pmapi.irs.model.dto.ApiApplyDTO;
import com.ningdatech.pmapi.irs.model.dto.ApiApplySearchResult;
import com.ningdatech.pmapi.projectdeclared.model.entity.IrsApplication; import com.ningdatech.pmapi.projectdeclared.model.entity.IrsApplication;
import com.ningdatech.pmapi.projectdeclared.model.entity.NdPiotTasks; import com.ningdatech.pmapi.projectdeclared.model.entity.NdPiotTasks;
import com.ningdatech.pmapi.projectdeclared.model.vo.IrsApplicationVO; import com.ningdatech.pmapi.projectdeclared.model.vo.IrsApplicationVO;
@@ -20,6 +22,7 @@ import org.springframework.stereotype.Component;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;


/** /**
@@ -43,7 +46,7 @@ public class IrsManage {
private final AppIrsManage appIrsManage; private final AppIrsManage appIrsManage;




public List<IrsApplicationVO> applicationList() {
public List<IrsApplicationVO> applicationList(String areaCode) {
//不请求IRS //不请求IRS
if(!isSearchApp) { if(!isSearchApp) {
List<IrsApplication> list = irsApplicationService.list(); List<IrsApplication> list = irsApplicationService.list();
@@ -54,12 +57,15 @@ public class IrsManage {
} }


try { try {
List<ApiApplySearchResult> apiApplySearchResults = appIrsManage.searchApps(new ApiApplyDTO());
if(CollUtil.isNotEmpty(apiApplySearchResults)){
return apiApplySearchResults.stream().map(apply -> {
ApiApplyDTO apiApplay = new ApiApplyDTO();
apiApplay.setAreaCode(areaCode);
JSONArray jsonArray = appIrsManage.searchApps(apiApplay);
if(CollUtil.isNotEmpty(jsonArray)){
return jsonArray.stream().map(apply -> {
JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(apply));
IrsApplicationVO vo = new IrsApplicationVO(); IrsApplicationVO vo = new IrsApplicationVO();
vo.setApplicationCode(apply.getAppId());
vo.setApplicationName(apply.getName());
vo.setApplicationCode(jsonObject.getString("appId"));
vo.setApplicationName(jsonObject.getString("name"));
return vo; return vo;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
} }


Loading…
Cancel
Save