ClockRecordMapper.xml 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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.ruoyi.system.mapper.ClockRecordMapper">
  6. <resultMap type="ClockRecord" id="ClockRecordResult">
  7. <result property="clockId" column="clock_id" />
  8. <result property="userId" column="user_id" />
  9. <result property="deptName" column="dept_name" />
  10. <result property="userName" column="user_name" />
  11. <result property="phonenumber" column="phonenumber" />
  12. <result property="idCard" column="id_card" />
  13. <result property="recordDt" column="record_dt" />
  14. <result property="recordDate" column="record_date" />
  15. <result property="recordTime" column="record_time" />
  16. <result property="recordLocations" column="record_locations" />
  17. <result property="week" column="week" />
  18. <result property="isOutwork" column="is_outwork" />
  19. <result property="pictureUrl" column="picture_url" />
  20. <result property="type" column="type" />
  21. <result property="source" column="source" />
  22. <result property="createBy" column="create_by" />
  23. <result property="createTime" column="create_time" />
  24. <result property="updateBy" column="update_by" />
  25. <result property="updateTime" column="update_time" />
  26. <result property="remark" column="remark" />
  27. </resultMap>
  28. <sql id="selectClockRecordVo">
  29. select clock_id, user_id, dept_name, user_name, phonenumber, id_card,record_dt,record_date, record_time,record_locations,week, is_outwork,picture_url,type,source, create_by, create_time, update_by, update_time, remark from clock_record
  30. </sql>
  31. <select id="selectClockRecordList" parameterType="ClockRecord" resultMap="ClockRecordResult">
  32. <include refid="selectClockRecordVo"/>
  33. <where>
  34. <if test="userId != null "> and user_id = #{userId}</if>
  35. <if test="deptName != null "> and dept_name like concat('%', #{deptName}, '%')</if>
  36. <if test="userName != null and userName != ''"> and user_name like concat('%', #{userName}, '%')</if>
  37. <if test="phonenumber != null and phonenumber != ''"> and phonenumber = #{phonenumber}</if>
  38. <if test="idCard != null and idCard != ''"> and id_card = #{idCard}</if>
  39. <if test="recordDate != null and recordDate != ''"> and record_date = #{recordDate}</if>
  40. <if test="week != null and week != ''"> and week = #{week}</if>
  41. <if test="isOutwork != null and isOutwork != ''"> and is_outwork = #{isOutwork}</if>
  42. <if test="type != null and type != ''"> and type = #{type}</if>
  43. <if test="source != null and source != ''"> and source = #{source}</if>
  44. <if test="startTime != null and startTime != ''"><!-- 开始时间检索 -->
  45. AND record_date &gt;= #{startTime}
  46. </if>
  47. <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
  48. AND record_date &lt;= #{endTime}
  49. </if>
  50. </where>
  51. </select>
  52. <select id="selectClockRecordByClockId" parameterType="Long" resultMap="ClockRecordResult">
  53. <include refid="selectClockRecordVo"/>
  54. where clock_id = #{clockId}
  55. </select>
  56. <select id="selectOrderFoodListRl" parameterType="ClockRecord" resultMap="ClockRecordResult">
  57. <include refid="selectClockRecordVo"/>
  58. <where>
  59. <if test="userId != null "> and user_id = #{userId}</if>
  60. <if test="deptName != null "> and dept_name like concat('%', #{deptName}, '%')</if>
  61. <if test="userName != null and userName != ''"> and user_name like concat('%', #{userName}, '%')</if>
  62. <if test="phonenumber != null and phonenumber != ''"> and phonenumber = #{phonenumber}</if>
  63. <if test="idCard != null and idCard != ''"> and id_card = #{idCard}</if>
  64. <if test="recordDate != null and recordDate != ''">
  65. and date_format(record_date,'%Y%m') = date_format(#{recordDate},'%Y%m')
  66. </if>
  67. <if test="isOutwork != null and isOutwork != ''"> and is_outwork = #{isOutwork}</if>
  68. <if test="type != null and type != ''"> and type = #{type}</if>
  69. <if test="startTime != null and startTime != ''"><!-- 开始时间检索 -->
  70. AND record_date &gt;= #{startTime}
  71. </if>
  72. <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
  73. AND record_date &lt;= #{endTime}
  74. </if>
  75. </where>
  76. </select>
  77. <select id="selectClockRecordNew" parameterType="ClockRecord" resultMap="ClockRecordResult">
  78. <include refid="selectClockRecordVo"/>
  79. where user_id = #{userId}
  80. order by record_time desc limit 1
  81. </select>
  82. <insert id="insertClockRecord" parameterType="ClockRecord" useGeneratedKeys="true" keyProperty="clockId">
  83. insert into clock_record
  84. <trim prefix="(" suffix=")" suffixOverrides=",">
  85. <if test="userId != null">user_id,</if>
  86. <if test="deptName != null">dept_name,</if>
  87. <if test="userName != null and userName != ''">user_name,</if>
  88. <if test="phonenumber != null">phonenumber,</if>
  89. <if test="idCard != null">id_card,</if>
  90. <if test="recordDt != null">record_dt,</if>
  91. <if test="recordDate != null">record_date,</if>
  92. <if test="recordTime != null">record_time,</if>
  93. <if test="recordLocations != null">record_locations,</if>
  94. <if test="week != null">week,</if>
  95. <if test="isOutwork != null and isOutwork != ''"> is_outwork,</if>
  96. <if test="pictureUrl != null and pictureUrl != ''"> picture_url,</if>
  97. <if test="type != null and type != ''">type,</if>
  98. <if test="source != null and source != ''"> source ,</if>
  99. <if test="createBy != null">create_by,</if>
  100. <if test="createTime != null">create_time,</if>
  101. <if test="updateBy != null">update_by,</if>
  102. <if test="updateTime != null">update_time,</if>
  103. <if test="remark != null">remark,</if>
  104. </trim>
  105. <trim prefix="values (" suffix=")" suffixOverrides=",">
  106. <if test="userId != null">#{userId},</if>
  107. <if test="deptName != null">#{deptName},</if>
  108. <if test="userName != null and userName != ''">#{userName},</if>
  109. <if test="phonenumber != null">#{phonenumber},</if>
  110. <if test="idCard != null">#{idCard},</if>
  111. <if test="recordDt != null">#{recordDt},</if>
  112. <if test="recordDate != null">#{recordDate},</if>
  113. <if test="recordTime != null">#{recordTime},</if>
  114. <if test="recordLocations != null"> #{recordLocations},</if>
  115. <if test="week != null">#{week},</if>
  116. <if test="isOutwork != null and isOutwork != ''">#{isOutwork},</if>
  117. <if test="pictureUrl != null and pictureUrl != ''"> #{pictureUrl},</if>
  118. <if test="type != null and type != ''">#{type},</if>
  119. <if test="source != null and source != ''"> #{source},</if>
  120. <if test="createBy != null">#{createBy},</if>
  121. <if test="createTime != null">#{createTime},</if>
  122. <if test="updateBy != null">#{updateBy},</if>
  123. <if test="updateTime != null">#{updateTime},</if>
  124. <if test="remark != null">#{remark},</if>
  125. </trim>
  126. </insert>
  127. <update id="updateClockRecord" parameterType="ClockRecord">
  128. update clock_record
  129. <trim prefix="SET" suffixOverrides=",">
  130. <if test="userId != null">user_id = #{userId},</if>
  131. <if test="deptName != null">dept_name = #{deptName},</if>
  132. <if test="userName != null and userName != ''">user_name = #{userName},</if>
  133. <if test="phonenumber != null">phonenumber = #{phonenumber},</if>
  134. <if test="idCard != null">id_card = #{idCard},</if>
  135. <if test="recordDt != null">record_dt= #{recordDt},</if>
  136. <if test="recordDate != null">record_date = #{recordDate},</if>
  137. <if test="recordTime != null">record_time = #{recordTime},</if>
  138. <if test="recordLocations != null">record_locations = #{recordLocations},</if>
  139. <if test="week != null "> and week = #{week},</if>
  140. <if test="isOutwork != null and isOutwork != ''"> is_outwork = #{isOutwork},</if>
  141. <if test="pictureUrl != null and pictureUrl != ''"> picture_url=#{pictureUrl},</if>
  142. <if test="type != null and type != ''">type = #{type},</if>
  143. <if test="source != null and source != ''"> source = #{source},</if>
  144. <if test="createBy != null">create_by = #{createBy},</if>
  145. <if test="createTime != null">create_time = #{createTime},</if>
  146. <if test="updateBy != null">update_by = #{updateBy},</if>
  147. <if test="updateTime != null">update_time = #{updateTime},</if>
  148. <if test="remark != null">remark = #{remark},</if>
  149. </trim>
  150. where clock_id = #{clockId}
  151. </update>
  152. <delete id="deleteClockRecordByClockId" parameterType="Long">
  153. delete from clock_record where clock_id = #{clockId}
  154. </delete>
  155. <delete id="deleteClockRecordByClockIds" parameterType="String">
  156. delete from clock_record where clock_id in
  157. <foreach item="clockId" collection="array" open="(" separator="," close=")">
  158. #{clockId}
  159. </foreach>
  160. </delete>
  161. </mapper>