Browse Source

新增获取盖章后文件接口

tags/24080901
CMM 1 year ago
parent
commit
13fd6bd3ee
3 changed files with 75 additions and 42 deletions
  1. +7
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/todocenter/controller/TodoCenterController.java
  2. +31
    -42
      pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java
  3. +37
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/todocenter/model/dto/SealInfoDTO.java

+ 7
- 0
pmapi/src/main/java/com/ningdatech/pmapi/todocenter/controller/TodoCenterController.java View File

@@ -6,6 +6,7 @@ import javax.validation.Valid;

import com.ningdatech.pmapi.projectdeclared.model.dto.DefaultDeclaredDTO;
import com.ningdatech.pmapi.todocenter.model.dto.AdjustHandleDTO;
import com.ningdatech.pmapi.todocenter.model.dto.SealInfoDTO;
import com.ningdatech.pmapi.todocenter.model.vo.ProcessProgressDetailVo;
import com.ningdatech.pmapi.todocenter.model.req.ProcessDetailReq;
import com.ningdatech.pmapi.todocenter.model.req.ToBeProcessedExportReq;
@@ -175,4 +176,10 @@ public class TodoCenterController {
public Long getNotSealedPdf (@Valid @PathVariable("projectId") Long projectId){
return todoCenterManage.getNotSealedPdf(projectId);
}

@ApiOperation("获取签章后的pdf文件")
@PostMapping("/getSealedPdf")
public Long getSealedPdf(@Valid @RequestBody SealInfoDTO req){
return todoCenterManage.getSealedPdf(req);
}
}

+ 31
- 42
pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java View File

@@ -47,6 +47,7 @@ import com.ningdatech.pmapi.todocenter.bean.entity.WorkNoticeInfo;
import com.ningdatech.pmapi.todocenter.enumeration.IsOrNotEnum;
import com.ningdatech.pmapi.todocenter.model.dto.AdjustHandleDTO;
import com.ningdatech.pmapi.todocenter.model.dto.PdfGenerateDTO;
import com.ningdatech.pmapi.todocenter.model.dto.SealInfoDTO;
import com.ningdatech.pmapi.todocenter.model.dto.SignReqDTO;
import com.ningdatech.pmapi.todocenter.model.vo.ProcessProgressDetailVo;
import com.ningdatech.pmapi.todocenter.enumeration.IsAppendProjectEnum;
@@ -64,7 +65,6 @@ import com.wflow.contants.HisProInsEndActId;
import com.wflow.exception.BusinessException;
import com.wflow.workflow.bean.dto.ProcessInstanceUserDto;
import com.wflow.workflow.bean.dto.ReqProcessHandlerDTO;
import com.wflow.workflow.bean.dto.SealPositionInfoDTO;
import com.wflow.workflow.bean.process.ProgressNode;
import com.wflow.workflow.bean.process.enums.NodeTypeEnum;
import com.wflow.workflow.bean.vo.ProcessInstanceVo;
@@ -268,10 +268,6 @@ public class TodoCenterManage {
case SEAL_PASS:
// 通过该任务,流程到下一审核人处
processTaskService.handleTask(param, userId);
if (ProcessHandlerEnum.SEAL_PASS.name().equals(param.getAction().name())) {
// 调用IRS接口,获取盖章后的pdf文件,并保存到项目库中
getSignPdf(param, declaredProject);
}
// 获取流程通过后的流程实例
HistoricProcessInstance newInstance = historyService.createHistoricProcessInstanceQuery()
.processInstanceId(processInstanceId)
@@ -426,16 +422,16 @@ public class TodoCenterManage {

/**
* 调用IRS接口,获取盖章后的pdf文件,上传到OSS,并保存文件ID到项目库中
* @param param
* @param req
* @param declaredProject
* @return void
* @author CMM
* @since 2023/03/16 21:34
*/
private void getSignPdf(ReqProcessHandlerDTO param, Project declaredProject) {
Long projectId = param.getProjectId();
private Long getSealedPdf(SealInfoDTO req, Project declaredProject) {
Long projectId = req.getProjectId();
// 设置pdf模板参数
JSONObject paramsMap = assemblyPdfParams(projectId);
JSONObject paramsMap = assemblyPdfParams(declaredProject);
// TODO 根据当前盖章单位设置对应的盖章意见与盖章日期
paramsMap.put("superOrgOpinion",null);
paramsMap.put("superOrgAuditDate",null);
@@ -450,26 +446,24 @@ public class TodoCenterManage {
InputStream fileInputStream = fileService.getFileInputStream(pdfFile);
String pdfEncode64 = Base64.encode(fileInputStream);
// 装配盖章接口请求参数信息
SignReqDTO req = new SignReqDTO();
req.setPdfEncode64(pdfEncode64);
SignReqDTO signReq = new SignReqDTO();
signReq.setPdfEncode64(pdfEncode64);
String originalFileName = pdfFile.getOriginalFileName();
req.setFileName(originalFileName);
SealPositionInfoDTO sealPositionInfo = param.getSealInfo();
Float posX = sealPositionInfo.getPosX();
Float posY = sealPositionInfo.getPosY();
req.setPosX(posX);
req.setPosY(posY);
// 获取流程发起人信息
Long projectSponsor = declaredProject.getSponsor();
UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(projectSponsor);
signReq.setFileName(originalFileName);
Float posX = req.getPosX();
Float posY = req.getPosY();
signReq.setPosX(posX);
signReq.setPosY(posY);
// 获取当前登录签章用户信息
Long userId = LoginUserUtil.getUserId();
UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(userId);
// 获取印章编号
CompanySignature companySignature = companySignatureService.getOne(Wrappers.lambdaQuery(CompanySignature.class)
.eq(CompanySignature::getOrganizationCode, userFullInfo.getOrganizationCode()));
String sealSn = companySignature.getSealSn();
req.setSealSn(sealSn);

signReq.setSealSn(sealSn);
// 调用盖章接口,获取盖章后返回的pdf文件字符数组
byte[] signPdf = IRSAPIRequest.createSignPdf(req);
byte[] signPdf = IRSAPIRequest.createSignPdf(signReq);
// 转换成MultipartFile
MultipartFile multipartFile = new MockMultipartFile("file", originalFileName + ".pdf", "application/pdf", signPdf);
// 上传OSS
@@ -479,6 +473,7 @@ public class TodoCenterManage {
declaredProject.setPretrialFileName(resultVo.getOriginalFileName());
declaredProject.setUpdateOn(LocalDateTime.now());
projectService.updateById(declaredProject);
return resultVo.getId();
}


@@ -1023,7 +1018,8 @@ public class TodoCenterManage {
*/
public Long getNotSealedPdf(Long projectId) {
// 设置pdf模板参数
JSONObject paramsMap = assemblyPdfParams(projectId);
Project project = projectService.getById(projectId);
JSONObject paramsMap = assemblyPdfParams(project);
paramsMap.put("superOrgOpinion",null);
paramsMap.put("superOrgAuditDate",null);
paramsMap.put("higherOrgOpinion",null);
@@ -1053,11 +1049,9 @@ public class TodoCenterManage {
project.setPretrialFileName(resultVO.getOriginalFileName());
project.setUpdateOn(LocalDateTime.now());
projectService.updateById(project);


try {
if (null != htmlInputStream) {
htmlInputStream.close();
htmlInputStream.close();
}

// 删除输出文件夹下的临时文件
@@ -1076,34 +1070,23 @@ public class TodoCenterManage {

/**
* 装配pdf模板参数
* @param projectId 申报项目ID
* @param project 申报项目ID
* @return com.alibaba.fastjson.JSONObject
* @author CMM
* @since 2023/03/16 22:28
*/
private JSONObject assemblyPdfParams(Long projectId) {
private JSONObject assemblyPdfParams(Project project) {
// 获取本地目录的pdf模板
String fileName = "预审申请单";
Long projectId = project.getId();
// 获取表单数据
Project project = projectService.getById(projectId);
PdfGenerateDTO pdfGenerateDTO = new PdfGenerateDTO();
BeanUtils.copyProperties(project, pdfGenerateDTO);
JSONObject paramsMap = JSONObject.parseObject(JSONObject.toJSONString(pdfGenerateDTO));
// 设置title
String title = "【" + project.getProjectName() + "】" + fileName;
paramsMap.put("title",title);
// 获取流程发起人信息
Long projectSponsor = project.getSponsor();
UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(projectSponsor);
// 获取印章编号
CompanySignature companySignature = companySignatureService.getOne(Wrappers.lambdaQuery(CompanySignature.class)
.eq(CompanySignature::getOrganizationCode, userFullInfo.getOrganizationCode()));
if (Objects.nonNull(companySignature)){
String sealSn = companySignature.getSealSn();
paramsMap.put("projectNo", sealSn);
}else {
paramsMap.put("projectNo", null);
}
paramsMap.put("projectNo", projectId);
// 获取预审申报的开始时间
ProjectInst projectInst = projectInstService.getOne(Wrappers.lambdaQuery(ProjectInst.class)
.eq(ProjectInst::getProjectId, projectId)
@@ -1151,4 +1134,10 @@ public class TodoCenterManage {
paramsMap.put("bigDataBureauName",null);
return paramsMap;
}

public Long getSealedPdf(SealInfoDTO req) {
Long projectId = req.getProjectId();
Project declaredProject = projectService.getById(projectId);
return getSealedPdf(req, declaredProject);
}
}

+ 37
- 0
pmapi/src/main/java/com/ningdatech/pmapi/todocenter/model/dto/SealInfoDTO.java View File

@@ -0,0 +1,37 @@
package com.ningdatech.pmapi.todocenter.model.dto;

import lombok.Data;

/**
* 调用天印外部接口签章所需信息
*
* @author CMM
* @since 2023/03/16 17:01
*/
@Data
public class SealInfoDTO {

/**
* 项目ID
*/
private Long projectId;
/**
* 印章x坐标
*/
private Float posX;
/**
* 印章y坐标
*/
private Float posY;

/**
* 页码
*/
private String posPage;

/**
* 签署类型
*/
private Integer signType;

}

Loading…
Cancel
Save