AttendanceMapper.xml 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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="cn.com.ty.lift.enterprise.oa.mapper.AttendanceMapper" >
  4. <resultMap id="BaseResultMap" type="cn.com.ty.lift.enterprise.oa.dto.AttendanceResponse" >
  5. <id column="id" property="id" jdbcType="BIGINT" />
  6. <result column="mt_company_id" property="mtCompanyId" jdbcType="BIGINT" />
  7. <result column="user_id" property="userId" jdbcType="BIGINT" />
  8. <result column="coordinate" property="coordinate" jdbcType="VARCHAR" />
  9. <result column="remarks" property="remarks" jdbcType="VARCHAR" />
  10. <result column="address" property="address" jdbcType="VARCHAR" />
  11. <result column="creator_id" property="creatorId" jdbcType="BIGINT" />
  12. <result column="create_date" property="createDate" jdbcType="TIMESTAMP" />
  13. <result column="update_id" property="updateId" jdbcType="BIGINT" />
  14. <result column="update_date" property="updateDate" jdbcType="TIMESTAMP" />
  15. <result column="status" property="status" jdbcType="INTEGER" />
  16. <result column="type" property="type" jdbcType="INTEGER" />
  17. <result column="username" property="username" jdbcType="VARCHAR" />
  18. <result column="top_time" property="topTime" jdbcType="TIMESTAMP" />
  19. <result column="down_time" property="updateDate" jdbcType="TIMESTAMP" />
  20. <result column="top_time_pm" property="updateDate" jdbcType="TIMESTAMP" />
  21. <result column="down_time_pm" property="updateDate" jdbcType="TIMESTAMP" />
  22. <result column="top_time_ot" property="updateDate" jdbcType="TIMESTAMP" />
  23. <result column="down_time_ot" property="updateDate" jdbcType="TIMESTAMP" />
  24. </resultMap>
  25. <!--根据条件分页查询-->
  26. <select id="pageByCondition" resultMap="BaseResultMap" parameterType="cn.com.ty.lift.enterprise.oa.dto.AttendanceRequest">
  27. SELECT
  28. att.*,
  29. mt.top_time,
  30. mt.down_time,
  31. mt.top_time_pm,
  32. mt.down_time_pm,
  33. mt.top_time_ot,
  34. mt.down_time_ot,
  35. ui.name AS username
  36. FROM attendance att
  37. LEFT JOIN user_info ui ON att.user_id = ui.user_id
  38. LEFT JOIN maintenance_company mt ON att.mt_company_id = mt.id
  39. <where>
  40. <if test="cond.username != null and cond.username != ''">
  41. AND ui.name LIKE concat('%',#{cond.username},'%')
  42. </if>
  43. <if test="cond.mtCompanyId != null and cond.mtCompanyId > 0">
  44. AND att.mt_company_id = #{cond.mtCompanyId}
  45. </if>
  46. <if test="cond.clockTime != null">
  47. AND date(att.create_date) = #{cond.clockTime}
  48. </if>
  49. <if test="cond.begin != null">
  50. AND date(att.create_date) &gt;= #{cond.begin}
  51. </if>
  52. <if test="cond.end != null">
  53. AND date(att.create_date) &lt;= #{cond.end}
  54. </if>
  55. </where>
  56. </select>
  57. <select id="listByIdList" resultMap="BaseResultMap" parameterType="cn.com.ty.lift.enterprise.oa.dto.AttendanceRequest">
  58. SELECT
  59. att.*,
  60. mt.top_time,
  61. mt.down_time,
  62. mt.top_time_pm,
  63. mt.down_time_pm,
  64. mt.top_time_ot,
  65. mt.down_time_ot,
  66. ui.name AS username,
  67. ui.mobile AS userMobile
  68. FROM attendance att
  69. LEFT JOIN user_info ui ON att.user_id = ui.user_id
  70. LEFT JOIN maintenance_company mt ON att.mt_company_id = mt.id
  71. <where>
  72. <if test="cond.userIds != null and cond.userIds.size > 0">
  73. AND att.user_id IN
  74. <foreach collection="cond.userIds" item="uId" open="(" separator="," close=")">
  75. #{uId}
  76. </foreach>
  77. </if>
  78. <if test="cond.userId != null and cond.userId != ''">
  79. AND att.user_id = #{cond.userId}
  80. </if>
  81. <if test="cond.mtCompanyId != null and cond.mtCompanyId != ''">
  82. AND att.mt_company_id = #{cond.mtCompanyId}
  83. </if>
  84. <if test="cond.attendanceYearMonth != null and cond.attendanceYearMonth != ''">
  85. AND DATE_FORMAT(att.create_date,'%Y-%m') = #{cond.attendanceYearMonth}
  86. </if>
  87. ORDER BY att.create_date DESC
  88. </where>
  89. </select>
  90. <select id="pageByUser" resultMap="BaseResultMap" parameterType="cn.com.ty.lift.enterprise.oa.dto.AttendanceRequest">
  91. SELECT
  92. att.*,
  93. ui.name AS username
  94. FROM attendance att
  95. LEFT JOIN user_info ui ON att.user_id = ui.user_id
  96. <where>
  97. <if test="cond.mtCompanyId != null and cond.mtCompanyId > 0">
  98. AND att.mt_company_id = #{cond.mtCompanyId}
  99. </if>
  100. <if test="cond.userId != null">
  101. AND ui.user_id LIKE #{cond.userId}
  102. </if>
  103. <if test="cond.clockTime != null">
  104. AND date(att.create_date) = #{cond.clockTime}
  105. </if>
  106. <if test="cond.begin != null">
  107. AND date(att.create_date) &gt; #{cond.begin}
  108. </if>
  109. <if test="cond.end != null">
  110. AND date(att.create_date) &lt; #{cond.end}
  111. </if>
  112. </where>
  113. </select>
  114. <select id="infoById" resultMap="BaseResultMap" parameterType="cn.com.ty.lift.enterprise.oa.dto.AttendanceRequest">
  115. SELECT
  116. att.*,
  117. ui.name AS username
  118. FROM attendance att
  119. LEFT JOIN user_info ui ON att.user_id = ui.user_id
  120. <where>
  121. <if test="cond.id != null and cond.id > 0">
  122. AND att.id LIKE #{cond.id}
  123. </if>
  124. </where>
  125. </select>
  126. </mapper>