Commit 454c96de authored by wangyangyang's avatar wangyangyang

文档 图册:回写ied计划状态

parent 2a4ae50c
...@@ -261,7 +261,7 @@ public class ExtAutoTaskServiceImpl implements ExtAutoTaskService { ...@@ -261,7 +261,7 @@ public class ExtAutoTaskServiceImpl implements ExtAutoTaskService {
excelVOS.add(catalogExcelVO); excelVOS.add(catalogExcelVO);
} }
//已发布的时候才需要生成图册目录 以及修改IED计划状态 //已发布的时候才需要生成图册目录 以及修改IED计划状态
if (Constants.DOC_RELEASE.equalsIgnoreCase(state)){ if (Constants.DOC_RELEASE.equalsIgnoreCase(state)) {
//TODO 图册生成图纸信息 //TODO 图册生成图纸信息
String dir = ResourceHelper.createTemDir().getPath(); String dir = ResourceHelper.createTemDir().getPath();
String filePath = dir + "\\图册.xlsx"; String filePath = dir + "\\图册.xlsx";
...@@ -271,10 +271,9 @@ public class ExtAutoTaskServiceImpl implements ExtAutoTaskService { ...@@ -271,10 +271,9 @@ public class ExtAutoTaskServiceImpl implements ExtAutoTaskService {
//转pdf //转pdf
String pdfName = "图册.pdf"; String pdfName = "图册.pdf";
String filePdfPath = dir + File.separator + pdfName; String filePdfPath = dir + File.separator + pdfName;
ExcelUtils.Ex2PDF(filePath, filePdfPath); ExcelUtils.excelToPDF(filePath, filePdfPath);
//上传文件到文件服务器 //上传文件到文件服务器
MultipartFile multipartFile = null; MultipartFile multipartFile = new MockMultipartFile("file", pdfName, com.yonde.dcs.plan.common.constants.Constants.CONTENT_TYPE_PDF, new FileInputStream(filePdfPath));
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)); RepoFileVO fileVO = fileManagerFeignService.uploadFile(multipartFile, CommonUtil.getBucketIdByAppName(com.yonde.dcs.document.core.constants.Constants.APPLICATION_DOC_INNER_NAME));
ObjFileLinkUtil.addFile(documentVO, fileVO, com.yonde.dcs.plan.common.constants.Constants.ATTACH_FILE); ObjFileLinkUtil.addFile(documentVO, fileVO, com.yonde.dcs.plan.common.constants.Constants.ATTACH_FILE);
documentVO.setOperator(OperatorType.MODIFY); documentVO.setOperator(OperatorType.MODIFY);
...@@ -284,9 +283,12 @@ public class ExtAutoTaskServiceImpl implements ExtAutoTaskService { ...@@ -284,9 +283,12 @@ public class ExtAutoTaskServiceImpl implements ExtAutoTaskService {
//TODO 判断该文档关联IED计划下所有的文档状态是否为已完成,已完成则回写IED计划状态----一个IED计划对应一个图册,直接修改计划状态即可 //TODO 判断该文档关联IED计划下所有的文档状态是否为已完成,已完成则回写IED计划状态----一个IED计划对应一个图册,直接修改计划状态即可
SearchQueryCondition query = SearchUtil.buildQuery("targetId", SearchItem.Operator.EQ, documentVO.getId()); SearchQueryCondition query = SearchUtil.buildQuery("targetId", SearchItem.Operator.EQ, documentVO.getId());
DxPageImpl iedPage = extIEDPlanDocLinkServiceFeign.findRecursion(query); DxPageImpl iedPage = extIEDPlanDocLinkServiceFeign.findRecursion(query);
if (iedPage.getTotalElements() > 0) {
ExtIEDPlanDocLinkVO extIEDPlanDocLinkVO = (ExtIEDPlanDocLinkVO) iedPage.getContent().get(0); ExtIEDPlanDocLinkVO extIEDPlanDocLinkVO = (ExtIEDPlanDocLinkVO) iedPage.getContent().get(0);
Long iedPlanId = extIEDPlanDocLinkVO.getSourceId(); Long iedPlanId = extIEDPlanDocLinkVO.getSourceId();
extIEDPlanServiceFeign.changeStatus(iedPlanId, Constants.IED_Complete, true); extIEDPlanServiceFeign.changeStatus(iedPlanId, Constants.IED_Complete, true);
}
} }
} }
//判断接口单为审阅中设置全局状态为已打开 //判断接口单为审阅中设置全局状态为已打开
......
...@@ -18,6 +18,9 @@ import org.springframework.web.multipart.MultipartFile; ...@@ -18,6 +18,9 @@ import org.springframework.web.multipart.MultipartFile;
@Slf4j @Slf4j
public class ExcelUtils { public class ExcelUtils {
public static final int EXCEL_FORMAT_PDF = 0; //excel转pdf
private static final int xlTypePDF = 0; private static final int xlTypePDF = 0;
/** /**
...@@ -55,6 +58,47 @@ public class ExcelUtils { ...@@ -55,6 +58,47 @@ public class ExcelUtils {
} }
/**
* 转换文件
*
* @param sourceFile
* @param targetFile
* @return
*/
public static boolean excelToPDF(String sourceFile, String targetFile) {
boolean result = true;
log.info("[文件转换-执行] >>>> 启动Excel...");
long start = System.currentTimeMillis();
ActiveXComponent app = null;
Dispatch excel = null;
try {
// 创建一个excel对象
app = new ActiveXComponent("Excel.Application");
// 不可见打开excel
app.setProperty("Visible", new Variant(false));
app.setProperty("AutomationSecurity", new Variant(3));
// 获取文挡属性
Dispatch excels = app.getProperty("Workbooks").toDispatch();
//调用Documents对象中Open方法打开文档,并返回打开的文档对象Document
excel = Dispatch.call(excels, "Open", sourceFile).toDispatch();
// Excel不能调用SaveAs方法,excel值为0
Dispatch.call(excel, "ExportAsFixedFormat", EXCEL_FORMAT_PDF, targetFile);
long end = System.currentTimeMillis();
log.info("[文件转换-执行] >>>> 打开文档:" + sourceFile + ",转换文档到PDF:" + targetFile + ",用时:" + (end - start) + "ms.");
} catch (Exception e) {
log.info("[文件转换-执行] >>>>Error:文档转换失败:", e);
} finally {
Dispatch.call(excel, "Close", false);
if (app != null)
app.invoke("Quit", new Variant[]{});
//如果没有这句话,winword.exe进程将不会关闭
ComThread.Release();
}
return result;
}
/*** /***
* *
* Excel转化成PDF * Excel转化成PDF
......
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