|
|
@ -8,7 +8,6 @@ import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.google.common.collect.Lists; |
|
|
|
|
|
|
|
import com.hnac.hzims.message.entity.config.PushConfigEntity; |
|
|
|
import com.hnac.hzims.message.entity.config.PushConfigEntity; |
|
|
|
import com.hnac.hzims.message.fegin.IMessageConfigClient; |
|
|
|
import com.hnac.hzims.message.fegin.IMessageConfigClient; |
|
|
|
import com.hnac.hzims.operational.access.dto.OperAccessTaskDTO; |
|
|
|
import com.hnac.hzims.operational.access.dto.OperAccessTaskDTO; |
|
|
@ -22,9 +21,12 @@ import com.hnac.hzims.ticket.allTicket.service.TicketInfoEvaluateService; |
|
|
|
import com.hnac.hzims.ticket.allTicket.vo.TicketInfoStatisticVO; |
|
|
|
import com.hnac.hzims.ticket.allTicket.vo.TicketInfoStatisticVO; |
|
|
|
import com.hnac.hzims.ticket.constants.TicketConstants; |
|
|
|
import com.hnac.hzims.ticket.constants.TicketConstants; |
|
|
|
import com.hnac.hzims.ticket.constants.WorkTicketConstants; |
|
|
|
import com.hnac.hzims.ticket.constants.WorkTicketConstants; |
|
|
|
|
|
|
|
import com.hnac.hzims.ticket.twoTicket.entity.WorkTicketFinish; |
|
|
|
import com.hnac.hzims.ticket.twoTicket.service.IFirstWorkTicketService; |
|
|
|
import com.hnac.hzims.ticket.twoTicket.service.IFirstWorkTicketService; |
|
|
|
|
|
|
|
import com.hnac.hzims.ticket.twoTicket.service.IWorkTicketFinishService; |
|
|
|
import com.hnac.hzims.ticket.utils.AsposeUtil; |
|
|
|
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.ObjectUtils; |
|
|
|
import com.hnac.hzims.ticket.utils.PdfUtils; |
|
|
|
import com.hnac.hzims.ticket.utils.PdfUtils; |
|
|
|
import com.hnac.hzims.ticket.workTicket.dto.*; |
|
|
|
import com.hnac.hzims.ticket.workTicket.dto.*; |
|
|
|
import com.hnac.hzims.ticket.workTicket.entity.*; |
|
|
|
import com.hnac.hzims.ticket.workTicket.entity.*; |
|
|
@ -59,13 +61,13 @@ import javax.servlet.http.HttpServletResponse; |
|
|
|
import java.io.FileNotFoundException; |
|
|
|
import java.io.FileNotFoundException; |
|
|
|
import java.io.FileOutputStream; |
|
|
|
import java.io.FileOutputStream; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.UnsupportedEncodingException; |
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.util.*; |
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
import java.util.stream.IntStream; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @author hx |
|
|
|
* @author hx |
|
|
@ -90,6 +92,7 @@ public class FirstWorkTicketServiceImpl extends BaseServiceImpl<WorkTicketInfoMa |
|
|
|
private final IWorkTicketInfoService ticketInfoService; |
|
|
|
private final IWorkTicketInfoService ticketInfoService; |
|
|
|
private final TicketInfoEvaluateService evaluateService; |
|
|
|
private final TicketInfoEvaluateService evaluateService; |
|
|
|
private final IWorkTicketContentService contentService; |
|
|
|
private final IWorkTicketContentService contentService; |
|
|
|
|
|
|
|
private final IWorkTicketFinishService workTicketFinishService; |
|
|
|
|
|
|
|
|
|
|
|
/**工作票流程修改后的key**/ |
|
|
|
/**工作票流程修改后的key**/ |
|
|
|
@Value("${hzims.ticket.first-work-flow-key-new}") |
|
|
|
@Value("${hzims.ticket.first-work-flow-key-new}") |
|
|
@ -276,72 +279,114 @@ public class FirstWorkTicketServiceImpl extends BaseServiceImpl<WorkTicketInfoMa |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void preview(HttpServletResponse response,Long ticketId) { |
|
|
|
public void preview(HttpServletResponse response,Long ticketId) { |
|
|
|
Map measure = new HashMap(3) {{ |
|
|
|
WorkTicketInfoEntity workTicketInfoEntity = this.getById(ticketId); |
|
|
|
put("index",1); |
|
|
|
Map params = this.getTicketParamById(ticketId,workTicketInfoEntity); |
|
|
|
put("safetyMeasure","暗室逢灯你根本就发给你开始的那数据打你电话"); |
|
|
|
String tempFileName = WorkTicketConstants.TicketSignageEnum.getTempFileNameByType(workTicketInfoEntity.getType()); |
|
|
|
put("status","√"); |
|
|
|
Assert.isTrue(StringUtil.isNotBlank(tempFileName),() -> { |
|
|
|
}}; |
|
|
|
throw new ServiceException("未找到模板文件,预览失败!"); |
|
|
|
Map<String,Object> params = new HashMap(){{ |
|
|
|
}); |
|
|
|
put("projectName","海南三亚一级站"); |
|
|
|
String wordPath = this.getFileSavePath() + params.get("code") + "_" + params.get("addressEquName") +".docx"; |
|
|
|
put("code","GY-D2-2311--004"); |
|
|
|
this.exportTicketWord("template/"+tempFileName, wordPath, params); |
|
|
|
put("principalName","杨汪洋"); |
|
|
|
String pdfPath = this.getFileSavePath() + params.get("code") + "_" + params.get("addressEquName") +".pdf"; |
|
|
|
put("classGroupName","白班"); |
|
|
|
AsposeUtil.wordToPdf(wordPath,pdfPath); |
|
|
|
put("classGroupMembersName","吴先强,唐钰,彭晨洋,黄兴,肖璐"); |
|
|
|
PdfUtils.readPdf(response,pdfPath); |
|
|
|
put("totalPerson","5"); |
|
|
|
} |
|
|
|
put("addressEquName","#1变压器出线-三洪奇"); |
|
|
|
|
|
|
|
put("workContent","#29电池舱第四簇高压箱"); |
|
|
|
private String getFileSavePath() { |
|
|
|
put("ps_year","2023"); |
|
|
|
String os = System.getProperty("os.name").toLowerCase(); |
|
|
|
put("ps_month","11"); |
|
|
|
if("linux".equals(os)) { |
|
|
|
put("ps_day","11"); |
|
|
|
return pdfSavePath; |
|
|
|
put("ps_hour","16"); |
|
|
|
} |
|
|
|
put("ps_minuter","45"); |
|
|
|
else { |
|
|
|
put("pe_year","2023"); |
|
|
|
return "E://template/"; |
|
|
|
put("pe_month","11"); |
|
|
|
} |
|
|
|
put("pe_day","12"); |
|
|
|
} |
|
|
|
put("pe_hour","11"); |
|
|
|
|
|
|
|
put("pe_minuter","13"); |
|
|
|
private Map<String,Object> getTicketParamById(Long ticketId,WorkTicketInfoEntity workTicketInfoEntity) { |
|
|
|
put("matterLibraryListOne", Lists.newArrayList(measure,measure,measure,measure,measure,measure,measure,measure)); |
|
|
|
Map params = ObjectUtils.obj2Map(workTicketInfoEntity); |
|
|
|
put("signerName","杨汪洋"); |
|
|
|
params.put("signerName",Optional.ofNullable(workTicketInfoEntity.getSigner()).map(UserCache::getUser).map(User::getName).orElse(null)); |
|
|
|
put("s_year","2023"); |
|
|
|
// 获取两票安措
|
|
|
|
put("s_month","11"); |
|
|
|
List<WorkTicketSafetyMeasureEntity> measures = workTicketSafetyMeasureService.selectByTicketId(ticketId); |
|
|
|
put("s_day","12"); |
|
|
|
if(CollectionUtil.isNotEmpty(measures)) { |
|
|
|
put("s_hour","11"); |
|
|
|
Map<String, List<Map>> measureMap = measures.stream().map(ObjectUtils::obj2Map).peek(m -> m.put("status", TicketConstants.SafetyMeasureStatusEnum.FINISH.getStatus().equals(m.get("status")) ? "√" : null)).collect(Collectors.groupingBy(m -> (String) m.get("type"))); |
|
|
|
put("s_minuter","13"); |
|
|
|
Arrays.stream(WorkTicketConstants.WorkTicketMeasureTypeEnum.class.getEnumConstants()).forEach(e -> { |
|
|
|
put("jobReceiver","杨汪洋"); |
|
|
|
if(ObjectUtil.isNotEmpty(measureMap.get(e.getType()))) { |
|
|
|
put("r_year","2023"); |
|
|
|
List<Map> list = measureMap.get(e.getType()); |
|
|
|
put("r_month","11"); |
|
|
|
List<HashMap<String, Object>> measureList = IntStream.iterate(0, index -> index + 1).limit(list.size()> 4 ? list.size() : 4).mapToObj(index -> { |
|
|
|
put("r_day","12"); |
|
|
|
if(list.size() != 0 && list.size() >= index + 1) { |
|
|
|
put("r_hour","11"); |
|
|
|
HashMap<String, Object> map = new HashMap<String, Object>() {{ |
|
|
|
put("r_minuter","13"); |
|
|
|
putAll(list.get(index)); |
|
|
|
put("l_year","2023"); |
|
|
|
put("index", index + 1); |
|
|
|
put("l_month","11"); |
|
|
|
}}; |
|
|
|
put("l_day","12"); |
|
|
|
return map; |
|
|
|
put("l_hour","11"); |
|
|
|
} |
|
|
|
put("l_minuter","13"); |
|
|
|
return new HashMap<String,Object>(); |
|
|
|
put("licensorName","杨汪洋"); |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
put("principalName1","杨汪洋"); |
|
|
|
params.put(e.getConvertAttributes(),measureList); |
|
|
|
put("groundNum","11"); |
|
|
|
} |
|
|
|
put("dismantleNum","12"); |
|
|
|
else { |
|
|
|
put("retainNum","8"); |
|
|
|
params.put(e.getConvertAttributes(),IntStream.iterate(0, index -> index + 1).limit(4).mapToObj(index -> new HashMap<String,Object>()).collect(Collectors.toList())); |
|
|
|
put("brakeNumber","A7758258"); |
|
|
|
} |
|
|
|
put("licensorName2","A7758258"); |
|
|
|
}); |
|
|
|
put("isSafety ","☑"); |
|
|
|
List<Map> addressList = measureMap.get(WorkTicketConstants.WorkTicketMeasureTypeEnum.Five.getType()); |
|
|
|
put("isHazard","☑"); |
|
|
|
List<Map> fillList = measureMap.get(WorkTicketConstants.WorkTicketMeasureTypeEnum.Flow.getType()); |
|
|
|
put("isRailway","☑"); |
|
|
|
List<Map<String, Object>> measureList = IntStream.iterate(0, index -> index + 1).limit(4).mapToObj(index -> { |
|
|
|
put("isLimited","☑"); |
|
|
|
Map<String,Object> result = new HashMap(); |
|
|
|
}}; |
|
|
|
if(CollectionUtil.isNotEmpty(addressList) && addressList.size() >= index + 1) { |
|
|
|
|
|
|
|
result.put("safetyMeasure",addressList.get(index).get("measure")); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(CollectionUtil.isNotEmpty(fillList) && fillList.size() >= index + 1) { |
|
|
|
|
|
|
|
result.put("safetyMeasure1",fillList.get(index).get("measure")); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
|
|
params.put("matterLibraryList",measureList); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
params.put("isSafety",workTicketInfoEntity.getIsSafety() ? "☑" : "□"); |
|
|
|
|
|
|
|
params.put("isHazard",workTicketInfoEntity.getIsHazard() ? "☑" : "□"); |
|
|
|
|
|
|
|
params.put("isRailway",workTicketInfoEntity.getIsRailway() ? "☑" : "□"); |
|
|
|
|
|
|
|
params.put("isLimited",workTicketInfoEntity.getIsLimited() ? "☑" : "□"); |
|
|
|
|
|
|
|
params.put("isStart",workTicketInfoEntity.getIsStart() ? "☑" : "□"); |
|
|
|
|
|
|
|
// 许可人许可环节
|
|
|
|
|
|
|
|
if(ObjectUtil.isNotEmpty(workTicketInfoEntity.getLicenseTime())) { |
|
|
|
|
|
|
|
params.put("licensorName",Optional.ofNullable(workTicketInfoEntity.getLicensor()).map(UserCache::getUser).map(User::getName).orElse(null)); |
|
|
|
|
|
|
|
params.put("principalName1",params.get("principalName")); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
WorkTicketFinish finish = workTicketFinishService.selectByTicketId(ticketId); |
|
|
|
|
|
|
|
if(ObjectUtil.isNotEmpty(finish)) { |
|
|
|
|
|
|
|
if(Func.isNotEmpty(finish.getWorkEndTime())) { |
|
|
|
|
|
|
|
params.put("principalName3",params.get("principalName")); |
|
|
|
|
|
|
|
params.put("licensorName1",params.get("licensorName")); |
|
|
|
|
|
|
|
params.putAll(ObjectUtils.LocalDateConvertMap(finish.getWorkEndTime(),"f","_")); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(Func.isNotEmpty(finish.getLicensorEndTime())) { |
|
|
|
|
|
|
|
params.put("licensorName2",params.get("licensorName")); |
|
|
|
|
|
|
|
params.put("groundNum",finish.getGroundNum()); |
|
|
|
|
|
|
|
params.put("dismantleNum",finish.getDismantleNum()); |
|
|
|
|
|
|
|
params.put("retainNum",finish.getRetainNum()); |
|
|
|
|
|
|
|
params.put("brakeNumber",finish.getBrakeNumber()); |
|
|
|
|
|
|
|
params.put("tellContent",finish.getTellContent()); |
|
|
|
|
|
|
|
params.putAll(ObjectUtils.LocalDateConvertMap(finish.getLicensorEndTime(),"e","_")); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return params; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* word模板填充内容并将结果导出 |
|
|
|
|
|
|
|
* @param templatePath 模板路径 |
|
|
|
|
|
|
|
* @param savePath 结果导出路径 |
|
|
|
|
|
|
|
* @param params 填充对象 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private void exportTicketWord(String templatePath, String savePath, Map params) { |
|
|
|
XWPFDocument xwpfDocument = null; |
|
|
|
XWPFDocument xwpfDocument = null; |
|
|
|
try { |
|
|
|
try { |
|
|
|
xwpfDocument = WordExportUtil.exportWord07("template/电气第一种工作票模版新.docx", params); |
|
|
|
xwpfDocument = WordExportUtil.exportWord07(templatePath, params); |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
throw new RuntimeException(e); |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
} |
|
|
|
String wordPath = "E://template/" + params.get("code") + "_" + params.get("addressEquName") +".docx"; |
|
|
|
|
|
|
|
String pdfPath = "E://template/" + params.get("code") + "_" + params.get("addressEquName") +".pdf"; |
|
|
|
|
|
|
|
// String pdfPath = pdfSavePath + "/" + params.get("code") + "_" + params.get("addressEquName") +".pdf";
|
|
|
|
|
|
|
|
FileOutputStream outputStream = null; |
|
|
|
FileOutputStream outputStream = null; |
|
|
|
try { |
|
|
|
try { |
|
|
|
outputStream = new FileOutputStream(wordPath); |
|
|
|
outputStream = new FileOutputStream(savePath); |
|
|
|
} catch (FileNotFoundException e) { |
|
|
|
} catch (FileNotFoundException e) { |
|
|
|
throw new RuntimeException(e); |
|
|
|
throw new RuntimeException(e); |
|
|
|
} |
|
|
|
} |
|
|
@ -358,8 +403,6 @@ public class FirstWorkTicketServiceImpl extends BaseServiceImpl<WorkTicketInfoMa |
|
|
|
throw new RuntimeException(e); |
|
|
|
throw new RuntimeException(e); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
AsposeUtil.wordToPdf(wordPath,pdfPath); |
|
|
|
|
|
|
|
PdfUtils.readPdf(response,pdfPath); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|