|
|
@@ -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; |
|
|
|
} |
|
|
|
} |