| | |
| | | import cn.hutool.core.lang.UUID; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.deepoove.poi.XWPFTemplate; |
| | |
| | | import com.ruoyi.common.core.domain.entity.User; |
| | | import com.ruoyi.common.utils.QueryWrappers; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.SignatureImageUtil; |
| | | import com.ruoyi.framework.exception.ErrorException; |
| | | import com.ruoyi.inspect.util.HackLoopTableRenderPolicy; |
| | | import com.ruoyi.process.dto.ProcessReportDto; |
| | | import com.ruoyi.process.mapper.ProcessReportMapper; |
| | | import com.ruoyi.process.pojo.ProcessReport; |
| | | import com.ruoyi.process.service.ProcessReportService; |
| | | import com.ruoyi.system.mapper.UserMapper; |
| | | import org.apache.commons.io.IOUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.poi.xwpf.usermodel.*; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | |
| | | @Resource |
| | | private ProcessReportMapper processReportMapper; |
| | | |
| | | |
| | | @Value("${wordUrl}") |
| | | private String wordUrl; |
| | | @Value("${file.path}") |
| | | private String imgUrl; |
| | | |
| | | @Resource |
| | | private UserMapper userMapper; |
| | | |
| | | @Override |
| | | public IPage<ProcessReport> pageProcessReport(Page page, ProcessReport processReport) { |
| | | //todo 仅看我 |
| | | IPage<ProcessReport> processReportIPage = processReportMapper.pageProcessReport(page, QueryWrappers.queryWrappers(processReport)); |
| | | // for (ProcessReport record : processReportIPage.getRecords()) { |
| | | // List<String> name = new ArrayList<>(); |
| | | // for (String s : record.getSignatory().split(",")) { |
| | | // User user = userMapper.selectById(Integer.parseInt(s)); |
| | | // name.add(user.getName()); |
| | | // } |
| | | // String signatoryName = name.stream().collect(Collectors.joining(",")); |
| | | // record.setSignatoryName(signatoryName); |
| | | // } |
| | | public IPage<ProcessReportDto> pageProcessReport(Page page, ProcessReportDto processReport) { |
| | | IPage<ProcessReportDto> processReportIPage = processReportMapper.pageProcessReport(page, QueryWrappers.queryWrappers(processReport)); |
| | | |
| | | return processReportIPage; |
| | | } |
| | | |
| | | @Override |
| | | public void exportProcessReport(List<Integer> ids, HttpServletResponse response) { |
| | | List<ProcessReport> processReports = processReportMapper.getIds(ids); |
| | | // for (ProcessReport record : processReports) { |
| | | // List<String> name = new ArrayList<>(); |
| | | // if(StringUtils.isNotBlank(record.getSignatory())){ |
| | | // for (String s : record.getSignatory().split(",")) { |
| | | // User user = userMapper.selectById(Integer.parseInt(s)); |
| | | // name.add(user.getName()); |
| | | // } |
| | | // String signatoryName = name.stream().collect(Collectors.joining(",")); |
| | | // record.setSignatoryName(signatoryName); |
| | | // } |
| | | // } |
| | | public void exportProcessReport(ProcessReportDto dto, HttpServletResponse response) { |
| | | List<ProcessReportDto> processReports = processReportMapper.exportProcessReport(); |
| | | for (ProcessReportDto processReport : processReports) { |
| | | // 发送人生成签名图片 |
| | | processReport.setSendUserRender(StringUtils.isNotBlank(processReport.getSendUserUrl()) |
| | | ? Pictures.ofLocal(imgUrl + "/" + processReport.getSendUserUrl()).create() : null); |
| | | |
| | | // 签收人生成图片 |
| | | processReport.setSignatoryRender(StringUtils.isNotBlank(processReport.getSignatory()) |
| | | ? Pictures.ofStream(SignatureImageUtil.saveImageToFile(processReport.getSignatory())).create() : null); |
| | | } |
| | | |
| | | // 获取路径 |
| | | InputStream inputStream = this.getClass().getResourceAsStream("/static/report-deal.docx"); |
| | | Configure configure = Configure.builder() |
| | |
| | | template.write(os); |
| | | os.flush(); |
| | | os.close(); |
| | | inputStream.close(); |
| | | inputStream.close(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | throw new RuntimeException("导出失败"); |