yxh
2 天以前 596834ce4e233130d61888128fe66a0c008543dd
ruoyi-admin/src/main/java/com/ruoyi/web/controller/project/ServiceReimbursementController.java
@@ -14,6 +14,7 @@
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.project.domain.*;
import com.ruoyi.project.common.FundNotifyMessageBuilder;
import com.ruoyi.project.domain.dto.ServiceReimbursementDto;
import com.ruoyi.project.domain.vo.CheckFundVO;
import com.ruoyi.project.domain.vo.DingTalkReqVo;
@@ -346,17 +347,27 @@
                    //陈慕华信息
                    sysUser = sysUserService.selectUserByUserName("047");
                }
                ConcurrentHashMap map = new ConcurrentHashMap();
                ArrayList<ConcurrentHashMap<String, Object>> contentList = new ArrayList<>();
                map.put("提交人:", loginUser.getUser().getUserName());
                map.put("提交时间:", new Date());
                map.put("内容:", serviceReimbursement.getReason());
                contentList.add(map);
                DingTalkReqVo dingTalkReqVo = new DingTalkReqVo();
                dingTalkReqVo.setTitle("差旅审批信息");
                dingTalkReqVo.setNumber(sysUser != null ? sysUser.getPhonenumber() : "");
                dingTalkReqVo.setContents(contentList);
                dingTalkService.sendNotification(dingTalkReqVo);
                //差旅费上报提交:单据信息 + 提交人/提交时间/内容
                //钉钉属于旁路通知,任何失败都不得影响"上报"主流程(否则前端会提示失败但数据已更新)
                try {
                    List<ConcurrentHashMap<String, Object>> contentList = FundNotifyMessageBuilder.newRows();
                    FundNotifyMessageBuilder.addBillInfo(contentList, "0", serviceReimbursement.getUsername(),
                            serviceReimbursement.getAmountrequested(), null,
                            FundNotifyMessageBuilder.billNo(serviceReimbursement.getBh(),
                                    serviceReimbursement.getId()));
                    FundNotifyMessageBuilder.addTravelInfo(contentList, serviceReimbursement.getTravelers(),
                            serviceReimbursement.getReason());
                    FundNotifyMessageBuilder.addSubmitInfo(contentList, loginUser.getUser().getNickName(),
                            new Date(), serviceReimbursement.getReason());
                    DingTalkReqVo dingTalkReqVo = new DingTalkReqVo();
                    dingTalkReqVo.setTitle(FundNotifyMessageBuilder.TITLE);
                    dingTalkReqVo.setNumber(sysUser != null ? sysUser.getPhonenumber() : "");
                    dingTalkReqVo.setContents(contentList);
                    dingTalkService.sendNotification(dingTalkReqVo);
                } catch (Throwable t) {
                    log.error("差旅上报钉钉通知失败,已忽略(不影响上报主流程),id={}",
                            serviceReimbursement.getId(), t);
                }
            }
            serviceReimbursementService.updateById(serviceReimbursement);
@@ -467,18 +478,16 @@
            System.out.println("目录已存在");
        }
        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");