fix:审批单合并成审批中心

dev_1.0.2
jiangpeng 2026-08-03 09:54:46 +08:00
parent 0106da0c29
commit a9ed35793a
8 changed files with 2439 additions and 0 deletions

View File

@ -0,0 +1,20 @@
import request from '@/utils/request'
// 查询审批任务列表
export function listApprovalTask(query) {
const { pageNum, pageSize, orderByColumn, isAsc, ...body } = query
return request({
url: '/approve/task/vue/list',
method: 'post',
params: { pageNum, pageSize, orderByColumn, isAsc },
data: body
})
}
// 获取审批任务数量统计
export function getApprovalTaskTotal() {
return request({
url: '/approve/task/vue/total',
method: 'get'
})
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,46 @@
package com.ruoyi.sip.controller.vue;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.sip.domain.ApprovalTask;
import com.ruoyi.sip.service.IApprovalTaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* Controller (Vue)
*
* @author auto
* @date 2026-07-27
*/
@RestController
@RequestMapping("/approve/task/vue")
public class VueApprovalTaskController extends BaseController {
@Autowired
private IApprovalTaskService approvalTaskService;
/**
*
*
*/
@PostMapping("/list")
public TableDataInfo list(@RequestBody ApprovalTask approvalTask) {
startPage();
List<ApprovalTask> list = approvalTaskService.selectApprovalTaskList(approvalTask);
return getDataTable(list);
}
/**
*
*
*/
@GetMapping("/total")
public AjaxResult getTotal() {
return AjaxResult.success(approvalTaskService.selectApprovalTaskCount());
}
}

View File

@ -0,0 +1,58 @@
package com.ruoyi.sip.domain;
import lombok.Data;
import lombok.Getter;
import lombok.ToString;
import com.ruoyi.common.core.domain.BaseEntity;
import java.math.BigDecimal;
/**
*
*
* @author auto
* @date 2026-07-27
*/
@Data
@ToString
public class ApprovalTask extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 主键ID */
private Long id;
/** 流程编号 */
private String processNo;
/** 流程标题 */
private String processTitle;
/** 审批类型 */
private String approveType;
/** 发起人 */
private String initiator;
/** 发起时间 */
private String startTime;
/** 审批人 */
private String approveUser;
/** 业务主键 */
private String businessKey;
/** 流程类型 */
private String processKey;
/** 待办任务ID */
private String taskId;
/** 含税总计 */
private BigDecimal totalAmount;
/** 审批状态1-待处理 / 2-已通过 / 3-已驳回) */
private String approveStatus;
}

View File

@ -0,0 +1,31 @@
package com.ruoyi.sip.mapper;
import com.ruoyi.sip.domain.ApprovalTask;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* Mapper
*
* @author auto
* @date 2026-07-27
*/
public interface ApprovalTaskMapper {
/**
*
*
* @param approvalTask
* @return
*/
List<ApprovalTask> selectApprovalTaskList(ApprovalTask approvalTask);
/**
*
*
* @return
*/
Map<String, Integer> selectApprovalTaskCount(@Param("approveUser") String approveUser);
}

View File

@ -0,0 +1,31 @@
package com.ruoyi.sip.service;
import com.ruoyi.sip.domain.ApprovalTask;
import java.util.List;
import java.util.Map;
/**
* Service
*
* @author auto
* @date 2026-07-27
*/
public interface IApprovalTaskService {
/**
*
*
* @param approvalTask
* @return
*/
List<ApprovalTask> selectApprovalTaskList(ApprovalTask approvalTask);
/**
*
*
* @return
*/
Map<String, Integer> selectApprovalTaskCount();
}

View File

@ -0,0 +1,48 @@
package com.ruoyi.sip.service.impl;
import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.sip.domain.ApprovalTask;
import com.ruoyi.sip.mapper.ApprovalTaskMapper;
import com.ruoyi.sip.service.IApprovalTaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
* Service
*
* @author auto
* @date 2026-07-27
*/
@Service
public class ApprovalTaskServiceImpl implements IApprovalTaskService {
@Autowired
private ApprovalTaskMapper approvalTaskMapper;
/**
*
*
* @param approvalTask
* @return
*/
@Override
public List<ApprovalTask> selectApprovalTaskList(ApprovalTask approvalTask) {
approvalTask.setApproveUser(String.valueOf(ShiroUtils.getUserId()));
List<ApprovalTask> list = approvalTaskMapper.selectApprovalTaskList(approvalTask);
return list;
}
/**
*
*
* @return
*/
@Override
public Map<String, Integer> selectApprovalTaskCount() {
return approvalTaskMapper.selectApprovalTaskCount(String.valueOf(ShiroUtils.getUserId()));
}
}

View File

@ -0,0 +1,878 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.sip.mapper.ApprovalTaskMapper">
<resultMap type="com.ruoyi.sip.domain.ApprovalTask" id="ApprovalTaskResult">
<result property="id" column="id" />
<result property="processNo" column="process_no" />
<result property="processTitle" column="process_title" />
<result property="approveType" column="approve_type" />
<result property="initiator" column="initiator" />
<result property="startTime" column="start_time" />
<result property="totalAmount" column="total_amount" />
<result property="approveStatus" column="approve_status" />
<result property="approveUser" column="approve_user" />
<result property="processKey" column="process_key" />
<result property="taskId" column="task_id" />
</resultMap>
<select id="selectApprovalTaskList" parameterType="com.ruoyi.sip.domain.ApprovalTask" resultMap="ApprovalTaskResult">
/* 订单审批 */
select
t1.id,
t1.order_code as process_no,
t2.project_name as process_title,
'order_approval' as approve_type,
t1.shipment_amount as total_amount,
t1.order_status as approve_status,
btc.apply_user_name as initiator,
btc.apply_time as start_time,
bt.task_id,
bt.business_key,
bt.process_key,
bt.approve_user
from project_order_info as t1
inner join project_info as t2 on t1.project_id = t2.id
left join (
select
business_key,
process_key,
apply_user_name,
apply_time,
approve_user,
row_number() over (partition by business_key order by apply_time desc) as row_num
from bu_todo_completed
where task_name = '售前'
and process_key in ('order_approve_online', 'order_approve_offline')
) as btc on t1.order_code = btc.business_key and btc.row_num = 1
left join (
select
task_id,
business_key,
process_key,
approve_user,
row_number() over (partition by business_key order by id desc) as row_num
from bu_todo
where process_key in ('order_approve_online', 'order_approve_offline')
<if test="approveUser != null and approveUser != &quot;1&quot;">
and approve_user = #{approveUser}
</if>
) as bt on t1.order_code = bt.business_key and bt.row_num = 1
where ifnull(t1.order_status, 0) != 0
<if test="approveUser != null and approveUser != &quot;1&quot;">
and exists(
select 1 from bu_todo_completed as btc
where btc.process_key in ('order_approve_online', 'order_approve_offline')
and t1.order_code = btc.business_key
and btc.approve_user = #{approveUser}
)
</if>
<if test="processNo != null and processNo != ''">
and t1.order_code like concat('%', #{processNo}, '%')
</if>
<if test="processTitle != null and processTitle != ''">
and t2.project_name like concat('%', #{processTitle}, '%')
</if>
<if test="initiator != null and initiator != ''">
and btc.apply_user_name like concat('%', #{initiator}, '%')
</if>
<if test="approveStatus != null and approveStatus != ''">
and t1.order_status = #{approveStatus}
</if>
<if test="approveType != null and approveType != '' and approveType != 'order_approval'">
and t1.id is null
</if>
union all
/* 采购审批 */
select
t1.id,
t1.purchase_no as process_no,
t2.vendor_name as process_title,
'purchase_approval' as approve_type,
t1.total_amount,
t1.approve_status,
btc.apply_user_name as initiator,
btc.apply_time as start_time,
bt.task_id,
bt.business_key,
bt.process_key,
bt.approve_user
from oms_purchase_order as t1
left join oms_vendor_info t2 on t1.vendor_id = t2.vendor_id
left join (
select
business_key,
apply_user_name,
apply_time,
process_key,
approve_user,
row_number() over (partition by business_key order by apply_time desc) as row_num
from bu_todo_completed
where task_name = '商务'
and process_key in ('purchase_order_online')
) as btc on t1.purchase_no = btc.business_key and btc.row_num = 1
left join (
select
task_id,
business_key,
process_key,
approve_user,
row_number() over (partition by business_key order by id desc) as row_num
from bu_todo
where process_key in ('purchase_order_online')
<if test="approveUser != null and approveUser != &quot;1&quot;">
and approve_user = #{approveUser}
</if>
) as bt on t1.purchase_no = bt.business_key and bt.row_num = 1
where ifnull(t1.approve_status, 0) != 0
<if test="approveUser != null and approveUser != &quot;1&quot;">
and exists(
select 1 from bu_todo_completed as btc
where btc.process_key in ('purchase_order_online')
and t1.purchase_no = btc.business_key
and btc.approve_user = #{approveUser}
)
</if>
<if test="processNo != null and processNo != ''">
and t1.purchase_no like concat('%', #{processNo}, '%')
</if>
<if test="processTitle != null and processTitle != ''">
and t2.vendor_name like concat('%', #{processTitle}, '%')
</if>
<if test="initiator != null and initiator != ''">
and btc.apply_user_name like concat('%', #{initiator}, '%')
</if>
<if test="approveStatus != null and approveStatus != ''">
and t1.approve_status = #{approveStatus}
</if>
<if test="approveType != null and approveType != '' and approveType != 'purchase_approval'">
and t1.id is null
</if>
union all
/* 付款审批 */
select
t1.id,
t1.payment_bill_code as process_no,
t2.vendor_name as process_title,
'payment_approval' as approve_type,
t1.total_price_with_tax as total_amount,
t1.approve_status,
btc.apply_user_name as initiator,
btc.apply_time as start_time,
bt.task_id,
bt.business_key,
bt.process_key,
bt.approve_user
from oms_payment_bill as t1
left join oms_vendor_info t2 on t1.vendor_code = t2.vendor_code
left join (
select
business_key,
apply_user_name,
apply_time,
process_key,
approve_user,
row_number() over (partition by business_key order by apply_time desc) as row_num
from bu_todo_completed
where task_name = '商务'
and process_key in ('finance_payment')
) as btc on t1.payment_bill_code = btc.business_key and btc.row_num = 1
left join (
select
task_id,
business_key,
process_key,
approve_user,
row_number() over (partition by business_key order by id desc) as row_num
from bu_todo
where process_key in ('finance_payment')
<if test="approveUser != null and approveUser != &quot;1&quot;">
and approve_user = #{approveUser}
</if>
) as bt on t1.payment_bill_code = bt.business_key and bt.row_num = 1
where ifnull(t1.approve_status, 0) != 0
and payment_bill_type in ('FROM_PAYABLE','PRE_PAYMENT')
<if test="approveUser != null and approveUser != &quot;1&quot;">
and exists(
select 1 from bu_todo_completed as btc
where btc.process_key in ('finance_payment')
and t1.payment_bill_code = btc.business_key
and btc.approve_user = #{approveUser}
)
</if>
<if test="processNo != null and processNo != ''">
and t1.payment_bill_code like concat('%', #{processNo}, '%')
</if>
<if test="processTitle != null and processTitle != ''">
and t2.vendor_name like concat('%', #{processTitle}, '%')
</if>
<if test="initiator != null and initiator != ''">
and btc.apply_user_name like concat('%', #{initiator}, '%')
</if>
<if test="approveStatus != null and approveStatus != ''">
and t1.approve_status = #{approveStatus}
</if>
<if test="approveType != null and approveType != '' and approveType != 'payment_approval'">
and t1.id is null
</if>
union all
/* 应付退款审批 */
select
t1.id,
t1.payment_bill_code as process_no,
t2.vendor_name as process_title,
'payment_refund_approval' as approve_type,
t1.total_price_with_tax as total_amount,
t1.approve_status,
btc.apply_user_name as initiator,
btc.apply_time as start_time,
bt.task_id,
bt.business_key,
bt.process_key,
bt.approve_user
from oms_payment_bill as t1
left join oms_vendor_info t2 on t1.vendor_code = t2.vendor_code
left join (
select
business_key,
apply_user_name,
apply_time,
process_key,
approve_user,
row_number() over (partition by business_key order by apply_time desc) as row_num
from bu_todo_completed
where task_name = '商务'
and process_key in ('finance_refund')
) as btc on t1.payment_bill_code = btc.business_key and btc.row_num = 1
left join (
select
task_id,
business_key,
process_key,
approve_user,
row_number() over (partition by business_key order by id desc) as row_num
from bu_todo
where process_key in ('finance_refund')
<if test="approveUser != null and approveUser != &quot;1&quot;">
and approve_user = #{approveUser}
</if>
) as bt on t1.payment_bill_code = bt.business_key and bt.row_num = 1
where ifnull(t1.approve_status, 0) != 0
and payment_bill_type in ('REFUND')
<if test="approveUser != null and approveUser != &quot;1&quot;">
and exists(
select 1 from bu_todo_completed as btc
where btc.process_key in ('finance_refund')
and t1.payment_bill_code = btc.business_key
and btc.approve_user = #{approveUser}
)
</if>
<if test="processNo != null and processNo != ''">
and t1.payment_bill_code like concat('%', #{processNo}, '%')
</if>
<if test="processTitle != null and processTitle != ''">
and t2.vendor_name like concat('%', #{processTitle}, '%')
</if>
<if test="initiator != null and initiator != ''">
and btc.apply_user_name like concat('%', #{initiator}, '%')
</if>
<if test="approveStatus != null and approveStatus != ''">
and t1.approve_status = #{approveStatus}
</if>
<if test="approveType != null and approveType != '' and approveType != 'payment_refund_approval'">
and t1.id is null
</if>
union all
/* 收票审批 */
select
t1.id,
t1.ticket_bill_code as process_no,
t2.vendor_name as process_title,
'ticket_approval' as approve_type,
t1.total_price_with_tax as total_amount,
t1.approve_status,
btc.apply_user_name as initiator,
btc.apply_time as start_time,
bt.task_id,
bt.business_key,
bt.process_key,
bt.approve_user
from oms_ticket_bill as t1
left join oms_vendor_info t2 on t1.vendor_code = t2.vendor_code
left join (
select
business_key,
apply_user_name,
apply_time,
process_key,
approve_user,
row_number() over (partition by business_key order by apply_time desc) as row_num
from bu_todo_completed
where task_name = '商务'
and process_key in ('fianance_ticket')
) as btc on t1.ticket_bill_code = btc.business_key and btc.row_num = 1
left join (
select
task_id,
business_key,
process_key,
approve_user,
row_number() over (partition by business_key order by id desc) as row_num
from bu_todo
where process_key in ('fianance_ticket')
<if test="approveUser != null and approveUser != &quot;1&quot;">
and approve_user = #{approveUser}
</if>
) as bt on t1.ticket_bill_code = bt.business_key and bt.row_num = 1
where ifnull(t1.approve_status, 0) != 0
and ticket_bill_type in ('FROM_PAYABLE','PRE_PAYMENT')
<if test="approveUser != null and approveUser != &quot;1&quot;">
and exists(
select 1 from bu_todo_completed as btc
where btc.process_key in ('fianance_ticket')
and t1.ticket_bill_code = btc.business_key
and btc.approve_user = #{approveUser}
)
</if>
<if test="processNo != null and processNo != ''">
and t1.ticket_bill_code like concat('%', #{processNo}, '%')
</if>
<if test="processTitle != null and processTitle != ''">
and t2.vendor_name like concat('%', #{processTitle}, '%')
</if>
<if test="initiator != null and initiator != ''">
and btc.apply_user_name like concat('%', #{initiator}, '%')
</if>
<if test="approveStatus != null and approveStatus != ''">
and t1.approve_status = #{approveStatus}
</if>
<if test="approveType != null and approveType != '' and approveType != 'ticket_approval'">
and t1.id is null
</if>
union all
/* 收票红冲审批 */
select
t1.id,
t1.ticket_bill_code as process_no,
t2.vendor_name as process_title,
'ticket_refund_approval' as approve_type,
t1.total_price_with_tax as total_amount,
t1.approve_status,
btc.apply_user_name as initiator,
btc.apply_time as start_time,
bt.task_id,
bt.business_key,
bt.process_key,
bt.approve_user
from oms_ticket_bill as t1
left join oms_vendor_info t2 on t1.vendor_code = t2.vendor_code
left join (
select
business_key,
apply_user_name,
apply_time,
process_key,
approve_user,
row_number() over (partition by business_key order by apply_time desc) as row_num
from bu_todo_completed
where task_name = '商务'
and process_key in ('finance_ticket_refound')
) as btc on t1.ticket_bill_code = btc.business_key and btc.row_num = 1
left join (
select
task_id,
business_key,
process_key,
approve_user,
row_number() over (partition by business_key order by id desc) as row_num
from bu_todo
where process_key in ('finance_ticket_refound')
<if test="approveUser != null and approveUser != &quot;1&quot;">
and approve_user = #{approveUser}
</if>
) as bt on t1.ticket_bill_code = bt.business_key and bt.row_num = 1
where ifnull(t1.approve_status, 0) != 0
and ticket_bill_type in ('RED_RUSH')
<if test="approveUser != null and approveUser != &quot;1&quot;">
and exists(
select 1 from bu_todo_completed as btc
where btc.process_key in ('finance_ticket_refound')
and t1.ticket_bill_code = btc.business_key
and btc.approve_user = #{approveUser}
)
</if>
<if test="processNo != null and processNo != ''">
and t1.ticket_bill_code like concat('%', #{processNo}, '%')
</if>
<if test="processTitle != null and processTitle != ''">
and t2.vendor_name like concat('%', #{processTitle}, '%')
</if>
<if test="initiator != null and initiator != ''">
and btc.apply_user_name like concat('%', #{initiator}, '%')
</if>
<if test="approveStatus != null and approveStatus != ''">
and t1.approve_status = #{approveStatus}
</if>
<if test="approveType != null and approveType != '' and approveType != 'ticket_refund_approval'">
and t1.id is null
</if>
union all
/* 收款审批 */
select
t1.id,
t1.receipt_bill_code as process_no,
t2.partner_name as process_title,
'receipt_approval' as approve_type,
t1.total_price_with_tax as total_amount,
t1.approve_status,
btc.apply_user_name as initiator,
btc.apply_time as start_time,
bt.task_id,
bt.business_key,
bt.process_key,
bt.approve_user
from oms_receipt_bill as t1
left join partner_info t2 on t1.partner_code = t2.partner_code
left join (
select
business_key,
apply_user_name,
apply_time,
process_key,
approve_user,
row_number() over (partition by business_key order by apply_time desc) as row_num
from bu_todo_completed
where task_name = '商务'
and process_key in ('finance_receipt_approve')
) as btc on t1.receipt_bill_code = btc.business_key and btc.row_num = 1
left join (
select
task_id,
business_key,
process_key,
approve_user,
row_number() over (partition by business_key order by id desc) as row_num
from bu_todo
where process_key in ('finance_receipt_approve')
<if test="approveUser != null and approveUser != &quot;1&quot;">
and approve_user = #{approveUser}
</if>
) as bt on t1.receipt_bill_code = bt.business_key and bt.row_num = 1
where ifnull(t1.approve_status, 0) != 0
and receipt_bill_type in ('FROM_RECEIVABLE','PRE_RECEIPT')
<if test="approveUser != null and approveUser != &quot;1&quot;">
and exists(
select 1 from bu_todo_completed as btc
where btc.process_key in ('finance_receipt_approve')
and t1.receipt_bill_code = btc.business_key
and btc.approve_user = #{approveUser}
)
</if>
<if test="processNo != null and processNo != ''">
and t1.receipt_bill_code like concat('%', #{processNo}, '%')
</if>
<if test="processTitle != null and processTitle != ''">
and t2.partner_name like concat('%', #{processTitle}, '%')
</if>
<if test="initiator != null and initiator != ''">
and btc.apply_user_name like concat('%', #{initiator}, '%')
</if>
<if test="approveStatus != null and approveStatus != ''">
and t1.approve_status = #{approveStatus}
</if>
<if test="approveType != null and approveType != '' and approveType != 'receipt_approval'">
and t1.id is null
</if>
union all
/* 应收退款审批 */
select
t1.id,
t1.receipt_bill_code as process_no,
t2.partner_name as process_title,
'receipt_refund_approval' as approve_type,
t1.total_price_with_tax as total_amount,
t1.approve_status,
btc.apply_user_name as initiator,
btc.apply_time as start_time,
bt.task_id,
bt.business_key,
bt.process_key,
bt.approve_user
from oms_receipt_bill as t1
left join partner_info t2 on t1.partner_code = t2.partner_code
left join (
select
business_key,
apply_user_name,
apply_time,
process_key,
approve_user,
row_number() over (partition by business_key order by apply_time desc) as row_num
from bu_todo_completed
where task_name = '商务'
and process_key in ('finance_receipt_refound')
) as btc on t1.receipt_bill_code = btc.business_key and btc.row_num = 1
left join (
select
task_id,
business_key,
process_key,
approve_user,
row_number() over (partition by business_key order by id desc) as row_num
from bu_todo
where process_key in ('finance_receipt_refound')
<if test="approveUser != null and approveUser != &quot;1&quot;">
and approve_user = #{approveUser}
</if>
) as bt on t1.receipt_bill_code = bt.business_key and bt.row_num = 1
where ifnull(t1.approve_status, 0) != 0
and receipt_bill_type in ('REFUND')
<if test="approveUser != null and approveUser != &quot;1&quot;">
and exists(
select 1 from bu_todo_completed as btc
where btc.process_key in ('finance_receipt_refound')
and t1.receipt_bill_code = btc.business_key
and btc.approve_user = #{approveUser}
)
</if>
<if test="processNo != null and processNo != ''">
and t1.receipt_bill_code like concat('%', #{processNo}, '%')
</if>
<if test="processTitle != null and processTitle != ''">
and t2.partner_name like concat('%', #{processTitle}, '%')
</if>
<if test="initiator != null and initiator != ''">
and btc.apply_user_name like concat('%', #{initiator}, '%')
</if>
<if test="approveStatus != null and approveStatus != ''">
and t1.approve_status = #{approveStatus}
</if>
<if test="approveType != null and approveType != '' and approveType != 'receipt_refund_approval'">
and t1.id is null
</if>
union all
/* 开票审批 */
select
t1.id,
t1.invoice_bill_code as process_no,
t2.partner_name as process_title,
'invoice_approval' as approve_type,
t1.total_price_with_tax as total_amount,
t1.approve_status,
btc.apply_user_name as initiator,
btc.apply_time as start_time,
bt.task_id,
bt.business_key,
bt.process_key,
bt.approve_user
from oms_invoice_bill as t1
left join partner_info t2 on t1.partner_code = t2.partner_code
left join (
select
business_key,
apply_user_name,
apply_time,
process_key,
approve_user,
row_number() over (partition by business_key order by apply_time desc) as row_num
from bu_todo_completed
where task_name = '商务'
and process_key in ('finance_invoice_approve')
) as btc on t1.invoice_bill_code = btc.business_key and btc.row_num = 1
left join (
select
task_id,
business_key,
process_key,
approve_user,
row_number() over (partition by business_key order by id desc) as row_num
from bu_todo
where process_key in ('finance_invoice_approve')
<if test="approveUser != null and approveUser != &quot;1&quot;">
and approve_user = #{approveUser}
</if>
) as bt on t1.invoice_bill_code = bt.business_key and bt.row_num = 1
where ifnull(t1.approve_status, 0) != 0
and invoice_bill_type in ('FROM_RECEIVABLE','PRE_INVOICE')
<if test="approveUser != null and approveUser != &quot;1&quot;">
and exists(
select 1 from bu_todo_completed as btc
where btc.process_key in ('finance_invoice_approve')
and t1.invoice_bill_code = btc.business_key
and btc.approve_user = #{approveUser}
)
</if>
<if test="processNo != null and processNo != ''">
and t1.invoice_bill_code like concat('%', #{processNo}, '%')
</if>
<if test="processTitle != null and processTitle != ''">
and t2.partner_name like concat('%', #{processTitle}, '%')
</if>
<if test="initiator != null and initiator != ''">
and btc.apply_user_name like concat('%', #{initiator}, '%')
</if>
<if test="approveStatus != null and approveStatus != ''">
and t1.approve_status = #{approveStatus}
</if>
<if test="approveType != null and approveType != '' and approveType != 'invoice_approval'">
and t1.id is null
</if>
union all
/* 应收红冲审批 */
select
t1.id,
t1.invoice_bill_code as process_no,
t2.partner_name as process_title,
'invoice_refund_approval' as approve_type,
t1.total_price_with_tax as total_amount,
t1.approve_status,
btc.apply_user_name as initiator,
btc.apply_time as start_time,
bt.task_id,
bt.business_key,
bt.process_key,
bt.approve_user
from oms_invoice_bill as t1
left join partner_info t2 on t1.partner_code = t2.partner_code
left join (
select
business_key,
apply_user_name,
apply_time,
process_key,
approve_user,
row_number() over (partition by business_key order by apply_time desc) as row_num
from bu_todo_completed
where task_name = '商务'
and process_key in ('finance_invoice_refound')
) as btc on t1.invoice_bill_code = btc.business_key and btc.row_num = 1
left join (
select
task_id,
business_key,
process_key,
approve_user,
row_number() over (partition by business_key order by id desc) as row_num
from bu_todo
where process_key in ('finance_invoice_refound')
<if test="approveUser != null and approveUser != &quot;1&quot;">
and approve_user = #{approveUser}
</if>
) as bt on t1.invoice_bill_code = bt.business_key and bt.row_num = 1
where ifnull(t1.approve_status, 0) != 0
and invoice_bill_type in ('RED_RUSH')
<if test="approveUser != null and approveUser != &quot;1&quot;">
and exists(
select 1 from bu_todo_completed as btc
where btc.process_key in ('finance_invoice_refound')
and t1.invoice_bill_code = btc.business_key
and btc.approve_user = #{approveUser}
)
</if>
<if test="processNo != null and processNo != ''">
and t1.invoice_bill_code like concat('%', #{processNo}, '%')
</if>
<if test="processTitle != null and processTitle != ''">
and t2.partner_name like concat('%', #{processTitle}, '%')
</if>
<if test="initiator != null and initiator != ''">
and btc.apply_user_name like concat('%', #{initiator}, '%')
</if>
<if test="approveStatus != null and approveStatus != ''">
and t1.approve_status = #{approveStatus}
</if>
<if test="approveType != null and approveType != '' and approveType != 'invoice_refund_approval'">
and t1.id is null
</if>
</select>
<select id="selectApprovalTaskCount" resultType="java.util.HashMap">
select
sum(total) as allCount,
sum(pending_count) as pendingCount,
sum(approved_count) as approvedCount,
sum(returned_count) as returnedCount
from (
/* 订单审批统计 */
select
count(1) as total,
sum(if(order_status = 1, 1, 0)) as pending_count,
sum(if(order_status = 2, 1, 0)) as approved_count,
sum(if(order_status = 3, 1, 0)) as returned_count
from project_order_info as t1
where ifnull(order_status, 0) != 0
<if test="approveUser != null and approveUser != &quot;1&quot;">
and exists(
select 1 from bu_todo_completed as btc
where btc.process_key in ('order_approve_online', 'order_approve_offline')
and t1.order_code = btc.business_key
and btc.approve_user = #{approveUser}
)
</if>
union all
/* 采购审批统计 */
select
count(1) as total,
sum(if(approve_status = 1, 1, 0)) as pending_count,
sum(if(approve_status = 2, 1, 0)) as approved_count,
sum(if(approve_status = 3, 1, 0)) as returned_count
from oms_purchase_order as t1
where ifnull(approve_status, 0) != 0
<if test="approveUser != null and approveUser != &quot;1&quot;">
and exists(
select 1 from bu_todo_completed as btc
where btc.process_key in ('purchase_order_online')
and t1.purchase_no = btc.business_key
and btc.approve_user = #{approveUser}
)
</if>
union all
/* 付款审批统计 */
select
count(1) as total,
sum(if(approve_status = 1, 1, 0)) as pending_count,
sum(if(approve_status = 2, 1, 0)) as approved_count,
sum(if(approve_status = 3, 1, 0)) as returned_count
from oms_payment_bill as t1
where ifnull(approve_status, 0) != 0
and payment_bill_type in ('FROM_PAYABLE','PRE_PAYMENT')
<if test="approveUser != null and approveUser != &quot;1&quot;">
and exists(
select 1 from bu_todo_completed as btc
where btc.process_key in ('finance_payment')
and t1.payment_bill_code = btc.business_key
and btc.approve_user = #{approveUser}
)
</if>
union all
/* 应付退款审批统计 */
select
count(1) as total,
sum(if(approve_status = 1, 1, 0)) as pending_count,
sum(if(approve_status = 2, 1, 0)) as approved_count,
sum(if(approve_status = 3, 1, 0)) as returned_count
from oms_payment_bill as t1
where ifnull(approve_status, 0) != 0
and payment_bill_type in ('REFUND')
<if test="approveUser != null and approveUser != &quot;1&quot;">
and exists(
select 1 from bu_todo_completed as btc
where btc.process_key in ('finance_refund')
and t1.payment_bill_code = btc.business_key
and btc.approve_user = #{approveUser}
)
</if>
union all
/* 收票审批统计 */
select
count(1) as total,
sum(if(approve_status = 1, 1, 0)) as pending_count,
sum(if(approve_status = 2, 1, 0)) as approved_count,
sum(if(approve_status = 3, 1, 0)) as returned_count
from oms_ticket_bill as t1
where ifnull(approve_status, 0) != 0
and ticket_bill_type in ('FROM_PAYABLE','PRE_PAYMENT')
<if test="approveUser != null and approveUser != &quot;1&quot;">
and exists(
select 1 from bu_todo_completed as btc
where btc.process_key in ('fianance_ticket')
and t1.ticket_bill_code = btc.business_key
and btc.approve_user = #{approveUser}
)
</if>
union all
/* 收票红冲审批统计 */
select
count(1) as total,
sum(if(approve_status = 1, 1, 0)) as pending_count,
sum(if(approve_status = 2, 1, 0)) as approved_count,
sum(if(approve_status = 3, 1, 0)) as returned_count
from oms_ticket_bill as t1
where ifnull(approve_status, 0) != 0
and ticket_bill_type in ('RED_RUSH')
<if test="approveUser != null and approveUser != &quot;1&quot;">
and exists(
select 1 from bu_todo_completed as btc
where btc.process_key in ('finance_ticket_refound')
and t1.ticket_bill_code = btc.business_key
and btc.approve_user = #{approveUser}
)
</if>
union all
/* 收款审批统计 */
select
count(1) as total,
sum(if(approve_status = 1, 1, 0)) as pending_count,
sum(if(approve_status = 2, 1, 0)) as approved_count,
sum(if(approve_status = 3, 1, 0)) as returned_count
from oms_receipt_bill as t1
where ifnull(approve_status, 0) != 0
and receipt_bill_type in ('FROM_RECEIVABLE','PRE_RECEIPT')
<if test="approveUser != null and approveUser != &quot;1&quot;">
and exists(
select 1 from bu_todo_completed as btc
where btc.process_key in ('finance_receipt_approve')
and t1.receipt_bill_code = btc.business_key
and btc.approve_user = #{approveUser}
)
</if>
union all
/* 应收退款审批统计 */
select
count(1) as total,
sum(if(approve_status = 1, 1, 0)) as pending_count,
sum(if(approve_status = 2, 1, 0)) as approved_count,
sum(if(approve_status = 3, 1, 0)) as returned_count
from oms_receipt_bill as t1
where ifnull(approve_status, 0) != 0
and receipt_bill_type in ('REFUND')
<if test="approveUser != null and approveUser != &quot;1&quot;">
and exists(
select 1 from bu_todo_completed as btc
where btc.process_key in ('finance_receipt_refound')
and t1.receipt_bill_code = btc.business_key
and btc.approve_user = #{approveUser}
)
</if>
union all
/* 开票审批统计 */
select
count(1) as total,
sum(if(approve_status = 1, 1, 0)) as pending_count,
sum(if(approve_status = 2, 1, 0)) as approved_count,
sum(if(approve_status = 3, 1, 0)) as returned_count
from oms_invoice_bill as t1
where ifnull(approve_status, 0) != 0
and invoice_bill_type in ('FROM_RECEIVABLE','PRE_INVOICE')
<if test="approveUser != null and approveUser != &quot;1&quot;">
and exists(
select 1 from bu_todo_completed as btc
where btc.process_key in ('finance_invoice_approve')
and t1.invoice_bill_code = btc.business_key
and btc.approve_user = #{approveUser}
)
</if>
union all
/* 应收红冲审批统计 */
select
count(1) as total,
sum(if(approve_status = 1, 1, 0)) as pending_count,
sum(if(approve_status = 2, 1, 0)) as approved_count,
sum(if(approve_status = 3, 1, 0)) as returned_count
from oms_invoice_bill as t1
where ifnull(approve_status, 0) != 0
and invoice_bill_type in ('RED_RUSH')
<if test="approveUser != null and approveUser != &quot;1&quot;">
and exists(
select 1 from bu_todo_completed as btc
where btc.process_key in ('finance_invoice_refound')
and t1.invoice_bill_code = btc.business_key
and btc.approve_user = #{approveUser}
)
</if>
) as t
</select>
</mapper>