From b902a510a9802f5a711f07f73d9c2fb3faf25dcb Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Tue, 27 Jun 2023 15:10:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BA=94=E7=94=A8=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ProjectApplicationController.java | 4 +-- .../pmapi/projectlib/manage/ApplicationManage.java | 35 +++++++++++++++++----- .../pmapi/projectlib/manage/ProjectLibManage.java | 2 +- 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/controller/ProjectApplicationController.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/controller/ProjectApplicationController.java index edba6bf..4378fcf 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/controller/ProjectApplicationController.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/controller/ProjectApplicationController.java @@ -24,10 +24,10 @@ public class ProjectApplicationController { private final ApplicationManage applicationManage; - @GetMapping("/get-report") + @GetMapping("/get-report/{appCode}") @ApiOperation("获取应用 试运行报告") @WebLog("获取应用 试运行报告") - public String getReport(@RequestParam(required = false) String appCode) { + public String getReport(@PathVariable String appCode) { return applicationManage.getReport(appCode); } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ApplicationManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ApplicationManage.java index 1497136..b80a1e0 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ApplicationManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ApplicationManage.java @@ -1,7 +1,12 @@ package com.ningdatech.pmapi.projectlib.manage; +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.exception.BizException; import com.ningdatech.basic.function.VUtils; +import com.ningdatech.basic.model.ApiResponse; import com.ningdatech.pmapi.common.util.HmacAuthUtil; import com.ningdatech.pmapi.projectlib.model.dto.ApplicationAppCodeSaveDTO; import com.ningdatech.pmapi.projectlib.model.entity.ProjectApplication; @@ -9,11 +14,9 @@ import com.ningdatech.pmapi.projectlib.service.IProjectApplicationService; import com.ningdatech.pmapi.user.util.LoginUserUtil; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Value; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpMethod; -import org.springframework.http.ResponseEntity; +import org.springframework.http.*; import org.springframework.stereotype.Component; import org.springframework.util.MultiValueMap; import org.springframework.web.client.RestTemplate; @@ -85,11 +88,29 @@ public class ApplicationManage { HttpEntity> formEntity = new HttpEntity>(headers); RestTemplate restTemplate = new RestTemplate(); - ResponseEntity forEntity = restTemplate.exchange(url, HttpMethod.GET,formEntity, String.class); + ResponseEntity forEntity = restTemplate.exchange(appUrl, HttpMethod.GET,formEntity, ApiResponse.class); log.info("body:",forEntity.getBody()); - String body = forEntity.getBody(); + ApiResponse body = forEntity.getBody(); - return null; + if(!body.getCode().equals(HttpStatus.OK.value())){ + throw new BizException(body.getMessage()); + } + + Object data = body.getData(); + if(Objects.nonNull(data)){ + JSONObject dataJson = JSON.parseObject(JSON.toJSONString(data)); + JSONArray resourceList = dataJson.getJSONArray("resourceList"); + if(CollUtil.isNotEmpty(resourceList)){ + JSONObject resource = JSON.parseObject(JSON.toJSONString(resourceList.get(0))); + if(StringUtils.isBlank(resource.getString("reportOss"))){ + //暂时没有 appCode 所以先返回测试数据 + return "https://irs-yyyw.oss-cn-hangzhou-zwynet-d01-a.internet.cloud.zj.gov.cn/tmp/%E6%B8%A9%E5%B7%9E%E5%B8%82%E4%B9%90%E6%B8%85%E5%B8%82%E5%8C%BA%E5%9F%9F%E4%BD%93%E6%A3%80%E4%BF%A1%E6%81%AF%E7%B3%BB%E7%BB%9F_9cf0b901f2ca4fbf8ff274da359ad219.html?Expires=1687833685&OSSAccessKeyId=wMhEw2BhpIDc1xwO&Signature=UPAbMdDy23FI1sNemszg5WH%2BG40%3D"; + }else{ + return resource.getString("reportOss"); + } + } + } + throw new BizException("获取报告失败!"); } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java index 05999dc..a0c13a9 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java @@ -731,7 +731,7 @@ public class ProjectLibManage { if(StringUtils.isNotBlank(req.getApplicationName())){ wrapper.and(q1 -> q1.like(ProjectApplication::getApplicationName,req.getApplicationName()) - .or(q2 -> q2.like(ProjectApplication::getAccountAppName,req.getApplicationName()))); + .or(q2 -> q2.like(ProjectApplication::getRelatedExistsApplication,req.getApplicationName()))); } wrapper.orderByDesc(ProjectApplication::getUpdateOn); projectApplicationService.page(page,wrapper);