AvgDurationMapper.java 1.6 KB

1234567891011121314151617181920212223242526272829303132333435
  1. package com.nokia.tsl_data.dao;
  2. import org.apache.ibatis.annotations.Insert;
  3. import org.apache.ibatis.annotations.Mapper;
  4. import org.apache.ibatis.annotations.Select;
  5. import java.util.List;
  6. import java.util.Map;
  7. /* cspell: disable */
  8. @Mapper
  9. public interface AvgDurationMapper {
  10. /**
  11. * 插入上月的平均处理时长
  12. */
  13. @Insert("with t1 as (select compl_area_local, " +
  14. " case when proce_time != '' then (extract('epoch' from to_timestamp(proce_time, 'YYYY-MM-DD HH24:MI:SS')) " +
  15. " - extract('epoch' from to_timestamp(accept_time, 'YYYY-MM-DD HH24:MI:SS'))) / 3600 " +
  16. " when is_online_complete = '是' then 0 " +
  17. " else (extract('epoch' from to_timestamp(end_time, 'YYYY-MM-DD HH24:MI:SS')) " +
  18. " - extract('epoch' from to_timestamp(accept_time, 'YYYY-MM-DD HH24:MI:SS'))) / 3600 end as duration " +
  19. "from tsl_data.mobile_complaint_day hdmc where month_id = #{month_id} " +
  20. "and day_id::float8 = extract('day' from to_timestamp(#{month_id}, 'YYYYMM') + interval '1 month' - interval '1 day')) " +
  21. "insert into tsl_data.avg_duration (month_id, city_name, avg_duration) " +
  22. "select #{month_id} as month_id, compl_area_local as city_name, avg(duration) as avg_duration " +
  23. "from t1 group by compl_area_local ")
  24. void insertOldTsDurationForMonth(String monthId);
  25. /**
  26. * 查询历史处理时长
  27. */
  28. @Select("select city_name, avg_duration from tsl_data.avg_duration where month_id = #{monthId}")
  29. List<Map<String, Object>> selectOldTsDurationForMonth(String monthId);
  30. }