Pārlūkot izejas kodu

已注册应用接口

master
PoffyZhang pirms 1 gada
vecāks
revīzija
b416d89f7f
8 mainītis faili ar 95 papildinājumiem un 40 dzēšanām
  1. +5
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/irs/controller/ApplicationController.java
  2. +20
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/irs/manage/AppIrsManage.java
  3. +33
    -4
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/IrsManage.java
  4. +21
    -36
      pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java
  5. +1
    -0
      pmapi/src/main/resources/application-dev.yml
  6. +1
    -0
      pmapi/src/main/resources/application-prod.yml
  7. +9
    -0
      pmapi/src/test/resources/application-dev.yml
  8. +5
    -0
      pmapi/src/test/resources/application-prod.yml

+ 5
- 0
pmapi/src/main/java/com/ningdatech/pmapi/irs/controller/ApplicationController.java Parādīt failu

@@ -10,6 +10,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.security.NoSuchAlgorithmException;
import java.util.List;

/**
* @Classname ApplicationController
@@ -37,4 +38,8 @@ public class ApplicationController {
return appIrsManage.searchApp(apply);
}

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

+ 20
- 0
pmapi/src/main/java/com/ningdatech/pmapi/irs/manage/AppIrsManage.java Parādīt failu

@@ -27,6 +27,7 @@ import org.springframework.web.client.RestTemplate;

import java.security.NoSuchAlgorithmException;
import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
@@ -169,4 +170,23 @@ public class AppIrsManage {
}
return null;
}

public List<ApiApplySearchResult> searchApps(ApiApplyDTO apply) throws NoSuchAlgorithmException {
long timestamp = System.currentTimeMillis();

String requestSecret = RefreshKeyUtil.getRequestSecret(searchAppKey, searchAppScret);
String sign = CryptUtils.MD5Encode(searchAppKey + requestSecret + timestamp);
String url = searchUrl + "?requestTime=" + timestamp + "&sign=" + sign +
"&appKey=" + searchAppKey + "&" +
"pageSize=100&pageNum=1";
RestTemplate restTemplate = new RestTemplate();
ResponseEntity<ApiSearchResult> forEntity = restTemplate.getForEntity(url, ApiSearchResult.class);

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

if(Objects.nonNull(forEntity.getBody()) && CollUtil.isNotEmpty(forEntity.getBody().getApiApplySearchResult())){
return forEntity.getBody().getApiApplySearchResult();
}
return Collections.emptyList();
}
}

+ 33
- 4
pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/IrsManage.java Parādīt failu

@@ -3,6 +3,9 @@ package com.ningdatech.pmapi.projectdeclared.manage;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import com.ningdatech.basic.util.CollUtils;
import com.ningdatech.pmapi.irs.manage.AppIrsManage;
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.NdPiotTasks;
import com.ningdatech.pmapi.projectdeclared.model.vo.IrsApplicationVO;
@@ -11,8 +14,10 @@ import com.ningdatech.pmapi.projectdeclared.service.INdPiotTasksService;
import com.ningdatech.pmapi.projectdeclared.service.IrsApplicationService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.security.NoSuchAlgorithmException;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
@@ -28,10 +33,15 @@ import java.util.stream.Collectors;
@RequiredArgsConstructor
public class IrsManage {

@Value("${irs.is-piot-tasks}")
private Boolean isPiotTasks;

private final IrsApplicationService irsApplicationService;

private final INdPiotTasksService piotTasksService;

private final AppIrsManage appIrsManage;


public List<IrsApplicationVO> applicationList() {
List<IrsApplication> list = irsApplicationService.list();
@@ -42,10 +52,29 @@ public class IrsManage {
}

public List<PiotTasksVO> listPiotTasks() {
List<NdPiotTasks> list = piotTasksService.list();
if(CollUtil.isEmpty(list)){
return Collections.emptyList();
//不请求IRS
if(!isPiotTasks){
List<NdPiotTasks> list = piotTasksService.list();
if(CollUtil.isEmpty(list)){
return Collections.emptyList();
}
return CollUtils.convert(list,task -> BeanUtil.copyProperties(task,PiotTasksVO.class));
}
try {
List<ApiApplySearchResult> apiApplySearchResults = appIrsManage.searchApps(new ApiApplyDTO());
if(CollUtil.isNotEmpty(apiApplySearchResults)){
return apiApplySearchResults.stream().map(apply -> {
PiotTasksVO vo = new PiotTasksVO();
vo.setTaskCode(apply.getAppId());
vo.setTaskName(apply.getName());
vo.setImportantTaskName(apply.getName());
vo.setSubSceneApplicationName(apply.getName());
return vo;
}).collect(Collectors.toList());
}
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
return CollUtils.convert(list,task -> BeanUtil.copyProperties(task,PiotTasksVO.class));
return Collections.emptyList();
}
}

+ 21
- 36
pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java Parādīt failu

@@ -239,6 +239,8 @@ public class ProjectLibManage {
//采取批量删除 批量添加的方式
projectApplicationService.remove(Wrappers.lambdaQuery(ProjectApplication.class)
.eq(ProjectApplication::getProjectId,project.getId()));
projectApplicationService.remove(Wrappers.lambdaQuery(ProjectApplication.class)
.eq(ProjectApplication::getProjectCode,project.getProjectCode()));
if (isApp && CollUtil.isNotEmpty(projectDto.getApplicationList())) {
Project finalProject = project;
List<ProjectApplication> applications = projectDto.getApplicationList().stream().map(application -> {
@@ -246,6 +248,7 @@ public class ProjectLibManage {
BeanUtils.copyProperties(application, projectApplication);
projectApplication.setId(null);
projectApplication.setProjectId(finalProject.getId());
projectApplication.setProjectCode(finalProject.getProjectCode());
projectApplication.setBuildOrgCode(finalProject.getBuildOrgCode());
projectApplication.setBuildOrgName(finalProject.getBuildOrgName());
return projectApplication;
@@ -275,6 +278,8 @@ public class ProjectLibManage {
//采取批量删除 批量添加的方式
projectApplicationService.remove(Wrappers.lambdaQuery(ProjectApplication.class)
.eq(ProjectApplication::getProjectId,project.getId()));
projectApplicationService.remove(Wrappers.lambdaQuery(ProjectApplication.class)
.eq(ProjectApplication::getProjectCode,project.getProjectCode()));
if (isApp && CollUtil.isNotEmpty(projectDto.getApplicationList())) {
Project finalProject = project;
List<ProjectApplication> applications = projectDto.getApplicationList().stream().map(application -> {
@@ -282,6 +287,7 @@ public class ProjectLibManage {
BeanUtils.copyProperties(application, projectApplication);
projectApplication.setId(null);
projectApplication.setProjectId(finalProject.getId());
projectApplication.setProjectCode(finalProject.getProjectCode());
return projectApplication;
}).collect(Collectors.toList());
projectApplicationService.saveOrUpdateBatch(applications);
@@ -347,6 +353,12 @@ public class ProjectLibManage {
.ne(Project::getId,project.getId())
.eq(Project::getProjectCode,project.getProjectCode()));

//采取批量删除 批量添加的方式
projectApplicationService.remove(Wrappers.lambdaQuery(ProjectApplication.class)
.eq(ProjectApplication::getProjectId,project.getId()));
projectApplicationService.remove(Wrappers.lambdaQuery(ProjectApplication.class)
.eq(ProjectApplication::getProjectCode,project.getProjectCode()));

//app
List<ProjectApplicationDTO> applicationList = projecDto.getApplicationList();
if(CollUtil.isNotEmpty(applicationList)){
@@ -398,6 +410,12 @@ public class ProjectLibManage {
.eq(Project::getProjectCode,project.getProjectCode()));

//app
//采取批量删除 批量添加的方式
projectApplicationService.remove(Wrappers.lambdaQuery(ProjectApplication.class)
.eq(ProjectApplication::getProjectId,project.getId()));
projectApplicationService.remove(Wrappers.lambdaQuery(ProjectApplication.class)
.eq(ProjectApplication::getProjectCode,project.getProjectCode()));

List<ProjectApplicationDTO> applicationList = projecDto.getApplicationList();
if(CollUtil.isNotEmpty(applicationList)){
List<ProjectApplication> apps = applicationList.stream()
@@ -405,6 +423,7 @@ public class ProjectLibManage {
ProjectApplication app = BeanUtil.copyProperties(a,ProjectApplication.class);
app.setId(null);
app.setProjectId(project.getId());
app.setProjectCode(project.getProjectCode());
app.setBuildOrgName(project.getBuildOrgName());
app.setBuildOrgCode(project.getBuildOrgCode());
return app;
@@ -442,23 +461,6 @@ public class ProjectLibManage {
.set(Project::getNewest,Boolean.FALSE)
.ne(Project::getId,project.getId())
.eq(Project::getProjectCode,project.getProjectCode()));

//app
List<ProjectApplication> applicationList = projectApplicationService.list(Wrappers.lambdaQuery(ProjectApplication.class)
.eq(ProjectApplication::getProjectId,oldProject.getId()));
if(CollUtil.isNotEmpty(applicationList)){
List<ProjectApplication> apps = applicationList.stream()
.map(a -> {
ProjectApplication app = BeanUtil.copyProperties(a,ProjectApplication.class);
app.setId(null);
app.setProjectId(project.getId());
app.setBuildOrgName(project.getBuildOrgName());
app.setBuildOrgCode(project.getBuildOrgCode());
return app;
})
.collect(Collectors.toList());
projectApplicationService.saveBatch(apps);
}
}

return project;
@@ -490,23 +492,6 @@ public class ProjectLibManage {
.set(Project::getNewest,Boolean.FALSE)
.ne(Project::getId,project.getId())
.eq(Project::getProjectCode,project.getProjectCode()));

//app
List<ProjectApplication> applicationList = projectApplicationService.list(Wrappers.lambdaQuery(ProjectApplication.class)
.eq(ProjectApplication::getProjectId,oldProject.getId()));
if(CollUtil.isNotEmpty(applicationList)){
List<ProjectApplication> apps = applicationList.stream()
.map(a -> {
ProjectApplication app = BeanUtil.copyProperties(a,ProjectApplication.class);
app.setId(null);
app.setProjectId(project.getId());
app.setBuildOrgName(project.getBuildOrgName());
app.setBuildOrgCode(project.getBuildOrgCode());
return app;
})
.collect(Collectors.toList());
projectApplicationService.saveBatch(apps);
}
}

return project;
@@ -529,7 +514,7 @@ public class ProjectLibManage {
vo.buildDynamicForm(projectInfo.getDynamicForm());
// 查询应用
List<ProjectApplication> applications = applicationService.list(Wrappers.lambdaQuery(ProjectApplication.class)
.eq(ProjectApplication::getProjectId, vo.getId()));
.eq(ProjectApplication::getProjectCode, vo.getProjectCode()));
Optional.ofNullable(applications).ifPresent(apps ->
vo.setProjectApplications(CollUtils.convert(apps,
ProjectHelper::convertVO)
@@ -839,7 +824,7 @@ public class ProjectLibManage {
}

return historyProjects.stream()
.map(p -> BeanUtil.copyProperties(p,ProjectDetailVO.class))
.map(p -> this.getProjectDetail(p.getId()))
.collect(Collectors.toList());
}
}

+ 1
- 0
pmapi/src/main/resources/application-dev.yml Parādīt failu

@@ -204,6 +204,7 @@ provincial:

#天印服务器接口信息
irs:
is-piot-tasks: false
seal-platform:
project-id: 330001110
project-secret: 70e512d40c8f440484db4acab181570a


+ 1
- 0
pmapi/src/main/resources/application-prod.yml Parādīt failu

@@ -207,6 +207,7 @@ provincial:

#天印服务器接口信息
irs:
is-piot-tasks: true
seal-platform:
project-id: 330001110
project-secret: 70e512d40c8f440484db4acab181570a


+ 9
- 0
pmapi/src/test/resources/application-dev.yml Parādīt failu

@@ -203,6 +203,7 @@ provincial:

#天印服务器接口信息
irs:
is-piot-tasks: false
seal-platform:
project-id: 330001110
project-secret: 70e512d40c8f440484db4acab181570a
@@ -213,6 +214,14 @@ irs:
url: https://bcdsg.zj.gov.cn:8443/restapi/prod/IC33000020230427000001/irs-res-bill/report/pdfUrl
appScret: BCDSGS_4ab4235d26a9a357170a39f3a13fd68c
appKey: BCDSGA_d874c8e46b541eb4e8aac6510fd3351b
push-app:
url: https://interface.zjzwfw.gov.cn/gateway/api/proxy/001003001029/dataSharing/94wbaL1I1Pbz0648.htm
appScret: 496f0f2a19994f76b4fd9dae087366c7
appKey: A331101453557202109017383
search-app:
url: https://interface.zjzwfw.gov.cn/gateway/api/001003001029/dataSharing/XS8daav3bcemZ3Ra.htm
appScret: 496f0f2a19994f76b4fd9dae087366c7
appKey: A331101453557202109017383
hostname: iZbp13nwyvib53j4j1p2xoZ

login:


+ 5
- 0
pmapi/src/test/resources/application-prod.yml Parādīt failu

@@ -202,6 +202,7 @@ provincial:

#天印服务器接口信息
irs:
is-piot-tasks: true
seal-platform:
project-id: 330001110
project-secret: 70e512d40c8f440484db4acab181570a
@@ -212,6 +213,10 @@ irs:
url: https://bcdsg.zj.gov.cn:8443/restapi/prod/IC33000020230427000001/irs-res-bill/report/pdfUrl
appScret: BCDSGS_4ab4235d26a9a357170a39f3a13fd68c
appKey: BCDSGA_d874c8e46b541eb4e8aac6510fd3351b
push-app:
url: https://interface.zjzwfw.gov.cn/gateway/api/proxy/001003001029/dataSharing/94wbaL1I1Pbz0648.htm
appScret: 496f0f2a19994f76b4fd9dae087366c7
appKey: A331101453557202109017383
hostname: iZ6mx01gyeodd80imxd2gbZ
login:
phone-verify-code:


Notiek ielāde…
Atcelt
Saglabāt