| | |
| | | @RepeatSubmit |
| | | public AjaxResult add(@RequestBody ServiceRelativesconfirmation serviceRelativesconfirmation) { |
| | | log.info("新增捐献亲属确认:{}", serviceRelativesconfirmation); |
| | | boolean save = serviceRelativesconfirmationService.save(serviceRelativesconfirmation); |
| | | // 2026-10-22:同一案例只允许一条未删除记录——已存在则更新,避免反复保存产生重复行 |
| | | if (serviceRelativesconfirmation.getInfoid() != null) { |
| | | ServiceRelativesconfirmation query = new ServiceRelativesconfirmation(); |
| | | query.setInfoid(serviceRelativesconfirmation.getInfoid()); |
| | | List<ServiceRelativesconfirmation> exist = serviceRelativesconfirmationService.queryList(query); |
| | | if (exist != null && !exist.isEmpty()) { |
| | | serviceRelativesconfirmation.setId(exist.get(0).getId()); |
| | | serviceRelativesconfirmationService.updateById(serviceRelativesconfirmation); |
| | | return AjaxResult.success(serviceRelativesconfirmation); |
| | | } |
| | | } |
| | | serviceRelativesconfirmationService.save(serviceRelativesconfirmation); |
| | | return AjaxResult.success(serviceRelativesconfirmation); |
| | | } |
| | | |
| | |
| | | String name = "人体器官捐献亲属确认登记表_" + dataMap.get("XM") + "_" + newTime; |
| | | //输出文档路径及名称 |
| | | File outFile = new File(RuoYiConfig.getProfile() + "/download/wordtemplate/" + name + ".doc"); |
| | | Writer out = null; |
| | | if (t == null) { |
| | | throw new ServiceException("模板加载失败,请检查模板文件是否存在", HttpStatus.NO_CONTENT); |
| | | } |
| | | |
| | | try { |
| | | out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outFile), "utf-8")); |
| | | // Writer 必须关闭/刷新:BufferedWriter 带缓冲,不关闭会造成文件句柄泄漏且内容可能不完整 |
| | | try (Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outFile), "utf-8"))) { |
| | | t.process(dataMap, out); |
| | | } catch (TemplateException e) { |
| | | e.printStackTrace(); |
| | | } catch (TemplateException | IOException e) { |
| | | log.error("生成模板文档失败, name={}", name, e); |
| | | throw new ServiceException("生成文档失败", HttpStatus.ERROR); |
| | | } |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("downloadUrl", "/profile/download/wordtemplate/" + name + ".doc"); |