| | |
| | | import com.yuanchu.mom.service.InsOrderService; |
| | | import com.yuanchu.mom.service.StandardTemplateService; |
| | | import com.yuanchu.mom.utils.GiveCode; |
| | | import com.yuanchu.mom.utils.JackSonUtil; |
| | | import com.yuanchu.mom.utils.MatrixToImageWriter; |
| | | import com.yuanchu.mom.utils.QueryWrappers; |
| | | import com.yuanchu.mom.vo.InsOrderPlanVO; |
| | | import org.apache.poi.xwpf.usermodel.TableRowAlign; |
| | |
| | | |
| | | @Value("${wordUrl}") |
| | | private String wordUrl; |
| | | |
| | | @Value("${twoCode}") |
| | | private String twoCode; |
| | | |
| | | @Resource |
| | | private GiveCode giveCode; |
| | |
| | | table.put("tableSize", tables.size() + 1); |
| | | }); |
| | | List<Map<String, String>> deviceList = insOrderMapper.selectDeviceList(deviceSet); |
| | | Map<String, String> codeStr = new HashMap<>(); |
| | | codeStr.put("报告编号", insReport.getCode()); |
| | | codeStr.put("样品名称", insOrder.getSample()); |
| | | codeStr.put("规格型号", samples.get(0).getModel()); |
| | | codeStr.put("发放日期", LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); |
| | | String codePath; |
| | | try { |
| | | codePath = new MatrixToImageWriter().code(JackSonUtil.marshal(codeStr).replaceAll("\\{","") |
| | | .replaceAll("}","").replaceAll(",","").replaceAll("\"",""), twoCode); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | ConfigureBuilder builder = Configure.builder(); |
| | | builder.useSpringEL(true); |
| | | XWPFTemplate template = XWPFTemplate.compile(url, builder.build()).render( |
| | |
| | | put("tableSize", tables.size() + 1); |
| | | put("standardMethod", standardMethod2); |
| | | put("deviceList", deviceList); |
| | | put("twoCode", Pictures.ofLocal(codePath).create()); |
| | | }}); |
| | | try { |
| | | String name = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yy_MM_dd_HH_mm_ss")) + ".docx"; |
| | | String name = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yy_MM_dd&HH_mm_ss")) + ".docx"; |
| | | template.writeAndClose(Files.newOutputStream(Paths.get(wordUrl + "/" + name))); |
| | | insReport.setUrl("/word/" + name); |
| | | insReportMapper.insert(insReport); |