Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dcs-doc-expand
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
INET-TWO
server
dcs-doc-expand
Commits
5caa6483
Commit
5caa6483
authored
Aug 13, 2024
by
xuzhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[feat][DOC]迁移类缺失问题修改
parent
1cb95188
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
633 additions
and
636 deletions
+633
-636
DocBeforeCreateEvent.java
.../java/com/yonde/dcs/core/events/DocBeforeCreateEvent.java
+256
-256
DocTransactionEvent.java
...n/java/com/yonde/dcs/core/events/DocTransactionEvent.java
+88
-88
ProcessDataUtils.java
...main/java/com/yonde/dcs/core/events/ProcessDataUtils.java
+135
-135
ValidateSecretListener.java
...ava/com/yonde/dcs/core/events/ValidateSecretListener.java
+138
-138
ExtAutoTaskServiceImpl.java
...m/yonde/dcs/core/service/impl/ExtAutoTaskServiceImpl.java
+16
-19
No files found.
dcs-doc-expand-core/src/main/java/com/yonde/dcs/core/events/DocBeforeCreateEvent.java
View file @
5caa6483
package
com
.
yonde
.
dcs
.
core
.
events
;
//package com.yonde.dcs.core.events;
//
//
import
cn.hutool.core.io.FileUtil
;
//import cn.hutool.core.io.FileUtil;
import
cn.hutool.extra.spring.SpringUtil
;
//import cn.hutool.extra.spring.SpringUtil;
import
com.alibaba.fastjson.JSONObject
;
//import com.alibaba.fastjson.JSONObject;
import
com.yonde.dcs.common.vo.ExtInterfaceInfoLinkVO
;
//import com.yonde.dcs.common.vo.ExtInterfaceInfoLinkVO;
import
com.yonde.dcs.core.constants.Constants
;
//import com.yonde.dcs.core.constants.Constants;
import
com.yonde.dcs.core.factory.InternalInterfaceUtils
;
//import com.yonde.dcs.core.factory.InternalInterfaceUtils;
import
com.yonde.dcs.core.factory.TechnicalFileUtils
;
//import com.yonde.dcs.core.factory.TechnicalFileUtils;
import
com.yonde.dcs.core.service.ExtDocService
;
//import com.yonde.dcs.core.service.ExtDocService;
import
com.yonde.dcs.core.util.ExtDocUtil
;
//import com.yonde.dcs.core.util.ExtDocUtil;
import
com.yonde.dcs.core.util.FileUtils
;
//import com.yonde.dcs.core.util.FileUtils;
import
com.yonde.dcs.core.word.ImportWordService
;
//import com.yonde.dcs.core.word.ImportWordService;
import
com.yonde.dcs.document.common.entity.vo.DxDocumentVO
;
//import com.yonde.dcs.document.common.entity.vo.DxDocumentVO;
import
com.yonde.dex.basedata.exception.DxBusinessException
;
//import com.yonde.dex.basedata.exception.DxBusinessException;
import
com.yonde.dex.dao.events.BusinessEventType
;
//import com.yonde.dex.dao.events.BusinessEventType;
import
com.yonde.dex.dao.events.DxEvent
;
//import com.yonde.dex.dao.events.DxEvent;
import
com.yonde.dex.dao.events.DxEventListener
;
//import com.yonde.dex.dao.events.DxEventListener;
import
com.yonde.dex.dao.events.DxEventWrap
;
//import com.yonde.dex.dao.events.DxEventWrap;
import
com.yonde.dex.dfs.vo.ObjFileLinkVO
;
//import com.yonde.dex.dfs.vo.ObjFileLinkVO;
import
com.yonde.dex.wfc.common.vo.DxWfProcessInfoVO
;
//import com.yonde.dex.wfc.common.vo.DxWfProcessInfoVO;
import
lombok.extern.slf4j.Slf4j
;
//import lombok.extern.slf4j.Slf4j;
import
org.apache.commons.collections.CollectionUtils
;
//import org.apache.commons.collections.CollectionUtils;
import
org.apache.commons.lang3.ObjectUtils
;
//import org.apache.commons.lang3.ObjectUtils;
import
org.springframework.beans.factory.annotation.Autowired
;
//import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Component
;
//import org.springframework.stereotype.Component;
//
import
java.io.File
;
//import java.io.File;
import
java.io.FileInputStream
;
//import java.io.FileInputStream;
import
java.io.IOException
;
//import java.io.IOException;
import
java.io.InputStream
;
//import java.io.InputStream;
import
java.lang.reflect.Method
;
//import java.lang.reflect.Method;
import
java.util.ArrayList
;
//import java.util.ArrayList;
import
java.util.Arrays
;
//import java.util.Arrays;
import
java.util.List
;
//import java.util.List;
//
/**
///**
* @author xfchai
// * @author xfchai
* @ClassName DocBeforeCreateEvent.java
// * @ClassName DocBeforeCreateEvent.java
* @Description 保存文档之前的操作事件
// * @Description 保存文档之前的操作事件
* @createTime 2021/11/15 14:29:00
// * @createTime 2021/11/15 14:29:00
*/
// */
@Component
//@Component
@Slf4j
//@Slf4j
@DxEvent
//@DxEvent
public
class
DocBeforeCreateEvent
{
//public class DocBeforeCreateEvent {
//word模板路径
// //word模板路径
public
static
final
String
PATH
=
Constants
.
MTEMPLATE_ABSOLUTE_PATH
;
// public static final String PATH = Constants.MTEMPLATE_ABSOLUTE_PATH;
public
static
final
String
DOC_END_WITH
=
".doc"
;
// public static final String DOC_END_WITH = ".doc";
public
static
final
String
DOCX_END_WITH
=
".docx"
;
// public static final String DOCX_END_WITH = ".docx";
@Autowired
// @Autowired
private
ExtDocService
extDocService
;
// private ExtDocService extDocService;
@Autowired
// @Autowired
private
ImportWordService
importWordService
;
// private ImportWordService importWordService;
@Autowired
// @Autowired
TechnicalFileUtils
technicalFileUtils
;
// TechnicalFileUtils technicalFileUtils;
@Autowired
// @Autowired
private
ProcessDataUtils
processDataUtils
;
// private ProcessDataUtils processDataUtils;
@Autowired
// @Autowired
private
ExtDocUtil
extDocUtil
;
// private ExtDocUtil extDocUtil;
//
@DxEventListener
(
value
=
DxDocumentVO
.
class
,
eventType
=
BusinessEventType
.
BEFORE_CREATE
,
order
=
1
)
// @DxEventListener(value = DxDocumentVO.class, eventType = BusinessEventType.BEFORE_CREATE, order = 1)
public
void
createDocListener
(
List
<
DxEventWrap
<
DxDocumentVO
>>
events
)
{
// public void createDocListener(List<DxEventWrap<DxDocumentVO>> events) {
events
.
forEach
(
e
->
{
// 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();
// String subTypeName = e.getTarget().getSubTypeName();
// //处理过时文件通知单
// //处理过时文件通知单
// if (Constants.OUTDATED_NOTIFY.equals(subTypeName)) {
// if (Constants.OUTDATED_NOTIFY.equals(subTypeName)) {
// processDataUtils.processOutdatedDocNotify(docObjFileLinks);
// 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", "文档编号已存在");
// }
// }
// 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
{
// * 审阅中编制任务后生成word文档
//将pdf上传到附件中
// *
extDocService
.
extractedAttachFile
(
documentVo
,
new
FileInputStream
(
dirPath
+
Constants
.
MERGER_PDF_FILE_NAME
),
"附件一"
,
Constants
.
ATTACH_FILE
);
// * @param documentVo
}
catch
(
IOException
e
)
{
// */
log
.
error
(
"文件输入错误!"
);
// public DxDocumentVO processCreateData(DxDocumentVO documentVo) {
}
catch
(
Exception
e
)
{
// //查询展开ObjFileLink
log
.
error
(
"上传附件错误!"
);
// DxDocumentVO documentVO = extDocUtil.findDocObjFileLinks(documentVo.getId());
}
// //根据状态判断是否进行更新word(审阅中)
}
// if (Constants.REVIEWING.equals(documentVO.getState()) || Constants.CAPITAL_RAISING.equals(documentVO.getState())) {
// //技术文件(设计图册或者安装图册)
public
void
generalQAPWord
(
DxDocumentVO
documentVo
)
{
// 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) {
//
// }
//}
dcs-doc-expand-core/src/main/java/com/yonde/dcs/core/events/DocTransactionEvent.java
View file @
5caa6483
package
com
.
yonde
.
dcs
.
core
.
events
;
//
package com.yonde.dcs.core.events;
//
//
import
com.yonde.dcs.common.vo.ExtIncomeDetailVO
;
//
import com.yonde.dcs.common.vo.ExtIncomeDetailVO;
import
com.yonde.dcs.core.service.ExtDocService
;
//
import com.yonde.dcs.core.service.ExtDocService;
import
com.yonde.dcs.core.util.ExtDocUtil
;
//
import com.yonde.dcs.core.util.ExtDocUtil;
import
com.yonde.dcs.document.common.entity.vo.DxDocumentVO
;
//
import com.yonde.dcs.document.common.entity.vo.DxDocumentVO;
import
com.yonde.dcs.document.core.service.DocumentService
;
//
import com.yonde.dcs.document.core.service.DocumentService;
import
com.yonde.dcs.plan.common.vo.ExtSpendingDetailVO
;
//
import com.yonde.dcs.plan.common.vo.ExtSpendingDetailVO;
import
com.yonde.dcs.plan.feign.ExtIncomeContractServiceFeign
;
//
import com.yonde.dcs.plan.feign.ExtIncomeContractServiceFeign;
import
com.yonde.dcs.plan.feign.ExtSpendingContractServiceFeign
;
//
import com.yonde.dcs.plan.feign.ExtSpendingContractServiceFeign;
import
com.yonde.dex.dao.service.BaseService
;
//
import com.yonde.dex.dao.service.BaseService;
import
lombok.extern.slf4j.Slf4j
;
//
import lombok.extern.slf4j.Slf4j;
import
org.springframework.beans.factory.annotation.Autowired
;
//
import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.beans.factory.annotation.Qualifier
;
//
import org.springframework.beans.factory.annotation.Qualifier;
import
org.springframework.stereotype.Component
;
//
import org.springframework.stereotype.Component;
import
org.springframework.transaction.event.TransactionPhase
;
//
import org.springframework.transaction.event.TransactionPhase;
import
org.springframework.transaction.event.TransactionalEventListener
;
//
import org.springframework.transaction.event.TransactionalEventListener;
//
/**
/
//
**
* @program: inet-pdm-service
//
* @program: inet-pdm-service
* @description: 文档事务事件
//
* @description: 文档事务事件
* @author: dang wei
//
* @author: dang wei
* @create: 2021-11-23 14:23
//
* @create: 2021-11-23 14:23
*/
//
*/
@Component
//
@Component
@Slf4j
//
@Slf4j
public
class
DocTransactionEvent
{
//
public class DocTransactionEvent {
//
@Autowired
//
@Autowired
private
ExtDocService
extDocService
;
//
private ExtDocService extDocService;
//
@Autowired
//
@Autowired
@Qualifier
(
"documentServiceImpl"
)
//
@Qualifier("documentServiceImpl")
DocumentService
documentService
;
//
DocumentService documentService;
@Autowired
//
@Autowired
private
ExtIncomeContractServiceFeign
extIncomeContractService
;
//
private ExtIncomeContractServiceFeign extIncomeContractService;
@Autowired
//
@Autowired
private
ExtSpendingContractServiceFeign
extSpendingContractService
;
//
private ExtSpendingContractServiceFeign extSpendingContractService;
@Autowired
//
@Autowired
private
ExtDocUtil
extDocUtil
;
//
private ExtDocUtil extDocUtil;
//
@TransactionalEventListener
(
phase
=
TransactionPhase
.
AFTER_COMMIT
)
//
@TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT)
public
void
afterCommit
(
BaseService
.
DataChangeEvent
event
)
{
//
public void afterCommit(BaseService.DataChangeEvent event) {
final
String
eventType
=
event
.
getEventType
();
//
final String eventType = event.getEventType();
final
BaseService
.
ChangeType
changeType
=
BaseService
.
ChangeType
.
valueOf
(
eventType
);
//
final BaseService.ChangeType changeType = BaseService.ChangeType.valueOf(eventType);
if
(
changeType
==
BaseService
.
ChangeType
.
POST_CREATE
||
changeType
==
BaseService
.
ChangeType
.
POST_UPDATE
||
changeType
==
BaseService
.
ChangeType
.
POST_DELETE
)
{
//
if (changeType == BaseService.ChangeType.POST_CREATE || changeType == BaseService.ChangeType.POST_UPDATE || changeType == BaseService.ChangeType.POST_DELETE) {
event
.
getEventTargets
().
forEach
(
t
->
{
//
event.getEventTargets().forEach(t -> {
DxDocumentVO
doc
=
new
DxDocumentVO
();
//
DxDocumentVO doc = new DxDocumentVO();
if
(
t
instanceof
ExtIncomeDetailVO
)
{
//
if (t instanceof ExtIncomeDetailVO) {
//刷新收入合同相关金额
//
//刷新收入合同相关金额
ExtIncomeDetailVO
extIncomeDetailVO
=
(
ExtIncomeDetailVO
)
t
;
//
ExtIncomeDetailVO extIncomeDetailVO = (ExtIncomeDetailVO) t;
this
.
refreshInContractAmount
(
extIncomeDetailVO
.
getExtIncomeContractId
());
//
this.refreshInContractAmount(extIncomeDetailVO.getExtIncomeContractId());
}
else
if
(
t
instanceof
ExtSpendingDetailVO
)
{
//
} else if (t instanceof ExtSpendingDetailVO) {
//刷新支出合同相关金额
//
//刷新支出合同相关金额
ExtSpendingDetailVO
spendingDetailVO
=
(
ExtSpendingDetailVO
)
t
;
//
ExtSpendingDetailVO spendingDetailVO = (ExtSpendingDetailVO) t;
this
.
refreshSpeContractAmount
(
spendingDetailVO
.
getExtSpendingContractId
());
//
this.refreshSpeContractAmount(spendingDetailVO.getExtSpendingContractId());
}
//
}
});
//
});
}
//
}
}
//
}
//
//
/**
//
/**
* 刷新收入合同金额
//
* 刷新收入合同金额
*
//
*
* @param contractId
//
* @param contractId
*/
//
*/
private
void
refreshInContractAmount
(
Long
contractId
)
{
//
private void refreshInContractAmount(Long contractId) {
//已到款
//
//已到款
//待拨付
//
//待拨付
extIncomeContractService
.
calculateIncome
(
contractId
);
//
extIncomeContractService.calculateIncome(contractId);
//XXX年到款
//
//XXX年到款
extIncomeContractService
.
reCalculIncomeById
(
contractId
);
//
extIncomeContractService.reCalculIncomeById(contractId);
}
//
}
//
/**
//
/**
* 刷新支出合同金额
//
* 刷新支出合同金额
*
//
*
* @param contractId
//
* @param contractId
*/
//
*/
private
void
refreshSpeContractAmount
(
Long
contractId
)
{
//
private void refreshSpeContractAmount(Long contractId) {
//已付金额
//
//已付金额
//未付金额
//
//未付金额
//付款比例
//
//付款比例
extSpendingContractService
.
calculateSpending
(
contractId
);
//
extSpendingContractService.calculateSpending(contractId);
}
//
}
}
//
}
dcs-doc-expand-core/src/main/java/com/yonde/dcs/core/events/ProcessDataUtils.java
View file @
5caa6483
package
com
.
yonde
.
dcs
.
core
.
events
;
//package com.yonde.dcs.core.events;
//
import
cn.hutool.core.io.FileUtil
;
//import cn.hutool.core.io.FileUtil;
import
cn.hutool.extra.spring.SpringUtil
;
//import cn.hutool.extra.spring.SpringUtil;
import
com.alibaba.fastjson.JSONObject
;
//import com.alibaba.fastjson.JSONObject;
//
import
com.yonde.dcs.common.vo.ExtInterfaceInfoLinkVO
;
//import com.yonde.dcs.common.vo.ExtInterfaceInfoLinkVO;
import
com.yonde.dcs.core.constants.Constants
;
//import com.yonde.dcs.core.constants.Constants;
import
com.yonde.dcs.core.factory.InternalInterfaceUtils
;
//import com.yonde.dcs.core.factory.InternalInterfaceUtils;
import
com.yonde.dcs.core.factory.OutdatedDocNotifyUtils
;
//import com.yonde.dcs.core.factory.OutdatedDocNotifyUtils;
import
com.yonde.dcs.core.service.ExtDocService
;
//import com.yonde.dcs.core.service.ExtDocService;
import
com.yonde.dcs.core.util.ExtDocUtil
;
//import com.yonde.dcs.core.util.ExtDocUtil;
import
com.yonde.dcs.core.util.FileUtils
;
//import com.yonde.dcs.core.util.FileUtils;
import
com.yonde.dcs.core.util.WorkFlowUtil
;
//import com.yonde.dcs.core.util.WorkFlowUtil;
import
com.yonde.dcs.core.word.ImportWordService
;
//import com.yonde.dcs.core.word.ImportWordService;
import
com.yonde.dcs.document.common.entity.vo.DxDocumentVO
;
//import com.yonde.dcs.document.common.entity.vo.DxDocumentVO;
import
com.yonde.dex.wfc.common.vo.DxWfProcessInfoVO
;
//import com.yonde.dex.wfc.common.vo.DxWfProcessInfoVO;
import
lombok.extern.slf4j.Slf4j
;
//import lombok.extern.slf4j.Slf4j;
import
org.springframework.beans.factory.annotation.Autowired
;
//import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Component
;
//import org.springframework.stereotype.Component;
import
org.springframework.util.CollectionUtils
;
//import org.springframework.util.CollectionUtils;
//
import
java.io.File
;
//import java.io.File;
import
java.io.FileInputStream
;
//import java.io.FileInputStream;
import
java.lang.reflect.Method
;
//import java.lang.reflect.Method;
import
java.util.ArrayList
;
//import java.util.ArrayList;
import
java.util.Arrays
;
//import java.util.Arrays;
import
java.util.List
;
//import java.util.List;
//
/**
///**
* @author xfchai
// * @author xfchai
* @ClassName ProcessDataUtils.java
// * @ClassName ProcessDataUtils.java
* @Description 数据处理工具类
// * @Description 数据处理工具类
* @createTime 2022/02/23 16:11:00
// * @createTime 2022/02/23 16:11:00
*/
// */
@Component
//@Component
@Slf4j
//@Slf4j
public
class
ProcessDataUtils
{
//public class ProcessDataUtils {
//word模板路径
// //word模板路径
public
static
final
String
PATH
=
Constants
.
MTEMPLATE_ABSOLUTE_PATH
;
// 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
;
// @Autowired
// @Autowired
// private DexWorkFlowService dexWorkFlowService;
// private ExtDocService extDocService;
// @Autowired
/**
// private ImportWordService importWordService;
* 单独处理过时文件通知单数据
// @Autowired
*/
// private ExtDocUtil extDocUtil;
public
void
processOutdatedDocNotify
(
DxDocumentVO
documentVo
)
{
// @Autowired
extDocService
.
getDocWord
(
documentVo
,
OutdatedDocNotifyUtils
.
class
,
new
DxWfProcessInfoVO
(),
""
);
// private WorkFlowUtil workFlowUtil;
}
//// @Autowired
//// private DexWorkFlowService dexWorkFlowService;
/**
//
* 处理单据word数据
// /**
*
// * 单独处理过时文件通知单数据
* @param documentVo
// */
*/
// public void processOutdatedDocNotify(DxDocumentVO documentVo) {
public
void
processData
(
DxDocumentVO
documentVo
)
{
// extDocService.getDocWord(documentVo, OutdatedDocNotifyUtils.class, new DxWfProcessInfoVO(), "");
String
subTypeName
=
documentVo
.
getSubTypeName
();
// }
//todo
//
// WfProcessInstVO DxWfProcessInstVO = workFlowUtil.getWfProcessInst(documentVo);
// /**
// DxWfProcessInfoVO wfProcessInfoVO = dexWorkFlowService.getProcessInstDetailById(DxWfProcessInstVO.getId());
// * 处理单据word数据
// switch (subTypeName) {
// *
// case Constants.INTERNAL_INTERFACE:
// * @param documentVo
// this.generateInterFaceWord(documentVo, new InterfaceInfoLinkVO(), wfProcessInfoVO);
// */
// break;
// public void processData(DxDocumentVO documentVo) {
// case Constants.CONTACTLIST:
// String subTypeName = documentVo.getSubTypeName();
// extDocService.getDocWord(documentVo, ContactListUtils.class, wfProcessInfoVO, "一");
// //todo
// break;
//// WfProcessInstVO DxWfProcessInstVO = workFlowUtil.getWfProcessInst(documentVo);
// case Constants.WORK_CONTACTLIST:
//// DxWfProcessInfoVO wfProcessInfoVO = dexWorkFlowService.getProcessInstDetailById(DxWfProcessInstVO.getId());
// extDocService.getDocWord(documentVo, WorkContactListUtils.class, wfProcessInfoVO, "");
//// switch (subTypeName) {
// break;
//// case Constants.INTERNAL_INTERFACE:
// case Constants.DESIGN_CHANGE:
//// this.generateInterFaceWord(documentVo, new InterfaceInfoLinkVO(), wfProcessInfoVO);
// extDocService.getDocWord(documentVo, DesignChangeUtils.class, wfProcessInfoVO, "");
//// break;
// break;
//// case Constants.CONTACTLIST:
// case Constants.DESIGN_APPLICATION:
//// extDocService.getDocWord(documentVo, ContactListUtils.class, wfProcessInfoVO, "一");
// extDocService.getDocWord(documentVo, DesignDocApplicatUtils.class, wfProcessInfoVO, "");
//// break;
// break;
//// case Constants.WORK_CONTACTLIST:
// case Constants.DESIGN_ENTER:
//// extDocService.getDocWord(documentVo, WorkContactListUtils.class, wfProcessInfoVO, "");
// extDocService.getDocWord(documentVo, DesignEnterUtils.class, wfProcessInfoVO, "");
//// break;
// break;
//// case Constants.DESIGN_CHANGE:
// case Constants.NCR:
//// extDocService.getDocWord(documentVo, DesignChangeUtils.class, wfProcessInfoVO, "");
// extDocService.getDocWord(documentVo, NCRUtils.class, wfProcessInfoVO, "");
//// break;
// break;
//// case Constants.DESIGN_APPLICATION:
// case Constants.DEN:
//// extDocService.getDocWord(documentVo, DesignDocApplicatUtils.class, wfProcessInfoVO, "");
// //根据模板生成两张不同澄清单
//// break;
// extDocService.getDocWord(documentVo, DENUtils.class, wfProcessInfoVO, "");
//// case Constants.DESIGN_ENTER:
// break;
//// 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
());
}
}
}
dcs-doc-expand-core/src/main/java/com/yonde/dcs/core/events/ValidateSecretListener.java
View file @
5caa6483
package
com
.
yonde
.
dcs
.
core
.
events
;
//package com.yonde.dcs.core.events;
//
//
import
com.yonde.dex.basedata.exception.DxBusinessException
;
//import com.yonde.dex.basedata.exception.DxBusinessException;
import
com.yonde.dex.context.common.vo.DxContextVO
;
//import com.yonde.dex.context.common.vo.DxContextVO;
import
com.yonde.dex.context.feign.ContextServiceFeign
;
//import com.yonde.dex.context.feign.ContextServiceFeign;
import
com.yonde.dex.dao.service.BaseService
;
//import com.yonde.dex.dao.service.BaseService;
import
com.yonde.dex.dao.service.listener.AbstractEventListener
;
//import com.yonde.dex.dao.service.listener.AbstractEventListener;
import
com.yonde.dex.dict.feign.DictDataFeignService
;
//import com.yonde.dex.dict.feign.DictDataFeignService;
import
com.yonde.dex.dict.service.vo.DictDataVO
;
//import com.yonde.dex.dict.service.vo.DictDataVO;
import
lombok.extern.slf4j.Slf4j
;
//import lombok.extern.slf4j.Slf4j;
import
org.apache.commons.collections4.CollectionUtils
;
//import org.apache.commons.collections4.CollectionUtils;
import
org.apache.commons.lang3.StringUtils
;
//import org.apache.commons.lang3.StringUtils;
import
org.springframework.beans.factory.annotation.Autowired
;
//import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.beans.factory.annotation.Qualifier
;
//import org.springframework.beans.factory.annotation.Qualifier;
import
org.springframework.stereotype.Service
;
//import org.springframework.stereotype.Service;
import
org.springframework.transaction.annotation.Transactional
;
//import org.springframework.transaction.annotation.Transactional;
//
import
java.util.List
;
//import java.util.List;
import
java.util.Set
;
//import java.util.Set;
import
java.util.stream.Collectors
;
//import java.util.stream.Collectors;
//
@Service
//@Service
@Slf4j
//@Slf4j
public
class
ValidateSecretListener
extends
AbstractEventListener
<
BaseService
.
DataChangeEvent
>
{
//public class ValidateSecretListener extends AbstractEventListener<BaseService.DataChangeEvent> {
@Autowired
// @Autowired
private
DictDataFeignService
dictDataService
;
// private DictDataFeignService dictDataService;
@Qualifier
(
"com.yonde.dex.context.feign.ContextProjectServiceFeign"
)
// @Qualifier("com.yonde.dex.context.feign.ContextProjectServiceFeign")
@Autowired
// @Autowired
//
private
ContextServiceFeign
contextServiceFeign
;
// private ContextServiceFeign contextServiceFeign;
//
@Override
// @Override
public
void
onAsynEvent
(
BaseService
.
DataChangeEvent
event
)
{
// 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);
// @Override
// checkResultStr = "收入合同密级不能高于项目密级!";
// 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 ExtSpendingContractVO) {
// checkResult = checkDxObjectVoSecret(dxObjectVo);
// checkResultStr = "支出合同密级不能高于项目密级!";
// }
// }
if
(
checkResult
)
{
//
checkResultStr
=
""
;
// @Transactional(rollbackFor = {Exception.class, Error.class})
}
// void extValidateSecret(Iterable<?> objects) {
return
checkResultStr
;
// 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);
* @return
// if (!StringUtils.isEmpty(checkResultStr)) {
*/
// throw new DxBusinessException("500", checkResultStr);
//todo
// }
private
Boolean
checkDxObjectVoSecret
(
DxContextVO
dxObjectVo
)
{
// }
// if (StringUtils.isBlank(dxObjectVo.getSecretCode())) {
//
//
// }
// }
//
// /**
// * 校验计划、收入合同、支出合同密级与项目的关系
// *
// * @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 true;
// }
// }
// DxContextVO dxContextVO = contextServiceFeign.get(dxObjectVo.getDxContextId());
// }
// return checkTargetSecret(dxContextVO.getSecretCode(), dxObjectVo.getSecretCode());
// return false;
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
;
}
}
dcs-doc-expand-core/src/main/java/com/yonde/dcs/core/service/impl/ExtAutoTaskServiceImpl.java
View file @
5caa6483
...
@@ -7,13 +7,13 @@ import cn.hutool.core.io.FileUtil;
...
@@ -7,13 +7,13 @@ import cn.hutool.core.io.FileUtil;
import
cn.hutool.extra.spring.SpringUtil
;
import
cn.hutool.extra.spring.SpringUtil
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.yonde.dcs.common.vo.*
;
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.NCRSCUtils
;
import
com.yonde.dcs.core.factory.TechnicalFileUtils
;
import
com.yonde.dcs.core.factory.TechnicalFileUtils
;
import
com.yonde.dcs.core.service.*
;
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.core.word.ImportWordService
;
import
com.yonde.dcs.document.common.entity.vo.DxDocumentVO
;
import
com.yonde.dcs.document.common.entity.vo.DxDocumentVO
;
import
com.yonde.dcs.document.core.service.DocumentService
;
import
com.yonde.dcs.document.core.service.DocumentService
;
...
@@ -27,10 +27,8 @@ import com.yonde.dcs.plan.feign.ExtPlanServiceFeign;
...
@@ -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.SearchItem
;
import
com.yonde.dex.basedata.data.search.SearchItems
;
import
com.yonde.dex.basedata.data.search.SearchItems
;
import
com.yonde.dex.basedata.data.search.SearchQueryCondition
;
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.DxPageImpl
;
import
com.yonde.dex.basedata.entity.data.OperatorType
;
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.exception.DxBusinessException
;
import
com.yonde.dex.basedata.utils.obj.DxEntityUtils
;
import
com.yonde.dex.basedata.utils.obj.DxEntityUtils
;
import
com.yonde.dex.dao.service.util.DxPageUtils
;
import
com.yonde.dex.dao.service.util.DxPageUtils
;
...
@@ -43,19 +41,16 @@ import com.yonde.dex.user.common.vo.DxUserInfoVO;
...
@@ -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.DxOrganizationFeign
;
import
com.yonde.dex.user.feign.DxUserInfoFeign
;
import
com.yonde.dex.user.feign.DxUserInfoFeign
;
import
com.yonde.dex.user.feign.SwitchUserService
;
import
com.yonde.dex.user.feign.SwitchUserService
;
import
com.yonde.dex.utils.common.utils.DxFileUtils
;
import
com.yonde.dex.wfc.common.vo.DxWfParticipantInfoVO
;
import
com.yonde.dex.wfc.common.vo.*
;
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.WfcProcessFeign
;
import
com.yonde.dex.wfc.feign.api.WfcTaskFeign
;
import
com.yonde.dex.wfc.feign.api.WfcTaskFeign
;
import
feign.form.ContentType
;
import
lombok.SneakyThrows
;
import
lombok.SneakyThrows
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.collections.MapUtils
;
import
org.apache.commons.lang3.ObjectUtils
;
import
org.apache.commons.lang3.ObjectUtils
;
import
org.apache.commons.lang3.StringUtils
;
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.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.beans.factory.annotation.Qualifier
;
...
@@ -66,7 +61,9 @@ import org.springframework.transaction.annotation.Transactional;
...
@@ -66,7 +61,9 @@ import org.springframework.transaction.annotation.Transactional;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.annotation.Resource
;
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.lang.reflect.Method
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
...
@@ -115,8 +112,8 @@ public class ExtAutoTaskServiceImpl implements ExtAutoTaskService {
...
@@ -115,8 +112,8 @@ public class ExtAutoTaskServiceImpl implements ExtAutoTaskService {
private
SwitchUserService
switchUserService
;
private
SwitchUserService
switchUserService
;
@Autowired
@Autowired
private
ExtInterfaceInfoLinkService
interfaceInfoLinkService
;
private
ExtInterfaceInfoLinkService
interfaceInfoLinkService
;
@Autowired
//
@Autowired
private
DocBeforeCreateEvent
docBeforeCreateEvent
;
//
private DocBeforeCreateEvent docBeforeCreateEvent;
@Autowired
@Autowired
private
FileManagerFeignService
fileManagerFeignService
;
private
FileManagerFeignService
fileManagerFeignService
;
@Autowired
@Autowired
...
@@ -135,8 +132,8 @@ public class ExtAutoTaskServiceImpl implements ExtAutoTaskService {
...
@@ -135,8 +132,8 @@ public class ExtAutoTaskServiceImpl implements ExtAutoTaskService {
private
TechnicalFileUtils
technicalFileUtils
;
private
TechnicalFileUtils
technicalFileUtils
;
@Autowired
@Autowired
private
WorkFlowUtil
workFlowUtil
;
private
WorkFlowUtil
workFlowUtil
;
@Autowired
//
@Autowired
private
ProcessDataUtils
processDataUtils
;
//
private ProcessDataUtils processDataUtils;
@Autowired
@Autowired
ExtApplicantService
extApplicantService
;
ExtApplicantService
extApplicantService
;
@Autowired
@Autowired
...
@@ -1026,8 +1023,8 @@ public class ExtAutoTaskServiceImpl implements ExtAutoTaskService {
...
@@ -1026,8 +1023,8 @@ public class ExtAutoTaskServiceImpl implements ExtAutoTaskService {
*/
*/
@Override
@Override
public
void
generateWordByAutoMethod
(
DxDocumentVO
documentVo
)
{
public
void
generateWordByAutoMethod
(
DxDocumentVO
documentVo
)
{
DxDocumentVO
dxDocumentVO
=
docBeforeCreateEvent
.
processCreateData
(
documentVo
);
//
DxDocumentVO dxDocumentVO = docBeforeCreateEvent.processCreateData(documentVo);
documentService
.
saveRecursion
(
dxDocumentVO
);
//
documentService.saveRecursion(dxDocumentVO);
}
}
/**
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment