|
|
|
@ -2,6 +2,7 @@ package com.hnac.hzims.ticket.twoTicket.service.impl;
|
|
|
|
|
|
|
|
|
|
import cn.afterturn.easypoi.excel.entity.TemplateExportParams; |
|
|
|
|
import cn.afterturn.easypoi.word.WordExportUtil; |
|
|
|
|
import cn.hutool.core.io.resource.FileResource; |
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
@ -74,6 +75,7 @@ import java.util.stream.Collectors;
|
|
|
|
|
import java.util.stream.IntStream; |
|
|
|
|
|
|
|
|
|
import static org.aspectj.weaver.tools.cache.SimpleCacheFactory.path; |
|
|
|
|
import static org.springframework.transaction.support.TransactionSynchronizationManager.getResource; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @author hx |
|
|
|
@ -292,15 +294,18 @@ public class FirstWorkTicketServiceImpl extends BaseServiceImpl<WorkTicketInfoMa
|
|
|
|
|
throw new ServiceException("未找到模板文件,预览失败!"); |
|
|
|
|
}); |
|
|
|
|
String wordPath = this.getFileSavePath() + params.get("code") + "_" + params.get("addressEquName") +".docx"; |
|
|
|
|
List<XWPFDocument> documents; |
|
|
|
|
List<File> templateFiles = this.getFiles(workTicketInfoEntity); |
|
|
|
|
try { |
|
|
|
|
documents = this.getDocuments(workTicketInfoEntity, params); |
|
|
|
|
MergeDocUtils.mergeDoc(templateFiles,new File(wordPath)); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
throw new RuntimeException(e); |
|
|
|
|
} |
|
|
|
|
try { |
|
|
|
|
this.exportTicketWord(documents,wordPath); |
|
|
|
|
} catch (IOException e) { |
|
|
|
|
XWPFDocument xwpfDocument = WordExportUtil.exportWord07(wordPath, params); |
|
|
|
|
xwpfDocument.write(new FileOutputStream(wordPath)); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
throw new RuntimeException(e); |
|
|
|
|
} |
|
|
|
|
String pdfPath = this.getFileSavePath() + params.get("code") + "_" + params.get("addressEquName") +".pdf"; |
|
|
|
@ -396,37 +401,45 @@ public class FirstWorkTicketServiceImpl extends BaseServiceImpl<WorkTicketInfoMa
|
|
|
|
|
params.putAll(ObjectUtils.LocalDateConvertMap(finish.getLicensorEndTime(),"e","_")); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
//第一种工作票
|
|
|
|
|
params.put("one", "6".equals(workTicketInfoEntity.getType()) ? "☑" : "□"); |
|
|
|
|
//第二种工作票
|
|
|
|
|
params.put("two", "7".equals(workTicketInfoEntity.getType()) ? "☑" : "□"); |
|
|
|
|
//水力机器工作票
|
|
|
|
|
params.put("three", "8".equals(workTicketInfoEntity.getType()) ? "☑" : "□"); |
|
|
|
|
return params; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private List<XWPFDocument> getDocuments(WorkTicketInfoEntity workTicketInfo,Map<String,Object> params) { |
|
|
|
|
List<XWPFDocument> result = Lists.newArrayList(); |
|
|
|
|
XWPFDocument document = this.fillDocument("template/" + WorkTicketConstants.TicketSignageEnum.getTempFileNameByType(workTicketInfo.getType()), params); |
|
|
|
|
result.add(document); |
|
|
|
|
private List<File> getFiles(WorkTicketInfoEntity workTicketInfo) { |
|
|
|
|
List<File> result = Lists.newArrayList(); |
|
|
|
|
String prefix; |
|
|
|
|
//Windows操作系统
|
|
|
|
|
if (TicketConstant.OS_NAME.toLowerCase().startsWith("windows")) { |
|
|
|
|
prefix = TicketConstant.TICKET_WINDOW_PATH; |
|
|
|
|
} else { |
|
|
|
|
prefix = TicketConstant.TICKET_LIUNX_PATH; |
|
|
|
|
} |
|
|
|
|
String templatePath = prefix + "/" + WorkTicketConstants.TicketSignageEnum.getTempFileNameByType(workTicketInfo.getType()); |
|
|
|
|
result.add(new File(templatePath)); |
|
|
|
|
//安全隔离措施附页 (true,展示附件,false,不展示附件)
|
|
|
|
|
if (workTicketInfo.getIsSafety()) { |
|
|
|
|
XWPFDocument xwpfDocument = this.fillDocument("template/" + TicketConstant.SECURE_PAGE, params); |
|
|
|
|
//result.add(xwpfDocument);
|
|
|
|
|
result.add(new File(prefix + "/" + TicketConstant.SAFETY_PAGE)); |
|
|
|
|
} |
|
|
|
|
//危险点分析与预控措施票 (true,展示附件,false,不展示附件)
|
|
|
|
|
if (workTicketInfo.getIsHazard()) { |
|
|
|
|
XWPFDocument xwpfDocument = this.fillDocument("template/" + TicketConstant.SAFETY_PAGE, params); |
|
|
|
|
//result.add(xwpfDocument);
|
|
|
|
|
result.add(new File(prefix + "/" + TicketConstant.SAFETY_PAGE)); |
|
|
|
|
} |
|
|
|
|
//动火工作票 (true,展示附件,false,不展示附件)
|
|
|
|
|
if (workTicketInfo.getIsRailway()) { |
|
|
|
|
XWPFDocument xwpfDocument = this.fillDocument("template/" + TicketConstant.FLIGHT_PAGE, params); |
|
|
|
|
//result.add(xwpfDocument);
|
|
|
|
|
result.add(new File(prefix + "/" + TicketConstant.FLIGHT_PAGE)); |
|
|
|
|
} |
|
|
|
|
//有限空间监测记录单(true,展示附件,false,不展示附件)
|
|
|
|
|
if (workTicketInfo.getIsLimited()) { |
|
|
|
|
XWPFDocument xwpfDocument = this.fillDocument("template/" + TicketConstant.SPACE_PAGE, params); |
|
|
|
|
//result.add(xwpfDocument);
|
|
|
|
|
result.add(new File(prefix + "/" + TicketConstant.SPACE_PAGE)); |
|
|
|
|
} |
|
|
|
|
//每日开工和收工时间附页
|
|
|
|
|
if (workTicketInfo.getIsStart()) { |
|
|
|
|
XWPFDocument xwpfDocument = this.fillDocument("template/" + TicketConstant.START_PAGE, params); |
|
|
|
|
//result.add(xwpfDocument);
|
|
|
|
|
result.add(new File(prefix + "/" + TicketConstant.START_PAGE)); |
|
|
|
|
} |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|