Browse Source

Merge branch '20230814_ls2_wps' of http://git.ningdatech.com/liushuai/project-management into dev

tags/24080901
PoffyZhang 1 year ago
parent
commit
a399772bb1
11 changed files with 205 additions and 47 deletions
  1. +2
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/common/constant/BizConst.java
  2. +82
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/irs/manage/ProjectIrsManage.java
  3. +1
    -21
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/controller/DeclaredProjectController.java
  4. +48
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DeclaredProjectManage.java
  5. +42
    -26
      pmapi/src/main/java/com/ningdatech/pmapi/wps/manage/WpsConvertManage.java
  6. +5
    -0
      pmapi/src/main/resources/application-dev.yml
  7. +5
    -0
      pmapi/src/main/resources/application-pre.yml
  8. +5
    -0
      pmapi/src/main/resources/application-prod.yml
  9. +5
    -0
      pmapi/src/test/resources/application-dev.yml
  10. +5
    -0
      pmapi/src/test/resources/application-pre.yml
  11. +5
    -0
      pmapi/src/test/resources/application-prod.yml

+ 2
- 0
pmapi/src/main/java/com/ningdatech/pmapi/common/constant/BizConst.java View File

@@ -90,4 +90,6 @@ public interface BizConst {
String ORG_CODE = "organizationCode";

String DEV = "dev";
String PRE = "pre";
String PROD = "prod";
}

+ 82
- 0
pmapi/src/main/java/com/ningdatech/pmapi/irs/manage/ProjectIrsManage.java View File

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

import com.alibaba.fastjson.JSONObject;
import com.ningdatech.irs.service.IRefreshTokenService;
import com.ningdatech.pmapi.common.util.CryptUtils;
import com.ningdatech.pmapi.common.util.HttpUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource;
import java.security.NoSuchAlgorithmException;
import java.util.Objects;

/**
* @Classname ProjectIrsManage
* @Description
* @Date 2023/8/15 11:43
* @Author PoffyZhang
*/
@Component
@Slf4j
@RequiredArgsConstructor
public class ProjectIrsManage {

@Value("${irs.core-biz.appKey}")
private String appKey;

@Value("${irs.core-biz.appScret}")
private String appSecret;

@Value("${irs.core-biz.url}")
private String coreBizUrl;

@Value("${irs.core-biz.interfaceName}")
private String interfaceName;
@Resource
private IRefreshTokenService refreshTokenService;

@Value("${irs.interface-refresh.request-token-url}")
private String govRequestTokenUrl;
@Value("${irs.interface-refresh.refresh-token-url}")
private String govRefreshTokenUrl;

/**
* 查询核心业务
*
* @param businessName
* @return
* @throws NoSuchAlgorithmException
*/
public JSONObject searchCoreBiz(String businessName,String orgCode) {
long timestamp = System.currentTimeMillis();
String secret = refreshTokenService.refreshToken(appKey, appSecret, govRequestTokenUrl, govRefreshTokenUrl,
interfaceName, HttpMethod.POST.name());
String sign = null;
try{
sign = CryptUtils.MD5Encode(appKey + secret + timestamp);
}catch (Exception e){
log.error(e.getMessage());
}
HttpComponentsClientHttpRequestFactory factory = HttpUtil.generateHttpRequestFactory();
RestTemplate restTemplate;
if(Objects.nonNull(factory)){
restTemplate = new RestTemplate(factory);
}else{
restTemplate = new RestTemplate();
}

String url = coreBizUrl + "?" +
"dingCode=" + orgCode + "&matterName=" + businessName + "&oid=&useState=1&limit=10&page=1" +
"&appKey=" + appKey + "&sign=" + sign + "&requestTime=" + timestamp;

ResponseEntity<JSONObject> forEntity = restTemplate.getForEntity(url, JSONObject.class);
log.info("body :{}",forEntity.getBody());
return forEntity.getBody();
}
}

+ 1
- 21
pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/controller/DeclaredProjectController.java View File

@@ -1,19 +1,13 @@
package com.ningdatech.pmapi.projectdeclared.controller;

import java.util.Iterator;

import javax.servlet.http.HttpServletResponse;

import com.ningdatech.log.annotation.WebLog;
import org.apache.commons.lang3.StringUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ningdatech.basic.model.PageVo;
import com.ningdatech.pmapi.common.util.ExcelDownUtil;
import com.ningdatech.pmapi.projectdeclared.contants.DeclaredProjectContant;
import com.ningdatech.pmapi.projectdeclared.manage.DeclaredProjectManage;
import com.ningdatech.pmapi.projectdeclared.manage.ProjectAdjustmentManage;
import com.ningdatech.pmapi.projectdeclared.model.dto.DeclaredProjectListParamDTO;
@@ -54,21 +48,7 @@ public class DeclaredProjectController {
@ApiOperation(value = "核心业务列表", notes = "核心业务列表")
@GetMapping("/core-biz")
public JSONObject bizList(@RequestParam(required = false) String businessName) {
JSONObject jsonObject = JSONObject.parseObject(DeclaredProjectContant.Biz.CORE_BIZ);
if(StringUtils.isNotBlank(businessName)){
JSONArray dataArray = JSONArray.parseArray(jsonObject.getString("data"));
Iterator iter = dataArray.stream().iterator();
JSONArray dataArrayRes = new JSONArray();
while (iter.hasNext()) {
JSONObject value = (JSONObject) iter.next();
String businessValue = value.getString("matterName");
if(StringUtils.isNotBlank(businessValue) && businessValue.contains(businessName)){
dataArrayRes.add(value);
}
}
jsonObject.put("data",dataArrayRes);
}
return jsonObject;
return declaredProjectManage.bizList(businessName);
}

@ApiOperation(value = "申报项目草稿箱列表", notes = "申报项目草稿箱列表")


+ 48
- 0
pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DeclaredProjectManage.java View File

@@ -3,6 +3,8 @@ package com.ningdatech.pmapi.projectdeclared.manage;
import cn.hutool.core.collection.CollUtil;
import com.alibaba.excel.EasyExcel;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -19,6 +21,8 @@ import com.ningdatech.pmapi.common.helper.RegionCacheHelper;
import com.ningdatech.pmapi.common.helper.UserInfoHelper;
import com.ningdatech.pmapi.common.util.ExcelDownUtil;
import com.ningdatech.pmapi.common.util.ExcelExportStyle;
import com.ningdatech.pmapi.irs.manage.ProjectIrsManage;
import com.ningdatech.pmapi.projectdeclared.contants.DeclaredProjectContant;
import com.ningdatech.pmapi.projectdeclared.model.dto.*;
import com.ningdatech.pmapi.projectdeclared.model.entity.ProjectDraft;
import com.ningdatech.pmapi.projectdeclared.model.vo.ProjectDraftVO;
@@ -37,6 +41,7 @@ import com.ningdatech.pmapi.staging.enums.MsgTypeEnum;
import com.ningdatech.pmapi.sys.manage.NoticeManage;
import com.ningdatech.pmapi.todocenter.constant.WorkNoticeConstant;
import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO;
import com.ningdatech.pmapi.user.security.auth.model.UserInfoDetails;
import com.ningdatech.pmapi.user.util.LoginUserUtil;
import com.wflow.bean.entity.WflowModels;
import com.wflow.exception.BusinessException;
@@ -48,6 +53,7 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

@@ -87,6 +93,11 @@ public class DeclaredProjectManage {

private final RegionCacheHelper regionCacheHelper;

private final ProjectIrsManage projectIrsManage;

@Value("${spring.profiles.active}")
private String active;

/**
* 新项目 启动实例
*
@@ -414,4 +425,41 @@ public class DeclaredProjectManage {
throw new RuntimeException(e);
}
}

/**
* 查询 核心业务
* @param businessName
* @return
*/
public JSONObject bizList(String businessName) {
JSONObject jsonObject = new JSONObject();
UserInfoDetails user = LoginUserUtil.loginUserDetail();
if(BizConst.DEV.equals(active)){
jsonObject = JSONObject.parseObject(DeclaredProjectContant.Biz.CORE_BIZ);
if(StringUtils.isNotBlank(businessName)){
JSONArray dataArray = JSONArray.parseArray(jsonObject.getString("data"));
if(CollUtil.isEmpty(dataArray)){
return new JSONObject();
}
Iterator iter = dataArray.stream().iterator();
JSONArray dataArrayRes = new JSONArray();
while (iter.hasNext()) {
JSONObject value = (JSONObject) iter.next();
String businessValue = value.getString("matterName");
if(StringUtils.isNotBlank(businessValue) && businessValue.contains(businessName)){
dataArrayRes.add(value);
}
}
jsonObject.put("data",dataArrayRes);
}
}else if(BizConst.PRE.equals(active) ||
BizConst.PROD.equals(active)){
jsonObject = projectIrsManage.searchCoreBiz(businessName,user.getEmpPosUnitCode());
}
if(CollUtil.isEmpty(jsonObject)){
return jsonObject;
}

return jsonObject;
}
}

+ 42
- 26
pmapi/src/main/java/com/ningdatech/pmapi/wps/manage/WpsConvertManage.java View File

@@ -7,10 +7,12 @@ import com.aliyun.oss.model.OSSObject;
import com.aliyun.oss.model.ObjectMetadata;
import com.ningdatech.file.properties.FileServerProperties;
import com.ningdatech.file.service.FileService;
import com.ningdatech.pmapi.common.constant.BizConst;
import com.ningdatech.pmapi.wps.contants.WpsContant;
import com.suwell.ofd.custom.agent.AtomAgent;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.stereotype.Component;

@@ -39,6 +41,9 @@ public class WpsConvertManage {

private final FileServerProperties fileServerProperties;

@Value("${spring.profiles.active}")
private String active;

// HTTPAgent ha = new HTTPAgent("http://127.0.0.1:8090");
//2、定义方法实现 多个文件合并转为1个pdf文件
public String offs2Pdf() {
@@ -95,37 +100,48 @@ public class WpsConvertManage {
OSS oss = new OSSClientBuilder().build(fileServerProperties.getAli().getEndpoint(), fileServerProperties.getAli().getAccessKeyId(), fileServerProperties.getAli().getAccessKeySecret());
AtomAgent ha = new AtomAgent(WpsContant.WPS_CONVERT_URL_ONLINE);
try (OSSObject ossObject = oss.getObject(file.getBucket(), file.getPath());
InputStream stream = ossObject.getObjectContent();
InputStream stream = ossObject.getObjectContent();
ServletOutputStream outputStream = response.getOutputStream()) {
String filePath = WpsContant.FIX_FILE_PATH + file.getOriginalFileName();
convert(stream,filePath);
//转换PDF
List<File> fileList =new ArrayList<File>();
//2)、定义转换后的pdf文件输出流
OutputStream out = null;
//3)、添加原文件到集合
fileList.add(new File(filePath));
//4)、赋值转换后的pdf文件输出流
File pdfFile = new File(WpsContant.PDF_PATH);
out = new FileOutputStream(pdfFile);
//5)、调用方法,执行将多个文件转为pdf文件
ha.OFDToPDF(fileList, out);
FileInputStream fileInputStream = new FileInputStream(pdfFile);

ObjectMetadata metadata = ossObject.getObjectMetadata();
response.setContentType(WpsContant.PDF_CONTENT_TYPE);
String fileName = URLEncoder.encode(WpsContant.PDF_NAME, CharsetUtil.UTF_8);
response.setHeader("Content-Disposition", "attachment;filename*=utf-8''" + fileName);
String fileName = null;
byte[] bytes = new byte[4096];
int read;
while ((read = fileInputStream.read(bytes)) != -1) {
outputStream.write(bytes, 0, read);
//测试环境 转不了PDF 请求不了 WPS转换服务器
if(BizConst.DEV.equals(active)){
ObjectMetadata metadata = ossObject.getObjectMetadata();
response.setContentType(metadata.getContentType());
fileName = URLEncoder.encode(file.getOriginalFileName(), CharsetUtil.UTF_8);
response.setHeader("Content-Disposition", "attachment;filename*=utf-8''" + fileName);
while ((read = stream.read(bytes)) != -1) {
outputStream.write(bytes, 0, read);
}
}else if(BizConst.PRE.equals(active) ||
BizConst.PROD.equals(active)){
String filePath = WpsContant.FIX_FILE_PATH + file.getOriginalFileName();
convert(stream,filePath);
//转换PDF
List<File> fileList =new ArrayList<File>();
//2)、定义转换后的pdf文件输出流
OutputStream out = null;
//3)、添加原文件到集合
fileList.add(new File(filePath));
//4)、赋值转换后的pdf文件输出流
File pdfFile = new File(WpsContant.PDF_PATH);
out = new FileOutputStream(pdfFile);
//5)、调用方法,执行将多个文件转为pdf文件
ha.OFDToPDF(fileList, out);
FileInputStream fileInputStream = new FileInputStream(pdfFile);
response.setContentType(WpsContant.PDF_CONTENT_TYPE);
fileName = URLEncoder.encode(WpsContant.PDF_NAME, CharsetUtil.UTF_8);
response.setHeader("Content-Disposition", "attachment;filename*=utf-8''" + fileName);
while ((read = fileInputStream.read(bytes)) != -1) {
outputStream.write(bytes, 0, read);
}
for(File f : fileList){
//用完就删
f.deleteOnExit();
}
}
outputStream.flush();
for(File f : fileList){
//用完就删
f.deleteOnExit();
}
}catch (Exception e){
log.error(e.getMessage());
}finally {


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

@@ -240,6 +240,11 @@ irs:
interfaceName: 3XN9R93Pva6db7sf
appSecret: 496f0f2a19994f76b4fd9dae087366c7
appKey: A331101453557202109017383
core-biz:
url: https://interface.zjzwfw.gov.cn/gateway/api/001008012012001/dataSharing/Fc3re2cq7r64Qfa7.htm
interfaceName: Fc3re2cq7r64Qfa7
appSecret: 496f0f2a19994f76b4fd9dae087366c7
appKey: A331101453557202109017383
interface-refresh:
method: POST
request-token-url: https://interface.zjzwfw.gov.cn/gateway/app/refreshTokenByKey.htm?appKey={appKey}&requestTime={requestTime}&sign={sign}


+ 5
- 0
pmapi/src/main/resources/application-pre.yml View File

@@ -243,6 +243,11 @@ irs:
interfaceName: 3XN9R93Pva6db7sf
appSecret: 496f0f2a19994f76b4fd9dae087366c7
appKey: A331101453557202109017383
core-biz:
url: https://interface.zjzwfw.gov.cn/gateway/api/001008012012001/dataSharing/Fc3re2cq7r64Qfa7.htm
interfaceName: Fc3re2cq7r64Qfa7
appSecret: 496f0f2a19994f76b4fd9dae087366c7
appKey: A331101453557202109017383
interface-refresh:
method: POST
request-token-url: https://interface.zjzwfw.gov.cn/gateway/app/refreshTokenByKey.htm?appKey={appKey}&requestTime={requestTime}&sign={sign}


+ 5
- 0
pmapi/src/main/resources/application-prod.yml View File

@@ -243,6 +243,11 @@ irs:
interfaceName: 3XN9R93Pva6db7sf
appSecret: 496f0f2a19994f76b4fd9dae087366c7
appKey: A331101453557202109017383
core-biz:
url: https://interface.zjzwfw.gov.cn/gateway/api/001008012012001/dataSharing/Fc3re2cq7r64Qfa7.htm
interfaceName: Fc3re2cq7r64Qfa7
appSecret: 496f0f2a19994f76b4fd9dae087366c7
appKey: A331101453557202109017383
interface-refresh:
method: POST
request-token-url: https://interface.zjzwfw.gov.cn/gateway/app/refreshTokenByKey.htm?appKey={appKey}&requestTime={requestTime}&sign={sign}


+ 5
- 0
pmapi/src/test/resources/application-dev.yml View File

@@ -240,6 +240,11 @@ irs:
interfaceName: 3XN9R93Pva6db7sf
appSecret: 496f0f2a19994f76b4fd9dae087366c7
appKey: A331101453557202109017383
core-biz:
url: https://interface.zjzwfw.gov.cn/gateway/api/001008012012001/dataSharing/Fc3re2cq7r64Qfa7.htm
interfaceName: Fc3re2cq7r64Qfa7
appSecret: 496f0f2a19994f76b4fd9dae087366c7
appKey: A331101453557202109017383
interface-refresh:
method: POST
request-token-url: https://interface.zjzwfw.gov.cn/gateway/app/refreshTokenByKey.htm?appKey={appKey}&requestTime={requestTime}&sign={sign}


+ 5
- 0
pmapi/src/test/resources/application-pre.yml View File

@@ -243,6 +243,11 @@ irs:
interfaceName: 3XN9R93Pva6db7sf
appSecret: 496f0f2a19994f76b4fd9dae087366c7
appKey: A331101453557202109017383
core-biz:
url: https://interface.zjzwfw.gov.cn/gateway/api/001008012012001/dataSharing/Fc3re2cq7r64Qfa7.htm
interfaceName: Fc3re2cq7r64Qfa7
appSecret: 496f0f2a19994f76b4fd9dae087366c7
appKey: A331101453557202109017383
interface-refresh:
method: POST
request-token-url: https://interface.zjzwfw.gov.cn/gateway/app/refreshTokenByKey.htm?appKey={appKey}&requestTime={requestTime}&sign={sign}


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

@@ -238,6 +238,11 @@ irs:
interfaceName: 3XN9R93Pva6db7sf
appSecret: 496f0f2a19994f76b4fd9dae087366c7
appKey: A331101453557202109017383
core-biz:
url: https://interface.zjzwfw.gov.cn/gateway/api/001008012012001/dataSharing/Fc3re2cq7r64Qfa7.htm
interfaceName: Fc3re2cq7r64Qfa7
appSecret: 496f0f2a19994f76b4fd9dae087366c7
appKey: A331101453557202109017383
interface-refresh:
method: POST
request-token-url: https://interface.zjzwfw.gov.cn/gateway/app/refreshTokenByKey.htm?appKey={appKey}&requestTime={requestTime}&sign={sign}


Loading…
Cancel
Save