BdglWeekworkMapper.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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.supervision.grassrootsregistration.mapper.BdglWeekworkMapper">
  6. <resultMap type="BdglWeekwork" id="BdglWeekworkResult">
  7. <result property="id" column="id" />
  8. <result property="name" column="name" />
  9. <result property="startTime" column="start_time" />
  10. <result property="endTime" column="end_time" />
  11. <result property="peopleId" column="people_id" />
  12. <result property="phone" column="phone" />
  13. <result property="peopleId1" column="people_id1" />
  14. <result property="peopleId2" column="people_id2" />
  15. <result property="time" column="time" />
  16. <result property="remark" column="remark" />
  17. <result property="unitId" column="unit_id" />
  18. <result property="adminId" column="admin_id" />
  19. <result property="peopleName" column="people_name" />
  20. <result property="people1Name" column="people1_name" />
  21. <result property="people2Name" column="people2_name" />
  22. <result property="unitName" column="unit_name" />
  23. <result property="adminName" column="admin_name" />
  24. <result property="organizer" column="organizer" />
  25. </resultMap>
  26. <resultMap id="BdglWeekworkBdglWeekworkRegisterResult" type="BdglWeekwork" extends="BdglWeekworkResult">
  27. <collection property="bdglWeekworkRegisterList" notNullColumn="sub_id" javaType="java.util.List" resultMap="BdglWeekworkRegisterResult" />
  28. </resultMap>
  29. <resultMap type="BdglWeekworkRegister" id="BdglWeekworkRegisterResult">
  30. <result property="id" column="sub_id" />
  31. <result property="week" column="sub_week" />
  32. <result property="time" column="sub_time" />
  33. <result property="dateline" column="sub_dateline" />
  34. <result property="contents" column="sub_contents" />
  35. <result property="unitId1" column="sub_unit_id1" />
  36. <result property="peopleIds" column="sub_people_ids" />
  37. <result property="address" column="sub_address" />
  38. <result property="startTime" column="sub_start_time" />
  39. <result property="endTime" column="sub_end_time" />
  40. <result property="weekworkId" column="sub_weekwork_id" />
  41. <result property="shouldArrive" column="sub_should_arrive" />
  42. <result property="realTo" column="sub_real_to" />
  43. <result property="percentage" column="sub_percentage" />
  44. <result property="organizer" column="sub_organizer" />
  45. <result property="sort" column="sort" />
  46. </resultMap>
  47. <sql id="selectBdglWeekworkVo">
  48. select id, name, start_time, end_time, people_id, phone, people_id1, people_id2, time, remark, unit_id, admin_id, people_name, people1_name, people2_name, unit_name, admin_name, organizer from bdgl_weekwork
  49. </sql>
  50. <select id="selectBdglWeekworkList" parameterType="BdglWeekwork" resultMap="BdglWeekworkResult">
  51. select id, name, start_time, end_time, people_id, w.phone, people_id1, people_id2, time, remark, unit_id, admin_id, people_name, people1_name, people2_name, unit_name, admin_name
  52. from bdgl_weekwork w left join sys_dept t
  53. on w.unit_id=t.dept_id
  54. <where>
  55. <if test="unitId != null ">
  56. and (w.unit_id=#{unitId} or find_in_set(#{unitId}, t.ancestors))
  57. </if>
  58. <if test="name != null and name != ''"> and w.name like concat('%', #{name}, '%')</if>
  59. <if test="startTime != null "> and w.start_time = #{startTime}</if>
  60. <if test="endTime != null "> and w.end_time = #{endTime}</if>
  61. <if test="peopleId != null "> and w.people_id = #{peopleId}</if>
  62. <if test="phone != null and phone != ''"> and w.phone = #{phone}</if>
  63. <if test="peopleId1 != null "> and w.people_id1 = #{peopleId1}</if>
  64. <if test="peopleId2 != null "> and w.people_id2 = #{peopleId2}</if>
  65. <if test="time != null "> and w.time = #{time}</if>
  66. <if test="adminId != null "> and w.admin_id = #{adminId}</if>
  67. <if test="peopleName != null and peopleName != ''"> and w.people_name like concat('%', #{peopleName}, '%')</if>
  68. <if test="people1Name != null and people1Name != ''"> and w.people1_name like concat('%', #{people1Name}, '%')</if>
  69. <if test="people2Name != null and people2Name != ''"> and w.people2_name like concat('%', #{people2Name}, '%')</if>
  70. <if test="unitName != null and unitName != ''"> and w.unit_name like concat('%', #{unitName}, '%')</if>
  71. <if test="adminName != null and adminName != ''"> and w.admin_name like concat('%', #{adminName}, '%')</if>
  72. <if test="organizer != null and organizer != ''"> and w.organizer like concat('%', #{organizer}, '%')</if>
  73. </where>
  74. order by w.id desc
  75. </select>
  76. <select id="selectBdglWeekworkById" parameterType="Integer" resultMap="BdglWeekworkBdglWeekworkRegisterResult">
  77. select a.id, a.name, a.start_time, a.end_time, a.people_id, a.phone, a.people_id1, a.people_id2, a.time, a.remark, a.unit_id, a.admin_id, a.people_name, a.people1_name, a.people2_name, a.unit_name, a.admin_name,
  78. b.id as sub_id, b.week as sub_week, b.time as sub_time, b.dateline as sub_dateline, b.contents as sub_contents, b.unit_id1 as sub_unit_id1, b.people_ids as sub_people_ids, b.address as sub_address, b.start_time as sub_start_time, b.end_time as sub_end_time, b.weekwork_id as sub_weekwork_id, b.should_arrive as sub_should_arrive, b.real_to as sub_real_to, b.percentage as sub_percentage,b.organizer as sub_organizer
  79. from bdgl_weekwork a
  80. left join bdgl_weekwork_register b on b.weekwork_id = a.id
  81. where a.id = #{id}
  82. ORDER BY b.time ,b.sort
  83. </select>
  84. <!--获取当前大队一周工作安排-->
  85. <select id="selectBdglWeekwork" resultMap="BdglWeekworkResult">
  86. <include refid="selectBdglWeekworkVo"/>
  87. where
  88. <![CDATA[
  89. start_time <= #{time} and end_time>=#{time}
  90. ]]>
  91. and unit_id=#{unitId}
  92. </select>
  93. <select id="selectBdglWeekworkLists" parameterType="BdglWeekwork" resultMap="BdglWeekworkResult">
  94. <include refid="selectBdglWeekworkVo"/>
  95. <where>
  96. <if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
  97. <if test="startTime != null "> and start_time = #{startTime}</if>
  98. <if test="endTime != null "> and end_time = #{endTime}</if>
  99. <if test="peopleId != null "> and people_id = #{peopleId}</if>
  100. <if test="phone != null and phone != ''"> and phone = #{phone}</if>
  101. <if test="peopleId1 != null "> and people_id1 = #{peopleId1}</if>
  102. <if test="peopleId2 != null "> and people_id2 = #{peopleId2}</if>
  103. <if test="time != null "> and time = #{time}</if>
  104. <if test="unitId != null "> and unit_id = #{unitId}</if>
  105. <if test="adminId != null "> and admin_id = #{adminId}</if>
  106. <if test="peopleName != null and peopleName != ''"> and people_name like concat('%', #{peopleName}, '%')</if>
  107. <if test="people1Name != null and people1Name != ''"> and people1_name like concat('%', #{people1Name}, '%')</if>
  108. <if test="people2Name != null and people2Name != ''"> and people2_name like concat('%', #{people2Name}, '%')</if>
  109. <if test="unitName != null and unitName != ''"> and unit_name like concat('%', #{unitName}, '%')</if>
  110. <if test="adminName != null and adminName != ''"> and admin_name like concat('%', #{adminName}, '%')</if>
  111. <if test="organizer != null and organizer != ''"> and organizer = #{organizer}</if>
  112. </where>
  113. </select>
  114. <insert id="insertBdglWeekwork" parameterType="BdglWeekwork" useGeneratedKeys="true" keyProperty="id">
  115. insert into bdgl_weekwork
  116. <trim prefix="(" suffix=")" suffixOverrides=",">
  117. <if test="name != null">name,</if>
  118. <if test="startTime != null">start_time,</if>
  119. <if test="endTime != null">end_time,</if>
  120. <if test="peopleId != null">people_id,</if>
  121. <if test="phone != null">phone,</if>
  122. <if test="peopleId1 != null">people_id1,</if>
  123. <if test="peopleId2 != null">people_id2,</if>
  124. <if test="time != null">time,</if>
  125. <if test="remark != null">remark,</if>
  126. <if test="unitId != null">unit_id,</if>
  127. <if test="adminId != null">admin_id,</if>
  128. <if test="peopleName != null">people_name,</if>
  129. <if test="people1Name != null">people1_name,</if>
  130. <if test="people2Name != null">people2_name,</if>
  131. <if test="unitName != null">unit_name,</if>
  132. <if test="adminName != null">admin_name,</if>
  133. <if test="organizer != null">organizer,</if>
  134. </trim>
  135. <trim prefix="values (" suffix=")" suffixOverrides=",">
  136. <if test="name != null">#{name},</if>
  137. <if test="startTime != null">#{startTime},</if>
  138. <if test="endTime != null">#{endTime},</if>
  139. <if test="peopleId != null">#{peopleId},</if>
  140. <if test="phone != null">#{phone},</if>
  141. <if test="peopleId1 != null">#{peopleId1},</if>
  142. <if test="peopleId2 != null">#{peopleId2},</if>
  143. <if test="time != null">#{time},</if>
  144. <if test="remark != null">#{remark},</if>
  145. <if test="unitId != null">#{unitId},</if>
  146. <if test="adminId != null">#{adminId},</if>
  147. <if test="peopleName != null">#{peopleName},</if>
  148. <if test="people1Name != null">#{people1Name},</if>
  149. <if test="people2Name != null">#{people2Name},</if>
  150. <if test="unitName != null">#{unitName},</if>
  151. <if test="adminName != null">#{adminName},</if>
  152. <if test="organizer != null">#{organizer},</if>
  153. </trim>
  154. </insert>
  155. <update id="updateBdglWeekwork" parameterType="BdglWeekwork">
  156. update bdgl_weekwork
  157. <trim prefix="SET" suffixOverrides=",">
  158. <if test="name != null">name = #{name},</if>
  159. <if test="startTime != null">start_time = #{startTime},</if>
  160. <if test="endTime != null">end_time = #{endTime},</if>
  161. <if test="peopleId != null">people_id = #{peopleId},</if>
  162. <if test="phone != null">phone = #{phone},</if>
  163. <if test="peopleId1 != null">people_id1 = #{peopleId1},</if>
  164. <if test="peopleId2 != null">people_id2 = #{peopleId2},</if>
  165. <if test="time != null">time = #{time},</if>
  166. <if test="remark != null">remark = #{remark},</if>
  167. <if test="unitId != null">unit_id = #{unitId},</if>
  168. <if test="adminId != null">admin_id = #{adminId},</if>
  169. <if test="peopleName != null">people_name = #{peopleName},</if>
  170. <if test="people1Name != null">people1_name = #{people1Name},</if>
  171. <if test="people2Name != null">people2_name = #{people2Name},</if>
  172. <if test="unitName != null">unit_name = #{unitName},</if>
  173. <if test="adminName != null">admin_name = #{adminName},</if>
  174. <if test="organizer != null">organizer = #{organizer},</if>
  175. </trim>
  176. where id = #{id}
  177. </update>
  178. <delete id="deleteBdglWeekworkById" parameterType="Integer">
  179. delete from bdgl_weekwork where id = #{id}
  180. </delete>
  181. <delete id="deleteBdglWeekworkByIds" parameterType="String">
  182. delete from bdgl_weekwork where id in
  183. <foreach item="id" collection="array" open="(" separator="," close=")">
  184. #{id}
  185. </foreach>
  186. </delete>
  187. <delete id="deleteBdglWeekworkRegisterByWeekworkIds" parameterType="String">
  188. delete from bdgl_weekwork_register where weekwork_id in
  189. <foreach item="weekworkId" collection="array" open="(" separator="," close=")">
  190. #{weekworkId}
  191. </foreach>
  192. </delete>
  193. <delete id="deleteBdglWeekworkRegisterByWeekworkId" parameterType="Integer">
  194. delete from bdgl_weekwork_register where weekwork_id = #{weekworkId}
  195. </delete>
  196. <insert id="batchBdglWeekworkRegister">
  197. insert into bdgl_weekwork_register( id, week, time, dateline, contents, unit_id1, people_ids, address, start_time, end_time, weekwork_id, should_arrive, real_to, percentage,organizer,sort,unit_id) values
  198. <foreach item="item" index="index" collection="list" separator=",">
  199. ( #{item.id}, #{item.week}, #{item.time}, #{item.dateline}, #{item.contents}, #{item.unitId1}, #{item.peopleIds}, #{item.address}, #{item.startTime}, #{item.endTime}, #{item.weekworkId}, #{item.shouldArrive}, #{item.realTo}, #{item.percentage},#{item.organizer},#{item.sort},#{item.unitId})
  200. </foreach>
  201. </insert>
  202. </mapper>