AccessNumberTrendMapper.xml 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.zhgd.scs.mapper.AccessNumberTrendMapper">
  6. <resultMap id="BaseResultMap" type="com.zhgd.scs.domain.AccessNumberTrend">
  7. <id property="id" column="id" jdbcType="BIGINT"/>
  8. <result property="time" column="time" jdbcType="TIMESTAMP"/>
  9. <result property="number" column="number" jdbcType="INTEGER"/>
  10. <result property="unitId" column="unit_name" jdbcType="VARCHAR"/>
  11. <result property="projectId" column="project_id" jdbcType="BIGINT"/>
  12. </resultMap>
  13. <select id="getTrend" resultType="com.zhgd.scs.domain.AccessNumberTrend">
  14. SELECT time,number
  15. FROM `access_number_trend`
  16. where project_id=#{projectId} AND DATE_FORMAT(time,'%Y-%m-%d')=#{date}
  17. <choose>
  18. <when test="unitId != null and unitId != ''">
  19. and unit_id = #{unitId}
  20. </when>
  21. <otherwise>
  22. and unit_id = -1
  23. </otherwise>
  24. </choose>
  25. ORDER BY time DESC
  26. </select>
  27. <select id="getTrendByDate" resultType="com.zhgd.scs.domain.vo.NameCountDate">
  28. SELECT
  29. date( in_time ) `date`, count( DISTINCT idcard ) count
  30. FROM
  31. access_task_time
  32. where project_id = #{projectId}
  33. <if test="unitId != null and unitId != ''">
  34. and unit_id = #{unitId}
  35. </if>
  36. <if test="start != null and end != null">
  37. and in_time between date(#{start}) and #{end}
  38. or date(in_time) = date(now())
  39. </if>
  40. GROUP BY
  41. date( in_time )
  42. </select>
  43. </mapper>