sinake
12 小时以前 e00825ef6dc894e11dffa7f8015fccc9f2f1071a
ruoyi-project/src/main/java/com/ruoyi/project/service/impl/ServiceFundServiceImpl.java
@@ -545,7 +545,7 @@
            //记录一下,下一级的审批,以便于下一级退回后,发起者提交时,能再提到当前审批层级
            serviceFund.setBackflowlevel(FlowLevel);
        } else {
        } //else {
            CheckFlag = 2;
            if (CheckFlag == 2) {
                //应医院要求如果出现退回,直接退到发起者
@@ -567,7 +567,7 @@
                    serviceFund.getUsername(), serviceFund.getPretaxcost(), serviceFund.getDonorname(),
                    FundNotifyMessageBuilder.billNo(serviceFund.getBh(), serviceFund.getId()));
            FundNotifyMessageBuilder.addAuditResult(contentList, loginUser.getUser().getNickName(), new Date(),
                    FundNotifyMessageBuilder.opinion(FundNotifyMessageBuilder.CONCLUSION_REJECT,
                    FundNotifyMessageBuilder.opinion(checkFundVO.getFlowconclusion()+"",
                            checkFundVO.getFlowcontent()));
            try {
                DingTalkReqVo dingTalkReqVo = new DingTalkReqVo();
@@ -578,7 +578,7 @@
            } catch (Exception e) {
                log.error("费用---审批未通过钉钉通知失败,fundId={}", serviceFund.getId(), e);
            }
        }
        //}
        serviceFund.setRecordstatus(RecordStatus);
        serviceFund.setFlowlevel(FlowLevel.longValue());
@@ -609,8 +609,16 @@
            sysUsers = sysUserMapper.selectUserByUserName(user.getUserName());
            log.info("费用sysUsers返回的值为:{}", sysUsers);
        }
        if (checkFundVO.getFlowconclusion() == 1 && sysUsers != null && sysUsers.getRoles() != null && sysUsers.getRoles().stream().anyMatch(role -> "officedirector".equals(role.getRoleKey()))) {
            serviceFund.setOfficedirector(user.getNickName());
        // 2026-10-09:推送条件由"当前审核人有 officedirector 角色"改为"本次审批后到达最后一级"。
        // 原写法在"最后一级审核人没有该角色"时永远不会推送,而"非最后一级的 officedirector"会提前推送。
        boolean uploadAtLastLevel = checkFundVO.getFlowconclusion() == 1
                && TotalLevel != null && TotalLevel != 0 && TotalLevel == OriginalFlowLevel + 1;
        if (uploadAtLastLevel) {
            // 仍只在该角色审批时记录办公室主任,保持字段语义不变
            if (sysUsers != null && sysUsers.getRoles() != null
                    && sysUsers.getRoles().stream().anyMatch(role -> "officedirector".equals(role.getRoleKey()))) {
                serviceFund.setOfficedirector(user.getNickName());
            }
            serviceFund.setUploadStates(1);
            //数据发送
            Boolean aBoolean1 = null;
@@ -709,8 +717,12 @@
    }
    private Boolean doSendData(ServiceFund serviceFund) {
        // fund和funddetail的数据获取
        addFundSharedInfo(serviceFund.getId());
        // 2026-10-09:接住 addFundSharedInfo 的失败信号(附件上传失败时它会回滚分享表并返回 false)
        Boolean sharedOk = addFundSharedInfo(serviceFund.getId());
        if (sharedOk == null || !sharedOk) {
            log.error("费用报销单上传失败:分享表/附件环节失败,审批不生效,fundId={}", serviceFund.getId());
            return false;
        }
        List<ServiceFundShared> fundShareInfos = serviceFundSharedMapper.getFundShareInfoById(serviceFund.getId());
        if (CollectionUtils.isEmpty(fundShareInfos)) return false;
@@ -1011,11 +1023,10 @@
            try {
                if (isUploadOaEnabled()) uploadOAFileAndUpdateDb(serviceFunddetailShareds.get(i));
            } catch (Exception e) {
                e.printStackTrace();
                log.error("Exception中入参的ID为:{},异常信息为 : {}", id, e.getMessage());
                log.error("费用附件上传医院协友系统失败:单据id={}(本次报销单上传整体失败,审批不生效)", id, e);
                if (id != null) {
                    Boolean aBoolean = sharedService.delfundsharedInfoById(null, id);
                    log.error("fund2分享表里的数据是否删除成功:{}", aBoolean);
                    log.error("已回滚分享表数据:{}", aBoolean);
                }
                return false;
            }
@@ -1843,7 +1854,7 @@
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("userName", "opo");
        map.put("password", "4126407a-9821-4874-be41-6568abd6dbe5");
        map.put("loginName", "OPO系统审批");
        map.put("loginName", "OPO系统");
        JSONObject jsonObj = new JSONObject(map);
@@ -1860,10 +1871,18 @@
                log.info("filePath的修改:{}", filePath);
                String url = rbDetailFile.getUrl();
                //file用的是绝对位置
                String substring = url.substring(url.indexOf("/profile/upload") + "/profile/upload".length());
                // 2026-10-09:附件地址解析加固,避免 url 异常/文件缺失时抛 NPE 导致看不到失败原因
                int profileIdx = url == null ? -1 : url.indexOf("/profile/upload");
                if (profileIdx < 0) {
                    throw new ServiceException("附件地址格式不正确(缺少 /profile/upload),无法上传协友:" + url);
                }
                String substring = url.substring(profileIdx + "/profile/upload".length());
//            String strFile = rbDetailFile.getUrl().replace(filePath, "/profile/upload");
                System.out.println("fund服务的filePath + substring: " + filePath + substring);
                File filetest = new File(filePath + substring);
                if (!filetest.exists()) {
                    throw new ServiceException("附件文件在服务器上不存在,无法上传协友:" + filetest.getAbsolutePath());
                }
                String struploadResult = HttpClientKit.sendPostWithFile(filetest, strFUrl);
                log.info("第三方传回的数据: {}", struploadResult);