| | |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.framework.exception.ErrorException; |
| | | import com.ruoyi.inspect.util.HackLoopTableRenderPolicy; |
| | | import com.ruoyi.inspect.util.UserUtils; |
| | | import com.ruoyi.process.dto.ProcessDealDto; |
| | | import com.ruoyi.process.mapper.InspectionOrderMapper; |
| | | import com.ruoyi.process.mapper.ProcessDealMapper; |
| | | import com.ruoyi.process.mapper.ProcessSampleMapper; |
| | |
| | | |
| | | @Override |
| | | public void exportProcessTotaldeal(Integer id, HttpServletResponse response) { |
| | | List<ProcessDeal> sampleDealDtos = processDealMapper.selectDeal(id); |
| | | List<ProcessDealDto> sampleDealDtos = processDealMapper.selectDeal(id); |
| | | ProcessTotaldeal processTotaldeal = processTotaldealMapper.selectById(id); |
| | | String submitUserUrl="1"; |
| | | String examineUserUrl="1"; |
| | | String ratifyUserUrl="1"; |
| | | //获取提交人签名 |
| | | if (ObjectUtils.isNotNull(processTotaldeal.getSubmitUser())) { |
| | | User user1 = userMapper.selectById(processTotaldeal.getSubmitUser()); |
| | | if (ObjectUtils.isEmpty(user1.getSignatureUrl())) throw new ErrorException("未找到提交人的电子签名,请上传自己的电子签名!"); |
| | | submitUserUrl = user1.getSignatureUrl(); |
| | | } |
| | | //获取审核人签名 |
| | | if (ObjectUtils.isNotNull(processTotaldeal.getExamineUser())) { |
| | | User user2 = userMapper.selectById(processTotaldeal.getExamineUser()); |
| | | if (ObjectUtils.isEmpty(user2.getSignatureUrl())) throw new ErrorException("未找到审核人的电子签名,请上传自己的电子签名!"); |
| | | examineUserUrl = user2.getSignatureUrl(); |
| | | } |
| | | //获取批准人签名 |
| | | if (ObjectUtils.isNotNull(processTotaldeal.getRatifyUser())) { |
| | | User user3 = userMapper.selectById(processTotaldeal.getRatifyUser()); |
| | | if (ObjectUtils.isEmpty(user3.getSignatureUrl())) throw new ErrorException("未找到批准人的电子签名,请上传自己的电子签名!"); |
| | | ratifyUserUrl = user3.getSignatureUrl(); |
| | | } |
| | | |
| | | // 获取路径 |
| | | InputStream inputStream = this.getClass().getResourceAsStream("/static/sample-deal.docx"); |
| | | Configure configure = Configure.builder() |
| | | .bind("sampleList", new HackLoopTableRenderPolicy()) |
| | | .build(); |
| | | FilePictureRenderData finalSubmitUserUrl = submitUserUrl!="1" ? new FilePictureRenderData(100, 50, imgUrl + "/" + submitUserUrl) : null; |
| | | FilePictureRenderData finalExamineUserUrl = examineUserUrl!="1" ? new FilePictureRenderData(100, 50, imgUrl + "/" + examineUserUrl) : null; |
| | | FilePictureRenderData finalRatifyUserUrl = ratifyUserUrl!="1" ? new FilePictureRenderData(100, 50, imgUrl + "/" + ratifyUserUrl) : null; |
| | | XWPFTemplate template = XWPFTemplate.compile(inputStream, configure).render( |
| | | new HashMap<String, Object>() {{ |
| | | put("sampleList", sampleDealDtos); |
| | | put("examineUrl", finalExamineUserUrl);//审核人 |
| | | put("ratifyUrl", finalRatifyUserUrl);//批准人 |
| | | put("writeUrl",finalSubmitUserUrl);//提交人 |
| | | put("writeUrl",UserUtils.getFinalUserSignatureUrl(processTotaldeal.getSubmitUser()));//提交人 |
| | | put("examineUrl", UserUtils.getFinalUserSignatureUrl(processTotaldeal.getExamineUser()));//审核人 |
| | | put("ratifyUrl", UserUtils.getFinalUserSignatureUrl(processTotaldeal.getRatifyUser()));//批准人 |
| | | }}); |
| | | try { |
| | | response.setContentType("application/msword"); |
| | |
| | | template.write(os); |
| | | os.flush(); |
| | | os.close(); |
| | | inputStream.close(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | throw new RuntimeException("导出失败"); |