|
|
@ -1,6 +1,7 @@ |
|
|
|
package com.hnac.hzims.ticket.repair.service.impl; |
|
|
|
package com.hnac.hzims.ticket.repair.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
import cn.afterturn.easypoi.excel.entity.TemplateExportParams; |
|
|
|
import cn.afterturn.easypoi.excel.entity.TemplateExportParams; |
|
|
|
|
|
|
|
import cn.afterturn.easypoi.word.WordExportUtil; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.alibaba.fastjson.TypeReference; |
|
|
|
import com.alibaba.fastjson.TypeReference; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
@ -12,13 +13,16 @@ import com.hnac.hzims.ticket.repair.service.IWorkTaskService; |
|
|
|
import com.hnac.hzims.ticket.repair.vo.WorkTaskContentVO; |
|
|
|
import com.hnac.hzims.ticket.repair.vo.WorkTaskContentVO; |
|
|
|
import com.hnac.hzims.ticket.repair.vo.WorkTaskPreviewVO; |
|
|
|
import com.hnac.hzims.ticket.repair.vo.WorkTaskPreviewVO; |
|
|
|
import com.hnac.hzims.ticket.repair.vo.WorkTaskVO; |
|
|
|
import com.hnac.hzims.ticket.repair.vo.WorkTaskVO; |
|
|
|
|
|
|
|
import com.hnac.hzims.ticket.utils.AsposeUtil; |
|
|
|
import com.hnac.hzims.ticket.utils.ExcelUtil; |
|
|
|
import com.hnac.hzims.ticket.utils.ExcelUtil; |
|
|
|
import com.hnac.hzims.ticket.utils.PdfUtils; |
|
|
|
import com.hnac.hzims.ticket.utils.PdfUtils; |
|
|
|
|
|
|
|
import com.hnac.hzims.ticket.utils.WordUtils; |
|
|
|
import com.hnac.hzims.ticket.workTicket.entity.WorkTicketInfoEntity; |
|
|
|
import com.hnac.hzims.ticket.workTicket.entity.WorkTicketInfoEntity; |
|
|
|
import com.hnac.hzims.ticket.workTicket.service.IWorkTicketInfoService; |
|
|
|
import com.hnac.hzims.ticket.workTicket.service.IWorkTicketInfoService; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.poi.ss.usermodel.Workbook; |
|
|
|
import org.apache.poi.ss.usermodel.Workbook; |
|
|
|
|
|
|
|
import org.apache.poi.xwpf.usermodel.XWPFDocument; |
|
|
|
import org.springblade.core.log.exception.ServiceException; |
|
|
|
import org.springblade.core.log.exception.ServiceException; |
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl; |
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl; |
|
|
|
import org.springblade.core.mp.support.Condition; |
|
|
|
import org.springblade.core.mp.support.Condition; |
|
|
@ -39,6 +43,10 @@ import org.springframework.web.context.request.RequestContextHolder; |
|
|
|
import org.springframework.web.context.request.ServletRequestAttributes; |
|
|
|
import org.springframework.web.context.request.ServletRequestAttributes; |
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
|
|
|
import java.io.File; |
|
|
|
|
|
|
|
import java.io.FileInputStream; |
|
|
|
|
|
|
|
import java.io.FileOutputStream; |
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
import java.util.*; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -57,8 +65,8 @@ public class WorkTaskServiceImpl extends BaseServiceImpl<WorkTaskMapper, WorkTas |
|
|
|
|
|
|
|
|
|
|
|
private final IUserClient userClient; |
|
|
|
private final IUserClient userClient; |
|
|
|
|
|
|
|
|
|
|
|
@Value("${hzims.ticket.workTask.saveWrokTask.xlsx}") |
|
|
|
@Value("${hzims.ticket.workTask.saveWrokTask.work}") |
|
|
|
private String saveWrokTaskXlsxPath; |
|
|
|
private String saveWrokTaskWorkPath; |
|
|
|
|
|
|
|
|
|
|
|
@Value("${hzims.ticket.workTask.saveWrokTask.pdf}") |
|
|
|
@Value("${hzims.ticket.workTask.saveWrokTask.pdf}") |
|
|
|
private String saveWrokTaskPdfPath; |
|
|
|
private String saveWrokTaskPdfPath; |
|
|
@ -185,7 +193,7 @@ public class WorkTaskServiceImpl extends BaseServiceImpl<WorkTaskMapper, WorkTas |
|
|
|
//准备数据
|
|
|
|
//准备数据
|
|
|
|
WorkTaskPreviewVO preview = this.workTaskExport(id); |
|
|
|
WorkTaskPreviewVO preview = this.workTaskExport(id); |
|
|
|
if(ObjectUtil.isEmpty(preview)){ |
|
|
|
if(ObjectUtil.isEmpty(preview)){ |
|
|
|
throw new ServiceException("查询应急抢修单失败"); |
|
|
|
throw new ServiceException("查询工作任务单失败"); |
|
|
|
} |
|
|
|
} |
|
|
|
Map<String,Object> params = new HashMap<>(); |
|
|
|
Map<String,Object> params = new HashMap<>(); |
|
|
|
try { |
|
|
|
try { |
|
|
@ -194,27 +202,15 @@ public class WorkTaskServiceImpl extends BaseServiceImpl<WorkTaskMapper, WorkTas |
|
|
|
}catch (Exception e) { |
|
|
|
}catch (Exception e) { |
|
|
|
log.error("转换对象失败!"); |
|
|
|
log.error("转换对象失败!"); |
|
|
|
} |
|
|
|
} |
|
|
|
TemplateExportParams templateExportParams = new TemplateExportParams("template/excel/work_task_template.xlsx", true); |
|
|
|
// 保存wrok至本地服务器
|
|
|
|
Workbook workbook = null; |
|
|
|
String fileName = preview.getCode() + "_工作任务单"; |
|
|
|
try { |
|
|
|
String path = WordUtils.uploadWord("/template/work/",saveWrokTaskWorkPath,params,"work_task_template",fileName); |
|
|
|
workbook = ExcelUtil.getWorkbook(templateExportParams,params); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//上传xlsx至服务器
|
|
|
|
|
|
|
|
String fileName = preview.getCode() + "_工作任务单" + PdfUtils.XLSX_SUFFIX; |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
ExcelUtil.upload(workbook,saveWrokTaskXlsxPath,fileName); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//将docx文件转换为pdf并保存
|
|
|
|
//将docx文件转换为pdf并保存
|
|
|
|
String pdfFileName = preview.getCode() + "_工作任务单" + PdfUtils.PDF_SUFFIX; |
|
|
|
String savePdfPath = saveWrokTaskPdfPath + preview.getCode() + "_工作任务单" + PdfUtils.PDF_SUFFIX; |
|
|
|
String xlsxFileName = preview.getCode() + "_工作任务单" + PdfUtils.XLSX_SUFFIX; |
|
|
|
AsposeUtil.wordToPdf(path,savePdfPath); |
|
|
|
PdfUtils.convertPdf(saveWrokTaskPdfPath, xlsxFileName, saveWrokTaskPdfPath, pdfFileName); |
|
|
|
|
|
|
|
String savePath = saveWrokTaskPdfPath + pdfFileName; |
|
|
|
|
|
|
|
// 设置response参数,可以打开下载页面
|
|
|
|
// 设置response参数,可以打开下载页面
|
|
|
|
PdfUtils.readPdf(response,savePath); |
|
|
|
PdfUtils.readPdf(response,savePdfPath); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|