Преглед на файлове

重大项目联审发送线上

master
PoffyZhang преди 1 година
родител
ревизия
97addd8361
променени са 12 файла, в които са добавени 136 реда и са изтрити 57 реда
  1. +2
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/common/config/ProvincialProperties.java
  2. +3
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/common/constant/BizConst.java
  3. +1
    -51
      pmapi/src/main/java/com/ningdatech/pmapi/ding/controller/DingInfoPullController.java
  4. +11
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/organization/manage/GovBusinessStripManage.java
  5. +10
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/provincial/service/IJoinReviewProvincialBureauService.java
  6. +88
    -6
      pmapi/src/main/java/com/ningdatech/pmapi/provincial/service/impl/JoinReviewProvincialBureauServiceImpl.java
  7. +6
    -0
      pmapi/src/main/resources/application-dev.yml
  8. +6
    -0
      pmapi/src/main/resources/application-pre.yml
  9. +6
    -0
      pmapi/src/main/resources/application-prod.yml
  10. +1
    -0
      pmapi/src/test/resources/application-dev.yml
  11. +1
    -0
      pmapi/src/test/resources/application-pre.yml
  12. +1
    -0
      pmapi/src/test/resources/application-prod.yml

+ 2
- 0
pmapi/src/main/java/com/ningdatech/pmapi/common/config/ProvincialProperties.java Целия файл

@@ -21,6 +21,8 @@ public class ProvincialProperties {

private String detailUrl;

private String domainUrl;

private String key;

private String secret;


+ 3
- 0
pmapi/src/main/java/com/ningdatech/pmapi/common/constant/BizConst.java Целия файл

@@ -85,4 +85,7 @@ public interface BizConst {

int MAX_EXPORT_COUNT = 5000;

String RESPONSE_KEY_DATA = "data";
String ORG_NAME = "organizationName";
String ORG_CODE = "organizationCode";
}

+ 1
- 51
pmapi/src/main/java/com/ningdatech/pmapi/ding/controller/DingInfoPullController.java Целия файл

@@ -2,27 +2,22 @@ package com.ningdatech.pmapi.ding.controller;

import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil;
import com.google.common.collect.Maps;
import com.ningdatech.irs.service.IRefreshTokenService;
import com.ningdatech.pmapi.common.config.ProvincialProperties;
import com.ningdatech.pmapi.common.util.CryptUtils;
import com.ningdatech.pmapi.common.util.HttpUtil;
import com.ningdatech.pmapi.ding.task.EmployeeBatchGetTask;
import com.ningdatech.pmapi.ding.task.GovBusinessStripsTask;
import com.ningdatech.pmapi.ding.task.OrganizationBatchGetTask;
import com.ningdatech.pmapi.organization.manage.ProcDefManage;
import com.ningdatech.zwdd.ZwddIntegrationProperties;
import com.ningdatech.zwdd.client.provider.ZwddAuthClientProvider;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;
import java.security.NoSuchAlgorithmException;
import java.util.Objects;
@@ -55,11 +50,6 @@ public class DingInfoPullController {
@Value("${irs.interface-refresh.refresh-token-url}")
private String govRefreshTokenUrl;

private final ZwddIntegrationProperties zwddIntegrationProperties;

@Autowired
private ProvincialProperties provincialProperties;

@GetMapping("/employee")
public void employeeBatchGet() {
employeeBatchGetTask.batchGetEmployeeTask();
@@ -117,36 +107,6 @@ public class DingInfoPullController {
return procDefManage.initByArea(areaCode);
}

@ApiOperation(value = "省级主管接口测试", notes = "省级主管接口测试")
@GetMapping("/test-org")
public String testOrg() throws NoSuchAlgorithmException {
Long timeStamp = System.currentTimeMillis();
String appSecret = "496f0f2a19994f76b4fd9dae087366c7";
String appKey = "A331101453557202109017383";
String method = "POST";
String secret = refreshTokenService.refreshToken(appKey,appSecret,govRequestTokenUrl,govRefreshTokenUrl,method);
String sign = CryptUtils.MD5Encode(appKey + secret + timeStamp);
HttpComponentsClientHttpRequestFactory factory = HttpUtil.generateHttpRequestFactory();
RestTemplate restTemplate;
if(Objects.nonNull(factory)){
restTemplate = new RestTemplate(factory);
}else{
restTemplate = new RestTemplate();
}

String url = "https://interface.zjzwfw.gov.cn/gateway" +
"/api/proxy/001003001029/dataSharing/62vd5jAdM0b7Gr00.htm?" +
"requestTime=" + timeStamp + "&sign=" + sign +
"&appKey=" + appKey + "&timestamp=" + timeStamp +
"&authSignature=" + getSha256(timeStamp/1000,provincialProperties.getPushUrl(), HttpMethod.GET.name()) +
"&authKey=" + provincialProperties.getKey();
log.info("url :{}",url);
ResponseEntity<String> forEntity = restTemplate.getForEntity(url, String.class);
log.info(forEntity.getBody());

return forEntity.getBody();
}

@ApiOperation(value = "测试项目归并", notes = "测试项目归并")
@GetMapping("/test-guibing")
public String testGuibing() throws NoSuchAlgorithmException {
@@ -177,14 +137,4 @@ public class DingInfoPullController {
log.info(forEntity.getBody());
return forEntity.getBody();
}

private String getSha256(Long timeStamp,String url,String method){
String secret = provincialProperties.getSecret();
String key = provincialProperties.getKey();
String bytesToSign = method + StrUtil.LF + url + StrUtil.LF + timeStamp + StrUtil.LF + key;
log.info("加密message :{}",bytesToSign);
String res = SecureUtil.hmacSha256(secret).digestBase64(bytesToSign,false);
log.info("加密结果 :{}",res);
return res;
}
}

+ 11
- 0
pmapi/src/main/java/com/ningdatech/pmapi/organization/manage/GovBusinessStripManage.java Целия файл

@@ -8,8 +8,10 @@ import com.ningdatech.pmapi.organization.model.vo.GovBusinessStripTreeVO;
import com.ningdatech.pmapi.organization.model.vo.ProvincialGovBusinessStripVO;
import com.ningdatech.pmapi.organization.service.IGovBusinessStripService;
import com.ningdatech.pmapi.organization.service.IProvincialGovBusinessStripService;
import com.ningdatech.pmapi.provincial.service.IJoinReviewProvincialBureauService;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
@@ -30,6 +32,11 @@ public class GovBusinessStripManage {

private final IProvincialGovBusinessStripService provincialGovBusinessStripService;

private final IJoinReviewProvincialBureauService joinReviewProvincialBureauService;

@Value("${irs.province-gov.can-search}")
private Boolean canSearch;

public List<GovBusinessStripTreeVO> getChildOrganizationList(String parentCode) {
if (Objects.isNull(parentCode)) {
parentCode = "-1";
@@ -48,6 +55,10 @@ public class GovBusinessStripManage {
}

public List<ProvincialGovBusinessStripVO> getProvincialGovBusinessStripList(String businessStripName) {
if(Objects.nonNull(canSearch) && canSearch){
return joinReviewProvincialBureauService.searchGovUnits();
}

List<ProvincialGovBusinessStrip> strips = provincialGovBusinessStripService.list(Wrappers.lambdaQuery(ProvincialGovBusinessStrip.class)
.orderByAsc(ProvincialGovBusinessStrip::getBusinessStripName));



+ 10
- 0
pmapi/src/main/java/com/ningdatech/pmapi/provincial/service/IJoinReviewProvincialBureauService.java Целия файл

@@ -1,8 +1,12 @@
package com.ningdatech.pmapi.provincial.service;

import com.ningdatech.pmapi.organization.model.vo.ProvincialGovBusinessStripVO;
import com.ningdatech.pmapi.provincial.model.dto.ProvincialProjectDTO;
import com.ningdatech.pmapi.provincial.model.res.SjApiResponse;

import java.security.NoSuchAlgorithmException;
import java.util.List;

/**
* @Classname JointReviewProvincialBureauService
* @Description 省局联审接口
@@ -23,4 +27,10 @@ public interface IJoinReviewProvincialBureauService {
* @return
*/
SjApiResponse processInfo(String projectId);

/**
* 查询省级主管单位列表
* @return
*/
List<ProvincialGovBusinessStripVO> searchGovUnits();
}

+ 88
- 6
pmapi/src/main/java/com/ningdatech/pmapi/provincial/service/impl/JoinReviewProvincialBureauServiceImpl.java Целия файл

@@ -1,23 +1,38 @@
package com.ningdatech.pmapi.provincial.service.impl;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.crypto.digest.MD5;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ningdatech.basic.model.ApiResponse;
import com.google.common.collect.Maps;
import com.ningdatech.irs.contants.IrsContant;
import com.ningdatech.irs.service.IRefreshTokenService;
import com.ningdatech.pmapi.common.config.ProvincialProperties;
import com.ningdatech.pmapi.common.constant.BizConst;
import com.ningdatech.pmapi.common.util.HttpUtil;
import com.ningdatech.pmapi.organization.model.vo.ProvincialGovBusinessStripVO;
import com.ningdatech.pmapi.provincial.model.dto.ProvinceApiResponse;
import com.ningdatech.pmapi.provincial.model.dto.ProvincialProjectDTO;
import com.ningdatech.pmapi.provincial.model.res.SjApiResponse;
import com.ningdatech.pmapi.provincial.service.IJoinReviewProvincialBureauService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.http.RequestEntity;
import org.springframework.http.ResponseEntity;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
* @Classname JointReviewProvincialBureauService
@@ -35,6 +50,23 @@ public class JoinReviewProvincialBureauServiceImpl implements IJoinReviewProvinc
@Autowired
private RestTemplate restTemplate;

@Resource(name = "refreshToken")
private IRefreshTokenService refreshTokenService;

@Value("${irs.interface-refresh.request-token-url}")
private String govRequestTokenUrl;
@Value("${irs.interface-refresh.refresh-token-url}")
private String govRefreshTokenUrl;

@Value("${irs.province-gov.url}")
private String govUrl;

@Value("${irs.province-gov.appSecret}")
private String govAppSecret;

@Value("${irs.province-gov.appKey}")
private String govAppKey;

/**
* 推送/保存 重大接口到 省局联审
* @return
@@ -48,7 +80,7 @@ public class JoinReviewProvincialBureauServiceImpl implements IJoinReviewProvinc
ResponseEntity<ProvinceApiResponse> responseEntity = null;

String signature = getSha256(timeStamp,provincialProperties.getPushUrl(),
HttpMethod.POST.name());
HttpMethod.POST.name(),provincialProperties.getKey(),provincialProperties.getSecret());

//发送post请求
RequestEntity<ProvincialProjectDTO> requestEntity = RequestEntity
@@ -90,7 +122,7 @@ public class JoinReviewProvincialBureauServiceImpl implements IJoinReviewProvinc
ResponseEntity<SjApiResponse> responseEntity = null;

String signature = getSha256(timeStamp,provincialProperties.getDetailUrl(),
HttpMethod.POST.name());
HttpMethod.POST.name(),provincialProperties.getKey(),provincialProperties.getSecret());

JSONObject jsonBaby = new JSONObject();
jsonBaby.put("projectId",projectId);
@@ -114,9 +146,59 @@ public class JoinReviewProvincialBureauServiceImpl implements IJoinReviewProvinc
return responseEntity.getBody();
}

private String getSha256(Long timeStamp,String url,String method){
String secret = provincialProperties.getSecret();
String key = provincialProperties.getKey();
@Override
public List<ProvincialGovBusinessStripVO> searchGovUnits() {
Long timeStamp = System.currentTimeMillis()/1000;
String appSecret = govAppSecret;
String appKey = govAppKey;
String method = HttpMethod.POST.name();
String secret = refreshTokenService.refreshToken(appKey,appSecret,govRequestTokenUrl,govRefreshTokenUrl,method);
String sign = MD5.create().digestHex(appKey + secret + timeStamp * 1000);
HttpComponentsClientHttpRequestFactory factory = HttpUtil.generateHttpRequestFactory();
RestTemplate restTemplate;
if(Objects.nonNull(factory)){
restTemplate = new RestTemplate(factory);
}else{
restTemplate = new RestTemplate();
}

String authSignature = getSha256(timeStamp,provincialProperties.getDomainUrl(), HttpMethod.POST.name(),
provincialProperties.getKey(),provincialProperties.getSecret());
String url = govUrl + "?appKey=" + appKey +
"&timestamp=" + timeStamp + "&sign=" + sign +
"&authKey=" + provincialProperties.getKey() + "&authSignature=" + authSignature +
"&requestTime=" + timeStamp*1000;
log.info("gov search url :{}",url);
ResponseEntity<JSONObject> forEntity = restTemplate.postForEntity(url,null, JSONObject.class, Maps.newHashMap());
JSONObject body = forEntity.getBody();
log.info("seach response :{}",body);
if(Objects.isNull(body)){
return Collections.emptyList();
}
String code = body.getString(IrsContant.RefreshToken.RESPONSE_KEY_CODE);
if(IrsContant.RefreshToken.SUCESS_CODE.equals(code)){
JSONObject datas = body.getJSONObject(IrsContant.RefreshToken.RESPONSE_KEY_DATAS);

if(Objects.isNull(datas)){
return Collections.emptyList();
}
JSONArray jsonArray = datas.getJSONArray(BizConst.RESPONSE_KEY_DATA);
if(CollUtil.isEmpty(jsonArray)){
return Collections.emptyList();
}
return jsonArray.stream().map(j -> {
JSONObject json = JSON.parseObject(JSON.toJSONString(j));
ProvincialGovBusinessStripVO vo = new ProvincialGovBusinessStripVO();
vo.setBusinessStripCode(json.getString(BizConst.ORG_CODE));
vo.setBusinessStripName(json.getString(BizConst.ORG_NAME));
return vo;
}).collect(Collectors.toList());
}

return Collections.emptyList();
}

private static String getSha256(Long timeStamp,String url,String method,String key,String secret){
String bytesToSign = method + StrUtil.LF + url + StrUtil.LF + timeStamp + StrUtil.LF + key;
log.info("加密message :{}",bytesToSign);
String res = SecureUtil.hmacSha256(secret).digestBase64(bytesToSign,false);


+ 6
- 0
pmapi/src/main/resources/application-dev.yml Целия файл

@@ -198,6 +198,7 @@ provincial:
host: http://223.4.72.75/prometheus-zhejiang_foreign
pushUrl: /api/v1/foreign/importantPro
detailUrl: /api/v1/foreign/importantProView
domainUrl: /api/v1/foreign/dominantUnit
key: 7fb48b518c6044a5a44deddd11b445e3
secret: ced8fff70018413c9516c58f95885624

@@ -223,6 +224,11 @@ irs:
url: https://interface.zjzwfw.gov.cn/gateway/api/001003001029/dataSharing/XS8daav3bcemZ3Ra.htm
appScret: 496f0f2a19994f76b4fd9dae087366c7
appKey: A331101453557202109017383
province-gov:
can-search: false
url: https://interface.zjzwfw.gov.cn/gateway/api/proxy/001003001029/dataSharing/62vd5jAdM0b7Gr00.htm
appSecret: 496f0f2a19994f76b4fd9dae087366c7
appKey: A331101453557202109017383
interface-refresh:
method: POST
request-token-url: https://interface.zjzwfw.gov.cn/gateway/app/refreshTokenByKey.htm?appKey={appKey}&requestTime={requestTime}&sign={sign}


+ 6
- 0
pmapi/src/main/resources/application-pre.yml Целия файл

@@ -196,6 +196,7 @@ provincial:
host: https://pms.zj.gov.cn/prometheus-zhejiang_foreign
pushUrl: /api/v1/foreign/importantPro
detailUrl: /api/v1/foreign/importantProView
domainUrl: /api/v1/foreign/dominantUnit
key: b5b2096953534a53991be4ea95f8cffa
secret: 1bec9b77134d4962ac466fbe9696b897
# host: http://223.4.72.75/prometheus-zhejiang_foreign
@@ -226,6 +227,11 @@ irs:
url: https://interface.zjzwfw.gov.cn/gateway/api/001003001029/dataSharing/XS8daav3bcemZ3Ra.htm
appScret: 496f0f2a19994f76b4fd9dae087366c7
appKey: A331101453557202109017383
province-gov:
can-search: true
url: https://interface.zjzwfw.gov.cn/gateway/api/proxy/001003001029/dataSharing/62vd5jAdM0b7Gr00.htm
appSecret: 496f0f2a19994f76b4fd9dae087366c7
appKey: A331101453557202109017383
interface-refresh:
method: POST
request-token-url: https://interface.zjzwfw.gov.cn/gateway/app/refreshTokenByKey.htm?appKey={appKey}&requestTime={requestTime}&sign={sign}


+ 6
- 0
pmapi/src/main/resources/application-prod.yml Целия файл

@@ -196,6 +196,7 @@ provincial:
host: https://pms.zj.gov.cn/prometheus-zhejiang_foreign
pushUrl: /api/v1/foreign/importantPro
detailUrl: /api/v1/foreign/importantProView
domainUrl: /api/v1/foreign/dominantUnit
key: b5b2096953534a53991be4ea95f8cffa
secret: 1bec9b77134d4962ac466fbe9696b897
# host: http://223.4.72.75/prometheus-zhejiang_foreign
@@ -226,6 +227,11 @@ irs:
url: https://interface.zjzwfw.gov.cn/gateway/api/001003001029/dataSharing/XS8daav3bcemZ3Ra.htm
appScret: 496f0f2a19994f76b4fd9dae087366c7
appKey: A331101453557202109017383
province-gov:
can-search: true
url: https://interface.zjzwfw.gov.cn/gateway/api/proxy/001003001029/dataSharing/62vd5jAdM0b7Gr00.htm
appSecret: 496f0f2a19994f76b4fd9dae087366c7
appKey: A331101453557202109017383
interface-refresh:
method: POST
request-token-url: https://interface.zjzwfw.gov.cn/gateway/app/refreshTokenByKey.htm?appKey={appKey}&requestTime={requestTime}&sign={sign}


+ 1
- 0
pmapi/src/test/resources/application-dev.yml Целия файл

@@ -197,6 +197,7 @@ provincial:
host: http://zj.ningdatech.com/prometheus-zhejiang_foreign
pushUrl: /api/v1/foreign/importantPro
detailUrl: /api/v1/foreign/importantProView
domainUrl: /api/v1/foreign/dominantUnit
key: 7196317343a64e67895dc0375c098fe7
secret: 75152a97f20e4c4c854dc6301cf72ad4



+ 1
- 0
pmapi/src/test/resources/application-pre.yml Целия файл

@@ -201,6 +201,7 @@ provincial:
host: http://223.4.72.75/prometheus-zhejiang_foreign
pushUrl: /api/v1/foreign/importantPro
detailUrl: /api/v1/foreign/importantProView
domainUrl: /api/v1/foreign/dominantUnit
key: 7fb48b518c6044a5a44deddd11b445e3
secret: ced8fff70018413c9516c58f95885624



+ 1
- 0
pmapi/src/test/resources/application-prod.yml Целия файл

@@ -196,6 +196,7 @@ provincial:
host: https://pms.zj.gov.cn/prometheus-zhejiang_foreign
pushUrl: /api/v1/foreign/importantPro
detailUrl: /api/v1/foreign/importantProView
domainUrl: /api/v1/foreign/dominantUnit
key: b5b2096953534a53991be4ea95f8cffa
secret: 1bec9b77134d4962ac466fbe9696b897



Loading…
Отказ
Запис