|
|
@ -38,6 +38,7 @@ import com.hnac.hzims.ticket.utils.PdfUtils; |
|
|
|
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 com.hnac.hzims.ticket.workTicket.vo.TicketMonthVO; |
|
|
|
import com.hnac.hzims.ticket.workTicket.vo.TicketMonthVO; |
|
|
|
|
|
|
|
import com.hnac.hzims.ticket.workTicket.vo.WorkTicketReportStatisticVO; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
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; |
|
|
@ -681,20 +682,33 @@ public class StandardTicketInfoServiceImpl extends BaseServiceImpl<StandardTicke |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public TicketInfoStatisticVO operateTicketReportStatistic(String startDate, String endDate, List<Long> deptIdList) { |
|
|
|
public List<TicketInfoStatisticVO> operateTicketReportStatistic(String startDate, String endDate, List<Long> deptIdList) { |
|
|
|
TicketInfoStatisticVO result = new TicketInfoStatisticVO(); |
|
|
|
List<TicketInfoStatisticVO> res = new ArrayList<>(); |
|
|
|
result.setTicketInfoType("操作票"); |
|
|
|
|
|
|
|
List<OperateTicketStatisticVO> operateTicketReportStatistic = this.baseMapper.getOperateTicketReportStatistic(startDate, endDate, deptIdList); |
|
|
|
List<OperateTicketStatisticVO> operateTicketReportStatistic = this.baseMapper.getOperateTicketReportStatistic(startDate, endDate, deptIdList); |
|
|
|
|
|
|
|
Map<String, List<OperateTicketStatisticVO>> operateTicket = operateTicketReportStatistic.stream().filter(o -> ObjectUtil.isNotEmpty(o.getTicketType())) |
|
|
|
|
|
|
|
.collect(Collectors.groupingBy(OperateTicketStatisticVO::getTicketType)); |
|
|
|
if (CollectionUtil.isNotEmpty(operateTicketReportStatistic)) { |
|
|
|
if (CollectionUtil.isNotEmpty(operateTicketReportStatistic)) { |
|
|
|
//已完成数量
|
|
|
|
for (Map.Entry<String, List<OperateTicketStatisticVO>> typeOperateTicket : operateTicket.entrySet()) { |
|
|
|
int ticketInfoCompleteNum = operateTicketReportStatistic.stream().filter(item -> "结束".equals(item.getFlowTaskName())).collect(Collectors.toList()).size(); |
|
|
|
String type = TicketConstants.TicketTypeNameEnum.getTicketNameByType(typeOperateTicket.getKey()); |
|
|
|
//合格数量
|
|
|
|
//已完成数量
|
|
|
|
int ticketInfoQualifiedNum = operateTicketReportStatistic.stream().filter(ticket -> Func.isNotEmpty(ticket.getEvaluation()) && 1 == ticket.getEvaluation().intValue()).collect(Collectors.toList()).size(); |
|
|
|
int ticketInfoCompleteNum = operateTicketReportStatistic.stream().filter(item -> "结束".equals(item.getFlowTaskName())).collect(Collectors.toList()).size(); |
|
|
|
//计算合格率
|
|
|
|
//合格数量
|
|
|
|
double ticketInfoProportion = new BigDecimal(ticketInfoQualifiedNum / (double) operateTicketReportStatistic.size() * 100).setScale(2, RoundingMode.HALF_DOWN).doubleValue(); |
|
|
|
int ticketInfoQualifiedNum = operateTicketReportStatistic.stream().filter(ticket -> Func.isNotEmpty(ticket.getEvaluation()) && 1 == ticket.getEvaluation().intValue()).collect(Collectors.toList()).size(); |
|
|
|
result = TicketInfoStatisticVO.builder().ticketInfoType("操作票").ticketInfoNumber(operateTicketReportStatistic.size()).ticketInfoCompleteNum(ticketInfoCompleteNum).ticketInfoQualifiedNum(ticketInfoQualifiedNum).ticketInfoStartNum(operateTicketReportStatistic.size() - ticketInfoCompleteNum).ticketInfoProportion(ticketInfoProportion).build(); |
|
|
|
//废票数量
|
|
|
|
} |
|
|
|
int ticketInfoInvalidatedNum = operateTicketReportStatistic.stream().filter(item -> "作废".equals(item.getFlowTaskName())).collect(Collectors.toList()).size(); |
|
|
|
return result; |
|
|
|
//计算合格率
|
|
|
|
|
|
|
|
double ticketInfoProportion = new BigDecimal(ticketInfoQualifiedNum / (double) operateTicketReportStatistic.size() * 100).setScale(2, RoundingMode.HALF_DOWN).doubleValue(); |
|
|
|
|
|
|
|
TicketInfoStatisticVO ticketInfoStatisticVO = TicketInfoStatisticVO.builder().ticketInfoType(type) |
|
|
|
|
|
|
|
.ticketInfoNumber(operateTicketReportStatistic.size()) |
|
|
|
|
|
|
|
.ticketInfoCompleteNum(ticketInfoCompleteNum) |
|
|
|
|
|
|
|
.ticketInfoQualifiedNum(ticketInfoQualifiedNum) |
|
|
|
|
|
|
|
.ticketInfoInvalidatedNum(ticketInfoInvalidatedNum) |
|
|
|
|
|
|
|
.ticketInfoStartNum(operateTicketReportStatistic.size() - ticketInfoCompleteNum) |
|
|
|
|
|
|
|
.ticketInfoProportion(ticketInfoProportion).build(); |
|
|
|
|
|
|
|
res.add(ticketInfoStatisticVO); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return res; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -788,16 +802,17 @@ public class StandardTicketInfoServiceImpl extends BaseServiceImpl<StandardTicke |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 操作票-关联数据 |
|
|
|
* 操作票-关联数据 |
|
|
|
|
|
|
|
* |
|
|
|
* @param page |
|
|
|
* @param page |
|
|
|
* @param business |
|
|
|
* @param business |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public IPage<StandardTicketInfoVO> operate(IPage<StandardTicketInfoEntity> page,OperateVo business) { |
|
|
|
public IPage<StandardTicketInfoVO> operate(IPage<StandardTicketInfoEntity> page, OperateVo business) { |
|
|
|
QueryWrapper<StandardTicketInfoEntity> queryWrapper = new QueryWrapper<>(); |
|
|
|
QueryWrapper<StandardTicketInfoEntity> queryWrapper = new QueryWrapper<>(); |
|
|
|
queryWrapper.ge(Func.isNotEmpty(business.getStartTime()), "oper.create_time", business.getStartTime()); |
|
|
|
queryWrapper.ge(Func.isNotEmpty(business.getStartTime()), "oper.create_time", business.getStartTime()); |
|
|
|
queryWrapper.le(Func.isNotEmpty(business.getEndTime()), "oper.create_time", business.getEndTime()); |
|
|
|
queryWrapper.le(Func.isNotEmpty(business.getEndTime()), "oper.create_time", business.getEndTime()); |
|
|
|
queryWrapper.in(Func.isNotEmpty(business.getDeptIds()), "oper.create_dept",Func.toLongList(",",business.getDeptIds())); |
|
|
|
queryWrapper.in(Func.isNotEmpty(business.getDeptIds()), "oper.create_dept", Func.toLongList(",", business.getDeptIds())); |
|
|
|
queryWrapper.like(Func.isNotEmpty(business.getCode()), "oper.code", business.getCode()); |
|
|
|
queryWrapper.like(Func.isNotEmpty(business.getCode()), "oper.code", business.getCode()); |
|
|
|
queryWrapper.eq(Func.isNotEmpty(business.getTicketType()), "oper.ticket_type", business.getTicketType()); |
|
|
|
queryWrapper.eq(Func.isNotEmpty(business.getTicketType()), "oper.ticket_type", business.getTicketType()); |
|
|
|
queryWrapper.eq(Func.isNotEmpty(business.getStatus()), "eva.status", business.getStatus()); |
|
|
|
queryWrapper.eq(Func.isNotEmpty(business.getStatus()), "eva.status", business.getStatus()); |
|
|
@ -816,11 +831,11 @@ public class StandardTicketInfoServiceImpl extends BaseServiceImpl<StandardTicke |
|
|
|
queryWrapper.eq(StandardTicketInfoEntity::getFlowTaskName, entity.getFlowTaskName()); |
|
|
|
queryWrapper.eq(StandardTicketInfoEntity::getFlowTaskName, entity.getFlowTaskName()); |
|
|
|
} |
|
|
|
} |
|
|
|
List<StandardTicketInfoEntity> standardTicketInfoEntities = super.baseMapper.selectList(queryWrapper); |
|
|
|
List<StandardTicketInfoEntity> standardTicketInfoEntities = super.baseMapper.selectList(queryWrapper); |
|
|
|
List<StandardTicketExportVO> list=new ArrayList<>(); |
|
|
|
List<StandardTicketExportVO> list = new ArrayList<>(); |
|
|
|
if (CollectionUtils.isNotEmpty(standardTicketInfoEntities)){ |
|
|
|
if (CollectionUtils.isNotEmpty(standardTicketInfoEntities)) { |
|
|
|
List<StandardTicketExportVO> standardTicketInfoVOS = standardTicketInfoEntities.parallelStream().map(standardTicketInfoEntity -> { |
|
|
|
List<StandardTicketExportVO> standardTicketInfoVOS = standardTicketInfoEntities.parallelStream().map(standardTicketInfoEntity -> { |
|
|
|
StandardTicketExportVO exportVO = new StandardTicketExportVO(); |
|
|
|
StandardTicketExportVO exportVO = new StandardTicketExportVO(); |
|
|
|
try { |
|
|
|
try { |
|
|
|
exportVO.setCompany(Optional.ofNullable(standardTicketInfoEntity.getCompany()).orElse(null)); |
|
|
|
exportVO.setCompany(Optional.ofNullable(standardTicketInfoEntity.getCompany()).orElse(null)); |
|
|
|
exportVO.setTicketType(Optional.ofNullable(DictCache.getValue(TicketConstants.TICKET_TYPE, standardTicketInfoEntity.getTicketType())).orElse(null)); |
|
|
|
exportVO.setTicketType(Optional.ofNullable(DictCache.getValue(TicketConstants.TICKET_TYPE, standardTicketInfoEntity.getTicketType())).orElse(null)); |
|
|
|
exportVO.setCode(Optional.ofNullable(standardTicketInfoEntity.getCode()).orElse(null)); |
|
|
|
exportVO.setCode(Optional.ofNullable(standardTicketInfoEntity.getCode()).orElse(null)); |
|
|
@ -853,22 +868,23 @@ public class StandardTicketInfoServiceImpl extends BaseServiceImpl<StandardTicke |
|
|
|
exportVO.setEndTime(Optional.ofNullable(DateUtil.format(standardTicketInfoEntity.getEndTime(), TicketConstants.TICKET_DATE_PATTERN)).orElse("")); |
|
|
|
exportVO.setEndTime(Optional.ofNullable(DateUtil.format(standardTicketInfoEntity.getEndTime(), TicketConstants.TICKET_DATE_PATTERN)).orElse("")); |
|
|
|
exportVO.setIsEvaluate("未评价"); |
|
|
|
exportVO.setIsEvaluate("未评价"); |
|
|
|
if (ObjectUtils.isNotEmpty(standardTicketInfoEntity.getIsEvaluate())) { |
|
|
|
if (ObjectUtils.isNotEmpty(standardTicketInfoEntity.getIsEvaluate())) { |
|
|
|
if (1==standardTicketInfoEntity.getIsEvaluate() ) { |
|
|
|
if (1 == standardTicketInfoEntity.getIsEvaluate()) { |
|
|
|
TicketInfoEvaluateEntity evaluateEntity = ticketInfoEvaluateService.getOne(new LambdaQueryWrapper<TicketInfoEvaluateEntity>() {{ |
|
|
|
TicketInfoEvaluateEntity evaluateEntity = ticketInfoEvaluateService.getOne(new LambdaQueryWrapper<TicketInfoEvaluateEntity>() {{ |
|
|
|
eq(TicketInfoEvaluateEntity::getTicketId, standardTicketInfoEntity.getId()); |
|
|
|
eq(TicketInfoEvaluateEntity::getTicketId, standardTicketInfoEntity.getId()); |
|
|
|
}}.last(" limit 1")); |
|
|
|
}}.last(" limit 1")); |
|
|
|
if ( ObjectUtil.isNotEmpty(evaluateEntity)) { |
|
|
|
if (ObjectUtil.isNotEmpty(evaluateEntity)) { |
|
|
|
exportVO.setIsEvaluate(evaluateEntity.getStatus() == 1 ? "合格" : "不合格"); |
|
|
|
exportVO.setIsEvaluate(evaluateEntity.getStatus() == 1 ? "合格" : "不合格"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}}catch (Exception e){ |
|
|
|
|
|
|
|
log.error("转换失败----》"+e.toString()+standardTicketInfoEntity.toString()); |
|
|
|
|
|
|
|
System.out.println("转换失败----》"+e.toString()+standardTicketInfoEntity.toString()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
return exportVO; |
|
|
|
} catch (Exception e) { |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
log.error("转换失败----》" + e.toString() + standardTicketInfoEntity.toString()); |
|
|
|
return standardTicketInfoVOS; |
|
|
|
System.out.println("转换失败----》" + e.toString() + standardTicketInfoEntity.toString()); |
|
|
|
}else { |
|
|
|
} |
|
|
|
|
|
|
|
return exportVO; |
|
|
|
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
|
|
return standardTicketInfoVOS; |
|
|
|
|
|
|
|
} else { |
|
|
|
return list; |
|
|
|
return list; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -876,8 +892,8 @@ public class StandardTicketInfoServiceImpl extends BaseServiceImpl<StandardTicke |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void exportOperateTicket(HttpServletResponse response, Long ticketId) { |
|
|
|
public void exportOperateTicket(HttpServletResponse response, Long ticketId) { |
|
|
|
StandardTicketInfoVO detail = this.detail(ticketId).getData(); |
|
|
|
StandardTicketInfoVO detail = this.detail(ticketId).getData(); |
|
|
|
Map<String,Object> params = com.hnac.hzims.ticket.utils.ObjectUtils.obj2Map(detail); |
|
|
|
Map<String, Object> params = com.hnac.hzims.ticket.utils.ObjectUtils.obj2Map(detail); |
|
|
|
params.put("measureMapList",this.convert(detail.getStandardTicketMeasureVOList())); |
|
|
|
params.put("measureMapList", this.convert(detail.getStandardTicketMeasureVOList())); |
|
|
|
XWPFDocument xwpfDocument = null; |
|
|
|
XWPFDocument xwpfDocument = null; |
|
|
|
String fileName = "template/电气操作票.docx"; |
|
|
|
String fileName = "template/电气操作票.docx"; |
|
|
|
try { |
|
|
|
try { |
|
|
@ -885,15 +901,15 @@ public class StandardTicketInfoServiceImpl extends BaseServiceImpl<StandardTicke |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
} |
|
|
|
String wordPath = this.getFileSavePath() + detail.getTitle() +".docx"; |
|
|
|
String wordPath = this.getFileSavePath() + detail.getTitle() + ".docx"; |
|
|
|
try { |
|
|
|
try { |
|
|
|
this.exportTicketWord(Lists.newArrayList(xwpfDocument),wordPath); |
|
|
|
this.exportTicketWord(Lists.newArrayList(xwpfDocument), wordPath); |
|
|
|
} catch (IOException e) { |
|
|
|
} catch (IOException e) { |
|
|
|
throw new RuntimeException(e); |
|
|
|
throw new RuntimeException(e); |
|
|
|
} |
|
|
|
} |
|
|
|
String pdfPath = this.getFileSavePath() + detail.getTitle() +".pdf"; |
|
|
|
String pdfPath = this.getFileSavePath() + detail.getTitle() + ".pdf"; |
|
|
|
AsposeUtil.wordToPdf(wordPath,pdfPath); |
|
|
|
AsposeUtil.wordToPdf(wordPath, pdfPath); |
|
|
|
PdfUtils.readPdf(response,pdfPath); |
|
|
|
PdfUtils.readPdf(response, pdfPath); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void exportTicketWord(List<XWPFDocument> documents, String savePath) throws IOException { |
|
|
|
private void exportTicketWord(List<XWPFDocument> documents, String savePath) throws IOException { |
|
|
@ -902,39 +918,35 @@ public class StandardTicketInfoServiceImpl extends BaseServiceImpl<StandardTicke |
|
|
|
for (XWPFDocument document : documents) { |
|
|
|
for (XWPFDocument document : documents) { |
|
|
|
document.write(out); |
|
|
|
document.write(out); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
catch (Exception e) { |
|
|
|
|
|
|
|
e.printStackTrace(); |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
} finally { |
|
|
|
finally { |
|
|
|
|
|
|
|
out.close(); |
|
|
|
out.close(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private String getFileSavePath() { |
|
|
|
private String getFileSavePath() { |
|
|
|
String os = System.getProperty("os.name").toLowerCase(); |
|
|
|
String os = System.getProperty("os.name").toLowerCase(); |
|
|
|
if("linux".equals(os)) { |
|
|
|
if ("linux".equals(os)) { |
|
|
|
return pdfSavePath; |
|
|
|
return pdfSavePath; |
|
|
|
} |
|
|
|
} else { |
|
|
|
else { |
|
|
|
|
|
|
|
return "E://template/"; |
|
|
|
return "E://template/"; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private List<Map> convert (List<? extends Object> list) { |
|
|
|
private List<Map> convert(List<? extends Object> list) { |
|
|
|
if(CollectionUtil.isNotEmpty(list)) { |
|
|
|
if (CollectionUtil.isNotEmpty(list)) { |
|
|
|
return IntStream.iterate(0, index -> index + 1).limit(list.size() > 25 ? list.size() : 25).mapToObj(index -> { |
|
|
|
return IntStream.iterate(0, index -> index + 1).limit(list.size() > 25 ? list.size() : 25).mapToObj(index -> { |
|
|
|
if(index <= list.size() - 1) { |
|
|
|
if (index <= list.size() - 1) { |
|
|
|
Map result = com.hnac.hzims.ticket.utils.ObjectUtils.obj2Map(list.get(index)); |
|
|
|
Map result = com.hnac.hzims.ticket.utils.ObjectUtils.obj2Map(list.get(index)); |
|
|
|
result.put("index",index + 1); |
|
|
|
result.put("index", index + 1); |
|
|
|
result.put("status",TicketConstants.MATTER_FINISH_STATUS == result.get("status") ? "√" : null); |
|
|
|
result.put("status", TicketConstants.MATTER_FINISH_STATUS == result.get("status") ? "√" : null); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} else { |
|
|
|
else { |
|
|
|
|
|
|
|
return new HashMap(); |
|
|
|
return new HashMap(); |
|
|
|
} |
|
|
|
} |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
} |
|
|
|
return IntStream.iterate(0,index -> index + 1).limit(4).mapToObj(index -> new HashMap()).collect(Collectors.toList()); |
|
|
|
return IntStream.iterate(0, index -> index + 1).limit(4).mapToObj(index -> new HashMap()).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|