HadSiteStaticMapper.xml 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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.bizmatics.persistence.mapper.HadSiteStaticMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.bizmatics.model.HadSiteStatic">
  6. <id column="id" property="id" />
  7. <result column="site_id" property="siteId" />
  8. <result column="max_epp" property="maxEpp" />
  9. <result column="min_epp" property="minEpp" />
  10. <result column="avg_epp" property="avgEpp" />
  11. <result column="load_ico" property="loadIco" />
  12. <result column="his_ico" property="hisIco" />
  13. <result column="had_time" property="hadTime" />
  14. </resultMap>
  15. <select id="selectCount" resultType="java.lang.Double">
  16. select
  17. IFNULL(sum(siteSum),0)
  18. FROM (
  19. SELECT
  20. (max(max_epp)-min(min_epp)) as siteSum
  21. FROM
  22. had_site_static as hs
  23. INNER JOIN user_site as us
  24. on hs.site_id = us.site_id
  25. <where>
  26. <if test="userId != null and userId != 0">
  27. and us.user_id = #{userId}
  28. </if>
  29. <if test="siteId != null and siteId != 0">
  30. and us.site_id = #{siteId}
  31. </if>
  32. <if test="startTime != null and endTime != null">
  33. and hs.had_time between #{startTime} and #{endTime}
  34. </if>
  35. </where>
  36. GROUP BY hs.site_id
  37. )as t
  38. </select>
  39. </mapper>