Commit 5caa6483 authored by xuzhang's avatar xuzhang

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

parent 1cb95188
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);
//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(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");
// 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", "文档编号已存在");
// }
}
}
//合并生成好的文档
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) {
}
}
// }
// });
// }
//
// /**
// * 审阅中编制任务后生成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 com.yonde.dcs.common.vo.ExtIncomeDetailVO;
import com.yonde.dcs.core.service.ExtDocService;
import com.yonde.dcs.core.util.ExtDocUtil;
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.dao.service.BaseService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import org.springframework.transaction.event.TransactionPhase;
import org.springframework.transaction.event.TransactionalEventListener;
/**
* @program: inet-pdm-service
* @description: 文档事务事件
* @author: dang wei
* @create: 2021-11-23 14:23
*/
@Component
@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.common.vo.ExtIncomeDetailVO;
//import com.yonde.dcs.core.service.ExtDocService;
//import com.yonde.dcs.core.util.ExtDocUtil;
//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.dao.service.BaseService;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Qualifier;
//import org.springframework.stereotype.Component;
//import org.springframework.transaction.event.TransactionPhase;
//import org.springframework.transaction.event.TransactionalEventListener;
//
///**
// * @program: inet-pdm-service
// * @description: 文档事务事件
// * @author: dang wei
// * @create: 2021-11-23 14:23
// */
//@Component
//@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 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.OutdatedDocNotifyUtils;
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.WorkFlowUtil;
import com.yonde.dcs.core.word.ImportWordService;
import com.yonde.dcs.document.common.entity.vo.DxDocumentVO;
import com.yonde.dex.wfc.common.vo.DxWfProcessInfoVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.io.File;
import java.io.FileInputStream;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* @author xfchai
* @ClassName ProcessDataUtils.java
* @Description 数据处理工具类
* @createTime 2022/02/23 16:11:00
*/
@Component
@Slf4j
public class ProcessDataUtils {
//word模板路径
public static final String PATH = Constants.MTEMPLATE_ABSOLUTE_PATH;
@Autowired
private ExtDocService extDocService;
@Autowired
private ImportWordService importWordService;
@Autowired
private ExtDocUtil extDocUtil;
@Autowired
private WorkFlowUtil workFlowUtil;
//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.OutdatedDocNotifyUtils;
//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.WorkFlowUtil;
//import com.yonde.dcs.core.word.ImportWordService;
//import com.yonde.dcs.document.common.entity.vo.DxDocumentVO;
//import com.yonde.dex.wfc.common.vo.DxWfProcessInfoVO;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//import org.springframework.util.CollectionUtils;
//
//import java.io.File;
//import java.io.FileInputStream;
//import java.lang.reflect.Method;
//import java.util.ArrayList;
//import java.util.Arrays;
//import java.util.List;
//
///**
// * @author xfchai
// * @ClassName ProcessDataUtils.java
// * @Description 数据处理工具类
// * @createTime 2022/02/23 16:11:00
// */
//@Component
//@Slf4j
//public class ProcessDataUtils {
// //word模板路径
// public static final String PATH = Constants.MTEMPLATE_ABSOLUTE_PATH;
// @Autowired
// private DexWorkFlowService dexWorkFlowService;
/**
* 单独处理过时文件通知单数据
*/
public void processOutdatedDocNotify(DxDocumentVO documentVo) {
extDocService.getDocWord(documentVo, OutdatedDocNotifyUtils.class, new DxWfProcessInfoVO(), "");
}
/**
* 处理单据word数据
*
* @param documentVo
*/
public void processData(DxDocumentVO documentVo) {
String subTypeName = documentVo.getSubTypeName();
//todo
// WfProcessInstVO DxWfProcessInstVO = workFlowUtil.getWfProcessInst(documentVo);
// DxWfProcessInfoVO wfProcessInfoVO = dexWorkFlowService.getProcessInstDetailById(DxWfProcessInstVO.getId());
// switch (subTypeName) {
// case Constants.INTERNAL_INTERFACE:
// this.generateInterFaceWord(documentVo, new InterfaceInfoLinkVO(), wfProcessInfoVO);
// break;
// case Constants.CONTACTLIST:
// extDocService.getDocWord(documentVo, ContactListUtils.class, wfProcessInfoVO, "一");
// break;
// case Constants.WORK_CONTACTLIST:
// extDocService.getDocWord(documentVo, WorkContactListUtils.class, wfProcessInfoVO, "");
// break;
// case Constants.DESIGN_CHANGE:
// extDocService.getDocWord(documentVo, DesignChangeUtils.class, wfProcessInfoVO, "");
// break;
// case Constants.DESIGN_APPLICATION:
// extDocService.getDocWord(documentVo, DesignDocApplicatUtils.class, wfProcessInfoVO, "");
// break;
// case Constants.DESIGN_ENTER:
// extDocService.getDocWord(documentVo, DesignEnterUtils.class, wfProcessInfoVO, "");
// break;
// case Constants.NCR:
// extDocService.getDocWord(documentVo, NCRUtils.class, wfProcessInfoVO, "");
// break;
// case Constants.DEN:
// //根据模板生成两张不同澄清单
// extDocService.getDocWord(documentVo, DENUtils.class, wfProcessInfoVO, "");
// break;
// private ExtDocService extDocService;
// @Autowired
// private ImportWordService importWordService;
// @Autowired
// private ExtDocUtil extDocUtil;
// @Autowired
// private WorkFlowUtil workFlowUtil;
//// @Autowired
//// private DexWorkFlowService dexWorkFlowService;
//
// /**
// * 单独处理过时文件通知单数据
// */
// public void processOutdatedDocNotify(DxDocumentVO documentVo) {
// extDocService.getDocWord(documentVo, OutdatedDocNotifyUtils.class, new DxWfProcessInfoVO(), "");
// }
//
// /**
// * 处理单据word数据
// *
// * @param documentVo
// */
// public void processData(DxDocumentVO documentVo) {
// String subTypeName = documentVo.getSubTypeName();
// //todo
//// WfProcessInstVO DxWfProcessInstVO = workFlowUtil.getWfProcessInst(documentVo);
//// DxWfProcessInfoVO wfProcessInfoVO = dexWorkFlowService.getProcessInstDetailById(DxWfProcessInstVO.getId());
//// switch (subTypeName) {
//// case Constants.INTERNAL_INTERFACE:
//// this.generateInterFaceWord(documentVo, new InterfaceInfoLinkVO(), wfProcessInfoVO);
//// break;
//// case Constants.CONTACTLIST:
//// extDocService.getDocWord(documentVo, ContactListUtils.class, wfProcessInfoVO, "一");
//// break;
//// case Constants.WORK_CONTACTLIST:
//// extDocService.getDocWord(documentVo, WorkContactListUtils.class, wfProcessInfoVO, "");
//// break;
//// case Constants.DESIGN_CHANGE:
//// extDocService.getDocWord(documentVo, DesignChangeUtils.class, wfProcessInfoVO, "");
//// break;
//// case Constants.DESIGN_APPLICATION:
//// extDocService.getDocWord(documentVo, DesignDocApplicatUtils.class, wfProcessInfoVO, "");
//// break;
//// case Constants.DESIGN_ENTER:
//// extDocService.getDocWord(documentVo, DesignEnterUtils.class, wfProcessInfoVO, "");
//// break;
//// case Constants.NCR:
//// extDocService.getDocWord(documentVo, NCRUtils.class, wfProcessInfoVO, "");
//// break;
//// case Constants.DEN:
//// //根据模板生成两张不同澄清单
//// extDocService.getDocWord(documentVo, DENUtils.class, wfProcessInfoVO, "");
//// break;
//// }
// }
//
// /**
// * 新建内部接口文档-生成内部接口的word
// *
// * @param documentVo
// * @param infoLinkVO 提资人信息
// */
// public void generateInterFaceWord(DxDocumentVO documentVo, ExtInterfaceInfoLinkVO infoLinkVO, DxWfProcessInfoVO wfProcessInfoVO) {
// try {
// String file = documentVo.getSubTypeName();
// String outWordFilePath = Constants.MERGER_FILE_ABSOLUTE_PATH + documentVo.getSubTypeName() + "\\" + documentVo.getNumber() + "\\";
// //生成特定的文档目录,保存生成的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);
// //生成word文件方法
// importWordService.getWordAllTable(jsonObject, PATH + file + ".docx", outWordFilePath + "outFile.docx");
// log.info("生成word文件内容结束====");
// //获取文件夹的所有文件--绝对路径
// List<String> fileList = new ArrayList<>();
// File[] files = FileUtil.ls(outWordFilePath);
// Arrays.stream(files).forEach(item -> {
// fileList.add(item.getAbsolutePath());
// });
// if (CollectionUtils.isEmpty(fileList)) {
// log.error("生成的word文件目录内容为空====");
// } else {
//// String filePath = fileList.stream().filter(item -> item.endsWith(".docx")).findFirst().get();
// String pdfFilePath = fileList.stream().filter(item -> item.endsWith(".pdf")).findFirst().get();
// //将pdf上传到附件中
// extDocService.extractedAttachFile(documentVo, new FileInputStream(pdfFilePath), "", Constants.ATTACH_FILE);
// log.info("获取生成的word文件内容结束====");
// }
// //删除生成后的临时文件
// FileUtils.deleteDirectory(Constants.MERGER_FILE_ABSOLUTE_PATH + documentVo.getSubTypeName() + "\\" + documentVo.getNumber());
// } catch (Exception e) {
// log.error("新建内部接口文档-生成内部接口的word错误:{}" + e.getMessage());
// }
}
/**
* 新建内部接口文档-生成内部接口的word
*
* @param documentVo
* @param infoLinkVO 提资人信息
*/
public void generateInterFaceWord(DxDocumentVO documentVo, ExtInterfaceInfoLinkVO infoLinkVO, DxWfProcessInfoVO wfProcessInfoVO) {
try {
String file = documentVo.getSubTypeName();
String outWordFilePath = Constants.MERGER_FILE_ABSOLUTE_PATH + documentVo.getSubTypeName() + "\\" + documentVo.getNumber() + "\\";
//生成特定的文档目录,保存生成的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);
//生成word文件方法
importWordService.getWordAllTable(jsonObject, PATH + file + ".docx", outWordFilePath + "outFile.docx");
log.info("生成word文件内容结束====");
//获取文件夹的所有文件--绝对路径
List<String> fileList = new ArrayList<>();
File[] files = FileUtil.ls(outWordFilePath);
Arrays.stream(files).forEach(item -> {
fileList.add(item.getAbsolutePath());
});
if (CollectionUtils.isEmpty(fileList)) {
log.error("生成的word文件目录内容为空====");
} else {
// String filePath = fileList.stream().filter(item -> item.endsWith(".docx")).findFirst().get();
String pdfFilePath = fileList.stream().filter(item -> item.endsWith(".pdf")).findFirst().get();
//将pdf上传到附件中
extDocService.extractedAttachFile(documentVo, new FileInputStream(pdfFilePath), "", Constants.ATTACH_FILE);
log.info("获取生成的word文件内容结束====");
}
//删除生成后的临时文件
FileUtils.deleteDirectory(Constants.MERGER_FILE_ABSOLUTE_PATH + documentVo.getSubTypeName() + "\\" + documentVo.getNumber());
} catch (Exception e) {
log.error("新建内部接口文档-生成内部接口的word错误:{}" + e.getMessage());
}
}
}
// }
//}
package com.yonde.dcs.core.events;
import com.yonde.dex.basedata.exception.DxBusinessException;
import com.yonde.dex.context.common.vo.DxContextVO;
import com.yonde.dex.context.feign.ContextServiceFeign;
import com.yonde.dex.dao.service.BaseService;
import com.yonde.dex.dao.service.listener.AbstractEventListener;
import com.yonde.dex.dict.feign.DictDataFeignService;
import com.yonde.dex.dict.service.vo.DictDataVO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
@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 = "计划密级不能高于项目密级!";
//package com.yonde.dcs.core.events;
//
//
//import com.yonde.dex.basedata.exception.DxBusinessException;
//import com.yonde.dex.context.common.vo.DxContextVO;
//import com.yonde.dex.context.feign.ContextServiceFeign;
//import com.yonde.dex.dao.service.BaseService;
//import com.yonde.dex.dao.service.listener.AbstractEventListener;
//import com.yonde.dex.dict.feign.DictDataFeignService;
//import com.yonde.dex.dict.service.vo.DictDataVO;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.commons.collections4.CollectionUtils;
//import org.apache.commons.lang3.StringUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Qualifier;
//import org.springframework.stereotype.Service;
//import org.springframework.transaction.annotation.Transactional;
//
//import java.util.List;
//import java.util.Set;
//import java.util.stream.Collectors;
//
//@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;
// }
// if (dxObjectVo instanceof ExtIncomeContractVO) {
// checkResult = checkDxObjectVoSecret(dxObjectVo);
// checkResultStr = "收入合同密级不能高于项目密级!";
// }
//
// @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);
// }
// }
//
//
// }
// if (dxObjectVo instanceof ExtSpendingContractVO) {
// checkResult = checkDxObjectVoSecret(dxObjectVo);
// 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 = "";
// }
if (checkResult) {
checkResultStr = "";
}
return checkResultStr;
}
/**
* 校验计划、收入合同、支出合同密级与项目的关系
*
* @return
*/
//todo
private Boolean checkDxObjectVoSecret(DxContextVO dxObjectVo) {
// if (StringUtils.isBlank(dxObjectVo.getSecretCode())) {
// return true;
// 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);
// }
// 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;
}
}
// 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;
// }
//}
......@@ -7,13 +7,13 @@ import cn.hutool.core.io.FileUtil;
import cn.hutool.extra.spring.SpringUtil;
import com.alibaba.fastjson.JSONObject;
import com.yonde.dcs.common.vo.*;
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.factory.NCRSCUtils;
import com.yonde.dcs.core.factory.TechnicalFileUtils;
import com.yonde.dcs.core.service.*;
import com.yonde.dcs.core.util.*;
import com.yonde.dcs.core.util.ExtDocUtil;
import com.yonde.dcs.core.util.ExtWfcUtil;
import com.yonde.dcs.core.util.SearchUtil;
import com.yonde.dcs.core.util.WorkFlowUtil;
import com.yonde.dcs.core.word.ImportWordService;
import com.yonde.dcs.document.common.entity.vo.DxDocumentVO;
import com.yonde.dcs.document.core.service.DocumentService;
......@@ -27,10 +27,8 @@ import com.yonde.dcs.plan.feign.ExtPlanServiceFeign;
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.api.CustomMultipartFile;
import com.yonde.dex.basedata.entity.data.DxPageImpl;
import com.yonde.dex.basedata.entity.data.OperatorType;
import com.yonde.dex.basedata.entity.jackson.JsonUtils;
import com.yonde.dex.basedata.exception.DxBusinessException;
import com.yonde.dex.basedata.utils.obj.DxEntityUtils;
import com.yonde.dex.dao.service.util.DxPageUtils;
......@@ -43,19 +41,16 @@ 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.user.feign.SwitchUserService;
import com.yonde.dex.utils.common.utils.DxFileUtils;
import com.yonde.dex.wfc.common.vo.*;
import com.yonde.dex.wfc.common.vo.DxWfParticipantInfoVO;
import com.yonde.dex.wfc.common.vo.DxWfProcessTaskVO;
import com.yonde.dex.wfc.common.vo.DxWfTaskContext;
import com.yonde.dex.wfc.feign.api.WfcProcessFeign;
import com.yonde.dex.wfc.feign.api.WfcTaskFeign;
import feign.form.ContentType;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.client.utils.CloneUtils;
import org.joda.time.LocalDate;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
......@@ -66,7 +61,9 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.io.*;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.lang.reflect.Method;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
......@@ -115,8 +112,8 @@ public class ExtAutoTaskServiceImpl implements ExtAutoTaskService {
private SwitchUserService switchUserService;
@Autowired
private ExtInterfaceInfoLinkService interfaceInfoLinkService;
@Autowired
private DocBeforeCreateEvent docBeforeCreateEvent;
// @Autowired
// private DocBeforeCreateEvent docBeforeCreateEvent;
@Autowired
private FileManagerFeignService fileManagerFeignService;
@Autowired
......@@ -135,8 +132,8 @@ public class ExtAutoTaskServiceImpl implements ExtAutoTaskService {
private TechnicalFileUtils technicalFileUtils;
@Autowired
private WorkFlowUtil workFlowUtil;
@Autowired
private ProcessDataUtils processDataUtils;
// @Autowired
// private ProcessDataUtils processDataUtils;
@Autowired
ExtApplicantService extApplicantService;
@Autowired
......@@ -1026,8 +1023,8 @@ public class ExtAutoTaskServiceImpl implements ExtAutoTaskService {
*/
@Override
public void generateWordByAutoMethod(DxDocumentVO documentVo) {
DxDocumentVO dxDocumentVO = docBeforeCreateEvent.processCreateData(documentVo);
documentService.saveRecursion(dxDocumentVO);
// DxDocumentVO dxDocumentVO = docBeforeCreateEvent.processCreateData(documentVo);
// documentService.saveRecursion(dxDocumentVO);
}
/**
......
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