| | |
| | | * 检验报告发放登记表 服务实现类 |
| | | * </p> |
| | | * |
| | | * @author 芯导软件(江苏)有限公司 |
| | | * @author |
| | | * @since 2024-11-05 08:58:39 |
| | | */ |
| | | @Service |
| | |
| | | processReport.setSignatoryName(signatoryName); |
| | | } |
| | | //生成检验报告发放登记表 |
| | | String url; |
| | | try { |
| | | InputStream inputStream = this.getClass().getResourceAsStream("/static/report-deal.docx"); |
| | | File file = File.createTempFile("temp", ".tmp"); |
| | | OutputStream outputStream = new FileOutputStream(file); |
| | | IOUtils.copy(inputStream, outputStream); |
| | | url = file.getAbsolutePath(); |
| | | } catch (FileNotFoundException e) { |
| | | throw new ErrorException("找不到模板文件"); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | InputStream inputStream = this.getClass().getResourceAsStream("/static/report-deal.docx"); |
| | | ConfigureBuilder builder = Configure.builder(); |
| | | builder.useSpringEL(true); |
| | | |
| | |
| | | tableRenderData.setTableStyle(tableStyle); |
| | | Map<String, Object> table = new HashMap<>(); |
| | | table.put("report", tableRenderData); |
| | | table.put("index1", index1); |
| | | reportList.add(table); |
| | | index1++; |
| | | } |
| | | } |
| | | Integer finalIndex = index1; |
| | | XWPFTemplate template = XWPFTemplate.compile(url, builder.build()).render( |
| | | XWPFTemplate template = XWPFTemplate.compile(inputStream, builder.build()).render( |
| | | new HashMap<String, Object>() {{ |
| | | put("reportList", reportList); |
| | | }}); |