Переглянути джерело

重大项目联审

master
PoffyZhang 1 рік тому
джерело
коміт
516414b751
13 змінених файлів з 413 додано та 48 видалено
  1. +0
    -47
      pmapi/src/main/java/com/ningdatech/pmapi/ding/controller/DingInfoPullController.java
  2. +40
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/irs/controller/ApplicationController.java
  3. +121
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/irs/manage/AppIrsManage.java
  4. +28
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/irs/model/dto/ApiApplyDTO.java
  5. +28
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/irs/model/dto/ApiApplySearchResult.java
  6. +17
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/irs/model/dto/ApiSearchResult.java
  7. +26
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/irs/model/dto/PushProjectAppToIrsDTO.java
  8. +123
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/irs/model/res/ApiResponse.java
  9. +7
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DefaultDeclaredProjectManage.java
  10. +2
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/projectlib/service/IProjectService.java
  11. +9
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/projectlib/service/impl/ProjectServiceImpl.java
  12. +8
    -0
      pmapi/src/main/resources/application-dev.yml
  13. +4
    -0
      pmapi/src/main/resources/application-prod.yml

+ 0
- 47
pmapi/src/main/java/com/ningdatech/pmapi/ding/controller/DingInfoPullController.java Переглянути файл

@@ -1,18 +1,11 @@
package com.ningdatech.pmapi.ding.controller;

import com.alibaba.fastjson.JSON;
import com.ningdatech.pmapi.common.util.CryptUtils;
import com.ningdatech.pmapi.common.util.RefreshKeyUtil;
import com.ningdatech.pmapi.ding.task.EmployeeBatchGetTask;
import com.ningdatech.pmapi.ding.task.GovBusinessStripsTask;
import com.ningdatech.pmapi.ding.task.OrganizationBatchGetTask;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;

import java.security.NoSuchAlgorithmException;

/**
* <p>
@@ -68,46 +61,6 @@ public class DingInfoPullController {
employeeBatchGetTask.getBatchEmployeeByCode(orgCode);
}

@GetMapping("/test-app")
public void testApp() throws NoSuchAlgorithmException {
long timestamp = System.currentTimeMillis();
String areaCode = "331121";
String appKey = "A331101453557202109017383";
String appScret = "496f0f2a19994f76b4fd9dae087366c7";

String requestSecret = RefreshKeyUtil.getRequestSecret(appKey, appScret);
String capCode = CryptUtils.MD5Encode(timestamp + areaCode);
String capTime = String.valueOf(timestamp);
String sign = CryptUtils.MD5Encode(appKey + requestSecret + timestamp);
String url = "https://interface.zjzwfw.gov.cn/gateway/api/proxy/001003001029/dataSharing/94wbaL1I1Pbz0648.htm?requestTime=" + timestamp +
"&sign=" + sign + "&appKey=" + appKey + "&capCode=" + capCode + "&capTime=" + capTime +
"&baseProjSys=测试应用&areaCode=331121&baseProjName=nsl-丽水演示项目&baseProjId=331100230130112233001" +
"&isEffective=1&baseProjSysCode=25083657";
RestTemplate restTemplate = new RestTemplate();
ResponseEntity<String> forEntity = restTemplate.getForEntity(url, String.class);

log.info("forEntity : {}",JSON.toJSONString(forEntity));
}

@GetMapping("/test-app2")
public void testApp2() throws NoSuchAlgorithmException {
long timestamp = System.currentTimeMillis();
String areaCode = "331121";
String appScret = "496f0f2a19994f76b4fd9dae087366c7";
String appKey = "A331101453557202109017383";
String appCode = "A331123467587202306014169";

String requestSecret = RefreshKeyUtil.getRequestSecret(appKey, appScret);
String sign = CryptUtils.MD5Encode(appKey + requestSecret + timestamp);
String url = "https://interface.zjzwfw.gov.cn/gateway/api/001003001029/dataSharing/XS8daav3bcemZ3Ra.htm?" +
"requestTime=" + timestamp + "&sign=" + sign + "&appKey=" + appKey + "&name=abc&" +
"pageSize=10&deptCode=abc&areaCode=" + areaCode + "&pageNum=1&appCode=" + appCode;
RestTemplate restTemplate = new RestTemplate();
ResponseEntity<String> forEntity = restTemplate.getForEntity(url, String.class);

log.info("forEntity : {}",JSON.toJSONString(forEntity));
}

@GetMapping("/getToken")
public String getToken() {
return employeeBatchGetTask.getToken();


+ 40
- 0
pmapi/src/main/java/com/ningdatech/pmapi/irs/controller/ApplicationController.java Переглянути файл

@@ -0,0 +1,40 @@
package com.ningdatech.pmapi.irs.controller;

import com.ningdatech.log.annotation.WebLog;
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.irs.model.dto.PushProjectAppToIrsDTO;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.security.NoSuchAlgorithmException;

/**
* @Classname ApplicationController
* @Description
* @Date 2023/7/12 9:26
* @Author PoffyZhang
*/
@RestController
@RequestMapping("/api/v1/app")
@AllArgsConstructor
@Slf4j
@Valid
public class ApplicationController {

private final AppIrsManage appIrsManage;

@PostMapping("/push-project-app")
@WebLog("推送项目和应用关系")
public Boolean pushProjectApp(@Valid @RequestBody PushProjectAppToIrsDTO dto) throws NoSuchAlgorithmException {
return appIrsManage.pushProjectApp(dto);
}

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

}

+ 121
- 0
pmapi/src/main/java/com/ningdatech/pmapi/irs/manage/AppIrsManage.java Переглянути файл

@@ -0,0 +1,121 @@
package com.ningdatech.pmapi.irs.manage;

import cn.hutool.core.collection.CollUtil;
import com.alibaba.fastjson.JSON;
import com.ningdatech.basic.function.VUtils;
import com.ningdatech.pmapi.common.util.CryptUtils;
import com.ningdatech.pmapi.common.util.RefreshKeyUtil;
import com.ningdatech.pmapi.irs.model.dto.ApiApplyDTO;
import com.ningdatech.pmapi.irs.model.dto.ApiApplySearchResult;
import com.ningdatech.pmapi.irs.model.dto.ApiSearchResult;
import com.ningdatech.pmapi.irs.model.dto.PushProjectAppToIrsDTO;
import com.ningdatech.pmapi.irs.model.res.ApiResponse;
import com.ningdatech.pmapi.projectlib.model.entity.Project;
import com.ningdatech.pmapi.projectlib.service.IProjectService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

import java.security.NoSuchAlgorithmException;
import java.util.Objects;

/**
* @Classname AppIrsManage
* @Description
* @Date 2023/7/12 11:43
* @Author PoffyZhang
*/
@Component
@Slf4j
@RequiredArgsConstructor
public class AppIrsManage {

private final IProjectService projectService;

@Value("${irs.push-app.appKey}")
private String pushAppKey;

@Value("${irs.push-app.appScret}")
private String pushAppScret;

@Value("${irs.push-app.url}")
private String pushUrl;

@Value("${irs.search-app.appKey}")
private String searchAppKey;

@Value("${irs.search-app.appScret}")
private String searchAppScret;

@Value("${irs.search-app.url}")
private String searchUrl;

/**
* 推送 项目和应用关系
* @param dto
* @return
* @throws NoSuchAlgorithmException
*/
public Boolean pushProjectApp(PushProjectAppToIrsDTO dto) throws NoSuchAlgorithmException {
String appCode = dto.getAppCode();
String projectCode = dto.getProjectCode();
Project project = projectService.getProjectByCode(projectCode);
VUtils.isTrue(Objects.isNull(project)).throwMessage("项目不存在!");

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

VUtils.isTrue(Objects.isNull(apiApplySearchResult)).throwMessage("应用在IRS不存在!");

long timestamp = System.currentTimeMillis();
String areaCode = project.getAreaCode();
String projectName = project.getProjectName();
String requestSecret = RefreshKeyUtil.getRequestSecret(pushAppKey, pushAppScret);
String capCode = CryptUtils.MD5Encode(timestamp + areaCode);
String capTime = String.valueOf(timestamp);
String sign = CryptUtils.MD5Encode(pushAppKey + requestSecret + timestamp);
String url = pushUrl + "?requestTime=" + timestamp +
"&sign=" + sign + "&appKey=" + pushAppKey + "&capCode=" + capCode + "&capTime=" + capTime +
"&baseProjSys=" + apiApplySearchResult.getName() + "&areaCode=" + areaCode + "&baseProjName=" + projectName +
"&baseProjId=" + project.getProjectCode() +
"&isEffective=1&baseProjSysCode=" + appCode;
RestTemplate restTemplate = new RestTemplate();
ResponseEntity<ApiResponse> forEntity = restTemplate.getForEntity(url, ApiResponse.class);

log.info("推送 项目和应用结果 : {}", JSON.toJSONString(forEntity));

ApiResponse body = forEntity.getBody();

return body.getSuccess();
}

/**
* 查询app
* @param apply
* @return
* @throws NoSuchAlgorithmException
*/
public ApiApplySearchResult searchApp(ApiApplyDTO apply) throws NoSuchAlgorithmException {
long timestamp = System.currentTimeMillis();
String appCode = apply.getAppId();

String requestSecret = RefreshKeyUtil.getRequestSecret(searchAppKey, searchAppScret);
String sign = CryptUtils.MD5Encode(searchAppKey + requestSecret + timestamp);
String url = searchUrl + "?requestTime=" + timestamp + "&sign=" + sign +
"&appKey=" + searchAppKey + "&" +
"pageSize=10&pageNum=1&appCode=" + appCode;
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().get(0);
}
return null;
}
}

+ 28
- 0
pmapi/src/main/java/com/ningdatech/pmapi/irs/model/dto/ApiApplyDTO.java Переглянути файл

@@ -0,0 +1,28 @@
package com.ningdatech.pmapi.irs.model.dto;

import lombok.Data;

@Data
public class ApiApplyDTO {
private int id;
private String orgId;
private String userId;
private String isDeleted;
private String name;
private String appId;
private String type;
private String status;
private String sysStateTime;
private String deptName;
private String deptCode;
private String fiveAreas;
private String constructionLevel;
private String isUnifiedConstruction;
private String deployType;
private String principal;
private String employeeCode;
private String areaName;
private String createTime;
private String modifiedTime;

}

+ 28
- 0
pmapi/src/main/java/com/ningdatech/pmapi/irs/model/dto/ApiApplySearchResult.java Переглянути файл

@@ -0,0 +1,28 @@
package com.ningdatech.pmapi.irs.model.dto;

import lombok.Data;

@Data
public class ApiApplySearchResult {
private int id;
private String orgId;
private String userId;
private String isDeleted;
private String name;
private String appId;
private String type;
private String status;
private String sysStateTime;
private String deptName;
private String deptCode;
private String fiveAreas;
private String constructionLevel;
private String isUnifiedConstruction;
private String deployType;
private String principal;
private String employeeCode;
private String areaName;
private String createTime;
private String modifiedTime;

}

+ 17
- 0
pmapi/src/main/java/com/ningdatech/pmapi/irs/model/dto/ApiSearchResult.java Переглянути файл

@@ -0,0 +1,17 @@
package com.ningdatech.pmapi.irs.model.dto;

import lombok.Data;

import java.util.List;

@Data
public class ApiSearchResult {
private Boolean success;
private Integer code;
private String message;
private Integer totalCount;
private Integer pageSize;
private Integer pageNum;
private List<ApiApplySearchResult> apiApplySearchResult;

}

+ 26
- 0
pmapi/src/main/java/com/ningdatech/pmapi/irs/model/dto/PushProjectAppToIrsDTO.java Переглянути файл

@@ -0,0 +1,26 @@
package com.ningdatech.pmapi.irs.model.dto;

import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;

import javax.validation.constraints.NotBlank;

/**
* @Classname PushProjectAppToIrsDto
* @Description
* @Date 2023/7/12 11:39
* @Author PoffyZhang
*/
@Data
@Builder
public class PushProjectAppToIrsDTO {

@ApiModelProperty("app code")
@NotBlank(message = "appCode 不能为空")
private String appCode;

@ApiModelProperty("项目编码")
@NotBlank(message = "项目编码 不能为空")
private String projectCode;
}

+ 123
- 0
pmapi/src/main/java/com/ningdatech/pmapi/irs/model/res/ApiResponse.java Переглянути файл

@@ -0,0 +1,123 @@
package com.ningdatech.pmapi.irs.model.res;

import com.ningdatech.basic.enumeration.Status;
import com.ningdatech.basic.model.ApiStatus;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
* <p>
* ApiResponse - 统一的接口返回值封装
* </p>
*
* @author WendyYang
* @since 14:29 2022/9/29
*/
@Data
@NoArgsConstructor
public class ApiResponse<T> implements Serializable {
private static final long serialVersionUID = 532384723325394156L;

public static final int SUCCESS_CODE = 200;

public static final String SUCCESS_MSG = "success";

public static final int ERROR_CODE = 500;

public static final String ERROR_MSG = "Internal server error";

/**
* 状态码
*/
private Integer code;

/**
* 返回内容
*/
private String message;

/**
* 返回数据
*/
private T data;


private Boolean success;
/**
* 全参构造函数
*
* @param code 状态码
* @param message 返回内容
* @param data 返回数据
*/
private ApiResponse(Integer code, String message, T data,Boolean success) {
this.code = code;
this.message = message;
this.data = data;
this.success = success;
}

/**
* 构造一个自定义的API返回
*
* @param code 状态码
* @param message 返回内容
* @param data 返回数据
* @return ApiResponse
*/
public static <T> ApiResponse<T> of(Integer code, String message, T data,Boolean success) {
return new ApiResponse<T>(code, message, data,success);
}

/**
* 构造一个成功且不带数据的API返回
*
* @return ApiResponse
*/
public static <T> ApiResponse<T> ofSuccess() {
return ofSuccess(null);
}

/**
* 构造一个成功且带数据的API返回
*
* @param data 返回数据
* @return ApiResponse
*/
public static <T> ApiResponse<T> ofSuccess(T data) {
return ofStatus(Status.OK, data,Boolean.TRUE);
}

/**
* 构造一个成功且自定义消息的API返回
*
* @param message 返回内容
* @return ApiResponse
*/
public static <T> ApiResponse<T> ofMessage(String message) {
return of(Status.OK.getCode(), message, null,Boolean.TRUE);
}

/**
* 构造一个有状态的API返回
*
* @param status 状态 {@link Status}
* @return ApiResponse
*/
public static <T> ApiResponse<T> ofStatus(ApiStatus status) {
return ofStatus(status, null,Boolean.TRUE);
}

/**
* 构造一个有状态且带数据的API返回
*
* @param status 状态 {@link Status}
* @param data 返回数据
* @return ApiResponse
*/
public static <T> ApiResponse<T> ofStatus(ApiStatus status, T data,Boolean success) {
return of(status.getCode(), status.getReasonPhrase(), data,success);
}
}

+ 7
- 1
pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DefaultDeclaredProjectManage.java Переглянути файл

@@ -178,7 +178,8 @@ public class DefaultDeclaredProjectManage {
startOrgInfoDto.setOrgModelMap(orgModelsList.stream()
.filter(v -> v.getOrgCode().equals(startOrgCode)
&& Boolean.FALSE.equals(v.getIsDelete())
&& (ProcessDefTypeEnum.SEAL.name().equals(v.getType()) ||
&& (ProcessDefTypeEnum.SEAL.name().equals(v.getType())||
ProcessDefTypeEnum.JOINT_REVIEW.name().equals(v.getType()) ||
ProcessDefTypeEnum.DEFAULT.name().equals(v.getType())))
.collect(Collectors.toMap(WflowOrgModels::getType, v -> v)));

@@ -189,6 +190,7 @@ public class DefaultDeclaredProjectManage {
.filter(v -> v.getOrgCode().equals(startOrgParentCode)
&& Boolean.FALSE.equals(v.getIsDelete())
&& (ProcessDefTypeEnum.SEAL.name().equals(v.getType()) ||
ProcessDefTypeEnum.JOINT_REVIEW.name().equals(v.getType()) ||
ProcessDefTypeEnum.DEFAULT.name().equals(v.getType())))
.collect(Collectors.toMap(WflowOrgModels::getType, v -> v)));

@@ -211,6 +213,7 @@ public class DefaultDeclaredProjectManage {
.filter(v -> v.getOrgCode().equals(project.getHigherSuperOrgCode())
&& Boolean.FALSE.equals(v.getIsDelete())
&& (ProcessDefTypeEnum.SEAL.name().equals(v.getType()) ||
ProcessDefTypeEnum.JOINT_REVIEW.name().equals(v.getType()) ||
ProcessDefTypeEnum.DEFAULT.name().equals(v.getType())))
.collect(Collectors.toMap(WflowOrgModels::getType, v -> v)));

@@ -246,6 +249,7 @@ public class DefaultDeclaredProjectManage {
.filter(v -> v.getOrgCode().equals(startOrgCode)
&& Boolean.FALSE.equals(v.getIsDelete())
&& (ProcessDefTypeEnum.SEAL.name().equals(v.getType()) ||
ProcessDefTypeEnum.JOINT_REVIEW.name().equals(v.getType()) ||
ProcessDefTypeEnum.DEFAULT.name().equals(v.getType())))
.collect(Collectors.toMap(WflowOrgModels::getType, v -> v)));

@@ -256,6 +260,7 @@ public class DefaultDeclaredProjectManage {
.filter(v -> v.getOrgCode().equals(startOrgParentCode)
&& Boolean.FALSE.equals(v.getIsDelete())
&& (ProcessDefTypeEnum.SEAL.name().equals(v.getType()) ||
ProcessDefTypeEnum.JOINT_REVIEW.name().equals(v.getType()) ||
ProcessDefTypeEnum.DEFAULT.name().equals(v.getType())))
.collect(Collectors.toMap(WflowOrgModels::getType, v -> v)));

@@ -278,6 +283,7 @@ public class DefaultDeclaredProjectManage {
.filter(v -> v.getOrgCode().equals(project.getHigherSuperOrgCode())
&& Boolean.FALSE.equals(v.getIsDelete())
&& (ProcessDefTypeEnum.SEAL.name().equals(v.getType()) ||
ProcessDefTypeEnum.JOINT_REVIEW.name().equals(v.getType()) ||
ProcessDefTypeEnum.DEFAULT.name().equals(v.getType())))
.collect(Collectors.toMap(WflowOrgModels::getType, v -> v)));



+ 2
- 0
pmapi/src/main/java/com/ningdatech/pmapi/projectlib/service/IProjectService.java Переглянути файл

@@ -20,4 +20,6 @@ public interface IProjectService extends IService<Project> {
public List<Long> getAllVersionProjectId(Long projectId);

Project getNewProject(Long projectId);

Project getProjectByCode(String projectCode);
}

+ 9
- 0
pmapi/src/main/java/com/ningdatech/pmapi/projectlib/service/impl/ProjectServiceImpl.java Переглянути файл

@@ -70,4 +70,13 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl

return newest;
}

@Override
public Project getProjectByCode(String projectCode) {
Project project = this.getOne(Wrappers.lambdaQuery(Project.class)
.eq(Project::getProjectCode, projectCode)
.eq(Project::getNewest,Boolean.TRUE)
.last(BizConst.LIMIT_1));
return project;
}
}

+ 8
- 0
pmapi/src/main/resources/application-dev.yml Переглянути файл

@@ -214,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:


+ 4
- 0
pmapi/src/main/resources/application-prod.yml Переглянути файл

@@ -217,6 +217,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:


Завантаження…
Відмінити
Зберегти