No Description

ReportMapper.xml 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="api.mapper.report.ReportMapper">
  6. <resultMap type="api.entity.view.report.Report" id="SysReportResult">
  7. <result property="DATE" column="DATE" />
  8. <result property="number" column="number" />
  9. </resultMap>
  10. <resultMap type="api.entity.view.report.HourReport" id="SysReportHourResult">
  11. <result property="DATE" column="DATE" />
  12. <result property="number" column="number" />
  13. </resultMap>
  14. <resultMap type="api.entity.view.report.OnlineServiceReport" id="SysOnlineServiceReport">
  15. <result property="userCode" column="userCode" />
  16. <result property="userName" column="userName" />
  17. <result property="sessionVolume" column="sessionVolume" />
  18. <result property="message" column="message" />
  19. <result property="workOrderNum" column="workOrderNum" />
  20. </resultMap>
  21. <resultMap type="api.entity.view.report.WorkOrderTypeReport" id="SysWorkOrderTypeReport">
  22. <result property="type_name" column="type_name" />
  23. <result property="type_count" column="type_count" />
  24. <result property="processed" column="processed" />
  25. <result property="completed" column="completed" />
  26. </resultMap>
  27. <resultMap type="api.entity.view.report.RecordReport" id="SysRecordReport">
  28. <result property="userCode" column="userCode" />
  29. <result property="userName" column="userName" />
  30. <result property="ldCount" column="ldCount" />
  31. <result property="noAnswer" column="noAnswer" />
  32. <result property="satisfied" column="satisfied" />
  33. <result property="satisfactory" column="satisfactory" />
  34. <result property="allAnswerTime" column="allAnswerTime" />
  35. <result property="noSatisfied" column="noSatisfied" />
  36. </resultMap>
  37. <resultMap type="api.entity.view.report.CompleteView" id="CompleteView">
  38. <result property="Name" column="Name" />
  39. <result property="number" column="number" />
  40. </resultMap>
  41. <resultMap type="api.entity.view.report.TrafficView" id="TrafficViewResult">
  42. <result property="Name" column="Name" />
  43. <result property="incoming" column="incoming" />
  44. <result property="answer" column="answer" />
  45. <result property="noAnswer" column="noAnswer" />
  46. </resultMap>
  47. <resultMap type="api.entity.view.report.SatisfactionView" id="SatisfactionViewResult">
  48. <result property="basically" column="basically" />
  49. <result property="satisfied" column="satisfied" />
  50. <result property="dissatisfied" column="dissatisfied" />
  51. </resultMap>
  52. <resultMap type="api.entity.view.report.TrafficMeasurement" id="TrafficMeasurementResult">
  53. <result property="incoming" column="incoming" />
  54. <result property="answer" column="answer" />
  55. <result property="avgWait" column="avgWait" />
  56. <result property="avgAnswer" column="avgAnswer" />
  57. </resultMap>
  58. <resultMap type="api.entity.view.report.RecordDateView" id="RecordDateViewResult">
  59. <result property="incoming" column="incoming" />
  60. <result property="exhalation" column="exhalation" />
  61. </resultMap>
  62. <resultMap type="api.entity.view.report.RegionOrder" id="RegionOrderResult">
  63. <result property="region" column="region" />
  64. <result property="name" column="name" />
  65. <result property="number" column="number" />
  66. <result property="callNumber" column="callNumber" />
  67. <result property="visitNumber" column="visitNumber" />
  68. <result property="mydRate" column="mydRate" />
  69. </resultMap>
  70. <resultMap type="api.entity.view.report.TelephoneBriefing" id="TelephoneBriefingResult">
  71. <result property="totalCalls" column="total_calls" />
  72. <result property="inboundTotal" column="inbound_total" />
  73. <result property="inboundConnected" column="inbound_connected" />
  74. <result property="inboundNotConnected" column="inbound_not_connected" />
  75. <result property="outboundTotal" column="outbound_total" />
  76. <result property="outboundConnected" column="outbound_connected" />
  77. <result property="outboundNotConnected" column="outbound_not_connected" />
  78. <result property="callDuration" column="call_duration" />
  79. <result property="basically" column="basically" />
  80. <result property="satisfied" column="satisfied" />
  81. <result property="dissatisfied" column="dissatisfied" />
  82. </resultMap>
  83. <select id="selectCountDayRecord" parameterType="Date" resultMap="SysReportResult">
  84. SELECT DATE(begin_time) AS DATE,COUNT(*) number FROM `call_record`
  85. WHERE `begin_time`>=#{beginTime} and `begin_time` <![CDATA[<=]]> #{endTime}
  86. GROUP BY DATE
  87. ORDER BY DATE;
  88. </select>
  89. <select id="selectCountHourRecord" parameterType="Date" resultMap="SysReportHourResult">
  90. SELECT DATE, COUNT(*) AS number
  91. FROM
  92. (
  93. SELECT
  94. DATE_FORMAT(
  95. CONCAT( DATE( begin_time ), ' ', HOUR ( begin_time ), ':', FLOOR( MINUTE ( begin_time ) / 30 ) * 30 ),
  96. '%Y-%m-%d %H:%i'
  97. ) AS DATE
  98. FROM call_record
  99. WHERE `begin_time`>=#{beginTime} and `begin_time` <![CDATA[<=]]> #{endTime}
  100. ) a
  101. GROUP BY DATE
  102. ORDER BY DATE;
  103. </select>
  104. <select id="selectCountDayWorkOrder" parameterType="Date" resultMap="SysReportResult">
  105. SELECT DATE(`createtime`) AS DATE,COUNT(*) number FROM `wo_workorderbase`
  106. WHERE `createtime`>=#{beginTime} AND `isdelete`=0 AND `createtime`<![CDATA[<=]]> #{endTime}
  107. GROUP BY DATE
  108. ORDER BY DATE;
  109. </select>
  110. <select id="selectCountHourWorkOrder" parameterType="Date" resultMap="SysReportHourResult">
  111. SELECT DATE, COUNT(*) AS number
  112. FROM
  113. (
  114. SELECT
  115. DATE_FORMAT(
  116. CONCAT( DATE( createtime ), ' ', HOUR ( createtime ), ':', FLOOR( MINUTE ( createtime ) / 30 ) * 30 ),
  117. '%Y-%m-%d %H:%i'
  118. ) AS DATE
  119. FROM wo_workorderbase
  120. WHERE `createtime`>=#{beginTime} AND `isdelete`=0 AND `createtime`<![CDATA[<=]]> #{endTime}
  121. ) a
  122. GROUP BY DATE
  123. ORDER BY DATE;
  124. </select>
  125. <select id="selectCountDayMessage" parameterType="Date" resultMap="SysReportResult">
  126. SELECT DATE(`create_time`) AS DATE,COUNT(*) number FROM `online_message`
  127. WHERE `create_time`>=#{beginTime} AND `create_time`<![CDATA[<=]]> #{endTime}
  128. GROUP BY DATE,`kh_user`
  129. ORDER BY DATE;
  130. </select>
  131. <select id="selectCountHourMessage" parameterType="Date" resultMap="SysReportHourResult">
  132. SELECT DATE, COUNT(*) AS number
  133. FROM
  134. (
  135. SELECT
  136. DATE_FORMAT(
  137. CONCAT( DATE( create_time ), ' ', HOUR ( create_time ), ':', FLOOR( MINUTE ( create_time ) / 30 ) * 30 ),
  138. '%Y-%m-%d %H:%i'
  139. ) AS DATE,`kh_user`
  140. FROM online_message
  141. WHERE `create_time`>=#{beginTime} AND `create_time`<![CDATA[<=]]> #{endTime}
  142. ) a
  143. GROUP BY DATE,`kh_user`
  144. ORDER BY DATE;
  145. </select>
  146. <select id="selectOnlineServiceReport" parameterType="api.entity.view.report.ScreenReport" resultMap="SysOnlineServiceReport">
  147. SELECT `kf_user` userCode, (SELECT `nick_name` FROM `sys_user` WHERE `user_name`=a.`kf_user` LIMIT 1) userName ,
  148. (SELECT COUNT(DISTINCT COALESCE(`kh_user`,'NULL')) FROM `online_message` WHERE `kf_user` =a.`kf_user`
  149. <if test="startTime != null and startTime !=''">
  150. AND UNIX_TIMESTAMP(`create_time`)>=UNIX_TIMESTAMP(#{startTime})
  151. </if>
  152. <if test="endTime != null and endTime !=''">
  153. AND UNIX_TIMESTAMP(`create_time`)<![CDATA[<=]]> UNIX_TIMESTAMP(#{endTime})
  154. </if>
  155. )
  156. sessionVolume,
  157. (SELECT COUNT(1) FROM `online_message` WHERE `kf_user` =a.`kf_user`
  158. <if test="startTime != null and startTime !=''">
  159. AND UNIX_TIMESTAMP(`create_time`)>=UNIX_TIMESTAMP(#{startTime} )
  160. </if>
  161. <if test="endTime != null and endTime !=''">
  162. AND UNIX_TIMESTAMP(`create_time`)<![CDATA[<=]]> UNIX_TIMESTAMP(#{endTime})
  163. </if>
  164. ) message,
  165. (SELECT COUNT(*) FROM `wo_workorderbase` WHERE `createuser` =a.`kf_user`
  166. <if test="startTime != null and startTime !=''">
  167. AND UNIX_TIMESTAMP(`createtime`)>=UNIX_TIMESTAMP(#{startTime} )
  168. </if>
  169. <if test="endTime != null and endTime !='' ">
  170. AND UNIX_TIMESTAMP(`createtime`) <![CDATA[<=]]> UNIX_TIMESTAMP(#{endTime})
  171. </if>
  172. )workOrderNum FROM `online_link` a
  173. where 1=1
  174. <if test="startTime != null and startTime !=''">
  175. AND UNIX_TIMESTAMP(`last_time`)>=UNIX_TIMESTAMP(#{startTime} )
  176. </if>
  177. <if test="endTime != null and endTime !=''">
  178. AND UNIX_TIMESTAMP(`last_time`) <![CDATA[<=]]> UNIX_TIMESTAMP(#{endTime})
  179. </if>
  180. <if test="usercode != null and usercode != ''">
  181. AND `kf_user`= #{usercode}
  182. </if>
  183. GROUP BY `kf_user`
  184. </select>
  185. <select id="selectWorkOrderTypeReport" parameterType="api.entity.view.report.ScreenReport" resultMap="SysWorkOrderTypeReport">
  186. SELECT (SELECT `type_name` FROM `workorder_type` WHERE `id` =a.workordercate) type_name,ancestor
  187. ,COUNT(1) type_count ,
  188. SUM(CASE WHEN workorderstate>3000 THEN 1 ELSE 0 END ) processed,
  189. SUM(CASE WHEN workorderstate=6000 THEN 1 ELSE 0 END ) completed
  190. FROM `wo_workorderbase` a
  191. WHERE `isdelete`=0
  192. <if test="startTime != null and startTime !=''">
  193. AND UNIX_TIMESTAMP(`createtime`)>=UNIX_TIMESTAMP(#{startTime} )
  194. </if>
  195. <if test="endTime != null and endTime !=''">
  196. AND UNIX_TIMESTAMP(`createtime`) <![CDATA[<=]]> UNIX_TIMESTAMP(#{endTime})
  197. </if>
  198. <if test="workordertype >0 ">
  199. AND `workordercate`= #{workordertype}
  200. </if>
  201. <if test="ancestor >0 ">
  202. AND `ancestor` LIKE CONCAT('%,', #{ancestor}, ',%')
  203. </if>
  204. GROUP BY workordercate,ancestor
  205. </select>
  206. <select id="selectRecordReport" parameterType="api.entity.view.report.ScreenReport" resultMap="SysRecordReport">
  207. SELECT `callee_agent` userCode, (SELECT `nick_name` FROM `sys_user` WHERE `user_name` COLLATE utf8mb4_general_ci=a.`callee_agent`
  208. LIMIT 1 ) userName ,
  209. COUNT(1) ldCount,
  210. SUM(CASE `is_answer` WHEN 1 THEN 1 ELSE 0 END ) answer,
  211. SUM(CASE `is_answer` WHEN 0 THEN 1 ELSE 0 END ) noAnswer,
  212. SUM(CASE `is_answer` WHEN 1 THEN TIMESTAMPDIFF(SECOND, answer_time, hangup_time) ELSE 0 END ) allAnswerTime,
  213. -- SUM(CASE WHEN `myd`>0 and `myd` <![CDATA[<]]> 3 THEN 1 ELSE 0 END ) satisfied,
  214. SUM(CASE WHEN `myd`=1 THEN 1 ELSE 0 END ) satisfied,
  215. SUM(CASE WHEN `myd`=2 THEN 1 ELSE 0 END ) satisfactory,
  216. SUM(CASE WHEN `myd`=3 THEN 1 ELSE 0 END ) noSatisfied
  217. FROM `rep_record` a
  218. WHERE 1=1 AND `callee_agent`!='' AND `callee_agent` IS NOT NULL
  219. AND `call_type`=1
  220. <if test="startTime != null and startTime !=''">
  221. AND UNIX_TIMESTAMP(`create_time`)>=UNIX_TIMESTAMP(#{startTime})
  222. </if>
  223. <if test="endTime != null and endTime !=''">
  224. AND UNIX_TIMESTAMP(`create_time`) <![CDATA[<=]]> UNIX_TIMESTAMP(#{endTime})
  225. </if>
  226. <if test="usercode != null and usercode != ''">
  227. AND `callee_agent`= #{usercode}
  228. </if>
  229. <if test="@api.entity.view.config.GlobalConfig@isNote == 1">
  230. AND (note=1 or (call_type=2 and note is null ))
  231. </if>
  232. GROUP BY `callee_agent`
  233. </select>
  234. <select id="selectBusinessType" parameterType="long" resultMap="CompleteView">
  235. select Name , SUM(number) number from
  236. (select CONCAT(ancestors, ',', id) ancestors,type_name Name from workorder_type where category=0 and parent_id=0 and is_delete=0) a
  237. left join (select COUNT(1) number, CONCAT((select ancestors from workorder_type where id=workordercate ),',',workordercate) ancestors from
  238. wo_workorderbase
  239. where is_delete=0
  240. <if test="time != null and time !='' ">
  241. and YEAR(create_time) = YEAR(CURRENT_DATE)
  242. AND ${time}(create_time) = ${time}(CURRENT_DATE)
  243. </if>
  244. group by ancestors) b on CONCAT(b.ancestors,',') LIKE CONCAT('%', a.ancestors,',' '%')
  245. group by Name
  246. </select>
  247. <select id="selectBusinessAreaType" parameterType="long" resultMap="CompleteView">
  248. WITH RECURSIVE sub_areas AS (
  249. SELECT id FROM sys_area WHERE id = #{area}
  250. UNION ALL
  251. SELECT a.id FROM sys_area a
  252. INNER JOIN sub_areas sa ON a.parent_id = sa.id
  253. )
  254. select Name , SUM(number) number from
  255. (select CONCAT(ancestors, ',', id) ancestors,type_name Name from workorder_type where category=0 and parent_id=0 and is_delete=0) a
  256. left join (select COUNT(1) number, CONCAT((select ancestors from workorder_type where id=workordercate ),',',workordercate) ancestors from
  257. wo_workorderbase o JOIN sub_areas sa ON o.area = sa.id
  258. where isdelete=0
  259. <if test="time != null and time !='' ">
  260. and YEAR(createtime) = YEAR(CURRENT_DATE)
  261. AND ${time}(createtime) = ${time}(CURRENT_DATE)
  262. </if>
  263. group by ancestors) b on CONCAT(b.ancestors,',') LIKE CONCAT('%', a.ancestors,',' '%')
  264. group by Name
  265. </select>
  266. <select id="selectDealingWithTrends" parameterType="Date" resultMap="SysReportHourResult">
  267. SELECT
  268. DATE_FORMAT( create_time, '%Y-%m-%d' ) as DATE,
  269. count(1) number
  270. FROM wo_workorderbase
  271. group by DATE
  272. ORDER BY DATE;
  273. </select>
  274. <select id="selectTraffic" parameterType="Date" resultMap="TrafficViewResult">
  275. select
  276. HOUR ( create_time ) DATE ,
  277. count(call_type=1 or null ) incoming,
  278. count(call_type=1 and is_answer=1 or null ) answer,
  279. count(call_type=1 and is_answer=0 or null ) noAnswer
  280. from rep_record
  281. where DATE_FORMAT(create_time, '%Y-%m-%d') = DATE_FORMAT(NOW(), '%Y-%m-%d')
  282. <if test="@api.entity.view.config.GlobalConfig@isNote == 1">
  283. AND (note=1 or (call_type=2 and note is null ))
  284. </if>
  285. GROUP BY DATE
  286. ORDER BY DATE;
  287. </select>
  288. <select id="selectSatisfaction" parameterType="Date" resultMap="SatisfactionViewResult">
  289. select
  290. count(myd=2 or null ) basically,
  291. count(myd=1 or null ) satisfied,
  292. count(myd=3 or null ) dissatisfied
  293. from rep_record
  294. where 1=1
  295. <if test="@api.entity.view.config.GlobalConfig@isNote == 1">
  296. AND (note=1 or (call_type=2 and note is null ))
  297. </if>
  298. </select>
  299. <select id="selectTrafficMeasurement" parameterType="Date" resultMap="TrafficMeasurementResult">
  300. select
  301. count(call_type=1 or null ) incoming,
  302. count(call_type=1 and is_answer=1 or null ) answer,
  303. AVG(TIMESTAMPDIFF(SECOND, wait_time, answer_time) and is_answer=1 AND call_type=1 ) avgWait,
  304. AVG(TIMESTAMPDIFF(SECOND, answer_time, hangup_time) and is_answer=1 AND call_type=1 ) avgAnswer
  305. from rep_record
  306. WHERE `create_time`>=#{beginTime} AND `create_time`<![CDATA[<=]]> #{endTime}
  307. <if test="@api.entity.view.config.GlobalConfig@isNote == 1">
  308. AND (note=1 or (call_type=2 and note is null ))
  309. </if>
  310. </select>
  311. <select id="selectConnection" parameterType="api.entity.view.report.ScreenConnection" resultMap="SysReportHourResult">
  312. select
  313. count(1) number,
  314. DATE_FORMAT( `create_time`, #{grouping} ) as DATE
  315. from rep_record
  316. WHERE `create_time`>=#{startTime} AND `create_time`<![CDATA[<=]]> #{endTime}
  317. and call_type=1
  318. <if test="@api.entity.view.config.GlobalConfig@isNote == 1">
  319. AND (note=1 or (call_type=2 and note is null ))
  320. </if>
  321. <if test="isAnswer >-1 ">
  322. AND `is_answer`= #{isAnswer}
  323. </if>
  324. group by DATE
  325. order by DATE
  326. </select>
  327. <select id="selectRecord" parameterType="String" resultMap="RecordDateViewResult">
  328. select COUNT(call_type=1 or NULL ) incoming,
  329. COUNT(call_type=2 or NULL ) exhalation,
  330. COUNT(1) total
  331. from rep_record where
  332. DATE_FORMAT( `create_time`, '%Y-%m' )= DATE_FORMAT( #{time}, '%Y-%m' )
  333. <if test="@api.entity.view.config.GlobalConfig@isNote == 1">
  334. AND (note=1 or (call_type=2 and note is null ))
  335. </if>
  336. </select>
  337. <select id="selectVisitCount" parameterType="String" resultType="long">
  338. select COUNT(DISTINCT workordercode) number
  339. from wo_visitlog
  340. where
  341. DATE_FORMAT( `createtime`, '%Y-%m' )= DATE_FORMAT( #{time}, '%Y-%m' )
  342. </select>
  343. <select id="selectCallTrends" parameterType="api.entity.view.report.ScreenConnection" resultMap="TrafficViewResult">
  344. select
  345. DATE_FORMAT( `create_time`, #{grouping}) DATE ,
  346. count(call_type=1 or null ) incoming,
  347. count(call_type=1 and is_answer=1 or null ) answer,
  348. count(call_type=1 and is_answer=0 or null ) noAnswer
  349. from rep_record
  350. WHERE `create_time`>=#{startTime} AND `create_time`<![CDATA[<=]]> #{endTime}
  351. and call_type=1
  352. <if test="@api.entity.view.config.GlobalConfig@isNote == 1">
  353. AND (note=1 or (call_type=2 and note is null ))
  354. </if>
  355. group by DATE
  356. order by DATE
  357. </select>
  358. <select id="selectAICount" parameterType="String" resultMap="CompleteView">
  359. select operate_type Name, COUNT(1) number from ai_operation
  360. GROUP BY operate_type
  361. </select>
  362. <select id="selectRegionOrderCount" parameterType="String" resultMap="RegionOrderResult">
  363. WITH RECURSIVE AreaCTE AS (
  364. SELECT
  365. id AS root_id,
  366. id AS child_id,
  367. name AS root_name,
  368. parent_id
  369. FROM sys_area
  370. WHERE type=#{type} and parent_id=#{area}
  371. UNION ALL
  372. SELECT
  373. a.root_id,
  374. s.id AS child_id,
  375. a.root_name,
  376. s.parent_id
  377. FROM sys_area s
  378. INNER JOIN AreaCTE a ON s.parent_id = a.child_id
  379. )
  380. SELECT
  381. a.root_id AS region,
  382. a.root_name AS name,
  383. COUNT(wo.workordercode) AS number,
  384. COUNT(DISTINCT wo.call_id) AS callNumber,
  385. COUNT(DISTINCT lv.workordercode) AS visitNumber,
  386. CONCAT(
  387. COALESCE(
  388. ROUND(
  389. AVG(CASE WHEN lv.myd > 0 AND lv.myd <![CDATA[<]]> 3 THEN 1 ELSE 0 END) * 100,
  390. 2
  391. ),
  392. 0
  393. ),
  394. '%'
  395. ) AS mydRate
  396. FROM AreaCTE a
  397. LEFT JOIN wo_workorderbase wo
  398. ON a.child_id = wo.area
  399. <if test="time != null and time !='' ">
  400. and YEAR(wo.createtime) = YEAR(CURRENT_DATE)
  401. AND ${time}(wo.createtime) = ${time}(CURRENT_DATE)
  402. </if>
  403. LEFT JOIN (
  404. SELECT
  405. v1.workordercode,
  406. v1.myd
  407. FROM wo_visitlog v1
  408. INNER JOIN (
  409. SELECT
  410. workordercode,
  411. MAX(visit_id) AS visit_id
  412. FROM wo_visitlog
  413. GROUP BY workordercode
  414. ) v2
  415. ON v1.workordercode = v2.workordercode
  416. AND v1.visit_id = v2.visit_id
  417. ) lv
  418. ON wo.workordercode = lv.workordercode
  419. GROUP BY a.root_id, a.root_name;
  420. </select>
  421. <select id="selectTelephoneData" parameterType="String" resultMap="RecordDateViewResult">
  422. select count(1) total,
  423. count(note=${note} and call_type = 1 or null ) incoming, count(call_type = 2
  424. or null ) exhalation from rep_record
  425. where 1=1
  426. <if test="time != null and time !='' ">
  427. and YEAR(create_time) = YEAR(CURRENT_DATE)
  428. AND ${time}(create_time) = ${time}(CURRENT_DATE)
  429. </if>
  430. </select>
  431. <select id="selectTelephoneBriefing" parameterType="String" resultMap="TelephoneBriefingResult">
  432. select
  433. count(1) total_calls ,
  434. SUM(CASE WHEN call_type = 1 THEN 1 ELSE 0 END) AS inbound_total,
  435. SUM(CASE WHEN call_type = 1 AND is_answer = 1 THEN 1 ELSE 0 END) AS inbound_connected,
  436. SUM(CASE WHEN call_type = 1 AND is_answer = 0 THEN 1 ELSE 0 END) AS inbound_not_connected,
  437. SUM(CASE WHEN call_type = 2 THEN 1 ELSE 0 END) AS outbound_total,
  438. SUM(CASE WHEN call_type = 2 AND is_answer = 1 THEN 1 ELSE 0 END) AS outbound_connected,
  439. SUM(CASE WHEN call_type = 2 AND is_answer = 0 THEN 1 ELSE 0 END) AS outbound_not_connected,
  440. SUM(CASE WHEN call_type = 1 AND is_answer = 1
  441. THEN TIMESTAMPDIFF(SECOND, answer_time, hangup_time) ELSE 0 END) call_duration,
  442. count(myd=2 or null ) basically,
  443. count(myd=1 or null ) satisfied,
  444. count(myd=3 or null ) dissatisfied
  445. from rep_record
  446. where 1=1
  447. <if test="@api.entity.view.config.GlobalConfig@isNote == 1" >
  448. AND (note=1 or (call_type=2 and note is null ))
  449. </if>
  450. <if test="startTime != null and startTime !=''">
  451. AND UNIX_TIMESTAMP(`create_time`)>=UNIX_TIMESTAMP(#{startTime})
  452. </if>
  453. <if test="endTime != null and endTime !=''">
  454. AND UNIX_TIMESTAMP(`create_time`) <![CDATA[<=]]> UNIX_TIMESTAMP(#{endTime})
  455. </if>
  456. </select>
  457. <select id="selectAreaKeywordCount" parameterType="Long" resultMap="CompleteView">
  458. WITH RECURSIVE sub_areas AS (
  459. SELECT id FROM sys_area WHERE id = #{area}
  460. UNION ALL
  461. SELECT a.id FROM sys_area a
  462. INNER JOIN sub_areas sa ON a.parent_id = sa.id
  463. )
  464. SELECT
  465. keyword_text AS `Name`,
  466. SUM(keyword_count) AS `number`
  467. FROM
  468. wo_workorderbase o
  469. JOIN
  470. rep_translate k ON o.call_id = k.callid
  471. JOIN
  472. JSON_TABLE(
  473. k.translate_json,
  474. '$[*]' COLUMNS (
  475. keyword_text VARCHAR(255) PATH '$.text',
  476. keyword_count INT PATH '$.count'
  477. )
  478. ) AS jt
  479. JOIN sub_areas sa ON o.area = sa.id
  480. WHERE
  481. 1=1
  482. <if test="time != null and time !='' ">
  483. and YEAR(createtime) = YEAR(CURRENT_DATE)
  484. AND ${time}(createtime) = ${time}(CURRENT_DATE)
  485. </if>
  486. GROUP BY
  487. keyword_text
  488. ORDER BY
  489. SUM(keyword_count) DESC
  490. LIMIT 10;
  491. </select>
  492. </mapper>