ManagementDetailMapper.java 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. @Select("select compl_area_local, substring(acct_date from 7 for 2) as day_id, count(1) as num " + //
  15. " from tsl_data.management_detail\r\n" + //
  16. " where stat_day_id = #{day} " + //
  17. " group by compl_area_local, substring(acct_date from 7 for 2)\r\n" + //
  18. " order by compl_area_local, substring(acct_date from 7 for 2)")
  19. List<Map<String, Object>> selectCityTslForMonth(@Param("day") String day);
  20. /**
  21. * 投诉清单全省分日计数 按账期查询
  22. */
  23. @Select("select substring(acct_date from 7 for 2) as day_id, count(1) as num" + //
  24. " from tsl_data.management_detail\r\n" + //
  25. " where stat_day_id = #{day} " + //
  26. " group by substring(acct_date from 7 for 2)\r\n" + //
  27. " order by substring(acct_date from 7 for 2)")
  28. List<Map<String, Object>> selectAllTslForMonth(@Param("day") String day);
  29. /**
  30. * 投诉清单地市总数 按账期查询
  31. */
  32. @Select("select compl_area_local, count(1) as num " + //
  33. " from tsl_data.management_detail\r\n" + //
  34. " where stat_day_id = #{day} " + //
  35. " group by compl_area_local\r\n" + //
  36. " order by compl_area_local")
  37. List<Map<String, Object>> selectCityAllForMonth(@Param("day") String day);
  38. /**
  39. * 全省总数 按账期查询
  40. */
  41. @Select("select count(1) as num\r\n" + //
  42. "from tsl_data.management_detail\r\n" + //
  43. "where stat_day_id = #{day} ")
  44. int selectAllForMonth(@Param("day") String day);
  45. /**
  46. * 从 河北_CEM移网质量投诉明细 mobile_complaint_day 中同步数据
  47. */
  48. @Insert("insert into tsl_data.management_detail (origin, stat_day_id, acct_date, sheet_no," +
  49. " compl_area_local, compl_city_local) " +
  50. "select 'mobile_complaint_day' as origin, concat(month_id, day_id) as stat_day_id," +
  51. " acct_date, sheet_no, compl_area_local, gis_city as compl_city_local " +
  52. " from tsl_data.mobile_complaint_day mcd \r\n" +
  53. " where month_id = substring(#{day} from 1 for 6) and day_id = substring(#{day} from 7 for 2) ")
  54. int insertFromMobileComplaint(@Param("day") String day);
  55. /**
  56. * 从 河北客户体验管理智能定责投诉明细月累计接口日 complaint_details_fix_ywd_day 同步数据
  57. */
  58. @Insert("insert into tsl_data.management_detail (origin, stat_day_id, acct_date, sheet_no," +
  59. " compl_area_local, compl_city_local) " +
  60. "select 'complaint_details_fix_ywd_day' as origin, concat(month_id, day_id) as stat_day_id," +
  61. " concat(month_id1, day_id1) as acct_date, sheet_no, compl_area_local, compl_city_local " +
  62. " from tsl_data.complaint_details_fix_ywd_day cdfyd \r\n" +
  63. " where duty_reason_id_day = '业务使用>>基础业务使用>>移网主被叫>>手机无法主被叫'\r\n" +
  64. " and month_id = substring(#{day} from 1 for 6) and day_id = substring(#{day} from 7 for 2) ")
  65. int insertFromComplaintDetailsFixYwd(@Param("day") String day);
  66. /**
  67. * 按照账期统计某个账期的数据量
  68. */
  69. @Select("select count(1) from tsl_data.management_detail where stat_day_id = #{day} ")
  70. int selectCountofStatDay(@Param("day") String day);
  71. @Delete("delete from tsl_data.management_detail where tat_day_id = #{day}")
  72. int deleteForStatDay(@Param("day") String day);
  73. @Select("with t1 as (select compl_area_local, sheet_no from tsl_data.management_detail md \n" + //
  74. " where stat_day_id = #{day}), \n" + //
  75. " t2 as (select distinct * from t1), \n" + //
  76. " t3 as (select compl_area_local, count(1) as total_num from t1 group by compl_area_local), \n" + //
  77. " t4 as (select compl_area_local, count(1) as distinct_num from t2 group by compl_area_local), \n"
  78. + " t5 as (select t3.compl_area_local, t3.total_num, t3.total_num - t4.distinct_num::float8 as repeat_num, \n"
  79. + " (t3.total_num - t4.distinct_num) / t3.total_num::float8 as repeat_ratio from T3, t4 \n" + //
  80. " where t3.compl_area_local = t4.compl_area_local) \n" + //
  81. " select '全省' as compl_area_local, sum(total_num) as total_num, sum(repeat_num) as repeat_num, \n"
  82. + " sum(repeat_num) / sum(total_num)::float8 as repeat_ratio from t5 union select * from t5 ")
  83. List<Map<String, Object>> selectRepeatTsCountForDay(String day);
  84. }