Commit 5ae287fc authored by xuzhang's avatar xuzhang

[fix][DOC]迁移类缺失问题修改

parent 224ed2bb
......@@ -2,6 +2,7 @@
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<profile default="true" name="Default" enabled="true" />
<profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
......
......@@ -26,7 +26,6 @@
<dependency>
<groupId>com.yonde.dcs</groupId>
<artifactId>dcs-doc-core</artifactId>
<version>4.1-RELEASE</version>
</dependency>
<dependency>
<groupId>com.yonde.dcs</groupId>
......
......@@ -24,7 +24,6 @@
<dependency>
<groupId>com.yonde.dcs</groupId>
<artifactId>dcs-doc-core</artifactId>
<version>4.1-RELEASE</version>
<exclusions>
<exclusion>
<groupId>com.yonde.dcs</groupId>
......@@ -163,6 +162,21 @@
<groupId>com.yonde.dex</groupId>
<artifactId>dex-wfc-common</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.yonde.dex</groupId>
<artifactId>dex-wfc-common</artifactId>
</dependency>
<dependency>
<groupId>com.luhuiguo</groupId>
<artifactId>aspose-words</artifactId>
......
......@@ -8,7 +8,6 @@ import com.yonde.dcs.core.constants.Constants;
import com.yonde.dcs.core.service.ExtAutoTaskService;
import com.yonde.dcs.core.service.ExtSendFormLinkService;
import com.yonde.dcs.core.util.ExtDocUtil;
import com.yonde.dcs.core.util.ExtWfcUtil;
import com.yonde.dcs.document.common.entity.vo.DxDocumentVO;
import com.yonde.dcs.esign.plugin.message.WfcSignMessage;
import com.yonde.dcs.plan.common.vo.ExtPlanVO;
......@@ -25,12 +24,12 @@ import com.yonde.dex.wfc.common.vo.DxWfTaskContext;
import com.yonde.dex.wfc.feign.api.WfcProcessFeign;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.SneakyThrows;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
import javax.validation.Valid;
import java.time.LocalDateTime;
import java.util.*;
......@@ -44,8 +43,11 @@ import java.util.*;
@RestController
@RequestMapping("/task")
@Api(tags = "自动任务服务接口")
@Controller(ExtAutoTaskController.BEAN_NAME)
public class ExtAutoTaskController {
public static final String BEAN_NAME = "extAutoTaskController";
@Autowired
WfcProcessFeign wfcProcessFeign;
......
package com.yonde.dcs.core.event;
import cn.hutool.core.io.FileUtil;
import cn.hutool.extra.spring.SpringUtil;
import com.alibaba.fastjson.JSONObject;
import com.yonde.dcs.common.vo.ExtIncomeDetailVO;
import com.yonde.dcs.common.vo.ExtInterfaceInfoLinkVO;
import com.yonde.dcs.core.constants.Constants;
import com.yonde.dcs.core.factory.InternalInterfaceUtils;
import com.yonde.dcs.core.factory.TechnicalFileUtils;
import com.yonde.dcs.core.service.ExtDocService;
import com.yonde.dcs.core.util.ExtDocUtil;
import com.yonde.dcs.core.util.FileUtils;
import com.yonde.dcs.core.util.ProcessDataUtils;
import com.yonde.dcs.core.util.Word2PdfJacobUtil;
import com.yonde.dcs.core.word.ImportWordService;
import com.yonde.dcs.document.common.entity.vo.DxDocumentVO;
import com.yonde.dcs.document.core.service.DocumentService;
import com.yonde.dcs.plan.common.vo.ExtSpendingDetailVO;
import com.yonde.dcs.plan.feign.ExtIncomeContractServiceFeign;
import com.yonde.dcs.plan.feign.ExtSpendingContractServiceFeign;
import com.yonde.dex.basedata.entity.vo.IdVO;
import com.yonde.dex.basedata.exception.DxBusinessException;
import com.yonde.dex.context.feign.ContextServiceFeign;
import com.yonde.dex.context.plugin.common.entity.DxContextVOHolder;
import com.yonde.dex.dao.service.BaseService;
import com.yonde.dex.dfs.vo.ObjFileLinkVO;
import com.yonde.dex.dfs.vo.RepoFileVO;
import com.yonde.dex.dict.feign.DictDataFeignService;
import com.yonde.dex.dict.service.vo.DictDataVO;
import com.yonde.dex.secretcode.plugin.common.entity.DxSecretVOHolder;
import com.yonde.dex.wfc.common.vo.DxWfProcessInfoVO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.event.TransactionPhase;
import org.springframework.transaction.event.TransactionalEventListener;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import static com.yonde.dex.dao.service.BaseService.ChangeType.POST_CREATE;
import static com.yonde.dex.dao.service.BaseService.ChangeType.POST_UPDATE;
/**
* @author wyy
* @date 2024-8-13 10:17
* @describe
*/
@Slf4j
@Component
public class DocumentEvent {
//word模板路径
public static final String PATH = Constants.MTEMPLATE_ABSOLUTE_PATH;
public static final String DOC_END_WITH = ".doc";
public static final String DOCX_END_WITH = ".docx";
@Autowired
private ProcessDataUtils processDataUtils;
@Autowired
private ExtDocUtil extDocUtil;
@Autowired
private ExtDocService extDocService;
@Autowired
private ImportWordService importWordService;
@Autowired
TechnicalFileUtils technicalFileUtils;
@Autowired
DocumentService documentService;
@Autowired
private ExtIncomeContractServiceFeign extIncomeContractService;
@Autowired
private ExtSpendingContractServiceFeign extSpendingContractService;
@Autowired
private DictDataFeignService dictDataService;
@Qualifier("com.yonde.dex.context.feign.ContextProjectServiceFeign")
@Autowired
private ContextServiceFeign contextServiceFeign;
public void createDocListener(DxDocumentVO documentVO) {
String subTypeName = documentVO.getSubTypeName();
//处理过时文件通知单
if (Constants.OUTDATED_NOTIFY.equals(subTypeName)) {
processDataUtils.processOutdatedDocNotify(documentVO);
} else if (ObjectUtils.isEmpty(documentVO.getMasterId())) {
//新建文档,校验编号是否存在
String number = documentVO.getNumber();
DxDocumentVO dxDocumentVO = extDocUtil.searchDocByNumber(number);
if (!ObjectUtils.isEmpty(dxDocumentVO)) {
throw new DxBusinessException("-1", "文档编号已存在");
}
}
}
/**
* 修改文档事件
*
* @param documentVO
*/
public void updateDocListener(DxDocumentVO documentVO) {
DxDocumentVO docObjFileLinks = extDocUtil.findDocObjFileLinks(documentVO.getId());
processUpdateData(docObjFileLinks);
String subTypeName = documentVO.getSubTypeName();
//处理过时文件通知单
if (Constants.OUTDATED_NOTIFY.equals(subTypeName)) {
processDataUtils.processOutdatedDocNotify(docObjFileLinks);
}
BeanUtils.copyProperties(docObjFileLinks, documentVO);
}
/**
* 修改事件更新word
*
* @param documentVo
*/
public void processUpdateData(DxDocumentVO documentVo) {
//根据状态判断是否进行更新word(不等于待审阅)
if (!Constants.PENDING_REVIEW.equals(documentVo.getState())) {
processDataUtils.processData(documentVo);
}
}
/**
* 审阅中编制任务后生成word文档
*
* @param documentVo
*/
public DxDocumentVO processCreateData(DxDocumentVO documentVo) {
//查询展开ObjFileLink
DxDocumentVO documentVO = extDocUtil.findDocObjFileLinks(documentVo.getId());
//根据状态判断是否进行更新word(审阅中)
if (Constants.REVIEWING.equals(documentVO.getState()) || Constants.CAPITAL_RAISING.equals(documentVO.getState())) {
//技术文件(设计图册或者安装图册)
if (Constants.TECHNICAL_FILE.equals(documentVO.getDxDocumentExpand().getOneLevCategory()) || Constants.QAP_DOC.equals(documentVO.getDxDocumentExpand().getOneLevCategory())) {
this.generalTechnicalWord(documentVO);
//删除生成后的临时文件
FileUtils.deleteDirectory(Constants.MERGER_FILE_ABSOLUTE_PATH + documentVO.getSubTypeName() + File.separator + documentVO.getNumber() + File.separator);
} else {
//单据的操作
processDataUtils.processData(documentVO);
}
}
return documentVO;
}
/**
* 自动方法生成内部接口的word
*
* @param documentVo
* @param infoLinkVO 提资人信息
*/
public void generateAutoInterFaceWord(DxDocumentVO documentVo, ExtInterfaceInfoLinkVO infoLinkVO, DxWfProcessInfoVO wfProcessInfoVO) {
try {
String file = documentVo.getSubTypeName();
String outWordFilePath = Constants.MERGER_FILE_ABSOLUTE_PATH + documentVo.getSubTypeName() + "\\" + documentVo.getNumber() + "\\" + Constants.MERGER_SOURCE + "\\";
//生成特定的文档目录,保存生成的word文件
FileUtil.mkdir(outWordFilePath);
Class<?> clazz = Class.forName("com.inet.pdm.factory.InternalInterfaceUtils");
Method settingDataMethod = clazz.getMethod("settingData", DxDocumentVO.class, ExtInterfaceInfoLinkVO.class, DxWfProcessInfoVO.class);
JSONObject jsonObject = (JSONObject) settingDataMethod.invoke(SpringUtil.getBean(InternalInterfaceUtils.class), documentVo, infoLinkVO, wfProcessInfoVO);
String generateWordFilePath = FileUtils.generateWordFile(outWordFilePath);
//生成word文件方法
importWordService.getWordAllTable(jsonObject, PATH + file + ".docx", generateWordFilePath);
log.info("生成word文件内容结束====");
//按照目录获取生成的pdf和word
String outFilePath = Constants.MERGER_FILE_ABSOLUTE_PATH + documentVo.getSubTypeName() + "\\" + documentVo.getNumber() + "\\" + Constants.MERGER_SOURCE + "\\";
//获取文件夹的所有文件--绝对路径
List<String> fileList = new ArrayList<>();
File[] files = FileUtil.ls(outFilePath);
Arrays.stream(files).forEach(item -> {
fileList.add(item.getAbsolutePath());
});
if (CollectionUtils.isEmpty(fileList)) {
log.error("自动方法=====生成的word文件目录内容为空====");
}
log.info("自动方法=====生成word文件完成!");
} catch (Exception e) {
log.error("自动方法=====生成内部接口的word错误:" + e.getMessage());
}
}
/**
* 生成技术文件word
*
* @param documentVo
*/
public void generalTechnicalWord(DxDocumentVO documentVo) {
int i = 1;
String dirPath = Constants.MERGER_FILE_ABSOLUTE_PATH + documentVo.getSubTypeName() + "\\" + documentVo.getNumber() + "\\" + Constants.MERGER_TARGET + "\\";
String outWordFilePath = Constants.MERGER_FILE_ABSOLUTE_PATH + documentVo.getSubTypeName() + "\\" + documentVo.getNumber() + "\\";
FileUtil.mkdir(dirPath);
//生成特定的文档目录,保存生成的word文件
String outPath = FileUtil.mkdir(outWordFilePath).getPath();
if (Constants.TECHNICAL_FILE.equals(documentVo.getDxDocumentExpand().getOneLevCategory())) {
JSONObject secretJson = technicalFileUtils.settingSecretData(documentVo);
//生成密级封皮word文件方法
importWordService.getWordAllTable(secretJson, Constants.TEMPLATE_PATH + "TechnicalFile/" + "TechnicalFileSecret.docx", outPath + "/" + i + "TechnicalFileSecret.docx");
i++;
//秘密,机密生成两张密级页
if ("Secret".equals(documentVo.getSecretCode()) || "Confidential".equals(documentVo.getSecretCode())) {
//生成密级封皮word文件方法
importWordService.getWordAllTable(secretJson, Constants.TEMPLATE_PATH + "TechnicalFile/" + "TechnicalFileSecret.docx", outPath + "/" + i + "TechnicalFileSecret.docx");
i++;
}
JSONObject interfaceHQJson = technicalFileUtils.settingInterfaceHQData(documentVo);
//生成接口会签封皮word文件方法
importWordService.getWordAllTable(interfaceHQJson, Constants.TEMPLATE_PATH + "TechnicalFile/" + "TechnicalFileInterfaceHQ.docx", outPath + "/" + i + "TechnicalFileInterfaceHQ.docx");
i++;
JSONObject auditJson = technicalFileUtils.settingAuditData(documentVo);
//生成专项审查封皮word文件方法
importWordService.getWordAllTable(auditJson, Constants.TEMPLATE_PATH + "TechnicalFile/" + "TechnicalFileAudit.docx", outPath + "/" + i + "TechnicalFileAudit.docx");
i++;
JSONObject historyJson = technicalFileUtils.settingHistoryData(documentVo);
//生成历史版本封皮word文件方法
importWordService.getWordAllTable(historyJson, Constants.TEMPLATE_PATH + "TechnicalFile/" + "TechnicalFileHistory.docx", outPath + "/" + i + "TechnicalFileHistory.docx");
i++;
if (Constants.DESIGN_ATLAS.equals(documentVo.getSubTypeName()) || Constants.INSTALL_ATLAS.equals(documentVo.getSubTypeName())) {
JSONObject drawingsJson = technicalFileUtils.settingAtlasCategoryData(documentVo);
//生成图册图纸封皮word文件方法
importWordService.getWordAllTable(drawingsJson, Constants.TEMPLATE_PATH + "TechnicalFile/" + "TechnicalFileAtlasCategory.docx", outPath + "/" + i + "TechnicalFileAtlasCategory.docx");
i++;
}
} else if (Constants.QAP_DOC.equals(documentVo.getDxDocumentExpand().getOneLevCategory())) {
JSONObject qapJson = technicalFileUtils.settingHistoryData(documentVo);
//生成历史版本封皮word文件方法
importWordService.getWordAllTable(qapJson, Constants.TEMPLATE_PATH + "QAPFile/" + "QAPCover.docx", outPath + "/" + i + "QAPCover.docx");
i++;
}
//(图册除外)合并用户上传的主内容word
if (!(Constants.DESIGN_ATLAS.equals(documentVo.getSubTypeName()) || Constants.INSTALL_ATLAS.equals(documentVo.getSubTypeName()))) {
InputStream inputStream = null;
List<ObjFileLinkVO> objFileLinks = documentVo.getObjFileLinks();
//判断是否为word,不是word不合并
if (!CollectionUtils.isEmpty(objFileLinks)) {
//todo 获取主内容数据流
RepoFileVO fileVO = extDocUtil.obtainPrimaryFile(objFileLinks);
if (!ObjectUtils.isEmpty(fileVO) && (fileVO.getOriginalFileName().endsWith(DOC_END_WITH) || fileVO.getOriginalFileName().endsWith(DOCX_END_WITH))) {
inputStream = extDocUtil.obtainPrimaryFileInputStream(fileVO);
//保存临时文件
String filePath = FileUtils.saveToLocal(inputStream, outWordFilePath + fileVO.getOriginalFileName());
log.info("临时文件目录为:", filePath);
//先将word转为pdf,再合并
Word2PdfJacobUtil.word2PDF(filePath, outPath + "/" + i + "MasterFile.pdf");
}
}
}
//合并生成好的文档
FileUtils.mergePdfFile(outPath, dirPath + Constants.MERGER_PDF_FILE_NAME);
try {
//将pdf上传到附件中
extDocService.extractedAttachFile(documentVo, new FileInputStream(dirPath + Constants.MERGER_PDF_FILE_NAME), "附件一", Constants.ATTACH_FILE);
} catch (IOException e) {
log.error("文件输入错误!");
} catch (Exception e) {
log.error("上传附件错误!");
}
}
public void generalQAPWord(DxDocumentVO documentVo) {
}
@TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT)
public void afterCommit(BaseService.DataChangeEvent event) {
final String eventType = event.getEventType();
final BaseService.ChangeType changeType = BaseService.ChangeType.valueOf(eventType);
if (changeType == POST_CREATE || changeType == POST_UPDATE || changeType == BaseService.ChangeType.POST_DELETE) {
event.getEventTargets().forEach(t -> {
DxDocumentVO doc = new DxDocumentVO();
if (t instanceof ExtIncomeDetailVO) {
//刷新收入合同相关金额
ExtIncomeDetailVO extIncomeDetailVO = (ExtIncomeDetailVO) t;
this.refreshInContractAmount(extIncomeDetailVO.getExtIncomeContractId());
} else if (t instanceof ExtSpendingDetailVO) {
//刷新支出合同相关金额
ExtSpendingDetailVO spendingDetailVO = (ExtSpendingDetailVO) t;
this.refreshSpeContractAmount(spendingDetailVO.getExtSpendingContractId());
}
});
}
}
/**
* 刷新收入合同金额
*
* @param contractId
*/
private void refreshInContractAmount(Long contractId) {
//已到款
//待拨付
extIncomeContractService.calculateIncome(contractId);
//XXX年到款
extIncomeContractService.reCalculIncomeById(contractId);
}
/**
* 刷新支出合同金额
*
* @param contractId
*/
private void refreshSpeContractAmount(Long contractId) {
//已付金额
//未付金额
//付款比例
extSpendingContractService.calculateSpending(contractId);
}
public void onEvent(BaseService.DataChangeEvent event) {
if (event.operationType.equals(POST_CREATE) || event.operationType.equals(POST_UPDATE)) {
extValidateSecret(event.eventTargets);
}
}
@Transactional(rollbackFor = {Exception.class, Error.class})
<P extends DxContextVOHolder & DxSecretVOHolder & IdVO> void extValidateSecret(Iterable<?> objects) {
for (Object data : objects) {
log.info(">>>>>extValidateSecret data:" + data);
log.info(">>>>>extValidateSecret data.getClass:" + data.getClass());
//校验项目中心相关对象密级和计划密级
if (data instanceof DxContextVOHolder && data instanceof DxSecretVOHolder && data instanceof IdVO) {
String checkResultStr = checkDxObjectSecret((P) data);
if (!StringUtils.isEmpty(checkResultStr)) {
throw new DxBusinessException("500", checkResultStr);
}
}
}
}
/**
* 校验计划、收入合同、支出合同密级与项目的关系
*
* @param p
* @return
*/
private <P extends DxContextVOHolder & DxSecretVOHolder & IdVO> String checkDxObjectSecret(P p) {
Boolean checkResult = checkDxObjectVoSecret(p.getSecretCode(), p.getDxContextId());
return checkResult ? "" : p.getSubTypeDisplayName() + "密级不能高于项目密级!";
}
/**
* 校验计划、收入合同、支出合同密级与项目的关系
*
* @return
*/
private Boolean checkDxObjectVoSecret(String secretcode, Long dxcontextid) {
if (StringUtils.isBlank(secretcode)) {
return true;
}
DxSecretVOHolder secretVOHolder = (DxSecretVOHolder) contextServiceFeign.get(dxcontextid);
return checkTargetSecret(secretVOHolder.getSecretCode(), secretcode);
}
/**
* 校验密级信息
*
* @param sourceSecret
* @param targetSecret
* @return
*/
private Boolean checkTargetSecret(String sourceSecret, String targetSecret) {
DictDataVO docSecretCodeDict;
if (StringUtils.isEmpty(sourceSecret)) {
//密级为空则获取默认密级
docSecretCodeDict = dictDataService.getMarkDictData("SecretCode");
} else {
docSecretCodeDict = dictDataService.getDictCode("SecretCode", sourceSecret);
}
List<DictDataVO> secretCodeDictList = dictDataService.getDictDatas("SecretCode");
if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(secretCodeDictList)) {
Set<String> enableSecretCodeSet = secretCodeDictList.stream()
.filter(x -> x.getDictSeq() <= docSecretCodeDict.getDictSeq())
.map(DictDataVO::getDictKey)
.collect(Collectors.toSet());
if (enableSecretCodeSet != null && enableSecretCodeSet.contains(targetSecret)) {
return true;
}
}
return false;
}
}
package com.yonde.dcs.core.events;
import cn.hutool.core.io.FileUtil;
import cn.hutool.extra.spring.SpringUtil;
import com.alibaba.fastjson.JSONObject;
import com.yonde.dcs.common.vo.ExtInterfaceInfoLinkVO;
import com.yonde.dcs.core.constants.Constants;
import com.yonde.dcs.core.factory.InternalInterfaceUtils;
import com.yonde.dcs.core.factory.TechnicalFileUtils;
import com.yonde.dcs.core.service.ExtDocService;
import com.yonde.dcs.core.util.ExtDocUtil;
import com.yonde.dcs.core.util.FileUtils;
import com.yonde.dcs.core.word.ImportWordService;
import com.yonde.dcs.document.common.entity.vo.DxDocumentVO;
import com.yonde.dex.basedata.exception.DxBusinessException;
import com.yonde.dex.dao.events.BusinessEventType;
import com.yonde.dex.dao.events.DxEvent;
import com.yonde.dex.dao.events.DxEventListener;
import com.yonde.dex.dao.events.DxEventWrap;
import com.yonde.dex.dfs.vo.ObjFileLinkVO;
import com.yonde.dex.wfc.common.vo.DxWfProcessInfoVO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* @author xfchai
* @ClassName DocBeforeCreateEvent.java
* @Description 保存文档之前的操作事件
* @createTime 2021/11/15 14:29:00
*/
@Component
@Slf4j
@DxEvent
public class DocBeforeCreateEvent {
//word模板路径
public static final String PATH = Constants.MTEMPLATE_ABSOLUTE_PATH;
public static final String DOC_END_WITH = ".doc";
public static final String DOCX_END_WITH = ".docx";
@Autowired
private ExtDocService extDocService;
@Autowired
private ImportWordService importWordService;
@Autowired
TechnicalFileUtils technicalFileUtils;
@Autowired
private ProcessDataUtils processDataUtils;
@Autowired
private ExtDocUtil extDocUtil;
@DxEventListener(value = DxDocumentVO.class, eventType = BusinessEventType.BEFORE_CREATE, order = 1)
public void createDocListener(List<DxEventWrap<DxDocumentVO>> events) {
events.forEach(e -> {
String subTypeName = e.getTarget().getSubTypeName();
//处理过时文件通知单
if (Constants.OUTDATED_NOTIFY.equals(subTypeName)) {
processDataUtils.processOutdatedDocNotify(e.getTarget());
} else if (ObjectUtils.isEmpty(e.getTarget().getMasterId())) {
//新建文档,校验编号是否存在
String number = e.getTarget().getNumber();
DxDocumentVO dxDocumentVO = extDocUtil.searchDocByNumber(number);
if (!ObjectUtils.isEmpty(dxDocumentVO)) {
throw new DxBusinessException("-1", "文档编号已存在");
}
}
});
}
/**
* 审阅中编制任务后生成word文档
*
* @param documentVo
*/
public DxDocumentVO processCreateData(DxDocumentVO documentVo) {
//查询展开ObjFileLink
DxDocumentVO documentVO = extDocUtil.findDocObjFileLinks(documentVo.getId());
//根据状态判断是否进行更新word(审阅中)
if (Constants.REVIEWING.equals(documentVO.getState()) || Constants.CAPITAL_RAISING.equals(documentVO.getState())) {
//技术文件(设计图册或者安装图册)
if (Constants.TECHNICAL_FILE.equals(documentVO.getDxDocumentExpand().getOneLevCategory()) || Constants.QAP_DOC.equals(documentVO.getDxDocumentExpand().getOneLevCategory())) {
this.generalTechnicalWord(documentVO);
//删除生成后的临时文件
FileUtils.deleteDirectory(Constants.MERGER_FILE_ABSOLUTE_PATH + documentVO.getSubTypeName() + File.separator + documentVO.getNumber() + File.separator);
} else {
//单据的操作
processDataUtils.processData(documentVO);
}
}
return documentVO;
}
/**
* 修改文档事件
*
* @param events
*/
@DxEventListener(value = DxDocumentVO.class, eventType = BusinessEventType.BEFORE_UPDATE, order = 1)
public void updateDocListener(List<DxEventWrap<DxDocumentVO>> events) {
events.forEach(e -> {
// DxDocumentVO target = e.getTarget();
// DxDocumentVO docObjFileLinks = extDocUtil.findDocObjFileLinks(target.getId());
// processUpdateData(docObjFileLinks);
// String subTypeName = e.getTarget().getSubTypeName();
// //处理过时文件通知单
// if (Constants.OUTDATED_NOTIFY.equals(subTypeName)) {
// processDataUtils.processOutdatedDocNotify(docObjFileLinks);
// }
// e.setTarget(docObjFileLinks);
});
}
/**
* 修改事件更新word
*
* @param documentVo
*/
public void processUpdateData(DxDocumentVO documentVo) {
//根据状态判断是否进行更新word(不等于待审阅)
if (!Constants.PENDING_REVIEW.equals(documentVo.getState())) {
processDataUtils.processData(documentVo);
}
}
/**
* 自动方法生成内部接口的word
*
* @param documentVo
* @param infoLinkVO 提资人信息
*/
public void generateAutoInterFaceWord(DxDocumentVO documentVo, ExtInterfaceInfoLinkVO infoLinkVO, DxWfProcessInfoVO wfProcessInfoVO) {
try {
String file = documentVo.getSubTypeName();
String outWordFilePath = Constants.MERGER_FILE_ABSOLUTE_PATH + documentVo.getSubTypeName() + "\\" + documentVo.getNumber() + "\\" + Constants.MERGER_SOURCE + "\\";
//生成特定的文档目录,保存生成的word文件
FileUtil.mkdir(outWordFilePath);
Class<?> clazz = Class.forName("com.inet.pdm.factory.InternalInterfaceUtils");
Method settingDataMethod = clazz.getMethod("settingData", DxDocumentVO.class, ExtInterfaceInfoLinkVO.class, DxWfProcessInfoVO.class);
JSONObject jsonObject = (JSONObject) settingDataMethod.invoke(SpringUtil.getBean(InternalInterfaceUtils.class), documentVo, infoLinkVO, wfProcessInfoVO);
String generateWordFilePath = FileUtils.generateWordFile(outWordFilePath);
//生成word文件方法
importWordService.getWordAllTable(jsonObject, PATH + file + ".docx", generateWordFilePath);
log.info("生成word文件内容结束====");
//按照目录获取生成的pdf和word
String outFilePath = Constants.MERGER_FILE_ABSOLUTE_PATH + documentVo.getSubTypeName() + "\\" + documentVo.getNumber() + "\\" + Constants.MERGER_SOURCE + "\\";
//获取文件夹的所有文件--绝对路径
List<String> fileList = new ArrayList<>();
File[] files = FileUtil.ls(outFilePath);
Arrays.stream(files).forEach(item -> {
fileList.add(item.getAbsolutePath());
});
if (CollectionUtils.isEmpty(fileList)) {
log.error("自动方法=====生成的word文件目录内容为空====");
}
log.info("自动方法=====生成word文件完成!");
} catch (Exception e) {
log.error("自动方法=====生成内部接口的word错误:" + e.getMessage());
}
}
/**
* 生成技术文件word
*
* @param documentVo
*/
public void generalTechnicalWord(DxDocumentVO documentVo) {
int i = 1;
String dirPath = Constants.MERGER_FILE_ABSOLUTE_PATH + documentVo.getSubTypeName() + "\\" + documentVo.getNumber() + "\\" + Constants.MERGER_TARGET + "\\";
String outWordFilePath = Constants.MERGER_FILE_ABSOLUTE_PATH + documentVo.getSubTypeName() + "\\" + documentVo.getNumber() + "\\";
FileUtil.mkdir(dirPath);
//生成特定的文档目录,保存生成的word文件
String outPath = FileUtil.mkdir(outWordFilePath).getPath();
if (Constants.TECHNICAL_FILE.equals(documentVo.getDxDocumentExpand().getOneLevCategory())) {
JSONObject secretJson = technicalFileUtils.settingSecretData(documentVo);
//生成密级封皮word文件方法
importWordService.getWordAllTable(secretJson, Constants.TEMPLATE_PATH + "TechnicalFile/" + "TechnicalFileSecret.docx", outPath + "/" + i + "TechnicalFileSecret.docx");
i++;
//秘密,机密生成两张密级页
if ("Secret".equals(documentVo.getSecretCode()) || "Confidential".equals(documentVo.getSecretCode())) {
//生成密级封皮word文件方法
importWordService.getWordAllTable(secretJson, Constants.TEMPLATE_PATH + "TechnicalFile/" + "TechnicalFileSecret.docx", outPath + "/" + i + "TechnicalFileSecret.docx");
i++;
}
JSONObject interfaceHQJson = technicalFileUtils.settingInterfaceHQData(documentVo);
//生成接口会签封皮word文件方法
importWordService.getWordAllTable(interfaceHQJson, Constants.TEMPLATE_PATH + "TechnicalFile/" + "TechnicalFileInterfaceHQ.docx", outPath + "/" + i + "TechnicalFileInterfaceHQ.docx");
i++;
JSONObject auditJson = technicalFileUtils.settingAuditData(documentVo);
//生成专项审查封皮word文件方法
importWordService.getWordAllTable(auditJson, Constants.TEMPLATE_PATH + "TechnicalFile/" + "TechnicalFileAudit.docx", outPath + "/" + i + "TechnicalFileAudit.docx");
i++;
JSONObject historyJson = technicalFileUtils.settingHistoryData(documentVo);
//生成历史版本封皮word文件方法
importWordService.getWordAllTable(historyJson, Constants.TEMPLATE_PATH + "TechnicalFile/" + "TechnicalFileHistory.docx", outPath + "/" + i + "TechnicalFileHistory.docx");
i++;
if (Constants.DESIGN_ATLAS.equals(documentVo.getSubTypeName()) || Constants.INSTALL_ATLAS.equals(documentVo.getSubTypeName())) {
JSONObject drawingsJson = technicalFileUtils.settingAtlasCategoryData(documentVo);
//生成图册图纸封皮word文件方法
importWordService.getWordAllTable(drawingsJson, Constants.TEMPLATE_PATH + "TechnicalFile/" + "TechnicalFileAtlasCategory.docx", outPath + "/" + i + "TechnicalFileAtlasCategory.docx");
i++;
}
} else if (Constants.QAP_DOC.equals(documentVo.getDxDocumentExpand().getOneLevCategory())) {
JSONObject qapJson = technicalFileUtils.settingHistoryData(documentVo);
//生成历史版本封皮word文件方法
importWordService.getWordAllTable(qapJson, Constants.TEMPLATE_PATH + "QAPFile/" + "QAPCover.docx", outPath + "/" + i + "QAPCover.docx");
i++;
}
//(图册除外)合并用户上传的主内容word
if (!(Constants.DESIGN_ATLAS.equals(documentVo.getSubTypeName()) || Constants.INSTALL_ATLAS.equals(documentVo.getSubTypeName()))) {
InputStream inputStream = null;
List<ObjFileLinkVO> objFileLinks = documentVo.getObjFileLinks();
//判断是否为word,不是word不合并
if (!CollectionUtils.isEmpty(objFileLinks)) {
//todo 获取主内容数据流
// PapersVO fileVO = extDocUtil.obtainPrimaryFile(objFileLinks);
// if (!ObjectUtils.isEmpty(fileVO) && (fileVO.getOriginalFileName().endsWith(DOC_END_WITH) || fileVO.getOriginalFileName().endsWith(DOCX_END_WITH))) {
// inputStream = extDocUtil.obtainPrimaryFileInputStream(fileVO);
// //保存临时文件
// String filePath = FileUtils.saveToLocal(inputStream, outWordFilePath + fileVO.getOriginalFileName());
// log.info("临时文件目录为:", filePath);
// //先将word转为pdf,再合并
// Word2PdfJacobUtil.word2PDF(filePath, outPath + "/" + i + "MasterFile.pdf");
// }
}
}
//合并生成好的文档
FileUtils.mergePdfFile(outPath, dirPath + Constants.MERGER_PDF_FILE_NAME);
try {
//将pdf上传到附件中
extDocService.extractedAttachFile(documentVo, new FileInputStream(dirPath + Constants.MERGER_PDF_FILE_NAME), "附件一", Constants.ATTACH_FILE);
} catch (IOException e) {
log.error("文件输入错误!");
} catch (Exception e) {
log.error("上传附件错误!");
}
}
public void generalQAPWord(DxDocumentVO documentVo) {
}
}
//package com.yonde.dcs.core.events;
//
//
//import cn.hutool.core.io.FileUtil;
//import cn.hutool.extra.spring.SpringUtil;
//import com.alibaba.fastjson.JSONObject;
//import com.yonde.dcs.common.vo.ExtInterfaceInfoLinkVO;
//import com.yonde.dcs.core.constants.Constants;
//import com.yonde.dcs.core.factory.InternalInterfaceUtils;
//import com.yonde.dcs.core.factory.TechnicalFileUtils;
//import com.yonde.dcs.core.service.ExtDocService;
//import com.yonde.dcs.core.util.ExtDocUtil;
//import com.yonde.dcs.core.util.FileUtils;
//import com.yonde.dcs.core.util.ProcessDataUtils;
//import com.yonde.dcs.core.word.ImportWordService;
//import com.yonde.dcs.document.common.entity.vo.DxDocumentVO;
//import com.yonde.dex.basedata.exception.DxBusinessException;
//import com.yonde.dex.dao.events.BusinessEventType;
//import com.yonde.dex.dao.events.DxEvent;
//import com.yonde.dex.dao.events.DxEventListener;
//import com.yonde.dex.dao.events.DxEventWrap;
//import com.yonde.dex.dfs.vo.ObjFileLinkVO;
//import com.yonde.dex.wfc.common.vo.DxWfProcessInfoVO;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.commons.collections.CollectionUtils;
//import org.apache.commons.lang3.ObjectUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//
//import java.io.File;
//import java.io.FileInputStream;
//import java.io.IOException;
//import java.io.InputStream;
//import java.lang.reflect.Method;
//import java.util.ArrayList;
//import java.util.Arrays;
//import java.util.List;
//
///**
// * @author xfchai
// * @ClassName DocBeforeCreateEvent.java
// * @Description 保存文档之前的操作事件
// * @createTime 2021/11/15 14:29:00
// */
//@Component
//@Slf4j
//@DxEvent
//public class DocBeforeCreateEvent {
//
//
//
//
//}
......@@ -27,62 +27,4 @@
//@Slf4j
//public class DocTransactionEvent {
//
// @Autowired
// private ExtDocService extDocService;
//
// @Autowired
// @Qualifier("documentServiceImpl")
// DocumentService documentService;
// @Autowired
// private ExtIncomeContractServiceFeign extIncomeContractService;
// @Autowired
// private ExtSpendingContractServiceFeign extSpendingContractService;
// @Autowired
// private ExtDocUtil extDocUtil;
//
// @TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT)
// public void afterCommit(BaseService.DataChangeEvent event) {
// final String eventType = event.getEventType();
// final BaseService.ChangeType changeType = BaseService.ChangeType.valueOf(eventType);
// if (changeType == BaseService.ChangeType.POST_CREATE || changeType == BaseService.ChangeType.POST_UPDATE || changeType == BaseService.ChangeType.POST_DELETE) {
// event.getEventTargets().forEach(t -> {
// DxDocumentVO doc = new DxDocumentVO();
// if (t instanceof ExtIncomeDetailVO) {
// //刷新收入合同相关金额
// ExtIncomeDetailVO extIncomeDetailVO = (ExtIncomeDetailVO) t;
// this.refreshInContractAmount(extIncomeDetailVO.getExtIncomeContractId());
// } else if (t instanceof ExtSpendingDetailVO) {
// //刷新支出合同相关金额
// ExtSpendingDetailVO spendingDetailVO = (ExtSpendingDetailVO) t;
// this.refreshSpeContractAmount(spendingDetailVO.getExtSpendingContractId());
// }
// });
// }
// }
//
//
// /**
// * 刷新收入合同金额
// *
// * @param contractId
// */
// private void refreshInContractAmount(Long contractId) {
// //已到款
// //待拨付
// extIncomeContractService.calculateIncome(contractId);
// //XXX年到款
// extIncomeContractService.reCalculIncomeById(contractId);
// }
//
// /**
// * 刷新支出合同金额
// *
// * @param contractId
// */
// private void refreshSpeContractAmount(Long contractId) {
// //已付金额
// //未付金额
// //付款比例
// extSpendingContractService.calculateSpending(contractId);
// }
//}
//package com.yonde.dcs.core.events;
//
//
//import com.yonde.dcs.plan.common.vo.ExtPlanVO;
//import com.yonde.dex.basedata.exception.DxBusinessException;
//import com.yonde.dex.context.common.vo.DxContextVO;
//import com.yonde.dex.context.feign.ContextServiceFeign;
......@@ -23,120 +24,8 @@
//@Service
//@Slf4j
//public class ValidateSecretListener extends AbstractEventListener<BaseService.DataChangeEvent> {
// @Autowired
// private DictDataFeignService dictDataService;
// @Qualifier("com.yonde.dex.context.feign.ContextProjectServiceFeign")
// @Autowired
//
// private ContextServiceFeign contextServiceFeign;
//
// @Override
// public void onAsynEvent(BaseService.DataChangeEvent event) {
//
// }
//
// @Override
// public void onEvent(BaseService.DataChangeEvent event) {
// // 页面资源变更的时候
// switch (event.operationType) {
// case POST_CREATE:
// extValidateSecret(event.eventTargets);
// break;
// case POST_UPDATE:
// extValidateSecret(event.eventTargets);
// break;
// case POST_DELETE:
// break;
// default:
// break;
// }
// }
//
// @Transactional(rollbackFor = {Exception.class, Error.class})
// void extValidateSecret(Iterable<?> objects) {
// for (Object data : objects) {
// log.info(">>>>>extValidateSecret data:" + data);
// log.info(">>>>>extValidateSecret data.getClass:" + data.getClass());
// //校验项目中心相关对象密级和计划密级
// if (data instanceof DxContextVO) {
// String checkResultStr = checkDxObjectSecret((DxContextVO) data);
// if (!StringUtils.isEmpty(checkResultStr)) {
// throw new DxBusinessException("500", checkResultStr);
// }
// }
//
//
// }
// }
//
// /**
// * 校验计划、收入合同、支出合同密级与项目的关系
// *
// * @param dxObjectVo
// * @return
// */
// private String checkDxObjectSecret(DxContextVO dxObjectVo) {
// String checkResultStr = "";
// Boolean checkResult = true;
// //todo
//// if (dxObjectVo instanceof ExtPlanVO) {
//// checkResult = checkDxObjectVoSecret(dxObjectVo);
//// checkResultStr = "计划密级不能高于项目密级!";
//// }
//// if (dxObjectVo instanceof ExtIncomeContractVO) {
//// checkResult = checkDxObjectVoSecret(dxObjectVo);
//// checkResultStr = "收入合同密级不能高于项目密级!";
//// }
//// if (dxObjectVo instanceof ExtSpendingContractVO) {
//// checkResult = checkDxObjectVoSecret(dxObjectVo);
//// checkResultStr = "支出合同密级不能高于项目密级!";
//// }
// if (checkResult) {
// checkResultStr = "";
// }
// return checkResultStr;
// }
//
// /**
// * 校验计划、收入合同、支出合同密级与项目的关系
// *
// * @return
// */
// //todo
// private Boolean checkDxObjectVoSecret(DxContextVO dxObjectVo) {
//// if (StringUtils.isBlank(dxObjectVo.getSecretCode())) {
//// return true;
//// }
//// DxContextVO dxContextVO = contextServiceFeign.get(dxObjectVo.getDxContextId());
//// return checkTargetSecret(dxContextVO.getSecretCode(), dxObjectVo.getSecretCode());
// return false;
// }
//
// /**
// * 校验密级信息
// *
// * @param sourceSecret
// * @param targetSecret
// * @return
// */
// private Boolean checkTargetSecret(String sourceSecret, String targetSecret) {
// DictDataVO docSecretCodeDict;
// if (StringUtils.isEmpty(sourceSecret)) {
// //密级为空则获取默认密级
// docSecretCodeDict = dictDataService.getMarkDictData("SecretCode");
// } else {
// docSecretCodeDict = dictDataService.getDictCode("SecretCode", sourceSecret);
// }
// List<DictDataVO> secretCodeDictList = dictDataService.getDictDatas("SecretCode");
// if (CollectionUtils.isNotEmpty(secretCodeDictList)) {
// Set<String> enableSecretCodeSet = secretCodeDictList.stream()
// .filter(x -> x.getDictSeq() <= docSecretCodeDict.getDictSeq())
// .map(DictDataVO::getDictKey)
// .collect(Collectors.toSet());
// if (enableSecretCodeSet != null && enableSecretCodeSet.contains(targetSecret)) {
// return true;
// }
// }
// return false;
// }
//}
package com.yonde.dcs.core.factory;
import com.alibaba.fastjson.JSONObject;
import com.yonde.dcs.common.vo.ExtInformingVO;
import com.yonde.dcs.common.vo.ExtInterfaceInfoLinkVO;
import com.yonde.dcs.core.constants.Constants;
import com.yonde.dcs.core.constants.SignConstants;
import com.yonde.dcs.core.service.ExtDocService;
import com.yonde.dcs.core.util.DateUtils;
import com.yonde.dcs.document.common.entity.vo.DxDocumentVO;
import com.yonde.dex.dfs.vo.ObjFileLinkVO;
import com.yonde.dex.user.common.vo.DxUserInfoVO;
import com.yonde.dex.user.feign.DxUserInfoFeign;
import com.yonde.dex.wfc.common.vo.DxWfActivityVO;
import com.yonde.dex.wfc.common.vo.DxWfProcessInfoVO;
import com.yonde.dex.wfc.common.vo.DxWfProcessTaskVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
/**
......@@ -39,109 +48,108 @@ public class InternalInterfaceUtils {
*/
public JSONObject settingData(DxDocumentVO v, ExtInterfaceInfoLinkVO infoLinkVO, DxWfProcessInfoVO wfProcessInfoVO) {
//获取动态属性
// Map<String, Object> dynamicAttrs = v.getDynamicAttrs();
// String designPhase = Objects.isNull(dynamicAttrs.get("designPhase")) ? "" : (String) dynamicAttrs.get("designPhase");
// String content = Objects.isNull(dynamicAttrs.get("content")) ? "" : (String) dynamicAttrs.get("content");
// String applicant = Objects.isNull(dynamicAttrs.get("applicant")) ? "" : (String) dynamicAttrs.get("applicant");
// String aplicationDate = Objects.isNull(dynamicAttrs.get("aplicationDate")) ? "" : (String) dynamicAttrs.get("aplicationDate");
// String requestDate = Objects.isNull(dynamicAttrs.get("requestDate")) ? "" : (String) dynamicAttrs.get("requestDate");
// String appReviewerDate = Objects.isNull(dynamicAttrs.get("appReviewerDate")) ? "" : (String) dynamicAttrs.get("appReviewerDate");
// String ztsSignDate = Objects.isNull(dynamicAttrs.get("ztsSignDate")) ? "" : (String) dynamicAttrs.get("ztsSignDate");
// JSONObject jsonObject = new JSONObject();
// //项目代号
// String projectCode = ObjectUtils.isEmpty(v.getProjectCode()) ? "" : v.getProjectCode();
// jsonObject.put("apply", "\u0052");
// //密级
// jsonObject.put("SecretCode", extDocService.searchDictDataByDictCode(Constants.SECRET_CODE, v.getSecretCode()));
// jsonObject.put("projectCode", projectCode);
// //设计阶段
// jsonObject.put("designPhase", extDocService.searchDictDataByDictCode(Constants.DESIGN_STAGE, designPhase));
// //接口资料编号
// jsonObject.put("number", ObjectUtils.isEmpty(v.getNumber()) ? "" : v.getNumber());
// //接口名称
// jsonObject.put("name", ObjectUtils.isEmpty(v.getName()) ? "" : v.getName());
// //申请方
// jsonObject.put("applicant", applicant);
// //申请人日期
// jsonObject.put("aplicationDate", DateUtils.conversionDate(aplicationDate));
// String userId = (String) dynamicAttrs.get("applicantorId");
// DxUserInfoVO userVO = (DxUserInfoVO) userService.get(Long.parseLong(userId));
// //申请人签审
// jsonObject.put("sqr_photo", userVO.getUserAccount() + ".png");
// //内容
// jsonObject.put("content", content);
// //要求提交日期
// jsonObject.put("requestDate", DateUtils.conversionDate(requestDate));
// String appReviewer = (String) dynamicAttrs.get("appReviewer");
// if (StringUtils.isEmpty(appReviewer)) {
// log.error("申请审核人为空!");
// }
// if (StringUtils.isEmpty((String) dynamicAttrs.get("ztsSign"))) {
// log.error("总体室签审为空!");
// }
// //申请审核人
// jsonObject.put("sqshr_photo", (String) dynamicAttrs.get("appReviewer") + ".png");
// //总体室签审/日期
// jsonObject.put("ztsSign", (String) dynamicAttrs.get("ztsSign") + ".png");
// //申请审核人日期
// jsonObject.put("appReviewerDate", DateUtils.conversionDate(appReviewerDate));
// jsonObject.put("ztsSignDate", DateUtils.conversionDate(ztsSignDate));
// //页数
// jsonObject.put("pages", v.getAttachPages());
// //判断内部接口基本信息有无附件属性
// checkObjFileLinks(jsonObject, v.getObjFileLinks());
// ExtInformingVO informingVO = infoLinkVO.getTarget();
// if (ObjectUtils.isEmpty(informingVO)) {
// jsonObject.put("infoAttach", "\u00A3");
// jsonObject.put("infoNoAttach", "\u00A3");
// return jsonObject;
// } else {
// jsonObject.put("informativeUnit", Objects.isNull(informingVO.getInformativeUnit()) ? "" : informingVO.getInformativeUnit());
// //提交人日期
// DxUserInfoVO informativeUser = informingVO.getInformativeUser();
// if (!ObjectUtils.isEmpty(informativeUser)) {
// String user = informativeUser.getUserAccount() + ".png";
// //提交人
// jsonObject.put("tjr_photo", user);
// }
// //提交人日期
// jsonObject.put("informativeDate", DateUtils.converLocalDateToString(informingVO.getCreateTime()));
// jsonObject.put("infoContent", Objects.isNull(informingVO.getInfoContent()) ? "" : informingVO.getInfoContent());
// jsonObject.put("remark", Objects.isNull(informingVO.getInfoComment()) ? "" : informingVO.getInfoComment());
// //有无附件属性
// List<ObjFileLinkVO> informingVOObjFileLinks = informingVO.getObjFileLinks();
// this.checkInforObjFileLinks(jsonObject, informingVOObjFileLinks);
// //todo 获取参与者
// List<WfTaskDefinitionVO> activities = wfProcessInfoVO.getActivityInfo();
// if (!CollectionUtils.isEmpty(activities)) {
// for (WfTaskDefinitionVO wf : activities) {
// if (SignConstants.SIGN_KEY_PREPARED.equals(wf.getTaskName())) {
// List<WfProcessTaskVO> taskList = wf.getTaskList();
// for (WfProcessTaskVO wfPro : taskList) {
// //编制且为提交时,把编制人填写备注的属性,写入word文档
// if (SignConstants.WfRoutingList.contains(wfPro.getResult())) {
// jsonObject.put("decription", ObjectUtils.isEmpty(wfPro.getComments()) ? "" : wfPro.getComments().get(0));
// }
// }
// }
// }
// //写入签名数据
// //负责人签字
// jsonObject.put("sqfqr_photo", extDocService.getSignImage(activities, SignConstants.SIGN_KEY_PREPARED));
// jsonObject.put("sqfqr_date", extDocService.getEndDate(activities, SignConstants.SIGN_KEY_PREPARED));
// //总体室签审/日期
// jsonObject.put("zts_photo", extDocService.getSignImage(activities, SignConstants.SIGN_KEY_ZTSQS));
// jsonObject.put("zts_date", extDocService.getEndDate(activities, SignConstants.SIGN_KEY_ZTSQS));
// //提资审核
// jsonObject.put("sh_photo", extDocService.getSignImage(activities, SignConstants.SIGN_KEY_TZSH));
// jsonObject.put("sh_date", extDocService.getEndDate(activities, SignConstants.SIGN_KEY_TZSH));
// //批准
// jsonObject.put("pz_photo", extDocService.getSignImage(activities, SignConstants.SIGN_KEY_APPROVED));
// jsonObject.put("pz_date", extDocService.getEndDate(activities, SignConstants.SIGN_KEY_APPROVED));
// }
// return jsonObject;
// }
return null;
Map<String, Object> dynamicAttrs = v.getDynamicAttrs();
String designPhase = Objects.isNull(dynamicAttrs.get("designPhase")) ? "" : (String) dynamicAttrs.get("designPhase");
String content = Objects.isNull(dynamicAttrs.get("content")) ? "" : (String) dynamicAttrs.get("content");
String applicant = Objects.isNull(dynamicAttrs.get("applicant")) ? "" : (String) dynamicAttrs.get("applicant");
String aplicationDate = Objects.isNull(dynamicAttrs.get("aplicationDate")) ? "" : (String) dynamicAttrs.get("aplicationDate");
String requestDate = Objects.isNull(dynamicAttrs.get("requestDate")) ? "" : (String) dynamicAttrs.get("requestDate");
String appReviewerDate = Objects.isNull(dynamicAttrs.get("appReviewerDate")) ? "" : (String) dynamicAttrs.get("appReviewerDate");
String ztsSignDate = Objects.isNull(dynamicAttrs.get("ztsSignDate")) ? "" : (String) dynamicAttrs.get("ztsSignDate");
JSONObject jsonObject = new JSONObject();
//项目代号
String projectCode = ObjectUtils.isEmpty(v.getDxDocumentExpand().getProjectCode()) ? "" : v.getDxDocumentExpand().getProjectCode();
jsonObject.put("apply", "\u0052");
//密级
jsonObject.put("SecretCode", extDocService.searchDictDataByDictCode(Constants.SECRET_CODE, v.getSecretCode()));
jsonObject.put("projectCode", projectCode);
//设计阶段
jsonObject.put("designPhase", extDocService.searchDictDataByDictCode(Constants.DESIGN_STAGE, designPhase));
//接口资料编号
jsonObject.put("number", ObjectUtils.isEmpty(v.getNumber()) ? "" : v.getNumber());
//接口名称
jsonObject.put("name", ObjectUtils.isEmpty(v.getName()) ? "" : v.getName());
//申请方
jsonObject.put("applicant", applicant);
//申请人日期
jsonObject.put("aplicationDate", DateUtils.conversionDate(aplicationDate));
String userId = (String) dynamicAttrs.get("applicantorId");
DxUserInfoVO userVO = (DxUserInfoVO) userService.get(Long.parseLong(userId));
//申请人签审
jsonObject.put("sqr_photo", userVO.getUserAccount() + ".png");
//内容
jsonObject.put("content", content);
//要求提交日期
jsonObject.put("requestDate", DateUtils.conversionDate(requestDate));
String appReviewer = (String) dynamicAttrs.get("appReviewer");
if (StringUtils.isEmpty(appReviewer)) {
log.error("申请审核人为空!");
}
if (StringUtils.isEmpty((String) dynamicAttrs.get("ztsSign"))) {
log.error("总体室签审为空!");
}
//申请审核人
jsonObject.put("sqshr_photo", (String) dynamicAttrs.get("appReviewer") + ".png");
//总体室签审/日期
jsonObject.put("ztsSign", (String) dynamicAttrs.get("ztsSign") + ".png");
//申请审核人日期
jsonObject.put("appReviewerDate", DateUtils.conversionDate(appReviewerDate));
jsonObject.put("ztsSignDate", DateUtils.conversionDate(ztsSignDate));
//页数
jsonObject.put("pages", v.getDxDocumentExpand().getAttachPages());
//判断内部接口基本信息有无附件属性
checkObjFileLinks(jsonObject, v.getObjFileLinks());
ExtInformingVO informingVO = infoLinkVO.getTarget();
if (ObjectUtils.isEmpty(informingVO)) {
jsonObject.put("infoAttach", "\u00A3");
jsonObject.put("infoNoAttach", "\u00A3");
return jsonObject;
} else {
jsonObject.put("informativeUnit", Objects.isNull(informingVO.getInformativeUnit()) ? "" : informingVO.getInformativeUnit());
//提交人日期
DxUserInfoVO informativeUser = informingVO.getInformativeUser();
if (!ObjectUtils.isEmpty(informativeUser)) {
String user = informativeUser.getUserAccount() + ".png";
//提交人
jsonObject.put("tjr_photo", user);
}
//提交人日期
jsonObject.put("informativeDate", DateUtils.converLocalDateToString(informingVO.getCreateTime()));
jsonObject.put("infoContent", Objects.isNull(informingVO.getInfoContent()) ? "" : informingVO.getInfoContent());
jsonObject.put("remark", Objects.isNull(informingVO.getInfoComment()) ? "" : informingVO.getInfoComment());
//有无附件属性
List<ObjFileLinkVO> informingVOObjFileLinks = informingVO.getObjFileLinks();
this.checkInforObjFileLinks(jsonObject, informingVOObjFileLinks);
//todo 获取参与者
List<DxWfActivityVO> activities = wfProcessInfoVO.getActivityInfo();
if (!CollectionUtils.isEmpty(activities)) {
for (DxWfActivityVO wf : activities) {
if (SignConstants.SIGN_KEY_PREPARED.equals(wf.getTaskName())) {
List<DxWfProcessTaskVO> taskList = wf.getTaskList();
for (DxWfProcessTaskVO wfPro : taskList) {
//编制且为提交时,把编制人填写备注的属性,写入word文档
if (SignConstants.WfRoutingList.contains(wfPro.getResult())) {
jsonObject.put("decription", ObjectUtils.isEmpty(wfPro.getComments()) ? "" : wfPro.getComments().get(0));
}
}
}
}
//写入签名数据
//负责人签字
jsonObject.put("sqfqr_photo", extDocService.getSignImage(activities, SignConstants.SIGN_KEY_PREPARED));
jsonObject.put("sqfqr_date", extDocService.getEndDate(activities, SignConstants.SIGN_KEY_PREPARED));
//总体室签审/日期
jsonObject.put("zts_photo", extDocService.getSignImage(activities, SignConstants.SIGN_KEY_ZTSQS));
jsonObject.put("zts_date", extDocService.getEndDate(activities, SignConstants.SIGN_KEY_ZTSQS));
//提资审核
jsonObject.put("sh_photo", extDocService.getSignImage(activities, SignConstants.SIGN_KEY_TZSH));
jsonObject.put("sh_date", extDocService.getEndDate(activities, SignConstants.SIGN_KEY_TZSH));
//批准
jsonObject.put("pz_photo", extDocService.getSignImage(activities, SignConstants.SIGN_KEY_APPROVED));
jsonObject.put("pz_date", extDocService.getEndDate(activities, SignConstants.SIGN_KEY_APPROVED));
}
return jsonObject;
}
}
/**
......
package com.yonde.dcs.core.factory;
import cn.hutool.core.io.FileUtil;
import com.alibaba.fastjson.JSONObject;
import com.jcraft.jsch.UserInfo;
import com.yonde.dcs.common.vo.ExtAtlasDrawingLinkVO;
import com.yonde.dcs.common.vo.ExtAuditRecordCardLinkVO;
import com.yonde.dcs.common.vo.ExtAuditRecordCardVO;
import com.yonde.dcs.core.constants.Constants;
import com.yonde.dcs.core.constants.DictConstants;
import com.yonde.dcs.core.constants.SignConstants;
import com.yonde.dcs.core.service.ExtAuditRecordCardLinkService;
import com.yonde.dcs.core.service.ExtDocService;
import com.yonde.dcs.core.util.DateUtils;
import com.yonde.dcs.core.util.ExtDocUtil;
import com.yonde.dcs.core.util.WorkFlowUtil;
import com.yonde.dcs.core.signUtils.SignUtil;
import com.yonde.dcs.core.util.*;
import com.yonde.dcs.core.word.ImportWordService;
import com.yonde.dcs.document.common.entity.vo.DxDocumentVO;
import com.yonde.dcs.document.core.service.DocumentService;
import com.yonde.dcs.document.core.service.shadow.DxDocumentServiceShadow;
import com.yonde.dcs.document.expand.entity.DxDocumentVOExpand;
import com.yonde.dcs.entity.excel.AuditPojo;
import com.yonde.dex.basedata.data.search.SearchItem;
import com.yonde.dex.basedata.data.search.SearchItems;
import com.yonde.dex.basedata.data.search.SearchQueryCondition;
import com.yonde.dex.basedata.entity.data.DxPageImpl;
import com.yonde.dex.dfs.vo.ObjFileLinkVO;
import com.yonde.dex.dfs.vo.RepoFileVO;
import com.yonde.dex.dict.feign.DictDataFeignService;
import com.yonde.dex.dict.service.vo.DictDataVO;
import com.yonde.dex.user.common.vo.DxOrganizationVO;
import com.yonde.dex.user.common.vo.DxUserInfoVO;
import com.yonde.dex.user.feign.DxOrganizationFeign;
import com.yonde.dex.user.feign.DxUserInfoFeign;
import com.yonde.dex.wfc.common.vo.DxWfProcessInfoVO;
import com.yonde.dex.wfc.common.vo.DxWfProcessTaskVO;
import com.yonde.dex.wfc.common.vo.DxWfProcessVarVO;
import com.yonde.dex.wfc.common.enums.TaskStateEnum;
import com.yonde.dex.wfc.common.vo.*;
import com.yonde.dex.wfc.feign.api.WfcProcessFeign;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.compress.utils.Lists;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
......@@ -38,10 +42,11 @@ import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.io.FileInputStream;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
/**
* @program: inet-pdm-service
......@@ -59,8 +64,8 @@ public class TechnicalFileUtils {
@Autowired
@Qualifier("documentServiceImpl")
private DocumentService documentService;
// @Autowired
// private IInstanceService instanceService;
@Autowired
private WfcProcessFeign wfcProcessFeign;
@Autowired
private ImportWordService importWordService;
@Autowired
......@@ -143,38 +148,44 @@ public class TechnicalFileUtils {
jsonObject.put("state", extDocService.searchDictDataByDictCode(Constants.OBJ_STATUS, doc.getState()));
//todo
// WfProcessInstVO wfProcessInstVO = workFlowUtil.getWfProcessInst(doc);
// List<DxWfProcessVarVO> wfProcessVarVOList = new ArrayList<>();
DxWfProcessVO wfProcessInstVO = workFlowUtil.getWfProcessInst(doc);
List<DxWfProcessVarVO> wfProcessVarVOList = new ArrayList<>();
// Map<String, Object> wfMap = new HashMap<>();
// if (!ObjectUtils.isEmpty(wfProcessInstVO)) {
// wfMap = this.instanceService.getAllProcessVariables(wfProcessInstVO.getId());
// wfMap = this.wfcProcessFeign.getProcessVariables(wfProcessInstVO.getId());
// }
// List<String> wfProcessVarSInterface = (List<String>) wfMap.get("interfaceReviewUser");
// //取接口会签值
// log.info("获取interfaceReviewUser的值为:{}", wfProcessVarSInterface);
// //定义接口会签信息集合
// List<AuditPojo> auditPojoList = new ArrayList<>();
// List<ExtAuditRecordCardVO> interfaceHQList = this.interAndSpecialData(doc, jsonObject, INTERFACE_SIGN_NAME);
// if (!CollectionUtils.isEmpty(interfaceHQList)) {
// for (int i = 0; i < interfaceHQList.size(); i++) {
// ExtAuditRecordCardVO auditRecordCardVO = interfaceHQList.get(i);
// AuditPojo auditPojo = new AuditPojo();
// //序号
// auditPojo.setSnumber(String.valueOf(i + 1));
// //接口信息描述
// auditPojo.setInfoDescribe(auditRecordCardVO.getIssueDescription());
// DxOrganizationVO userIdAndOrgId = getUserIdAndOrgId(wfProcessVarSInterface);
// //接口设计项(组)
// auditPojo.setInterDesign(userIdAndOrgId.getName());
// DxUserInfoVO userVO = (DxUserInfoVO) userService.get(auditRecordCardVO.getCreatorId());
// //签字
// auditPojo.setSignName(userVO.getUserAccount() + ".png");
// //日期
// auditPojo.setSignDate(DateUtils.converLocalDateToString(auditRecordCardVO.getModifyTime()));
// auditPojoList.add(auditPojo);
// }
// }
// jsonObject.put("interHQList", auditPojoList);
List<DxWfProcessVarVO> processVariables = this.wfcProcessFeign.getProcessVariables(wfProcessInstVO.getId());
List<String> wfProcessVarSInterface = processVariables.stream()
.filter(dxWfProcessVarVO -> "interfaceReviewUser".equals(dxWfProcessVarVO.getKey()))
.map(dxWfProcessVarVO -> dxWfProcessVarVO.getValue().toString())
.collect(Collectors.toList());
//取接口会签值
log.info("获取interfaceReviewUser的值为:{}", wfProcessVarSInterface);
//定义接口会签信息集合
List<AuditPojo> auditPojoList = new ArrayList<>();
List<ExtAuditRecordCardVO> interfaceHQList = this.interAndSpecialData(doc, jsonObject, INTERFACE_SIGN_NAME);
if (!CollectionUtils.isEmpty(interfaceHQList)) {
for (int i = 0; i < interfaceHQList.size(); i++) {
ExtAuditRecordCardVO auditRecordCardVO = interfaceHQList.get(i);
AuditPojo auditPojo = new AuditPojo();
//序号
auditPojo.setSnumber(String.valueOf(i + 1));
//接口信息描述
auditPojo.setInfoDescribe(auditRecordCardVO.getIssueDescription());
DxOrganizationVO organizationVO = getUserIdAndOrgId(wfProcessVarSInterface);
//接口设计项(组)
auditPojo.setInterDesign(organizationVO.getName());
DxUserInfoVO userVO = (DxUserInfoVO) userService.get(auditRecordCardVO.getCreatorId());
//签字
auditPojo.setSignName(userVO.getUserAccount() + ".png");
//日期
auditPojo.setSignDate(DateUtils.converLocalDateToString(auditRecordCardVO.getModifyTime()));
auditPojoList.add(auditPojo);
}
}
jsonObject.put("interHQList", auditPojoList);
return jsonObject;
}
......@@ -202,39 +213,47 @@ public class TechnicalFileUtils {
//阶段状态
jsonObject.put("phaseState", ObjectUtils.isEmpty(doc.getDxDocumentExpand().getPhaseState()) ? "" : doc.getDxDocumentExpand().getPhaseState());
//todo 获取人员
// WfProcessInstVO wfProcessInstVO = workFlowUtil.getWfProcessInst(doc);
// List<WfProcessVarVO> wfProcessVarVOList = new ArrayList<>();
DxWfProcessVO wfProcessInstVO = workFlowUtil.getWfProcessInst(doc);
// List<DxWfProcessVarVO> wfProcessVarVOList = new ArrayList<>();
// Map<String, Object> wfMap = new HashMap<>();
// if (!ObjectUtils.isEmpty(wfProcessInstVO)) {
// wfMap = this.instanceService.getAllProcessVariables(wfProcessInstVO.getId());
// wfMap = this.wfcProcessFeign.getProcessVariables(wfProcessInstVO.getId());
// }
// //取专项审查值
// List<String> wfProcessVarSAudit = (List<String>) wfMap.get("auditUser");
// log.info("获取auditUser的值为:{}", wfProcessVarSAudit);
// //定义专项审查信息集合
// List<AuditPojo> auditPojoList = new ArrayList<>();
// List<AuditRecordCardVO> auditSignList = this.interAndSpecialData(doc, jsonObject, AUDIT_SIGN_NAME);
// if (!CollectionUtils.isEmpty(auditSignList)) {
// for (int i = 0; i < auditSignList.size(); i++) {
// AuditRecordCardVO auditRecordCardVO = auditSignList.get(i);
// AuditPojo auditPojo = new AuditPojo();
// //序号
// auditPojo.setSnumber(String.valueOf(i + 1));
// //接口信息描述
// auditPojo.setInfoDescribe(auditRecordCardVO.getIssueDescription());
// OrganizationVO userIdAndOrgId = getUserIdAndOrgId(wfProcessVarSAudit);
// //接口设计项(组)
// auditPojo.setInterDesign(userIdAndOrgId.getOrgName());
// //签字(图片路径)
// UserVO userVO = userService.get(auditRecordCardVO.getCreatorId());
// //签字
// auditPojo.setSignName(userVO.getUserAccount() + ".png");
// //日期
// auditPojo.setSignDate(DateUtils.converLocalDateToString(auditRecordCardVO.getModifyTime()));
// auditPojoList.add(auditPojo);
// }
// }
// jsonObject.put("auditInfoList", auditPojoList);
List<DxWfProcessVarVO> processVariables = this.wfcProcessFeign.getProcessVariables(wfProcessInstVO.getId());
//取专项审查值
List<String> wfProcessVarSAudit = processVariables.stream()
.filter(dxWfProcessVarVO -> "auditUser".equals(dxWfProcessVarVO.getKey()))
.map(dxWfProcessVarVO -> dxWfProcessVarVO.getValue().toString())
.collect(Collectors.toList());
log.info("获取auditUser的值为:{}", wfProcessVarSAudit);
//定义专项审查信息集合
List<AuditPojo> auditPojoList = new ArrayList<>();
List<ExtAuditRecordCardVO> auditSignList = this.interAndSpecialData(doc, jsonObject, AUDIT_SIGN_NAME);
if (!CollectionUtils.isEmpty(auditSignList)) {
for (int i = 0; i < auditSignList.size(); i++) {
ExtAuditRecordCardVO auditRecordCardVO = auditSignList.get(i);
AuditPojo auditPojo = new AuditPojo();
//序号
auditPojo.setSnumber(String.valueOf(i + 1));
//接口信息描述
auditPojo.setInfoDescribe(auditRecordCardVO.getIssueDescription());
DxOrganizationVO organizationVO = getUserIdAndOrgId(wfProcessVarSAudit);
//接口设计项(组)
auditPojo.setInterDesign(organizationVO.getName());
//签字(图片路径)
DxUserInfoVO userVO = (DxUserInfoVO) userService.get(auditRecordCardVO.getCreatorId());
//签字
auditPojo.setSignName(userVO.getUserAccount() + ".png");
//日期
auditPojo.setSignDate(DateUtils.converLocalDateToString(auditRecordCardVO.getModifyTime()));
auditPojoList.add(auditPojo);
}
}
jsonObject.put("auditInfoList", auditPojoList);
return jsonObject;
}
......@@ -254,7 +273,7 @@ public class TechnicalFileUtils {
JSONObject jsonObject = new JSONObject();
//todo 项目代号
// jsonObject.put("projectCode", (ObjectUtils.isEmpty(doc.getProjectCode()) ? "" : doc.getProjectCode()));
jsonObject.put("projectCode", (ObjectUtils.isEmpty(doc.getDxDocumentExpand().getProjectCode()) ? "" : doc.getDxDocumentExpand().getProjectCode()));
//设计阶段
jsonObject.put("designPhase", extDocService.searchDictDataByDictCode(Constants.DESIGN_STAGE, designPhase));
//专业名称
......@@ -345,66 +364,66 @@ public class TechnicalFileUtils {
//填充校核、审核、审定内容的多选框
this.settingContentData(jsonObject, doc);
//todo 填充设计者名字
// List<WfTaskDefinitionVO> activities = wfProcessInfoVO.getActivityInfo();
// //获取参与者
// if (!CollectionUtils.isEmpty(activities)) {
// //打印总体室备注
// for (WfTaskDefinitionVO wf : activities) {
// if (SignConstants.ZTSSignTaskList.contains(wf.getTaskName())) {
// List<WfProcessTaskVO> taskList = wf.getTaskList();
// for (WfProcessTaskVO wfPro : taskList) {
// //总体室且为通过时,把编制人填写备注的属性,写入word文档
// if (SignConstants.WfRoutingList.contains(wfPro.getResult())) {
// jsonObject.put("decription", ObjectUtils.isEmpty(wfPro.getComments()) ? "" : wfPro.getComments().get(0));
// }
// }
// }
// }
// //设计者
// jsonObject.put("bz_name", extDocService.getSignImage(activities, SignConstants.SIGN_KEY_PREPARED));
// //校核
// jsonObject.put("jh_name", extDocService.getSignImage(activities, SignConstants.SIGN_KEY_CHECKER));
// jsonObject.put("jh_date", extDocService.getEndDate(activities, SignConstants.SIGN_KEY_CHECKER));
// //审核
// jsonObject.put("sh_name", extDocService.getSignImage(activities, SignConstants.SIGN_KEY_SH));
// jsonObject.put("sh_date", extDocService.getEndDate(activities, SignConstants.SIGN_KEY_SH));
// //总体室
// jsonObject.put("zts_name", extDocService.getSignImage(activities, SignConstants.SIGN_KEY_ZTSJKSC));
// jsonObject.put("zts_date", extDocService.getEndDate(activities, SignConstants.SIGN_KEY_ZTSJKSC));
// //审定
// jsonObject.put("sd_name", extDocService.getSignImage(activities, SignConstants.SIGN_SD));
// jsonObject.put("sd_date", extDocService.getEndDate(activities, SignConstants.SIGN_SD));
// }
// List<AuditRecordCardLinkVO> auditRecordRecursionList = this.findAuditRecordRecursion(doc.getVersionId());
// //校核List
// List<AuditRecordCardVO> checkList = new ArrayList();
// List<AuditRecordCardVO> auditList = new ArrayList();
// List<AuditRecordCardVO> approvalList = new ArrayList();
// if (!CollectionUtils.isEmpty(auditRecordRecursionList)) {
// for (AuditRecordCardLinkVO auditRecordCardLinkVO : auditRecordRecursionList) {
// AuditRecordCardVO target = auditRecordCardLinkVO.getTarget();
// if (!ObjectUtils.isEmpty(target)) {
// String taskName = target.getTaskName();
// switch (taskName) {
// case "校核":
// checkList.add(target);
// break;
// case "审核":
// auditList.add(target);
// break;
// case "审定":
// approvalList.add(target);
// break;
// }
// }
// }
// }
// //校核
// jsonObject.put("checkList", checkList);
// //审核
// jsonObject.put("auditList", auditList);
// //审定
// jsonObject.put("approvalList", approvalList);
List<DxWfActivityVO> activities = wfProcessInfoVO.getActivityInfo();
//获取参与者
if (!CollectionUtils.isEmpty(activities)) {
//打印总体室备注
for (DxWfActivityVO wf : activities) {
if (SignConstants.ZTSSignTaskList.contains(wf.getTaskName())) {
List<DxWfProcessTaskVO> taskList = wf.getTaskList();
for (DxWfProcessTaskVO wfPro : taskList) {
//总体室且为通过时,把编制人填写备注的属性,写入word文档
if (SignConstants.WfRoutingList.contains(wfPro.getResult())) {
jsonObject.put("decription", ObjectUtils.isEmpty(wfPro.getComments()) ? "" : wfPro.getComments().get(0));
}
}
}
}
//设计者
jsonObject.put("bz_name", extDocService.getSignImage(activities, SignConstants.SIGN_KEY_PREPARED));
//校核
jsonObject.put("jh_name", extDocService.getSignImage(activities, SignConstants.SIGN_KEY_CHECKER));
jsonObject.put("jh_date", extDocService.getEndDate(activities, SignConstants.SIGN_KEY_CHECKER));
//审核
jsonObject.put("sh_name", extDocService.getSignImage(activities, SignConstants.SIGN_KEY_SH));
jsonObject.put("sh_date", extDocService.getEndDate(activities, SignConstants.SIGN_KEY_SH));
//总体室
jsonObject.put("zts_name", extDocService.getSignImage(activities, SignConstants.SIGN_KEY_ZTSJKSC));
jsonObject.put("zts_date", extDocService.getEndDate(activities, SignConstants.SIGN_KEY_ZTSJKSC));
//审定
jsonObject.put("sd_name", extDocService.getSignImage(activities, SignConstants.SIGN_SD));
jsonObject.put("sd_date", extDocService.getEndDate(activities, SignConstants.SIGN_SD));
}
List<ExtAuditRecordCardLinkVO> auditRecordRecursionList = this.findAuditRecordRecursion(doc.getVersionId());
//校核List
List<ExtAuditRecordCardVO> checkList = new ArrayList();
List<ExtAuditRecordCardVO> auditList = new ArrayList();
List<ExtAuditRecordCardVO> approvalList = new ArrayList();
if (!CollectionUtils.isEmpty(auditRecordRecursionList)) {
for (ExtAuditRecordCardLinkVO auditRecordCardLinkVO : auditRecordRecursionList) {
ExtAuditRecordCardVO target = auditRecordCardLinkVO.getTarget();
if (!ObjectUtils.isEmpty(target)) {
String taskName = target.getTaskName();
switch (taskName) {
case "校核":
checkList.add(target);
break;
case "审核":
auditList.add(target);
break;
case "审定":
approvalList.add(target);
break;
}
}
}
}
//校核
jsonObject.put("checkList", checkList);
//审核
jsonObject.put("auditList", auditList);
//审定
jsonObject.put("approvalList", approvalList);
return jsonObject;
}
......@@ -412,24 +431,25 @@ public class TechnicalFileUtils {
* 填充校核、审核、审定内容的多选框
*
* @param jsonObject
* @param doc
* @param dxDocumentVO
*/
private void settingContentData(JSONObject jsonObject, DxDocumentVO doc) {
private void settingContentData(JSONObject jsonObject, DxDocumentVO dxDocumentVO) {
//todo 校核内容
// String checkContent = doc.getCheckContent();
// this.handleContentData(DictConstants.CheckContent, checkContent, jsonObject);
// //(校核)标准化审查内容
// String checkStandardReview = doc.getCheckStandardReview();
// this.handleContentData(DictConstants.CheckStandardReview, checkStandardReview, jsonObject);
// //审核内容
// String reviewContent = doc.getReviewContent();
// this.handleContentData(DictConstants.ReviewContent, reviewContent, jsonObject);
// //(审核)标准化审查内容
// String reviewContentStandard = doc.getReviewContentStandard();
// this.handleContentData(DictConstants.ReviewContentStandardReview, reviewContentStandard, jsonObject);
// // 审定内容
// String verifyContent = doc.getVerifyContent();
// this.handleContentData(DictConstants.verifierContent, verifyContent, jsonObject);
DxDocumentVOExpand<DxDocumentVO> doc = dxDocumentVO.getDxDocumentExpand();
String checkContent = doc.getCheckContent();
this.handleContentData(DictConstants.CheckContent, checkContent, jsonObject);
//(校核)标准化审查内容
String checkStandardReview = doc.getCheckStandardReview();
this.handleContentData(DictConstants.CheckStandardReview, checkStandardReview, jsonObject);
//审核内容
String reviewContent = doc.getReviewContent();
this.handleContentData(DictConstants.ReviewContent, reviewContent, jsonObject);
//(审核)标准化审查内容
String reviewContentStandard = doc.getReviewContentStandard();
this.handleContentData(DictConstants.ReviewContentStandardReview, reviewContentStandard, jsonObject);
// 审定内容
String verifyContent = doc.getVerifyContent();
this.handleContentData(DictConstants.verifierContent, verifyContent, jsonObject);
}
/**
......@@ -441,24 +461,29 @@ public class TechnicalFileUtils {
*/
private void handleContentData(String dictKey, String difContent, JSONObject jsonObject) {
// todo
// List<DictDataVO> dictDataVOList = dictDataService.getDictDatasByDictCode(dictKey);
// if (!StringUtils.isEmpty(difContent)) {
// String[] checkContentSplit = difContent.split(",");
// List<String> collect = Arrays.stream(checkContentSplit).collect(Collectors.toList());
// dictDataVOList.forEach(item -> {
// if (collect.contains(item.getDictKey())) {
// //对号
// jsonObject.put(item.getDictKey(), "\u0052");
// } else {
// jsonObject.put(item.getDictKey(), "\u00A3");//方框
// }
// });
// } else {
// dictDataVOList.forEach(item -> {
// //方框
// jsonObject.put(item.getDictKey(), "\u00A3");//方框
// });
// }
SearchItems searchItems = new SearchItems();
List<SearchItem> searchItemsList = Lists.newArrayList();
searchItemsList.add(new SearchItem("dictKey", null, dictKey));
searchItems.setItems(searchItemsList);
List<DictDataVO> dictDataVOList = dictDataService.getAllDictDatas(searchItems);
if (!StringUtils.isEmpty(difContent)) {
String[] checkContentSplit = difContent.split(",");
List<String> collect = Arrays.stream(checkContentSplit).collect(Collectors.toList());
dictDataVOList.forEach(item -> {
if (collect.contains(item.getDictKey())) {
//对号
jsonObject.put(item.getDictKey(), "\u0052");
} else {
jsonObject.put(item.getDictKey(), "\u00A3");//方框
}
});
} else {
dictDataVOList.forEach(item -> {
//方框
jsonObject.put(item.getDictKey(), "\u00A3");//方框
});
}
}
/**
......@@ -473,19 +498,19 @@ public class TechnicalFileUtils {
List<ExtAuditRecordCardVO> interfaceHQList = this.interAndSpecialData(documentVO, jsonObject, INTERFACE_SIGN_NAME);
//定义接口会签或者专项审查集合
List<DxWfProcessVarVO> wfProcessVarVOList = new ArrayList<>();
List<DxWfActivityVO> activities = wfProcessInfoVO.getActivityInfo();
if (!CollectionUtils.isEmpty(activities)) {
//写入签名数据
jsonObject.put("sh_photo", extDocService.getSignImage(activities, SignConstants.SIGN_KEY_JKHQ));
jsonObject.put("sh_date", extDocService.getEndDate(activities, SignConstants.SIGN_KEY_JKHQ));
//设计者
jsonObject.put("bz_name", extDocService.getSignImage(activities, SignConstants.SIGN_KEY_PREPARED));
}
//todo 获取人员
// WfProcessInstVO wfProcessInstVO = workFlowUtil.getWfProcessInst(documentVO);
DxWfProcessVO wfProcessInstVO = workFlowUtil.getWfProcessInst(documentVO);
// Map<String, Object> wfMap = new HashMap<>();
// if (!ObjectUtils.isEmpty(wfProcessInstVO)) {
// wfMap = this.instanceService.getAllProcessVariables(wfProcessInstVO.getId());
// }
// List<WfTaskDefinitionVO> activities = wfProcessInfoVO.getActivityInfo();
// if (!CollectionUtils.isEmpty(activities)) {
// //写入签名数据
// jsonObject.put("sh_photo", extDocService.getSignImage(activities, SignConstants.SIGN_KEY_JKHQ));
// jsonObject.put("sh_date", extDocService.getEndDate(activities, SignConstants.SIGN_KEY_JKHQ));
// //设计者
// jsonObject.put("bz_name", extDocService.getSignImage(activities, SignConstants.SIGN_KEY_PREPARED));
// wfMap = this.wfcProcessFeign.getProcessVariables(wfProcessInstVO.getId());
// }
// if (!CollectionUtils.isEmpty(wfMap)) {
// List<String> wfProcessVarsInterface = (List<String>) wfMap.get("interfaceReviewUser");
......@@ -494,21 +519,32 @@ public class TechnicalFileUtils {
// log.info("获取interfaceReviewUser的值为:{}", wfProcessVarsInterface);
// this.getUserIdAndOrgId(wfProcessVarsInterface, jsonObject);
// }
// if (!CollectionUtils.isEmpty(interfaceHQList)) {
// //根据集合数据生成多份文件
// for (int i = 0; i < interfaceHQList.size(); i++) {
// AuditRecordCardVO auditRecordCardVO = interfaceHQList.get(i);
// //接口信息描述
// jsonObject.put("issueDescription", auditRecordCardVO.getIssueDescription());
// jsonObject.put("revisions", auditRecordCardVO.getRevisions());
// jsonObject.put("replyRevision", auditRecordCardVO.getReplyRevision());
// jsonObject.put("issueVerify", auditRecordCardVO.getIssueVerify());
// jsonObject.put("replyRevision", auditRecordCardVO.getReplyRevision());
// importWordService.getWordAllTable(jsonObject, Constants.TEMPLATE_PATH + "TechnicalFile/QHInterfaceTemplate.docx", outWordFilePath + "/" + "QHInterfaceHQ" + i + ".docx");
// }
// } else {
// log.error("接口会签interfaceHQList集合值为空!");
// }
List<DxWfProcessVarVO> processVariables = this.wfcProcessFeign.getProcessVariables(wfProcessInstVO.getId());
if (CollectionUtils.isEmpty(processVariables)) {
List<String> wfProcessVarsInterface = processVariables.stream()
.filter(dxWfProcessVarVO -> "interfaceReviewUser".equals(dxWfProcessVarVO.getKey()))
.map(dxWfProcessVarVO -> dxWfProcessVarVO.getValue().toString())
.collect(Collectors.toList());
//取接口会签值
log.info("获取interfaceReviewUser的值为:{}", wfProcessVarsInterface);
this.getUserIdAndOrgId(wfProcessVarsInterface, jsonObject);
}
if (!CollectionUtils.isEmpty(interfaceHQList)) {
//根据集合数据生成多份文件
for (int i = 0; i < interfaceHQList.size(); i++) {
ExtAuditRecordCardVO auditRecordCardVO = interfaceHQList.get(i);
//接口信息描述
jsonObject.put("issueDescription", auditRecordCardVO.getIssueDescription());
jsonObject.put("revisions", auditRecordCardVO.getRevisions());
jsonObject.put("replyRevision", auditRecordCardVO.getReplyRevision());
jsonObject.put("issueVerify", auditRecordCardVO.getIssueVerify());
jsonObject.put("replyRevision", auditRecordCardVO.getReplyRevision());
importWordService.getWordAllTable(jsonObject, Constants.TEMPLATE_PATH + "TechnicalFile/QHInterfaceTemplate.docx", outWordFilePath + "/" + "QHInterfaceHQ" + i + ".docx");
}
} else {
log.error("接口会签interfaceHQList集合值为空!");
}
return jsonObject;
}
......@@ -523,41 +559,51 @@ public class TechnicalFileUtils {
JSONObject jsonObject = new JSONObject();
List<ExtAuditRecordCardVO> auditRecordRecursionList = this.interAndSpecialData(documentVO, jsonObject, AUDIT_SIGN_NAME);
//定义接口会签或者专项审查集合
List<DxWfActivityVO> activities = wfProcessInfoVO.getActivityInfo();
if (!CollectionUtils.isEmpty(activities)) {
//专项审查签字
jsonObject.put("sc_photo", extDocService.getSignImage(activities, SignConstants.SIGN_KEY_ZXSC));
jsonObject.put("sc_date", extDocService.getEndDate(activities, SignConstants.SIGN_KEY_ZXSC));
//设计者
jsonObject.put("bz_name", extDocService.getSignImage(activities, SignConstants.SIGN_KEY_PREPARED));
jsonObject.put("bz_date", extDocService.getEndDate(activities, SignConstants.SIGN_KEY_PREPARED));
}
//todo 获取人员
// WfProcessInstVO wfProcessInstVO = workFlowUtil.getWfProcessInst(documentVO);
DxWfProcessVO wfProcessInstVO = workFlowUtil.getWfProcessInst(documentVO);
// Map<String, Object> wfMap = new HashMap<>();
// if (!ObjectUtils.isEmpty(wfProcessInstVO)) {
// wfMap = this.instanceService.getAllProcessVariables(wfProcessInstVO.getId());
// }
// List<WfTaskDefinitionVO> activities = wfProcessInfoVO.getActivityInfo();
// if (!CollectionUtils.isEmpty(activities)) {
// //专项审查签字
// jsonObject.put("sc_photo", extDocService.getSignImage(activities, SignConstants.SIGN_KEY_ZXSC));
// jsonObject.put("sc_date", extDocService.getEndDate(activities, SignConstants.SIGN_KEY_ZXSC));
// //设计者
// jsonObject.put("bz_name", extDocService.getSignImage(activities, SignConstants.SIGN_KEY_PREPARED));
// jsonObject.put("bz_date", extDocService.getEndDate(activities, SignConstants.SIGN_KEY_PREPARED));
// wfMap = this.wfcProcessFeign.getProcessVariables(wfProcessInstVO.getId());
// }
// if (!CollectionUtils.isEmpty(wfMap)) {
// List<String> wfProcessVarsAudit = (List<String>) wfMap.get("auditUser");
// log.info("获取auditUser的值为:{}", wfProcessVarsAudit);
// this.getUserIdAndOrgId(wfProcessVarsAudit, jsonObject);
// }
// if (!CollectionUtils.isEmpty(auditRecordRecursionList)) {
// //根据集合数据生成多份文件
// for (int i = 0; i < auditRecordRecursionList.size(); i++) {
// ExtAuditRecordCardVO auditRecordCardVO = auditRecordRecursionList.get(i);
// //接口信息描述
// jsonObject.put("issueDescription", auditRecordCardVO.getIssueDescription());
// jsonObject.put("revisions", auditRecordCardVO.getRevisions());
// jsonObject.put("replyRevision", auditRecordCardVO.getReplyRevision());
// jsonObject.put("issueVerify", auditRecordCardVO.getIssueVerify());
// jsonObject.put("replyRevision", auditRecordCardVO.getReplyRevision());
// importWordService.getWordAllTable(jsonObject, Constants.TEMPLATE_PATH + "TechnicalFile/QHAuditTemplate.docx", outWordFilePath + "/" + "QHAuditHQ" + i + ".docx");
// }
// } else {
// log.error("专项审查auditRecordRecursionList集合值为空!");
// }
List<DxWfProcessVarVO> processVariables = this.wfcProcessFeign.getProcessVariables(wfProcessInstVO.getId());
if (CollectionUtils.isEmpty(processVariables)) {
List<String> wfProcessVarsAudit = processVariables.stream()
.filter(dxWfProcessVarVO -> "auditUser".equals(dxWfProcessVarVO.getKey()))
.map(dxWfProcessVarVO -> dxWfProcessVarVO.getValue().toString())
.collect(Collectors.toList());
log.info("获取auditUser的值为:{}", wfProcessVarsAudit);
this.getUserIdAndOrgId(wfProcessVarsAudit, jsonObject);
}
if (!CollectionUtils.isEmpty(auditRecordRecursionList)) {
//根据集合数据生成多份文件
for (int i = 0; i < auditRecordRecursionList.size(); i++) {
ExtAuditRecordCardVO auditRecordCardVO = auditRecordRecursionList.get(i);
//接口信息描述
jsonObject.put("issueDescription", auditRecordCardVO.getIssueDescription());
jsonObject.put("revisions", auditRecordCardVO.getRevisions());
jsonObject.put("replyRevision", auditRecordCardVO.getReplyRevision());
jsonObject.put("issueVerify", auditRecordCardVO.getIssueVerify());
jsonObject.put("replyRevision", auditRecordCardVO.getReplyRevision());
importWordService.getWordAllTable(jsonObject, Constants.TEMPLATE_PATH + "TechnicalFile/QHAuditTemplate.docx", outWordFilePath + "/" + "QHAuditHQ" + i + ".docx");
}
} else {
log.error("专项审查auditRecordRecursionList集合值为空!");
}
return jsonObject;
}
......@@ -635,8 +681,8 @@ public class TechnicalFileUtils {
DxUserInfoVO userVO = (DxUserInfoVO) userService.get(Long.parseLong(userId));
if (!ObjectUtils.isEmpty(organizationVO)) {
//todo 接口设计项
// jsonObject.put("interSJX", organizationVO.getOrgName());
// jsonObject.put("specialSJX", organizationVO.getOrgName());
jsonObject.put("interSJX", organizationVO.getName());
jsonObject.put("specialSJX", organizationVO.getName());
}
} else {
log.error("获取获取组织名称填充数据方法的错误,值为:{}", value);
......@@ -690,31 +736,31 @@ public class TechnicalFileUtils {
String pictureFrame = (String) dynamicAttrs.get("pictureFrame");
List<ObjFileLinkVO> objFileLinks = target.getObjFileLinks();
//todo 获取主内容数据流
// PapersVO fileVO = extDocUtil.obtainPrimaryFile(objFileLinks);
// InputStream inputStream = extDocUtil.obtainPrimaryFileInputStream(fileVO);
// if (ObjectUtils.isEmpty(inputStream)) {
// //无主内容
// return;
// }
// //获取外部资源配置
// Properties prop = ResourceHelper.getResource();
// //上传文件路径
// String uploadFilePath = prop.getProperty("UploadFilePath");
// //保存临时文件
// String filePath = FileUtils.saveToLocal(inputStream, uploadFilePath + fileVO.getOriginalFileName());
// log.info("结束下载主内容======》" + fileVO.getId());
// //获取接口会签签审节点
// WfProcessInstVO wfProcessInstVO = null;
// if (ObjectUtils.isEmpty(documentVO)) {
// //如果是原理图和布置图,自动任务生成第三个签名pdf
// wfProcessInstVO = workFlowUtil.getWfProcessInst(target);
// } else {
// //跟图册随签
// wfProcessInstVO = workFlowUtil.getWfProcessInst(documentVO);
// }
RepoFileVO fileVO = extDocUtil.obtainPrimaryFile(objFileLinks);
InputStream inputStream = extDocUtil.obtainPrimaryFileInputStream(fileVO);
if (ObjectUtils.isEmpty(inputStream)) {
//无主内容
return;
}
//获取外部资源配置
Properties prop = ResourceHelper.getResource();
//上传文件路径
String uploadFilePath = prop.getProperty("UploadFilePath");
//保存临时文件
String filePath = FileUtils.saveToLocal(inputStream, uploadFilePath + fileVO.getOriginalFileName());
log.info("结束下载主内容======》" + fileVO.getId());
//获取接口会签签审节点
DxWfProcessVO wfProcessInstVO = null;
if (ObjectUtils.isEmpty(documentVO)) {
//如果是原理图和布置图,自动任务生成第三个签名pdf
wfProcessInstVO = workFlowUtil.getWfProcessInst(target);
} else {
//跟图册随签
wfProcessInstVO = workFlowUtil.getWfProcessInst(documentVO);
}
// Map<String, Object> wfMap = new HashMap<>();
// if (!ObjectUtils.isEmpty(wfProcessInstVO)) {
// wfMap = this.instanceService.getAllProcessVariables(wfProcessInstVO.getId());
// wfMap = this.wfcProcessFeign.getProcessVariables(wfProcessInstVO.getId());
// }
// List<String> wfProcessVarsInterface = null;
// if (!CollectionUtils.isEmpty(wfMap)) {
......@@ -722,76 +768,86 @@ public class TechnicalFileUtils {
// wfProcessVarsInterface = (List<String>) wfMap.get("interfaceReviewUser");
// log.info("获取图纸的interfaceReviewUser的值为:{}", wfProcessVarsInterface);
// }
// if (Constants.PRINCIPLE_DRAWINGS.equals(subTypeName) || Constants.LAYOUT_DRAWINGS.equals(subTypeName) || Constants.PART_DRAWINGS.equals(subTypeName)) {
// Map<String, String> map = new HashMap();
// //原理布置图、零件图
// List<WfTaskDefinitionVO> activities = wfProcessInfoVO.getActivityInfo();
// if (!CollectionUtils.isEmpty(activities)) {
// //写入签名数据
// map.put("SJPHOTO", extDocService.getSignImage(activities, SignConstants.SIGN_KEY_PREPARED));
// map.put("SJDATE", extDocService.getEndDate(activities, SignConstants.SIGN_KEY_PREPARED));
// //校核
// map.put("JHPHOTO", extDocService.getSignImage(activities, SignConstants.SIGN_KEY_CHECKER));
// map.put("JHDATE", extDocService.getEndDate(activities, SignConstants.SIGN_KEY_CHECKER));
// //审核
// map.put("SHPHOTO", extDocService.getSignImage(activities, SignConstants.SIGN_KEY_SH));
// map.put("SHDATE", extDocService.getEndDate(activities, SignConstants.SIGN_KEY_SH));
// //审定
// map.put("SDPHOTO", extDocService.getSignImage(activities, SignConstants.SIGN_KEY_SD));
// map.put("SDDATE", extDocService.getEndDate(activities, SignConstants.SIGN_KEY_SD));
// //批准
// map.put("PZPHOTO", extDocService.getSignImage(activities, SignConstants.SIGN_KEY_APPROVED));
// map.put("PZDATE", extDocService.getEndDate(activities, SignConstants.SIGN_KEY_APPROVED));
// //标准化(审核)
// map.put("BZHPHOTO", extDocService.getSignImage(activities, SignConstants.SIGN_KEY_SH));
// map.put("BZHDATE", extDocService.getEndDate(activities, SignConstants.SIGN_KEY_SH));
// //获取接口会签人的信息
// List<AuditPojo> auditPojoList = new ArrayList<>();
// if (!CollectionUtils.isEmpty(wfProcessVarsInterface)) {
// List<String> userAndOrgId = wfProcessVarsInterface;
// //组织id和userId
// for (int i = 0; i < userAndOrgId.size(); i++) {
// String item = userAndOrgId.get(i);
// String[] split = item.split("-");
// String splitOrgId = null;
// String splituserId = null;
// if (split.length == 1) {
// auditPojoList.add(null);
// } else {
// splitOrgId = split[0];
// splituserId = split[1];
// //接口设计项(组)
// OrganizationVO organizationVO = organizationService.get(Long.parseLong(splitOrgId));
// UserVO userVO = userService.get(Long.parseLong(splituserId));
// AuditPojo auditPojo = new AuditPojo();
// String orgName = organizationVO.getOrgName();
// String auditRecordCard = userVO.getUserAccount();
// //签审日期
// String auditDate = this.getMultiEndDate(activities, SignConstants.SIGN_KEY_JKHQ, userVO.getId(), i);
// auditPojo.setInterDesign(orgName);
// auditPojo.setSignDate(auditDate);
// auditPojo.setSignName(auditRecordCard);
// auditPojoList.add(auditPojo);
// }
//
// }
// }
// this.extractedInterHQData(map, auditPojoList);
// }
// String generateFilePath = Constants.MERGER_FILE_ABSOLUTE_PATH + target.getNumber() + "\\";
// try {
// FileUtil.mkdir(generateFilePath);
// //得到主内容
// SignUtil.sign(filePath, generateFilePath + "generateReplace.pdf", map, pictureFrame);
// //挂载到附件上
// extDocService.operateAttachFile(target, new FileInputStream(generateFilePath + "generateReplace.pdf"), "");
// } catch (Exception e) {
// log.error("生成图纸失败!" + e.getMessage());
// } finally {
// //删除生成后的临时文件(删除的是number目录和目录下的文件)
// FileUtils.deleteDirectory(generateFilePath);
// }
// }
List<DxWfProcessVarVO> processVariables = this.wfcProcessFeign.getProcessVariables(wfProcessInstVO.getId());
List<String> wfProcessVarsInterface = null;
if (CollectionUtils.isEmpty(processVariables)) {
//取接口会签值
wfProcessVarsInterface = processVariables.stream()
.filter(dxWfProcessVarVO -> "interfaceReviewUser".equals(dxWfProcessVarVO.getKey()))
.map(dxWfProcessVarVO -> dxWfProcessVarVO.getValue().toString())
.collect(Collectors.toList());
log.info("获取图纸的interfaceReviewUser的值为:{}", wfProcessVarsInterface);
}
if (Constants.PRINCIPLE_DRAWINGS.equals(subTypeName) || Constants.LAYOUT_DRAWINGS.equals(subTypeName) || Constants.PART_DRAWINGS.equals(subTypeName)) {
Map<String, String> map = new HashMap();
//原理布置图、零件图
List<DxWfActivityVO> activities = wfProcessInfoVO.getActivityInfo();
if (!CollectionUtils.isEmpty(activities)) {
//写入签名数据
map.put("SJPHOTO", extDocService.getSignImage(activities, SignConstants.SIGN_KEY_PREPARED));
map.put("SJDATE", extDocService.getEndDate(activities, SignConstants.SIGN_KEY_PREPARED));
//校核
map.put("JHPHOTO", extDocService.getSignImage(activities, SignConstants.SIGN_KEY_CHECKER));
map.put("JHDATE", extDocService.getEndDate(activities, SignConstants.SIGN_KEY_CHECKER));
//审核
map.put("SHPHOTO", extDocService.getSignImage(activities, SignConstants.SIGN_KEY_SH));
map.put("SHDATE", extDocService.getEndDate(activities, SignConstants.SIGN_KEY_SH));
//审定
map.put("SDPHOTO", extDocService.getSignImage(activities, SignConstants.SIGN_KEY_SD));
map.put("SDDATE", extDocService.getEndDate(activities, SignConstants.SIGN_KEY_SD));
//批准
map.put("PZPHOTO", extDocService.getSignImage(activities, SignConstants.SIGN_KEY_APPROVED));
map.put("PZDATE", extDocService.getEndDate(activities, SignConstants.SIGN_KEY_APPROVED));
//标准化(审核)
map.put("BZHPHOTO", extDocService.getSignImage(activities, SignConstants.SIGN_KEY_SH));
map.put("BZHDATE", extDocService.getEndDate(activities, SignConstants.SIGN_KEY_SH));
//获取接口会签人的信息
List<AuditPojo> auditPojoList = new ArrayList<>();
if (!CollectionUtils.isEmpty(wfProcessVarsInterface)) {
List<String> userAndOrgId = wfProcessVarsInterface;
//组织id和userId
for (int i = 0; i < userAndOrgId.size(); i++) {
String item = userAndOrgId.get(i);
String[] split = item.split("-");
String splitOrgId = null;
String splituserId = null;
if (split.length == 1) {
auditPojoList.add(null);
} else {
splitOrgId = split[0];
splituserId = split[1];
//接口设计项(组)
DxOrganizationVO organizationVO = (DxOrganizationVO) organizationService.get(Long.parseLong(splitOrgId));
DxUserInfoVO userVO = (DxUserInfoVO) userService.get(Long.parseLong(splituserId));
AuditPojo auditPojo = new AuditPojo();
String orgName = organizationVO.getName();
String auditRecordCard = userVO.getUserAccount();
//签审日期
String auditDate = this.getMultiEndDate(activities, SignConstants.SIGN_KEY_JKHQ, userVO.getId(), i);
auditPojo.setInterDesign(orgName);
auditPojo.setSignDate(auditDate);
auditPojo.setSignName(auditRecordCard);
auditPojoList.add(auditPojo);
}
}
}
this.extractedInterHQData(map, auditPojoList);
}
String generateFilePath = Constants.MERGER_FILE_ABSOLUTE_PATH + target.getNumber() + "\\";
try {
FileUtil.mkdir(generateFilePath);
//得到主内容
SignUtil.sign(filePath, generateFilePath + "generateReplace.pdf", map, pictureFrame);
//挂载到附件上
extDocService.operateAttachFile(target, new FileInputStream(generateFilePath + "generateReplace.pdf"), "");
} catch (Exception e) {
log.error("生成图纸失败!" + e.getMessage());
} finally {
//删除生成后的临时文件(删除的是number目录和目录下的文件)
FileUtils.deleteDirectory(generateFilePath);
}
}
}
/**
......@@ -847,47 +903,49 @@ public class TechnicalFileUtils {
return new AuditPojo();
}
//todo
// /**
// * 会签多人签名(获取某个环节结束时间)
// *
// * @param activities
// * @param activityName
// * @return
// */
// private String getMultiEndDate(List<WfTaskDefinitionVO> activities, String activityName, Long userId,
// int number) {
// List<String> list = new ArrayList<>();
// for (WfTaskDefinitionVO wf : activities) {
// if (wf.getTaskName().equals(activityName)) {
// list = getMultiActivityEndDate(wf, userId);
// }
// }
// if (!CollectionUtils.isEmpty(list) && list.size() >= number + 1) {
// return list.get(number);
// }
// return " ";
// }
/**
* 会签多人签名(获取某个环节结束时间)
*
* @param activities
* @param activityName
* @return
*/
private String getMultiEndDate(List<DxWfActivityVO> activities, String activityName, Long userId,
int number) {
List<String> list = new ArrayList<>();
for (DxWfActivityVO wf : activities) {
if (wf.getTaskName().equals(activityName)) {
list = getMultiActivityEndDate(wf, userId);
}
}
if (!CollectionUtils.isEmpty(list) && list.size() >= number + 1) {
return list.get(number);
}
return " ";
}
//todo
// /**
// * 获取环节所有执行者,以,隔开
// *
// * @param activity
// * @return
// */
// private List<String> getMultiActivityEndDate(WfTaskDefinitionVO activity, Long userId) {
// List<String> list = new ArrayList<>();
// List<WfProcessTaskVO> taskList = activity.getTaskList();
// SimpleDateFormat dateFm = new SimpleDateFormat("yyyy-MM-dd");
// if (!CollectionUtils.isEmpty(taskList)) {
// for (WfProcessTaskVO wf : taskList) {
// String assignee = wf.getAssignee();
// if (Long.parseLong(assignee) == userId && wf.getState().equals(TaskStateEnum.COMPLETE.name()) && (SignConstants.WfResultList.contains(wf.getResult()))) {
// Date endDate = wf.getEndTime();
// list.add(dateFm.format(endDate).replace("-", "."));
// }
// }
// return list;
// }
// return null;
// }
/**
* 获取环节所有执行者,以,隔开
*
* @param activity
* @return
*/
private List<String> getMultiActivityEndDate(DxWfActivityVO activity, Long userId) {
List<String> list = new ArrayList<>();
List<DxWfProcessTaskVO> taskList = activity.getTaskList();
SimpleDateFormat dateFm = new SimpleDateFormat("yyyy-MM-dd");
if (!CollectionUtils.isEmpty(taskList)) {
for (DxWfProcessTaskVO wf : taskList) {
String assignee = wf.getAssignee();
if (Long.parseLong(assignee) == userId && wf.getState().equals(TaskStateEnum.COMPLETE.name()) && (SignConstants.WfResultList.contains(wf.getResult()))) {
Date endDate = wf.getEndTime();
list.add(dateFm.format(endDate).replace("-", "."));
}
}
return list;
}
return null;
}
}
......@@ -8,11 +8,9 @@ import cn.hutool.extra.spring.SpringUtil;
import cn.hutool.http.ContentType;
import com.alibaba.fastjson.JSONObject;
import com.yonde.dcs.common.vo.*;
import com.yonde.dcs.core.constants.Constants;
import com.yonde.dcs.core.constants.SignConstants;
import com.yonde.dcs.core.events.DocBeforeCreateEvent;
import com.yonde.dcs.core.events.ProcessDataUtils;
import com.yonde.dcs.core.event.DocumentEvent;
import com.yonde.dcs.core.factory.*;
import com.yonde.dcs.core.service.*;
import com.yonde.dcs.core.util.*;
......@@ -81,9 +79,12 @@ import java.util.stream.Collectors;
* @author: dang wei
* @create: 2021-09-27 09:42
*/
@Service
@Service(ExtAutoTaskServiceImpl.BEAN_NAME)
@Slf4j
public class ExtAutoTaskServiceImpl implements ExtAutoTaskService {
public static final String BEAN_NAME = "extAutoTaskServiceImpl";
@Qualifier("documentServiceImpl")
@Autowired
private DocumentService documentService;
......@@ -113,6 +114,7 @@ public class ExtAutoTaskServiceImpl implements ExtAutoTaskService {
private DxPostMemberLinkFeign<DxPostMemberLinkVO> dxPostMemberLinkFeign;
@Resource
private ExtPlanDocLinkServiceFeign planDocLinkService;
@Autowired
private ExtPlanServiceFeign extPlanService;
@Autowired
......@@ -122,7 +124,7 @@ public class ExtAutoTaskServiceImpl implements ExtAutoTaskService {
@Autowired
private ExtInterfaceInfoLinkService interfaceInfoLinkService;
@Autowired
private DocBeforeCreateEvent docBeforeCreateEvent;
private DocumentEvent documentEvent;
@Autowired
private FileManagerFeignService fileManagerFeignService;
@Autowired
......@@ -643,7 +645,7 @@ public class ExtAutoTaskServiceImpl implements ExtAutoTaskService {
if (!CollectionUtils.isEmpty(interfaceInfoLinkVOS)) {
//1、先根据提资记录生成多个文档
interfaceInfoLinkVOS.stream().forEach(item -> {
docBeforeCreateEvent.generateAutoInterFaceWord(docObjFile, item, wfProcessInfoVO);
documentEvent.generateAutoInterFaceWord(docObjFile, item, wfProcessInfoVO);
});
try {
//2、合并生成好的文档
......@@ -968,7 +970,7 @@ public class ExtAutoTaskServiceImpl implements ExtAutoTaskService {
if (!CollectionUtils.isEmpty(interfaceInfoLinkVOS)) {
//1、先根据提资记录生成多个文档(不需要上传到附件和主内容中)
interfaceInfoLinkVOS.stream().forEach(item -> {
docBeforeCreateEvent.generateAutoInterFaceWord(documentVO, item, wfProcessInfoVO);
documentEvent.generateAutoInterFaceWord(documentVO, item, wfProcessInfoVO);
});
try {
//2、合并生成好的文档
......@@ -1000,8 +1002,8 @@ public class ExtAutoTaskServiceImpl implements ExtAutoTaskService {
*/
@Override
public void generateWordByAutoMethod(DxDocumentVO documentVo) {
// DxDocumentVO dxDocumentVO = docBeforeCreateEvent.processCreateData(documentVo);
// documentService.saveRecursion(dxDocumentVO);
DxDocumentVO dxDocumentVO = documentEvent.processCreateData(documentVo);
documentService.saveRecursion(dxDocumentVO);
}
/**
......@@ -1087,7 +1089,7 @@ public class ExtAutoTaskServiceImpl implements ExtAutoTaskService {
FileUtil.mkdir(outWordFilePath);
try {
//先生成封皮数据
docBeforeCreateEvent.generalTechnicalWord(documentVO);
documentEvent.generalTechnicalWord(documentVO);
JSONObject jsonObject = technicalFileUtils.settingData(documentVO, wfProcessInfoVO);
//生成校核、审核、审定的记录卡
importWordService.getWordAllTable(jsonObject, Constants.TEMPLATE_PATH + "TechnicalFile/QHTemplate.docx", outWordFilePath + "/QHAuditDoc.docx");
......
package com.yonde.dcs.core.service.impl.expand;
import com.yonde.dcs.core.constants.Constants;
import com.yonde.dcs.core.event.DocumentEvent;
import com.yonde.dcs.core.util.ProcessDataUtils;
import com.yonde.dcs.core.util.ExtDocUtil;
import com.yonde.dex.basedata.exception.DxBusinessException;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.logging.log4j.spi.CopyOnWrite;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import java.util.Collection;
import io.swagger.annotations.ApiOperation;
import java.util.Collection;
import java.util.List;
import com.yonde.dcs.document.common.entity.vo.DxDocumentVO;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Autowired;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import com.yonde.dcs.core.service.expand.ExtDxDocumentService;
import com.yonde.dcs.document.core.repository.DocumentRepository;
import com.yonde.dcs.document.entity.po.DxDocument;
import javax.annotation.Resource;
import com.yonde.dcs.document.core.service.impl.DocumentServiceImpl;
/**
......@@ -31,16 +39,22 @@ public class ExtDxDocumentServiceImpl<V extends DxDocumentVO> extends DocumentSe
@Autowired
DocumentRepository<DxDocument> documentRepository;
@Autowired
private DocumentEvent documentEvent;
@Override
public void beforeSave(Collection<V> target) {
//循环处理每一个文档
for (V v : target) {
documentEvent.createDocListener(v);
}
super.beforeSave(target);
}
@Override
public void beforeUpdate(Collection<V> target, Collection<V> origin) {
for (V v : target) {
documentEvent.updateDocListener(v);
}
super.beforeUpdate(target,origin);
}
}
......
package com.yonde.dcs.core.signUtils;
import com.itextpdf.io.font.PdfEncodings;
import com.itextpdf.io.image.ImageData;
import com.itextpdf.io.image.ImageDataFactory;
import com.itextpdf.kernel.colors.ColorConstants;
import com.itextpdf.kernel.font.PdfFont;
import com.itextpdf.kernel.font.PdfFontFactory;
import com.itextpdf.kernel.geom.AffineTransform;
import com.itextpdf.kernel.geom.PageSize;
import com.itextpdf.kernel.geom.Rectangle;
import com.itextpdf.kernel.pdf.PdfDocument;
import com.itextpdf.kernel.pdf.PdfPage;
import com.itextpdf.kernel.pdf.PdfReader;
import com.itextpdf.kernel.pdf.PdfWriter;
import com.itextpdf.kernel.pdf.canvas.PdfCanvas;
import com.itextpdf.kernel.pdf.canvas.parser.PdfCanvasProcessor;
import com.itextpdf.kernel.pdf.canvas.parser.listener.IPdfTextLocation;
import com.itextpdf.kernel.pdf.canvas.parser.listener.RegexBasedLocationExtractionStrategy;
import com.itextpdf.kernel.pdf.xobject.PdfImageXObject;
import com.itextpdf.layout.Document;
import com.itextpdf.layout.element.Image;
import com.yonde.dcs.core.util.ResourceHelper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.CollectionUtils;
import javax.imageio.ImageIO;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.*;
import java.util.regex.Pattern;
@Slf4j
public class SignHelper {
/**
* 找出关键字坐标
*
* @param keyWord 占位符
* @param page 页
* @return 指定关键字再当前页的坐标集合
*/
public static List<Rectangle> getWordRectangle(String keyWord, PdfPage page) {
List<Rectangle> rectangleList = new ArrayList<>();
//找出关键字坐标
RegexBasedLocationExtractionStrategy strategy = new RegexBasedLocationExtractionStrategy(keyWord);
PdfCanvasProcessor canvasProcessor = new PdfCanvasProcessor(strategy);
canvasProcessor.processPageContent(page);
Collection<IPdfTextLocation> resultantLocations = strategy.getResultantLocations();
for (IPdfTextLocation location : resultantLocations) {
System.out.println("关键字的x:" + location.getRectangle().getX() + "y:" + location.getRectangle().getY() + "宽:" + location.getRectangle().getWidth() + "高:" + location.getRectangle().getHeight());
rectangleList.add(location.getRectangle());
}
return rectangleList;
}
/**
* 写文本
*
* @param canvas 画布
* @param rectangle 占位符坐标信息
* @param text 要替换的文本
* @param fontSize 字体大小 传null默认占位符大小
* @param fontStyle 字体样式 传null默认pdf自带字体
*/
public static void canvasFont(PdfCanvas canvas, Rectangle rectangle, String text, Float fontSize, PdfFont fontStyle, String pictureFrame) throws IOException {
//改变背景色
canvas.saveState();
canvas.setFillColor(ColorConstants.WHITE);
canvas.rectangle(rectangle);
canvas.fill();
canvas.restoreState();
//新文本
canvas.beginText();
if (Objects.isNull(fontStyle)) {
//TODO 解决中文字体显示问题 默认系统宋体常规字体
String path = "C:\\Windows\\Fonts\\simsun.ttc";
fontStyle = PdfFontFactory.createFont(path + ",0", PdfEncodings.IDENTITY_H, true);
}
//设置字体和大小
if (fontSize == null) {
fontSize = getFontSize(fontStyle, text, rectangle.getWidth());
}
canvas.setFontAndSize(fontStyle, fontSize);
if (!"A4".equals(pictureFrame)) {
AffineTransform affineTransform = new AffineTransform();
affineTransform.setToTranslation(rectangle.getX(), rectangle.getY() + rectangle.getHeight() + 4);
affineTransform.rotate(-Math.PI / 2);
canvas.setTextMatrix(affineTransform);
} else {
canvas.setTextMatrix(rectangle.getX(), rectangle.getY());
}
//设置字体的输出位置
// ColumnText.showTextAligned(canvas,
// Element.ALIGN_LEFT, new Phrase("Text"), xPosition, yPosition, 0);
//要输出的text
canvas.showText(text);
canvas.endText();
}
/**
* 得到字体大小
*
* @param font 字体类型
* @param text 所写文本
* @param width 框宽度
* @return 字体的大小
*/
public static float getFontSize(PdfFont font, String text, Float width) {
float fontSize = 10;
while (font.getWidth(text, fontSize) <= width) {
fontSize = fontSize + 1;
}
return fontSize - 1;
}
/**
* 签文字
*
* @param sourcePath 源文件
* @param targetPath 目标文件
* @param flagMap 占位符
* @param fontSize 字体大小
* @param fontStyle 字体样式
*/
public static void signWord(String sourcePath, String targetPath,
Map<String, String> flagMap,
Float fontSize, PdfFont fontStyle, String pictureFrame) throws Exception {
PdfDocument pdfDocument = null;
PdfCanvas canvas = null;
PdfPage page = null;
try {
pdfDocument = new PdfDocument(new PdfReader(sourcePath), new PdfWriter(targetPath));
PageSize defaultPageSize = pdfDocument.getDefaultPageSize();
} catch (IOException e) {
log.error("[PDF 签文字] pdf路径错误,原路径:" + sourcePath + ",目标路径:" + targetPath);
}
//对pdf的每一页都进行签字
for (int i = 0; i < pdfDocument.getNumberOfPages(); i++) {
Map<String, List<Rectangle>> rectangleMap = new HashMap<>();
page = pdfDocument.getPage(i + 1);
//记录坐标信息, key为占位符
for (Map.Entry<String, String> entry : flagMap.entrySet()) {
rectangleMap.put(entry.getKey(), getWordRectangle(entry.getKey(), page));
}
canvas = new PdfCanvas(page);
//写文本
for (Map.Entry<String, List<Rectangle>> entry : rectangleMap.entrySet()) {
String key = entry.getKey();
if (!CollectionUtils.isEmpty(entry.getValue())) {
for (Rectangle rect : entry.getValue()) {
if (key.contains("HQ")) {
//会签节点,以A4的格式
canvasFont(canvas, rect, flagMap.get(entry.getKey()), fontSize, fontStyle, "A4");
} else {
canvasFont(canvas, rect, flagMap.get(entry.getKey()), fontSize, fontStyle, pictureFrame);
}
}
}
}
}
pdfDocument.close();
}
/**
* 签图片
*
* @param sourcePath 原pdf路径
* @param targetPath 签后pdf路径
* @param flagMap key:关键字(占位符) value:图片路径
* @param xOffSet x轴偏移量 (正数:图片向右移动, 负数:图片向左移动)
* @param yOffset y轴偏移量 (正数:图片向右移动, 负数:图片向左移动)
*/
public static void signImage(String sourcePath, String targetPath,
Map<String, String> flagMap,
Float xOffSet, Float yOffset, String pictureFrame) throws Exception {
PdfDocument pdfDocument = null;
Rectangle rectangle = null;
ImageData imageData = null;
PdfImageXObject imageXObject = null;
PdfCanvas canvas = null;
PdfPage page = null;
RegexBasedLocationExtractionStrategy strategy = null;
PdfCanvasProcessor canvasProcessor = null;
Pattern p = null;
Document document = null;
Image image = null;
try {
pdfDocument = new PdfDocument(new PdfReader(sourcePath), new PdfWriter(targetPath));
} catch (IOException e) {
log.error("[PDF 签图片] pdf路径错误,原路径:" + sourcePath + ",目标路径:" + targetPath);
}
for (int i = 0; i < pdfDocument.getNumberOfPages(); i++) {
for (Map.Entry<String, String> entry : flagMap.entrySet()) {
//获取每一页,从第1页(下标为1)开始
page = pdfDocument.getPage(i + 1);
//找出关键字坐标
strategy = new RegexBasedLocationExtractionStrategy(entry.getKey());
canvasProcessor = new PdfCanvasProcessor(strategy);
canvasProcessor.processPageContent(page);
Collection<IPdfTextLocation> resultantLocations = strategy.getResultantLocations();
//签图片
canvas = new PdfCanvas(pdfDocument.getPage(i + 1));
canvas.saveState();
canvas.setFillColor(ColorConstants.WHITE);
for (IPdfTextLocation location : resultantLocations) {
rectangle = location.getRectangle();
if (xOffSet != null) {
rectangle.setX(rectangle.getX() + xOffSet);
}
if (yOffset != null) {
rectangle.setY(rectangle.getY() + yOffset);
}
//读取并添加图片到指定位置(横板图片位置:D:\InetService\resource\drawingImage 正常图片位置:D:\SignService\SignImages)
//获取外部资源配置
Properties prop = ResourceHelper.getResource();
//获取图片文件路径
String drawingImagePath = prop.getProperty("DrawingImagePath");
String signImagePath = prop.getProperty("SignImagePath");
try {
if (!"A4".equals(pictureFrame)) {
if (entry.getKey().contains("HQ")) {
imageData = ImageDataFactory.create(signImagePath + entry.getValue());
document = new Document(pdfDocument, PageSize.A3);
image = new Image(imageData, rectangle.getX(), rectangle.getY());
image.setHeight(rectangle.getHeight());
image.setWidth(rectangle.getWidth());
} else {
// imageData = ImageDataFactory.create(drawingImagePath + entry.getValue());
imageData = ImageDataFactory.create(signImagePath + entry.getValue());
document = new Document(pdfDocument, PageSize.A3);
image = new Image(imageData, rectangle.getX(), rectangle.getY() + rectangle.getHeight());
image.setRotationAngle(-Math.PI / 2);
//宽高反的rectangleWidth:12.0 rectangleHeight:42.0
image.setHeight(rectangle.getWidth());
image.setWidth(rectangle.getHeight());
}
} else {
imageData = ImageDataFactory.create(signImagePath + entry.getValue());
document = new Document(pdfDocument, PageSize.A4);
image = new Image(imageData, rectangle.getX(), rectangle.getY());
image.setHeight(rectangle.getHeight());
image.setWidth(rectangle.getWidth());
}
} catch (MalformedURLException e) {
log.error("[PDF 签图片] 待签名图片路径错误:" + entry.getValue());
}
document.add(image);
}
}
}
if (document != null) {
document.close();
}
// pdfDocument.close();
}
/**
* 处理签名图片
*/
public static Image signImageByDocument(PdfDocument pdfDocument, Document document, ImageData imageData, Image image, Rectangle rectangle,String checkVal) {
document = new Document(pdfDocument, PageSize.A3);
image = new Image(imageData, rectangle.getX(), rectangle.getY());
image.setHeight(rectangle.getHeight());
image.setWidth(rectangle.getWidth());
return image;
}
/**
* 判断是否为图片 适用格式: bmp/gif/jpg/png
*
* @param imageUrl 图片绝对路径
* @return 布尔值
*/
public static Boolean isImage(String imageUrl) {
try {
// 通过ImageReader来解码这个file并返回一个BufferedImage对象
// 如果找不到合适的ImageReader则会返回null,我们可以认为这不是图片文件
// 或者在解析过程中报错,也返回false
java.awt.Image image = ImageIO.read(new File(imageUrl));
return image != null;
} catch (IOException ex) {
return false;
}
}
public static Boolean checkImage(String imageUrl) {
boolean b = imageUrl.endsWith(".png");
return b;
}
}
package com.yonde.dcs.core.signUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.Map;
/**
* @author wyy
* @version 1.0
* @description: pdf签名
* @date 2021/6/25 15:21
*/
@Component
@Slf4j
public class SignImageUtil {
/**
* 签图片 图片的大小为占位符的大小
*
* @param sourcePath 原文件路径
* @param targetPath 目标文件路径
* @param flagMap key:占位符 value:图片绝对路径
*/
public static void signImage(String sourcePath, String targetPath, Map<String, String> flagMap, String pictureFrame) throws Exception {
SignHelper.signImage(sourcePath, targetPath, flagMap, null, null, pictureFrame);
}
/**
* 签图片 图片的大小为占位符的大小
*
* @param sourcePath 原文件路径
* @param targetPath 目标文件路径
* @param flagMap key:占位符 value:图片绝对路径
* @param xOffSet x轴偏移量 (正数:图片向右移动, 负数:图片向左移动)
* @param yOffset y轴偏移量 (正数:图片向上移动, 负数:图片向下移动)
*/
public static void signImage(String sourcePath, String targetPath, Map<String, String> flagMap, Float xOffSet, Float yOffset, String pictureFrame) throws Exception {
SignHelper.signImage(sourcePath, targetPath, flagMap, xOffSet, yOffset, pictureFrame);
}
}
package com.yonde.dcs.core.signUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
/**
* @author wyy
* @version 1.0
* @description: pdf签名
* @date 2021/6/25 15:21
*/
@Component
@Slf4j
public class SignUtil {
//word调整文字宽度(高度可改变字体大小调整):动态调整文字的宽高,鼠标右键选中-右键点击-字体-高级-字符间距-缩放
//缩放>100% 拉宽
//缩放<100% 变窄
/**
* 签字+签图片
*
* @param sourcePath 原文件路径
* @param targetPath 目标文件路径
* @param flagMap key:占位符 value:替换文本/图片路径
*/
public static void sign(String sourcePath, String targetPath, Map<String, String> flagMap, String pictureFrame) throws Exception {
Map<String, String> wordMap = new HashMap<>();
Map<String, String> imageMap = new HashMap<>();
for (Map.Entry<String, String> entry : flagMap.entrySet()) {
//判断是否为图片 适用格式: bmp/gif/jpg/png
if (SignHelper.checkImage(entry.getValue())) {
log.info("图片路径为:" + entry.getValue().toString());
imageMap.put(entry.getKey(), entry.getValue());
} else {
wordMap.put(entry.getKey(), entry.getValue());
}
}
String temPath = targetPath.replaceFirst(".pdf", "-tem.pdf");
//签文字
SignWordUtil.signWord(sourcePath, temPath, wordMap, pictureFrame);
//签图片
SignImageUtil.signImage(temPath, targetPath, imageMap, pictureFrame);
}
}
package com.yonde.dcs.core.signUtils;
import com.itextpdf.kernel.font.PdfFont;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.Map;
/**
* @author wyy
* @version 1.0
* @description: 签文字
* @date 2021/6/25 15:21
*/
@Component
@Slf4j
public class SignWordUtil {
/**
* 签文字:字体大小为占位符大小(以占位符宽度大小为准)
*
* @param sourcePath 源文件
* @param targetPath 目标文件
* @param flagMap key:占位符 value:替换文本
*/
public static void signWord(String sourcePath, String targetPath, Map<String, String> flagMap, String pictureFrame) throws Exception {
SignHelper.signWord(sourcePath, targetPath, flagMap, null, null, pictureFrame);
}
/**
* 签文字
*
* @param sourcePath 源文件
* @param targetPath 目标文件
* @param flagMap key:占位符 value:替换文本
* @param fontSize 字体大小
*/
public static void signWord(String sourcePath, String targetPath, Map<String, String> flagMap, Float fontSize, String pictureFrame) throws Exception {
SignHelper.signWord(sourcePath, targetPath, flagMap, fontSize, null, pictureFrame);
}
/**
* 签文字:字体大小为占位符大小(以占位符宽度大小为准)
*
* @param sourcePath 源文件
* @param targetPath 目标文件
* @param flagMap key:占位符 value:替换文本
* @param fontStyle 字体样式
*/
public static void signWord(String sourcePath, String targetPath, Map<String, String> flagMap, PdfFont fontStyle, String pictureFrame) throws Exception {
SignHelper.signWord(sourcePath, targetPath, flagMap, null, fontStyle, pictureFrame);
}
/**
* 签文字
*
* @param sourcePath 源文件
* @param targetPath 目标文件
* @param flagMap key:占位符 value:替换文本
* @param fontSize 字体大小
* @param fontStyle 字体样式
*/
public static void signWord(String sourcePath, String targetPath, Map<String, String> flagMap, Float fontSize, PdfFont fontStyle, String pictureFrame) throws Exception {
SignHelper.signWord(sourcePath, targetPath, flagMap, fontSize, fontStyle, pictureFrame);
}
}
......@@ -24,10 +24,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestAttributes;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.io.InputStream;
import java.util.*;
import java.util.stream.Collectors;
/**
......@@ -116,9 +114,9 @@ public class ExtDocUtil {
* @param fileVO
*/
// TODO: 2024/8/1 minioFileStoreService不存在
// public InputStream obtainPrimaryFileInputStream(RepoFileVO fileVO) {
// InputStream inputStream = null;
// if (!ObjectUtils.isEmpty(fileVO)) {
public InputStream obtainPrimaryFileInputStream(RepoFileVO fileVO) {
InputStream inputStream = null;
if (!ObjectUtils.isEmpty(fileVO)) {
// log.info("开始下载主内容======》" + fileVO.getId());
// RepoFileVO fileEntity = this.fileService.findFileInfoById(fileVO.getId());
// Site siteEntity = this.siteService.findByIsDefault(true);
......@@ -127,11 +125,11 @@ public class ExtDocUtil {
// } else {
// inputStream = this.minioFileStoreService.download(fileEntity.getBucketName(), fileEntity.getMinioFileName(), fileEntity.getSecretKey(), siteEntity);
// }
// } else {
// log.error("下载主内容失败======》fileVO为空!");
// }
// return inputStream;
// }
} else {
log.error("下载主内容失败======》fileVO为空!");
}
return inputStream;
}
/**
* 通过id查询文档附件
......
......@@ -20,7 +20,7 @@ import java.util.stream.Collectors;
* @date 2021/7/12 10:28
*/
public class ObjFileLinkUtil {
//TODO 暂使用RepoFileVO替换PapersVO
public static <T extends IdVO & ContentHolder> void removeAllFile(T holder) {
if (!CollectionUtils.isEmpty(((ContentHolder) holder).getObjFileLinks())) {
......@@ -42,11 +42,11 @@ public class ObjFileLinkUtil {
* @param fileType
* @param <T>
*/
// public static <T extends IdVO & ContentHolder> void replaceFile(T holder, PapersVO fileVO, String fileType) {
// removeFile(holder, fileType);
// addFile(holder, fileVO, fileType);
// }
//
public static <T extends IdVO & ContentHolder> void replaceFile(T holder, RepoFileVO fileVO, String fileType) {
removeFile(holder, fileType);
addFile(holder, fileVO, fileType);
}
public static <T extends IdVO & ContentHolder> void addFile(T holder, RepoFileVO fileVO, String fileType) {
if (CollectionUtils.isEmpty(((ContentHolder)holder).getObjFileLinks())) {
((ContentHolder)holder).setObjFileLinks(new ArrayList());
......@@ -149,7 +149,6 @@ public class ObjFileLinkUtil {
* @param <T>
* @return
*/
public static <T extends IdVO & ContentHolder> List<RepoFileVO> getAppointTypeFile(T holder, String fileType) {
if (!Objects.isNull(holder) && !CollectionUtils.isEmpty(((ContentHolder) holder).getObjFileLinks())) {
List<ObjFileLinkVO> fileLinkVOList = holder.getObjFileLinks().stream().filter(o -> o.getContentType().equalsIgnoreCase(fileType)).collect(Collectors.toList());
......@@ -168,15 +167,15 @@ public class ObjFileLinkUtil {
* @param <T>
* @return
*/
// public static <T extends IdVO & ContentHolder> List<PapersVO> getAppointNameFile(T holder, String fileType, String fileLikeName) {
// if (!Objects.isNull(holder) && !CollectionUtils.isEmpty(((ContentHolder) holder).getObjFileLinks())) {
// List<ObjFileLinkVO> fileLinkVOList = holder.getObjFileLinks().stream().filter(o -> o.getContentType().equalsIgnoreCase(fileType)).collect(Collectors.toList());
// if (!CollectionUtils.isEmpty(fileLinkVOList)) {
// return fileLinkVOList.stream().map(ObjFileLinkVO::getTarget).filter(o -> o.getOriginalFileName().contains(fileLikeName)).collect(Collectors.toList());
// }
// }
// return null;
// }
public static <T extends IdVO & ContentHolder> List<RepoFileVO> getAppointNameFile(T holder, String fileType, String fileLikeName) {
if (!Objects.isNull(holder) && !CollectionUtils.isEmpty(((ContentHolder) holder).getObjFileLinks())) {
List<ObjFileLinkVO> fileLinkVOList = holder.getObjFileLinks().stream().filter(o -> o.getContentType().equalsIgnoreCase(fileType)).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(fileLinkVOList)) {
return fileLinkVOList.stream().map(ObjFileLinkVO::getTarget).filter(o -> o.getOriginalFileName().contains(fileLikeName)).collect(Collectors.toList());
}
}
return null;
}
}
package com.yonde.dcs.core.events;
package com.yonde.dcs.core.util;
import cn.hutool.core.io.FileUtil;
import cn.hutool.extra.spring.SpringUtil;
......
package com.yonde.dcs.core.event;
import com.yonde.dcs.common.vo.ExtIncomeContractVO;
import com.yonde.dcs.common.vo.ExtSpendingContractVO;
import com.yonde.dcs.plan.common.vo.ExtPlanVO;
import org.apache.commons.compress.utils.Lists;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.List;
//@SpringBootTest
@RunWith(SpringRunner.class)
public class DocumentEventTest {
@Mock
DocumentEvent documentEvent;
@Test
public void extValidateSecretTest() {
ExtPlanVO extPlanVO = new ExtPlanVO();
ExtIncomeContractVO extIncomeContractVO = new ExtIncomeContractVO();
ExtSpendingContractVO extSpendingContractVO = new ExtSpendingContractVO();
List objects = Lists.newArrayList();
objects.add(extPlanVO);
objects.add(extIncomeContractVO);
objects.add(extSpendingContractVO);
documentEvent.extValidateSecret(objects);
Assert.assertNotNull("1");
}
}
package com.yonde.dcs.feign;
import com.yonde.dcs.core.util.ExtDocUtil;
import com.yonde.dcs.document.common.entity.vo.DxDocumentVO;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.springframework.test.context.junit4.SpringRunner;
import java.io.File;
@RunWith(SpringRunner.class)
public class ExtAutoTaskServiceFeignTest {
@Mock
ExtAutoTaskServiceFeign extAutoTaskServiceFeign;
@Mock
ExtDocUtil extDocUtil;
@Test
public void generateNcrReviewWordTest() {
DxDocumentVO dxDocumentVO = new DxDocumentVO();
dxDocumentVO.setSubTypeName("subTypeName");
dxDocumentVO.setNumber("number");
Mockito.when(extDocUtil.findDocObjFileLinks(Mockito.any())).thenReturn(dxDocumentVO);
extAutoTaskServiceFeign.generateNcrReviewWord(1L, null);
Assert.assertNotNull(new File("D:\\InetService\\resource\\template\\words\\subTypeName\\number\\source"));
}
}
\ No newline at end of file
......@@ -9,7 +9,6 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
......@@ -23,7 +22,7 @@ import java.util.Map;
**/
@Api(tags = "ExtAutoTask-FEIGN")
@FeignClient(value = "${dcs.feign.DCS-DOC}", path = "/task")
public interface ExtAutoTaskServiceFeign {
public interface ExtAutoTaskServiceFeign{
@ApiOperation(value = "客户化文档修改状态", notes = "客户化文档修改状态", httpMethod = "POST")
@PostMapping(value = "/extChangeDocState")
void extChangeDocState(@RequestBody DxDocumentVO documentVO, @RequestParam(name = "state") String state);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment