|
|
@ -1,8 +1,7 @@ |
|
|
|
package com.hnac.hzims.ticket.twoTicket.service.impl; |
|
|
|
package com.hnac.hzims.ticket.twoTicket.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import cn.afterturn.easypoi.excel.ExcelExportUtil; |
|
|
|
import cn.afterturn.easypoi.word.WordExportUtil; |
|
|
|
import cn.afterturn.easypoi.excel.entity.TemplateExportParams; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
@ -36,7 +35,7 @@ import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.SneakyThrows; |
|
|
|
import lombok.SneakyThrows; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.lang3.math.NumberUtils; |
|
|
|
import org.apache.commons.lang3.math.NumberUtils; |
|
|
|
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.secure.utils.AuthUtil; |
|
|
|
import org.springblade.core.secure.utils.AuthUtil; |
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
import org.springblade.core.tool.api.R; |
|
|
@ -123,11 +122,9 @@ public class TicketProcessServiceImpl implements TicketProcessService { |
|
|
|
private final IWorkTicketInfoService ticketInfoService; |
|
|
|
private final IWorkTicketInfoService ticketInfoService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Value("${hzims.ticket.path.pdf.savePath}") |
|
|
|
@Value("${hzims.ticket.path.word.templatePath}") |
|
|
|
private String pdfSavePath; |
|
|
|
private String templatePath; |
|
|
|
|
|
|
|
|
|
|
|
@Value("${hzims.ticket.path.xlsx.savePath}") |
|
|
|
|
|
|
|
private String xlsSavePath; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 启动开票流程 |
|
|
|
* 启动开票流程 |
|
|
@ -348,17 +345,13 @@ public class TicketProcessServiceImpl implements TicketProcessService { |
|
|
|
User user = UserCache.getUser(workTicket.getStepOperator()); |
|
|
|
User user = UserCache.getUser(workTicket.getStepOperator()); |
|
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotEmpty(nextStepOperator)) { |
|
|
|
if (StringUtils.isNotEmpty(nextStepOperator)) { |
|
|
|
Long taskUser = NumberUtils.createLong(nextStepOperator.startsWith("taskUser_") ? |
|
|
|
Long taskUser = NumberUtils.createLong(nextStepOperator.startsWith("taskUser_") ? nextStepOperator.substring(9) : null); |
|
|
|
nextStepOperator.substring(9) : null); |
|
|
|
|
|
|
|
//下一个审批人
|
|
|
|
//下一个审批人
|
|
|
|
User stepUser = UserCache.getUser(taskUser); |
|
|
|
User stepUser = UserCache.getUser(taskUser); |
|
|
|
flowDescription = "审批中,当前环节是".concat(description) |
|
|
|
flowDescription = "审批中,当前环节是".concat(description).concat(",当前审批人是").concat(user.getName()).concat(",下一个审批人是").concat(stepUser.getName()).concat("待审批"); |
|
|
|
.concat(",当前审批人是").concat(user.getName()) |
|
|
|
|
|
|
|
.concat(",下一个审批人是").concat(stepUser.getName()).concat("待审批"); |
|
|
|
|
|
|
|
workTicket.setNextStepOperator(taskUser); |
|
|
|
workTicket.setNextStepOperator(taskUser); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
flowDescription = "审批中,当前环节是".concat(description) |
|
|
|
flowDescription = "审批中,当前环节是".concat(description).concat(",审批人是").concat(user.getName()); |
|
|
|
.concat(",审批人是").concat(user.getName()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
//如果taskId为空 或 flowStatus = 99
|
|
|
|
//如果taskId为空 或 flowStatus = 99
|
|
|
|
if (StringUtils.isEmpty(taskId) || 99 == flowStatus) { |
|
|
|
if (StringUtils.isEmpty(taskId) || 99 == flowStatus) { |
|
|
@ -609,39 +602,32 @@ public class TicketProcessServiceImpl implements TicketProcessService { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@SneakyThrows |
|
|
|
@SneakyThrows |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void preview(String ticketType, Long ticketId) { |
|
|
|
public String preview(String ticketType, Long ticketId) { |
|
|
|
WorkTicketVo workTicketVo = ticketInfoService.selectDetailsById(ticketId); |
|
|
|
WorkTicketVo workTicketVo = ticketInfoService.selectDetailsById(ticketId); |
|
|
|
//将查询的数据转换为map
|
|
|
|
//将查询的数据转换为map
|
|
|
|
Map<String, Object> workTicketInfoMap = this.convertMap(workTicketVo); |
|
|
|
Map<String, Object> workTicketInfoMap = this.convertMap(workTicketVo); |
|
|
|
workTicketInfoMap.put("name", 22); |
|
|
|
|
|
|
|
String fileName = TicketConstants.WordFileNameEnum.getFileNameByType(ticketType) + PdfUtils.XLSX_SUFFIX; |
|
|
|
String fileName = TicketConstants.WordFileNameEnum.getFileNameByType(ticketType) + PdfUtils.XLSX_SUFFIX; |
|
|
|
log.info("工作票模板为:{}", fileName); |
|
|
|
log.info("工作票模板为:{}", fileName); |
|
|
|
TemplateExportParams templateExportParams = new TemplateExportParams("template/新电气第一种工作票模板.xlsx", true); |
|
|
|
XWPFDocument doc = WordExportUtil.exportWord07("template/电气第一种工作票模版.docx", workTicketInfoMap); |
|
|
|
Workbook workbook = null; |
|
|
|
FileOutputStream fos = null; |
|
|
|
try { |
|
|
|
String name = null; |
|
|
|
workbook = ExcelExportUtil.exportExcel(templateExportParams, workTicketInfoMap); |
|
|
|
String os = System.getProperty("os.name"); |
|
|
|
} catch (Exception e) { |
|
|
|
//Windows操作系统
|
|
|
|
e.printStackTrace(); |
|
|
|
if (os != null && os.toLowerCase().startsWith("windows")) { |
|
|
|
|
|
|
|
log.info("当前系统版本是:{}", os); |
|
|
|
|
|
|
|
name = "D:/导出excel/电气第一种工作票模版.docx"; |
|
|
|
|
|
|
|
fos = new FileOutputStream(name); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
//其它操作系统
|
|
|
|
|
|
|
|
log.info("当前系统版本是:{}", os); |
|
|
|
|
|
|
|
String prefix = IdWorker.get32UUID(); |
|
|
|
|
|
|
|
name = templatePath + prefix + ".docx"; |
|
|
|
|
|
|
|
fos = new FileOutputStream(name); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
FileOutputStream fos = new FileOutputStream("F:\\idea项目\\flowable\\demo\\src\\main\\resources\\新电气第一种工作票模板5" + |
|
|
|
doc.write(fos); |
|
|
|
".xlsx"); |
|
|
|
fos.close(); |
|
|
|
workbook.write(fos); |
|
|
|
return name; |
|
|
|
// //上传xlsx至服务器
|
|
|
|
|
|
|
|
// try {
|
|
|
|
|
|
|
|
// ExcelUtil.upload(workbook, xlsSavePath, workTicketVo.getWorkTicket().getWorkContent() + PdfUtils.XLSX_SUFFIX);
|
|
|
|
|
|
|
|
// } catch (Exception e) {
|
|
|
|
|
|
|
|
// e.printStackTrace();
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// //将xlsx文件转换为pdf并保存
|
|
|
|
|
|
|
|
// String pdfFileName = workTicketVo.getWorkTicket().getWorkContent() + PdfUtils.PDF_SUFFIX;
|
|
|
|
|
|
|
|
// String xlsFileName = workTicketVo.getWorkTicket().getWorkContent() + PdfUtils.XLSX_SUFFIX;
|
|
|
|
|
|
|
|
// PdfUtils.convertPdf(xlsSavePath, xlsFileName, pdfSavePath, pdfFileName);
|
|
|
|
|
|
|
|
// String savePath = pdfSavePath + pdfFileName;
|
|
|
|
|
|
|
|
// // 设置response参数,可以打开下载页面
|
|
|
|
|
|
|
|
// ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
|
|
|
|
|
|
|
// HttpServletResponse response = servletRequestAttributes.getResponse();
|
|
|
|
|
|
|
|
// PdfUtils.readPdf(response, savePath);
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -650,7 +636,7 @@ public class TicketProcessServiceImpl implements TicketProcessService { |
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
WorkTicketInfoEntity workTicket = workTicketVo.getWorkTicket(); |
|
|
|
WorkTicketInfoEntity workTicket = workTicketVo.getWorkTicket(); |
|
|
|
//1. 工作对象
|
|
|
|
//1. 工作对象
|
|
|
|
Map<String, Object> workTicketInfoMap = PdfUtils.objectToMap(workTicket); |
|
|
|
Map<String, Object> workTicketInfoMap = PdfUtils.objectToMap(workTicket, true); |
|
|
|
|
|
|
|
|
|
|
|
//2. 安全措施
|
|
|
|
//2. 安全措施
|
|
|
|
List<WorkTicketSafetyMeasureEntity> safetyMeasuresList = workTicketVo.getSafetyMeasuresList(); |
|
|
|
List<WorkTicketSafetyMeasureEntity> safetyMeasuresList = workTicketVo.getSafetyMeasuresList(); |
|
|
@ -658,13 +644,25 @@ public class TicketProcessServiceImpl implements TicketProcessService { |
|
|
|
Map<String, List<WorkTicketSafetyMeasureEntity>> measureMap = safetyMeasuresList.stream().collect(Collectors.groupingBy(WorkTicketSafetyMeasureEntity::getType)); |
|
|
|
Map<String, List<WorkTicketSafetyMeasureEntity>> measureMap = safetyMeasuresList.stream().collect(Collectors.groupingBy(WorkTicketSafetyMeasureEntity::getType)); |
|
|
|
Arrays.stream(WorkTicketConstants.WorkTicketMeasureTypeEnum.class.getEnumConstants()).forEach(measureEnum -> { |
|
|
|
Arrays.stream(WorkTicketConstants.WorkTicketMeasureTypeEnum.class.getEnumConstants()).forEach(measureEnum -> { |
|
|
|
if (CollectionUtil.isNotEmpty(measureMap.get(measureEnum.getType()))) { |
|
|
|
if (CollectionUtil.isNotEmpty(measureMap.get(measureEnum.getType()))) { |
|
|
|
List<Map<String, Object>> mapList = measureMap.get(measureEnum.getType()).stream().map(measureVO -> { |
|
|
|
|
|
|
|
Map<String, Object> map = PdfUtils.objectToMap(measureVO); |
|
|
|
List<Map<String, Object>> mapList = new ArrayList<>(); |
|
|
|
|
|
|
|
int tempIndex = 1, index = 1; |
|
|
|
|
|
|
|
List<WorkTicketSafetyMeasureEntity> workTicketSafetyMeasureEntities = measureMap.get(measureEnum.getType()); |
|
|
|
|
|
|
|
for (WorkTicketSafetyMeasureEntity measureVO : workTicketSafetyMeasureEntities) { |
|
|
|
|
|
|
|
String type = measureEnum.getType(); |
|
|
|
|
|
|
|
if (tempIndex != Integer.valueOf(type)) { |
|
|
|
|
|
|
|
index = 1; |
|
|
|
|
|
|
|
tempIndex++; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Map<String, Object> map = PdfUtils.objectToMap(measureVO, true); |
|
|
|
|
|
|
|
map.put("index", index); |
|
|
|
map.put("safetyMeasure", ObjectUtil.isNotEmpty(map.get("measure")) ? map.get("measure") : null); |
|
|
|
map.put("safetyMeasure", ObjectUtil.isNotEmpty(map.get("measure")) ? map.get("measure") : null); |
|
|
|
String status = TicketConstants.SafetyMeasureStatusEnum.FINISH.getStatus().equals(measureVO.getStatus()) ? TicketConstants.SafetyMeasureStatusEnum.FINISH.getDescribe() : " "; |
|
|
|
String status = TicketConstants.SafetyMeasureStatusEnum.FINISH.getStatus().equals(measureVO.getStatus()) ? "√" : "×"; |
|
|
|
map.put("status", status); |
|
|
|
map.put("status", status); |
|
|
|
return map; |
|
|
|
mapList.add(map); |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
index++; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
workTicketInfoMap.put(measureEnum.getConvertAttributes(), mapList); |
|
|
|
workTicketInfoMap.put(measureEnum.getConvertAttributes(), mapList); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
workTicketInfoMap.put(measureEnum.getConvertAttributes(), new ArrayList<Map<String, String>>(1)); |
|
|
|
workTicketInfoMap.put(measureEnum.getConvertAttributes(), new ArrayList<Map<String, String>>(1)); |
|
|
@ -681,21 +679,26 @@ public class TicketProcessServiceImpl implements TicketProcessService { |
|
|
|
//4. 工作票延期
|
|
|
|
//4. 工作票延期
|
|
|
|
WorkTicketDelayEntity workTicketDelay = workTicketVo.getWorkTicketDelay(); |
|
|
|
WorkTicketDelayEntity workTicketDelay = workTicketVo.getWorkTicketDelay(); |
|
|
|
if (ObjectUtils.isNotEmpty(workTicketDelay)) { |
|
|
|
if (ObjectUtils.isNotEmpty(workTicketDelay)) { |
|
|
|
result.putAll(PdfUtils.objectToMap(workTicketDelay)); |
|
|
|
result.putAll(PdfUtils.objectToMap(workTicketDelay, true)); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
result.putAll(PdfUtils.objectToMap(new WorkTicketDelayEntity(), true)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//5. 工作结束
|
|
|
|
//5. 工作结束
|
|
|
|
WorkTicketFinish workTicketFinish = workTicketVo.getWorkTicketFinish(); |
|
|
|
WorkTicketFinish workTicketFinish = workTicketVo.getWorkTicketFinish(); |
|
|
|
if (ObjectUtils.isNotEmpty(workTicketFinish)) { |
|
|
|
if (ObjectUtils.isNotEmpty(workTicketFinish)) { |
|
|
|
result.putAll(PdfUtils.objectToMap(workTicketFinish)); |
|
|
|
result.putAll(PdfUtils.objectToMap(workTicketFinish, true)); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
result.putAll(PdfUtils.objectToMap(new WorkTicketFinish(), true)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//5. 工作票负责人变更
|
|
|
|
//5. 工作票负责人变更
|
|
|
|
WorkTicketPrincipalChangeEntity workTicketPrincipalChange = workTicketVo.getWorkTicketPrincipalChange(); |
|
|
|
WorkTicketPrincipalChangeEntity workTicketPrincipalChange = workTicketVo.getWorkTicketPrincipalChange(); |
|
|
|
if (ObjectUtils.isNotEmpty(workTicketPrincipalChange)) { |
|
|
|
if (ObjectUtils.isNotEmpty(workTicketPrincipalChange)) { |
|
|
|
result.putAll(PdfUtils.objectToMap(workTicketPrincipalChange)); |
|
|
|
result.putAll(PdfUtils.objectToMap(workTicketPrincipalChange, true)); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
result.putAll(PdfUtils.objectToMap(new WorkTicketPrincipalChangeEntity(), true)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|