Commit 21ec4376 authored by xuzhang's avatar xuzhang

[feat][DOC]定时任务Feign接口添加

parent 0c095bbb
...@@ -13,8 +13,10 @@ ...@@ -13,8 +13,10 @@
<module name="dcs-doc-expand-feign" /> <module name="dcs-doc-expand-feign" />
<module name="dcs-doc-expand-entity" /> <module name="dcs-doc-expand-entity" />
<module name="dcs-doc-expand-server" /> <module name="dcs-doc-expand-server" />
<module name="dcs-doc-autotask-interface" />
</profile> </profile>
</annotationProcessing> </annotationProcessing>
<bytecodeTargetLevel>
<module name="dcs-doc-autotask-interface" target="1.8" />
</bytecodeTargetLevel>
</component> </component>
</project> </project>
\ No newline at end of file
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.yonde.dcs</groupId> <groupId>com.yonde.dcs</groupId>
<artifactId>dcs-doc-expand-core</artifactId> <artifactId>dcs-doc-expand-feign</artifactId>
<version>4.1-RELEASE</version> <version>4.1-RELEASE</version>
</dependency> </dependency>
</dependencies> </dependencies>
......
package com.yonde.dcs.task; //package com.yonde.dcs.task;
//
import cn.hutool.core.collection.CollectionUtil; //import cn.hutool.core.collection.CollectionUtil;
import com.yonde.dcs.core.constants.Constants; //import com.yonde.dcs.core.constants.Constants;
import com.yonde.dcs.core.service.ExtSendFormLinkService; //import com.yonde.dcs.core.service.ExtSendFormLinkService;
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.dex.basedata.entity.api.ApiResult; //import com.yonde.dex.basedata.entity.api.ApiResult;
import com.yonde.dex.basedata.entity.vo.IdVO; //import com.yonde.dex.basedata.entity.vo.IdVO;
import com.yonde.dex.taskmonitor.api.interfaces.TaskMessagePusher; //import com.yonde.dex.taskmonitor.api.interfaces.TaskMessagePusher;
import com.yonde.dex.wfc.common.vo.DxWfProcessSearchVO; //import com.yonde.dex.wfc.common.vo.DxWfProcessSearchVO;
import com.yonde.dex.wfc.common.vo.DxWfProcessVO; //import com.yonde.dex.wfc.common.vo.DxWfProcessVO;
import com.yonde.dex.wfc.feign.api.WfcProcessFeign; //import com.yonde.dex.wfc.feign.api.WfcProcessFeign;
import io.swagger.annotations.Api; //import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; //import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; //import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page; //import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*; //import org.springframework.web.bind.annotation.*;
//
/** ///**
* @program: service // * @program: service
* @description: 自动任务服务接口 // * @description: 自动任务服务接口
* @author: dang wei // * @author: dang wei
* @create: 2021-07-13 10:01 // * @create: 2021-07-13 10:01
*/ // */
@RestController //@RestController
@RequestMapping("/task") //@RequestMapping("/task")
@Api(tags = "自动任务服务接口") //@Api(tags = "自动任务服务接口")
public class ExtAutoTaskController { //public class ExtAutoTaskController {
//
@Autowired // @Autowired
WfcProcessFeign wfcProcessFeign; // WfcProcessFeign wfcProcessFeign;
//
@Autowired // @Autowired
TaskMessagePusher taskMessagePusher; // TaskMessagePusher taskMessagePusher;
@Autowired // @Autowired
private ExtAutoTaskService autoTaskService; // private ExtAutoTaskService autoTaskService;
@Autowired // @Autowired
private ExtDocUtil extDocUtil; // private ExtDocUtil extDocUtil;
//
@Autowired // @Autowired
private ExtSendFormLinkService sendFormLinkService; // private ExtSendFormLinkService sendFormLinkService;
//
@ApiOperation("电子签名") // @ApiOperation("电子签名")
@PostMapping({"/esign"}) // @PostMapping({"/esign"})
public ApiResult esign(@RequestBody IdVO entity) { // public ApiResult esign(@RequestBody IdVO entity) {
DxWfProcessSearchVO dxWfProcessSearchVO = new DxWfProcessSearchVO(); // DxWfProcessSearchVO dxWfProcessSearchVO = new DxWfProcessSearchVO();
dxWfProcessSearchVO.setPboClass(entity.getDxClassname()); // dxWfProcessSearchVO.setPboClass(entity.getDxClassname());
dxWfProcessSearchVO.setPboId(entity.getId()); // dxWfProcessSearchVO.setPboId(entity.getId());
Page<DxWfProcessVO> dxWfProcessVODxPage = this.wfcProcessFeign.getProcessList(dxWfProcessSearchVO, 1, 1); // Page<DxWfProcessVO> dxWfProcessVODxPage = this.wfcProcessFeign.getProcessList(dxWfProcessSearchVO, 1, 1);
if (CollectionUtil.isNotEmpty(dxWfProcessVODxPage.getContent())) { // if (CollectionUtil.isNotEmpty(dxWfProcessVODxPage.getContent())) {
DxWfProcessVO dxWfProcessVO = dxWfProcessVODxPage.getContent().get(0); // DxWfProcessVO dxWfProcessVO = dxWfProcessVODxPage.getContent().get(0);
//
String pboKey = ""; // String pboKey = "";
String signNode = ""; // String signNode = "";
//
if (DxDocumentVO.class.getName().equals(entity.getDxClassname())) { // if (DxDocumentVO.class.getName().equals(entity.getDxClassname())) {
pboKey = "doc"; // pboKey = "doc";
signNode = "Activity_0st1yf8"; // signNode = "Activity_0st1yf8";
} // }
// DxWfTaskContext dxWfTaskContext = new DxWfTaskContext(dxWfProcessVO.getBusinessKey(), dxWfProcessVO.getId(), dxWfProcessVO.getProcessDef().getId(), signNode, null, (Map) null); //// DxWfTaskContext dxWfTaskContext = new DxWfTaskContext(dxWfProcessVO.getBusinessKey(), dxWfProcessVO.getId(), dxWfProcessVO.getProcessDef().getId(), signNode, null, (Map) null);
//todo 在4.1中未找到WfcSignMessage 注释了71-74行 ////todo 在4.1中未找到WfcSignMessage 注释了71-74行
// WfcSignMessage wfcSignMessage = new WfcSignMessage(new HashMap()); // // WfcSignMessage wfcSignMessage = new WfcSignMessage(new HashMap());
// wfcSignMessage.setWfTaskContext(dxWfTaskContext); //// wfcSignMessage.setWfTaskContext(dxWfTaskContext);
// wfcSignMessage.setSignType(pboKey); //// wfcSignMessage.setSignType(pboKey);
// TaskMessage taskMessage = (new WfcSignMessageBuilder()).newTasks(wfcSignMessage); //// TaskMessage taskMessage = (new WfcSignMessageBuilder()).newTasks(wfcSignMessage);
// this.taskMessagePusher.sendMessage(taskMessage); //// this.taskMessagePusher.sendMessage(taskMessage);
this.taskMessagePusher.sendMessage(null); // this.taskMessagePusher.sendMessage(null);
return ApiResult.ok("重新发送电子签名请求成功!"); // return ApiResult.ok("重新发送电子签名请求成功!");
} else { // } else {
return ApiResult.ok("该对象未走签审流程!"); // return ApiResult.ok("该对象未走签审流程!");
} // }
} // }
@ApiOperation(value = "更新PDF", notes = "更新PDF", httpMethod = "GET") // @ApiOperation(value = "更新PDF", notes = "更新PDF", httpMethod = "GET")
@GetMapping(value = "/updatePdf/{id}") // @GetMapping(value = "/updatePdf/{id}")
public ApiResult updatePdf(@PathVariable Long id) { // public ApiResult updatePdf(@PathVariable Long id) {
DxDocumentVO documentVO = extDocUtil.findDocObjFileLinks(id); // DxDocumentVO documentVO = extDocUtil.findDocObjFileLinks(id);
//重新生成设计图册签名 // //重新生成设计图册签名
autoTaskService.generateQHTechDoc(documentVO, null); // autoTaskService.generateQHTechDoc(documentVO, null);
if (Constants.OUTDATED_NOTIFY.equals(documentVO.getSubTypeName())) { // if (Constants.OUTDATED_NOTIFY.equals(documentVO.getSubTypeName())) {
//特殊处理过时文件通知单 // //特殊处理过时文件通知单
autoTaskService.generateOutdatedDocNotify(documentVO); // autoTaskService.generateOutdatedDocNotify(documentVO);
} else { // } else {
//重新生成单据签名 // //重新生成单据签名
autoTaskService.generateDocWordSign(documentVO, null, "二"); // autoTaskService.generateDocWordSign(documentVO, null, "二");
} // }
return ApiResult.ok("更新成功!"); // return ApiResult.ok("更新成功!");
} // }
} //}
/*
package com.yonde.dcs.task; package com.yonde.dcs.task;
...@@ -8,141 +9,182 @@ import com.yonde.dcs.plan.common.vo.ExtPlanVO; ...@@ -8,141 +9,182 @@ import com.yonde.dcs.plan.common.vo.ExtPlanVO;
import java.util.Map; import java.util.Map;
*/
/** /**
* @program: inet-pdm-service * @program: inet-pdm-service
* @description: 自动任务服务接口 * @description: 自动任务服务接口
* @author: dang wei * @author: dang wei
* @create: 2021-09-27 09:41 * @create: 2021-09-27 09:41
*/ *//*
public interface ExtAutoTaskService { public interface ExtAutoTaskService {
/** */
/**
* 客户化文档修改状态 * 客户化文档修改状态
* *
* @param documentVO * @param documentVO
*/ *//*
void extChangeDocState(DxDocumentVO documentVO, String state); void extChangeDocState(DxDocumentVO documentVO, String state);
/** */
/**
* 给选择的提资方人员发放通知 * 给选择的提资方人员发放通知
* *
* @param documentVO * @param documentVO
* @param userId * @param userId
*/ *//*
void informativeUser(DxDocumentVO documentVO, String userId); void informativeUser(DxDocumentVO documentVO, String userId);
/** */
/**
* 设置提资审核 * 设置提资审核
* *
* @param taskParticipant * @param taskParticipant
* @param processInstId * @param processInstId
* @param key * @param key
* @param value * @param value
*/ *//*
void extSetProcessVariable(Map<String, Object> taskParticipant, String processInstId, String key, Object value); void extSetProcessVariable(Map<String, Object> taskParticipant, String processInstId, String key, Object value);
/** */
/**
* 设置提资人变量 * 设置提资人变量
* *
* @param processInstId * @param processInstId
* @param varKey * @param varKey
* @param informativeUser * @param informativeUser
*/ *//*
void setInformativeUser(String processInstId, String varKey, String informativeUser); void setInformativeUser(String processInstId, String varKey, String informativeUser);
/**
* 自动发送联系单
*/ */
/**
* 自动发送联系单
*//*
void sendContractDoc(DxDocumentVO documentVO, String contractName); void sendContractDoc(DxDocumentVO documentVO, String contractName);
/** */
/**
* 创建过时文件通知单 * 创建过时文件通知单
* *
* @param documentVO * @param documentVO
*/ *//*
void createDocNotify(DxDocumentVO documentVO); void createDocNotify(DxDocumentVO documentVO);
/** */
/**
* 设置编制节点人员回显事件 * 设置编制节点人员回显事件
* *
* @param taskId * @param taskId
* @param documentVO * @param documentVO
*/ *//*
void setProcessSelectionInfo(String taskId, DxDocumentVO documentVO); void setProcessSelectionInfo(String taskId, DxDocumentVO documentVO);
/** */
/**
* 任务完成后更新pbo属性,驳回操作,设置编制节点人员回显 * 任务完成后更新pbo属性,驳回操作,设置编制节点人员回显
* *
* @param taskId * @param taskId
* @param documentVO * @param documentVO
*/ *//*
void getProcessSelectionInfo(String taskId, DxDocumentVO documentVO); void getProcessSelectionInfo(String taskId, DxDocumentVO documentVO);
/** */
/**
* 计划生命周期事件 * 计划生命周期事件
* *
* @param extPlanVO * @param extPlanVO
*/ *//*
void pressPlanInfo(ExtPlanVO extPlanVO) throws Exception; void pressPlanInfo(ExtPlanVO extPlanVO) throws Exception;
/** */
/**
* 内部接口-生成提资信息word * 内部接口-生成提资信息word
* *
* @param documentVO * @param documentVO
*/ *//*
void generateInformationWord(DxDocumentVO documentVO); void generateInformationWord(DxDocumentVO documentVO);
/**
* 生成NCR审查单word
*/ */
/**
* 生成NCR审查单word
*//*
void generateNcrReviewWord(DxDocumentVO documentVO, Map<String, Object> wfTaskContext); void generateNcrReviewWord(DxDocumentVO documentVO, Map<String, Object> wfTaskContext);
/** */
/**
* 生成word签字 * 生成word签字
* *
* @param documentVO * @param documentVO
* @param wfTaskContext * @param wfTaskContext
* @param fileName 同室审核完生成签名附件为(附件1),签审流程走完后生成签名附件为(附件2),没有是为""。 * @param fileName 同室审核完生成签名附件为(附件1),签审流程走完后生成签名附件为(附件2),没有是为""。
*/ *//*
void generateDocWordSign(DxDocumentVO documentVO, Map<String, Object> wfTaskContext, String fileName); void generateDocWordSign(DxDocumentVO documentVO, Map<String, Object> wfTaskContext, String fileName);
/**
* 内部接口-保存内部接口信息的总体室、审核签审信息值
*/ */
/**
* 内部接口-保存内部接口信息的总体室、审核签审信息值
*//*
void savedInterfaceWf(DxDocumentVO documentVO, Map<String, Object> wfTaskContext); void savedInterfaceWf(DxDocumentVO documentVO, Map<String, Object> wfTaskContext);
/**
* 自动任务-编制节点后生成word方法(自动任务修改方法)
*/ */
/**
* 自动任务-编制节点后生成word方法(自动任务修改方法)
*//*
void generateWordByAutoMethod(DxDocumentVO documentVo); void generateWordByAutoMethod(DxDocumentVO documentVo);
/**
* 自动任务-校验图册下的图纸是否检入
*/ */
/**
* 自动任务-校验图册下的图纸是否检入
*//*
void checkLockerUtil(DxDocumentVO documentVo); void checkLockerUtil(DxDocumentVO documentVo);
/**
* 自动任务-生成QH技术文件签审页
*/ */
/**
* 自动任务-生成QH技术文件签审页
*//*
void generateQHTechDoc(DxDocumentVO documentVO, Map<String, Object> wfTaskContext); void generateQHTechDoc(DxDocumentVO documentVO, Map<String, Object> wfTaskContext);
/** */
/**
* 结束流程实例 * 结束流程实例
* *
* @param iterationObject * @param iterationObject
*/ *//*
// TODO: 2024/7/31 DxIterationVO在4.1不存在 // TODO: 2024/7/31 DxIterationVO在4.1不存在
// void endProcess(DxIterationVO iterationObject); // void endProcess(DxIterationVO iterationObject);
/** */
/**
* 生成过时文件通知单word * 生成过时文件通知单word
* *
* @param documentVO * @param documentVO
*/ *//*
void generateOutdatedDocNotify(DxDocumentVO documentVO); void generateOutdatedDocNotify(DxDocumentVO documentVO);
/**
* 已发布后修改状态已过时
*/ */
/**
* 已发布后修改状态已过时
*//*
void changeOldDataState(DxDocumentVO documentVO); void changeOldDataState(DxDocumentVO documentVO);
} }
*/
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -138,6 +138,27 @@ ...@@ -138,6 +138,27 @@
<artifactId>ooxml-schemas</artifactId> <artifactId>ooxml-schemas</artifactId>
<version>1.4</version> <version>1.4</version>
</dependency> </dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>5.5.13.2</version>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>layout</artifactId>
<version>7.1.11</version>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>forms</artifactId>
<version>7.1.13</version>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itext-asian</artifactId>
<version>5.2.0</version>
</dependency>
</dependencies> </dependencies>
</project> </project>
package com.yonde.dcs.core.controller;
import cn.hutool.core.collection.CollectionUtil;
import com.yonde.dcs.common.vo.ExtApplicantVO;
import com.yonde.dcs.common.vo.ExtAuditObjectVO;
import com.yonde.dcs.common.vo.ExtInterfaceVO;
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.dcs.plan.common.vo.ExtPlanVO;
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 lombok.SneakyThrows;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.Map;
/**
* @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("更新成功!");
}
@ApiOperation(value = "客户化文档修改状态", notes = "客户化文档修改状态", httpMethod = "POST")
@PostMapping(value = "/extChangeDocState")
public void extChangeDocState(@RequestBody DxDocumentVO documentVO, @RequestParam("state") String state) {
autoTaskService.extChangeDocState(documentVO, state);
}
@ApiOperation(value = "给选择的提资方人员发放通知", notes = "给选择的提资方人员发放通知", httpMethod = "POST")
@PostMapping(value = "/informativeUser")
public void informativeUser(@RequestBody DxDocumentVO documentVO, @RequestParam("userId") String userId) {
autoTaskService.informativeUser(documentVO, userId);
}
@ApiOperation(value = "设置提资审核", notes = "设置提资审核", httpMethod = "POST")
@PostMapping(value = "/extSetProcessVariable")
public void extSetProcessVariable(Map<String, Object> taskParticipant,
@RequestParam("processInstId") String processInstId,
@RequestParam("key") String key,
Object value) {
autoTaskService.extSetProcessVariable(taskParticipant, processInstId, key, value);
}
@ApiOperation(value = "设置提资人变量", notes = "设置提资人变量", httpMethod = "POST")
@PostMapping(value = "/setInformativeUser")
public void setInformativeUser(@RequestParam("processInstId") String processInstId,
@RequestParam("varKey") String varKey,
@RequestParam("informativeUser") String informativeUser) {
autoTaskService.setInformativeUser(processInstId, varKey, informativeUser);
}
@ApiOperation(value = "自动发送联系单", notes = "自动发送联系单", httpMethod = "POST")
@PostMapping(value = "/sendContractDoc")
public void sendContractDoc(@RequestBody DxDocumentVO documentVO, @RequestParam("contractName") String contractName) {
autoTaskService.sendContractDoc(documentVO, contractName);
}
@ApiOperation(value = "创建过时文件通知单", notes = "创建过时文件通知单", httpMethod = "POST")
@PostMapping(value = "/createDocNotify")
public void createDocNotify(@RequestBody DxDocumentVO documentVO) {
autoTaskService.createDocNotify(documentVO);
}
@ApiOperation(value = "设置编制节点人员回显事件", notes = "设置编制节点人员回显事件", httpMethod = "POST")
@PostMapping(value = "/setProcessSelectionInfo")
public void setProcessSelectionInfo(@RequestParam("taskId") String taskId, @RequestBody DxDocumentVO documentVO) {
autoTaskService.setProcessSelectionInfo(taskId, documentVO);
}
@ApiOperation(value = "任务完成后更新pbo属性,驳回操作,设置编制节点人员回显", notes = "任务完成后更新pbo属性,驳回操作,设置编制节点人员回显", httpMethod = "POST")
@PostMapping(value = "/getProcessSelectionInfo")
public void getProcessSelectionInfo(@RequestParam("taskId") String taskId, @RequestBody DxDocumentVO documentVO) {
autoTaskService.getProcessSelectionInfo(taskId, documentVO);
}
@ApiOperation(value = "计划生命周期事件", notes = "计划生命周期事件", httpMethod = "POST")
@PostMapping(value = "/pressPlanInfo")
public void pressPlanInfo(@RequestBody ExtPlanVO extPlanVO) throws Exception {
autoTaskService.pressPlanInfo(extPlanVO);
}
@ApiOperation(value = "内部接口-生成提资信息word", notes = "内部接口-生成提资信息word", httpMethod = "POST")
@PostMapping(value = "/generateInformationWord")
public void generateInformationWord(@RequestBody DxDocumentVO documentVO) {
autoTaskService.generateInformationWord(documentVO);
}
@ApiOperation(value = "生成NCR审查单word", notes = "生成NCR审查单word", httpMethod = "POST")
@PostMapping(value = "/generateNcrReviewWord")
public void generateNcrReviewWord(@RequestBody DxDocumentVO documentVO, Map<String, Object> wfTaskContext) {
autoTaskService.generateNcrReviewWord(documentVO, wfTaskContext);
}
@ApiOperation(value = "生成word签字", notes = "生成word签字", httpMethod = "POST")
@PostMapping(value = "/generateDocWordSign")
public void generateDocWordSign(@RequestBody DxDocumentVO documentVO,
Map<String, Object> wfTaskContext,
@RequestParam("fileName")String fileName) {
autoTaskService.generateDocWordSign(documentVO, wfTaskContext,fileName);
}
@ApiOperation(value = "内部接口-保存内部接口信息的总体室、审核签审信息值", notes = "内部接口-保存内部接口信息的总体室、审核签审信息值", httpMethod = "POST")
@PostMapping(value = "/savedInterfaceWf")
public void savedInterfaceWf(@RequestBody DxDocumentVO documentVO, Map<String, Object> wfTaskContext) {
autoTaskService.savedInterfaceWf(documentVO, wfTaskContext);
}
@ApiOperation(value = "自动任务-编制节点后生成word方法", notes = "自动任务-编制节点后生成word方法", httpMethod = "POST")
@PostMapping(value = "/generateWordByAutoMethod")
public void generateWordByAutoMethod(@RequestBody DxDocumentVO documentVO) {
autoTaskService.generateWordByAutoMethod(documentVO);
}
@ApiOperation(value = "自动任务-校验图册下的图纸是否检入", notes = "自动任务-校验图册下的图纸是否检入", httpMethod = "POST")
@PostMapping(value = "/checkLockerUtil")
public void checkLockerUtil(@RequestBody DxDocumentVO documentVO) {
autoTaskService.checkLockerUtil(documentVO);
}
@ApiOperation(value = "自动任务-生成QH技术文件签审页", notes = "自动任务-生成QH技术文件签审页", httpMethod = "POST")
@PostMapping(value = "/generateQHTechDoc")
public void generateQHTechDoc(@RequestBody DxDocumentVO documentVO, Map<String, Object> wfTaskContext) {
autoTaskService.generateQHTechDoc(documentVO,wfTaskContext);
}
//endProcess
@ApiOperation(value = "生成过时文件通知单word", notes = "生成过时文件通知单word", httpMethod = "POST")
@PostMapping(value = "/generateOutdatedDocNotify")
public void generateOutdatedDocNotify(@RequestBody DxDocumentVO documentVO) {
autoTaskService.generateOutdatedDocNotify(documentVO);
}
@ApiOperation(value = "已发布后修改状态已过时", notes = "已发布后修改状态已过时", httpMethod = "POST")
@PostMapping(value = "/changeOldDataState")
public void changeOldDataState(@RequestBody DxDocumentVO documentVO) {
autoTaskService.changeOldDataState(documentVO);
}
@ApiOperation(value = "申请内容 签名", notes = "申请内容 签名", httpMethod = "POST")
@PostMapping(value = "/autoApplicantSign")
public void autoApplicantSign(@RequestBody ExtApplicantVO applicantVO, Map<String, Object> wfTaskContext) {
autoTaskService.autoApplicantSign(applicantVO,wfTaskContext);
}
@ApiOperation(value = "接口单签名", notes = "接口单签名", httpMethod = "POST")
@PostMapping(value = "/autoInterFaceSign")
public void autoInterFaceSign(@RequestBody ExtInterfaceVO extInterfaceVO, Map<String, Object> wfTaskContext) {
autoTaskService.autoInterFaceSign(extInterfaceVO,wfTaskContext);
}
@ApiOperation(value = "签审对象的终止流程", notes = "签审对象的终止流程", httpMethod = "POST")
@PostMapping(value = "/autoInterfaceEnd")
public void autoInterfaceEnd(@RequestBody ExtAuditObjectVO auditObjectVO) {
autoTaskService.autoInterfaceEnd(auditObjectVO);
}
@ApiOperation(value = "申请内容走完流程后 自动启动 接口单的流程", notes = "申请内容走完流程后 自动启动 接口单的流程", httpMethod = "POST")
@PostMapping(value = "/startInterFaceFlow")
public void startInterFaceFlow(@RequestBody ExtApplicantVO applicantVO) {
autoTaskService.startInterFaceFlow(applicantVO);
}
@ApiOperation(value = "重新创建启动流程", notes = "重新创建启动流程", httpMethod = "POST")
@PostMapping(value = "/startAddInterFaceFlow")
public void startAddInterFaceFlow(@RequestBody ExtInterfaceVO extInterfaceVO) {
autoTaskService.startAddInterFaceFlow(extInterfaceVO);
}
@ApiOperation(value = "签审对象 扫描所有提资单 并更新状态", notes = "签审对象 扫描所有提资单 并更新状态", httpMethod = "POST")
@PostMapping(value = "/stopAllExtApplicantFaceFlow")
public void stopAllExtApplicantFaceFlow(@RequestBody ExtInterfaceVO extInterfaceVO) {
autoTaskService.stopAllExtApplicantFaceFlow(extInterfaceVO);
}
}
package com.yonde.dcs.core.service;
import com.yonde.dcs.common.vo.ExtApplicantVO;
import com.yonde.dcs.common.vo.ExtAuditObjectVO;
import com.yonde.dcs.common.vo.ExtInterfaceVO;
import com.yonde.dcs.document.common.entity.vo.DxDocumentVO;
import com.yonde.dcs.feign.ExtAutoTaskServiceFeign;
import com.yonde.dcs.plan.common.vo.ExtPlanVO;
import lombok.SneakyThrows;
import java.util.Map;
/**
* @program: inet-pdm-service
* @description: 自动任务服务接口
* @author: dang wei
* @create: 2021-09-27 09:41
*/
public interface ExtAutoTaskService extends ExtAutoTaskServiceFeign {
/**
* 客户化文档修改状态
*
* @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);
/**
* 申请内容 签名
*
* @param applicantVO
* @param wfTaskContext
*/
@SneakyThrows
void autoApplicantSign(ExtApplicantVO applicantVO, Map<String, Object> wfTaskContext);
/**
* 接口单签名
*
* @param extInterfaceVO
* @param wfTaskContext
*/
void autoInterFaceSign(ExtInterfaceVO extInterfaceVO, Map<String, Object> wfTaskContext);
/**
* 签审对象 关联的接口单 状态置为已终止 (签审对象的终止流程)
* @param auditObjectVO
*/
@SneakyThrows
void autoInterfaceEnd(ExtAuditObjectVO auditObjectVO);
/**
* 申请内容走完流程后 自动启动 接口单的流程
* @param applicantVO 申请内容
*/
void startInterFaceFlow(ExtApplicantVO applicantVO);
/**
* 接口单 走完流程后 根据属性 applicantConfirm 申请方确认:待补充、不接受 重新创建启动流程
*
* @param extInterfaceVO
*/
void startAddInterFaceFlow(ExtInterfaceVO extInterfaceVO);
/**
* 签审对象 扫描所有提资单 并更新状态
* @param extInterfaceVO
*/
void stopAllExtApplicantFaceFlow(ExtInterfaceVO extInterfaceVO);
}
package com.yonde.dcs.core.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.io.FileUtil;
import cn.hutool.extra.spring.SpringUtil;
import com.alibaba.fastjson.JSONObject;
import com.yonde.dcs.common.vo.*;
import com.yonde.dcs.core.constants.SignConstants;
import com.yonde.dcs.core.events.DocBeforeCreateEvent;
import com.yonde.dcs.core.events.ProcessDataUtils;
import com.yonde.dcs.core.factory.NCRSCUtils;
import com.yonde.dcs.core.factory.TechnicalFileUtils;
import com.yonde.dcs.core.service.*;
import com.yonde.dcs.core.util.*;
import com.yonde.dcs.core.word.ImportWordService;
import com.yonde.dcs.document.common.entity.vo.DxDocumentVO;
import com.yonde.dcs.document.core.service.DocumentService;
import com.yonde.dcs.plan.common.constants.Constants;
import com.yonde.dcs.plan.common.utils.FileUtils;
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.api.CustomMultipartFile;
import com.yonde.dex.basedata.entity.data.DxPageImpl;
import com.yonde.dex.basedata.entity.data.OperatorType;
import com.yonde.dex.basedata.entity.jackson.JsonUtils;
import com.yonde.dex.basedata.exception.DxBusinessException;
import com.yonde.dex.basedata.utils.obj.DxEntityUtils;
import com.yonde.dex.dao.service.util.DxPageUtils;
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.utils.common.utils.DxFileUtils;
import com.yonde.dex.wfc.common.vo.*;
import com.yonde.dex.wfc.feign.api.WfcProcessFeign;
import com.yonde.dex.wfc.feign.api.WfcTaskFeign;
import feign.form.ContentType;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.client.utils.CloneUtils;
import org.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.*;
import java.lang.reflect.Method;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
/**
* @program: inet-pdm-service
* @description: 自动任务服务接口
* @author: dang wei
* @create: 2021-09-27 09:42
*/
@Service
@Slf4j
public class ExtAutoTaskServiceImpl implements ExtAutoTaskService {
@Qualifier("documentServiceImpl")
@Autowired
private DocumentService 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;
@Autowired
ExtApplicantService extApplicantService;
@Autowired
ExtInterfaceService extInterfaceService;
// @Autowired
// IOrganizationService organizationService;
// @Autowired
// private ChangeUserHelper changeUserHelper;
/**
* 客制化文档修改状态
*
* @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.getDxDocumentExpand().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.getDxDocumentExpand().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.getDxDocumentExpand().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);
}
});
}*/
}
/**
* 接口单 签名 pdf是放在主内容里面 master_file
*
* @param applicantVO
* @param wfTaskContext
*/
@SneakyThrows
@Override
public void autoApplicantSign(ExtApplicantVO applicantVO, Map<String, Object> wfTaskContext) {
DxWfTaskContext context = (DxWfTaskContext) wfTaskContext.get("context");
SearchQueryCondition queryCondition = SearchUtil.buildQueryWithOpenAttr("id", SearchItem.Operator.EQ, applicantVO.getId(), "objFileLinks.target");
DxPageImpl<ExtApplicantVO> recursion = extApplicantService.findRecursion(queryCondition);
applicantVO = recursion.getContent().get(0);
//TODO 获取任务参与者信息,key:占位符,value:人名 节点名称还需要补充
// Map<String, String> taskMap = getTaskParticipants(context);
// //将签字后的pdf挂到接口单上面
// PapersVO papersVO = ObjFileLinkUtil.getAppointTypeFile(applicantVO, Constants.MASTER_FILE).get(0);
// String temDir = DxFileUtils.createRandomTemp("interface");
// String interFacePath = downPaperToLocal(papersVO, temDir);
// String interSignPath = temDir + "签字_" + papersVO.getOriginalFileName();
// //pdf签字
// PDFUtil.signWord(interFacePath, interSignPath, taskMap);
// FileUtil.rename(new File(interSignPath), papersVO.getOriginalFileName(), true);
// //删除旧文件,增加新文件
// ObjFileLinkUtil.removeFile(applicantVO, Constants.MASTER_FILE);
// papersVO = savePDFToMinio(interFacePath);//上传到minio
// //TODO 附件上传待指定
// ObjFileLinkUtil.addFile(applicantVO, papersVO, Constants.MASTER_FILE);
// extInterfaceService.saveRecursion(applicantVO);
// FileUtils.deleteDirectory(temDir);
}
/**
* 获取流程参与者
*
* @param wfTaskContext
* @return
*/
@SneakyThrows
public Map<String, String> getTaskParticipants(DxWfTaskContext wfTaskContext) {
Map<String, String> data = new HashMap<>();
String processId = wfTaskContext.getProcessId();
return getTaskParticipants(processId);
}
@SneakyThrows
public Map<String, String> getTaskParticipants(String processId) {
Map<String, String> data = new HashMap<>();
//TODO
// DxWfProcessInfoVO wfProcessInfoVO = dexWorkFlowService.getProcessInstSimpleDetailById(processId);
// List<DxWfProcessTaskVO> activities = wfProcessInfoVO.getHistoryInfo();
// String dateStr = "";
// HashMap<String, String> signMap = CloneUtils.cloneObject(SignConstants.SignNodeMap);
// for (Map.Entry<String, String> entry : signMap.entrySet()) {
// dateStr = new StringBuffer(entry.getValue()).reverse().toString();
// //节点参与人
// data.put(entry.getValue(), getResolverName(activities, entry.getKey()));
// //节点时间
// data.put(dateStr, getResolverData(activities, entry.getKey()));
// }
// data.entrySet().removeIf(o -> org.springframework.util.StringUtils.isEmpty(o.getValue()));
return data;
}
/**
* 下载文件到本地
*
* @param file
* @param dir
* @return
*/
// public String downPaperToLocal(PapersVO file, String dir) {
// InputStream inputStream = null;
// CustomMultipartFile multipartFile = null;
// try {
// multipartFile = feignDownloadService.downloadio(file.getId());
// } catch (IOException e) {
// log.info("[接口单] >>> 文件服务下载为文件:{}--失败!", file.getId());
// throw new DxBusinessException("500", "文件服务下载文件失败:" + file);
// }
// try {
// inputStream = new ByteArrayInputStream(multipartFile.getBytes());
// } catch (IOException e) {
// log.info("[接口单] >>> 文件服务下载的文件:{}--转换为输入流失败!", file.getId());
// throw new DxBusinessException("500", "文件服务下载的文件转换为输入流失败:" + file);
// }
// String filePath = dir + file.getOriginalFileName();
// //保存到本地目录
// FileUtils.inputToFile(inputStream, filePath);
// return filePath;
//
// }
/**
* 获取某个环节执行者
*
* @param activities
* @param activityName
* @return
*/
private String getResolverName(List<DxWfProcessTaskVO> activities, String activityName) {
DxWfProcessTaskVO resolver = getResolver(activities, activityName);
if (Objects.isNull(resolver)) {
return null;
}
//获取用户的id resolver.getAssigneeName() 用户的名称
//Long userId = Long.valueOf(resolver.getAssignee());
return resolver.getAssigneeName();
}
/**
* 保存pdf到文件服务
* @param pdfPath
* @return
*/
// @Transactional(rollbackFor = Exception.class)
// public PapersVO savePDFToMinio(String pdfPath) throws IOException {
// String pdfName = pdfPath.substring(pdfPath.lastIndexOf("/") + 1);
// MultipartFile multipartFile = new MockMultipartFile("file", pdfName,
// ContentType.MULTIPART.toString(), new FileInputStream(pdfPath));
// Long field = fileManagerFeignService.upload(multipartFile, Constants.BUCKET_NAME);
// if (field == null) {
// log.error(">>> 接口单pdf >>> 文件上传失败!");
// throw new DxBusinessException("500", "文件服务上传文件失败:" + pdfPath);
// } else {
// log.info(">>> 接口单pdf >>>文件上传成功:{}", field);
// }
// //根据docId查询文件对象
// PapersVO fileVO = fileManagerFeignService.findFileInfoById(field);
// return fileVO;
// }
/**
* 获取某个环节的结束时间
*
* @param activities
* @param activityName
* @return
*/
private String getResolverData(List<DxWfProcessTaskVO> activities, String activityName) {
DxWfProcessTaskVO resolver = getResolver(activities, activityName);
SimpleDateFormat dateFm = new SimpleDateFormat("yyyy-MM-dd");
if (Objects.isNull(resolver)) {
return null;
}
Date endTime = resolver.getEndTime();
if (Objects.isNull(endTime)) {
endTime = new DateTime();
}
return dateFm.format(endTime).replace("-", ".");
}
/**
* 得到环节信息
*
* @param activities
* @param activityName
* @return
*/
private DxWfProcessTaskVO getResolver(List<DxWfProcessTaskVO> activities, String activityName) {
DxWfProcessTaskVO resolver = activities.stream()
.filter(wfProcessTaskVO -> wfProcessTaskVO.getName().equals(activityName) && ("通过".equals(wfProcessTaskVO.getResult()) || "提交审阅".equals(wfProcessTaskVO.getResult()) || "提交签审".equalsIgnoreCase(wfProcessTaskVO.getResult()))).findFirst().orElse(null);
return resolver;
}
/**
* 接口单 签名 pdf是放在主内容里面 master_file
*
* @param extInterfaceVO
* @param wfTaskContext
*/
@SneakyThrows
@Override
public void autoInterFaceSign(ExtInterfaceVO extInterfaceVO, Map<String, Object> wfTaskContext) {
//TODO
// DxWfTaskContext context = (DxWfTaskContext) wfTaskContext.get("context");
// SearchQueryCondition queryCondition = SearchUtil.buildQueryWithOpenAttr("id", SearchItem.Operator.EQ, extInterfaceVO.getId(), "objFileLinks.target");
// DxPageImpl<ExtInterfaceVO> recursion = extInterfaceService.findRecursion(queryCondition);
// extInterfaceVO = recursion.getContent().get(0);
// //TODO 申请内容节点信息
// ExtApplicantVO applicantVO = (ExtApplicantVO) extApplicantService.get(extInterfaceVO.getExtApplicantId());
// Map<String, String> taskMap = ExtWfcUtil.getProcessTeam(ExtApplicantVO.class, applicantVO.getVersionId(), SignConstants.SignNodeMap);
// //TODO 接口单接点信息
// Map<String, String> interFaceMap = ExtWfcUtil.getProcessTeam(ExtInterfaceVO.class, extInterfaceVO.getVersionId(), SignConstants.InterfaceSignNodeMap);
// if (MapUtils.isNotEmpty(interFaceMap)){
// taskMap.putAll(interFaceMap);
// }
//TODO 将签字后的pdf挂到接口单上面
// PapersVO papersVO = ObjFileLinkUtil.getAppointTypeFile(extInterfaceVO, Constants.MASTER_FILE).get(0);
// String temDir = DxFileUtils.createRandomTemp("interface");
// String interFacePath = downPaperToLocal(papersVO, temDir);
// String interSignPath = temDir + "签字_" + papersVO.getOriginalFileName();
// //pdf签字
// PDFUtil.signWord(interFacePath, interSignPath, taskMap);
// FileUtil.rename(new File(interSignPath), papersVO.getOriginalFileName(), true);
// //删除旧文件,增加新文件
// ObjFileLinkUtil.removeFile(extInterfaceVO, Constants.MASTER_FILE);
// papersVO = savePDFToMinio(interFacePath);//上传到minio
// //TODO 附件上传待指定
// ObjFileLinkUtil.addFile(extInterfaceVO, papersVO, Constants.MASTER_FILE);
// extInterfaceService.saveRecursion(extInterfaceVO);
// FileUtils.deleteDirectory(temDir);
}
/**
* 签审对象 关联的接口单 状态置为已终止 (签审对象的终止流程)
*
* @param auditObjectVO
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void autoInterfaceEnd(ExtAuditObjectVO auditObjectVO) {
//TODO
// SearchQueryCondition queryCondition = SearchUtil.buildQueryWithOpenAttr("sourceId", SearchItem.Operator.EQ, auditObjectVO.getId(), "target");
// DxPageImpl<ExtAuditInterfLinkVO> recursion = extAuditInterfLinkService.findRecursion(queryCondition);
// if (CollectionUtil.isNotEmpty(recursion.getContent())) {
// //TODO 设置接口单状态为终止
// List<ExtAuditInterfLinkVO> content = recursion.getContent();
// for (ExtAuditInterfLinkVO linkVO : content) {
// ExtInterfaceVO interfaceVO = linkVO.getTarget();
// extInterfaceService.changeStatus(interfaceVO, Constants.STATUS_END, true);
// }
//
// }
}
/**
* 申请内容走完流程后 自动启动 接口单的流程
*
* @param applicantVO 申请内容
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void startInterFaceFlow(ExtApplicantVO applicantVO) {
//TODO
// applicantVO.setOperator(OperatorType.NO_CHANGE);
// //获取申请内容所关联的提资人
// String providers = applicantVO.getProviders();
// //TODO 组织id 逗号隔开
// String[] split = providers.split(",");
// List<DxOrganizationVO> organizationVOList = new ArrayList<>();
// for (String orgId : split) {
// DxOrganizationVO organizationVO = organizationService.get(Long.valueOf(orgId));
// organizationVOList.add(organizationVO);
//
// }
// String userAccount = applicantVO.getCreator().getAccount();
// try {
// changeUserHelper.switchServiceUser(userAccount);
// for (DxOrganizationVO organizationVO : organizationVOList) {
// ExtInterfaceVO extInterfaceVO = new ExtInterfaceVO();
// //TODO 设置提资人ID 取组织下面 岗位为 主设人 的用户
// Long userId = getUserByOrg(organizationVO);
// extInterfaceVO.setDxClassname(extInterfaceVO.getDxClassname());
// extInterfaceVO.setDxContextId(applicantVO.getDxContextId());
// extInterfaceVO.setExtApplicant(applicantVO);
// extInterfaceVO.setProviderId(userId);
// extInterfaceVO.setExtApplicantId(applicantVO.getId());
// extInterfaceVO.setExtApplicantIdType(applicantVO.getSubTypeName());
// extInterfaceVO.setApplicatDate(applicantVO.getSubmitDate());
// extInterfaceVO.setOperator(OperatorType.ADD);
// organizationVO.setOperator(OperatorType.NO_CHANGE);
// extInterfaceVO.setProviderOrg(organizationVO);
// extInterfaceVO.setApplicantOrg(organizationVO);
// extInterfaceVO.setApplicantOrgId(applicantVO.getApplicantOrgId());
// extInterfaceVO.setApplicantOrgIdType(applicantVO.getApplicantOrgIdType());
// extInterfaceVO = (ExtInterfaceVO) extInterfaceService.saveRecursion(extInterfaceVO);
//
// //TODO 手动启动流程
// DxWfProcessStartVO startVO = new DxWfProcessStartVO();
// startVO.setBusinessObject(extInterfaceVO);
// startVO.setProcessDefKey("ExtInterface");
// startVO.setBusinessService(extInterfaceVO.getDxClassname());
// startVO.setBusinessObjectId(String.valueOf(extInterfaceVO.getId()));
// startVO.setUserId(applicantVO.getCreator().getUserId().toString());
//
// Map<String, Object> var = new HashMap<>();
// DxWfTaskPerformerVO taskPerformerVO = new DxWfTaskPerformerVO();
// List<String> userIdList = new ArrayList<>();
// // 此处放入任务接收人id
// userIdList.add(String.valueOf(userId));
// taskPerformerVO.setPerformers(userIdList);
//
// var.put("taskPerformer", JsonUtils.toJsonStr(taskPerformerVO));
// startVO.setProcessVar(var);
// //TODO 手动启动流程
// dexWorkFlowService.startProcessWithVar(startVO);
// //废弃版
// //dexWorkFlowService.startProcessByKey("ExtInterface", extInterfaceVO);
// }
//
// } catch (Exception e) {
// throw new DxBusinessException("-1 切换用户失败", e.getMessage());
// } finally {
// changeUserHelper.closeSwitchUser();
// }
}
/**
* 接口单 走完流程后 根据属性 applicantConfirm 申请方确认:待补充、不接受 重新创建启动流程
*
* @param extInterfaceVO
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void startAddInterFaceFlow(ExtInterfaceVO extInterfaceVO) {
//TODO
// String userAccount = extInterfaceVO.getCreator().getAccount();
// try {
// changeUserHelper.switchServiceUser(userAccount);
// //若申请方确认 属性值 不为 关闭,则需要重新启动流程
// ExtInterfaceVO newInterFace = new ExtInterfaceVO();
// //TODO 接口单编号规则 需要用到申请内容,需要把申请内容对象塞进去
// ExtApplicantVO applicantVO = (ExtApplicantVO) extApplicantService.get(extInterfaceVO.getExtApplicantId());
// applicantVO.setOperator(OperatorType.NO_CHANGE);
// newInterFace.setPreviousId(extInterfaceVO.getId());
// newInterFace.setDxContextId(applicantVO.getDxContextId());
// newInterFace.setProviderId(extInterfaceVO.getProviderId());
// newInterFace.setProviderIdType(extInterfaceVO.getProviderIdType());
// newInterFace.setApplicatDate(extInterfaceVO.getApplicatDate());
// newInterFace.setProvideContent(extInterfaceVO.getProvideContent());
// newInterFace.setDynamicAttrs(extInterfaceVO.getDynamicAttrs());
// //TODO 初始化规则需要知道提资方
// OrganizationVO organizationVO = organizationService.get(extInterfaceVO.getProviderOrgId());
// organizationVO.setOperator(OperatorType.NO_CHANGE);
// newInterFace.setProviderOrg(organizationVO);
// newInterFace.setProviderOrgId(extInterfaceVO.getProviderOrgId());
// newInterFace.setProviderOrgIdType(extInterfaceVO.getProviderOrgIdType());
// newInterFace.setApplicantOrgId(extInterfaceVO.getApplicantOrgId());
// newInterFace.setApplicantOrgIdType(extInterfaceVO.getApplicantOrgIdType());
// //TODO 编号和名称待定 后续需要确认 是否能按初始化规则生成
// newInterFace.setExtApplicant(applicantVO);
// newInterFace.setOperator(OperatorType.ADD);
// newInterFace = (ExtInterfaceVO) extInterfaceService.saveRecursion(newInterFace);
//
// //TODO 手动启动流程
// DxWfProcessStartVO startVO = new DxWfProcessStartVO();
// startVO.setBusinessObject(newInterFace);
// startVO.setProcessDefKey("ExtInterface");
// startVO.setBusinessService(newInterFace.getDxClassname());
// startVO.setBusinessObjectId(String.valueOf(newInterFace.getId()));
// startVO.setUserId(extInterfaceVO.getCreator().getUserId().toString());
//
// Map<String, Object> var = new HashMap<>();
// DxWfTaskPerformerVO taskPerformerVO = new DxWfTaskPerformerVO();
// List<String> userIdList = new ArrayList<>();
// // 此处放入任务接收人id
//// Long userId = getUserByOrgId(extInterfaceVO.getProviderOrgId());
// Long userId = extInterfaceVO.getProviderId();
// userIdList.add(String.valueOf(userId));
// taskPerformerVO.setPerformers(userIdList);
//
// var.put("taskPerformer", JsonUtils.toJsonStr(taskPerformerVO));
// startVO.setProcessVar(var);
// //TODO 手动启动流程
// dexWorkFlowService.startProcessWithVar(startVO);
// } catch (Exception e) {
// throw new DxBusinessException("-1 切换用户失败", e.getMessage());
// } finally {
// changeUserHelper.closeSwitchUser();
// }
}
/**
* 签审对象 扫描所有提资单 并更新状态
* @param extInterfaceVO
*/
@Override
public void stopAllExtApplicantFaceFlow(ExtInterfaceVO extInterfaceVO) {
SearchQueryCondition condition = SearchQueryCondition.builder()
.openProp(SearchQueryCondition.builder().name("extInterfaces").build())
.searchItems(SearchItems.builder()
.item(new SearchItem("id", SearchItem.Operator.EQ, extInterfaceVO.getExtApplicantId(), null)).build()).build();
List<ExtApplicantVO> recursions = extApplicantService.findRecursion(condition).getContent();
if(!CollectionUtil.isEmpty(recursions)){
Optional<ExtApplicantVO> first = recursions.stream().findFirst();
List<ExtInterfaceVO> extInterfaces = first.get().getExtInterfaces();
List<ExtInterfaceVO> collect = extInterfaces.stream().filter(recursion -> Constants.PBULISHED.equals(recursion.getState()) && "gb".equals(recursion.getApplicantConfirm())).collect(Collectors.toList());
if(!CollectionUtil.isEmpty(collect)&&!CollectionUtil.isEmpty(extInterfaces)){
if(extInterfaces.size()==collect.size()){
//TODO 申请内容关联的多个内部接口单 状态全部为“已发布(关闭)”后,应该自动将申请内容状态置为“全部关闭”
//TODO extApplicantService.changeStatus(first.get(),Constants.CLOSE_ALL,true);
// extApplicantService.changeStatus(first.get(),Constants.OBSOLETE,true);
}
}
}
}
}
package com.yonde.dcs.core.util;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.map.MapUtil;
import com.yonde.dcs.core.constants.SignConstants;
import com.yonde.dex.dao.service.util.ApplicationContextUtil;
import com.yonde.dex.wfc.common.vo.DxWfProcessInfoVO;
import com.yonde.dex.wfc.common.vo.DxWfProcessTaskVO;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.client.utils.CloneUtils;
import org.springframework.data.domain.Page;
import org.springframework.util.CollectionUtils;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* @author wyy
* @date 2023-2-10 16:00
* @describe
*/
@Slf4j
public class ExtWfcUtil {
/**
* 根据 versionId + 类型 获取当前版本流程参与者的信息
*
* @param clsObj
* @param versionId
* @param signMap 签字节点需要搜索的签字节点,可为空
* @return
*/
public static Map<String, String> getProcessTeam(Class clsObj, Long versionId, HashMap<String, String> signMap) {
//TODO
// IInstanceService processService = ApplicationContextUtil.getBean(IInstanceService.class);
// WfProcessInstSearchVO searchVO = new WfProcessInstSearchVO();
// searchVO.setPboId(versionId);
// searchVO.setPboClass(clsObj.getCanonicalName());
// Page<WfProcessInstVO> processList = processService.getProcessInstList(searchVO, 1, 100);
// if (Objects.isNull(processList) || CollectionUtils.isEmpty(processList.getContent())) {
// log.error("[EXT流程]:根据pbo的versionId和cls类型未获取到团队成员:{}", versionId + clsObj.getCanonicalName());
// return new HashMap<>();
// }
// WfProcessInstVO dxWfProcessVO = processList.getContent().get(0);
// String instId = dxWfProcessVO.getId();
// return getTaskParticipants(instId, clsObj, signMap);
return null;
}
/**
* 获取 提资人
*
* @param clsObj
* @param versionId
* @return
*/
public static Long getProcessTiZiId(Class clsObj, Long versionId) {
//TODO
// IInstanceService processService = ApplicationContextUtil.getBean(IInstanceService.class);
// WfProcessInstSearchVO searchVO = new WfProcessInstSearchVO();
// searchVO.setPboId(versionId);
// searchVO.setPboClass(clsObj.getCanonicalName());
// Page<WfProcessInstVO> processList = processService.getProcessInstList(searchVO, 1, 100);
// if (Objects.isNull(processList) || CollectionUtils.isEmpty(processList.getContent())) {
// log.error("[EXT流程]:根据pbo的versionId和cls类型未获取到团队成员:{}", versionId + clsObj.getCanonicalName());
// return null;
// }
// WfProcessInstVO dxWfProcessVO = processList.getContent().get(0);
// String instId = dxWfProcessVO.getId();
// DexWorkFlowService dexWorkFlowService = ApplicationContextUtil.getBean(DexWorkFlowService.class);
// DxWfProcessInfoVO wfProcessInfoVO = dexWorkFlowService.getProcessInstSimpleDetailById(instId);
// List<DxWfProcessTaskVO> activities = wfProcessInfoVO.getHistoryInfo();
// DxWfProcessTaskVO resolver = activities.stream()
// .filter(wfProcessTaskVO -> wfProcessTaskVO.getName().equals("提资中") && ("通过".equals(wfProcessTaskVO.getResult()) || "提交审阅".equals(wfProcessTaskVO.getResult()) || "提交签审".equalsIgnoreCase(wfProcessTaskVO.getResult()))).findFirst().orElse(null);
// return Long.valueOf(resolver.getAssignee());
return null;
}
/**
* 获取流程参与者
*
* @param processId
* @param clsObj
* @return
*/
@SneakyThrows
public static Map<String, String> getTaskParticipants(String processId, Class clsObj, HashMap<String, String> signMap) {
//TODO
// Map<String, String> data = new HashMap<>();
// DexWorkFlowService dexWorkFlowService = ApplicationContextUtil.getBean(DexWorkFlowService.class);
// DxWfProcessInfoVO wfProcessInfoVO = dexWorkFlowService.getProcessInstSimpleDetailById(processId);
// List<DxWfProcessTaskVO> activities = wfProcessInfoVO.getHistoryInfo();
// String dateStr = "";
// if (MapUtil.isEmpty(signMap)) {
// signMap = CloneUtils.cloneObject(SignConstants.SignNodeMap);
// }
// for (Map.Entry<String, String> entry : signMap.entrySet()) {
// dateStr = new StringBuffer(entry.getValue()).reverse().toString();
// //节点参与人
// data.put(entry.getValue(), getResolverName(activities, entry.getKey()));
// //节点时间
// data.put(dateStr, getResolverData(activities, entry.getKey()));
// }
// data.entrySet().removeIf(o -> org.springframework.util.StringUtils.isEmpty(o.getValue()));
// return data;
return null;
}
/**
* 获取某个环节执行者
*
* @param activities
* @param activityName
* @return
*/
public static String getResolverName(List<DxWfProcessTaskVO> activities, String activityName) {
DxWfProcessTaskVO resolver = getResolver(activities, activityName);
if (Objects.isNull(resolver)) {
return null;
}
//获取用户的id resolver.getAssigneeName() 用户的名称
//Long userId = Long.valueOf(resolver.getAssignee());
return resolver.getAssigneeName();
}
/**
* 得到环节信息
*
* @param activities
* @param activityName
* @return
*/
public static DxWfProcessTaskVO getResolver(List<DxWfProcessTaskVO> activities, String activityName) {
DxWfProcessTaskVO resolver = activities.stream()
.filter(wfProcessTaskVO -> wfProcessTaskVO.getName().equals(activityName) && ("通过".equals(wfProcessTaskVO.getResult()) || "提交审阅".equals(wfProcessTaskVO.getResult()) || "提交签审".equalsIgnoreCase(wfProcessTaskVO.getResult()))).findFirst().orElse(null);
return resolver;
}
/**
* 获取某个环节的结束时间
*
* @param activities
* @param activityName
* @return
*/
public static String getResolverData(List<DxWfProcessTaskVO> activities, String activityName) {
DxWfProcessTaskVO resolver = getResolver(activities, activityName);
SimpleDateFormat dateFm = new SimpleDateFormat("yyyy-MM-dd");
if (Objects.isNull(resolver)) {
return null;
}
Date endTime = resolver.getEndTime();
if (Objects.isNull(endTime)) {
endTime = new DateTime();
}
return dateFm.format(endTime).replace("-", ".");
}
}
package com.yonde.dcs.core.util;
import com.yonde.dex.basedata.entity.data.OperatorType;
import com.yonde.dex.basedata.entity.vo.IdVO;
import com.yonde.dex.dfs.handler.ContentHolder;
import com.yonde.dex.dfs.vo.ObjFileLinkVO;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* @author wyy
* @version 1.0
* @description:
* @date 2021/7/12 10:28
*/
public class ObjFileLinkUtil {
public static <T extends IdVO & ContentHolder> void removeAllFile(T holder) {
if (!CollectionUtils.isEmpty(((ContentHolder) holder).getObjFileLinks())) {
List<ObjFileLinkVO> fileLinkVos = (List) ((ContentHolder) holder).getObjFileLinks();
if (!CollectionUtils.isEmpty(fileLinkVos)) {
for (ObjFileLinkVO fileLinkVo : fileLinkVos) {
fileLinkVo.setOperator(OperatorType.REMOVE);
}
}
}
}
/**
* 移除pdf文件
*
* @param holder
* @param fileVO
* @param fileType
* @param <T>
*/
// public static <T extends IdVO & ContentHolder> void replaceFile(T holder, PapersVO fileVO, String fileType) {
// removeFile(holder, fileType);
// addFile(holder, fileVO, fileType);
// }
//
// public static <T extends IdVO & ContentHolder> void addFile(T holder, PapersVO fileVO, String fileType) {
// if (CollectionUtils.isEmpty(((ContentHolder)holder).getObjFileLinks())) {
// ((ContentHolder)holder).setObjFileLinks(new ArrayList());
// }
//
// ObjFileLinkVO linkVo = new ObjFileLinkVO();
// linkVo.setTarget(fileVO);
// linkVo.setOperator(OperatorType.ADD);
// linkVo.setContentType(fileType);
// ((ContentHolder)holder).getObjFileLinks().add(linkVo);
// }
/**
* 删除指定的文件
* @param holder
* @param fileName
* @param fileType
* @param <T>
*/
public static <T extends IdVO & ContentHolder> void deleteFileByName(T holder, String fileName, String fileType) {
if (!CollectionUtils.isEmpty(((ContentHolder)holder).getObjFileLinks())) {
List<ObjFileLinkVO> fileLinkVos = (List)((ContentHolder)holder).getObjFileLinks().stream().filter((m) -> {
return fileType.equalsIgnoreCase(m.getContentType());
}).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(fileLinkVos)) {
for (ObjFileLinkVO fileLinkVo : fileLinkVos) {
if (fileName.equals(fileLinkVo.getTarget().getOriginalFileName())){
fileLinkVo.setOperator(OperatorType.REMOVE);
}
}
}
}
}
/**
* 模糊 删除指定的文件
* @param holder
* @param fileName
* @param fileType
* @param <T>
*/
public static <T extends IdVO & ContentHolder> void deleteFileByLikeName(T holder, String fileName, String fileType) {
if (!CollectionUtils.isEmpty(((ContentHolder)holder).getObjFileLinks())) {
List<ObjFileLinkVO> fileLinkVos = (List)((ContentHolder)holder).getObjFileLinks().stream().filter((m) -> {
return fileType.equalsIgnoreCase(m.getContentType());
}).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(fileLinkVos)) {
for (ObjFileLinkVO fileLinkVo : fileLinkVos) {
if (!fileLinkVo.getTarget().getOriginalFileName().contains("签字_")){ //签字文件不删除
if (fileLinkVo.getTarget().getOriginalFileName().contains(fileName)){
fileLinkVo.setOperator(OperatorType.REMOVE);
}
}
}
}
}
}
public static <T extends IdVO & ContentHolder> void removeFile(T holder, String fileType) {
if (!CollectionUtils.isEmpty(((ContentHolder)holder).getObjFileLinks())) {
List<ObjFileLinkVO> fileLinkVos = (List)((ContentHolder)holder).getObjFileLinks().stream().filter((m) -> {
return fileType.equalsIgnoreCase(m.getContentType());
}).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(fileLinkVos)) {
Iterator var3 = fileLinkVos.iterator();
while (var3.hasNext()) {
ObjFileLinkVO linkVo = (ObjFileLinkVO) var3.next();
linkVo.setOperator(OperatorType.REMOVE);
}
}
}
}
public static <T extends IdVO & ContentHolder> void removeFileByFileName(T holder, String fileName) {
if (!CollectionUtils.isEmpty(((ContentHolder) holder).getObjFileLinks())) {
List<ObjFileLinkVO> fileLinkVos = (List) ((ContentHolder) holder).getObjFileLinks();
if (!CollectionUtils.isEmpty(fileLinkVos)) {
for (ObjFileLinkVO fileLinkVo : fileLinkVos) {
if (fileLinkVo.getTarget().getOriginalFileName().equals(fileName)) {
fileLinkVo.setOperator(OperatorType.REMOVE);
}
}
}
}
}
/**
* 获取对象指定 类型的file
*
* @param holder
* @param fileType
* @param <T>
* @return
*/
// public static <T extends IdVO & ContentHolder> List<PapersVO> getAppointTypeFile(T holder, String fileType) {
// if (!Objects.isNull(holder) && !CollectionUtils.isEmpty(((ContentHolder) holder).getObjFileLinks())) {
// List<ObjFileLinkVO> fileLinkVOList = holder.getObjFileLinks().stream().filter(o -> o.getContentType().equalsIgnoreCase(fileType)).collect(Collectors.toList());
// if (!CollectionUtils.isEmpty(fileLinkVOList)) {
// return fileLinkVOList.stream().map(ObjFileLinkVO::getTarget).collect(Collectors.toList());
// }
// }
// return null;
// }
/**
* 获取对象指定 类型的file
*
* @param holder
* @param fileType
* @param <T>
* @return
*/
// public static <T extends IdVO & ContentHolder> List<PapersVO> getAppointNameFile(T holder, String fileType, String fileLikeName) {
// if (!Objects.isNull(holder) && !CollectionUtils.isEmpty(((ContentHolder) holder).getObjFileLinks())) {
// List<ObjFileLinkVO> fileLinkVOList = holder.getObjFileLinks().stream().filter(o -> o.getContentType().equalsIgnoreCase(fileType)).collect(Collectors.toList());
// if (!CollectionUtils.isEmpty(fileLinkVOList)) {
// return fileLinkVOList.stream().map(ObjFileLinkVO::getTarget).filter(o -> o.getOriginalFileName().contains(fileLikeName)).collect(Collectors.toList());
// }
// }
// return null;
// }
}
package com.yonde.dcs.core.util;
import com.itextpdf.io.image.ImageData;
import com.itextpdf.io.image.ImageDataFactory;
import com.itextpdf.kernel.colors.ColorConstants;
import com.itextpdf.kernel.font.PdfFont;
import com.itextpdf.kernel.font.PdfFontFactory;
import com.itextpdf.kernel.geom.Rectangle;
import com.itextpdf.kernel.pdf.canvas.PdfCanvas;
import com.itextpdf.kernel.pdf.canvas.parser.PdfCanvasProcessor;
import com.itextpdf.kernel.pdf.canvas.parser.listener.IPdfTextLocation;
import com.itextpdf.kernel.pdf.canvas.parser.listener.RegexBasedLocationExtractionStrategy;
import com.itextpdf.kernel.pdf.xobject.PdfImageXObject;
import com.itextpdf.text.*;
import com.itextpdf.text.pdf.*;
import com.yonde.dex.basedata.exception.DxBusinessException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.CollectionUtils;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.*;
import java.util.List;
/**
* @author wyy
* @version 1.0
* @description:
* @date 2022/2/11 16:14
*/
@Slf4j
public class PDFUtil {
/**
*
* @param sourcePath
* @param targetPath
* @param flagMap
* @throws IOException
*/
public static void sign(String sourcePath, String targetPath,
Map<String, String> flagMap
) throws IOException {
Map<String, String> wordMap = new HashMap<>();
Map<String, String> imageMap = new HashMap<>();
for (Map.Entry<String, String> entry : flagMap.entrySet()) {
if (entry.getValue().contains(".png")){
imageMap.put(entry.getKey(), entry.getValue());
}else {
wordMap.put(entry.getKey(), entry.getValue());
}
}
String temPath = sourcePath.substring(0, sourcePath.lastIndexOf("/") + 1) + UUID.randomUUID().toString().replace("-", "") + ".pdf";
//签文字
signWord(sourcePath, temPath, wordMap);
//签图片
signImage(temPath, targetPath, imageMap);
}
/**
* pdf签图片 或者替换文字
* @param sourcePath 原pdf路径
* @param targetPath 签后pdf路径
* @param flagMap key:关键字(占位符) value:图片路径
// * @param xOffSet x轴偏移量 (正数:图片向右移动, 负数:图片向左移动)
// * @param yOffset y轴偏移量 (正数:图片向右移动, 负数:图片向左移动)
* @throws IOException
*/
public static void signImage(String sourcePath, String targetPath,
Map<String, String> flagMap){
com.itextpdf.kernel.pdf.PdfDocument pdfDocument = null;
Rectangle rectangle = null;
ImageData imageData = null;
PdfImageXObject imageXObject = null;
PdfCanvas canvas = null;
com.itextpdf.kernel.pdf.PdfPage page = null;
RegexBasedLocationExtractionStrategy strategy = null;
PdfCanvasProcessor canvasProcessor = null;
try {
pdfDocument = new com.itextpdf.kernel.pdf.PdfDocument(new com.itextpdf.kernel.pdf.PdfReader(sourcePath), new com.itextpdf.kernel.pdf.PdfWriter(targetPath));
} catch (IOException e) {
throw new DxBusinessException("500", "pdf路径错误,原路径:" + sourcePath + ",目标路径:" + targetPath);
}
for (int i = 0; i < pdfDocument.getNumberOfPages(); i++) {
for (Map.Entry<String, String> entry : flagMap.entrySet()) {
//获取每一页,从第1页(下标为1)开始
page = pdfDocument.getPage(i+1);
//找出关键字坐标
strategy = new RegexBasedLocationExtractionStrategy(entry.getKey());
canvasProcessor = new PdfCanvasProcessor(strategy);
canvasProcessor.processPageContent(page);
Collection<IPdfTextLocation> resultantLocations = strategy.getResultantLocations();
//签图片
canvas = new PdfCanvas(pdfDocument.getPage(i + 1));
canvas.saveState();
canvas.setFillColor(ColorConstants.WHITE);
for (IPdfTextLocation location : resultantLocations) {
rectangle = location.getRectangle();
//TODO 设置图片的位置 + 宽高
// rectangle.setWidth(width);
// rectangle.setHeight(height);
// rectangle.setX(rectangle.getX() + xOffSet);
// rectangle.setY(rectangle.getY() + yOffset);
//读取并添加图片到指定位置
try {
imageData = ImageDataFactory.create(entry.getValue());
} catch (MalformedURLException e) {
throw new DxBusinessException("500", "待签名图片路径错误:" + entry.getValue());
}
imageXObject = new PdfImageXObject(imageData);
canvas.addXObject(imageXObject, rectangle);
//收尾步骤,关闭画布和pdf,否则pdf打开错误
canvas.release();
}
}
}
pdfDocument.close();
}
/**
* 签文字
*
* @param sourcePath
* @param targetPath
* @param flagMap
* @throws IOException
*/
public static void signWord(String sourcePath, String targetPath, Map<String, String> flagMap) throws IOException {
com.itextpdf.kernel.pdf.PdfDocument pdfDocument = null;
Rectangle rectangle = null;
PdfCanvas canvas = null;
com.itextpdf.kernel.pdf.PdfPage page = null;
float fontSize = 4;
try {
pdfDocument = new com.itextpdf.kernel.pdf.PdfDocument(new com.itextpdf.kernel.pdf.PdfReader(sourcePath), new com.itextpdf.kernel.pdf.PdfWriter(targetPath));
} catch (IOException e) {
throw new DxBusinessException("500", "pdf路径错误,原路径:" + sourcePath + ",目标路径:" + targetPath);
}
for (int i = 0; i < pdfDocument.getNumberOfPages(); i++) {
Map<String, List<Rectangle>> rectangleMap = new HashMap<>();
page = pdfDocument.getPage(i + 1);
//TODO 记录坐标信息, key为占位符
for (Map.Entry<String, String> entry : flagMap.entrySet()) {
rectangleMap.put(entry.getKey(), getWordRectangle(entry.getKey(), page));
}
canvas = new PdfCanvas(page);
//写文本
for (Map.Entry<String, List<Rectangle>> entry : rectangleMap.entrySet()) {
if (CollectionUtils.isEmpty(entry.getValue())){
continue;
}
rectangle = entry.getValue().get(0);
//改变背景色
canvas.saveState();
canvas.setFillColor(ColorConstants.WHITE);
canvas.rectangle(rectangle);
canvas.fill();
canvas.restoreState();
//新文本
canvas.beginText();
//TODO 解决中文字体显示问题
PdfFont font = PdfFontFactory.createFont("STSong-Light", "UniGB-UCS2-H",true);
//设置字体和大小
fontSize = getFontSize(font, flagMap.get(entry.getKey()), rectangle.getWidth());
canvas.setFontAndSize(font, fontSize);
//设置字体的输出位置
canvas.setTextMatrix(rectangle.getX(), rectangle.getY());
//要输出的text
canvas.showText(flagMap.get(entry.getKey()));
canvas.endText();
}
}
pdfDocument.close();
}
/**
* 获取合适的文字大小
* @param font
* @param text
* @param width
* @return
*/
public static float getFontSize(PdfFont font, String text, Float width){
//TODO 日期占位符是BKBS四个字符,显示是2022.01.02 所以占位符的宽度乘以2
width = width * 2;
float fontSize = 4;
while (font.getWidth(text, fontSize) <= width){
fontSize = fontSize + 1;
}
return fontSize - 1;
}
/**
* 获取关键字再这一页的坐标
* @param word
* @param page
* @return
*/
public static List<Rectangle> getWordRectangle(String word, com.itextpdf.kernel.pdf.PdfPage page){
List<Rectangle> rectangleList = new ArrayList<>();
//找出关键字坐标
RegexBasedLocationExtractionStrategy strategy = new RegexBasedLocationExtractionStrategy(word);
PdfCanvasProcessor canvasProcessor = new PdfCanvasProcessor(strategy);
canvasProcessor.processPageContent(page);
Collection<IPdfTextLocation> resultantLocations = strategy.getResultantLocations();
for (IPdfTextLocation location : resultantLocations) {
rectangleList.add(location.getRectangle());
}
return rectangleList;
}
/**
* 合并pdf
* @param fileList 文件路径
* @param savePath 合并后的文件路径
* @param addPageNumber 是否在底部加页码
* @param indexAddPageNumber 首页是否加页码
*/
public static void mergePdf(List<String> fileList, String savePath, boolean addPageNumber, boolean indexAddPageNumber) {
//为空不进行处理
if (CollectionUtils.isEmpty(fileList)){
return;
}
try {
PdfReader pdfReader = new PdfReader(fileList.get(0));
com.itextpdf.text.Rectangle pageSize = pdfReader.getPageSize(1);
Document document = new Document(pageSize);
PdfCopy copy = new PdfCopy(document, new FileOutputStream(savePath));
document.open();
//插入页数
PdfCopy.PageStamp stamp;//插入页码所需 不要页码可删除
int pageNumber = 0;
float width = document.getPageSize().getWidth();
float height = document.getPageSize().getHeight();
float x = width/2; //x坐标
float y = (float) (height * 0.05); //y坐标
Paragraph paragraph = indexAddPageNumber?setFooter("1"):setFooter("");//首页页码是否添加
for (int i = 0; i < fileList.size(); i++) {
PdfReader reader = new PdfReader(fileList.get(i));
int n = reader.getNumberOfPages();
for (int j = 1; j <= n; j++) {
document.newPage();
PdfImportedPage page = copy.getImportedPage(reader, j);
if (addPageNumber){
pageNumber = pageNumber + 1;
//设置pdf页数,首页不设置
stamp=copy.createPageStamp(page);//插入页码所需 不要页码可删除
ColumnText.showTextAligned(stamp.getUnderContent(), Element.ALIGN_CENTER, paragraph,x,y,0f);//插入页码所需 不要页码可删除
stamp.alterContents();//插入页码所需 不要页码可删除
paragraph = setFooter(String.valueOf(pageNumber));
}
copy.addPage(page);
}
reader.close();
}
pdfReader.close();
copy.close();
document.close();
} catch (IOException e) {
e.printStackTrace();
} catch (DocumentException e) {
e.printStackTrace();
}
log.info(">>> 工艺计划 >>> 合并pdf文件成功,待合并文件:{},合并完成文件:{}", fileList, savePath);
}
/**
* 设置页脚
* @param index
* @return
* @throws IOException
* @throws DocumentException
*/
private static Paragraph setFooter(String index) throws IOException, DocumentException {
// 这个字体是itext-asian.jar中自带的 所以不用考虑操作系统环境问题.
BaseFont bf = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", false);
// baseFont不支持字体样式设定.但是font字体要求操作系统支持此字体会带来移植问题.
Font font = new Font(bf, 10);
font.setStyle(Font.BOLD);
font.getBaseFont();
Paragraph paragraph = new Paragraph(index, font);
paragraph.setAlignment(Element.ALIGN_LEFT);
return paragraph;
}
}
package com.yonde.dcs.core.util;
import com.yonde.dex.basedata.data.search.SearchItem;
import com.yonde.dex.basedata.data.search.SearchQueryBuilder;
import com.yonde.dex.basedata.data.search.SearchQueryCondition;
public class SearchUtil {
/**
* 构建查询条件
*
* @param key
* @param value
* @return
*/
public static SearchQueryCondition buildQuery(String key, SearchItem.Operator operator, Object value) {
return SearchQueryBuilder.openBuild()
.openFilterBuilder()
.setItem(key, operator, value)
.builder().build();
}
/**
* 构建带扩展属性的查询条件
*
* @param key
* @param value
* @param openAttr
* @return
*/
public static SearchQueryCondition buildQueryWithOpenAttr(String key, SearchItem.Operator operator, Object value, String openAttr) {
return SearchQueryBuilder.openBuild()
.setPropName(openAttr)
.openFilterBuilder()
.setItem(key, operator, value)
.builder().build();
}
}
package com.yonde.dcs.feign;
import com.yonde.dcs.common.vo.ExtApplicantVO;
import com.yonde.dcs.common.vo.ExtAuditObjectVO;
import com.yonde.dcs.common.vo.ExtInterfaceVO;
import com.yonde.dcs.document.common.entity.vo.DxDocumentVO;
import com.yonde.dcs.plan.common.vo.ExtPlanVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.Map;
/**
* @description: ExtApplicant-Feign
* @author: dexadmin
* @version: V
* @date: 2024-8-2 15:26:37
**/
@Api(tags = "ExtAutoTask-FEIGN")
@FeignClient(value = "${dcs.feign.DCS-DOC}", path = "/task")
public interface ExtAutoTaskServiceFeign {
@ApiOperation(value = "客户化文档修改状态", notes = "客户化文档修改状态", httpMethod = "PUT")
@PutMapping(value = "/extChangeDocState")
void extChangeDocState(@RequestBody DxDocumentVO documentVO, @RequestParam(name = "state") String state);
@ApiOperation(value = "给选择的提资方人员发放通知", notes = "给选择的提资方人员发放通知", httpMethod = "POST")
@PostMapping(value = "/informativeUser")
void informativeUser(@RequestBody DxDocumentVO documentVO, @RequestParam("userId") String userId);
@ApiOperation(value = "设置提资审核", notes = "设置提资审核", httpMethod = "POST")
@PostMapping(value = "/extSetProcessVariable")
void extSetProcessVariable(Map<String, Object> taskParticipant,
@RequestParam("processInstId") String processInstId,
@RequestParam("key") String key,
Object value);
@ApiOperation(value = "设置提资人变量", notes = "设置提资人变量", httpMethod = "POST")
@PostMapping(value = "/setInformativeUser")
void setInformativeUser(@RequestParam("processInstId") String processInstId,
@RequestParam("varKey") String varKey,
@RequestParam("informativeUser") String informativeUser);
@ApiOperation(value = "自动发送联系单", notes = "自动发送联系单", httpMethod = "POST")
@PostMapping(value = "/sendContractDoc")
void sendContractDoc(@RequestBody DxDocumentVO documentVO, @RequestParam("contractName") String contractName);
@ApiOperation(value = "创建过时文件通知单", notes = "创建过时文件通知单", httpMethod = "POST")
@PostMapping(value = "/createDocNotify")
void createDocNotify(@RequestBody DxDocumentVO documentVO);
@ApiOperation(value = "设置编制节点人员回显事件", notes = "设置编制节点人员回显事件", httpMethod = "POST")
@PostMapping(value = "/setProcessSelectionInfo")
void setProcessSelectionInfo(@RequestParam("taskId") String taskId, @RequestBody DxDocumentVO documentVO);
@ApiOperation(value = "任务完成后更新pbo属性,驳回操作,设置编制节点人员回显", notes = "任务完成后更新pbo属性,驳回操作,设置编制节点人员回显", httpMethod = "POST")
@PostMapping(value = "/getProcessSelectionInfo")
void getProcessSelectionInfo(@RequestParam("taskId") String taskId, @RequestBody DxDocumentVO documentVO);
@ApiOperation(value = "计划生命周期事件", notes = "计划生命周期事件", httpMethod = "POST")
@PostMapping(value = "/pressPlanInfo")
void pressPlanInfo(@RequestBody ExtPlanVO extPlanVO) throws Exception;
@ApiOperation(value = "内部接口-生成提资信息word", notes = "内部接口-生成提资信息word", httpMethod = "POST")
@PostMapping(value = "/generateInformationWord")
void generateInformationWord(@RequestBody DxDocumentVO documentVO);
@ApiOperation(value = "生成NCR审查单word", notes = "生成NCR审查单word", httpMethod = "POST")
@PostMapping(value = "/generateNcrReviewWord")
void generateNcrReviewWord(@RequestBody DxDocumentVO documentVO, Map<String, Object> wfTaskContext);
@ApiOperation(value = "生成word签字", notes = "生成word签字", httpMethod = "POST")
@PostMapping(value = "/generateDocWordSign")
void generateDocWordSign(@RequestBody DxDocumentVO documentVO, Map<String, Object> wfTaskContext, @RequestParam("fileName") String fileName);
@ApiOperation(value = "内部接口-保存内部接口信息的总体室、审核签审信息值", notes = "内部接口-保存内部接口信息的总体室、审核签审信息值", httpMethod = "POST")
@PostMapping(value = "/savedInterfaceWf")
void savedInterfaceWf(@RequestBody DxDocumentVO documentVO, Map<String, Object> wfTaskContext);
@ApiOperation(value = "自动任务-编制节点后生成word方法", notes = "自动任务-编制节点后生成word方法", httpMethod = "POST")
@PostMapping(value = "/generateWordByAutoMethod")
void generateWordByAutoMethod(@RequestBody DxDocumentVO documentVO);
@ApiOperation(value = "自动任务-校验图册下的图纸是否检入", notes = "自动任务-校验图册下的图纸是否检入", httpMethod = "POST")
@PostMapping(value = "/checkLockerUtil")
void checkLockerUtil(@RequestBody DxDocumentVO documentVO);
@ApiOperation(value = "自动任务-生成QH技术文件签审页", notes = "自动任务-生成QH技术文件签审页", httpMethod = "POST")
@PostMapping(value = "/generateQHTechDoc")
void generateQHTechDoc(@RequestBody DxDocumentVO documentVO, Map<String, Object> wfTaskContext);
//endProcess
@ApiOperation(value = "生成过时文件通知单word", notes = "生成过时文件通知单word", httpMethod = "POST")
@PostMapping(value = "/generateOutdatedDocNotify")
void generateOutdatedDocNotify(@RequestBody DxDocumentVO documentVO);
@ApiOperation(value = "已发布后修改状态已过时", notes = "已发布后修改状态已过时", httpMethod = "POST")
@PostMapping(value = "/changeOldDataState")
void changeOldDataState(@RequestBody DxDocumentVO documentVO);
@ApiOperation(value = "申请内容 签名", notes = "申请内容 签名", httpMethod = "POST")
@PostMapping(value = "/autoApplicantSign")
void autoApplicantSign(@RequestBody ExtApplicantVO applicantVO, Map<String, Object> wfTaskContext);
@ApiOperation(value = "接口单签名", notes = "接口单签名", httpMethod = "POST")
@PostMapping(value = "/autoInterFaceSign")
void autoInterFaceSign(@RequestBody ExtInterfaceVO extInterfaceVO, Map<String, Object> wfTaskContext);
@ApiOperation(value = "签审对象的终止流程", notes = "签审对象的终止流程", httpMethod = "POST")
@PostMapping(value = "/autoInterfaceEnd")
void autoInterfaceEnd(@RequestBody ExtAuditObjectVO auditObjectVO);
@ApiOperation(value = "申请内容走完流程后 自动启动 接口单的流程", notes = "申请内容走完流程后 自动启动 接口单的流程", httpMethod = "POST")
@PostMapping(value = "/startInterFaceFlow")
void startInterFaceFlow(@RequestBody ExtApplicantVO applicantVO);
@ApiOperation(value = "重新创建启动流程", notes = "重新创建启动流程", httpMethod = "POST")
@PostMapping(value = "/startAddInterFaceFlow")
void startAddInterFaceFlow(@RequestBody ExtInterfaceVO extInterfaceVO);
@ApiOperation(value = "签审对象 扫描所有提资单 并更新状态", notes = "签审对象 扫描所有提资单 并更新状态", httpMethod = "POST")
@PostMapping(value = "/stopAllExtApplicantFaceFlow")
void stopAllExtApplicantFaceFlow(@RequestBody ExtInterfaceVO extInterfaceVO);
}
...@@ -92,11 +92,11 @@ ...@@ -92,11 +92,11 @@
<groupId>com.yonde.dex</groupId> <groupId>com.yonde.dex</groupId>
<artifactId>dex-cache-rediscaffeine</artifactId> <artifactId>dex-cache-rediscaffeine</artifactId>
</dependency> </dependency>
<dependency> <!-- <dependency>-->
<groupId>com.yonde.dcs</groupId> <!-- <groupId>com.yonde.dcs</groupId>-->
<artifactId>dcs-doc-autotask-interface</artifactId> <!-- <artifactId>dcs-doc-autotask-interface</artifactId>-->
<version>4.1-RELEASE</version> <!-- <version>4.1-RELEASE</version>-->
</dependency> <!-- </dependency>-->
</dependencies> </dependencies>
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
<module>dcs-doc-expand-server</module> <module>dcs-doc-expand-server</module>
<module>dcs-doc-expand-build-lib</module> <module>dcs-doc-expand-build-lib</module>
<module>dcs-doc-expand-build-thirdLib</module> <module>dcs-doc-expand-build-thirdLib</module>
<module>dcs-doc-autotask-interface</module> <!-- <module>dcs-doc-autotask-interface</module>-->
</modules> </modules>
<properties> <properties>
<java.version>1.8</java.version> <java.version>1.8</java.version>
......
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