wecom-dashboards/excel-handle/src/main/resources/mapper/wecom/CustomerExportDataMapper.xml

754 lines
31 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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.excel.wecom.mapper.CustomerExportDataMapper">
<select id="countCustomerExportDataVOList" resultType="int">
SELECT count(1)
FROM customer_export_data
<where>
corp_id = #{corpId}
<if test="startDate != null">
AND add_time &gt;= #{startDate}
</if>
<if test="endDate != null">
AND add_time &lt;= #{endDate}
</if>
<if test="customerName != null">
AND customer_name like concat('%',#{customerName},'%')
</if>
</where>
</select>
<select id="getDistinctDate" resultType="java.util.Date">
select distinct add_date from customer_export_data where corp_id = #{corpId} order by add_date
</select>
<!-- 查询客户导出数据VO列表(用于导出) -->
<select id="selectCustomerExportDataVOList" resultType="com.ruoyi.excel.wecom.vo.CustomerExportDataVO">
SELECT
customer_name as customerName,
description,
add_user_name as addUserName,
add_user_account as addUserAccount,
add_user_department as addUserDepartment,
add_time as addTime,
add_date as addDate,
source,
mobile,
company,
email,
address,
position,
phone,
tag_group1 as tagGroup1,
tag_group2 as tagGroup2,
tag_group3 as tagGroup3,
tag_group4 as tagGroup4,
tag_group5 as tagGroup5,
tag_group6 as tagGroup6,
tag_group7 as tagGroup7,
tag_group8 as tagGroup8,
tag_group9 as tagGroup9,
tag_group10 as tagGroup10,
tag_group11 as tagGroup11,
tag_group12 as tagGroup12,
tag_group13 as tagGroup13,
tag_group14 as tagGroup14,
tag_group15 as tagGroup15,
tag_group16 as tagGroup16,
tag_group17 as tagGroup17,
tag_group18 as tagGroup18
FROM customer_export_data
<where>
corp_id = #{corpId}
<if test="startDate != null">
AND add_time &gt;= #{startDate}
</if>
<if test="endDate != null">
AND add_time &lt;= #{endDate}
</if>
<if test="customerName != null">
AND customer_name like concat('%',#{customerName},'%')
</if>
</where>
ORDER BY add_time DESC
</select>
<select id="selectCustomerExportDataList" resultType="com.ruoyi.excel.wecom.domain.CustomerExportData">
SELECT
customer_name as customerName,
description,
add_user_name as addUserName,
add_user_account as addUserAccount,
add_user_department as addUserDepartment,
add_time as addTime,
add_date as addDate,
source,
mobile,
company,
email,
address,
position,
phone,
tag_group1 as tagGroup1,
tag_group2 as tagGroup2,
tag_group3 as tagGroup3,
tag_group4 as tagGroup4,
tag_group5 as tagGroup5,
tag_group6 as tagGroup6,
tag_group7 as tagGroup7,
tag_group8 as tagGroup8,
tag_group9 as tagGroup9,
tag_group10 as tagGroup10,
tag_group11 as tagGroup11,
tag_group12 as tagGroup12,
tag_group13 as tagGroup13,
tag_group14 as tagGroup14,
tag_group15 as tagGroup15,
tag_group16 as tagGroup16,
tag_group17 as tagGroup17,
tag_group18 as tagGroup18
FROM customer_export_data
<where>
corp_id = #{corpId}
<if test="startDate != null">
AND add_time &gt;= #{startDate}
</if>
<if test="endDate != null">
AND add_time &lt;= #{endDate}
</if>
<if test="customerName != null">
AND customer_name like concat('%',#{customerName},'%')
</if>
</where>
ORDER BY add_time DESC
</select>
<!-- 根据客户唯一标识查询客户数据(客户名称+添加人账号+添加时间) -->
<select id="selectByUniqueKey" resultType="com.ruoyi.excel.wecom.domain.CustomerExportData">
SELECT *
FROM customer_export_data
WHERE
corp_id = #{corpId}
and
customer_user_id = #{customerUserId}
AND add_user_account = #{addUserAccount}
AND add_time = #{addTime}
LIMIT 1
</select>
<select id="selectByFinishDate" resultType="java.lang.Long">
select count(1) from customer_export_data
WHERE
corp_id = #{corpId} and finish_date = #{date} and tag_group7 in
<foreach collection="successFlags" item="successFlag" open="(" separator="," close=")">
#{successFlag}
</foreach>
<if test="attr != null and attr != '' and attr == 'tag_group1'">
AND tag_group1 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group2'">
AND tag_group2 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group3'">
AND tag_group3 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group4'">
AND tag_group4 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group5'">
AND tag_group5 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group6'">
AND tag_group6 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group7'">
AND tag_group7 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group8'">
AND tag_group8 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group9'">
AND tag_group9 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group10'">
AND tag_group10 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group11'">
AND tag_group11 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group12'">
AND tag_group12 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group13'">
AND tag_group13 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group14'">
AND tag_group14 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group15'">
AND tag_group15 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group16'">
AND tag_group16 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group17'">
AND tag_group17 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group18'">
AND tag_group18 is not null
</if>
</select>
<!-- 查询及时单数量(根据成交日期和订单状态) -->
<select id="selectTimelyOrderCount" resultType="java.lang.Long">
select count(1) from customer_export_data
WHERE
corp_id = #{corpId} and finish_date = #{date}
and tag_group7 in
<foreach collection="successFlags" item="successFlag" open="(" separator="," close=")">
#{successFlag}
</foreach>
<if test="attr != null and attr != '' and attr == 'tag_group1'">
AND tag_group1 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group2'">
AND tag_group2 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group3'">
AND tag_group3 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group10'">
AND tag_group10 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group11'">
AND tag_group11 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group12'">
AND tag_group12 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group13'">
AND tag_group13 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group14'">
AND tag_group14 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group16'">
AND tag_group16 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group17'">
AND tag_group17 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group18'">
AND tag_group18 is not null
</if>
</select>
<!-- 查询非及时单数量(根据成交日期和订单状态) -->
<select id="selectNonTimelyOrderCount" resultType="java.lang.Long">
select count(1) from customer_export_data
WHERE
corp_id = #{corpId} and finish_date = #{date}
and tag_group7 in
<foreach collection="successFlags" item="successFlag" open="(" separator="," close=")">
#{successFlag}
</foreach>
<if test="attr != null and attr != '' and attr == 'tag_group1'">
AND tag_group1 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group2'">
AND tag_group2 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group3'">
AND tag_group3 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group10'">
AND tag_group10 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group11'">
AND tag_group11 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group12'">
AND tag_group12 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group13'">
AND tag_group13 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group14'">
AND tag_group14 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group16'">
AND tag_group16 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group17'">
AND tag_group17 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group18'">
AND tag_group18 is not null
</if>
</select>
<!-- 查询成单数(根据成交日期、组字段和标签值) -->
<select id="selectByFinishDateAndTag" resultType="java.lang.Long">
select count(1) from customer_export_data
WHERE
corp_id = #{corpId} and finish_date = #{date} and tag_group7 in
<foreach collection="successFlags" item="successFlag" open="(" separator="," close=")">
#{successFlag}
</foreach>
<if test="attr != null and attr != '' and attr == 'tag_group1'">
AND tag_group1 = #{tagValue}
</if>
<if test="attr != null and attr != '' and attr == 'tag_group2'">
AND tag_group2 = #{tagValue}
</if>
<if test="attr != null and attr != '' and attr == 'tag_group3'">
AND tag_group3 = #{tagValue}
</if>
<if test="attr != null and attr != '' and attr == 'tag_group10'">
AND tag_group10 = #{tagValue}
</if>
<if test="attr != null and attr != '' and attr == 'tag_group11'">
AND tag_group11 = #{tagValue}
</if>
<if test="attr != null and attr != '' and attr == 'tag_group12'">
AND tag_group12 = #{tagValue}
</if>
<if test="attr != null and attr != '' and attr == 'tag_group13'">
AND tag_group13 = #{tagValue}
</if>
<if test="attr != null and attr != '' and attr == 'tag_group14'">
AND tag_group14 = #{tagValue}
</if>
<if test="attr != null and attr != '' and attr == 'tag_group16'">
AND tag_group16 = #{tagValue}
</if>
<if test="attr != null and attr != '' and attr == 'tag_group17'">
AND tag_group17 = #{tagValue}
</if>
<if test="attr != null and attr != '' and attr == 'tag_group18'">
AND tag_group18 = #{tagValue}
</if>
</select>
<!-- 查询及时单数量(根据成交日期、订单状态和标签值) -->
<select id="selectTimelyOrderCountByTag" resultType="java.lang.Long">
select count(1) from customer_export_data
WHERE
corp_id = #{corpId} and finish_date = #{date}
and tag_group7 in
<foreach collection="successFlags" item="successFlag" open="(" separator="," close=")">
#{successFlag}
</foreach>
<if test="attr != null and attr != '' and attr == 'tag_group1'">
AND tag_group1 = #{tagValue}
</if>
<if test="attr != null and attr != '' and attr == 'tag_group2'">
AND tag_group2 = #{tagValue}
</if>
<if test="attr != null and attr != '' and attr == 'tag_group3'">
AND tag_group3 = #{tagValue}
</if>
<if test="attr != null and attr != '' and attr == 'tag_group10'">
AND tag_group10 = #{tagValue}
</if>
<if test="attr != null and attr != '' and attr == 'tag_group11'">
AND tag_group11 = #{tagValue}
</if>
<if test="attr != null and attr != '' and attr == 'tag_group12'">
AND tag_group12 = #{tagValue}
</if>
<if test="attr != null and attr != '' and attr == 'tag_group13'">
AND tag_group13 = #{tagValue}
</if>
<if test="attr != null and attr != '' and attr == 'tag_group14'">
AND tag_group14 = #{tagValue}
</if>
<if test="attr != null and attr != '' and attr == 'tag_group16'">
AND tag_group16 = #{tagValue}
</if>
<if test="attr != null and attr != '' and attr == 'tag_group17'">
AND tag_group17 = #{tagValue}
</if>
<if test="attr != null and attr != '' and attr == 'tag_group18'">
AND tag_group18 = #{tagValue}
</if>
</select>
<!-- 查询非及时单数量(根据成交日期、订单状态和标签值) -->
<select id="selectNonTimelyOrderCountByTag" resultType="java.lang.Long">
select count(1) from customer_export_data
WHERE
corp_id = #{corpId} and finish_date = #{date}
and tag_group7 in
<foreach collection="successFlags" item="successFlag" open="(" separator="," close=")">
#{successFlag}
</foreach>
<if test="attr != null and attr != '' and attr == 'tag_group1'">
AND tag_group1 = #{tagValue}
</if>
<if test="attr != null and attr != '' and attr == 'tag_group2'">
AND tag_group2 = #{tagValue}
</if>
<if test="attr != null and attr != '' and attr == 'tag_group3'">
AND tag_group3 = #{tagValue}
</if>
<if test="attr != null and attr != '' and attr == 'tag_group10'">
AND tag_group10 = #{tagValue}
</if>
<if test="attr != null and attr != '' and attr == 'tag_group11'">
AND tag_group11 = #{tagValue}
</if>
<if test="attr != null and attr != '' and attr == 'tag_group12'">
AND tag_group12 = #{tagValue}
</if>
<if test="attr != null and attr != '' and attr == 'tag_group13'">
AND tag_group13 = #{tagValue}
</if>
<if test="attr != null and attr != '' and attr == 'tag_group14'">
AND tag_group14 = #{tagValue}
</if>
<if test="attr != null and attr != '' and attr == 'tag_group16'">
AND tag_group16 = #{tagValue}
</if>
<if test="attr != null and attr != '' and attr == 'tag_group17'">
AND tag_group17 = #{tagValue}
</if>
<if test="attr != null and attr != '' and attr == 'tag_group18'">
AND tag_group18 = #{tagValue}
</if>
</select>
<!-- 分页查询客户导出数据VO列表(用于异步导出) -->
<select id="selectCustomerExportDataVOListByPage" resultType="com.ruoyi.excel.wecom.vo.CustomerExportDataVO">
SELECT
customer_name as customerName,
description,
add_user_name as addUserName,
add_user_account as addUserAccount,
add_user_department as addUserDepartment,
add_time as addTime,
add_date as addDate,
source,
mobile,
company,
email,
address,
position,
phone,
tag_group1 as tagGroup1,
tag_group2 as tagGroup2,
tag_group3 as tagGroup3,
tag_group4 as tagGroup4,
tag_group5 as tagGroup5,
tag_group6 as tagGroup6,
tag_group7 as tagGroup7,
tag_group8 as tagGroup8,
tag_group9 as tagGroup9,
tag_group10 as tagGroup10,
tag_group11 as tagGroup11,
tag_group12 as tagGroup12,
tag_group13 as tagGroup13,
tag_group14 as tagGroup14,
tag_group15 as tagGroup15,
tag_group16 as tagGroup16,
tag_group17 as tagGroup17,
tag_group18 as tagGroup18
FROM customer_export_data
<where>
corp_id = #{corpId}
<if test="startDate != null">
AND add_time &gt;= #{startDate}
</if>
<if test="endDate != null">
AND add_time &lt;= #{endDate}
</if>
<if test="customerName != null">
AND customer_name like concat('%',#{customerName},'%')
</if>
</where>
ORDER BY add_time DESC
LIMIT #{limit} OFFSET #{offset}
</select>
<!-- 按日期范围查询成单数根据finish_date -->
<select id="selectOrderCountByFinishDateRange" resultType="java.lang.Long">
select count(1) from customer_export_data
WHERE
corp_id = #{corpId} and tag_group7 in
<foreach collection="successFlags" item="successFlag" open="(" separator="," close=")">
#{successFlag}
</foreach>
<if test="startDate != null">
AND finish_date &gt;= #{startDate}
</if>
<if test="endDate != null">
AND finish_date &lt;= #{endDate}
</if>
<if test="attr != null and attr != '' and attr == 'tag_group1'">
AND tag_group1 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group2'">
AND tag_group2 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group3'">
AND tag_group3 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group10'">
AND tag_group10 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group11'">
AND tag_group11 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group12'">
AND tag_group12 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group13'">
AND tag_group13 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group14'">
AND tag_group14 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group16'">
AND tag_group16 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group17'">
AND tag_group17 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group18'">
AND tag_group18 is not null
</if>
</select>
<!-- 按日期范围查询及时单数量根据finish_date -->
<select id="selectTimelyOrderCountByDateRange" resultType="java.lang.Long">
select count(1) from customer_export_data
WHERE
corp_id = #{corpId}
and tag_group7 in
<foreach collection="successFlags" item="successFlag" open="(" separator="," close=")">
#{successFlag}
</foreach>
<if test="startDate != null">
AND finish_date &gt;= #{startDate}
</if>
<if test="endDate != null">
AND finish_date &lt;= #{endDate}
</if>
<if test="attr != null and attr != '' and attr == 'tag_group1'">
AND tag_group1 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group2'">
AND tag_group2 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group3'">
AND tag_group3 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group10'">
AND tag_group10 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group11'">
AND tag_group11 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group12'">
AND tag_group12 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group13'">
AND tag_group13 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group14'">
AND tag_group14 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group16'">
AND tag_group16 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group17'">
AND tag_group17 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group18'">
AND tag_group18 is not null
</if>
</select>
<!-- 按日期范围查询非及时单数量根据finish_date -->
<select id="selectNonTimelyOrderCountByDateRange" resultType="java.lang.Long">
select count(1) from customer_export_data
WHERE
corp_id = #{corpId}
and tag_group7 in
<foreach collection="successFlags" item="successFlag" open="(" separator="," close=")">
#{successFlag}
</foreach>
<if test="startDate != null">
AND finish_date &gt;= #{startDate}
</if>
<if test="endDate != null">
AND finish_date &lt;= #{endDate}
</if>
<if test="attr != null and attr != '' and attr == 'tag_group1'">
AND tag_group1 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group2'">
AND tag_group2 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group3'">
AND tag_group3 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group10'">
AND tag_group10 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group11'">
AND tag_group11 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group12'">
AND tag_group12 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group13'">
AND tag_group13 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group14'">
AND tag_group14 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group16'">
AND tag_group16 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group17'">
AND tag_group17 is not null
</if>
<if test="attr != null and attr != '' and attr == 'tag_group18'">
AND tag_group18 is not null
</if>
</select>
<!-- 批量查询所有组的成单数根据finish_date- 一次查询返回所有组的数据 -->
<select id="selectOrderCountBatchByFinishDateRange" resultType="java.util.Map">
SELECT
SUM(CASE WHEN tag_group1 IS NOT NULL THEN 1 ELSE 0 END) as tag_group1,
SUM(CASE WHEN tag_group2 IS NOT NULL THEN 1 ELSE 0 END) as tag_group2,
SUM(CASE WHEN tag_group3 IS NOT NULL THEN 1 ELSE 0 END) as tag_group3,
SUM(CASE WHEN tag_group10 IS NOT NULL THEN 1 ELSE 0 END) as tag_group10,
SUM(CASE WHEN tag_group11 IS NOT NULL THEN 1 ELSE 0 END) as tag_group11,
SUM(CASE WHEN tag_group12 IS NOT NULL THEN 1 ELSE 0 END) as tag_group12,
SUM(CASE WHEN tag_group13 IS NOT NULL THEN 1 ELSE 0 END) as tag_group13,
SUM(CASE WHEN tag_group14 IS NOT NULL THEN 1 ELSE 0 END) as tag_group14,
SUM(CASE WHEN tag_group16 IS NOT NULL THEN 1 ELSE 0 END) as tag_group16,
SUM(CASE WHEN tag_group17 IS NOT NULL THEN 1 ELSE 0 END) as tag_group17,
SUM(CASE WHEN tag_group18 IS NOT NULL THEN 1 ELSE 0 END) as tag_group18
FROM customer_export_data
WHERE corp_id = #{corpId} and tag_group7 in
<foreach collection="successFlags" item="successFlag" open="(" separator="," close=")">
#{successFlag}
</foreach>
<if test="startDate != null">
AND finish_date &gt;= #{startDate}
</if>
<if test="endDate != null">
AND finish_date &lt;= #{endDate}
</if>
</select>
<!-- 批量查询所有组的及时单数量根据finish_date -->
<select id="selectTimelyOrderCountBatchByDateRange" resultType="java.util.Map">
SELECT
SUM(CASE WHEN tag_group1 IS NOT NULL THEN 1 ELSE 0 END) as tag_group1,
SUM(CASE WHEN tag_group2 IS NOT NULL THEN 1 ELSE 0 END) as tag_group2,
SUM(CASE WHEN tag_group3 IS NOT NULL THEN 1 ELSE 0 END) as tag_group3,
SUM(CASE WHEN tag_group10 IS NOT NULL THEN 1 ELSE 0 END) as tag_group10,
SUM(CASE WHEN tag_group11 IS NOT NULL THEN 1 ELSE 0 END) as tag_group11,
SUM(CASE WHEN tag_group12 IS NOT NULL THEN 1 ELSE 0 END) as tag_group12,
SUM(CASE WHEN tag_group13 IS NOT NULL THEN 1 ELSE 0 END) as tag_group13,
SUM(CASE WHEN tag_group14 IS NOT NULL THEN 1 ELSE 0 END) as tag_group14,
SUM(CASE WHEN tag_group16 IS NOT NULL THEN 1 ELSE 0 END) as tag_group16,
SUM(CASE WHEN tag_group17 IS NOT NULL THEN 1 ELSE 0 END) as tag_group17,
SUM(CASE WHEN tag_group18 IS NOT NULL THEN 1 ELSE 0 END) as tag_group18
FROM customer_export_data
WHERE corp_id = #{corpId}
and tag_group7 in
<foreach collection="successFlags" item="successFlag" open="(" separator="," close=")">
#{successFlag}
</foreach>
<if test="startDate != null">
AND finish_date &gt;= #{startDate}
</if>
<if test="endDate != null">
AND finish_date &lt;= #{endDate}
</if>
</select>
<!-- 批量查询所有组的非及时单数量根据finish_date -->
<select id="selectNonTimelyOrderCountBatchByDateRange" resultType="java.util.Map">
SELECT
SUM(CASE WHEN tag_group1 IS NOT NULL THEN 1 ELSE 0 END) as tag_group1,
SUM(CASE WHEN tag_group2 IS NOT NULL THEN 1 ELSE 0 END) as tag_group2,
SUM(CASE WHEN tag_group3 IS NOT NULL THEN 1 ELSE 0 END) as tag_group3,
SUM(CASE WHEN tag_group10 IS NOT NULL THEN 1 ELSE 0 END) as tag_group10,
SUM(CASE WHEN tag_group11 IS NOT NULL THEN 1 ELSE 0 END) as tag_group11,
SUM(CASE WHEN tag_group12 IS NOT NULL THEN 1 ELSE 0 END) as tag_group12,
SUM(CASE WHEN tag_group13 IS NOT NULL THEN 1 ELSE 0 END) as tag_group13,
SUM(CASE WHEN tag_group14 IS NOT NULL THEN 1 ELSE 0 END) as tag_group14,
SUM(CASE WHEN tag_group16 IS NOT NULL THEN 1 ELSE 0 END) as tag_group16,
SUM(CASE WHEN tag_group17 IS NOT NULL THEN 1 ELSE 0 END) as tag_group17,
SUM(CASE WHEN tag_group18 IS NOT NULL THEN 1 ELSE 0 END) as tag_group18
FROM customer_export_data
WHERE corp_id = #{corpId}
and tag_group7 in
<foreach collection="successFlags" item="successFlag" open="(" separator="," close=")">
#{successFlag}
</foreach>
<if test="startDate != null">
AND finish_date &gt;= #{startDate}
</if>
<if test="endDate != null">
AND finish_date &lt;= #{endDate}
</if>
</select>
<!-- 查询未分组记录的成单数(所有组字段都为空) -->
<select id="selectUngroupedFinishCount" resultType="java.lang.Long">
SELECT COUNT(*)
FROM customer_export_data
WHERE corp_id = #{corpId}
AND finish_date = #{date}
AND tag_group7 IN
<foreach collection="successFlags" item="successFlag" open="(" separator="," close=")">
#{successFlag}
</foreach>
AND tag_group1 IS NULL AND tag_group2 IS NULL AND tag_group3 IS NULL
AND tag_group10 IS NULL AND tag_group11 IS NULL AND tag_group12 IS NULL
AND tag_group13 IS NULL AND tag_group14 IS NULL AND tag_group16 IS NULL
AND tag_group17 IS NULL AND tag_group18 IS NULL
</select>
<!-- 查询未分组记录的及时单数量 -->
<select id="selectUngroupedTimelyOrderCount" resultType="java.lang.Long">
SELECT COUNT(*)
FROM customer_export_data
WHERE corp_id = #{corpId}
AND finish_date = #{date}
AND tag_group7 IN
<foreach collection="successFlags" item="successFlag" open="(" separator="," close=")">
#{successFlag}
</foreach>
AND tag_group1 IS NULL AND tag_group2 IS NULL AND tag_group3 IS NULL
AND tag_group10 IS NULL AND tag_group11 IS NULL AND tag_group12 IS NULL
AND tag_group13 IS NULL AND tag_group14 IS NULL AND tag_group16 IS NULL
AND tag_group17 IS NULL AND tag_group18 IS NULL
</select>
<!-- 查询未分组记录的非及时单数量 -->
<select id="selectUngroupedNonTimelyOrderCount" resultType="java.lang.Long">
SELECT COUNT(*)
FROM customer_export_data
WHERE corp_id = #{corpId}
AND finish_date = #{date}
AND tag_group7 IN
<foreach collection="successFlags" item="successFlag" open="(" separator="," close=")">
#{successFlag}
</foreach>
AND tag_group1 IS NULL AND tag_group2 IS NULL AND tag_group3 IS NULL
AND tag_group10 IS NULL AND tag_group11 IS NULL AND tag_group12 IS NULL
AND tag_group13 IS NULL AND tag_group14 IS NULL AND tag_group16 IS NULL
AND tag_group17 IS NULL AND tag_group18 IS NULL
</select>
</mapper>