sinake
2 天以前 c76f64a1f4d9a7f7283373be70b1dfd925286e4d
ruoyi-admin/src/main/java/com/ruoyi/web/controller/project/ServiceRelativesconfirmationController.java
@@ -19,6 +19,7 @@
import freemarker.template.TemplateException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
@@ -46,6 +47,7 @@
 * @author ruoyi
 * @date 2021-11-15
 */
@Slf4j
@Api("亲属确认管理")
@RestController
@RequestMapping("/project/relativesconfirmation")
@@ -119,6 +121,7 @@
    @PostMapping("/add")
    @RepeatSubmit
    public AjaxResult add(@RequestBody ServiceRelativesconfirmation serviceRelativesconfirmation) {
        log.info("新增捐献亲属确认:{}", serviceRelativesconfirmation);
        boolean save = serviceRelativesconfirmationService.save(serviceRelativesconfirmation);
        return AjaxResult.success(serviceRelativesconfirmation);
    }
@@ -132,6 +135,7 @@
    @PostMapping("/edit")
    @RepeatSubmit
    public AjaxResult edit(@RequestBody ServiceRelativesconfirmation serviceRelativesconfirmation) {
        log.info("修改亲属确认:{}", serviceRelativesconfirmation);
        if (serviceRelativesconfirmation.getInfoid() == null || serviceRelativesconfirmation.getId() == null) {
            throw new BaseException("请联系工程师检查ID是否为空");
        }
@@ -185,13 +189,16 @@
        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");
@@ -233,8 +240,8 @@
        } else if (relativeConfirmation.getSex().equals("2")) {
            dataMap.put("XB", "女");
        }
        dataMap.put("CSRQ", relativeConfirmation.getBirthday() == null ? "" : relativeConfirmation.getBirthday().substring(0, 10));
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        dataMap.put("CSRQ", relativeConfirmation.getBirthday() == null ? "" : simpleDateFormat.format(relativeConfirmation.getBirthday()).substring(0, 10));
        dataMap.put("MZ", NationalityEnum.getDescByCode(relativeConfirmation.getNation()) == null ? "" : NationalityEnum.getDescByCode(relativeConfirmation.getNation()));
        dataMap.put("XL", Education.getDescByCode(relativeConfirmation.getEducation()) == null ? "" : Education.getDescByCode(relativeConfirmation.getEducation()));
        String occupation = "";