huminmin
2026-07-13 53c0da6e44a01acf9d97bdc7abaf25e5984b92dc
src/main/java/com/ruoyi/approve/service/impl/ApprovalInstanceServiceImpl.java
@@ -31,6 +31,9 @@
import com.ruoyi.framework.security.LoginUser;
import com.ruoyi.framework.web.domain.R;
import com.ruoyi.procurementrecord.utils.StockUtils;
import com.ruoyi.production.mapper.ProductionProductMainMapper;
import com.ruoyi.production.pojo.ProductionProductMain;
import com.ruoyi.production.service.ProductionAccountService;
import com.ruoyi.project.system.domain.SysDept;
import com.ruoyi.project.system.domain.SysUser;
import com.ruoyi.project.system.mapper.SysDeptMapper;
@@ -94,6 +97,8 @@
    private final EnterpriseNewsMapper enterpriseNewsMapper;
    private final EnterpriseNewsScopeDeptMapper enterpriseNewsScopeDeptMapper;
    private final ApprovalTemplateNodeApproverMapper approvalTemplateNodeApproverMapper;
    private final ProductionProductMainMapper productionProductMainMapper;
    private final ProductionAccountService productionAccountService;
    @Override
    public R listPage(Page<ApprovalInstanceVo> page, ApprovalInstanceDto approvalInstanceDto) {
@@ -420,20 +425,8 @@
        instance.setStatus("REJECTED");
        instance.setFinishTime(now);
        this.updateById(instance);
        // 驳回对应的企业新闻, 差旅报销
        if (instance.getBusinessType().equals(TypeEnums.ENTERPRISE_NEWS_APPROVAL.getCode())) {
            enterpriseNewsMapper.update(
                    new LambdaUpdateWrapper<EnterpriseNews>()
                            .eq(EnterpriseNews::getId, instance.getBusinessId())
                            .set(EnterpriseNews::getStatus, "REJECTED")
            );
        }else if (instance.getBusinessType().equals(TypeEnums.TRAVEL_REIMBURSEMENT_APPROVAL.getCode())||instance.getBusinessType().equals(TypeEnums.EXPENSE_APPROVAL.getCode())) {
            finReimbursementMapper.update(
                    new LambdaUpdateWrapper<FinReimbursement>()
                            .eq(FinReimbursement::getId, instance.getBusinessId())
                            .set(FinReimbursement::getBillStatus, "REJECTED")
            );
        }
        // 统一处理业务状态更新
        handleBusinessAfterApprovalFinished(instance);
        return R.ok("审批已驳回");
    }
@@ -562,6 +555,10 @@
        }
        if (TypeEnums.ENTERPRISE_NEWS_APPROVAL.getCode().equals(businessType)) {
            handleNewsApprovalFinished(instance, status);
            return;
        }
        if (TypeEnums.PRODUCTION_REPORT_APPROVAL.getCode().equals(businessType)) {
            handleProductionReportApprovalFinished(instance, status);
        }
    }
@@ -682,7 +679,7 @@
    private void handleShippingApprovalFinished(ApprovalInstance instance, String status) {
        ShippingInfo shippingInfo = shippingInfoMapper.selectOne(
                new LambdaQueryWrapper<ShippingInfo>()
                        .eq(ShippingInfo::getId, instance.getTitle())
                        .eq(ShippingInfo::getShippingNo, instance.getTitle())
                        .orderByDesc(ShippingInfo::getCreateTime)
                        .last("limit 1")
        );
@@ -701,6 +698,28 @@
            shippingInfo.setStatus(ShippingStatusEnum.IN_PROGRESS.getCode());
        }
        shippingInfoMapper.updateById(shippingInfo);
    }
    private void handleProductionReportApprovalFinished(ApprovalInstance instance, String status) {
        if (instance == null || instance.getBusinessId() == null) {
            return;
        }
        ProductionProductMain productionProductMain = productionProductMainMapper.selectById(instance.getBusinessId());
        if (productionProductMain == null) {
            return;
        }
        if ("APPROVED".equals(status)) {
            productionProductMain.setAuditStatus(1);
        } else if ("REJECTED".equals(status)) {
            productionProductMain.setAuditStatus(2);
        } else if ("PENDING".equals(status)) {
            productionProductMain.setAuditStatus(0);
        } else {
            return;
        }
        productionProductMainMapper.updateById(productionProductMain);
        productionAccountService.rebuildByProductionProductMainId(productionProductMain.getId());
    }
    private List<ApprovalTask> createNodeAndTasks(ApprovalInstance instance, ApprovalTemplateNode templateNode) {
@@ -757,10 +776,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) {