DayStatisticsMapper.xml 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.txz.operating.dao.DayStatisticsMapper">
  4. <resultMap id="BaseResultMap" type="com.txz.operating.model.DayStatistics">
  5. <!--
  6. WARNING - @mbg.generated
  7. -->
  8. <id column="id" jdbcType="BIGINT" property="id" />
  9. <result column="dimension_id" jdbcType="BIGINT" property="dimensionId" />
  10. <result column="section_id" jdbcType="BIGINT" property="sectionId" />
  11. <result column="seq" jdbcType="INTEGER" property="seq" />
  12. <result column="section_name" jdbcType="VARCHAR" property="sectionName" />
  13. <result column="cut_day" jdbcType="DATE" property="cutDay" />
  14. <result column="statistics_value" jdbcType="DECIMAL" property="statisticsValue" />
  15. <result column="statistics_total" jdbcType="DECIMAL" property="statisticsTotal" />
  16. </resultMap>
  17. <select id="findStatisticsByCondition" resultType="com.txz.operating.web.bo.DayStatisticsBo">
  18. select sum(statistics_value) as statisticsValue,
  19. <choose>
  20. <when test="dataType != null and dataType == 2">
  21. DATE_FORMAT(cut_day, '%Y-%u') as cutDay
  22. </when>
  23. <when test="dataType != null and dataType == 3">
  24. DATE_FORMAT(cut_day, '%Y-%m') as cutDay
  25. </when>
  26. <when test="dataType != null and dataType == 4">
  27. DATE_FORMAT(cut_day, '%Y') as cutDay
  28. </when>
  29. <otherwise>
  30. cut_day as cutDay
  31. </otherwise>
  32. </choose>
  33. from r_day_statistics
  34. where section_id = #{sectionId} and cut_day between #{startTime} and #{endTime}
  35. GROUP BY
  36. <choose>
  37. <when test="dataType != null and dataType == 2">
  38. DATE_FORMAT(cut_day, '%Y-%u')
  39. </when>
  40. <when test="dataType != null and dataType == 3">
  41. DATE_FORMAT(cut_day, '%Y-%m')
  42. </when>
  43. <when test="dataType != null and dataType == 4">
  44. DATE_FORMAT(cut_day, '%Y')
  45. </when>
  46. <otherwise>
  47. cut_day
  48. </otherwise>
  49. </choose>
  50. order by cut_day
  51. </select>
  52. </mapper>