|
|
@ -1,6 +1,7 @@ |
|
|
|
package com.hnac.hzims.ticket.standardTicket.service.impl; |
|
|
|
package com.hnac.hzims.ticket.standardTicket.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
import cn.afterturn.easypoi.excel.entity.TemplateExportParams; |
|
|
|
import cn.afterturn.easypoi.excel.entity.TemplateExportParams; |
|
|
|
|
|
|
|
import cn.afterturn.easypoi.word.WordExportUtil; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
@ -8,6 +9,7 @@ import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
|
|
|
|
import com.google.common.collect.Lists; |
|
|
|
import com.hnac.hzims.ticket.allTicket.entity.TicketInfoEvaluateEntity; |
|
|
|
import com.hnac.hzims.ticket.allTicket.entity.TicketInfoEvaluateEntity; |
|
|
|
import com.hnac.hzims.ticket.allTicket.service.TicketInfoEvaluateService; |
|
|
|
import com.hnac.hzims.ticket.allTicket.service.TicketInfoEvaluateService; |
|
|
|
import com.hnac.hzims.ticket.allTicket.vo.DoublePassRateVO; |
|
|
|
import com.hnac.hzims.ticket.allTicket.vo.DoublePassRateVO; |
|
|
@ -30,6 +32,7 @@ import com.hnac.hzims.ticket.standardTicket.wrapper.StandardTicketInfoWrapper; |
|
|
|
import com.hnac.hzims.ticket.twoTicket.vo.operation.StandardTicketInfoVo; |
|
|
|
import com.hnac.hzims.ticket.twoTicket.vo.operation.StandardTicketInfoVo; |
|
|
|
import com.hnac.hzims.ticket.twoTicket.vo.operation.StandardTicketMeasureVo; |
|
|
|
import com.hnac.hzims.ticket.twoTicket.vo.operation.StandardTicketMeasureVo; |
|
|
|
import com.hnac.hzims.ticket.twoTicket.vo.ticket.StandardTicketCountQueryVo; |
|
|
|
import com.hnac.hzims.ticket.twoTicket.vo.ticket.StandardTicketCountQueryVo; |
|
|
|
|
|
|
|
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.workTicket.entity.WorkTicketInfoEntity; |
|
|
|
import com.hnac.hzims.ticket.workTicket.entity.WorkTicketInfoEntity; |
|
|
@ -39,6 +42,7 @@ import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
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.BaseEntity; |
|
|
|
import org.springblade.core.mp.base.BaseEntity; |
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl; |
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl; |
|
|
@ -64,6 +68,8 @@ import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
|
|
|
import java.io.FileOutputStream; |
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.math.RoundingMode; |
|
|
|
import java.math.RoundingMode; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.time.LocalDateTime; |
|
|
@ -73,6 +79,7 @@ import java.time.temporal.TemporalAdjusters; |
|
|
|
import java.util.*; |
|
|
|
import java.util.*; |
|
|
|
import java.util.concurrent.atomic.AtomicInteger; |
|
|
|
import java.util.concurrent.atomic.AtomicInteger; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
import java.util.stream.IntStream; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @author hx |
|
|
|
* @author hx |
|
|
@ -865,4 +872,69 @@ public class StandardTicketInfoServiceImpl extends BaseServiceImpl<StandardTicke |
|
|
|
return list; |
|
|
|
return list; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void exportOperateTicket(HttpServletResponse response, Long ticketId) { |
|
|
|
|
|
|
|
StandardTicketInfoVO detail = this.detail(ticketId).getData(); |
|
|
|
|
|
|
|
Map<String,Object> params = com.hnac.hzims.ticket.utils.ObjectUtils.obj2Map(detail); |
|
|
|
|
|
|
|
params.put("measureMapList",this.convert(detail.getStandardTicketMeasureVOList())); |
|
|
|
|
|
|
|
XWPFDocument xwpfDocument = null; |
|
|
|
|
|
|
|
String fileName = "template/电气操作票.docx"; |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
xwpfDocument = WordExportUtil.exportWord07(fileName, params); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
String wordPath = this.getFileSavePath() + detail.getTitle() +".docx"; |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
this.exportTicketWord(Lists.newArrayList(xwpfDocument),wordPath); |
|
|
|
|
|
|
|
} catch (IOException e) { |
|
|
|
|
|
|
|
throw new RuntimeException(e); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
String pdfPath = this.getFileSavePath() + detail.getTitle() +".pdf"; |
|
|
|
|
|
|
|
AsposeUtil.wordToPdf(wordPath,pdfPath); |
|
|
|
|
|
|
|
PdfUtils.readPdf(response,pdfPath); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void exportTicketWord(List<XWPFDocument> documents, String savePath) throws IOException { |
|
|
|
|
|
|
|
FileOutputStream out = new FileOutputStream(savePath); |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
for (XWPFDocument document : documents) { |
|
|
|
|
|
|
|
document.write(out); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
catch (Exception e) { |
|
|
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
finally { |
|
|
|
|
|
|
|
out.close(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String getFileSavePath() { |
|
|
|
|
|
|
|
String os = System.getProperty("os.name").toLowerCase(); |
|
|
|
|
|
|
|
if("linux".equals(os)) { |
|
|
|
|
|
|
|
return pdfSavePath; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
return "E://template/"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private List<Map> convert (List<? extends Object> list) { |
|
|
|
|
|
|
|
if(CollectionUtil.isNotEmpty(list)) { |
|
|
|
|
|
|
|
return IntStream.iterate(0, index -> index + 1).limit(list.size() > 25 ? list.size() : 25).mapToObj(index -> { |
|
|
|
|
|
|
|
if(index <= list.size() - 1) { |
|
|
|
|
|
|
|
Map result = com.hnac.hzims.ticket.utils.ObjectUtils.obj2Map(list.get(index)); |
|
|
|
|
|
|
|
result.put("index",index + 1); |
|
|
|
|
|
|
|
result.put("status",TicketConstants.MATTER_FINISH_STATUS == result.get("status") ? "√" : null); |
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
return new HashMap(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return IntStream.iterate(0,index -> index + 1).limit(4).mapToObj(index -> new HashMap()).collect(Collectors.toList()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|