diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/irs/controller/ApplicationController.java b/pmapi/src/main/java/com/ningdatech/pmapi/irs/controller/ApplicationController.java index f2e2d2e..8aac63b 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/irs/controller/ApplicationController.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/irs/controller/ApplicationController.java @@ -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 searchApps(ApiApplyDTO apply) throws NoSuchAlgorithmException { + return appIrsManage.searchApps(apply); + } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/irs/manage/AppIrsManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/irs/manage/AppIrsManage.java index e78f959..6981dd5 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/irs/manage/AppIrsManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/irs/manage/AppIrsManage.java @@ -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 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 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(); + } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/IrsManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/IrsManage.java index 181647f..c29bdc5 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/IrsManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/IrsManage.java @@ -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 applicationList() { List list = irsApplicationService.list(); @@ -42,10 +52,29 @@ public class IrsManage { } public List listPiotTasks() { - List list = piotTasksService.list(); - if(CollUtil.isEmpty(list)){ - return Collections.emptyList(); + //不请求IRS + if(!isPiotTasks){ + List list = piotTasksService.list(); + if(CollUtil.isEmpty(list)){ + return Collections.emptyList(); + } + return CollUtils.convert(list,task -> BeanUtil.copyProperties(task,PiotTasksVO.class)); + } + try { + List 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(); } } 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 03566a3..dbcad89 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 @@ -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 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 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 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 applicationList = projecDto.getApplicationList(); if(CollUtil.isNotEmpty(applicationList)){ List 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 applicationList = projectApplicationService.list(Wrappers.lambdaQuery(ProjectApplication.class) - .eq(ProjectApplication::getProjectId,oldProject.getId())); - if(CollUtil.isNotEmpty(applicationList)){ - List 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 applicationList = projectApplicationService.list(Wrappers.lambdaQuery(ProjectApplication.class) - .eq(ProjectApplication::getProjectId,oldProject.getId())); - if(CollUtil.isNotEmpty(applicationList)){ - List 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 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()); } } diff --git a/pmapi/src/main/resources/application-dev.yml b/pmapi/src/main/resources/application-dev.yml index 49d8e27..d40b5fb 100644 --- a/pmapi/src/main/resources/application-dev.yml +++ b/pmapi/src/main/resources/application-dev.yml @@ -204,6 +204,7 @@ provincial: #天印服务器接口信息 irs: + is-piot-tasks: false seal-platform: project-id: 330001110 project-secret: 70e512d40c8f440484db4acab181570a diff --git a/pmapi/src/main/resources/application-prod.yml b/pmapi/src/main/resources/application-prod.yml index 1948252..eeefd52 100644 --- a/pmapi/src/main/resources/application-prod.yml +++ b/pmapi/src/main/resources/application-prod.yml @@ -207,6 +207,7 @@ provincial: #天印服务器接口信息 irs: + is-piot-tasks: true seal-platform: project-id: 330001110 project-secret: 70e512d40c8f440484db4acab181570a diff --git a/pmapi/src/test/resources/application-dev.yml b/pmapi/src/test/resources/application-dev.yml index d2ec236..163edd8 100644 --- a/pmapi/src/test/resources/application-dev.yml +++ b/pmapi/src/test/resources/application-dev.yml @@ -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: diff --git a/pmapi/src/test/resources/application-prod.yml b/pmapi/src/test/resources/application-prod.yml index 87aea90..e70c130 100644 --- a/pmapi/src/test/resources/application-prod.yml +++ b/pmapi/src/test/resources/application-prod.yml @@ -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: