8 小时以前 3d2fd3a3f7d0571721b0f894e07c80553fd1e26c
fix(approve): 修复审批流程中的SQL查询和跳转路径问题

- 修复AccountInvoiceApplicationMapper.xml中的SQL查询条件语法
- 修复AccountPaymentApplicationMapper.xml中的SQL查询条件语法
- 实现基于业务类型的动态跳转路径功能,替换硬编码路径
- 在FinReimbursementServiceImpl中添加删除验证和关联审批实例清理
- 统一审批通知中的页面跳转路径逻辑
已修改5个文件
77 ■■■■ 文件已修改
src/main/java/com/ruoyi/approve/service/impl/ApprovalInstanceServiceImpl.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/approve/service/impl/FinReimbursementServiceImpl.java 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/collaborativeApproval/service/impl/EnterpriseNewsServiceImpl.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/account/purchase/AccountPaymentApplicationMapper.xml 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/account/sales/AccountInvoiceApplicationMapper.xml 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/approve/service/impl/ApprovalInstanceServiceImpl.java
@@ -745,10 +745,29 @@
        String title = StringUtils.hasText(instance.getTemplateName()) ? instance.getTemplateName() : "审批提醒";
        String message = "审批单号 " + instance.getInstanceNo() + " 需要您审批";
        String jumpPath = "/officeProcessAutomation/ApproveManage/approve-list?id=" + instance.getId();
        String jumpPath = getJumpPathByBusinessType(instance.getBusinessType(), instance.getId());
        sysNoticeService.simpleNoticeByUser(title, message, approverIds, jumpPath);
    }
    private String getJumpPathByBusinessType(Long businessType, Long instanceId) {
        if (businessType == null) {
            return "/collaborativeApproval/approve-list?id=" + instanceId;
        }
        if (TypeEnums.LEAVE_APPROVAL.getCode().equals(businessType)) {
            return "/collaborativeApproval/AttendManage/leave-apply?id=" + instanceId;
        }
        if (TypeEnums.OVERTIME_APPROVAL.getCode().equals(businessType)) {
            return "/collaborativeApproval/AttendManage/overtime-apply?id=" + instanceId;
        }
        if (TypeEnums.TRAVEL_REIMBURSEMENT_APPROVAL.getCode().equals(businessType)) {
            return "/collaborativeApproval/ReimburseManage/travel-reimburse?id=" + instanceId;
        }
        if (TypeEnums.EXPENSE_APPROVAL.getCode().equals(businessType)) {
            return "/collaborativeApproval/ReimburseManage/cost-reimburse?id=" + instanceId;
        }
        return "/collaborativeApproval/approve-list?id=" + instanceId;
    }
    private void sendEnterpriseNewsNotice(Long newsId) {
        EnterpriseNews enterpriseNews = enterpriseNewsMapper.selectById(newsId);
        if (enterpriseNews == null) {
src/main/java/com/ruoyi/approve/service/impl/FinReimbursementServiceImpl.java
@@ -274,6 +274,26 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Boolean delete(List<Long> ids) {
        if (ids == null || ids.isEmpty()) {
            throw new ServiceException("删除失败,请选择要删除的数据");
        }
        // 查询报销单关联的审批实例ID
        List<FinReimbursement> reimbursements = finReimbursementMapper.selectList(
                new LambdaQueryWrapper<FinReimbursement>()
                        .in(FinReimbursement::getId, ids)
                        .isNotNull(FinReimbursement::getApprovalInstanceId)
        );
        List<Long> approvalInstanceIds = reimbursements.stream()
                .map(FinReimbursement::getApprovalInstanceId)
                .filter(Objects::nonNull)
                .distinct()
                .collect(Collectors.toList());
        // 删除关联的审批记录
        if (!approvalInstanceIds.isEmpty()) {
            approvalInstanceService.delete(approvalInstanceIds);
        }
        fileUtil.deleteStorageAttachmentsByApplicationAndRecordTypeAndRecordIds(ApplicationTypeEnum.FILE, RecordTypeEnum.FIN_REIMBURSEMENT, ids);
        //先删除明细
        finReimbursementDetailMapper.delete(new LambdaQueryWrapper<FinReimbursementDetail>().in(FinReimbursementDetail::getReimbursementId, ids));
@@ -494,10 +514,20 @@
        }
        String title = "报销审批";
        String message = "审批单号 " + instance.getInstanceNo() + " 需要您审批";
        String jumpPath = "/approvalInstance?id=" + instance.getId();
        String jumpPath = getJumpPathByBusinessType(instance.getBusinessType(), instance.getId());
        sysNoticeService.simpleNoticeByUser(title, message, approverIds, jumpPath);
    }
    private String getJumpPathByBusinessType(Long businessType, Long instanceId) {
        if (TypeEnums.TRAVEL_REIMBURSEMENT_APPROVAL.getCode().equals(businessType)) {
            return "/collaborativeApproval/ReimburseManage/travel-reimburse?id=" + instanceId;
        }
        if (TypeEnums.EXPENSE_APPROVAL.getCode().equals(businessType)) {
            return "/collaborativeApproval/ReimburseManage/cost-reimburse?id=" + instanceId;
        }
        return "/approvalInstance?id=" + instanceId;
    }
    private void resetApprovalFlow(FinReimbursement existing, Long reimbursementId) {
        if (existing == null || existing.getApprovalInstanceId() == null) {
            return;
src/main/java/com/ruoyi/collaborativeApproval/service/impl/EnterpriseNewsServiceImpl.java
@@ -403,7 +403,7 @@
        String title = StringUtils.isNotEmpty(instance.getTemplateName()) ? instance.getTemplateName() : "审批提醒";
        String message = "审批单号 " + instance.getInstanceNo() + " 需要您审批";
        String jumpPath = "/officeProcessAutomation/ApproveManage/approve-list/?id=" + instance.getId();
        String jumpPath = "/collaborativeApproval/approve-list/?id=" + instance.getId();
        sysNoticeService.simpleNoticeByUser(title, message, approverIds, jumpPath);
    }
}
src/main/resources/mapper/account/purchase/AccountPaymentApplicationMapper.xml
@@ -88,12 +88,14 @@
    </select>
    <select id="existsByStockInRecordId" resultType="java.lang.Boolean">
         SELECT COUNT(*) > 0
        SELECT COUNT(*) > 0
        FROM account_payment_application
        WHERE  status != 2
        <foreach collection="stockInRecordIds" item="id" open="(" separator=" OR " close=")">
            FIND_IN_SET(#{id}, stock_in_record_ids)
        </foreach>
        WHERE status != 2
        AND (
            <foreach collection="stockInRecordIds" item="id" separator=" OR ">
                FIND_IN_SET(#{id}, stock_in_record_ids) > 0
            </foreach>
        )
    </select>
</mapper>
src/main/resources/mapper/account/sales/AccountInvoiceApplicationMapper.xml
@@ -65,10 +65,12 @@
    <select id="existsByStockOutRecordId" resultType="java.lang.Boolean">
        SELECT COUNT(*) > 0
        FROM account_invoice_application
        WHERE status!=2
        <foreach collection="stockOutRecordIds" item="id" open="(" separator=" OR " close=")">
            FIND_IN_SET(#{id}, stock_out_record_ids)
        </foreach>
        WHERE status != 2
        AND (
            <foreach collection="stockOutRecordIds" item="id" separator=" OR ">
                FIND_IN_SET(#{id}, stock_out_record_ids) > 0
            </foreach>
        )
    </select>
</mapper>