|
|
@ -1,53 +1,60 @@ |
|
|
|
package com.hnac.hzims.ticket.library.service.impl; |
|
|
|
package com.hnac.hzims.ticket.library.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
import cn.afterturn.easypoi.excel.ExcelExportUtil; |
|
|
|
|
|
|
|
import cn.afterturn.easypoi.excel.entity.TemplateExportParams; |
|
|
|
import cn.afterturn.easypoi.excel.entity.TemplateExportParams; |
|
|
|
|
|
|
|
import cn.afterturn.easypoi.word.WordExportUtil; |
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
|
|
|
import com.google.common.collect.Lists; |
|
|
|
import com.google.common.collect.Lists; |
|
|
|
|
|
|
|
import com.hnac.hzims.common.logs.utils.StringUtils; |
|
|
|
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.library.dto.TicketMatterGroupDTO; |
|
|
|
import com.hnac.hzims.ticket.library.dto.TicketMatterGroupDTO; |
|
|
|
import com.hnac.hzims.ticket.library.entity.TicketMatterGroupEntity; |
|
|
|
import com.hnac.hzims.ticket.library.entity.TicketMatterGroupEntity; |
|
|
|
import com.hnac.hzims.ticket.library.mapper.TicketMatterGroupMapper; |
|
|
|
import com.hnac.hzims.ticket.library.mapper.TicketMatterGroupMapper; |
|
|
|
import com.hnac.hzims.ticket.library.service.ITicketMatterGroupService; |
|
|
|
import com.hnac.hzims.ticket.library.service.ITicketMatterGroupService; |
|
|
|
import com.hnac.hzims.ticket.library.vo.TicketMatterGroupVO; |
|
|
|
import com.hnac.hzims.ticket.library.vo.TicketMatterGroupVO; |
|
|
|
import com.hnac.hzims.ticket.library.wrapper.TicketMatterGroupWrapper; |
|
|
|
import com.hnac.hzims.ticket.library.wrapper.TicketMatterGroupWrapper; |
|
|
|
|
|
|
|
import com.hnac.hzims.ticket.standardTicket.service.OperationTicketService; |
|
|
|
|
|
|
|
import com.hnac.hzims.ticket.standardTicket.utils.OperationWordHelper; |
|
|
|
import com.hnac.hzims.ticket.standardTicket.vo.StandardTicketInfoVO; |
|
|
|
import com.hnac.hzims.ticket.standardTicket.vo.StandardTicketInfoVO; |
|
|
|
|
|
|
|
import com.hnac.hzims.ticket.twoTicket.constant.TicketConstant; |
|
|
|
|
|
|
|
import com.hnac.hzims.ticket.twoTicket.entity.TicketInfoDanger; |
|
|
|
|
|
|
|
import com.hnac.hzims.ticket.twoTicket.entity.WorkTicketFinish; |
|
|
|
|
|
|
|
import com.hnac.hzims.ticket.twoTicket.service.TicketProcessService; |
|
|
|
|
|
|
|
import com.hnac.hzims.ticket.twoTicket.utils.WordHelper; |
|
|
|
|
|
|
|
import com.hnac.hzims.ticket.twoTicket.utils.WordMapUtils; |
|
|
|
|
|
|
|
import com.hnac.hzims.ticket.twoTicket.vo.operation.StandardTicketInfoVo; |
|
|
|
|
|
|
|
import com.hnac.hzims.ticket.twoTicket.vo.process.WorkTicketVo; |
|
|
|
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.*; |
|
|
|
import com.hnac.hzims.ticket.workTicket.entity.TwoTicketMatterLibraryEntity; |
|
|
|
|
|
|
|
import com.hnac.hzims.ticket.workTicket.service.ITwoTicketMatterLibraryService; |
|
|
|
import com.hnac.hzims.ticket.workTicket.service.ITwoTicketMatterLibraryService; |
|
|
|
import com.hnac.hzims.ticket.workTicket.vo.*; |
|
|
|
import com.hnac.hzims.ticket.workTicket.vo.*; |
|
|
|
import com.hnac.hzims.ticket.workTicket.wrapper.TwoTicketMatterLibraryWrapper; |
|
|
|
import com.hnac.hzims.ticket.workTicket.wrapper.TwoTicketMatterLibraryWrapper; |
|
|
|
import com.itextpdf.text.Document; |
|
|
|
import com.spire.pdf.PdfNewDocument; |
|
|
|
import com.itextpdf.text.pdf.PdfCopy; |
|
|
|
|
|
|
|
import com.itextpdf.text.pdf.PdfImportedPage; |
|
|
|
|
|
|
|
import com.itextpdf.text.pdf.PdfReader; |
|
|
|
|
|
|
|
import com.itextpdf.text.pdf.PdfWriter; |
|
|
|
|
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
|
|
|
|
import lombok.SneakyThrows; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
|
import org.apache.commons.io.IOUtils; |
|
|
|
|
|
|
|
import org.apache.http.entity.ContentType; |
|
|
|
|
|
|
|
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; |
|
|
|
import org.springblade.core.mp.support.Query; |
|
|
|
import org.springblade.core.mp.support.Query; |
|
|
|
import org.springblade.core.oss.OssTemplate; |
|
|
|
|
|
|
|
import org.springblade.core.oss.model.BladeFile; |
|
|
|
|
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
import org.springblade.core.tool.utils.*; |
|
|
|
import org.springblade.core.tool.utils.*; |
|
|
|
|
|
|
|
import org.springblade.system.user.cache.UserCache; |
|
|
|
|
|
|
|
import org.springblade.system.user.entity.User; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.mock.web.MockMultipartFile; |
|
|
|
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.ServletOutputStream; |
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import java.io.*; |
|
|
|
|
|
|
|
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; |
|
|
@ -60,7 +67,7 @@ import java.util.stream.Collectors; |
|
|
|
@RequiredArgsConstructor |
|
|
|
@RequiredArgsConstructor |
|
|
|
public class TicketMatterGroupServiceImpl extends BaseServiceImpl<TicketMatterGroupMapper, TicketMatterGroupEntity> implements ITicketMatterGroupService { |
|
|
|
public class TicketMatterGroupServiceImpl extends BaseServiceImpl<TicketMatterGroupMapper, TicketMatterGroupEntity> implements ITicketMatterGroupService { |
|
|
|
|
|
|
|
|
|
|
|
/**word模板预览导出保存路径**/ |
|
|
|
/** word模板预览导出保存路径 **/ |
|
|
|
@Value("${hzims.ticket.path.xlsx.savePath}") |
|
|
|
@Value("${hzims.ticket.path.xlsx.savePath}") |
|
|
|
private String xlsSavePath; |
|
|
|
private String xlsSavePath; |
|
|
|
|
|
|
|
|
|
|
@ -71,34 +78,38 @@ public class TicketMatterGroupServiceImpl extends BaseServiceImpl<TicketMatterGr |
|
|
|
private final ITwoTicketMatterLibraryService twoTicketMatterLibraryService; |
|
|
|
private final ITwoTicketMatterLibraryService twoTicketMatterLibraryService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final OperationTicketService operationTicketService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final TicketProcessService ticketProcessService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public R<IPage<TicketMatterGroupVO>> queryList(TicketMatterGroupDTO req, Query query){ |
|
|
|
public R<IPage<TicketMatterGroupVO>> queryList(TicketMatterGroupDTO req, Query query) { |
|
|
|
LambdaQueryWrapper<TicketMatterGroupEntity> queryWrapper = this.getQueryWrapper(req); |
|
|
|
LambdaQueryWrapper<TicketMatterGroupEntity> queryWrapper = this.getQueryWrapper(req); |
|
|
|
IPage page = this.page(Condition.getPage(query),queryWrapper); |
|
|
|
IPage page = this.page(Condition.getPage(query), queryWrapper); |
|
|
|
return R.data(page.setRecords(TicketMatterGroupWrapper.build().listVO(page.getRecords()))); |
|
|
|
return R.data(page.setRecords(TicketMatterGroupWrapper.build().listVO(page.getRecords()))); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public R<TicketMatterGroupVO> detail(Long id){ |
|
|
|
public R<TicketMatterGroupVO> detail(Long id) { |
|
|
|
TicketMatterGroupEntity entity = getById(id); |
|
|
|
TicketMatterGroupEntity entity = getById(id); |
|
|
|
TicketMatterGroupVO groupVO = TicketMatterGroupWrapper.build().entityVO(entity); |
|
|
|
TicketMatterGroupVO groupVO = TicketMatterGroupWrapper.build().entityVO(entity); |
|
|
|
/**获取安措**/ |
|
|
|
/**获取安措**/ |
|
|
|
List<TwoTicketMatterLibraryEntity> libraryEntityList = twoTicketMatterLibraryService.list(new LambdaQueryWrapper<TwoTicketMatterLibraryEntity>(){{ |
|
|
|
List<TwoTicketMatterLibraryEntity> libraryEntityList = twoTicketMatterLibraryService.list(new LambdaQueryWrapper<TwoTicketMatterLibraryEntity>() {{ |
|
|
|
eq(TwoTicketMatterLibraryEntity::getMatterGroup,id); |
|
|
|
eq(TwoTicketMatterLibraryEntity::getMatterGroup, id); |
|
|
|
orderByAsc(TwoTicketMatterLibraryEntity::getType); |
|
|
|
orderByAsc(TwoTicketMatterLibraryEntity::getType); |
|
|
|
orderByDesc(TwoTicketMatterLibraryEntity::getSort); |
|
|
|
orderByDesc(TwoTicketMatterLibraryEntity::getSort); |
|
|
|
}}); |
|
|
|
}}); |
|
|
|
if(CollectionUtil.isNotEmpty(libraryEntityList)){ |
|
|
|
if (CollectionUtil.isNotEmpty(libraryEntityList)) { |
|
|
|
Map<String,List<TwoTicketMatterLibraryEntity>> libraryMap = libraryEntityList.stream() |
|
|
|
Map<String, List<TwoTicketMatterLibraryEntity>> libraryMap = libraryEntityList.stream() |
|
|
|
.sorted(Comparator.comparing(TwoTicketMatterLibraryEntity::getType).thenComparing(TwoTicketMatterLibraryEntity::getSort)).collect(Collectors.groupingBy(TwoTicketMatterLibraryEntity::getType)); |
|
|
|
.sorted(Comparator.comparing(TwoTicketMatterLibraryEntity::getType).thenComparing(TwoTicketMatterLibraryEntity::getSort)).collect(Collectors.groupingBy(TwoTicketMatterLibraryEntity::getType)); |
|
|
|
libraryMap.forEach((type,list)->{ |
|
|
|
libraryMap.forEach((type, list) -> { |
|
|
|
if(ONE_TYPE.equals(type)){ |
|
|
|
if (ONE_TYPE.equals(type)) { |
|
|
|
groupVO.setMatterLibraryListOne(TwoTicketMatterLibraryWrapper.build().listVO(list)); |
|
|
|
groupVO.setMatterLibraryListOne(TwoTicketMatterLibraryWrapper.build().listVO(list)); |
|
|
|
} |
|
|
|
} else if (TWO_TYPE.equals(type)) { |
|
|
|
else if(TWO_TYPE.equals(type)){ |
|
|
|
|
|
|
|
groupVO.setMatterLibraryListTwo(TwoTicketMatterLibraryWrapper.build().listVO(list)); |
|
|
|
groupVO.setMatterLibraryListTwo(TwoTicketMatterLibraryWrapper.build().listVO(list)); |
|
|
|
} |
|
|
|
} else if (THREE_TYPE.equals(type)) { |
|
|
|
else if(THREE_TYPE.equals(type)){ |
|
|
|
|
|
|
|
groupVO.setMatterLibraryListThree(TwoTicketMatterLibraryWrapper.build().listVO(list)); |
|
|
|
groupVO.setMatterLibraryListThree(TwoTicketMatterLibraryWrapper.build().listVO(list)); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
@ -109,33 +120,33 @@ public class TicketMatterGroupServiceImpl extends BaseServiceImpl<TicketMatterGr |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public R updateById(TicketMatterGroupDTO req) { |
|
|
|
public R updateById(TicketMatterGroupDTO req) { |
|
|
|
TicketMatterGroupEntity groupEntity = BeanUtil.copy(req,TicketMatterGroupEntity.class); |
|
|
|
TicketMatterGroupEntity groupEntity = BeanUtil.copy(req, TicketMatterGroupEntity.class); |
|
|
|
updateById(groupEntity); |
|
|
|
updateById(groupEntity); |
|
|
|
List<TwoTicketMatterLibraryEntity> libraryEntityList = new ArrayList<>(); |
|
|
|
List<TwoTicketMatterLibraryEntity> libraryEntityList = new ArrayList<>(); |
|
|
|
if(CollectionUtil.isNotEmpty(req.getMatterLibraryListOne())){ |
|
|
|
if (CollectionUtil.isNotEmpty(req.getMatterLibraryListOne())) { |
|
|
|
libraryEntityList.addAll(req.getMatterLibraryListOne().stream().map(libraryDto->BeanUtil.copy(libraryDto,TwoTicketMatterLibraryEntity.class)).collect(Collectors.toList())); |
|
|
|
libraryEntityList.addAll(req.getMatterLibraryListOne().stream().map(libraryDto -> BeanUtil.copy(libraryDto, TwoTicketMatterLibraryEntity.class)).collect(Collectors.toList())); |
|
|
|
} |
|
|
|
} |
|
|
|
if(CollectionUtil.isNotEmpty(req.getMatterLibraryListTwo())){ |
|
|
|
if (CollectionUtil.isNotEmpty(req.getMatterLibraryListTwo())) { |
|
|
|
libraryEntityList.addAll(req.getMatterLibraryListTwo().stream().map(libraryDto->BeanUtil.copy(libraryDto,TwoTicketMatterLibraryEntity.class)).collect(Collectors.toList())); |
|
|
|
libraryEntityList.addAll(req.getMatterLibraryListTwo().stream().map(libraryDto -> BeanUtil.copy(libraryDto, TwoTicketMatterLibraryEntity.class)).collect(Collectors.toList())); |
|
|
|
} |
|
|
|
} |
|
|
|
if(CollectionUtil.isNotEmpty(req.getMatterLibraryListThree())){ |
|
|
|
if (CollectionUtil.isNotEmpty(req.getMatterLibraryListThree())) { |
|
|
|
libraryEntityList.addAll(req.getMatterLibraryListThree().stream().map(libraryDto->BeanUtil.copy(libraryDto,TwoTicketMatterLibraryEntity.class)).collect(Collectors.toList())); |
|
|
|
libraryEntityList.addAll(req.getMatterLibraryListThree().stream().map(libraryDto -> BeanUtil.copy(libraryDto, TwoTicketMatterLibraryEntity.class)).collect(Collectors.toList())); |
|
|
|
} |
|
|
|
} |
|
|
|
List<TwoTicketMatterLibraryEntity> list = twoTicketMatterLibraryService.list(new LambdaQueryWrapper<TwoTicketMatterLibraryEntity>(){{ |
|
|
|
List<TwoTicketMatterLibraryEntity> list = twoTicketMatterLibraryService.list(new LambdaQueryWrapper<TwoTicketMatterLibraryEntity>() {{ |
|
|
|
eq(TwoTicketMatterLibraryEntity::getMatterGroup,req.getId()); |
|
|
|
eq(TwoTicketMatterLibraryEntity::getMatterGroup, req.getId()); |
|
|
|
}}); |
|
|
|
}}); |
|
|
|
if(CollectionUtil.isNotEmpty(list)){ |
|
|
|
if (CollectionUtil.isNotEmpty(list)) { |
|
|
|
//取出移除数据
|
|
|
|
//取出移除数据
|
|
|
|
List<Long> subtractList = (List<Long>)CollectionUtils.subtract( |
|
|
|
List<Long> subtractList = (List<Long>) CollectionUtils.subtract( |
|
|
|
list.stream().map(TwoTicketMatterLibraryEntity::getId).collect(Collectors.toList()), |
|
|
|
list.stream().map(TwoTicketMatterLibraryEntity::getId).collect(Collectors.toList()), |
|
|
|
libraryEntityList.stream().map(TwoTicketMatterLibraryEntity::getId).collect(Collectors.toList()) |
|
|
|
libraryEntityList.stream().map(TwoTicketMatterLibraryEntity::getId).collect(Collectors.toList()) |
|
|
|
); |
|
|
|
); |
|
|
|
if(CollectionUtil.isNotEmpty(subtractList)){ |
|
|
|
if (CollectionUtil.isNotEmpty(subtractList)) { |
|
|
|
twoTicketMatterLibraryService.deleteLogic(subtractList); |
|
|
|
twoTicketMatterLibraryService.deleteLogic(subtractList); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
libraryEntityList.forEach(library->{ |
|
|
|
libraryEntityList.forEach(library -> { |
|
|
|
if(Func.isEmpty(library.getId())){ |
|
|
|
if (Func.isEmpty(library.getId())) { |
|
|
|
library.setMatterGroup(groupEntity.getId()); |
|
|
|
library.setMatterGroup(groupEntity.getId()); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
@ -146,30 +157,30 @@ public class TicketMatterGroupServiceImpl extends BaseServiceImpl<TicketMatterGr |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public R doSave(TicketMatterGroupDTO req) { |
|
|
|
public R doSave(TicketMatterGroupDTO req) { |
|
|
|
TicketMatterGroupEntity groupEntity = BeanUtil.copy(req,TicketMatterGroupEntity.class); |
|
|
|
TicketMatterGroupEntity groupEntity = BeanUtil.copy(req, TicketMatterGroupEntity.class); |
|
|
|
boolean flag = save(groupEntity); |
|
|
|
boolean flag = save(groupEntity); |
|
|
|
if(!flag){ |
|
|
|
if (!flag) { |
|
|
|
throw new ServiceException("保存对象失败"); |
|
|
|
throw new ServiceException("保存对象失败"); |
|
|
|
} |
|
|
|
} |
|
|
|
/**组合安措、操作事项库列表**/ |
|
|
|
/**组合安措、操作事项库列表**/ |
|
|
|
List<TwoTicketMatterLibraryEntity> list = new ArrayList<>(); |
|
|
|
List<TwoTicketMatterLibraryEntity> list = new ArrayList<>(); |
|
|
|
if(CollectionUtil.isNotEmpty(req.getMatterLibraryListOne())){ |
|
|
|
if (CollectionUtil.isNotEmpty(req.getMatterLibraryListOne())) { |
|
|
|
list.addAll(req.getMatterLibraryListOne().stream().map(matterLibrary->{ |
|
|
|
list.addAll(req.getMatterLibraryListOne().stream().map(matterLibrary -> { |
|
|
|
TwoTicketMatterLibraryEntity libraryEntity = BeanUtil.copy(matterLibrary,TwoTicketMatterLibraryEntity.class); |
|
|
|
TwoTicketMatterLibraryEntity libraryEntity = BeanUtil.copy(matterLibrary, TwoTicketMatterLibraryEntity.class); |
|
|
|
libraryEntity.setMatterGroup(groupEntity.getId()); |
|
|
|
libraryEntity.setMatterGroup(groupEntity.getId()); |
|
|
|
return libraryEntity; |
|
|
|
return libraryEntity; |
|
|
|
}).collect(Collectors.toList())); |
|
|
|
}).collect(Collectors.toList())); |
|
|
|
} |
|
|
|
} |
|
|
|
if(CollectionUtil.isNotEmpty(req.getMatterLibraryListTwo())){ |
|
|
|
if (CollectionUtil.isNotEmpty(req.getMatterLibraryListTwo())) { |
|
|
|
list.addAll(req.getMatterLibraryListTwo().stream().map(matterLibrary->{ |
|
|
|
list.addAll(req.getMatterLibraryListTwo().stream().map(matterLibrary -> { |
|
|
|
TwoTicketMatterLibraryEntity libraryEntity = BeanUtil.copy(matterLibrary,TwoTicketMatterLibraryEntity.class); |
|
|
|
TwoTicketMatterLibraryEntity libraryEntity = BeanUtil.copy(matterLibrary, TwoTicketMatterLibraryEntity.class); |
|
|
|
libraryEntity.setMatterGroup(groupEntity.getId()); |
|
|
|
libraryEntity.setMatterGroup(groupEntity.getId()); |
|
|
|
return libraryEntity; |
|
|
|
return libraryEntity; |
|
|
|
}).collect(Collectors.toList())); |
|
|
|
}).collect(Collectors.toList())); |
|
|
|
} |
|
|
|
} |
|
|
|
if(CollectionUtil.isNotEmpty(req.getMatterLibraryListThree())){ |
|
|
|
if (CollectionUtil.isNotEmpty(req.getMatterLibraryListThree())) { |
|
|
|
list.addAll(req.getMatterLibraryListThree().stream().map(matterLibrary->{ |
|
|
|
list.addAll(req.getMatterLibraryListThree().stream().map(matterLibrary -> { |
|
|
|
TwoTicketMatterLibraryEntity libraryEntity = BeanUtil.copy(matterLibrary,TwoTicketMatterLibraryEntity.class); |
|
|
|
TwoTicketMatterLibraryEntity libraryEntity = BeanUtil.copy(matterLibrary, TwoTicketMatterLibraryEntity.class); |
|
|
|
libraryEntity.setMatterGroup(groupEntity.getId()); |
|
|
|
libraryEntity.setMatterGroup(groupEntity.getId()); |
|
|
|
return libraryEntity; |
|
|
|
return libraryEntity; |
|
|
|
}).collect(Collectors.toList())); |
|
|
|
}).collect(Collectors.toList())); |
|
|
@ -180,52 +191,50 @@ public class TicketMatterGroupServiceImpl extends BaseServiceImpl<TicketMatterGr |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void preview(Long id, String type, HttpServletResponse response) throws Exception { |
|
|
|
public void preview(Long id, String type, HttpServletResponse response) throws Exception { |
|
|
|
Map<String,Object> params = new HashMap<>(); |
|
|
|
Map<String, Object> params = new HashMap<>(); |
|
|
|
R<TicketMatterGroupVO> groupVOR = detail(id); |
|
|
|
R<TicketMatterGroupVO> groupVOR = detail(id); |
|
|
|
if(!groupVOR.isSuccess()){ |
|
|
|
if (!groupVOR.isSuccess()) { |
|
|
|
throw new ServiceException(groupVOR.getMsg()); |
|
|
|
throw new ServiceException(groupVOR.getMsg()); |
|
|
|
} |
|
|
|
} |
|
|
|
if(TicketConstants.WordFileNameEnum.WORK.getType().equals(type)){ |
|
|
|
if (TicketConstants.WordFileNameEnum.WORK.getType().equals(type)) { |
|
|
|
//若为工作票
|
|
|
|
//若为工作票
|
|
|
|
try{ |
|
|
|
try { |
|
|
|
params = this.completeWorkTicketData(new WorkTicketInfoVO()); |
|
|
|
params = this.completeWorkTicketData(new WorkTicketInfoVO()); |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
catch(Exception e){ |
|
|
|
|
|
|
|
throw new ServiceException("对象转换失败"); |
|
|
|
throw new ServiceException("对象转换失败"); |
|
|
|
} |
|
|
|
} |
|
|
|
TicketMatterGroupVO groupVO = groupVOR.getData(); |
|
|
|
TicketMatterGroupVO groupVO = groupVOR.getData(); |
|
|
|
|
|
|
|
|
|
|
|
//完善模板数据
|
|
|
|
//完善模板数据
|
|
|
|
/**获取安措**/ |
|
|
|
/**获取安措**/ |
|
|
|
List<TwoTicketMatterLibraryEntity> libraryEntityList = twoTicketMatterLibraryService.list(new LambdaQueryWrapper<TwoTicketMatterLibraryEntity>(){{ |
|
|
|
List<TwoTicketMatterLibraryEntity> libraryEntityList = twoTicketMatterLibraryService.list(new LambdaQueryWrapper<TwoTicketMatterLibraryEntity>() {{ |
|
|
|
eq(TwoTicketMatterLibraryEntity::getMatterGroup,id); |
|
|
|
eq(TwoTicketMatterLibraryEntity::getMatterGroup, id); |
|
|
|
orderByAsc(TwoTicketMatterLibraryEntity::getType); |
|
|
|
orderByAsc(TwoTicketMatterLibraryEntity::getType); |
|
|
|
orderByDesc(TwoTicketMatterLibraryEntity::getSort); |
|
|
|
orderByDesc(TwoTicketMatterLibraryEntity::getSort); |
|
|
|
}}); |
|
|
|
}}); |
|
|
|
if(TicketConstants.WordFileNameEnum.SECOND_WORK.getType().equals(groupVO.getTicketType())) { |
|
|
|
if (TicketConstants.WordFileNameEnum.SECOND_WORK.getType().equals(groupVO.getTicketType())) { |
|
|
|
//第二种工作票
|
|
|
|
//第二种工作票
|
|
|
|
params.put("measures", libraryEntityList.stream().map(TwoTicketMatterLibraryEntity::getSafetyMeasure).collect(Collectors.joining(","))); |
|
|
|
params.put("measures", libraryEntityList.stream().map(TwoTicketMatterLibraryEntity::getSafetyMeasure).collect(Collectors.joining(","))); |
|
|
|
params.put("workTicketContentDtoList", Lists.newArrayList()); |
|
|
|
params.put("workTicketContentDtoList", Lists.newArrayList()); |
|
|
|
} |
|
|
|
} else if (TicketConstants.WordFileNameEnum.MECHANICAL_WORK.getType().equals(groupVO.getTicketType())) { |
|
|
|
else if(TicketConstants.WordFileNameEnum.MECHANICAL_WORK.getType().equals(groupVO.getTicketType())) { |
|
|
|
|
|
|
|
//机械工作票
|
|
|
|
//机械工作票
|
|
|
|
List<Map<String, Object>> mapList = libraryEntityList.stream().map(measure -> { |
|
|
|
List<Map<String, Object>> mapList = libraryEntityList.stream().map(measure -> { |
|
|
|
Map<String, Object> result = PdfUtils.objectToMap(measure); |
|
|
|
Map<String, Object> result = PdfUtils.objectToMap(measure); |
|
|
|
result.put("status", ""); |
|
|
|
result.put("status", ""); |
|
|
|
result.put("measure",measure.getSafetyMeasure()); |
|
|
|
result.put("measure", measure.getSafetyMeasure()); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
log.info("机械工作票安措:{}", JSON.toJSONString(mapList)); |
|
|
|
log.info("机械工作票安措:{}", JSON.toJSONString(mapList)); |
|
|
|
params.put("initMeasures",mapList); |
|
|
|
params.put("initMeasures", mapList); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
params.put("matterLibraryListOne",new ArrayList<String>()); |
|
|
|
params.put("matterLibraryListOne", new ArrayList<String>()); |
|
|
|
params.put("matterLibraryListTwo",new ArrayList<String>()); |
|
|
|
params.put("matterLibraryListTwo", new ArrayList<String>()); |
|
|
|
params.put("matterLibraryListThree",new ArrayList<String>()); |
|
|
|
params.put("matterLibraryListThree", new ArrayList<String>()); |
|
|
|
if(CollectionUtil.isNotEmpty(groupVO.getMatterLibraryListOne())){ |
|
|
|
if (CollectionUtil.isNotEmpty(groupVO.getMatterLibraryListOne())) { |
|
|
|
params.put("matterLibraryListOne",groupVO.getMatterLibraryListOne().stream().map(library-> { |
|
|
|
params.put("matterLibraryListOne", groupVO.getMatterLibraryListOne().stream().map(library -> { |
|
|
|
try { |
|
|
|
try { |
|
|
|
Map<String,Object> map = PdfUtils.objectToMap(library); |
|
|
|
Map<String, Object> map = PdfUtils.objectToMap(library); |
|
|
|
map.put("status", " "); |
|
|
|
map.put("status", " "); |
|
|
|
return map; |
|
|
|
return map; |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
@ -234,10 +243,10 @@ public class TicketMatterGroupServiceImpl extends BaseServiceImpl<TicketMatterGr |
|
|
|
} |
|
|
|
} |
|
|
|
}).collect(Collectors.toList())); |
|
|
|
}).collect(Collectors.toList())); |
|
|
|
} |
|
|
|
} |
|
|
|
if(CollectionUtil.isNotEmpty(groupVO.getMatterLibraryListTwo())){ |
|
|
|
if (CollectionUtil.isNotEmpty(groupVO.getMatterLibraryListTwo())) { |
|
|
|
params.put("matterLibraryListTwo",groupVO.getMatterLibraryListTwo().stream().map(library-> { |
|
|
|
params.put("matterLibraryListTwo", groupVO.getMatterLibraryListTwo().stream().map(library -> { |
|
|
|
try { |
|
|
|
try { |
|
|
|
Map<String,Object> map = PdfUtils.objectToMap(library); |
|
|
|
Map<String, Object> map = PdfUtils.objectToMap(library); |
|
|
|
map.put("status", " "); |
|
|
|
map.put("status", " "); |
|
|
|
return map; |
|
|
|
return map; |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
@ -246,10 +255,10 @@ public class TicketMatterGroupServiceImpl extends BaseServiceImpl<TicketMatterGr |
|
|
|
} |
|
|
|
} |
|
|
|
}).collect(Collectors.toList())); |
|
|
|
}).collect(Collectors.toList())); |
|
|
|
} |
|
|
|
} |
|
|
|
if(CollectionUtil.isNotEmpty(groupVO.getMatterLibraryListThree())){ |
|
|
|
if (CollectionUtil.isNotEmpty(groupVO.getMatterLibraryListThree())) { |
|
|
|
params.put("matterLibraryListThree",groupVO.getMatterLibraryListThree().stream().map(library-> { |
|
|
|
params.put("matterLibraryListThree", groupVO.getMatterLibraryListThree().stream().map(library -> { |
|
|
|
try { |
|
|
|
try { |
|
|
|
Map<String,Object> map = PdfUtils.objectToMap(library); |
|
|
|
Map<String, Object> map = PdfUtils.objectToMap(library); |
|
|
|
map.put("status", " "); |
|
|
|
map.put("status", " "); |
|
|
|
return map; |
|
|
|
return map; |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
@ -258,37 +267,35 @@ public class TicketMatterGroupServiceImpl extends BaseServiceImpl<TicketMatterGr |
|
|
|
} |
|
|
|
} |
|
|
|
}).collect(Collectors.toList())); |
|
|
|
}).collect(Collectors.toList())); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (TicketConstants.WordFileNameEnum.OPERATE.getType().equals(type)) { |
|
|
|
else if(TicketConstants.WordFileNameEnum.OPERATE.getType().equals(type)){ |
|
|
|
|
|
|
|
//若为操作票
|
|
|
|
//若为操作票
|
|
|
|
try{ |
|
|
|
try { |
|
|
|
params = PdfUtils.objectToMap(new StandardTicketInfoVO()); |
|
|
|
params = PdfUtils.objectToMap(new StandardTicketInfoVO()); |
|
|
|
AtomicInteger index = new AtomicInteger(1); |
|
|
|
AtomicInteger index = new AtomicInteger(1); |
|
|
|
params.put("measureMapList",groupVOR.getData().getMatterLibraryListOne().stream().map(library-> { |
|
|
|
params.put("measureMapList", groupVOR.getData().getMatterLibraryListOne().stream().map(library -> { |
|
|
|
Map<String,Object> map = new HashMap<>(); |
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
map.put("index", index.get()); |
|
|
|
map.put("index", index.get()); |
|
|
|
map.put("measure", library.getSafetyMeasure()); |
|
|
|
map.put("measure", library.getSafetyMeasure()); |
|
|
|
map.put("status", " "); |
|
|
|
map.put("status", " "); |
|
|
|
index.getAndIncrement(); |
|
|
|
index.getAndIncrement(); |
|
|
|
return map; |
|
|
|
return map; |
|
|
|
}).collect(Collectors.toList())); |
|
|
|
}).collect(Collectors.toList())); |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
catch (Exception e) { |
|
|
|
|
|
|
|
throw new ServiceException("对象转换失败"); |
|
|
|
throw new ServiceException("对象转换失败"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//获取导出word路径
|
|
|
|
//获取导出word路径
|
|
|
|
String fileName = TicketConstants.WordFileNameEnum.getFileNameByType(groupVOR.getData().getTicketType()) + PdfUtils.XLSX_SUFFIX; |
|
|
|
String fileName = TicketConstants.WordFileNameEnum.getFileNameByType(groupVOR.getData().getTicketType()) + PdfUtils.XLSX_SUFFIX; |
|
|
|
TemplateExportParams templateExportParams = new TemplateExportParams("template/" + fileName, true); |
|
|
|
TemplateExportParams templateExportParams = new TemplateExportParams("template/" + fileName, true); |
|
|
|
Workbook workbook = ExcelUtil.getWorkbook(templateExportParams,params); |
|
|
|
Workbook workbook = ExcelUtil.getWorkbook(templateExportParams, params); |
|
|
|
//上传xlsx至服务器
|
|
|
|
//上传xlsx至服务器
|
|
|
|
ExcelUtil.upload(workbook,xlsSavePath,fileName); |
|
|
|
ExcelUtil.upload(workbook, xlsSavePath, fileName); |
|
|
|
//将xlsx文件转换为pdf并保存
|
|
|
|
//将xlsx文件转换为pdf并保存
|
|
|
|
String pdfFileName = TicketConstants.WordFileNameEnum.getFileNameByType(groupVOR.getData().getTicketType()) + PdfUtils.PDF_SUFFIX; |
|
|
|
String pdfFileName = TicketConstants.WordFileNameEnum.getFileNameByType(groupVOR.getData().getTicketType()) + PdfUtils.PDF_SUFFIX; |
|
|
|
PdfUtils.convertPdf(xlsSavePath, fileName, pdfSavePath, pdfFileName); |
|
|
|
PdfUtils.convertPdf(xlsSavePath, fileName, pdfSavePath, pdfFileName); |
|
|
|
String savePath = pdfSavePath + pdfFileName; |
|
|
|
String savePath = pdfSavePath + pdfFileName; |
|
|
|
// 设置response参数,可以打开下载页面
|
|
|
|
// 设置response参数,可以打开下载页面
|
|
|
|
PdfUtils.readPdf(response,savePath); |
|
|
|
PdfUtils.readPdf(response, savePath); |
|
|
|
//上传minio并获取相应路径
|
|
|
|
//上传minio并获取相应路径
|
|
|
|
// String savePath = pdfSavePath + pdfFileName;
|
|
|
|
// String savePath = pdfSavePath + pdfFileName;
|
|
|
|
// File saveFile = new File(savePath);
|
|
|
|
// File saveFile = new File(savePath);
|
|
|
@ -297,25 +304,24 @@ public class TicketMatterGroupServiceImpl extends BaseServiceImpl<TicketMatterGr |
|
|
|
// return ossTemplate.putFile(multipartFile);
|
|
|
|
// return ossTemplate.putFile(multipartFile);
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private LambdaQueryWrapper<TicketMatterGroupEntity> getQueryWrapper(TicketMatterGroupDTO groupDTO){ |
|
|
|
private LambdaQueryWrapper<TicketMatterGroupEntity> getQueryWrapper(TicketMatterGroupDTO groupDTO) { |
|
|
|
LambdaQueryWrapper<TicketMatterGroupEntity> queryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
LambdaQueryWrapper<TicketMatterGroupEntity> queryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
if(Func.isNotEmpty(groupDTO.getTicketType())){ |
|
|
|
if (Func.isNotEmpty(groupDTO.getTicketType())) { |
|
|
|
queryWrapper.in(TicketMatterGroupEntity::getTicketType, Arrays.asList(groupDTO.getTicketType().split(","))); |
|
|
|
queryWrapper.in(TicketMatterGroupEntity::getTicketType, Arrays.asList(groupDTO.getTicketType().split(","))); |
|
|
|
} |
|
|
|
} |
|
|
|
if(Func.isNotEmpty(groupDTO.getName())){ |
|
|
|
if (Func.isNotEmpty(groupDTO.getName())) { |
|
|
|
queryWrapper.like(TicketMatterGroupEntity::getTicketType, groupDTO.getName()); |
|
|
|
queryWrapper.like(TicketMatterGroupEntity::getTicketType, groupDTO.getName()); |
|
|
|
} |
|
|
|
} |
|
|
|
queryWrapper.orderByDesc(TicketMatterGroupEntity::getCreateTime).orderByDesc(TicketMatterGroupEntity::getUpdateTime); |
|
|
|
queryWrapper.orderByDesc(TicketMatterGroupEntity::getCreateTime).orderByDesc(TicketMatterGroupEntity::getUpdateTime); |
|
|
|
return queryWrapper; |
|
|
|
return queryWrapper; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private Map<String,Object> completeWorkTicketData(WorkTicketInfoVO workTicketInfoVO){ |
|
|
|
private Map<String, Object> completeWorkTicketData(WorkTicketInfoVO workTicketInfoVO) { |
|
|
|
/**将workTicketInfoVO封装进Map,以便pdf导出**/ |
|
|
|
/**将workTicketInfoVO封装进Map,以便pdf导出**/ |
|
|
|
Map<String,Object> workTicketInfoMap = new HashMap<>(); |
|
|
|
Map<String, Object> workTicketInfoMap = new HashMap<>(); |
|
|
|
try { |
|
|
|
try { |
|
|
|
workTicketInfoMap = PdfUtils.objectToMap(workTicketInfoVO); |
|
|
|
workTicketInfoMap = PdfUtils.objectToMap(workTicketInfoVO); |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
catch (Exception e) { |
|
|
|
|
|
|
|
log.info("转换对象失败!"); |
|
|
|
log.info("转换对象失败!"); |
|
|
|
} |
|
|
|
} |
|
|
|
/**签发**/ |
|
|
|
/**签发**/ |
|
|
@ -326,18 +332,18 @@ public class TicketMatterGroupServiceImpl extends BaseServiceImpl<TicketMatterGr |
|
|
|
workTicketInfoMap.put("licenseTime", " "); |
|
|
|
workTicketInfoMap.put("licenseTime", " "); |
|
|
|
|
|
|
|
|
|
|
|
/**负责人收到工作票**/ |
|
|
|
/**负责人收到工作票**/ |
|
|
|
workTicketInfoMap.put("receivePrincipal"," "); |
|
|
|
workTicketInfoMap.put("receivePrincipal", " "); |
|
|
|
workTicketInfoMap.put("receiveTime", " "); |
|
|
|
workTicketInfoMap.put("receiveTime", " "); |
|
|
|
workTicketInfoMap.put("principalConfirm"," "); |
|
|
|
workTicketInfoMap.put("principalConfirm", " "); |
|
|
|
|
|
|
|
|
|
|
|
/**负责人确认安全事项**/ |
|
|
|
/**负责人确认安全事项**/ |
|
|
|
workTicketInfoMap.put("confirmPrincipal"," "); |
|
|
|
workTicketInfoMap.put("confirmPrincipal", " "); |
|
|
|
workTicketInfoMap.put("confirmTime", " "); |
|
|
|
workTicketInfoMap.put("confirmTime", " "); |
|
|
|
|
|
|
|
|
|
|
|
/**工作结束**/ |
|
|
|
/**工作结束**/ |
|
|
|
workTicketInfoMap.put("finisher"," "); |
|
|
|
workTicketInfoMap.put("finisher", " "); |
|
|
|
workTicketInfoMap.put("finishTime", " "); |
|
|
|
workTicketInfoMap.put("finishTime", " "); |
|
|
|
workTicketInfoMap.put("principalFinish"," "); |
|
|
|
workTicketInfoMap.put("principalFinish", " "); |
|
|
|
|
|
|
|
|
|
|
|
/**工作终结**/ |
|
|
|
/**工作终结**/ |
|
|
|
workTicketInfoMap.put("endLicensor", " "); |
|
|
|
workTicketInfoMap.put("endLicensor", " "); |
|
|
@ -364,8 +370,8 @@ public class TicketMatterGroupServiceImpl extends BaseServiceImpl<TicketMatterGr |
|
|
|
workTicketInfoMap.put("delayLicenseTime", " "); |
|
|
|
workTicketInfoMap.put("delayLicenseTime", " "); |
|
|
|
|
|
|
|
|
|
|
|
/**跨日工作时间**/ |
|
|
|
/**跨日工作时间**/ |
|
|
|
List<Map<String,String>> operateMapList = new ArrayList<>(); |
|
|
|
List<Map<String, String>> operateMapList = new ArrayList<>(); |
|
|
|
Map<String,String> map = new HashMap<>(4); |
|
|
|
Map<String, String> map = new HashMap<>(4); |
|
|
|
map.put("startTime", " "); |
|
|
|
map.put("startTime", " "); |
|
|
|
map.put("endTime", " "); |
|
|
|
map.put("endTime", " "); |
|
|
|
map.put("principal", " "); |
|
|
|
map.put("principal", " "); |
|
|
@ -374,8 +380,319 @@ public class TicketMatterGroupServiceImpl extends BaseServiceImpl<TicketMatterGr |
|
|
|
workTicketInfoMap.put("operateMapList", operateMapList); |
|
|
|
workTicketInfoMap.put("operateMapList", operateMapList); |
|
|
|
|
|
|
|
|
|
|
|
/**运行值班人员暂为空**/ |
|
|
|
/**运行值班人员暂为空**/ |
|
|
|
workTicketInfoMap.put("dutyPersonName"," "); |
|
|
|
workTicketInfoMap.put("dutyPersonName", " "); |
|
|
|
workTicketInfoMap.put("membersConfirm"," "); |
|
|
|
workTicketInfoMap.put("membersConfirm", " "); |
|
|
|
return workTicketInfoMap; |
|
|
|
return workTicketInfoMap; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 票据模板预览 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param id 编号 |
|
|
|
|
|
|
|
* @param type 模板类型:2为工作票;1为操作票 |
|
|
|
|
|
|
|
* @param status 模板状态 |
|
|
|
|
|
|
|
* @param response |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void newPreview(Long id, Integer type, Integer status, HttpServletResponse response) { |
|
|
|
|
|
|
|
String fileName = IdWorker.get32UUID() + ".docx"; |
|
|
|
|
|
|
|
// response.setContentType("application/octet-stream;charset=ISO8859-1");
|
|
|
|
|
|
|
|
response.setHeader("Content-Disposition", "attachment; filename=" + fileName); |
|
|
|
|
|
|
|
response.setContentType("application/vnd.ms-excel;charset=utf-8"); |
|
|
|
|
|
|
|
R<TicketMatterGroupVO> detail = this.detail(id); |
|
|
|
|
|
|
|
if (!detail.isSuccess()) { |
|
|
|
|
|
|
|
throw new ServiceException(detail.getMsg()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
TicketMatterGroupVO groupVO = detail.getData(); |
|
|
|
|
|
|
|
if (groupVO == null) { |
|
|
|
|
|
|
|
throw new ServiceException("查询数据不存在"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//判断票据类型是操操作票还是工作票
|
|
|
|
|
|
|
|
this.getTypeByStatus(type, status, groupVO, response, id); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 判断票据类型是操操作票还是工作票 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param type 模板类型:2为工作票;1为操作票 |
|
|
|
|
|
|
|
* @param status 模板状态 |
|
|
|
|
|
|
|
* @param groupVO |
|
|
|
|
|
|
|
* @param response |
|
|
|
|
|
|
|
* @param id |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private void getTypeByStatus(Integer type, Integer status, TicketMatterGroupVO groupVO, HttpServletResponse response, Long id) { |
|
|
|
|
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
|
|
|
|
switch (type) { |
|
|
|
|
|
|
|
//操作票
|
|
|
|
|
|
|
|
case 1: |
|
|
|
|
|
|
|
getStandardTicket(result, status, groupVO, response); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
//工作票
|
|
|
|
|
|
|
|
case 2: |
|
|
|
|
|
|
|
getWordTicket(result, status, groupVO, response, id); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
throw new ServiceException("输入的模板类型不存在"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 工作票 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param params |
|
|
|
|
|
|
|
* @param groupVO |
|
|
|
|
|
|
|
* @param response |
|
|
|
|
|
|
|
* @param id |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@SneakyThrows |
|
|
|
|
|
|
|
private void getWordTicket(Map<String, Object> params, Integer status, TicketMatterGroupVO groupVO, |
|
|
|
|
|
|
|
HttpServletResponse response, Long id) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
WorkTicketInfoEntity workTicket = new WorkTicketInfoEntity(); |
|
|
|
|
|
|
|
//1. 工作对象
|
|
|
|
|
|
|
|
Map<String, Object> workTicketInfoMap = PdfUtils.objectToMapResult(workTicket, params); |
|
|
|
|
|
|
|
ticketProcessService.getDataConversion(workTicketInfoMap, "isSafety", false); |
|
|
|
|
|
|
|
//危险点分析与预控措施票 (true,展示附件,false,不展示附件)
|
|
|
|
|
|
|
|
ticketProcessService.getDataConversion(workTicketInfoMap, "isHazard", false); |
|
|
|
|
|
|
|
//危险点分析与预控措施票 (true,展示附件,false,不展示附件)
|
|
|
|
|
|
|
|
ticketProcessService.getDataConversion(workTicketInfoMap, "isRailway", false); |
|
|
|
|
|
|
|
//有限空间监测记录单(true,展示附件,false,不展示附件)
|
|
|
|
|
|
|
|
ticketProcessService.getDataConversion(workTicketInfoMap, "isLimited", false); |
|
|
|
|
|
|
|
params.putAll(workTicketInfoMap); |
|
|
|
|
|
|
|
//3. 工作票工作任务组
|
|
|
|
|
|
|
|
params.put("workTicketContentDtoList", new ArrayList<>()); |
|
|
|
|
|
|
|
//4. 工作票延期
|
|
|
|
|
|
|
|
params.putAll(PdfUtils.objectToMapResult(new WorkTicketDelayEntity(), params)); |
|
|
|
|
|
|
|
//5. 工作结束
|
|
|
|
|
|
|
|
params.putAll(PdfUtils.objectToMapResult(new WorkTicketFinish(), params)); |
|
|
|
|
|
|
|
//5. 工作票负责人变更;
|
|
|
|
|
|
|
|
params.putAll(PdfUtils.objectToMapResult(new WorkTicketPrincipalChangeEntity(), params)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
params.put("matterLibraryListOne", new ArrayList<>()); |
|
|
|
|
|
|
|
params.put("matterLibraryListTwo", new ArrayList<>()); |
|
|
|
|
|
|
|
params.put("matterLibraryListThree", new ArrayList<>()); |
|
|
|
|
|
|
|
params.put("matterLibraryListFour", new ArrayList<>()); |
|
|
|
|
|
|
|
params.put("matterLibraryListFive", new ArrayList<>()); |
|
|
|
|
|
|
|
params.put("matterLibraryListFlow", new ArrayList<>()); |
|
|
|
|
|
|
|
params.put("matterLibraryListSeven", new ArrayList<>()); |
|
|
|
|
|
|
|
params.put("matterLibraryListEight", new ArrayList<>()); |
|
|
|
|
|
|
|
params.put("matterLibraryListNine", new ArrayList<>()); |
|
|
|
|
|
|
|
params.put("matterLibraryListTen", new ArrayList<>()); |
|
|
|
|
|
|
|
params.put("matterLibraryList", new ArrayList<>()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** 获取安措 **/ |
|
|
|
|
|
|
|
List<TwoTicketMatterLibraryEntity> libraryEntityList = twoTicketMatterLibraryService.list(new LambdaQueryWrapper<TwoTicketMatterLibraryEntity>() {{ |
|
|
|
|
|
|
|
eq(TwoTicketMatterLibraryEntity::getMatterGroup, id); |
|
|
|
|
|
|
|
orderByAsc(TwoTicketMatterLibraryEntity::getType); |
|
|
|
|
|
|
|
orderByDesc(TwoTicketMatterLibraryEntity::getSort); |
|
|
|
|
|
|
|
}}); |
|
|
|
|
|
|
|
if (TicketConstants.WordFileNameEnum.SECOND_WORK.getType().equals(groupVO.getTicketType())) { |
|
|
|
|
|
|
|
//第二种工作票
|
|
|
|
|
|
|
|
params.put("measures", libraryEntityList.stream().map(TwoTicketMatterLibraryEntity::getSafetyMeasure).collect(Collectors.joining(","))); |
|
|
|
|
|
|
|
params.put("workTicketContentDtoList", Lists.newArrayList()); |
|
|
|
|
|
|
|
} else if (TicketConstants.WordFileNameEnum.MECHANICAL_WORK.getType().equals(groupVO.getTicketType())) { |
|
|
|
|
|
|
|
//机械工作票
|
|
|
|
|
|
|
|
List<Map<String, Object>> mapList = libraryEntityList.stream().map(measure -> { |
|
|
|
|
|
|
|
Map<String, Object> result = PdfUtils.objectToMap(measure); |
|
|
|
|
|
|
|
result.put("status", ""); |
|
|
|
|
|
|
|
result.put("measure", measure.getSafetyMeasure()); |
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
|
|
log.info("机械工作票安措:{}", JSON.toJSONString(mapList)); |
|
|
|
|
|
|
|
params.put("initMeasures", mapList); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//许可人确认安全措施,负责人确认安全措施
|
|
|
|
|
|
|
|
WordHelper.putMap(params, "principalName1", 10); |
|
|
|
|
|
|
|
//负责人变更
|
|
|
|
|
|
|
|
WordHelper.putMap(params, "signerName2", 10); |
|
|
|
|
|
|
|
WordHelper.putMap(params, "licensorName1", 10); |
|
|
|
|
|
|
|
//延期
|
|
|
|
|
|
|
|
WordHelper.putMap(params, "principalName2", 10); |
|
|
|
|
|
|
|
//许可人确认工作票终结
|
|
|
|
|
|
|
|
WordHelper.putMap(params, "principalName3", 10); |
|
|
|
|
|
|
|
WordHelper.putMap(params, "licensorName2", 10); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
WordMapUtils.newMapWithList("matterLibraryList", params, true, 4, null); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (CollectionUtil.isNotEmpty(groupVO.getMatterLibraryListOne())) { |
|
|
|
|
|
|
|
params.put("matterLibraryListOne", groupVO.getMatterLibraryListOne().stream().map(library -> { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
Map<String, Object> map = PdfUtils.objectToMap(library); |
|
|
|
|
|
|
|
map.put("status", " "); |
|
|
|
|
|
|
|
return map; |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}).collect(Collectors.toList())); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (CollectionUtil.isNotEmpty(groupVO.getMatterLibraryListTwo())) { |
|
|
|
|
|
|
|
params.put("matterLibraryListTwo", groupVO.getMatterLibraryListTwo().stream().map(library -> { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
Map<String, Object> map = PdfUtils.objectToMap(library); |
|
|
|
|
|
|
|
map.put("status", " "); |
|
|
|
|
|
|
|
return map; |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}).collect(Collectors.toList())); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (CollectionUtil.isNotEmpty(groupVO.getMatterLibraryListThree())) { |
|
|
|
|
|
|
|
params.put("matterLibraryListThree", groupVO.getMatterLibraryListThree().stream().map(library -> { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
Map<String, Object> map = PdfUtils.objectToMap(library); |
|
|
|
|
|
|
|
map.put("status", " "); |
|
|
|
|
|
|
|
return map; |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}).collect(Collectors.toList())); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.isMatterLibraryList(params); |
|
|
|
|
|
|
|
Map<String, Object> resultMap = WordHelper.resultMap(params); |
|
|
|
|
|
|
|
String workTicketStatus = WordMapUtils.getWorkTicketStatus(status); |
|
|
|
|
|
|
|
String os = TicketConstant.OS_NAME; |
|
|
|
|
|
|
|
//Windows操作系统
|
|
|
|
|
|
|
|
if (os != null && os.toLowerCase().startsWith("windows")) { |
|
|
|
|
|
|
|
String url = "template/" + workTicketStatus; |
|
|
|
|
|
|
|
XWPFDocument doc = WordExportUtil.exportWord07(url, resultMap); |
|
|
|
|
|
|
|
log.info("当前系统版本是:{}", os); |
|
|
|
|
|
|
|
doc.write(response.getOutputStream()); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
String url = TicketConstant.TICKET_LIUNX_PATH + "/" + workTicketStatus; |
|
|
|
|
|
|
|
XWPFDocument doc = WordExportUtil.exportWord07(url, resultMap); |
|
|
|
|
|
|
|
//其它操作系统
|
|
|
|
|
|
|
|
log.info("当前系统版本是:{}", os); |
|
|
|
|
|
|
|
ServletOutputStream outputStream = response.getOutputStream(); |
|
|
|
|
|
|
|
doc.write(outputStream); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 操作票 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param workTicketInfoMap 返回的数据 |
|
|
|
|
|
|
|
* @param groupVO |
|
|
|
|
|
|
|
* @param response |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@SneakyThrows |
|
|
|
|
|
|
|
private void getStandardTicket(Map<String, Object> workTicketInfoMap, Integer status, TicketMatterGroupVO groupVO, |
|
|
|
|
|
|
|
HttpServletResponse response) { |
|
|
|
|
|
|
|
workTicketInfoMap.putAll(this.convertMap(new StandardTicketInfoVo())); |
|
|
|
|
|
|
|
AtomicInteger index = new AtomicInteger(1); |
|
|
|
|
|
|
|
List<Map<String, Object>> collect = groupVO.getMatterLibraryListOne().stream().map(library -> { |
|
|
|
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
|
|
|
|
map.put("index", index.get()); |
|
|
|
|
|
|
|
map.put("measure", library.getSafetyMeasure()); |
|
|
|
|
|
|
|
map.put("status", " "); |
|
|
|
|
|
|
|
map.put("hello", ""); |
|
|
|
|
|
|
|
map.put("hello1", ""); |
|
|
|
|
|
|
|
map.put("operationTime", ""); |
|
|
|
|
|
|
|
index.getAndIncrement(); |
|
|
|
|
|
|
|
return map; |
|
|
|
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
|
|
workTicketInfoMap.put("measureMapList", collect); |
|
|
|
|
|
|
|
Map<String, Object> resultMap = OperationWordHelper.resultMap(workTicketInfoMap); |
|
|
|
|
|
|
|
String workTicketStatus = this.getWorkTicketStatus(status); |
|
|
|
|
|
|
|
String os = TicketConstant.OS_NAME; |
|
|
|
|
|
|
|
//Windows操作系统
|
|
|
|
|
|
|
|
if (os != null && os.toLowerCase().startsWith("windows")) { |
|
|
|
|
|
|
|
String url = "template/" + workTicketStatus; |
|
|
|
|
|
|
|
XWPFDocument doc = WordExportUtil.exportWord07(url, resultMap); |
|
|
|
|
|
|
|
log.info("当前系统版本是:{}", os); |
|
|
|
|
|
|
|
doc.write(response.getOutputStream()); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
String url = TicketConstant.TICKET_LIUNX_PATH + "/" + workTicketStatus; |
|
|
|
|
|
|
|
XWPFDocument doc = WordExportUtil.exportWord07(url, resultMap); |
|
|
|
|
|
|
|
//其它操作系统
|
|
|
|
|
|
|
|
log.info("当前系统版本是:{}", os); |
|
|
|
|
|
|
|
ServletOutputStream outputStream = response.getOutputStream(); |
|
|
|
|
|
|
|
doc.write(outputStream); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 将查询的数据转换为map |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param standardTicketInfoVo |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private Map<String, Object> convertMap(StandardTicketInfoVo standardTicketInfoVo) { |
|
|
|
|
|
|
|
//1. 操作票装换map
|
|
|
|
|
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
|
|
|
|
Map<String, Object> stringObjectMap = PdfUtils.objectToMapResult(standardTicketInfoVo, result); |
|
|
|
|
|
|
|
result.putAll(stringObjectMap); |
|
|
|
|
|
|
|
WordMapUtils.newMapWithList("measureMapList", result, false, 17, null); |
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 根据状态获取模板 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param status |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public static String getWorkTicketStatus(Integer status) { |
|
|
|
|
|
|
|
String pathName = null; |
|
|
|
|
|
|
|
switch (status) { |
|
|
|
|
|
|
|
case 1: |
|
|
|
|
|
|
|
pathName = "电气第一种工作票模版.docx"; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 2: |
|
|
|
|
|
|
|
pathName = "电气第二种工作票模版.docx"; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 3: |
|
|
|
|
|
|
|
pathName = "水力机械工作票模版.docx"; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 4: |
|
|
|
|
|
|
|
pathName = "电气操作票.docx"; |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
pathName = "电气第一种工作票模版.docx"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return pathName; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 验证是否有数据 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param workTicketInfoMap |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private void isMatterLibraryList(Map<String, Object> workTicketInfoMap) { |
|
|
|
|
|
|
|
//1. 第一种工作票
|
|
|
|
|
|
|
|
//1.1 应断开断路器和隔离开关,包括填写前已断开断路器和隔离开关(注明编号)、应取熔断器(保险)
|
|
|
|
|
|
|
|
WordMapUtils.newMapWithList(WorkTicketConstants.WorkTicketMeasureTypeEnum.ONE.getConvertAttributes(), workTicketInfoMap, true, 6, "safetyMeasure", "status"); |
|
|
|
|
|
|
|
//1.2 应装设接地线、隔板、隔罩(注明确切地点),应合上接地刀闸(注明双重名称)
|
|
|
|
|
|
|
|
WordMapUtils.newMapWithList(WorkTicketConstants.WorkTicketMeasureTypeEnum.TWO.getConvertAttributes(), workTicketInfoMap, true, 3, "safetyMeasure", "status"); |
|
|
|
|
|
|
|
//1.3 应装设遮拦、应挂标识牌及防止二次回路误碰等措施(注明确实地点、名称)
|
|
|
|
|
|
|
|
WordMapUtils.newMapWithList(WorkTicketConstants.WorkTicketMeasureTypeEnum.THREE.getConvertAttributes(), workTicketInfoMap, true, 6, "safetyMeasure", "status"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//2. 第二种工作票
|
|
|
|
|
|
|
|
//2.1 应断开断路器和隔离开关,包括填写前已断开断路器和隔离开关(注明编号)、应取熔断器(保险)
|
|
|
|
|
|
|
|
WordMapUtils.newMapWithList(WorkTicketConstants.WorkTicketMeasureTypeEnum.SEVEN.getConvertAttributes(), workTicketInfoMap, true, 6, "safetyMeasure", "status"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//3. 水利机器工作票
|
|
|
|
|
|
|
|
//3.1 必须采取的安全措施
|
|
|
|
|
|
|
|
WordMapUtils.newMapWithList(WorkTicketConstants.WorkTicketMeasureTypeEnum.EIGHT.getConvertAttributes(), workTicketInfoMap, true, 8, "safetyMeasure", "status"); |
|
|
|
|
|
|
|
//3.2 检修工作要求检修人员自行执行的安全措施(由工作负责人填写)
|
|
|
|
|
|
|
|
WordMapUtils.newMapWithList(WorkTicketConstants.WorkTicketMeasureTypeEnum.NINE.getConvertAttributes(), workTicketInfoMap, true, 5, "safetyMeasure", "status"); |
|
|
|
|
|
|
|
//3.3 检修工作要求检修人员自行执行的安全措施(由工作负责人填写)
|
|
|
|
|
|
|
|
WordMapUtils.newMapWithList(WorkTicketConstants.WorkTicketMeasureTypeEnum.TEN.getConvertAttributes(), workTicketInfoMap, true, 5, "safetyMeasure", "status"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|