ManagementDetailMapper.java 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. package com.nokia.tsl_data.dao;
  2. import java.util.List;
  3. import java.util.Map;
  4. import org.apache.ibatis.annotations.Delete;
  5. import org.apache.ibatis.annotations.Insert;
  6. import org.apache.ibatis.annotations.Mapper;
  7. import org.apache.ibatis.annotations.Param;
  8. import org.apache.ibatis.annotations.Select;
  9. @Mapper
  10. public interface ManagementDetailMapper {
  11. /**
  12. * 投诉清单分日期分地市计数 按账期查询
  13. */
  14. // 20240611 更新,增加类型限制
  15. @Select("select compl_area_local, substring(acct_date from 7 for 2) as day_id, count(1) as num " + //
  16. " from tsl_data.management_detail\r\n" + //
  17. " where stat_day_id = #{day} and origin = 'mobile_complaint_day' " +
  18. " group by compl_area_local, substring(acct_date from 7 for 2)\r\n" + //
  19. " order by compl_area_local, substring(acct_date from 7 for 2)")
  20. List<Map<String, Object>> selectCityTslForMonth(@Param("day") String day);
  21. /**
  22. * 投诉清单全省分日计数 按账期查询
  23. */
  24. @Select("select substring(acct_date from 7 for 2) as day_id, count(1) as num" + //
  25. " from tsl_data.management_detail\r\n" + //
  26. " where stat_day_id = #{day} and origin = 'mobile_complaint_day' " + //
  27. " group by substring(acct_date from 7 for 2)\r\n" + //
  28. " order by substring(acct_date from 7 for 2)")
  29. List<Map<String, Object>> selectAllTslForMonth(@Param("day") String day);
  30. /**
  31. * 投诉清单地市总数 按账期查询
  32. */
  33. @Select("select compl_area_local, count(1) as num " + //
  34. " from tsl_data.management_detail\r\n" + //
  35. " where stat_day_id = #{day} and origin = 'mobile_complaint_day' " + //
  36. " group by compl_area_local\r\n" + //
  37. " order by compl_area_local")
  38. List<Map<String, Object>> selectCityAllForMonth(@Param("day") String day);
  39. /**
  40. * 全省总数 按账期查询
  41. */
  42. @Select("select count(1) as num\r\n" + //
  43. "from tsl_data.management_detail\r\n" + //
  44. "where stat_day_id = #{day} and origin = 'mobile_complaint_day' ")
  45. int selectAllForMonth(@Param("day") String day);
  46. /**
  47. * 从 河北_CEM移网质量投诉明细 mobile_complaint_day 中同步数据
  48. */
  49. @Insert("insert into tsl_data.management_detail (origin, stat_day_id, acct_date, sheet_no," +
  50. " compl_area_local, compl_city_local, busi_no) " +
  51. "select 'mobile_complaint_day' as origin, concat(month_id, day_id) as stat_day_id," +
  52. " acct_date, sheet_no, compl_area_local, gis_city as compl_city_local, busi_no " +
  53. " from tsl_data.mobile_complaint_day mcd \r\n" +
  54. " where month_id = substring(#{day} from 1 for 6) and day_id = substring(#{day} from 7 for 2) ")
  55. int insertFromMobileComplaint(@Param("day") String day);
  56. /**
  57. * 从 河北客户体验管理智能定责投诉明细月累计接口日 complaint_details_fix_ywd_day 同步数据
  58. */
  59. @Insert("insert into tsl_data.management_detail (origin, stat_day_id, acct_date, sheet_no," +
  60. " compl_area_local, compl_city_local, busi_no) " +
  61. "select 'complaint_details_fix_ywd_day' as origin, concat(month_id, day_id) as stat_day_id," +
  62. " concat(month_id1, day_id1) as acct_date, sheet_no, compl_area_local, compl_city_local, busi_no "
  63. + " from tsl_data.complaint_details_fix_ywd_day cdfyd \r\n" +
  64. " where duty_reason_id_day = '业务使用>>基础业务使用>>移网主被叫>>手机无法主被叫'\r\n" +
  65. " and month_id = substring(#{day} from 1 for 6) and day_id = substring(#{day} from 7 for 2) ")
  66. int insertFromComplaintDetailsFixYwd(@Param("day") String day);
  67. /**
  68. * 按照账期统计某个账期的数据量
  69. */
  70. @Select("select count(1) from tsl_data.management_detail where stat_day_id = #{day} ")
  71. int selectCountofStatDay(@Param("day") String day);
  72. @Delete("delete from tsl_data.management_detail where stat_day_id = #{day}")
  73. int deleteForStatDay(@Param("day") String day);
  74. @Select("with t1 as (select compl_area_local, busi_no from tsl_data.management_detail md \n" + //
  75. " where stat_day_id = #{day}), \n" + //
  76. " t2 as (select distinct * from t1), \n" + //
  77. " t3 as (select compl_area_local, count(1) as total_num from t1 group by compl_area_local), \n"
  78. + " t4 as (select compl_area_local, count(1) as distinct_num from t2 group by compl_area_local), \n"
  79. + " t5 as (select t3.compl_area_local, t3.total_num, t3.total_num - t4.distinct_num::float8 as repeat_num, \n"
  80. + " (t3.total_num - t4.distinct_num) / t3.total_num::float8 as repeat_ratio from T3, t4 \n" + //
  81. " where t3.compl_area_local = t4.compl_area_local) \n" + //
  82. " select '全省' as compl_area_local, sum(total_num) as total_num, sum(repeat_num) as repeat_num, \n"
  83. + " sum(repeat_num) / sum(total_num)::float8 as repeat_ratio from t5 union select * from t5 ")
  84. List<Map<String, Object>> selectRepeatTsCountForDay(String day);
  85. /**
  86. * 20241204 修改
  87. * 使用同一个账期的数据,提取重复工单数据
  88. */
  89. @Select("with t1 as (select compl_area_local, busi_no from tsl_data.management_detail md \n" + //
  90. " where stat_day_id = #{statDayId} and acct_date <= #{day} ), \n" + //
  91. " t2 as (select distinct * from t1), \n" + //
  92. " t3 as (select compl_area_local, count(1) as total_num from t1 group by compl_area_local), \n"
  93. + " t4 as (select compl_area_local, count(1) as distinct_num from t2 group by compl_area_local), \n"
  94. + " t5 as (select t3.compl_area_local, t3.total_num, t3.total_num - t4.distinct_num::float8 as repeat_num, \n"
  95. + " (t3.total_num - t4.distinct_num) / t3.total_num::float8 as repeat_ratio from T3, t4 \n" + //
  96. " where t3.compl_area_local = t4.compl_area_local) \n" + //
  97. " select '全省' as compl_area_local, sum(total_num) as total_num, sum(repeat_num) as repeat_num, \n"
  98. + " sum(repeat_num) / sum(total_num)::float8 as repeat_ratio from t5 union select * from t5 ")
  99. List<Map<String, Object>> selectRepeatTsCountForDayAndStatDayId(@Param("day") String day, @Param("statDayId") String statDayId);
  100. }