Browse Source

获取试运行报告

master
PoffyZhang 1 year ago
parent
commit
d7096ab256
4 changed files with 105 additions and 7 deletions
  1. +99
    -5
      pmapi/src/main/java/com/ningdatech/pmapi/ding/controller/DingInfoPullController.java
  2. +2
    -2
      pmapi/src/main/java/com/ningdatech/pmapi/irs/manage/AppIrsManage.java
  3. +1
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ApplicationManage.java
  4. +3
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/dto/ProjectDTO.java

+ 99
- 5
pmapi/src/main/java/com/ningdatech/pmapi/ding/controller/DingInfoPullController.java View File

@@ -4,6 +4,8 @@ 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;
@@ -20,16 +22,24 @@ import com.sun.crypto.provider.HmacMD5KeyGenerator;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
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.UnsupportedEncodingException;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.time.LocalDateTime;
import java.util.Objects;

/**
@@ -119,9 +129,93 @@ public class DingInfoPullController {
return procDefManage.initByArea(areaCode);
}

@ApiOperation(value = "测试项目详情推送", notes = "测试项目详情推送")
@GetMapping("/test-push-project")
public String testPushProject(@ModelAttribute ProjectDTO projectDto) throws Exception {
return appIrsManage.pushProjectDetail(projectDto);
@ApiOperation(value = "项目详情推送", notes = "项目详情推送")
@GetMapping("/push-project")
public String pushProject() throws Exception {
File f = new File("/temp/遂昌归集项目信息(需补).xlsx");
// File f = new File("C:\\Users\\PoffyZhang\\Desktop\\遂昌归集项目信息(需补).xlsx");
Workbook wb = readExcel(new FileInputStream(f),f.getName());
Assert.notNull(wb,"文件流为空");
Row row;
Integer sucessNum = 0;
if(wb != null){
//获取第一个sheet
Sheet sheet = wb.getSheetAt(0);
//获取最大行数
int rownum = sheet.getPhysicalNumberOfRows();
//获取第一行
row = sheet.getRow(0);
//获取最大列数
for (int i = 1; i<rownum; i++) {
row = sheet.getRow(i);
if(Objects.isNull(row) || Objects.isNull(row.getCell(0))){
//取不到数据了 停止
log.info("数据取完");
break;
}
ProjectDTO projectDto = new ProjectDTO();

projectDto.setProjectCode(row.getCell(0).toString());
projectDto.setProjectName(row.getCell(1).toString());
projectDto.setArea(row.getCell(2).toString());
projectDto.setAreaCode(row.getCell(3).toString());
String baseProjType = String.valueOf(row.getCell(4));
if(StringUtils.isNotBlank(baseProjType) && baseProjType.contains(".")){
baseProjType = baseProjType.substring(0,
baseProjType.indexOf("."));
}
projectDto.setBaseProjType(baseProjType);
projectDto.setBaseConstructionType(String.valueOf(row.getCell(5)));
projectDto.setBaseProjConsClass(String.valueOf(row.getCell(6)));
projectDto.setBaseLowestLevel(String.valueOf(row.getCell(7)));
projectDto.setProjectYear(Integer.valueOf(String.valueOf(row.getCell(8))));
projectDto.setBaseProjBasis(String.valueOf(row.getCell(9)));
projectDto.setBuildBasis(String.valueOf(row.getCell(10)));
String baseProjSerProg = String.valueOf(row.getCell(12));
if(StringUtils.isNotBlank(baseProjSerProg) && baseProjSerProg.contains(".")){
baseProjSerProg = baseProjSerProg.substring(0,
baseProjSerProg.indexOf("."));
}
projectDto.setBaseProjSetProg(baseProjSerProg);
projectDto.setResponsibleMan(String.valueOf(row.getCell(13)));
projectDto.setResponsibleManMobile(String.valueOf(row.getCell(14)));
projectDto.setContactName(String.valueOf(row.getCell(15)));
projectDto.setContactPhone(String.valueOf(row.getCell(16)));
projectDto.setBuildOrgName(String.valueOf(row.getCell(18)));
projectDto.setBuildOrgCode(String.valueOf(row.getCell(19)));
projectDto.setSuperOrg(String.valueOf(row.getCell(21)));
projectDto.setSuperOrgCode(String.valueOf(row.getCell(22)));
projectDto.setHigherSuperOrg(String.valueOf(row.getCell(24)));
projectDto.setHigherSuperOrgCode(String.valueOf(row.getCell(25)));

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

if(StringUtils.isNotBlank(appIrsManage.pushProjectDetail(projectDto))){
sucessNum ++;
}
}
}

return "推送IRS项目详情成功数量:" + sucessNum;
}

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

extString = extString.substring(extString.lastIndexOf("."));
try {
if(".xls".equals(extString)){
return wb = new HSSFWorkbook(is);
}else if(".xlsx".equals(extString)){
return wb = new XSSFWorkbook(is);
}else {
return wb = null;
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return wb;
}
}

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

@@ -304,7 +304,7 @@ public class AppIrsManage {
String ProjPrincipalCall = projectDto.getResponsibleManMobile();//"13884366607"
//内容类别
String baseConstructionType = projectDto.getBaseConstructionType();//"01"
String baseProjType = String.valueOf(projectDto.getProjectType());//"1"
String baseProjType = projectDto.getBaseProjType();//"1"
String baseProjContacts = projectDto.getContactName();//"毛以林"
String isEffective = "1";
String baseConsDeprtDing = projectDto.getBuildOrgCode();//"GO_9a7dce7fbaf54787998fa004f1b7c0e1";
@@ -324,7 +324,7 @@ public class AppIrsManage {
log.error(e.getMessage());
}

String url = "https://interface.zjzwfw.gov.cn/gateway/api/proxy/001003001029/dataSharing/3XN9R93Pva6db7sf.htm?" +
String url = pushProjectUrl+ "?" +
"requestTime=" + timestamp + "&sign=" + sign +
"&appKey=" + appKey + "&baseProjPrincipal=" + baseProjPrincipal + "" +
"&baseProjSetYear=" + baseProjSetYear + "&baseProjId=" + baseProjId +


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

@@ -106,6 +106,7 @@ public class ApplicationManage {
RestTemplate restTemplate = new RestTemplate();
ResponseEntity<ApiResponse> forEntity = restTemplate.exchange(appUrl, HttpMethod.GET,formEntity, ApiResponse.class);

log.info("forEntity:",JSON.toJSONString(forEntity));
log.info("body:",forEntity.getBody());
ApiResponse body = forEntity.getBody();



+ 3
- 0
pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/dto/ProjectDTO.java View File

@@ -314,4 +314,7 @@ public class ProjectDTO implements Serializable {

//01政策、法规,02规划或决策部署,03上级下达任务,04领导批示,05单位核心业务或单位职能,00其他,多个时用中文;分割
private String baseProjBasis;

@ApiModelProperty("项目类型 01首次建设;02迭代升级;03结转建设;04新运维;05续运维")
private String baseProjType;
}

Loading…
Cancel
Save