| | |
| | | |
| | | import com.ruoyi.common.annotation.NotRepeatCommit; |
| | | import com.ruoyi.common.config.RuoYiConfig; |
| | | import com.ruoyi.common.constant.HttpStatus; |
| | | import com.ruoyi.common.enums.OrganEnum; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.exception.base.BaseException; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.bean.DtoConversionUtils; |
| | | import com.ruoyi.project.domain.ServiceDonatebaseinfo; |
| | | import com.ruoyi.project.domain.ServiceDonateorgan; |
| | | import com.ruoyi.project.domain.ServiceDonationwitnessorgan; |
| | | import com.ruoyi.project.domain.vo.DonationWitnessVO; |
| | | import com.ruoyi.project.domain.vo.TimeVO; |
| | | import com.ruoyi.project.service.IBaseOnlyvalueService; |
| | |
| | | * 查询捐献见证列表 |
| | | */ |
| | | @ApiOperation("获取捐献见证列表") |
| | | //@PreAuthorize("@ss.hasPermi('project:donationwitness:list')") |
| | | //// @PreAuthorize("@ss.hasPermi('project:donationwitness:list')") |
| | | @GetMapping("/list") |
| | | public TableDataInfo list(ServiceDonationwitness serviceDonationwitness) { |
| | | startPage(); |
| | |
| | | * 导出捐献见证列表 |
| | | */ |
| | | @ApiOperation("导出捐献见证列表") |
| | | //@PreAuthorize("@ss.hasPermi('project:donationwitness:export')") |
| | | //// @PreAuthorize("@ss.hasPermi('project:donationwitness:export')") |
| | | @Log(title = "捐献见证", businessType = BusinessType.EXPORT) |
| | | @GetMapping("/export") |
| | | public AjaxResult export(ServiceDonationwitness serviceDonationwitness) { |
| | |
| | | * 获取捐献见证详细信息 |
| | | */ |
| | | @ApiOperation("通过id获取见证信息") |
| | | //@PreAuthorize("@ss.hasPermi('project:donationwitness:query')") |
| | | //// @PreAuthorize("@ss.hasPermi('project:donationwitness:query')") |
| | | @GetMapping(value = "/{id}") |
| | | public AjaxResult getInfo(@PathVariable("id") Long id) { |
| | | return AjaxResult.success(serviceDonationwitnessService.getById(id)); |
| | |
| | | * 新增捐献见证 |
| | | */ |
| | | @ApiOperation("新增捐献见证") |
| | | //@PreAuthorize("@ss.hasPermi('project:donationwitness:add')") |
| | | //// @PreAuthorize("@ss.hasPermi('project:donationwitness:add')") |
| | | @Log(title = "捐献见证", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | @PostMapping("/add") |
| | | @RepeatSubmit |
| | | public AjaxResult add(@RequestBody ServiceDonationwitness serviceDonationwitness) { |
| | | log.info("新增捐献见证infoId为:{}", serviceDonationwitness.getInfoid()); |
| | | ServiceDonationwitness sd = new ServiceDonationwitness(); |
| | | sd.setInfoid(serviceDonationwitness.getInfoid()); |
| | | sd.setDel_flag(0); |
| | | List<ServiceDonationwitness> serviceDonationwitnesses = serviceDonationwitnessService.selectServiceDonationwitnessList(sd); |
| | | if (CollectionUtils.isEmpty(serviceDonationwitnesses)) { |
| | | boolean save = serviceDonationwitnessService.save(serviceDonationwitness); |
| | | log.info("新增捐献见证是否成功:{},id为:{},infoId为:{}", save, serviceDonationwitness.getId(), serviceDonationwitness.getInfoid()); |
| | | } else { |
| | | log.info("新增捐献见证id为:{}", serviceDonationwitnesses.get(0).getId()); |
| | | serviceDonationwitness.setId(serviceDonationwitnesses.get(0).getId()); |
| | | serviceDonationwitnessService.updateById(serviceDonationwitness); |
| | | } |
| | | |
| | | return toAjax(serviceDonationwitnessService.save(serviceDonationwitness)); |
| | | return AjaxResult.success(serviceDonationwitness); |
| | | } |
| | | |
| | | /** |
| | | * 修改捐献见证 |
| | | */ |
| | | @ApiOperation("修改捐献见证") |
| | | //@PreAuthorize("@ss.hasPermi('project:donationwitness:edit')") |
| | | //// @PreAuthorize("@ss.hasPermi('project:donationwitness:edit')") |
| | | @Log(title = "捐献见证", businessType = BusinessType.UPDATE) |
| | | @PostMapping("/edit") |
| | | @RepeatSubmit |
| | | public AjaxResult edit(@RequestBody ServiceDonationwitness serviceDonationwitness) { |
| | | log.info("新增捐献见证id为:{},infoId为:{}", serviceDonationwitness.getId(), serviceDonationwitness.getInfoid()); |
| | | |
| | | int last = -1; |
| | | if (StringUtils.isNotEmpty(serviceDonationwitness.getDonorno())) { |
| | | last = serviceDonationwitness.getDonorno().lastIndexOf("*"); |
| | |
| | | * 删除捐献见证 |
| | | */ |
| | | @ApiOperation("删除捐献见证") |
| | | //@PreAuthorize("@ss.hasPermi('project:donationwitness:remove')") |
| | | //// @PreAuthorize("@ss.hasPermi('project:donationwitness:remove')") |
| | | @Log(title = "捐献见证", businessType = BusinessType.DELETE) |
| | | @GetMapping("/remove/{ids}") |
| | | public AjaxResult remove(@PathVariable Long[] ids) { |
| | |
| | | String name = "人体器官捐献获取见证登记表_" + dataMap.get("XM") + "_" + newTime; |
| | | //输出文档路径及名称 |
| | | File outFile = new File(RuoYiConfig.getProfile() + "/download/wordtemplate/" + name + ".doc"); |
| | | Writer out = null; |
| | | |
| | | try { |
| | | out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outFile), "utf-8")); |
| | | |
| | | } catch (FileNotFoundException e1) { |
| | | e1.printStackTrace(); |
| | | if (t == null) { |
| | | throw new ServiceException("模板加载失败,请检查模板文件是否存在", HttpStatus.NO_CONTENT); |
| | | } |
| | | try { |
| | | |
| | | // 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"); |
| | |
| | | Boolean i = null; |
| | | for (ServiceDonationwitness serviceDonationwitness : serviceDonationwitnessList) { |
| | | log.info("捐献见证管理id是否为空 : {},基础表的id为 : {}", serviceDonationwitness.getId(), serviceDonationwitness.getInfoid()); |
| | | ServiceDonationwitness sd2 = new ServiceDonationwitness(); |
| | | sd2.setInfoid(serviceDonationwitness.getInfoid()); |
| | | sd2.setDel_flag(0); |
| | | List<ServiceDonationwitness> serviceDonationwitnesses = serviceDonationwitnessService.queryList(sd2); |
| | | if (!CollectionUtils.isEmpty(serviceDonationwitnesses)) { |
| | | serviceDonationwitness.setId(serviceDonationwitnesses.get(0).getId()); |
| | | } |
| | | if (serviceDonationwitness.getId() == null) { |
| | | i = serviceDonationwitnessService.save(serviceDonationwitness); |
| | | } else { |