Commit 335fcf12 authored by wangyangyang's avatar wangyangyang

文档 图册:自动任务生成图册目录--调整

parent b564dd87
......@@ -63,10 +63,10 @@ public class ExtAutoTaskController {
private ExtDxDocumentService extDxDocumentService;
@ApiOperation("生成图册目录")
@ApiOperation("生成图册目录且修改图册已经图纸状态为发布")
@GetMapping({"/catalog"})
public ApiResult generateCatalog(@RequestParam Long docId) {
return ApiResult.ok(extDxDocumentService.generateCatalog(docId), "查询成功");
public void generateCatalog(@RequestParam Long docId) {
autoTaskService.generateCatalog(docId);
}
......
......@@ -35,12 +35,17 @@ public class ExtDxDocumentController<V extends DxDocumentVO, S extends ExtDxDocu
return ApiResult.ok(service.getDocAndFolder(dxContextId, parentId), "查询成功");
}
@ApiOperation("生成图册目录")
@GetMapping({"/catalog"})
public ApiResult generateCatalog(@RequestParam Long docId) {
return ApiResult.ok(service.generateCatalog(docId), "查询成功");
}
//
// /**
// * 自动任务 这块弃用
// * @param docId
// * @return
// */
// @ApiOperation("生成图册目录")
// @GetMapping({"/catalog"})
// public ApiResult generateCatalog(@RequestParam Long docId) {
// return ApiResult.ok(service.generateCatalog(docId), "查询成功");
// }
}
......
......@@ -19,6 +19,16 @@ import java.util.Map;
* @create: 2021-09-27 09:41
*/
public interface ExtAutoTaskService extends ExtAutoTaskServiceFeign {
/**
* 生成图册目录
* @param docId
* @return
*/
void generateCatalog(Long docId);
/**
* 客户化文档修改状态
*
......
......@@ -6,10 +6,13 @@ import cn.hutool.core.date.DateTime;
import cn.hutool.core.io.FileUtil;
import cn.hutool.extra.spring.SpringUtil;
import cn.hutool.http.ContentType;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
import com.alibaba.fastjson.JSONObject;
import com.yonde.dcs.document.common.vo.*;
import com.yonde.dcs.document.core.event.DocumentEvent;
import com.yonde.dcs.document.core.excel.ExtCatalogExcelVO;
import com.yonde.dcs.document.core.factory.*;
import com.yonde.dcs.document.core.service.*;
import com.yonde.dcs.document.core.util.*;
......@@ -153,6 +156,48 @@ public class ExtAutoTaskServiceImpl implements ExtAutoTaskService {
@Autowired
ExtAuditInterfLinkService extAuditInterfLinkService;
@SneakyThrows
@Override
public void generateCatalog(Long docId) {
SearchQueryCondition queryCondition = SearchUtil.buildQueryWithOpenAttr("id", SearchItem.Operator.EQ, docId, "targetExtAtlasDrawingLink.target");
DxPageImpl<DxDocumentVO> recursion = documentService.findRecursion(queryCondition);
DxDocumentVO dxDocumentVO = recursion.getContent().get(0);
List<ExtAtlasDrawingLinkVO> targetExtAtlasDrawingLink = dxDocumentVO.getDxDocumentExpand().getTargetExtAtlasDrawingLink();
if (CollectionUtil.isNotEmpty(targetExtAtlasDrawingLink)) {
List<ExtCatalogExcelVO> excelVOS = new ArrayList<>();
for (int i = 0; i < targetExtAtlasDrawingLink.size(); i++) {
DxDocumentVO documentVO = targetExtAtlasDrawingLink.get(i).getTarget();
ExtCatalogExcelVO catalogExcelVO = new ExtCatalogExcelVO();
catalogExcelVO.setIndex(String.valueOf(i + 1));
catalogExcelVO.setName(documentVO.getName());
catalogExcelVO.setVersionKey(documentVO.getVersionKey());
catalogExcelVO.setDrawNumber(String.valueOf(documentVO.getDynamicAttrs().get("drawNumber")));
catalogExcelVO.setPictureFrame(String.valueOf(documentVO.getDynamicAttrs().get("pictureFrame")));
excelVOS.add(catalogExcelVO);
}
String dir = ResourceHelper.createTemDir().getPath();
String filePath = dir + "\\图册.xlsx";
EasyExcel.write(filePath, ExtCatalogExcelVO.class)
.registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
.sheet("图册").doWrite(excelVOS);
//转pdf
String pdfName = "图册.pdf";
String filePdfPath = dir + File.separator + pdfName;
ExcelUtils.Ex2PDF(filePath, filePdfPath);
//上传文件到文件服务器
MultipartFile multipartFile = null;
multipartFile = new MockMultipartFile("file", pdfName, com.yonde.dcs.plan.common.constants.Constants.CONTENT_TYPE_PDF, new FileInputStream(filePdfPath));
RepoFileVO fileVO = fileManagerFeignService.uploadFile(multipartFile, CommonUtil.getBucketIdByAppName(com.yonde.dcs.document.core.constants.Constants.APPLICATION_DOC_INNER_NAME));
ObjFileLinkUtil.addFile(dxDocumentVO, fileVO, com.yonde.dcs.plan.common.constants.Constants.ATTACH_FILE);
dxDocumentVO.setOperator(OperatorType.MODIFY);
dxDocumentVO = (DxDocumentVO) documentService.saveRecursion(dxDocumentVO);
FileUtil.del(dir);
//TODO 设置图册图纸 状态为已发布 (客制化修改文档状态接口 已存在直接流程中配置即可 ExtAutoTaskService extChangeDocState)
//TODO 判断该文档关联IED计划下所有的文档状态是否为已完成,已完成则回写IED计划状态----后续补充
}
}
/**
* 客制化文档修改状态
*
......
......@@ -27,9 +27,9 @@ import java.util.Map;
public interface ExtAutoTaskServiceFeign{
@ApiOperation("生成图册目录")
@ApiOperation(value = "生成图册目录", notes = "生成图册目录", httpMethod = "GET")
@GetMapping({"/catalog"})
ApiResult generateCatalog(@RequestParam(name = "docId") Long docId);
void generateCatalog(@RequestParam(name = "docId") Long docId);
@ApiOperation(value = "客户化文档修改状态", notes = "客户化文档修改状态", httpMethod = "POST")
......
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