Commit 3883847f authored by xuzhang's avatar xuzhang

[feat][DOC]代码迁移

parent 7049b1c1
package com.yonde.dcs.core.controller;
import cn.hutool.core.collection.CollectionUtil;
import com.yonde.dcs.core.constants.Constants;
import com.yonde.dcs.core.service.ExtAutoTaskService;
import com.yonde.dcs.core.service.ExtSendFormLinkService;
import com.yonde.dcs.core.util.ExtDocUtil;
import com.yonde.dcs.document.common.entity.vo.DxDocumentVO;
import com.yonde.dex.basedata.entity.api.ApiResult;
import com.yonde.dex.basedata.entity.vo.IdVO;
import com.yonde.dex.taskmonitor.api.interfaces.TaskMessagePusher;
import com.yonde.dex.wfc.common.vo.DxWfProcessSearchVO;
import com.yonde.dex.wfc.common.vo.DxWfProcessVO;
import com.yonde.dex.wfc.feign.api.WfcProcessFeign;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;
/**
* @program: service
* @description: 自动任务服务接口
* @author: dang wei
* @create: 2021-07-13 10:01
*/
@RestController
@RequestMapping("/task")
@Api(tags = "自动任务服务接口")
public class ExtAutoTaskController {
@Autowired
WfcProcessFeign wfcProcessFeign;
@Autowired
TaskMessagePusher taskMessagePusher;
@Autowired
private ExtAutoTaskService autoTaskService;
@Autowired
private ExtDocUtil extDocUtil;
@Autowired
private ExtSendFormLinkService sendFormLinkService;
@ApiOperation("电子签名")
@PostMapping({"/esign"})
public ApiResult esign(@RequestBody IdVO entity) {
DxWfProcessSearchVO dxWfProcessSearchVO = new DxWfProcessSearchVO();
dxWfProcessSearchVO.setPboClass(entity.getDxClassname());
dxWfProcessSearchVO.setPboId(entity.getId());
Page<DxWfProcessVO> dxWfProcessVODxPage = this.wfcProcessFeign.getProcessList(dxWfProcessSearchVO, 1, 1);
if (CollectionUtil.isNotEmpty(dxWfProcessVODxPage.getContent())) {
DxWfProcessVO dxWfProcessVO = dxWfProcessVODxPage.getContent().get(0);
String pboKey = "";
String signNode = "";
if (DxDocumentVO.class.getName().equals(entity.getDxClassname())) {
pboKey = "doc";
signNode = "Activity_0st1yf8";
}
// DxWfTaskContext dxWfTaskContext = new DxWfTaskContext(dxWfProcessVO.getBusinessKey(), dxWfProcessVO.getId(), dxWfProcessVO.getProcessDef().getId(), signNode, null, (Map) null);
//todo 在4.1中未找到WfcSignMessage 注释了71-74行
// WfcSignMessage wfcSignMessage = new WfcSignMessage(new HashMap());
// wfcSignMessage.setWfTaskContext(dxWfTaskContext);
// wfcSignMessage.setSignType(pboKey);
// TaskMessage taskMessage = (new WfcSignMessageBuilder()).newTasks(wfcSignMessage);
// this.taskMessagePusher.sendMessage(taskMessage);
this.taskMessagePusher.sendMessage(null);
return ApiResult.ok("重新发送电子签名请求成功!");
} else {
return ApiResult.ok("该对象未走签审流程!");
}
}
@ApiOperation(value = "更新PDF", notes = "更新PDF", httpMethod = "GET")
@GetMapping(value = "/updatePdf/{id}")
public ApiResult updatePdf(@PathVariable Long id) {
DxDocumentVO documentVO = extDocUtil.findDocObjFileLinks(id);
//重新生成设计图册签名
autoTaskService.generateQHTechDoc(documentVO, null);
if (Constants.OUTDATED_NOTIFY.equals(documentVO.getSubTypeName())) {
//特殊处理过时文件通知单
autoTaskService.generateOutdatedDocNotify(documentVO);
} else {
//重新生成单据签名
autoTaskService.generateDocWordSign(documentVO, null, "二");
}
return ApiResult.ok("更新成功!");
}
}
......@@ -12,6 +12,7 @@ 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;
......@@ -24,7 +25,9 @@ import java.util.stream.Collectors;
public class ValidateSecretListener extends AbstractEventListener<BaseService.DataChangeEvent> {
@Autowired
private DictDataFeignService dictDataService;
@Qualifier("com.yonde.dex.context.feign.ContextProjectServiceFeign")
@Autowired
private ContextServiceFeign contextServiceFeign;
@Override
......
package com.yonde.dcs.core.service;
import com.yonde.dcs.document.common.entity.vo.DxDocumentVO;
import com.yonde.dcs.plan.common.vo.ExtPlanVO;
import java.util.Map;
/**
* @program: inet-pdm-service
* @description: 自动任务服务接口
* @author: dang wei
* @create: 2021-09-27 09:41
*/
public interface ExtAutoTaskService {
/**
* 客户化文档修改状态
*
* @param documentVO
*/
void extChangeDocState(DxDocumentVO documentVO, String state);
/**
* 给选择的提资方人员发放通知
*
* @param documentVO
* @param userId
*/
void informativeUser(DxDocumentVO documentVO, String userId);
/**
* 设置提资审核
*
* @param taskParticipant
* @param processInstId
* @param key
* @param value
*/
void extSetProcessVariable(Map<String, Object> taskParticipant, String processInstId, String key, Object value);
/**
* 设置提资人变量
*
* @param processInstId
* @param varKey
* @param informativeUser
*/
void setInformativeUser(String processInstId, String varKey, String informativeUser);
/**
* 自动发送联系单
*/
void sendContractDoc(DxDocumentVO documentVO, String contractName);
/**
* 创建过时文件通知单
*
* @param documentVO
*/
void createDocNotify(DxDocumentVO documentVO);
/**
* 设置编制节点人员回显事件
*
* @param taskId
* @param documentVO
*/
void setProcessSelectionInfo(String taskId, DxDocumentVO documentVO);
/**
* 任务完成后更新pbo属性,驳回操作,设置编制节点人员回显
*
* @param taskId
* @param documentVO
*/
void getProcessSelectionInfo(String taskId, DxDocumentVO documentVO);
/**
* 计划生命周期事件
*
* @param extPlanVO
*/
void pressPlanInfo(ExtPlanVO extPlanVO) throws Exception;
/**
* 内部接口-生成提资信息word
*
* @param documentVO
*/
void generateInformationWord(DxDocumentVO documentVO);
/**
* 生成NCR审查单word
*/
void generateNcrReviewWord(DxDocumentVO documentVO, Map<String, Object> wfTaskContext);
/**
* 生成word签字
*
* @param documentVO
* @param wfTaskContext
* @param fileName 同室审核完生成签名附件为(附件1),签审流程走完后生成签名附件为(附件2),没有是为""。
*/
void generateDocWordSign(DxDocumentVO documentVO, Map<String, Object> wfTaskContext, String fileName);
/**
* 内部接口-保存内部接口信息的总体室、审核签审信息值
*/
void savedInterfaceWf(DxDocumentVO documentVO, Map<String, Object> wfTaskContext);
/**
* 自动任务-编制节点后生成word方法(自动任务修改方法)
*/
void generateWordByAutoMethod(DxDocumentVO documentVo);
/**
* 自动任务-校验图册下的图纸是否检入
*/
void checkLockerUtil(DxDocumentVO documentVo);
/**
* 自动任务-生成QH技术文件签审页
*/
void generateQHTechDoc(DxDocumentVO documentVO, Map<String, Object> wfTaskContext);
/**
* 结束流程实例
*
* @param iterationObject
*/
// TODO: 2024/7/31 DxIterationVO在4.1不存在
// void endProcess(DxIterationVO iterationObject);
/**
* 生成过时文件通知单word
*
* @param documentVO
*/
void generateOutdatedDocNotify(DxDocumentVO documentVO);
/**
* 已发布后修改状态已过时
*/
void changeOldDataState(DxDocumentVO documentVO);
}
package com.yonde.dcs.core.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.io.FileUtil;
import cn.hutool.extra.spring.SpringUtil;
import com.alibaba.fastjson.JSONObject;
import com.yonde.dcs.core.service.ExtAutoTaskService;
import com.yonde.dcs.plan.common.vo.ExtPlanDocLinkVO;
import com.yonde.dcs.plan.common.vo.ExtPlanVO;
import com.yonde.dcs.plan.feign.ExtDistributeRecordServiceFeign;
import com.yonde.dcs.plan.feign.ExtPlanDocLinkServiceFeign;
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.data.DxPageImpl;
import com.yonde.dex.basedata.entity.data.OperatorType;
import com.yonde.dex.basedata.exception.DxBusinessException;
import com.yonde.dex.basedata.utils.obj.DxEntityUtils;
import com.yonde.dex.dao.service.util.DxPageUtils;
import com.yonde.dex.dfs.feign.FileManagerFeignService;
import com.yonde.dex.dfs.objfilelink.service.ObjFileLinkService;
import com.yonde.dex.dfs.vo.ObjFileLinkVO;
import com.yonde.dex.dfs.vo.RepoFileVO;
import com.yonde.dex.user.common.vo.DxOrganizationVO;
import com.yonde.dex.user.common.vo.DxUserInfoVO;
import com.yonde.dex.user.feign.DxOrganizationFeign;
import com.yonde.dex.user.feign.DxUserInfoFeign;
import com.yonde.dex.user.feign.SwitchUserService;
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 lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.lang.reflect.Method;
import java.util.*;
/**
* @program: inet-pdm-service
* @description: 自动任务服务接口
* @author: dang wei
* @create: 2021-09-27 09:42
*/
@Service
@Slf4j
public class ExtAutoTaskServiceImpl implements ExtAutoTaskService {
@Qualifier("dxDocumentServiceImpl")
@Autowired
private DxDocumentService documentService;
@Autowired
private ExtObsoleteDocLinkService obsoleteDocLinkService;
@Autowired
private ExtComDocLinkService extComDocLinkService;
@Autowired
private ExtReviewDocComLinkService extReviewDocComLinkService;
@Autowired
private ExtDocService extDocService;
@Autowired
private ExtDistributeRecordServiceFeign distributeRecordService;
@Autowired
private WfcProcessFeign wfInstanceService;
@Autowired
private ExtInterfaceReplaceLinkService interfaceReplaceLinkService;
@Autowired
private ExtAtlasDrawingLinkService atlasDrawingLinkService;
@Autowired
private DxUserInfoFeign userService;
@Autowired
private DxOrganizationFeign dxOrganizationFeign;
@Resource
private ExtPlanDocLinkServiceFeign planDocLinkService;
@Autowired
private ExtPlanServiceFeign extPlanService;
@Autowired
private WfcTaskFeign taskService;
@Autowired
private SwitchUserService switchUserService;
@Autowired
private ExtInterfaceInfoLinkService interfaceInfoLinkService;
@Autowired
private DocBeforeCreateEvent docBeforeCreateEvent;
@Autowired
private FileManagerFeignService fileManagerFeignService;
@Autowired
private ObjFileLinkService objFileLinkService;
@Autowired
private WfcProcessFeign dexWorkFlowService;
@Autowired
private ExtDocUtil extDocUtil;
@Autowired
private ImportWordService importWordService;
//生成过时文件通知单编码
@Autowired
private ExtSerialNumberService serialNumberService;
@Autowired
private TechnicalFileUtils technicalFileUtils;
@Autowired
private WorkFlowUtil workFlowUtil;
@Autowired
private ProcessDataUtils processDataUtils;
/**
* 客制化文档修改状态
*
* @param documentVO
*/
@Override
public void extChangeDocState(DxDocumentVO documentVO, String state) {
if (StringUtils.containsIgnoreCase(state, "_")) {
state = state.split("_")[2];
}
//设计图册和安装图册
if (Constants.DESIGN_ATLAS.equals(documentVO.getSubTypeName()) || Constants.INSTALL_ATLAS.equals(documentVO.getSubTypeName())) {
List<ExtAtlasDrawingLinkVO> drawingLinks = this.recursionAtlasDoc(documentVO.getVersionId());
String docState = documentVO.getState();
String finalState = state;
drawingLinks.stream().forEach(item -> {
DxDocumentVO doc = new DxDocumentVO();
BeanUtils.copyProperties(item.getTarget(), doc);
if (Constants.PENDING_REVIEW.equals(doc.getState()) || docState.equals(doc.getState())) {
doc.setState(finalState);
//设置修改人和时间不变
doc.markModifyIdHold();
doc.markModifyTimeHold();
documentService.changeStatus(doc);
}
});
}
//判断接口单为审阅中设置全局状态为已打开
if (Constants.INTERNAL_INTERFACE.equals(documentVO.getSubTypeName())) {
if (Constants.REVIEWING.equals(state)) {
Map<String, Object> map = new HashMap<>();
//设置全局状态为打开
map.put(Constants.GLOBAL_STATE, Constants.OPENED);
documentVO.setDynamicAttrs(map);
documentVO = (DxDocumentVO) documentService.save(documentVO);
}
if (Constants.PBULISHED.equals(state)) {
List<ExtInterfaceReplaceLinkVO> replaceLinkVOS = this.searchSourceInterfaceReplaceLink(documentVO.getVersionId());
replaceLinkVOS.stream().forEach(replaceLinkVO -> {
DxDocumentVO target = replaceLinkVO.getTarget();
if (Constants.PBULISHED.equals(target.getState())) {
//是已发布的替换单
target.setState(Constants.OBSOLETE);
//设置修改人和时间不变
target.markModifyIdHold();
target.markModifyTimeHold();
DxDocumentVO dxDocumentVO = (DxDocumentVO) documentService.changeStatus(target);
//生成过时文件通知单(并置为已发布状态)
this.createDocNotify(dxDocumentVO);
}
});
}
}
// 需支持多条专家评审意见驱动一份文件升版;
// 需支持一条专家评审意见驱动多份文件升版;
// 需支持专家评审意见不驱动文件升版,仅记录专家评审意见;
if (Constants.PBULISHED.equals(state)) {
//判断是否评审会资料
if (Constants.METTING_MATERIALS.equals(documentVO.getTwoLevCategory())) {
//展开sourceExtReviewDocComLink
List<ExtReviewDocComLinkVO> reviewDocComLinkVOS = this.searchSourceExtReviewDocComLink(documentVO.getVersionId());
if (!CollectionUtils.isEmpty(reviewDocComLinkVOS)) {
reviewDocComLinkVOS.stream().forEach(reviewDocComLinkVO -> {
ExtReviewCommentVO commentVO = reviewDocComLinkVO.getTarget();
List<ExtComDocLinkVO> sourceExtComDocLink = commentVO.getExtComDocLinks();
if (!CollectionUtils.isEmpty(sourceExtComDocLink)) {
sourceExtComDocLink.stream().forEach(x -> {
ExtReviseVersionVO reviseVersionVO = new ExtReviseVersionVO();
reviseVersionVO.setPhaseState(x.getPhaseState());
reviseVersionVO.setChangeReason(x.getChangeReason());
reviseVersionVO.setCauseDescript(x.getCauseDescript());
//判断是否为升版的文件
DxDocumentVO latest = (DxDocumentVO) documentService.getLatest(x.getTarget().getId());
DxDocumentVO upgradeDoc;
if (Constants.PBULISHED.equals(latest.getState())) {
//需要升版
upgradeDoc = extDocService.reviseDocVersion(x.getTarget().getId(), reviseVersionVO);
} else {
upgradeDoc = latest;
}
//更新专家评审意见为升版对象
x.setTarget(upgradeDoc);
x.setTargetId(upgradeDoc.getVersionId());
extComDocLinkService.update(x);
});
}
});
}
}
//判断是否文档关联计划
ExtPlanDocLinkVO planDocLinkVO = this.searchExtPlanDocLink(documentVO.getMasterId());
if (!ObjectUtils.isEmpty(planDocLinkVO) && !ObjectUtils.isEmpty(planDocLinkVO.getSource())) {
//得到souceId获取计划,更新计划状态
ExtPlanVO source = planDocLinkVO.getSource();
source.setTaskState(Constants.COMPLETED);
// TODO: 2024/8/1 将extPlanService.saveOrUpdate改为update
extPlanService.update(source);
}
}
documentVO.setState(state);
//设置修改人和时间不变
documentVO.markModifyIdHold();
documentVO.markModifyTimeHold();
documentService.changeStatus(documentVO);
}
/**
* 通过文档的masterId查询计划关联关系
*
* @param masterId
* @return
*/
private ExtPlanDocLinkVO searchExtPlanDocLink(Long masterId) {
SearchQueryCondition condition = SearchQueryCondition.builder()
.openProp(SearchQueryCondition.builder().name("source").build())
.searchItems(SearchItems.builder().item(new SearchItem("targetId", SearchItem.Operator.EQ, masterId, null)).build()).build();
DxPageImpl<ExtPlanDocLinkVO> recursion = planDocLinkService.findRecursion(condition);
if (!CollectionUtils.isEmpty(recursion.getContent())) {
return DxPageUtils.getFirst(recursion);
}
return null;
}
/**
* 创建过时文件通知单对象
*
* @param documentVO
* @return
*/
@Override
public void createDocNotify(DxDocumentVO documentVO) {
//创建过时文件通知单对象
DxDocumentVO docNotify = new DxDocumentVO();
docNotify.setSubTypeName("OutdatedDocNotify");
docNotify.setName(documentVO.getName() + "过时文件通知单");
Map<String, Object> map = new HashMap<>();
map.put("obsoletedDocNo", documentVO.getNumber());
map.put("obsoleteDocVer", documentVO.getDisplayVersion());
map.put("obsoleteDocName", documentVO.getName());
map.put("pages", 1);
//String generateEncode = serialNumberService.generateEncode(documentVO);
//docNotify.setNumber(generateEncode);
docNotify.setDynamicAttrs(map);
DxDocumentVO save = (DxDocumentVO) documentService.saveRecursion(docNotify);
save.setState(Constants.PBULISHED);
DxDocumentVO dxDocumentVO = (DxDocumentVO) documentService.changeStatus(save);
ExtObsoleteDocLinkVO linkVO = new ExtObsoleteDocLinkVO();
linkVO.setSource(documentVO);
linkVO.setTarget(dxDocumentVO);
//过时文件通知单关联当前文档最新版本
obsoleteDocLinkService.save(linkVO);
}
/**
* 深度展开查询接口替换单
*
* @param versionId
* @return
*/
private List<ExtInterfaceReplaceLinkVO> searchSourceInterfaceReplaceLink(Long versionId) {
SearchQueryCondition condition = SearchQueryCondition.builder()
.openProp(SearchQueryCondition.builder().name("target").build())
.searchItems(SearchItems.builder()
.item(new SearchItem("sourceId", SearchItem.Operator.EQ, versionId, null)).build()).build();
DxPageImpl recursion = interfaceReplaceLinkService.findRecursion(condition);
if (!ObjectUtils.isEmpty(recursion)) {
return recursion.getContent();
}
return null;
}
/**
* 深度展开查询评审文件专家意见关联实体
*
* @param versionId
* @return
*/
private List<ExtReviewDocComLinkVO> searchSourceExtReviewDocComLink(Long versionId) {
SearchQueryCondition condition = SearchQueryCondition.builder()
.openProp(SearchQueryCondition.builder().name("target")
.openProp(SearchQueryCondition.builder().name("sourceExtComDocLink")
.openProp(SearchQueryCondition.builder().name("target").build())
.build()).build())
.searchItems(SearchItems.builder()
.item(new SearchItem("sourceId", SearchItem.Operator.EQ, versionId, null)).build()).build();
DxPageImpl recursion = extReviewDocComLinkService.findRecursion(condition);
if (!ObjectUtils.isEmpty(recursion)) {
return recursion.getContent();
}
return null;
}
/**
* 给选择的提资方人员发放通知
* getUserOrg
*
* @param documentVO
* @param userId
*/
@Override
public void informativeUser(DxDocumentVO documentVO, String userId) {
//userId格式为 组织id+用户id
if (StringUtils.isNotEmpty(userId)) {
String[] splits = userId.split(",");
List<String> userIdList = new ArrayList<>();
Arrays.stream(splits).forEach(item -> {
String[] split = item.split("-");
String s = null;
if (split.length == 1) {
s = split[0];
} else {
s = split[1];
}
userIdList.add(s);
});
//接口申请单业务
if (Constants.INTERNAL_INTERFACE.equals(documentVO.getSubTypeName())) {
userIdList.stream().forEach(x -> {
this.generateDistributeRecord(documentVO, x, Constants.DistributeType_Paper, Constants.BoTitle + "-" + documentVO.getName(), "002");
});
}
// 设计输入资料表(补充设计资料)
if (Constants.DESIGN_ENTER.equals(documentVO.getSubTypeName())) {
userIdList.stream().forEach(x -> {
this.generateDistributeRecord(documentVO, x, Constants.DistributeType_Paper, Constants.BZSJSR + "-" + documentVO.getName(), "002");
});
}
}
}
/**
* 生成分发记录对象方法
*
* @param documentVO
* @param userId
* @param code
*/
private void generateDistributeRecord(DxDocumentVO documentVO, String userId, String distributeType, String boTitle, String code) {
List<ExtDisReocredLinkVO> list = new ArrayList<>();
//创建分发记录对象
ExtDistributeRecordVO recordVO = new ExtDistributeRecordVO();
//分发类型
recordVO.setDistributeType(distributeType);
//名称
recordVO.setBoTitle(boTitle);
//分发时间
recordVO.setDistributTime(new Date());
//获取分发单位
DxOrganizationVO organizationVOS = dxOrganizationFeign.findOrgByUser(documentVO.getCreatorId());
if (null!=organizationVOS) {
//分发单位
recordVO.setDistributDepart(null);
} else {
//分发单位
recordVO.setDistributDepart(organizationVOS.getName());
}
//发送者
recordVO.setSenderId(documentVO.getCreatorId());
//接收者
recordVO.setHandlerId(Long.valueOf(userId));
//接收时间
recordVO.setReceiveTime(new Date());
DxOrganizationVO orgReceiver = dxOrganizationFeign.findOrgByUser(Long.valueOf(userId));
if (null!=organizationVOS) {
//接收单位
recordVO.setReceiver(null);
} else {
//接收单位
recordVO.setReceiver(orgReceiver.getName());
}
//是否需回复
recordVO.setReplyDistribute("是");
ExtDisReocredLinkVO disReocredLinkVO = new ExtDisReocredLinkVO();
//disReocredLinkVO.setTarget(documentVO);
disReocredLinkVO.setTargetId(documentVO.getId());
disReocredLinkVO.setTargetIdType(DxEntityUtils.getModelName(DxDocumentVO.class));
disReocredLinkVO.setOperator(OperatorType.ADD);
list.add(disReocredLinkVO);
recordVO.setSourceDisReocredLink(list);
recordVO.setOperator(OperatorType.ADD);
distributeRecordService.saveRecursion(recordVO);
}
/**
* 自动发送联系单
*
* @param documentVO
*/
@Override
public void sendContractDoc(DxDocumentVO documentVO, String contractName) {
List<DxOrganizationVO> userRefByOrg = dxOrganizationFeign.findAllChildOrg(1626768664052L,true);
if (CollectionUtils.isNotEmpty(userRefByOrg)){
List<DxUserInfoVO> dxUserInfos = userRefByOrg.get(0).getDxUserInfos();
dxUserInfos.stream().forEach(item -> {
//获取总体室技术文档管理员组的所有用户id
generateDistributeRecord(documentVO, item.getUserId().toString(), Constants.DistributeType_Doc, contractName + "-" + documentVO.getName(), "003");
});
}
}
/**
* 设置提资审核
*
* @param
* @param
*/
@Override
public void extSetProcessVariable(Map<String, Object> taskParticipant, String processInstId, String key, Object value) {
if (!ObjectUtils.isEmpty(value) && value instanceof String) {
if (!org.springframework.util.StringUtils.isEmpty(taskParticipant.get("wf_act_TeamRole_FundingReview_userList"))) {
//获取参与者人员
List users = (List) taskParticipant.get("wf_act_TeamRole_FundingReview_userList");
//通过流程id查询
if (StringUtils.isNoneBlank(processInstId)) {
Map<String, Object> varMap = new HashMap(1);
String join = StringUtils.join(value, ",", users.get(0));
varMap.put(key, join);
this.wfInstanceService.setProcessVariables(processInstId, varMap);
}
}
} else {
if (!org.springframework.util.StringUtils.isEmpty(taskParticipant.get("wf_act_TeamRole_FundingReview_userList"))) {
//获取参与者人员
List users = (List) taskParticipant.get("wf_act_TeamRole_FundingReview_userList");
//通过流程id查询
if (StringUtils.isNoneBlank(processInstId)) {
Map<String, Object> varMap = new HashMap(1);
String join = StringUtils.join(users.get(0));
varMap.put(key, join);
this.wfInstanceService.setProcessVariables(processInstId, varMap);
}
}
}
}
/**
* 设置提资人变量
*
* @param processInstId
* @param varKey
* @param informativeUser
*/
@Override
public void setInformativeUser(String processInstId, String varKey, String informativeUser) {
String[] infoUsers = informativeUser.split(",");
StringJoiner joiner = new StringJoiner(",");
Arrays.stream(infoUsers).forEach(item -> {
joiner.add(item.substring(item.indexOf("-") + 1));
});
Map<String, Object> varMap = new HashMap(1);
varMap.put(varKey, joiner.toString());
this.wfInstanceService.setProcessVariables(processInstId, varMap);
}
/**
* 通过id查询图纸
*
* @param id
*/
private List<ExtAtlasDrawingLinkVO> recursionAtlasDoc(Long id) {
SearchQueryCondition condition = SearchQueryCondition.builder()
.openProp(SearchQueryCondition.builder().name("target")
.openProp(SearchQueryCondition.builder().name("objFileLinks").build()).build())
.searchItems(SearchItems.builder()
.item(new SearchItem("sourceId", SearchItem.Operator.EQ, id, null)).build()).build();
DxPageImpl recursion = atlasDrawingLinkService.findRecursion(condition);
if (!ObjectUtils.isEmpty(recursion)) {
return recursion.getContent();
}
return null;
}
/**
* 设置编制节点人员回显
*
* @param taskId
* @param documentVO
*/
@Override
public void setProcessSelectionInfo(String taskId, DxDocumentVO documentVO) {
Map<String, Object> dynamicAttrs = documentVO.getDynamicAttrs();
Map<String, Object> taskParticipant = new HashMap<>();
//审核者
taskParticipant.put("wf_act_TeamRole_review_userList", Objects.isNull(dynamicAttrs.get("review")) ? new Long[]{} : Convert.toLongArray(dynamicAttrs.get("review").toString().split(",")));
taskParticipant.put("wf_act_TeamRole_Approver_userList", Objects.isNull(dynamicAttrs.get("approver")) ? new String[]{} : Convert.toLongArray(dynamicAttrs.get("approver").toString().split(",")));
taskParticipant.put("wf_act_TeamRole_approve_userList", Objects.isNull(dynamicAttrs.get("verifier")) ? new String[]{} : Convert.toLongArray(dynamicAttrs.get("verifier").toString().split(",")));
Map<String, Object> taskMap = new HashMap<>();
taskMap.put("participantList",taskParticipant);
taskMap.put("routeSelect","pass");
this.taskService.setTaskVars(taskId, taskMap);
}
/**
* 任务完成后更新pbo属性,驳回操作,设置编制节点人员回显
* 驳回时更新编制节点人员回显事件
*
* @param taskId
* @param
*/
@Override
public void getProcessSelectionInfo(String taskId, DxDocumentVO documentVO) {
// TODO: 2024/7/31 4.1 taskService.getTaskSelectionInfo(taskId)此方法不存在
List<DxWfParticipantInfoVO> processTeamParticipantList = dexWorkFlowService.getProcessTeamParticipantList(taskId);
// WfTaskSelectionVo taskSelectionInfo = this.taskService.getTaskSelectionInfo(taskId);
// Map<String, Object> participantList = taskSelectionInfo.getParticipantList();
// Long[] review = (Long[]) participantList.get("wf_act_TeamRole_review_userList");
// Long[] approver = (Long[]) participantList.get("wf_act_TeamRole_Approver_userList");
// Long[] verifier = (Long[]) participantList.get("wf_act_TeamRole_approve_userList");
// //更新pbo属性
// Map<String, Object> dynamicAttrs = documentVO.getDynamicAttrs();
// dynamicAttrs.put("review", review.toString());
// dynamicAttrs.put("approver", approver.toString());
// dynamicAttrs.put("verifier", verifier.toString()·);
// documentVO.setOperator(OperatorType.MODIFY);
// documentService.saveRecursion(documentVO);
}
/**
* 计划生命周期事件
*
* @param extPlanVO
*/
@Override
public void pressPlanInfo(ExtPlanVO extPlanVO) throws Exception {
try {
String userAccount = extPlanVO.getPlanExecutor();
switchUserService.switchUserByAccount(userAccount);
this.createPlanDocInfo(extPlanVO);
} catch (Exception e) {
throw new DxBusinessException("-1", e.getMessage());
} finally {
switchUserService.close();
}
}
/**
* 创建计划交付文件
*
* @param extPlanVO
*/
private void createPlanDocInfo(ExtPlanVO extPlanVO) {
if ("交付文件类".equals(extPlanVO.getFeedbackType())) {
//按照文件分类启动工作流
DxDocumentVO doc = new DxDocumentVO();
doc.setNumber(extPlanVO.getFileNumber());
doc.setName(extPlanVO.getFileName());
// TODO: 2024/7/31 4.1 setProjectCode此字段不存在
// doc.setProjectCode(extPlanVO.getProjectCode());
Map<String, Object> map = new HashMap<>();
map.put("fileNumber", extPlanVO.getFileCode());
map.put("review", org.springframework.util.StringUtils.isEmpty(this.searchUserId(extPlanVO.getReview())) ? "" : this.searchUserId(extPlanVO.getReview()));
map.put("approver", org.springframework.util.StringUtils.isEmpty(this.searchUserId(extPlanVO.getApprover())) ? "" : this.searchUserId(extPlanVO.getApprover()));
map.put("verifier", org.springframework.util.StringUtils.isEmpty(this.searchUserId(extPlanVO.getVerifier())) ? "" : this.searchUserId(extPlanVO.getVerifier()));
map.put("code", extPlanVO.getSystemCode());
map.put("fileCode", extPlanVO.getFileCode());
doc.setDynamicAttrs(map);
doc.setState(extPlanVO.getPhaseState());
//查询文档分类
// TODO: 2024/8/1 extPlanService.searchFileT这个方法不存在
// this.extPlanService.searchFileType(extPlanVO.getFileType(), doc);
doc.markCreatorIdHold();
doc.markModifyIdHold();
//设置文档创建者
doc.setCreatorId(this.searchUserId(extPlanVO.getPlanExecutor()));
doc.setModifierId(this.searchUserId(extPlanVO.getPlanExecutor()));
DxDocumentVO dxDocumentVO = (DxDocumentVO) documentService.saveRecursion(doc);
//绑定计划和文档的link
ExtPlanDocLinkVO planDocLinkVO = new ExtPlanDocLinkVO();
planDocLinkVO.setSource(extPlanVO);
// TODO: 2024/8/1 DxDocumentVO参数类型不匹对
// planDocLinkVO.setTarget(dxDocumentVO);
planDocLinkService.save(planDocLinkVO);
}
if ("计划反馈类".equals(extPlanVO.getFeedbackType())) {
//向计划执行人分发通知
// TODO: 2024/8/1 extPlanService.generatePlanDistributeRecord方法不存在
// this.extPlanService.generatePlanDistributeRecord(extPlanVO);
}
}
public Long searchUserId(String userAccount) {
DxUserInfoVO userInfoVO = new DxUserInfoVO();
userInfoVO.setUserAccount(userAccount);
List<Long> userIds = userService.getUserIdsByCondition(userInfoVO);
if (CollectionUtils.isEmpty(userIds)) {
return userIds.get(0);
}
return null;
}
/**
* 生成提资信息word
*
* @param documentVO
*/
@Override
public void generateInformationWord(DxDocumentVO documentVO) {
DxDocumentVO docObjFile = extDocUtil.findDocObjFileLinks(documentVO.getId());
//合并后word存放路径
String dirPath = Constants.MERGER_FILE_ABSOLUTE_PATH + documentVO.getSubTypeName() + "\\" + documentVO.getNumber() + "\\" + Constants.MERGER_TARGET + "\\";
String filePath = Constants.JD_BEFORE_MERGER_PATH + documentVO.getSubTypeName() + "/" + documentVO.getNumber() + "/" + Constants.MERGER_SOURCE;
String fileInputName = Constants.BEFORE_MERGER_PATH + documentVO.getSubTypeName() + "/" + documentVO.getNumber() + "/" + Constants.MERGER_TARGET + "/" + Constants.MERGER_FILE_NAME;
List<ExtInterfaceInfoLinkVO> interfaceInfoLinkVOS = this.recursionInterfaceInfoLinks(documentVO.getVersionId());
// TODO: 2024/8/1 getWfProcessInst返回属性不匹对
// WfProcessInstVO wfProcessInstVO = workFlowUtil.getWfProcessInst(documentVO);
// DxWfProcessVO wfProcessInfoVO = dexWorkFlowService.getProcessDetail(wfProcessInstVO.getId());
if (!CollectionUtils.isEmpty(interfaceInfoLinkVOS)) {
//1、先根据提资记录生成多个文档
interfaceInfoLinkVOS.stream().forEach(item -> {
// TODO: 2024/8/1 generateAutoInterFaceWord入参不匹对
// docBeforeCreateEvent.generateAutoInterFaceWord(docObjFile, item, wfProcessInfoVO);
});
try {
//2、合并生成好的文档
//生成word的路径为:D:\InetService\resource\template\words\新文档的subTypeName\新文档的number\target\mergeDoc.doc
FileUtil.mkdir(dirPath);
//合并pdf
FileUtils.mergePdfFile(filePath, dirPath + Constants.MERGER_PDF_FILE_NAME);
if (!ObjectUtils.isEmpty(docObjFile)) {
//上传到附件
extDocService.extractedAttachFile(docObjFile, new FileInputStream(dirPath + Constants.MERGER_PDF_FILE_NAME), "", Constants.ATTACH_FILE);
} else {
log.error("上传文档错误:通过id查询文档附件为空!");
}
//删除生成后的临时文件
FileUtils.deleteDirectory(Constants.MERGER_FILE_ABSOLUTE_PATH + documentVO.getSubTypeName() + "\\" + documentVO.getNumber());
} catch (Exception e) {
log.error("合并生成文档错误:" + e.getMessage());
}
}
//保存附件
documentService.saveRecursion(docObjFile);
}
/**
* 自动任务上传文件
*
* @param documentVo
* @param inputStreamDoc
* @throws Exception
*/
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void operateFile(DxDocumentVO documentVo, InputStream inputStreamDoc) throws Exception {
//上传文件到文件服务器
MultipartFile multipartFile = new MockMultipartFile("file", documentVo.getName() + ".doc",
Constants.CONTENT_TYPE_DOC, inputStreamDoc);
RepoFileVO field = fileManagerFeignService.uploadFile(multipartFile, Long.valueOf(Constants.BUCKET_NAME));
if (field == null) {
log.error("文件上传失败!");
} else {
log.info("文件上传成功:" + field);
}
//根据docId查询文件对象
RepoFileVO fileVO = fileManagerFeignService.findFileInfoById(field.getId());
//删除已有的主内容
/* if (CollectionUtil.isNotEmpty(documentVo.getObjFileLinks())) {
for (ObjFileLinkVO item : documentVo.getObjFileLinks()) {
if (Constants.MASTER_FILE.equals(item.getContentType())) {
objFileLinkService.delete(item.getId());
}
}
}*/
//更新文件到objFileLinks
// addMasterFile(documentVo, fileVO, Constants.MASTER_FILE);
//将pdf上传到附件中
this.operateAttachFile(documentVo);
}
public void operateAttachFile(DxDocumentVO dxDocumentVo) {
DxDocumentVO dxDocumentVoWithFiles = extDocUtil.getDxDocumentVoWithFiles(dxDocumentVo.getId());
//获取主内容pdf
RepoFileVO fileVO = extDocUtil.getPrimaryFile(dxDocumentVoWithFiles);
if (CollectionUtil.isNotEmpty(dxDocumentVoWithFiles.getObjFileLinks())) {
for (ObjFileLinkVO item : dxDocumentVoWithFiles.getObjFileLinks()) {
if (Constants.ATTACH_FILE.equals(item.getContentType()) && item.getTarget().getOriginalFileName().equals(fileVO.getOriginalFileName())) {
objFileLinkService.delete(item.getId());
}
}
}
//将pdf挂载到附件中
this.addMasterFile(dxDocumentVo, fileVO, Constants.ATTACH_FILE);
}
/**
* 更新文件到objFileLinks
*
* @param documentVo
* @param fileVO
*/
public void addMasterFile(DxDocumentVO documentVo, RepoFileVO fileVO, String fileType) {
ObjFileLinkVO objFileLinkVo = new ObjFileLinkVO();
objFileLinkVo.setTarget(fileVO);
objFileLinkVo.setSource(documentVo);
objFileLinkVo.setOperator(OperatorType.ADD);
objFileLinkVo.setContentType(fileType);
objFileLinkService.save(objFileLinkVo);
}
/**
* 通过versionId查询提资记录Link
*
* @param id
*/
private List<ExtInterfaceInfoLinkVO> recursionInterfaceInfoLinks(Long id) {
SearchQueryCondition condition = SearchQueryCondition.builder()
.openProp(SearchQueryCondition.builder().name("target")
.openProp(SearchQueryCondition.builder().name("targetInterfaceInfoLink").build())
.openProp(SearchQueryCondition.builder().name("objFileLinks")
.openProp(SearchQueryCondition.builder().name("target").build()).build()).build())
.searchItems(SearchItems.builder()
.item(new SearchItem("sourceId", SearchItem.Operator.EQ, id, null)).build()).build();
DxPageImpl recursion = interfaceInfoLinkService.findRecursion(condition);
if (!ObjectUtils.isEmpty(recursion)) {
return recursion.getContent();
}
return null;
}
/**
* 自动任务生成NCR审查单
*
* @param documentVo
* @param wfTaskContext
*/
@Override
public void generateNcrReviewWord(DxDocumentVO documentVo, Map<String, Object> wfTaskContext) {
DxDocumentVO documentVO = extDocUtil.findDocObjFileLinks(documentVo.getId());
try {
String templatePath = Constants.MTEMPLATE_ABSOLUTE_PATH;
String templateName = "NCRReview.docx";
String outDirPath = Constants.MERGER_FILE_ABSOLUTE_PATH + "\\" + documentVO.getSubTypeName() + "\\" + documentVO.getNumber() + "\\" + Constants.MERGER_SOURCE + "\\";
String outFilePath = Constants.MERGER_FILE_ABSOLUTE_PATH + "\\" + documentVO.getSubTypeName() + "\\" + documentVO.getNumber() + "\\" + Constants.MERGER_TARGET + "\\";
List<DxWfProcessTaskVO> taskList = this.getTaskList(wfTaskContext);
//创建生成word的文件夹
FileUtil.mkdir(outDirPath);
FileUtil.mkdir(outFilePath);
if (!CollectionUtils.isEmpty(taskList)) {
JSONObject jsonObject = new JSONObject();
for (DxWfProcessTaskVO wf : taskList) {
Class<?> clazz = Class.forName("com.inet.pdm.factory.NCRSCUtils");
Method settingDataMethod = clazz.getMethod("settingData", DxDocumentVO.class, DxWfProcessTaskVO.class, JSONObject.class);
jsonObject = (JSONObject) settingDataMethod.invoke(SpringUtil.getBean(NCRSCUtils.class), documentVO, wf, jsonObject);
}
//生成审查单
importWordService.getWordAllTable(jsonObject, templatePath + templateName, outFilePath + "ncrReview.docx");
log.info("生成审查单word文件内容结束====");
//获取文件夹的所有文件--绝对路径
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文件目录内容为空====");
} else {
String pdfFilePath = fileList.stream().filter(item -> item.endsWith(".pdf")).findFirst().get();
FileInputStream inputStreamDoc = new FileInputStream(pdfFilePath);
//上传到附件中
this.uploadAttachFile(documentVO, inputStreamDoc, "NCR审查单");
//将签名后的pdf上传到附件中
log.info("生成审查单----获取生成的word文件内容结束====");
}
//删除生成后的临时文件夹
FileUtils.deleteDirectory(Constants.MERGER_FILE_ABSOLUTE_PATH + documentVO.getSubTypeName() + "\\" + documentVO.getNumber() + "\\");
}
} catch (Exception e) {
log.error("自动任务生成NCR审查单的word错误:" + e.getMessage());
}
}
/**
* 获取任务集合
*
* @param wfTaskContext
* @return
*/
private List<DxWfProcessTaskVO> getTaskList(Map<String, Object> wfTaskContext) {
DxWfTaskContext context = (DxWfTaskContext) wfTaskContext.get("context");
String processId = context.getProcessId();
// TODO: 2024/7/31 4.1此方法不存在 getProcessInstDetailById(processId)
// DxWfProcessInfoVO wfProcessInfoVO = dexWorkFlowService.getProcessInstDetailById(processId);
// List<WfTaskDefinitionVO> activities = wfProcessInfoVO.getActivityInfo();
// List<DxWfProcessTaskVO> taskVOList = new ArrayList<>();
// for (WfTaskDefinitionVO wf : activities) {
// //判断节点上是否存在
// if (SignConstants.NCRSignTaskList.contains(wf.getTaskName())) {
// List<WfProcessTaskVO> taskList = wf.getTaskList();
// for (WfProcessTaskVO wfPro : taskList) {
// if ("通过".equals(wfPro.getResult())) {
// taskVOList.add(wfPro);
// }
// }
// }
// }
// return taskVOList;
return null;
}
/**
* 上传附件
*
* @param documentVO
* @param inputStreamDoc
*/
private void uploadAttachFile(DxDocumentVO documentVO, InputStream inputStreamDoc, String fileName) {
try {
//上传文件到文件服务器
MultipartFile multipartFile = null;
if (StringUtils.isNotBlank(fileName)) {
multipartFile = new MockMultipartFile("file", fileName + ".pdf",
Constants.CONTENT_TYPE_DOC, inputStreamDoc);
} else {
multipartFile = new MockMultipartFile("file", documentVO.getName() + ".pdf",
Constants.CONTENT_TYPE_DOC, inputStreamDoc);
}
RepoFileVO field = fileManagerFeignService.uploadFile(multipartFile, Long.valueOf(Constants.BUCKET_NAME));
if (field == null) {
log.error("文件上传失败!");
} else {
log.info("文件上传成功:" + field);
}
//根据docId查询文件对象
RepoFileVO fileVO = fileManagerFeignService.findFileInfoById(field.getId());
//上传到附件
this.addMasterFile(documentVO, fileVO, Constants.ATTACH_FILE);
} catch (Exception e) {
log.error("文件上传失败!");
}
}
@Override
public void generateDocWordSign(DxDocumentVO documentVo, Map<String, Object> wfTaskContext, String fileName) {
//深度查询展开ObjLink
DxDocumentVO documentVO = extDocUtil.findDocObjFileLinks(documentVo.getId());
log.info("自动任务======生成word签名开始");
// TODO: 2024/7/31 4.1返回对象不匹对 WfProcessInstVO
// WfProcessInstVO wfProcessInstVO = workFlowUtil.getWfProcessInst(documentVO);
// TODO: 2024/7/31 4.1此方法不存在 getProcessInstDetailById(processId)
// WfProcessInfoVO wfProcessInfoVO = dexWorkFlowService.getProcessInstDetailById(wfProcessInstVO.getId());
String subTypeName = documentVO.getSubTypeName();
log.info("自动任务======生成word签名进行中,文档SubTypeName:{}", subTypeName);
// switch (subTypeName) {
// case Constants.CONTACTLIST:
// extDocService.generateDocWordSign(documentVO, ContactListUtils.class, wfProcessInfoVO, fileName);
// break;
// case Constants.WORK_CONTACTLIST:
// extDocService.generateDocWordSign(documentVO, WorkContactListUtils.class, wfProcessInfoVO, "");
// break;
// case Constants.DESIGN_ENTER:
// extDocService.generateDocWordSign(documentVO, DesignEnterUtils.class, wfProcessInfoVO, "");
// break;
// case Constants.NCR:
// extDocService.generateDocWordSign(documentVO, NCRUtils.class, wfProcessInfoVO, "");
// break;
// case Constants.INTERNAL_INTERFACE:
// this.generateInterfaceSignWord(documentVO, wfProcessInfoVO);
// break;
// case Constants.DESIGN_CHANGE:
// extDocService.generateDocWordSign(documentVO, DesignChangeUtils.class, wfProcessInfoVO, "");
// break;
// case Constants.DESIGN_APPLICATION:
// extDocService.generateDocWordSign(documentVO, DesignDocApplicatUtils.class, wfProcessInfoVO, "");
// break;
// case Constants.DEN:
// extDocService.generateDocWordSign(documentVO, DENUtils.class, wfProcessInfoVO, "");
// break;
// }
//保存附件
documentService.saveRecursion(documentVO);
log.info("自动任务======生成word签名完成");
}
/**
* 内部接口-保存内部接口信息的总体室、审核签审信息值
*
* @param documentVO
* @param wfTaskContext
*/
@Override
public void savedInterfaceWf(DxDocumentVO documentVO, Map<String, Object> wfTaskContext) {
DxWfTaskContext context = (DxWfTaskContext) wfTaskContext.get("context");
String processId = context.getProcessId();
// TODO: 2024/7/31 4.1此方法不存在 getProcessInstDetailById(processId)
// DxWfProcessInfoVO wfProcessInfoVO = dexWorkFlowService.getProcessInstDetailById(processId);
Map<String, Object> dynamicAttrs = documentVO.getDynamicAttrs();
// List<WfTaskDefinitionVO> activities = wfProcessInfoVO.getActivityInfo();
// if (!org.springframework.util.CollectionUtils.isEmpty(activities)) {
// //申请审核
// dynamicAttrs.replace("appReviewer", this.getUserName(activities, SignConstants.SIGN_KEY_SQSH));
// dynamicAttrs.replace("appReviewerDate", extDocService.getEndDate(activities, SignConstants.SIGN_KEY_SQSH));
// //总体室签审
// dynamicAttrs.replace("ztsSign", this.getUserName(activities, SignConstants.SIGN_KEY_ZTSQS));
// dynamicAttrs.replace("ztsSignDate", extDocService.getEndDate(activities, SignConstants.SIGN_KEY_ZTSQS));
// }
documentVO.setOperator(OperatorType.MODIFY);
DxDocumentVO dxDocumentVO = (DxDocumentVO) documentService.saveRecursion(documentVO);
}
// public String getUserName(List<WfTaskDefinitionVO> activities, String activityName) {
// for (WfTaskDefinitionVO wf : activities) {
// if (wf.getTaskName().equals(activityName)) {
// return getActivityUserName(wf);
// }
// }
// return "";
// }
/**
* 获取用户名称及用户id
*/
// TODO: 2024/7/31 4.1 这个类不存在WfTaskDefinitionVO
// public String getActivityUserName(WfTaskDefinitionVO activity) {
// String str = "";
// List<DxWfProcessTaskVO> taskList = activity.getTaskList();
// for (DxWfProcessTaskVO wf : taskList) {
// if (wf.getState().equals(TaskStateEnum.COMPLETE.name()) && (SignConstants.WfResultList.contains(wf.getResult()))) {
// //获取用户名称和id
// String userName = wf.getAssigneeName();
// String userId = wf.getAssignee();
// DxUserInfoVO userVO = userService.get(Long.parseLong(userId));
// str = userVO.getUserAccount();
// }
// }
// return str;
// }
/**
* 生成内部接口签名word
*
* @param documentVO
*/
// TODO: 2024/7/31 4.1 这个类不存在WfProcessInfoVO
// public void generateInterfaceSignWord(DxDocumentVO documentVO, WfProcessInfoVO wfProcessInfoVO) {
// //合并后word存放路径
// String dirPath = Constants.MERGER_FILE_ABSOLUTE_PATH + documentVO.getSubTypeName() + "\\" + documentVO.getNumber() + "\\" + Constants.MERGER_SIGN + "\\";
// String filePath = Constants.JD_BEFORE_MERGER_PATH + documentVO.getSubTypeName() + "/" + documentVO.getNumber() + "/" + Constants.MERGER_SOURCE;
// String fileInputName = dirPath + Constants.MERGER_PDF_FILE_NAME;
// List<ExtInterfaceInfoLinkVO> interfaceInfoLinkVOS = this.recursionInterfaceInfoLinks(documentVO.getVersionId());
// if (!CollectionUtils.isEmpty(interfaceInfoLinkVOS)) {
// //1、先根据提资记录生成多个文档(不需要上传到附件和主内容中)
// interfaceInfoLinkVOS.stream().forEach(item -> {
// docBeforeCreateEvent.generateAutoInterFaceWord(documentVO, item, wfProcessInfoVO);
// });
// try {
// //2、合并生成好的文档
// //生成word的路径为:D:\InetService\resource\template\words\新文档的subTypeName\新文档的number\target\mergeDoc.doc
// FileUtil.mkdir(dirPath);
// FileUtils.mergeFile(filePath, dirPath + Constants.MERGER_FILE_NAME);
// Word2PdfJacobUtil.word2PDF(dirPath + Constants.MERGER_FILE_NAME, fileInputName);
// FileInputStream inputStreamDoc = new FileInputStream(fileInputName);
// //上传到附件中
// extDocService.extractedAttachFile(documentVO, inputStreamDoc, "", Constants.ATTACH_FILE);
// } catch (Exception e) {
// log.error("生成内部接口签名====生成文档错误:" + e.getMessage());
// } finally {
// //删除生成后的临时文件
// FileUtils.deleteDirectory(Constants.MERGER_FILE_ABSOLUTE_PATH + documentVO.getSubTypeName() + "\\" + documentVO.getNumber() + "\\");
// }
// } else {
// //为空就生成单个的签名文件
// processDataUtils.generateInterFaceWord(documentVO, new ExtInterfaceInfoLinkVO(), wfProcessInfoVO);
// }
// //生成过时文件通知单
// this.generateOutNotify(documentVO, wfProcessInfoVO);
// }
/**
* 自动任务-编制节点后生成word方法
*
* @param documentVo
*/
@Override
public void generateWordByAutoMethod(DxDocumentVO documentVo) {
DxDocumentVO dxDocumentVO = docBeforeCreateEvent.processCreateData(documentVo);
documentService.saveRecursion(dxDocumentVO);
}
/**
* 校验图册、图纸是否检入检出
*
* @param documentVO
*/
@Override
public void checkLockerUtil(DxDocumentVO documentVO) {
if ((Constants.TECHNICAL_FILE.equals(documentVO.getOneLevCategory())) && (Constants.DESIGN_ATLAS.equals(documentVO.getSubTypeName()) || Constants.INSTALL_ATLAS.equals(documentVO.getSubTypeName()))) {
//校验图册检出状态
if (Objects.nonNull(documentVO.getLocker())) {
throw new DxBusinessException("-1", "图册已被检出,编号:" + documentVO.getNumber());
}
//获取图册下的相关图纸
List<ExtAtlasDrawingLinkVO> drawingLinks = extDocService.recursionAtlasDoc(documentVO.getVersionId());
if (!org.springframework.util.CollectionUtils.isEmpty(drawingLinks)) {
drawingLinks.stream().forEach(item -> {
if (Objects.nonNull(item.getTarget().getLocker())) {
throw new DxBusinessException("-1", "图纸已被检出,编号:" + item.getTarget().getNumber());
}
});
}
}
}
/**
* 自动任务-生成QH技术文件签审页
*/
@Override
public void generateQHTechDoc(DxDocumentVO documentVO, Map<String, Object> wfTaskContext) {
if ((Constants.TECHNICAL_FILE.equals(documentVO.getOneLevCategory()))) {
//TODO: 2024/7/31 4.1 不存在这个方法getWfProcessInst
// DxWfProcessVO wfProcessInstVO = workFlowUtil.getWfProcessInst(documentVO);
// TODO: 2024/7/31 4.1 不存在这个方法getProcessInstDetailById
// DxWfProcessInfoVO wfProcessInfoVO = dexWorkFlowService.getProcessInstDetailById(wfProcessInstVO.getId());
// //深度查询展开objFileLink
// DxDocumentVO dxDocumentVO = extDocUtil.findDocObjFileLinks(documentVO.getId());
// //生成QH技术文件签审页
// this.generateQHTechDocWord(dxDocumentVO, wfProcessInfoVO);
// //如果是原理图和布置图,生成三个pdf
// technicalFileUtils.operateDrawingDoc(null, dxDocumentVO, wfProcessInfoVO);
// documentService.saveRecursion(dxDocumentVO);
// //生成图册下图纸的pdf
// if (Constants.DESIGN_ATLAS.equals(dxDocumentVO.getSubTypeName()) || Constants.INSTALL_ATLAS.equals(dxDocumentVO.getSubTypeName())) {
// technicalFileUtils.settingAtlasDrawingData(documentVO, wfProcessInfoVO);
// }
// //生成过时文件通知单
// this.generateOutNotify(documentVO, wfProcessInfoVO);
}
}
/**
* 生成过时文件通知单方法
*
* @param documentVO
* @param wfProcessInfoVO
*/
// TODO: 2024/7/31 4.1 这个类不存在WfProcessInfoVO
// private void generateOutNotify(DxDocumentVO documentVO, WfProcessInfoVO wfProcessInfoVO) {
// List<ExtObsoleteDocLinkVO> obsoleteDocLinkVOS = extDocUtil.recursionObsoleteDocLinkBySourceId(documentVO.getVersionId());
// if (!CollectionUtils.isEmpty(obsoleteDocLinkVOS)) {
// ExtObsoleteDocLinkVO obsoleteDocLinkVO = obsoleteDocLinkVOS.get(0);
// DxDocumentVO target = obsoleteDocLinkVO.getTarget();
// if (!ObjectUtils.isEmpty(target)) {
// extDocService.generateDocWordSign(target, OutdatedDocNotifyUtils.class, wfProcessInfoVO, "");
// //保存
// documentService.saveRecursion(target);
// } else {
// log.error("生成过时文件通知单失败!");
// }
// }
// }
/**
* 自动任务-生成QH技术文件签审页
*/
// TODO: 2024/7/31 4.1 这个类不存在WfProcessInfoVO
// private void generateQHTechDocWord(DxDocumentVO documentVO, WfProcessInfoVO wfProcessInfoVO) {
// 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() + "\\" + Constants.MERGER_SOURCE + "\\";
// //生成特定的文档目录,保存生成的word文件
// FileUtil.mkdir(outWordFilePath);
// try {
// //先生成封皮数据
// docBeforeCreateEvent.generalTechnicalWord(documentVO);
// JSONObject jsonObject = technicalFileUtils.settingData(documentVO, wfProcessInfoVO);
// //生成校核、审核、审定的记录卡
// importWordService.getWordAllTable(jsonObject, Constants.TEMPLATE_PATH + "TechnicalFile/QHTemplate.docx", outWordFilePath + "/QHAuditDoc.docx");
// //生成接口会签
// technicalFileUtils.interfaceHQSetting(documentVO, wfProcessInfoVO);
// //专项审查表
// technicalFileUtils.specialSCSetting(documentVO, wfProcessInfoVO);
// //合并生成好的文档
// FileUtils.mergePdfFile(outWordFilePath, dirPath + Constants.MERGER_PDF_FILE_NAME);
// log.info("生成QH技术文件签审页-合并pdf文件完成!");
// //将pdf上传到附件中(客制化)
// extDocService.extractedAttachFile(documentVO, new FileInputStream(dirPath + Constants.MERGER_PDF_FILE_NAME), "附件二", Constants.ATTACH_FILE);
// } catch (Exception exception) {
// log.error("自动任务-生成QH技术文件签审页错误!" + exception.getMessage());
// } finally {
// //删除生成后的临时文件
// FileUtils.deleteDirectory(Constants.MERGER_FILE_ABSOLUTE_PATH + documentVO.getSubTypeName() + "\\" + documentVO.getNumber() + "\\");
// }
// }
/**
* 结束流程实例
*
* @param iterationObject
*/
// TODO: 2024/7/31 4.1 这个类不存在DxIterationVO
// @Override
// public void endProcess(DxIterationVO iterationObject) {
// WfProcessInstVO wfProcessInstVO = workFlowUtil.getWfProcessInst(iterationObject);
// if (Objects.nonNull(wfProcessInstVO)) {
// dexWorkFlowService.endProcessInst(wfProcessInstVO.getId());
// }
// }
/**
* 生成过时文件通知单word
*
* @param documentVO
*/
@Override
public void generateOutdatedDocNotify(DxDocumentVO documentVO) {
List<ExtObsoleteDocLinkVO> obsoleteDocLinkVOS = extDocUtil.recursionObsoleteDocLinkByTargetId(documentVO.getVersionId());
if (!CollectionUtil.isEmpty(obsoleteDocLinkVOS)) {
obsoleteDocLinkVOS.stream().forEach(item -> {
DxDocumentVO source = item.getSource();
if (!ObjectUtils.isEmpty(source)) {
// TODO: 2024/7/31 4.1 这个类不存在WfProcessInstVO
// WfProcessInstVO wfProcessInstVO = workFlowUtil.getWfProcessInst(source);
// DxWfProcessInfoVO wfProcessInfoVO = dexWorkFlowService.getProcessInstDetailById(wfProcessInstVO.getId());
// extDocService.generateDocWordSign(documentVO, OutdatedDocNotifyUtils.class, wfProcessInfoVO, "");
// } else {
log.error("更新pdf失败,生成过时文件通知单失败!");
}
});
}
//保存附件
documentService.saveRecursion(documentVO);
}
/**
* 已发布后修改状态已过时
*
* @param documentVO
*/
@Override
public void changeOldDataState(DxDocumentVO documentVO) {
//获取上一大版本的最新小版本
//List<DxDocumentVO> docVersions = documentService.getLastedIterationByVersions(documentVO.getId());
List<DxDocumentVO> allDocVersions = documentService.getAllIterationsByObjId(documentVO.getId());
if (!CollectionUtils.isEmpty(allDocVersions)) {
allDocVersions.stream().forEach((doc) -> {
//已发布状态置为已过时
if (Constants.RELEASED.equals(doc.getState())) {
doc.setState(Constants.OBSOLETE);
documentService.changeStatus(doc);
}
});
}
/* if (!CollectionUtils.isEmpty(docVersions)) {
docVersions.stream().forEach((doc) -> {
//已发布状态置为已过时
if (Constants.RELEASED.equals(doc.getState())) {
doc.setState(Constants.OBSOLETE);
documentService.changeStatus(doc);
}
});
}*/
}
}
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