Browse Source

Merge remote-tracking branch 'origin/master'

master
WendyYang 1 year ago
parent
commit
58096f6b67
6 changed files with 96 additions and 24 deletions
  1. +69
    -13
      pmapi/src/main/java/com/ningdatech/pmapi/ding/controller/DingInfoPullController.java
  2. +1
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/irs/controller/ApplicationController.java
  3. +2
    -2
      pmapi/src/main/java/com/ningdatech/pmapi/irs/manage/AppIrsManage.java
  4. +12
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java
  5. +9
    -5
      pmapi/src/test/java/com/ningdatech/pmapi/irs/IrsTest.java
  6. +3
    -3
      pmapi/src/test/resources/application-prod.yml

+ 69
- 13
pmapi/src/main/java/com/ningdatech/pmapi/ding/controller/DingInfoPullController.java View File

@@ -1,15 +1,9 @@
package com.ningdatech.pmapi.ding.controller;

import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.crypto.digest.HMac;
import cn.hutool.crypto.digest.MD5;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Maps;
import com.ningdatech.irs.service.IRefreshTokenService;
import com.ningdatech.pmapi.common.util.CryptUtils;
import com.ningdatech.pmapi.common.util.HttpUtil;
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;
@@ -17,8 +11,7 @@ import com.ningdatech.pmapi.irs.manage.AppIrsManage;
import com.ningdatech.pmapi.organization.manage.ProcDefManage;
import com.ningdatech.pmapi.projectlib.model.dto.ProjectDTO;
import com.ningdatech.pmapi.projectlib.model.entity.Project;
import com.sun.crypto.provider.HmacMD5;
import com.sun.crypto.provider.HmacMD5KeyGenerator;
import com.ningdatech.pmapi.projectlib.service.IProjectService;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -30,16 +23,12 @@ import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.time.LocalDateTime;
import java.util.Objects;

/**
@@ -72,6 +61,8 @@ public class DingInfoPullController {

private final AppIrsManage appIrsManage;

private final IProjectService projectService;

@GetMapping("/employee")
public void employeeBatchGet() {
employeeBatchGetTask.batchGetEmployeeTask();
@@ -199,6 +190,71 @@ public class DingInfoPullController {
return "推送IRS项目详情成功数量:" + sucessNum;
}

@ApiOperation(value = "应用和项目关系推送", notes = "应用和项目关系推送")
@GetMapping("/push-app-project")
public String pushAppProject() throws Exception {
long timestamp = System.currentTimeMillis();
String areaCode = "331123";
String appKey = "A331101453557202109017383";
String appScret = "496f0f2a19994f76b4fd9dae087366c7";
String baseProjSys = "初次建设的应用21";
String baseProjSysCode = "A331123467587202307014177";
String baseProjName = "遂昌县-nsl-项目测试004";
String baseProjId = "331123230130123412186";
String requestSecret = RefreshKeyUtil.getRequestSecret(appKey, appScret);
String capCode = CryptUtils.encryptHMAC(timestamp + areaCode,"bcb4fc0f517fc168ee543fcf4d231f3b");
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=" + baseProjSys + "&areaCode=331123&baseProjName=" + baseProjName + "&baseProjId=" + baseProjId +
"&isEffective=1&baseProjSysCode=" + baseProjSysCode;
RestTemplate restTemplate = new RestTemplate();
log.info("url :{}",url);
ResponseEntity<String> forEntity = restTemplate.getForEntity(url, String.class);

log.info(JSON.toJSONString(forEntity));

return forEntity.getBody();
}

@ApiOperation(value = "项目详情推送", notes = "项目详情推送")
@GetMapping("/push-project-detail")
public String pushProjectDetail() throws NoSuchAlgorithmException {
Project project = projectService.getById(189L);
ProjectDTO projectDto = new ProjectDTO();

projectDto.setProjectCode(project.getProjectCode());
projectDto.setProjectName(project.getProjectName());
projectDto.setArea(project.getArea());
projectDto.setAreaCode(project.getAreaCode());
projectDto.setBaseProjType("1");
projectDto.setBaseConstructionType("03");
projectDto.setBaseProjConsClass("C");
projectDto.setBaseLowestLevel("C");
projectDto.setProjectYear(project.getProjectYear());
projectDto.setBaseProjBasis("1");
projectDto.setBuildBasis("01");
projectDto.setBaseProjSetProg("05");
projectDto.setResponsibleMan(project.getResponsibleMan());
projectDto.setResponsibleManMobile(project.getResponsibleManMobile());
projectDto.setContactName(project.getContactName());
projectDto.setContactPhone(project.getContactPhone());
projectDto.setBuildOrgName(project.getBuildOrgName());
projectDto.setBuildOrgCode(project.getBuildOrgCode());
projectDto.setSuperOrg(project.getSuperOrg());
projectDto.setSuperOrgCode(project.getSuperOrgCode());
projectDto.setHigherSuperOrg(project.getHigherSuperOrg());
projectDto.setHigherSuperOrgCode(project.getHigherSuperOrgCode());

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

if(StringUtils.isNotBlank(appIrsManage.pushProjectDetail(projectDto))){
return "推送成功";
}
return "推送失败";
}

public static Workbook readExcel(InputStream is, String extString){
Workbook wb = null;



+ 1
- 1
pmapi/src/main/java/com/ningdatech/pmapi/irs/controller/ApplicationController.java View File

@@ -32,7 +32,7 @@ public class ApplicationController {

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



+ 2
- 2
pmapi/src/main/java/com/ningdatech/pmapi/irs/manage/AppIrsManage.java View File

@@ -99,7 +99,7 @@ public class AppIrsManage {
* @return
* @throws NoSuchAlgorithmException
*/
public Boolean pushProjectApp(PushProjectAppToIrsDTO dto) throws NoSuchAlgorithmException {
public Boolean pushProjectApp(PushProjectAppToIrsDTO dto) throws Exception {
String appCode = dto.getAppCode();
Long appId = dto.getAppId();
String projectCode = dto.getProjectCode();
@@ -119,7 +119,7 @@ public class AppIrsManage {
String areaCode = project.getAreaCode();
String projectName = project.getProjectName();
String requestSecret = RefreshKeyUtil.getRequestSecret(pushAppKey, pushAppScret);
String capCode = CryptUtils.MD5Encode(timestamp + areaCode);
String capCode = CryptUtils.encryptHMAC(timestamp + areaCode,"bcb4fc0f517fc168ee543fcf4d231f3b");
String capTime = String.valueOf(timestamp);
String sign = CryptUtils.MD5Encode(pushAppKey + requestSecret + timestamp);
String url = pushUrl + "?requestTime=" + timestamp +


+ 12
- 0
pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java View File

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

List<ProjectApplication> apps = projectApplicationService.list(Wrappers.lambdaQuery(ProjectApplication.class)
.eq(ProjectApplication::getProjectId, oldProject.getId()));
if(CollUtil.isNotEmpty(apps)){
apps = apps.stream().map(app -> {
app.setProjectVersion(project.getVersion());
app.setProjectId(project.getId());
app.setId(null);
return app;
}).collect(Collectors.toList());
projectApplicationService.saveBatch(apps);
}
}

return project;


+ 9
- 5
pmapi/src/test/java/com/ningdatech/pmapi/irs/IrsTest.java View File

@@ -44,7 +44,8 @@ public class IrsTest extends AppTests {
@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 url = "https://bcdsg.zj.gov.cn:8443/restapi/prod/IC33000020230427000001/irs-res-bill/report/pdfUrl" +
"?appCode=A331123467587202307014177";
String appScret = "BCDSGS_4ab4235d26a9a357170a39f3a13fd68c";
String appKey = "BCDSGA_d874c8e46b541eb4e8aac6510fd3351b";

@@ -86,18 +87,21 @@ public class IrsTest extends AppTests {
@Test
public void test2() throws NoSuchAlgorithmException {
long timestamp = System.currentTimeMillis();
String areaCode = "331121";
String areaCode = "331123";
String appKey = "A331101453557202109017383";
String appScret = "496f0f2a19994f76b4fd9dae087366c7";

String baseProjSys = "初次建设的应用21";
String baseProjSysCode = "A331123467587202307014177";
String baseProjName = "遂昌县-nsl-项目测试004";
String baseProjId = "331123230130123412186";
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";
"&baseProjSys=" + baseProjSys + "&areaCode=331123&baseProjName=" + baseProjName + "&baseProjId=" + baseProjId +
"&isEffective=1&baseProjSysCode=" + baseProjSysCode;
RestTemplate restTemplate = new RestTemplate();
ResponseEntity<String> forEntity = restTemplate.getForEntity(url, String.class);



+ 3
- 3
pmapi/src/test/resources/application-prod.yml View File

@@ -13,9 +13,9 @@ spring:
namespace: "spring:session"
redis:
timeout: 5000
host: localhost
port: 6379
database: 0
host: 47.98.125.47
port: 26379
database: 4
password: Ndkj1234
jedis:
pool:


Loading…
Cancel
Save