|
|
@@ -1,9 +1,7 @@ |
|
|
|
package com.hz.pm.api.ding.controller; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.ningdatech.irs.service.IRefreshTokenService; |
|
|
|
import com.hz.pm.api.common.util.CryptUtils; |
|
|
|
import com.hz.pm.api.common.util.RefreshKeyUtil; |
|
|
|
import com.hz.pm.api.ding.task.EmployeeBatchGetTask; |
|
|
|
import com.hz.pm.api.ding.task.GovBusinessStripsTask; |
|
|
|
import com.hz.pm.api.ding.task.OrganizationBatchGetTask; |
|
|
@@ -14,6 +12,7 @@ import com.hz.pm.api.projectdeclared.manage.IrsManage; |
|
|
|
import com.hz.pm.api.projectlib.model.dto.ProjectDTO; |
|
|
|
import com.hz.pm.api.projectlib.model.entity.Project; |
|
|
|
import com.hz.pm.api.projectlib.service.IProjectService; |
|
|
|
import com.ningdatech.irs.service.IRefreshTokenService; |
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
@@ -29,9 +28,13 @@ import org.springframework.http.ResponseEntity; |
|
|
|
import org.springframework.util.Assert; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
import org.springframework.web.client.RestTemplate; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import javax.validation.Valid; |
|
|
|
import java.io.*; |
|
|
|
import java.io.File; |
|
|
|
import java.io.FileInputStream; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.InputStream; |
|
|
|
import java.security.NoSuchAlgorithmException; |
|
|
|
import java.util.Objects; |
|
|
|
|
|
|
@@ -116,7 +119,7 @@ public class DingInfoPullController { |
|
|
|
|
|
|
|
@GetMapping("/getToken") |
|
|
|
public String getToken() { |
|
|
|
return employeeBatchGetTask.getToken(); |
|
|
|
return employeeBatchGetTask.getToken(); |
|
|
|
} |
|
|
|
|
|
|
|
@GetMapping("/getAuthToken") |
|
|
@@ -141,11 +144,11 @@ public class DingInfoPullController { |
|
|
|
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,"文件流为空"); |
|
|
|
Workbook wb = readExcel(new FileInputStream(f), f.getName()); |
|
|
|
Assert.notNull(wb, "文件流为空"); |
|
|
|
Row row; |
|
|
|
Integer sucessNum = 0; |
|
|
|
if(wb != null){ |
|
|
|
if (wb != null) { |
|
|
|
//获取第一个sheet |
|
|
|
Sheet sheet = wb.getSheetAt(0); |
|
|
|
//获取最大行数 |
|
|
@@ -153,9 +156,9 @@ public class DingInfoPullController { |
|
|
|
//获取第一行 |
|
|
|
row = sheet.getRow(0); |
|
|
|
//获取最大列数 |
|
|
|
for (int i = 1; i<rownum; i++) { |
|
|
|
for (int i = 1; i < rownum; i++) { |
|
|
|
row = sheet.getRow(i); |
|
|
|
if(Objects.isNull(row) || Objects.isNull(row.getCell(0))){ |
|
|
|
if (Objects.isNull(row) || Objects.isNull(row.getCell(0))) { |
|
|
|
//取不到数据了 停止 |
|
|
|
log.info("数据取完"); |
|
|
|
break; |
|
|
@@ -167,7 +170,7 @@ public class DingInfoPullController { |
|
|
|
projectDto.setArea(row.getCell(2).toString()); |
|
|
|
projectDto.setAreaCode("331123000"); |
|
|
|
String baseProjType = String.valueOf(row.getCell(4)); |
|
|
|
if(StringUtils.isNotBlank(baseProjType) && baseProjType.contains(".")){ |
|
|
|
if (StringUtils.isNotBlank(baseProjType) && baseProjType.contains(".")) { |
|
|
|
baseProjType = baseProjType.substring(0, |
|
|
|
baseProjType.indexOf(".")); |
|
|
|
} |
|
|
@@ -179,7 +182,7 @@ public class DingInfoPullController { |
|
|
|
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(".")){ |
|
|
|
if (StringUtils.isNotBlank(baseProjSerProg) && baseProjSerProg.contains(".")) { |
|
|
|
baseProjSerProg = baseProjSerProg.substring(0, |
|
|
|
baseProjSerProg.indexOf(".")); |
|
|
|
} |
|
|
@@ -195,10 +198,10 @@ public class DingInfoPullController { |
|
|
|
projectDto.setHigherSuperOrg(String.valueOf(row.getCell(24))); |
|
|
|
projectDto.setHigherSuperOrgCode(String.valueOf(row.getCell(25))); |
|
|
|
|
|
|
|
log.info("projectDto :{}",JSON.toJSONString(projectDto)); |
|
|
|
log.info("projectDto :{}", JSON.toJSONString(projectDto)); |
|
|
|
|
|
|
|
if(StringUtils.isNotBlank(appIrsManage.pushProjectDetail(projectDto))){ |
|
|
|
sucessNum ++; |
|
|
|
if (StringUtils.isNotBlank(appIrsManage.pushProjectDetail(projectDto))) { |
|
|
|
sucessNum++; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@@ -218,15 +221,15 @@ public class DingInfoPullController { |
|
|
|
String baseProjName = "遂昌县-nsl-项目测试004"; |
|
|
|
String baseProjId = "331123230130123412186"; |
|
|
|
String requestSecret = refreshTokenService.refreshToken(appKey, appSecret, govRequestTokenUrl, govRefreshTokenUrl, HttpMethod.POST.name()); |
|
|
|
String capCode = CryptUtils.encryptHMAC(timestamp + areaCode,"bcb4fc0f517fc168ee543fcf4d231f3b"); |
|
|
|
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 + |
|
|
|
"&baseProjSys=" + baseProjSys + "&areaCode=331123&baseProjName=" + baseProjName + "&baseProjId=" + baseProjId + |
|
|
|
"&isEffective=1&baseProjSysCode=" + baseProjSysCode; |
|
|
|
RestTemplate restTemplate = new RestTemplate(); |
|
|
|
log.info("url :{}",url); |
|
|
|
log.info("url :{}", url); |
|
|
|
ResponseEntity<String> forEntity = restTemplate.getForEntity(url, String.class); |
|
|
|
|
|
|
|
log.info(JSON.toJSONString(forEntity)); |
|
|
@@ -263,9 +266,9 @@ public class DingInfoPullController { |
|
|
|
projectDto.setHigherSuperOrg(project.getHigherSuperOrg()); |
|
|
|
projectDto.setHigherSuperOrgCode(project.getHigherSuperOrgCode()); |
|
|
|
|
|
|
|
log.info("projectDto :{}",JSON.toJSONString(projectDto)); |
|
|
|
log.info("projectDto :{}", JSON.toJSONString(projectDto)); |
|
|
|
|
|
|
|
if(StringUtils.isNotBlank(appIrsManage.pushProjectDetail(projectDto))){ |
|
|
|
if (StringUtils.isNotBlank(appIrsManage.pushProjectDetail(projectDto))) { |
|
|
|
return "推送成功"; |
|
|
|
} |
|
|
|
return "推送失败"; |
|
|
@@ -283,16 +286,16 @@ public class DingInfoPullController { |
|
|
|
return irsManage.forward(dto); |
|
|
|
} |
|
|
|
|
|
|
|
public static Workbook readExcel(InputStream is, String extString){ |
|
|
|
public static Workbook readExcel(InputStream is, String extString) { |
|
|
|
Workbook wb = null; |
|
|
|
|
|
|
|
extString = extString.substring(extString.lastIndexOf(".")); |
|
|
|
try { |
|
|
|
if(".xls".equals(extString)){ |
|
|
|
if (".xls".equals(extString)) { |
|
|
|
return wb = new HSSFWorkbook(is); |
|
|
|
}else if(".xlsx".equals(extString)){ |
|
|
|
} else if (".xlsx".equals(extString)) { |
|
|
|
return wb = new XSSFWorkbook(is); |
|
|
|
}else { |
|
|
|
} else { |
|
|
|
return wb = null; |
|
|
|
} |
|
|
|
} catch (IOException e) { |
|
|
|