Commit 70313efc authored by wei's avatar wei 🎱

查询科研类收入合同

parent 9b6e9463
package com.yonde.dcs.plan.core.controller;
import org.springframework.stereotype.Controller;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import java.util.List;
import com.yonde.dcs.plan.common.vo.ExtInComeContractVO;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Autowired;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;
import com.yonde.dcs.plan.core.controller.shadow.ExtInComeContractControllerShadow;
import com.yonde.dcs.plan.core.service.AutoTaskService;
import com.yonde.dcs.plan.core.service.ExtInComeContractService;
import com.yonde.dex.basedata.entity.api.ApiResult;
import com.yonde.dcs.plan.core.controller.shadow.ExtInComeContractControllerShadow;
import javax.annotation.Resource;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
/**
* @description: ExtInComeContract-Controller
* @author: dexadmin
* @version: V
* @date: 2024-9-24 16:48:58
**/
* @description: ExtInComeContract-Controller
* @author: dexadmin
* @version: V
* @date: 2024-9-24 16:48:58
**/
@Api(tags = "ExtInComeContract管理服务")
@RequestMapping("/ExtInComeContract")
@ResponseBody()
@Controller(ExtInComeContractController.BEAN_NAME)
public class ExtInComeContractController<V extends ExtInComeContractVO, S extends ExtInComeContractService<V>> extends ExtInComeContractControllerShadow<V, S> {
@Autowired
private ExtInComeContractService extInComeContractService;
@Autowired
private AutoTaskService autoTaskService;
@ApiOperation("发起审批流程")
@PostMapping({"startWorkflow"})
public ApiResult startWorkflow(@RequestParam("id") Long id) {
return ApiResult.ok(extInComeContractService.startWorkflow(id), "操作完成");
}
@ApiOperation(value = "生成word签字", notes = "生成word签字", httpMethod = "POST")
@PostMapping(value = "/generateContractWordSign")
public void generateContractWordSign(@RequestParam("documentId") Long contractId,
@RequestParam("fileName") String fileName) {
autoTaskService.generateInComeContractWordSign(contractId, fileName);
}
@ApiOperation("查询科研类收入合同")
@PostMapping({"getResearchCategory"})
public ApiResult getResearchCategory(@RequestParam(value = "subTypeName", defaultValue = "ExtDtIncomeContract") String subTypeName) {
return ApiResult.ok(extInComeContractService.getResearchCategory(subTypeName), "查询成功");
}
}
......@@ -21,4 +21,6 @@ public interface AutoTaskService {
* @param fileName
*/
void generateContractWordSign(Long contractId, String fileName);
void generateInComeContractWordSign(Long contractId, String fileName);
}
......@@ -22,7 +22,7 @@ public interface ExtExpenditureContractService<V extends ExtExpenditureContractV
ExtExpenditureContractVO findExpenditureContractObjFileLinks(Long contractId);
void generateContractWordSign(ExtExpenditureContractVO expenditureContractVO, Class<ContractUtils> contractUtilsClass,
void generateContractWordSign(Object object, Class<ContractUtils> contractUtilsClass,
DxWfProcessInfoVO wfProcessInfoVO, String fileName);
/**
......
......@@ -2,12 +2,20 @@ package com.yonde.dcs.plan.core.service;
import com.yonde.dcs.plan.common.vo.ExtInComeContractVO;
import com.yonde.dcs.plan.core.service.shadow.ExtInComeContractServiceShadow;
import java.util.List;
/**
* @description: ExtInComeContract-service
* @author: dexadmin
* @version: V
* @date: 2024-9-24 16:48:58
**/
* @description: ExtInComeContract-service
* @author: dexadmin
* @version: V
* @date: 2024-9-24 16:48:58
**/
public interface ExtInComeContractService<V extends ExtInComeContractVO> extends ExtInComeContractServiceShadow<V> {
ExtInComeContractVO startWorkflow(Long id);
ExtInComeContractVO findExtInComeContractObjFileLinks(Long contractId);
List<ExtInComeContractVO> getResearchCategory(String subTypeName);
}
package com.yonde.dcs.plan.core.service.impl;
import com.yonde.dcs.plan.common.vo.ExtExpenditureContractVO;
import com.yonde.dcs.plan.common.vo.ExtInComeContractVO;
import com.yonde.dcs.plan.core.factory.ContractUtils;
import com.yonde.dcs.plan.core.service.AutoTaskService;
import com.yonde.dcs.plan.core.service.ExtExpenditureContractService;
import com.yonde.dcs.plan.core.service.ExtInComeContractService;
import com.yonde.dcs.plan.core.service.ExtPlanService;
import com.yonde.dcs.plan.core.util.WorkFlowUtil;
import com.yonde.dex.user.common.vo.DxOrganizationVO;
......@@ -25,7 +27,6 @@ import java.util.List;
@Slf4j
public class AutoTaskServiceImpl implements AutoTaskService {
@Autowired
private ExtPlanService extPlanService;
......@@ -35,6 +36,9 @@ public class AutoTaskServiceImpl implements AutoTaskService {
@Autowired
private ExtExpenditureContractService extExpenditureContractService;
@Autowired
private ExtInComeContractService extInComeContractService;
/**
* 通过userId获取组织名
*
......@@ -61,5 +65,20 @@ public class AutoTaskServiceImpl implements AutoTaskService {
log.info("自动任务======生成word签名完成");
}
@Override
public void generateInComeContractWordSign(Long contractId, String fileName) {
//深度查询展开ObjLink
ExtInComeContractVO extInComeContractVO = extInComeContractService.findExtInComeContractObjFileLinks(contractId);
log.info("自动任务======生成word签名开始");
DxWfProcessVO wfProcessInstVO = workFlowUtil.getWfProcessInst(extInComeContractVO);
DxWfProcessInfoVO wfProcessInfoVO = workFlowUtil.getProcessInstDetail(wfProcessInstVO);
String subTypeName = extInComeContractVO.getSubTypeName();
log.info("自动任务======生成word签名进行中,文档SubTypeName:{}", subTypeName);
extExpenditureContractService.generateContractWordSign(extInComeContractVO, ContractUtils.class, wfProcessInfoVO, fileName);
//保存附件
extExpenditureContractService.saveRecursion(extInComeContractVO);
log.info("自动任务======生成word签名完成");
}
}
......@@ -3,10 +3,12 @@ package com.yonde.dcs.plan.core.service.impl;
import cn.hutool.core.io.FileUtil;
import cn.hutool.extra.spring.SpringUtil;
import com.google.common.collect.Lists;
import com.yonde.dcs.plan.common.constants.Constants;
import com.yonde.dcs.plan.common.constants.SignConstants;
import com.yonde.dcs.plan.common.utils.FileUtils;
import com.yonde.dcs.plan.common.vo.ExtExpenditureContractVO;
import com.yonde.dcs.plan.common.vo.ExtInComeContractVO;
import com.yonde.dcs.plan.core.factory.ContractUtils;
import com.yonde.dcs.plan.core.repository.ExtExpenditureContractRepository;
import com.yonde.dcs.plan.core.service.ExtExpenditureContractService;
......@@ -98,15 +100,31 @@ public class ExtExpenditureContractServiceImpl<V extends ExtExpenditureContractV
return this.changeStatus(extExpenditureContractVO.getId(), "submitReviewing", true);
}
public void generateContractWordSign(ExtExpenditureContractVO expenditureContractVO, Class classType,
public void generateContractWordSign(Object obj, Class classType,
DxWfProcessInfoVO wfProcessInfoVO, String fileName) {
String outFilePath = Constants.MERGER_FILE_ABSOLUTE_PATH;
String sPath = Constants.MERGER_FILE_ABSOLUTE_PATH;
try {
Class<?> clazz = Class.forName("com.yonde.dcs.plan.core.factory.ContractUtils");
Method settingDataMethod = clazz.getMethod("settingData", ExtExpenditureContractVO.class, DxWfProcessInfoVO.class);
settingDataMethod.invoke(SpringUtil.getBean(classType), expenditureContractVO, wfProcessInfoVO);
log.info("签名----生成word文件内容结束====");
if (obj instanceof ExtExpenditureContractVO) {
ExtExpenditureContractVO expenditureContractVO = (ExtExpenditureContractVO) obj;
Class<?> clazz = Class.forName("com.yonde.dcs.plan.core.factory.ContractUtils");
Method settingDataMethod = clazz.getMethod("settingData", ExtExpenditureContractVO.class, DxWfProcessInfoVO.class);
settingDataMethod.invoke(SpringUtil.getBean(classType), expenditureContractVO, wfProcessInfoVO);
outFilePath = outFilePath + expenditureContractVO.getSubTypeName() + "\\" + expenditureContractVO.getNumber() + "\\";
sPath = sPath + expenditureContractVO.getSubTypeName() + "\\" + expenditureContractVO.getNumber();
} else if (obj instanceof ExtInComeContractVO) {
ExtInComeContractVO extInComeContractVO = (ExtInComeContractVO) obj;
Class<?> clazz = Class.forName("com.yonde.dcs.plan.core.factory.ContractUtils");// TODO 改
Method settingDataMethod = clazz.getMethod("settingData", ExtInComeContractVO.class, DxWfProcessInfoVO.class);
settingDataMethod.invoke(SpringUtil.getBean(classType), extInComeContractVO, wfProcessInfoVO);
outFilePath = outFilePath + extInComeContractVO.getSubTypeName() + "\\" + extInComeContractVO.getNumber() + "\\";
sPath = sPath + extInComeContractVO.getSubTypeName() + "\\" + extInComeContractVO.getNumber();
} else {
log.error("签名----没有合同相关类型====");
return;
}
log.info("签名----获取生成的word文件内容结束====");
//按照目录获取生成的pdf和word
String outFilePath = Constants.MERGER_FILE_ABSOLUTE_PATH + expenditureContractVO.getSubTypeName() + "\\" + expenditureContractVO.getNumber() + "\\";
//获取文件夹的所有文件--绝对路径
List<String> fileList = new ArrayList<>();
File[] files = FileUtil.ls(outFilePath);
......@@ -116,12 +134,14 @@ public class ExtExpenditureContractServiceImpl<V extends ExtExpenditureContractV
if (CollectionUtils.isEmpty(fileList)) {
log.error("签名----生成的word文件目录内容为空====");
} else {
// PDF
String pdfFilePath = fileList.stream().filter(item -> item.endsWith(".pdf")).findFirst().get();
this.extractedAttachFile(expenditureContractVO, new FileInputStream(pdfFilePath), fileName, Constants.ATTACH_FILE);
this.extractedAttachFile(obj, new FileInputStream(pdfFilePath), fileName, Constants.ATTACH_FILE);
log.info("签名----获取生成的word文件内容结束====");
}
//删除生成后的临时文件
FileUtils.deleteDirectory(Constants.MERGER_FILE_ABSOLUTE_PATH + expenditureContractVO.getSubTypeName() + "\\" + expenditureContractVO.getNumber());
FileUtils.deleteDirectory(sPath);
} catch (Exception e) {
log.error("签名----通过不同的合同类型生成不同word错误:{}" + e.getMessage());
}
......@@ -130,29 +150,31 @@ public class ExtExpenditureContractServiceImpl<V extends ExtExpenditureContractV
/**
* 上传附件(事件专用上传附件)
*
* @param expenditureContractVO
* @param obj
* @param inputStreamPdf
* @param fileName
* @throws IOException
*/
public void extractedAttachFile(ExtExpenditureContractVO expenditureContractVO, InputStream inputStreamPdf,
public void extractedAttachFile(Object obj, InputStream inputStreamPdf,
String fileName, String docFileType) throws IOException {
String originalFileName = StringUtils.isEmpty(fileName) ? expenditureContractVO.getName() : fileName;
String secretCode = CommonUtils.getSecretCode(expenditureContractVO.getSecretCode());
String originalFileName = "";
String secretCode = "";
List<ObjFileLinkVO> objFileLinks = Lists.newArrayList();
if (obj instanceof ExtExpenditureContractVO) {
ExtExpenditureContractVO expenditureContractVO = (ExtExpenditureContractVO) obj;
originalFileName = StringUtils.isEmpty(fileName) ? expenditureContractVO.getName() : fileName;
secretCode = CommonUtils.getSecretCode(expenditureContractVO.getSecretCode());
objFileLinks = expenditureContractVO.getObjFileLinks();
} else if (obj instanceof ExtInComeContractVO) {
ExtInComeContractVO extInComeContractVO = (ExtInComeContractVO) obj;
originalFileName = StringUtils.isEmpty(fileName) ? extInComeContractVO.getName() : fileName;
secretCode = CommonUtils.getSecretCode(extInComeContractVO.getSecretCode());
objFileLinks = extInComeContractVO.getObjFileLinks();
}
originalFileName = originalFileName + "(" + secretCode + ")";
//上传文件到文件服务器
MultipartFile multipartFile = null;
multipartFile = new MockMultipartFile("file", originalFileName + ".pdf", Constants.CONTENT_TYPE_PDF, inputStreamPdf);
// if (StringUtils.isEmpty(fileName)) {
// //如果等于空,默认文件名称为getName.pdf
// multipartFile = new MockMultipartFile("file", documentVo.getName() + ".pdf",
// Constants.CONTENT_TYPE_PDF, inputStreamPdf);
// } else {
// //如果不等于空,默认文件名称为name.pdf
// multipartFile = new MockMultipartFile("file", fileName + ".pdf",
// Constants.CONTENT_TYPE_PDF, inputStreamPdf);
// }
RepoFileVO field = fileManagerService.uploadFile(multipartFile, getBucketId());
if (field == null) {
log.error("文件上传失败!");
......@@ -162,28 +184,21 @@ public class ExtExpenditureContractServiceImpl<V extends ExtExpenditureContractV
//根据docId查询文件对象
RepoFileVO fileVO = fileManagerFeignService.findFileInfoById(field.getId());
//上传到DOC_PDF_FILE为了浏览(Constants.PDF_FILE)
this.doProcessContract(expenditureContractVO, fileVO, docFileType);
}
/**
* 更新主内容或附件
*
* @param expenditureContractVO
* @param fileVO
* @param fileType
*/
private void doProcessContract(ExtExpenditureContractVO expenditureContractVO, RepoFileVO fileVO, String fileType) {
// DxObjFileUtils.removeFile(documentVo, fileType);
List<ObjFileLinkVO> objFileLinks = expenditureContractVO.getObjFileLinks();
//删除逻辑
if (!CollectionUtils.isEmpty(objFileLinks)) {
objFileLinks.stream().forEach(item -> {
if (item.getContentType().equals(fileType) && item.getTarget().getOriginalFileName().equals(fileVO.getOriginalFileName())) {
objFileLinks.forEach(item -> {
if (item.getContentType().equals(docFileType) && item.getTarget().getOriginalFileName().equals(fileVO.getOriginalFileName())) {
item.setOperator(OperatorType.REMOVE);
}
});
}
DxObjFileUtils.addFile(expenditureContractVO, fileVO, fileType);
if (obj instanceof ExtExpenditureContractVO) {
ExtExpenditureContractVO expenditureContractVO = (ExtExpenditureContractVO) obj;
DxObjFileUtils.addFile(expenditureContractVO, fileVO, docFileType);
} else if (obj instanceof ExtInComeContractVO) {
ExtInComeContractVO extInComeContractVO = (ExtInComeContractVO) obj;
DxObjFileUtils.addFile(extInComeContractVO, fileVO, docFileType);
}
}
public Long getBucketId() {
......
package com.yonde.dcs.plan.core.service.impl;
import com.google.common.collect.Lists;
import com.yonde.dcs.plan.common.vo.ExtExpenditureContractVO;
import com.yonde.dex.basedata.data.search.SearchItem;
import com.yonde.dex.basedata.data.search.SearchItems;
import com.yonde.dex.basedata.data.search.SearchQueryCondition;
import com.yonde.dex.basedata.entity.data.DxPageImpl;
import com.yonde.dex.basedata.exception.DxBusinessException;
import com.yonde.dex.dao.service.util.DxPageUtils;
import com.yonde.dex.wfc.feign.api.WfcProcessFeign;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
import io.swagger.annotations.ApiOperation;
import java.util.ArrayList;
import java.util.List;
import com.yonde.dcs.plan.common.vo.ExtInComeContractVO;
import org.springframework.beans.factory.annotation.Qualifier;
......@@ -29,6 +41,55 @@ public class ExtInComeContractServiceImpl<V extends ExtInComeContractVO> impleme
@Autowired
ExtInComeContractRepository<ExtInComeContract> extInComeContractRepository;
@Autowired
private WfcProcessFeign wfcProcessFeign;
@Override
public ExtInComeContractVO startWorkflow(Long id) {
ExtInComeContractVO extInComeContractVO = this.get(id);
if (extInComeContractVO == null) {
throw new DxBusinessException("500", "获取不到对象");
}
if (!extInComeContractVO.getState().equals("edit")) {
throw new DxBusinessException("500", "该对象不是编制状态");
}
wfcProcessFeign.startProcessByKey("ExtInComeContractWF", extInComeContractVO);
return this.changeStatus(extInComeContractVO.getId(), "submitReviewing", true);
}
@Override
public ExtInComeContractVO findExtInComeContractObjFileLinks(Long id) {
SearchQueryCondition query = SearchQueryCondition.builder()
.openProp(SearchQueryCondition.builder().name("creator").build())
.openProp(SearchQueryCondition.builder().name("modifier").build())
.openProp(SearchQueryCondition.builder().name("objFileLinks").openProp(SearchQueryCondition.builder().name("target").build()).build())
.searchItems(SearchItems.builder().item(new SearchItem("id", SearchItem.Operator.EQ,
id, null)).item(new SearchItem("latest", SearchItem.Operator.EQ,
true, null)).operator(SearchItems.BooleanOperator.AND).build()).build();
//通过id查询文档
DxPageImpl<V> dexPage = this.findRecursion(query);
if (!org.apache.commons.collections.CollectionUtils.isEmpty(dexPage.getContent())) {
return DxPageUtils.getFirst(dexPage);
}
return null;
}
@Override
public List<ExtInComeContractVO> getResearchCategory(String subTypeName) {
SearchQueryCondition query = SearchQueryCondition.builder()
.openProp(SearchQueryCondition.builder().name("sourceTopicContractLink")
.openProp(SearchQueryCondition.builder().name("target").build()).build())
.searchItems(SearchItems.builder()
.item(new SearchItem("subTypeName", SearchItem.Operator.EQ, subTypeName, null))
.item(new SearchItem("latest", SearchItem.Operator.EQ, true, null))
.operator(SearchItems.BooleanOperator.AND).build()).build();
DxPageImpl<V> dexPage = this.findRecursion(query);
if (CollectionUtils.isNotEmpty(dexPage.getContent())) {
return (List<ExtInComeContractVO>) dexPage.getContent();
}
return Lists.newArrayList();
}
}
......@@ -4,6 +4,7 @@ package com.yonde.dcs.plan.core.util;
import com.yonde.dcs.document.common.entity.vo.DxDocumentVO;
import com.yonde.dcs.plan.common.constants.SignConstants;
import com.yonde.dcs.plan.common.vo.ExtExpenditureContractVO;
import com.yonde.dcs.plan.common.vo.ExtInComeContractVO;
import com.yonde.dex.user.common.vo.DxUserInfoVO;
import com.yonde.dex.user.feign.DxUserInfoFeign;
import com.yonde.dex.version.plugin.common.entity.DxIterationVOHolder;
......@@ -86,6 +87,29 @@ public class WorkFlowUtil {
return null;
}
/**
* 获取流程实例
*
* @param extInComeContractVO
* @return
*/
// TODO: xpc WfProcessInstVO不存在改为DxWfProcessVO
public DxWfProcessVO getWfProcessInst(ExtInComeContractVO extInComeContractVO) {
// TODO: getProcessInstList方法不存在改为getProcessList
// WfProcessInstSearchVO wfProcessInstSearchVO = new WfProcessInstSearchVO();
// wfProcessInstSearchVO.setPboClass(DxDocumentVO.class.getName());
// wfProcessInstSearchVO.setPboId(doc.getVersionId());
// Page<WfProcessInstVO> wfProcessInstVOPage = this.instanceService.getProcessInstList(wfProcessInstSearchVO, 1, 10);
DxWfProcessSearchVO dxWfProcessSearchVO = new DxWfProcessSearchVO();
dxWfProcessSearchVO.setPboClass(ExtExpenditureContractVO.class.getName());
dxWfProcessSearchVO.setPboId(extInComeContractVO.getVersionId());
Page<DxWfProcessVO> processList = wfcProcessFeign.getProcessList(dxWfProcessSearchVO, 1, 10);
if (!CollectionUtils.isEmpty(processList.getContent())) {
return processList.getContent().get(0);
}
return null;
}
/**
* 获取流程实例
*
......
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