You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cinnamon-ui-v2/main_vm/build/resources/main/mapper/test/StatisticsDashboard_SQL.xml

229 lines
5.9 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTO Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.icomsys.main_vm.db.mybatis.mapper.StatisticsDashboardMapper">
<select id="selectStatCallInfo" resultType="java.util.HashMap">
/* StatisticsDashboardMapper.selectStatCallInfo */
<![CDATA[
SELECT
b.callInitDate AS callInitDateB
, a.*
FROM
(
SELECT
DATE_FORMAT(Z.CALL_INIT_DATE, '%Y-%m-%d') AS callInitDate
, Z.TOKEN
, Z.OPR_MNG_CODE
, Z.IN_CHANNEL_TYPE
, Z.CALL_END_CONVERSION
FROM TB_CALL_INFO Z
WHERE Z.CALL_INIT_DATE > DATE_ADD(CURDATE(), INTERVAL -6 DAY) AND Z.CALL_INIT_DATE < DATE_ADD(CURDATE(), INTERVAL 1 DAY)
AND Z.IN_CHANNEL_TYPE = 'VOICE'
]]>
<if test="oprMngCode != null and oprMngCode != ''">
<choose>
<when test="oprMngCode == 'all'">
<![CDATA[
AND Z.OPR_MNG_CODE IN
]]>
<foreach item="item" index="index" collection="oprMngCodeList" open="(" separator="," close=")">
#{item}
</foreach>
</when>
<otherwise>
<![CDATA[
AND Z.OPR_MNG_CODE = #{oprMngCode}
]]>
</otherwise>
</choose>
</if>
<![CDATA[
) a
RIGHT JOIN
(
SELECT
@N := @N +1 AS n
, DATE_FORMAT( DATE_ADD( DATE_ADD(CURDATE(), INTERVAL -6 DAY) , INTERVAL @N -1 DAY),'%Y-%m-%d') AS callInitDate
FROM (TB_CALL_INFO), (SELECT @N:=0 FROM DUAL ) a
LIMIT 7
) b ON a.callInitDate = b.callInitDate
ORDER BY b.callInitDate ASC
]]>
</select>
<select id="selectStatIntent" resultType="java.util.HashMap">
/* StatisticsDashboardMapper.selectStatIntent */
<![CDATA[
SELECT
b.callInitDate AS callInitDateB
, a.*
FROM
(
SELECT
DATE_FORMAT(Y.CALL_INIT_DATE, '%Y-%m-%d') AS callInitDate
, Z.*
FROM TB_CALL_USER_LOG Z
INNER JOIN TB_CALL_INFO Y
ON Y.TOKEN = Z.TOKEN
WHERE Z.USER_TEXT != ''
AND Z.INTENT_RESULT_CODE IS NOT NULL
AND Y.CALL_INIT_DATE > DATE_ADD(CURDATE(), INTERVAL -6 DAY) AND Y.CALL_INIT_DATE < DATE_ADD(CURDATE(), INTERVAL 1 DAY)
AND Y.IN_CHANNEL_TYPE = 'VOICE'
]]>
<if test="oprMngCode != null and oprMngCode != ''">
<choose>
<when test="oprMngCode == 'all'">
<![CDATA[
AND Z.OPR_MNG_CODE IN
]]>
<foreach item="item" index="index" collection="oprMngCodeList" open="(" separator="," close=")">
#{item}
</foreach>
</when>
<otherwise>
<![CDATA[
AND Z.OPR_MNG_CODE = #{oprMngCode}
]]>
</otherwise>
</choose>
</if>
<![CDATA[
) a
RIGHT JOIN
(
SELECT
@N := @N +1 AS n
, DATE_FORMAT( DATE_ADD( DATE_ADD(CURDATE(), INTERVAL -6 DAY) , INTERVAL @N -1 DAY),'%Y-%m-%d') AS callInitDate
FROM (TB_CALL_INFO), (SELECT @N:=0 FROM DUAL ) a
LIMIT 7
) b ON a.callInitDate = b.callInitDate
ORDER BY b.callInitDate ASC
]]>
</select>
<select id="selectStatScenario" resultType="java.util.HashMap">
/* StatisticsDashboardMapper.selectStatScenario */
<![CDATA[
SELECT
b.callInitDate AS callInitDateB
, a.*
FROM
(
SELECT
DATE_FORMAT(Y.CALL_INIT_DATE, '%Y-%m-%d') AS callInitDate
, Z.*
FROM TB_SCENARIO_BREAK_NODE Z
INNER JOIN TB_CALL_INFO Y
ON Y.TOKEN = Z.TOKEN
WHERE Y.CALL_INIT_DATE > DATE_ADD(CURDATE(), INTERVAL -6 DAY) AND Y.CALL_INIT_DATE < DATE_ADD(CURDATE(), INTERVAL 1 DAY)
AND Y.IN_CHANNEL_TYPE = 'VOICE'
]]>
<if test="oprMngCode != null and oprMngCode != ''">
<choose>
<when test="oprMngCode == 'all'">
<![CDATA[
AND Z.OPR_MNG_CODE IN
]]>
<foreach item="item" index="index" collection="oprMngCodeList" open="(" separator="," close=")">
#{item}
</foreach>
</when>
<otherwise>
<![CDATA[
AND Z.OPR_MNG_CODE = #{oprMngCode}
]]>
</otherwise>
</choose>
</if>
<![CDATA[
) a
RIGHT JOIN
(
SELECT
@N := @N +1 AS n
, DATE_FORMAT( DATE_ADD( DATE_ADD(CURDATE(), INTERVAL -6 DAY) , INTERVAL @N -1 DAY),'%Y-%m-%d') AS callInitDate
FROM (TB_CALL_INFO), (SELECT @N:=0 FROM DUAL ) a
LIMIT 7
) b ON a.callInitDate = b.callInitDate
ORDER BY b.callInitDate ASC
]]>
</select>
<select id="selectCallCntByToday" resultType="java.util.HashMap">
<![CDATA[
SELECT
b.callInitDate AS callInitDate
, IFNULL(a.totCnt, 0) AS totCnt
, b.n
FROM
(
SELECT
DATE_FORMAT(Z.CALL_INIT_DATE, '%H:00') AS callInitDate
, COUNT(*) AS totCnt
FROM TB_CALL_INFO Z
WHERE Z.CALL_INIT_DATE > CURDATE() AND Z.CALL_INIT_DATE < DATE_ADD(CURDATE(), INTERVAL 1 DAY)
AND Z.IN_CHANNEL_TYPE = 'VOICE'
]]>
<if test="oprMngCode != null and oprMngCode != ''">
<choose>
<when test="oprMngCode == 'all'">
<![CDATA[
AND Z.OPR_MNG_CODE IN
]]>
<foreach item="item" index="index" collection="oprMngCodeList" open="(" separator="," close=")">
#{item}
</foreach>
</when>
<otherwise>
<![CDATA[
AND Z.OPR_MNG_CODE = #{oprMngCode}
]]>
</otherwise>
</choose>
</if>
<![CDATA[
GROUP BY DATE_FORMAT(Z.CALL_INIT_DATE, '%H')
) a
RIGHT JOIN
(
SELECT
@N := @N +1 AS n
, DATE_FORMAT( DATE_ADD( DATE_FORMAT(CURDATE(), '%Y-%m-%d 00:00') , INTERVAL @N -1 HOUR),'%H:00') AS callInitDate
FROM (TB_CALL_INFO), (SELECT @N:=0 FROM DUAL ) a
LIMIT 24
) b ON a.callInitDate = b.callInitDate
WHERE n-1 <= DATE_FORMAT(CURTIME(), '%H')
ORDER BY b.callInitDate ASC
]]>
</select>
<select id="selectCurCallCnt" resultType="int">
<![CDATA[
SELECT
COUNT(*)
FROM TB_CALL_INFO
WHERE CALL_INIT_DATE > CURDATE() AND CALL_INIT_DATE < DATE_ADD(CURDATE(), INTERVAL 1 DAY)
AND IN_CHANNEL_TYPE = 'VOICE'
AND CALL_END_TYPE = 'ING'
]]>
<if test="oprMngCode != null and oprMngCode != ''">
<choose>
<when test="oprMngCode == 'all'">
<![CDATA[
AND OPR_MNG_CODE IN
]]>
<foreach item="item" index="index" collection="oprMngCodeList" open="(" separator="," close=")">
#{item}
</foreach>
</when>
<otherwise>
<![CDATA[
AND OPR_MNG_CODE = #{oprMngCode}
]]>
</otherwise>
</choose>
</if>
</select>
</mapper>