CheckPointDao.xml 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  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.ourwill.module.house.dao.daily.CheckPointDao">
  4. <resultMap type="cn.ourwill.module.house.entity.daily.CheckPoint" id="baseMap">
  5. <result column="ID" property="id"/>
  6. <result column="checkpoint_name" property="checkpointName"/>
  7. <result column="checkpoint_code" property="checkpointCode"/>
  8. <result column="checkpoint_desc" property="checkpointDesc"/>
  9. <result column="checkpoint_grain_id" property="checkpointGrainId"/>
  10. <result column="checkpoint_grain_name" property="checkpointGrainName"/>
  11. <result column="checkpoint_post_id" property="checkpointPostId"/>
  12. <result column="checkpoint_post_name" property="checkpointPostName"/>
  13. </resultMap>
  14. <sql id="columns">
  15. a.ID ,
  16. a.checkpoint_name ,
  17. a.checkpoint_code ,
  18. a.checkpoint_desc ,
  19. a.checkpoint_grain_id ,
  20. a.checkpoint_grain_name ,
  21. a.checkpoint_post_id ,
  22. a.checkpoint_post_name
  23. </sql>
  24. <sql id="joinCols">
  25. </sql>
  26. <select id="get" resultMap="baseMap">
  27. SELECT
  28. <include refid="columns"/>
  29. FROM checkpoint a
  30. <include refid="joinCols"/>
  31. WHERE a.id = #{id}
  32. </select>
  33. <select id="findList" resultMap="baseMap">
  34. SELECT
  35. <include refid="columns"/>
  36. FROM checkpoint a
  37. LEFT JOIN sys_grain sg on sg.id=a.checkpoint_grain_id
  38. <include refid="joinCols"/>
  39. <where>
  40. <if test="id !=null">
  41. and a.ID = #{id}
  42. </if>
  43. <if test="checkpointName !=null">
  44. and a.checkpoint_name like CONCAT('%',#{checkpointName},'%')
  45. </if>
  46. <if test="checkpointCode !=null">
  47. and a.checkpoint_code = #{checkpointCode}
  48. </if>
  49. <if test="checkpointDesc !=null">
  50. and a.checkpoint_desc like CONCAT('%',#{checkpointDesc},'%')
  51. </if>
  52. <if test="checkpointGrainId !=null">
  53. and a.checkpoint_grain_id = #{checkpointGrainId}
  54. </if>
  55. <if test="checkpointGrainName !=null">
  56. and a.checkpoint_grain_name = #{checkpointGrainName}
  57. </if>
  58. <if test="checkpointPostId !=null">
  59. and a.checkpoint_post_id = #{checkpointPostId}
  60. </if>
  61. <if test="checkpointPostName !=null">
  62. and a.checkpoint_post_name = #{checkpointPostName}
  63. </if>
  64. <if test="cityId !=null">
  65. and sg.parentId = #{cityId}
  66. </if>
  67. </where>
  68. <choose>
  69. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  70. ORDER BY ${page.orderBy}
  71. </when>
  72. <otherwise>
  73. </otherwise>
  74. </choose>
  75. </select>
  76. <select id="findBkList" resultMap="baseMap">
  77. SELECT
  78. <include refid="columns"/>
  79. FROM checkpoint a
  80. LEFT JOIN sys_grain sg on sg.id=a.checkpoint_grain_id
  81. <include refid="joinCols"/>
  82. <where>
  83. <if test="id !=null">
  84. and a.ID = #{id}
  85. </if>
  86. <if test="checkpointName !=null">
  87. and a.checkpoint_name like CONCAT('%',#{checkpointName},'%')
  88. </if>
  89. <if test="checkpointCode !=null">
  90. and a.checkpoint_code = #{checkpointCode}
  91. </if>
  92. <if test="checkpointDesc !=null">
  93. and a.checkpoint_desc like CONCAT('%',#{checkpointDesc},'%')
  94. </if>
  95. <if test="checkpointGrainId !=null">
  96. and a.checkpoint_grain_id in (SELECT id FROM sys_grain a WHERE parentId = #{checkpointGrainId} OR parentId IN (SELECT id FROM sys_grain WHERE parentId = #{checkpointGrainId} AND NAME LIKE '%库外储粮%'))
  97. </if>
  98. <if test="checkpointGrainName !=null">
  99. and a.checkpoint_grain_name = #{checkpointGrainName}
  100. </if>
  101. <if test="checkpointPostId !=null">
  102. and a.checkpoint_post_id = #{checkpointPostId}
  103. </if>
  104. <if test="checkpointPostName !=null">
  105. and a.checkpoint_post_name = #{checkpointPostName}
  106. </if>
  107. </where>
  108. <choose>
  109. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  110. ORDER BY ${page.orderBy}
  111. </when>
  112. <otherwise>
  113. </otherwise>
  114. </choose>
  115. </select>
  116. <select id="findAllList" resultMap="baseMap">
  117. SELECT
  118. <include refid="columns"/>
  119. FROM checkpoint a
  120. <include refid="joinCols"/>
  121. <where>
  122. <if test="id !=null">
  123. and ID = #{id}
  124. </if>
  125. <if test="checkpointName !=null">
  126. and checkpoint_name like CONCAT('%',#{checkpointName},'%')
  127. </if>
  128. <if test="checkpointCode !=null">
  129. and checkpoint_code = #{checkpointCode}
  130. </if>
  131. <if test="checkpointDesc !=null">
  132. and checkpoint_desc like CONCAT('%',#{checkpointDesc},'%')
  133. </if>
  134. <if test="checkpointGrainId !=null">
  135. and checkpoint_grain_id = #{checkpointGrainId}
  136. </if>
  137. <if test="checkpointGrainName !=null">
  138. and checkpoint_grain_name = #{checkpointGrainName}
  139. </if>
  140. <if test="checkpointPostId !=null">
  141. and checkpoint_post_id = #{checkpointPostId}
  142. </if>
  143. <if test="checkpointPostName !=null">
  144. and checkpoint_post_name = #{checkpointPostName}
  145. </if>
  146. </where>
  147. <choose>
  148. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  149. ORDER BY ${page.orderBy}
  150. </when>
  151. <otherwise>
  152. </otherwise>
  153. </choose>
  154. </select>
  155. <insert id="insert" keyColumn="ID" keyProperty="id" useGeneratedKeys="true"
  156. parameterType="cn.ourwill.module.house.entity.daily.CheckPoint">
  157. INSERT INTO checkpoint
  158. <trim prefix="(" suffix=")" suffixOverrides=",">
  159. <if test="id !=null">
  160. ID,
  161. </if>
  162. <if test="checkpointName !=null">
  163. checkpoint_name,
  164. </if>
  165. <if test="checkpointCode !=null">
  166. checkpoint_code,
  167. </if>
  168. <if test="checkpointDesc !=null">
  169. checkpoint_desc,
  170. </if>
  171. <if test="checkpointGrainId !=null">
  172. checkpoint_grain_id,
  173. </if>
  174. <if test="checkpointGrainName !=null">
  175. checkpoint_grain_name,
  176. </if>
  177. <if test="checkpointPostId !=null">
  178. checkpoint_post_id,
  179. </if>
  180. <if test="checkpointPostName !=null">
  181. checkpoint_post_name
  182. </if>
  183. </trim>
  184. <trim prefix="values (" suffix=")" suffixOverrides=",">
  185. <if test="id !=null">
  186. #{id},
  187. </if>
  188. <if test="checkpointName !=null">
  189. #{checkpointName},
  190. </if>
  191. <if test="checkpointCode !=null">
  192. #{checkpointCode},
  193. </if>
  194. <if test="checkpointDesc !=null">
  195. #{checkpointDesc},
  196. </if>
  197. <if test="checkpointGrainId !=null">
  198. #{checkpointGrainId},
  199. </if>
  200. <if test="checkpointGrainName !=null">
  201. #{checkpointGrainName},
  202. </if>
  203. <if test="checkpointPostId !=null">
  204. #{checkpointPostId},
  205. </if>
  206. <if test="checkpointPostName !=null">
  207. #{checkpointPostName}
  208. </if>
  209. </trim>
  210. </insert>
  211. <update id="update" parameterType="cn.ourwill.module.house.entity.daily.CheckPoint">
  212. UPDATE checkpoint <set>
  213. <if test="id != null">
  214. ID= #{id} ,
  215. </if>
  216. <if test="checkpointName != null">
  217. checkpoint_name= #{checkpointName} ,
  218. </if>
  219. <if test="checkpointCode != null">
  220. checkpoint_code= #{checkpointCode} ,
  221. </if>
  222. <if test="checkpointDesc !=null">
  223. checkpoint_desc = #{checkpointDesc} ,
  224. </if>
  225. <if test="checkpointGrainId != null">
  226. checkpoint_grain_id= #{checkpointGrainId} ,
  227. </if>
  228. <if test="checkpointGrainName != null">
  229. checkpoint_grain_name= #{checkpointGrainName} ,
  230. </if>
  231. <if test="checkpointPostId != null">
  232. checkpoint_post_id= #{checkpointPostId} ,
  233. </if>
  234. <if test="checkpointPostName != null">
  235. checkpoint_post_name= #{checkpointPostName} ,
  236. </if>
  237. </set>
  238. WHERE id = #{id}
  239. </update>
  240. <delete id="deleteById" parameterType="java.lang.Long">
  241. DELETE FROM checkpoint WHERE ID = #{id}
  242. </delete>
  243. <delete id="deleteByIds" parameterType="java.util.List">
  244. DELETE FROM checkpoint WHERE ID IN
  245. <foreach collection="list" index="index" item="item" open="(" separator="," close=")">
  246. #{item}
  247. </foreach>
  248. </delete>
  249. </mapper>