TimeCalculationMapper.xml 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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.management.platform.mapper.TimeCalculationMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.management.platform.entity.TimeCalculation">
  6. <id column="id" property="id" />
  7. <result column="user_id" property="userId" />
  8. <result column="action_type" property="actionType" />
  9. <result column="date" property="date" />
  10. <result column="start_time" property="startTime" />
  11. <result column="end_time" property="endTime" />
  12. <result column="duration" property="duration" />
  13. <result column="pic_url" property="picUrl" />
  14. </resultMap>
  15. <!-- 通用查询结果列 -->
  16. <sql id="Base_Column_List">
  17. id, user_id, action_type, date, start_time, end_time, duration, pic_url
  18. </sql>
  19. <!--分页获取异常记录-->
  20. <select id="getDevianceList" resultType="java.util.Map">
  21. SELECT a.start_time AS time, b.name, a.action_type AS type, a.date, a.pic_url AS picUrl
  22. FROM time_calculation AS a
  23. LEFT JOIN user AS b ON a.user_id = b.id
  24. WHERE 1=1
  25. <if test="companyId != null and companyId != ''">
  26. AND b.company_id=#{companyId}
  27. </if>
  28. <if test="userId != null and userId != ''">
  29. AND a.user_id = #{userId}
  30. </if>
  31. <if test="actionCode != null and actionCode != ''">
  32. AND a.action_type = #{actionCode}
  33. </if>
  34. <if test="actionCode == null">
  35. AND a.action_type IN (6,7,8)
  36. </if>
  37. <if test="date != null and date != ''">
  38. AND a.date = #{date}
  39. </if>
  40. ORDER BY a.id DESC
  41. </select>
  42. <!--分页获取异常记录的总数量-->
  43. <select id="countDeviance" resultType="java.lang.Integer">
  44. SELECT COUNT(a.id) AS count
  45. FROM time_calculation AS a
  46. LEFT JOIN user AS b ON a.user_id = b.id
  47. WHERE 1=1
  48. <if test="companyId != null and companyId != ''">
  49. AND b.company_id=#{companyId}
  50. </if>
  51. <if test="userId != null and userId != ''">
  52. AND a.user_id = #{userId}
  53. </if>
  54. <if test="actionCode != null and actionCode != ''">
  55. AND a.action_type = #{actionCode}
  56. </if>
  57. <if test="actionCode == null">
  58. AND a.action_type IN (6,7,8)
  59. </if>
  60. <if test="date != null and date != ''">
  61. AND a.date = #{date}
  62. </if>
  63. </select>
  64. <!--获取某日所有有记录的用户id-->
  65. <select id="getTodayStatisticsUser" resultType="java.util.Map">
  66. SELECT DISTINCT b.id, b.name, b.phone
  67. FROM time_calculation AS a
  68. LEFT JOIN user AS b
  69. ON a.user_id = b.id
  70. WHERE 1=1
  71. <if test="companyId != null and companyId != ''">
  72. AND b.company_id=#{companyId}
  73. </if>
  74. <if test="date != null and date != ''">
  75. AND a.date = #{date}
  76. </if>
  77. </select>
  78. <!--根据日期和id获取所有统计信息-->
  79. <select id="getTodayStatistics" resultType="java.util.Map">
  80. SELECT action_type AS type, duration
  81. FROM time_calculation
  82. WHERE 1=1
  83. <if test="date != null and date != ''">
  84. AND date = #{date}
  85. </if>
  86. <if test="userId != null and userId != ''">
  87. AND user_id = #{userId}
  88. </if>
  89. </select>
  90. </mapper>