MobileComplaintMapper.java 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. package com.nokia.tsl_data.dao;
  2. import org.apache.ibatis.annotations.*;
  3. import java.util.List;
  4. import java.util.Map;
  5. @Mapper
  6. public interface MobileComplaintMapper {
  7. /**
  8. * 统计某天入库工单数量
  9. */
  10. @Select("select count(1) from tsl_data.mobile_complaint_day " +
  11. "where month_id = substring(#{day} from 1 for 6) and day_id = substring(#{day} from 7 for 2)")
  12. int selectCompCountForDay(String day);
  13. /**
  14. * 超时工单统计
  15. */
  16. @Select("with t1 as (select compl_area_local, is_timeout from tsl_data.mobile_complaint_day " +
  17. " where month_id = substring(#{day} from 1 for 6) and day_id = substring(#{day} from 7 for 2)), "
  18. +
  19. "t2 as (select '全省' as compl_area_local, count(1) as total_num from t1), " +
  20. "t3 as (select compl_area_local, count(1) as total_num from t1 group by compl_area_local), " +
  21. "t4 as (select * from t2 union select * from t3), " +
  22. "t5 as (select compl_area_local from t1 where is_timeout = '是'), " +
  23. "t7 as (select '全省' as compl_area_local, count(1) as timeout_num from t5), " +
  24. "t8 as (select compl_area_local, count(1) as timeout_num from t5 group by compl_area_local), " +
  25. "t9 as (select * from t7 union select * from t8) " +
  26. "select t4.compl_area_local, t4.total_num, t9.timeout_num, t9.timeout_num / t4.total_num::float8 as timeout_ratio "
  27. +
  28. "from t4, t9 where t4.compl_area_local = t9.compl_area_local")
  29. List<Map<String, Object>> selectTimeoutTsCountForDay(String day);
  30. /**
  31. * 处理时长统计
  32. */
  33. @Select("with t1 as (select compl_area_local, " +
  34. "case when proce_time != '' then (extract('epoch' from to_timestamp( proce_time, 'YYYY-MM-DD HH24:MI:SS'))"
  35. +
  36. " - extract('epoch' from to_timestamp(accept_time, 'YYYY-MM-DD HH24:MI:SS'))) / 3600" +
  37. " when is_online_complete = '是' then 0" +
  38. " else (extract('epoch' from to_timestamp(end_time, 'YYYY-MM-DD HH24:MI:SS'))" +
  39. " - extract('epoch' from to_timestamp(accept_time, 'YYYY-MM-DD HH24:MI:SS'))) / 3600 "
  40. +
  41. " end as duration from tsl_data.mobile_complaint_day " +
  42. "where month_id = substring(#{day} from 1 for 6) and day_id = substring(#{day} from 7 for 2)) "
  43. +
  44. "select compl_area_local, avg(duration)::float8 as avg_duration from t1 group by compl_area_local")
  45. List<Map<String, Object>> selectTsDurationForDay(String day);
  46. /**
  47. * 重复工单
  48. */
  49. @Select("with t1 as (select compl_area_local, busi_no from tsl_data.mobile_complaint_day " +
  50. " where month_id = substring(#{day} from 1 for 6) and day_id = substring(#{day} from 7 for 2)), "
  51. +
  52. "t2 as (select distinct * from t1), " +
  53. "t3 as (select compl_area_local, count(1) as total_num from t1 group by compl_area_local), " +
  54. "t4 as (select compl_area_local, count(1) as distinct_num from t2 group by compl_area_local), "
  55. +
  56. "t5 as (select t3.compl_area_local, t3.total_num, t3.total_num - t4.distinct_num::float8 as repeat_num, "
  57. +
  58. " (t3.total_num - t4.distinct_num) / t3.total_num::float8 as repeat_ratio from T3, t4 " +
  59. " where t3.compl_area_local = t4.compl_area_local) " +
  60. "select '全省' as compl_area_local, sum(total_num) as total_num, sum(repeat_num) as repeat_num, "
  61. +
  62. "sum(repeat_num) / sum(total_num)::float8 as repeat_ratio from t5 union select * from t5 ")
  63. List<Map<String, Object>> selectRepeatTsCountForDay(String day);
  64. /**
  65. * 投诉清单按日按地市计数
  66. */
  67. @Select("select compl_area_local, substring(acct_date from 7 for 2) as day_id, count(1) as num " +
  68. " from tsl_data.mobile_complaint_day where month_id = substring(#{day} from 1 for 6) " +
  69. " and day_id = substring(#{day} from 7 for 2) group by compl_area_local, substring(acct_date from 7 for 2) "
  70. +
  71. " order by compl_area_local, substring(acct_date from 7 for 2)")
  72. List<Map<String, Object>> selectCityTslForMonth(String day);
  73. /**
  74. * 投诉清单全省计数
  75. */
  76. @Select("select substring(acct_date from 7 for 2) as day_id, count(1) as num " +
  77. "from tsl_data.mobile_complaint_day where month_id = substring(#{day} from 1 for 6) " +
  78. "and day_id = substring(#{day} from 7 for 2) group by substring(acct_date from 7 for 2) " +
  79. "order by substring(acct_date from 7 for 2)")
  80. List<Map<String, Object>> selectAllTslForMonth(String day);
  81. /**
  82. * 投诉清单地市总数
  83. */
  84. @Select("select compl_area_local, count(1) as num from tsl_data.mobile_complaint_day " +
  85. "where month_id = substring(#{day} from 1 for 6) and day_id = substring(#{day} from 7 for 2) " +
  86. " group by compl_area_local order by compl_area_local")
  87. List<Map<String, Object>> selectCityAllForMonth(String day);
  88. /**
  89. * 投诉清单按月计算总数
  90. */
  91. @Select("select count(1) as num from tsl_data.mobile_complaint_day hdmc " +
  92. "where month_id = substring(#{day} from 1 for 6) and day_id = substring(#{day} from 7 for 2)")
  93. int selectAllForMonth(String day);
  94. @Delete("delete from tsl_data.mobile_complaint_day where month_id = #{month_id} and day_id = #{day_id} ")
  95. int deleteMobileComplaintForMonthIdAndDayId(@Param("month_id") String monthId, @Param("day_id") String dayId);
  96. /**
  97. * 删除某天的管理端投诉清单
  98. */
  99. default int deleteMobileCompForDay(String day) {
  100. return deleteMobileComplaintForMonthIdAndDayId(day.substring(0, 6), day.substring(6));
  101. }
  102. @Select("select count(1) from tsl_data.mobile_complaint_day where month_id = #{month_id} and day_id = #{day_id} ")
  103. int countForDay(@Param("month_id") String monthId, @Param("day_id") String dayId);
  104. default int countForDay(String day) {
  105. return countForDay(day.substring(0, 6), day.substring(6));
  106. }
  107. // 3G简网投诉情况
  108. // 移网质量>>网络覆盖>>Vo-LTE>>未开通/不支撑Vo-LTE功能
  109. // 移网质量>>网络覆盖>>2/3G网络精简>>2/3G网络精简
  110. // 日定责问题分类 DUTY_REASON_ID_DAY
  111. // 地市按日统计 20240409 新增
  112. @Select("select compl_area_local, substring(acct_date from 7 for 2) as day_id, count(1) as num " +
  113. "from tsl_data.mobile_complaint_day " +
  114. "where month_id = #{month_id} and day_id = #{day_id} " +
  115. "and duty_reason_id_day in ( " +
  116. "'移网质量>>网络覆盖>>Vo-LTE>>未开通/不支撑Vo-LTE功能', " +
  117. "'移网质量>>网络覆盖>>2/3G网络精简>>2/3G网络精简') " +
  118. "group by compl_area_local, substring(acct_date from 7 for 2) " +
  119. "order by compl_area_local, substring(acct_date from 7 for 2)")
  120. List<Map<String, Object>> selectCity3GjwForMonth(@Param("month_id") String monthId,
  121. @Param("day_id") String dayId);
  122. default List<Map<String, Object>> selectCity3GjwForMonth(String day) {
  123. return selectCity3GjwForMonth(day.substring(0, 6), day.substring(6));
  124. }
  125. // 全省按日统计 20240409 新增
  126. @Select("select substring(acct_date from 7 for 2) as day_id, count(1) as num " +
  127. "from tsl_data.mobile_complaint_day " +
  128. "where month_id = #{month_id} and day_id = #{day_id} " +
  129. "and duty_reason_id_day in ( " +
  130. "'移网质量>>网络覆盖>>Vo-LTE>>未开通/不支撑Vo-LTE功能', " +
  131. "'移网质量>>网络覆盖>>2/3G网络精简>>2/3G网络精简') " +
  132. "group by substring(acct_date from 7 for 2) " +
  133. "order by substring(acct_date from 7 for 2)")
  134. List<Map<String, Object>> selectAll3GjwGroupByDayForMonth(@Param("month_id") String monthId,
  135. @Param("day_id") String dayId);
  136. default List<Map<String, Object>> selectAll3GjwGroupByDayForMonth(String day) {
  137. return selectAll3GjwGroupByDayForMonth(day.substring(0, 6), day.substring(6));
  138. }
  139. @Select("select compl_area_local, count(1) as num " +
  140. "from tsl_data.mobile_complaint_day " +
  141. "where month_id = #{month_id} and day_id = #{day_id} " +
  142. "and duty_reason_id_day in ( " +
  143. "'移网质量>>网络覆盖>>Vo-LTE>>未开通/不支撑Vo-LTE功能', " +
  144. "'移网质量>>网络覆盖>>2/3G网络精简>>2/3G网络精简') " +
  145. "group by compl_area_local " +
  146. "order by compl_area_local ")
  147. List<Map<String, Object>> selectCityAll3GjwForMonth(@Param("month_id") String monthId,
  148. @Param("day_id") String dayId);
  149. default List<Map<String, Object>> selectCityAll3GjwForMonth(String day) {
  150. return selectCityAll3GjwForMonth(day.substring(0, 6), day.substring(6));
  151. }
  152. @Select("select count(1) from tsl_data.mobile_complaint_day " +
  153. "where month_id = #{month_id} and day_id = #{day_id} " +
  154. "and duty_reason_id_day in ( " +
  155. "'移网质量>>网络覆盖>>Vo-LTE>>未开通/不支撑Vo-LTE功能', " +
  156. "'移网质量>>网络覆盖>>2/3G网络精简>>2/3G网络精简')")
  157. int selectAll3GjwForMonth(@Param("month_id") String monthId, @Param("day_id") String dayId);
  158. default int selectAll3GjwForMonth(String day) {
  159. return selectAll3GjwForMonth(day.substring(0, 6), day.substring(6));
  160. }
  161. }