Browse Source

Merge remote-tracking branch 'origin/master'

tags/24080901
CMM 1 year ago
parent
commit
f3170f8219
7 changed files with 152 additions and 13 deletions
  1. +2
    -6
      pmapi/src/main/java/com/ningdatech/pmapi/irs/sign/IRSAPIRequest.java
  2. +2
    -2
      pmapi/src/main/java/com/ningdatech/pmapi/projectlib/controller/ProjectApplicationController.java
  3. +43
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ApplicationManage.java
  4. +15
    -2
      pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java
  5. +5
    -1
      pmapi/src/main/resources/application-dev.yml
  6. +4
    -1
      pmapi/src/main/resources/application-prod.yml
  7. +81
    -0
      pmapi/src/test/java/com/ningdatech/pmapi/irs/IrsTest.java

+ 2
- 6
pmapi/src/main/java/com/ningdatech/pmapi/irs/sign/IRSAPIRequest.java View File

@@ -43,7 +43,7 @@ public class IRSAPIRequest {
* *
* @return * @return
*/ */
public static byte[] createSignPdf(SignReqDTO req) {
public static String createSignPdf(SignReqDTO req) {
String pdfEncode64 = req.getPdfEncode64(); String pdfEncode64 = req.getPdfEncode64();
Float posX = req.getPosX(); Float posX = req.getPosX();
Float posY = req.getPosY(); Float posY = req.getPosY();
@@ -79,11 +79,7 @@ public class IRSAPIRequest {
JSONObject object = JSON.parseObject(data, JSONObject.class); JSONObject object = JSON.parseObject(data, JSONObject.class);
// 获取盖好章的PDF文件内容Base64字符串 // 获取盖好章的PDF文件内容Base64字符串
String signFileB64 = object.getString("signFileB64"); String signFileB64 = object.getString("signFileB64");
if (Objects.nonNull(signFileB64)){
return Base64.getDecoder().decode(signFileB64);
}else {
return null;
}
return signFileB64;
} }






+ 2
- 2
pmapi/src/main/java/com/ningdatech/pmapi/projectlib/controller/ProjectApplicationController.java View File

@@ -27,8 +27,8 @@ public class ProjectApplicationController {
@GetMapping("/get-report") @GetMapping("/get-report")
@ApiOperation("获取应用 试运行报告") @ApiOperation("获取应用 试运行报告")
@WebLog("获取应用 试运行报告") @WebLog("获取应用 试运行报告")
public String getReport(@Valid @RequestBody ApplicationAppCodeSaveDTO dto) {
return applicationManage.getReport(dto);
public String getReport(@RequestParam(required = false) String appCode) {
return applicationManage.getReport(appCode);
} }


@PostMapping("/save-appcode") @PostMapping("/save-appcode")


+ 43
- 1
pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ApplicationManage.java View File

@@ -1,15 +1,25 @@
package com.ningdatech.pmapi.projectlib.manage; package com.ningdatech.pmapi.projectlib.manage;


import com.alibaba.fastjson.JSON;
import com.ningdatech.basic.function.VUtils; import com.ningdatech.basic.function.VUtils;
import com.ningdatech.pmapi.common.util.HmacAuthUtil;
import com.ningdatech.pmapi.projectlib.model.dto.ApplicationAppCodeSaveDTO; import com.ningdatech.pmapi.projectlib.model.dto.ApplicationAppCodeSaveDTO;
import com.ningdatech.pmapi.projectlib.model.entity.ProjectApplication; import com.ningdatech.pmapi.projectlib.model.entity.ProjectApplication;
import com.ningdatech.pmapi.projectlib.service.IProjectApplicationService; import com.ningdatech.pmapi.projectlib.service.IProjectApplicationService;
import com.ningdatech.pmapi.user.util.LoginUserUtil; import com.ningdatech.pmapi.user.util.LoginUserUtil;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
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.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;


import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.Map;
import java.util.Objects; import java.util.Objects;


/** /**
@@ -25,6 +35,15 @@ import java.util.Objects;
@Slf4j @Slf4j
public class ApplicationManage { public class ApplicationManage {


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

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

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

private final IProjectApplicationService applicationService; private final IProjectApplicationService applicationService;


/** /**
@@ -46,7 +65,30 @@ public class ApplicationManage {
return "保存失败"; return "保存失败";
} }


public String getReport(ApplicationAppCodeSaveDTO dto) {
/**
* 获取试运行报告
* @param appCode
* @return
*/
public String getReport(String appCode) {
String method = HttpMethod.GET.name();
String appUrl = url + "?appCode=" + appCode;

Map<String, String> header = HmacAuthUtil.generateHeader(appUrl, method, appKey, appScret);
//请求头
HttpHeaders headers = new HttpHeaders();

for(Map.Entry<String, String> entry : header.entrySet()){
headers.add(entry.getKey(), entry.getValue());
}
//封装请求头
HttpEntity<MultiValueMap<String, Object>> formEntity = new HttpEntity<MultiValueMap<String, Object>>(headers);

RestTemplate restTemplate = new RestTemplate();
ResponseEntity<String> forEntity = restTemplate.exchange(url, HttpMethod.GET,formEntity, String.class);

log.info("body:",forEntity.getBody());
String body = forEntity.getBody();


return null; return null;
} }


+ 15
- 2
pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java View File

@@ -105,6 +105,7 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import sun.misc.BASE64Decoder;


/** /**
* @author ZPF * @author ZPF
@@ -495,10 +496,22 @@ public class TodoCenterManage {
Integer signType = req.getSignType(); Integer signType = req.getSignType();
signReq.setSignType(signType); signReq.setSignType(signType);
// 调用盖章接口,获取盖章后返回的pdf文件字符数组 // 调用盖章接口,获取盖章后返回的pdf文件字符数组
byte[] signPdf = IRSAPIRequest.createSignPdf(signReq);
String signPdf = IRSAPIRequest.createSignPdf(signReq);
ByteArrayInputStream inputStream = null; ByteArrayInputStream inputStream = null;
if (Objects.nonNull(signPdf)) { if (Objects.nonNull(signPdf)) {
inputStream = new ByteArrayInputStream(signPdf);
BASE64Decoder decoder = new BASE64Decoder();
try {
//转码
byte[] b = decoder.decodeBuffer(signPdf);
for (int i = 0; i < b.length; ++i) {
if (b[i] < 0) {//调整异常数据
b[i] += 256;
}
}
inputStream = new ByteArrayInputStream(b);
}catch (Exception e){

}
} }
// 转换成MultipartFile // 转换成MultipartFile
MultipartFile multipartFile; MultipartFile multipartFile;


+ 5
- 1
pmapi/src/main/resources/application-dev.yml View File

@@ -209,10 +209,14 @@ irs:
access-key: 42bcb49bea174986a3bfdfba7d005566 access-key: 42bcb49bea174986a3bfdfba7d005566
secret-key: bebff29877d4443abd67fc4f8fb335d8 secret-key: bebff29877d4443abd67fc4f8fb335d8
api-url: https://bcdsg.zj.gov.cn:8443/restapi/prod/IC33000020220309000004/seal-platform/seal/v1/rest/sign/signPdf api-url: https://bcdsg.zj.gov.cn:8443/restapi/prod/IC33000020220309000004/seal-platform/seal/v1/rest/sign/signPdf

app-report:
url: https://bcdsg.zj.gov.cn:8443/restapi/prod/IC33000020230427000001/irs-res-bill/report/pdfUrl
appScret: BCDSGS_4ab4235d26a9a357170a39f3a13fd68c
appKey: BCDSGA_d874c8e46b541eb4e8aac6510fd3351b
hostname: iZbp13nwyvib53j4j1p2xoZ hostname: iZbp13nwyvib53j4j1p2xoZ


login: login:
phone-verify-code: phone-verify-code:
skip: true skip: true




+ 4
- 1
pmapi/src/main/resources/application-prod.yml View File

@@ -208,7 +208,10 @@ irs:
access-key: 42bcb49bea174986a3bfdfba7d005566 access-key: 42bcb49bea174986a3bfdfba7d005566
secret-key: bebff29877d4443abd67fc4f8fb335d8 secret-key: bebff29877d4443abd67fc4f8fb335d8
api-url: https://bcdsg.zj.gov.cn:8443/restapi/prod/IC33000020220309000004/seal-platform/seal/v1/rest/sign/signPdf api-url: https://bcdsg.zj.gov.cn:8443/restapi/prod/IC33000020220309000004/seal-platform/seal/v1/rest/sign/signPdf

app-report:
url: https://bcdsg.zj.gov.cn:8443/restapi/prod/IC33000020230427000001/irs-res-bill/report/pdfUrl
appScret: BCDSGS_4ab4235d26a9a357170a39f3a13fd68c
appKey: BCDSGA_d874c8e46b541eb4e8aac6510fd3351b
hostname: iZ6mx01gyeodd80imxd2gbZ hostname: iZ6mx01gyeodd80imxd2gbZ
login: login:
phone-verify-code: phone-verify-code:


+ 81
- 0
pmapi/src/test/java/com/ningdatech/pmapi/irs/IrsTest.java View File

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

import com.alibaba.fastjson.JSON;
import com.google.common.collect.Maps;
import com.ningdatech.pmapi.common.util.CryptUtils;
import com.ningdatech.pmapi.common.util.HmacAuthUtil;
import com.ningdatech.pmapi.common.util.RefreshKeyUtil;
import org.junit.Test;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;

import java.security.NoSuchAlgorithmException;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
* @Classname IrsTest
* @Description
* @Date 2023/6/26 17:42
* @Author PoffyZhang
*/
public class IrsTest {

@Test
public void test1(){
String method = "GET";
String url = "https://bcdsg.zj.gov.cn:8443/restapi/prod/IC33000020230427000001/irs-res-bill/report/pdfUrl?appCode=A330000100000202105005790";
String appScret = "BCDSGS_4ab4235d26a9a357170a39f3a13fd68c";
String appKey = "BCDSGA_d874c8e46b541eb4e8aac6510fd3351b";

Map<String, String> header = HmacAuthUtil.generateHeader(url, method, appKey, appScret);
//请求头
HttpHeaders headers = new HttpHeaders();

for(Map.Entry<String, String> entry : header.entrySet()){
headers.add(entry.getKey(), entry.getValue());
}
//封装请求头
HttpEntity<MultiValueMap<String, Object>> formEntity = new HttpEntity<MultiValueMap<String, Object>>(headers);

RestTemplate restTemplate = new RestTemplate();
ResponseEntity<String> forEntity = restTemplate.exchange(url, HttpMethod.GET,formEntity, String.class);

System.out.println(JSON.toJSONString(forEntity));
}

@Test
public void test2() 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);

System.out.println(JSON.toJSONString(forEntity));
}

@Test
public void test3() throws NoSuchAlgorithmException {
long timestamp = System.currentTimeMillis();
String areaCode = "331121";
System.out.println(CryptUtils.MD5Encode(timestamp + areaCode));
}
}

Loading…
Cancel
Save