CzrkJzdzMapper.xml 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  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.boman.web.core.mapper.CzrkJzdzMapper">
  6. <resultMap type="com.boman.domain.CzrkJzdz" id="CzrkJzdzResult">
  7. <result property="id" column="id" />
  8. <result property="czrkId" column="czrk_id" />
  9. <result property="idCard" column="id_card" />
  10. <result property="userName" column="user_name" />
  11. <result property="sort" column="sort" />
  12. <result property="deptId" column="dept_id" />
  13. <result property="provinceId" column="province_id" />
  14. <result property="province" column="province" />
  15. <result property="cityId" column="city_id" />
  16. <result property="city" column="city" />
  17. <result property="regionId" column="region_id" />
  18. <result property="region" column="region" />
  19. <result property="townId" column="town_id" />
  20. <result property="town" column="town" />
  21. <result property="villageId" column="village_id" />
  22. <result property="village" column="village" />
  23. <result property="nowIn" column="now_in" />
  24. <result property="createBy" column="create_by" />
  25. <result property="createTime" column="create_time" />
  26. <result property="updateBy" column="update_by" />
  27. <result property="updateTime" column="update_time" />
  28. <result property="status" column="status" />
  29. </resultMap>
  30. <sql id="selectCzrkJzdzVo">
  31. select id, czrk_id, id_card, user_name, sort, dept_id, province_id, province, city_id, city, region_id, region, town_id, town, village_id, village, now_in, create_by, create_time, update_by, update_time, status from czrk_jzdz
  32. </sql>
  33. <select id="selectCzrkJzdzList" resultMap="CzrkJzdzResult">
  34. <include refid="selectCzrkJzdzVo"/>
  35. <where>
  36. <if test="czrkId != null "> and czrk_id = #{czrkId}</if>
  37. <if test="idCard != null and idCard != ''"> and id_card = #{idCard}</if>
  38. <if test="userName != null and userName != ''"> and user_name like concat( #{userName}, '%')</if>
  39. <if test="sort != null "> and sort = #{sort}</if>
  40. <if test="deptId != null "> and dept_id = #{deptId}</if>
  41. <if test="provinceId != null and provinceId != ''"> and province_id = #{provinceId}</if>
  42. <if test="province != null and province != ''"> and province = #{province}</if>
  43. <if test="cityId != null and cityId != ''"> and city_id = #{cityId}</if>
  44. <if test="city != null and city != ''"> and city = #{city}</if>
  45. <if test="regionId != null and regionId != ''"> and region_id = #{regionId}</if>
  46. <if test="region != null and region != ''"> and region = #{region}</if>
  47. <if test="townId != null and townId != ''"> and town_id = #{townId}</if>
  48. <if test="town != null and town != ''"> and town = #{town}</if>
  49. <if test="villageId != null and villageId != ''"> and village_id = #{villageId}</if>
  50. <if test="village != null and village != ''"> and village = #{village}</if>
  51. <if test="nowIn != null and nowIn != ''"> and now_in = #{nowIn}</if>
  52. <if test="status != null and status != ''"> and status = #{status}</if>
  53. <if test="deptIdList != null and deptIdList.size() > 0">
  54. and dept_id in
  55. <foreach item="deptId" collection="deptIdList" open="(" separator="," close=")">
  56. #{deptId}
  57. </foreach>
  58. </if>
  59. </where>
  60. order by create_time DESC
  61. </select>
  62. <select id="listIdCard" resultType="string">
  63. select id_card from czrk_jzdz
  64. <where>
  65. <if test="czrkId != null "> and czrk_id = #{czrkId}</if>
  66. <if test="idCard != null and idCard != ''"> and id_card = #{idCard}</if>
  67. <if test="userName != null and userName != ''"> and user_name like concat( #{userName}, '%')</if>
  68. <if test="sort != null "> and sort = #{sort}</if>
  69. <if test="deptId != null "> and dept_id = #{deptId}</if>
  70. <if test="provinceId != null and provinceId != ''"> and province_id = #{provinceId}</if>
  71. <if test="province != null and province != ''"> and province = #{province}</if>
  72. <if test="cityId != null and cityId != ''"> and city_id = #{cityId}</if>
  73. <if test="city != null and city != ''"> and city = #{city}</if>
  74. <if test="regionId != null and regionId != ''"> and region_id = #{regionId}</if>
  75. <if test="region != null and region != ''"> and region = #{region}</if>
  76. <if test="townId != null and townId != ''"> and town_id = #{townId}</if>
  77. <if test="town != null and town != ''"> and town = #{town}</if>
  78. <if test="villageId != null and villageId != ''"> and village_id = #{villageId}</if>
  79. <if test="village != null and village != ''"> and village = #{village}</if>
  80. <if test="nowIn != null and nowIn != ''"> and now_in = #{nowIn}</if>
  81. <if test="status != null and status != ''"> and status = #{status}</if>
  82. </where>
  83. </select>
  84. <select id="selectCzrkJzdzById" parameterType="Long" resultMap="CzrkJzdzResult">
  85. <include refid="selectCzrkJzdzVo"/>
  86. where id = #{id}
  87. </select>
  88. <select id="listByIdCard" resultMap="CzrkJzdzResult">
  89. <include refid="selectCzrkJzdzVo"/>
  90. where id_card in
  91. <foreach item="idCard" collection="idCardList" open="(" separator="," close=")">
  92. #{idCard}
  93. </foreach>
  94. </select>
  95. <select id="listByCzrkIds" resultMap="CzrkJzdzResult">
  96. <include refid="selectCzrkJzdzVo"/>
  97. where czrk_id in
  98. <foreach item="czrkId" collection="czrkIds" open="(" separator="," close=")">
  99. #{czrkId}
  100. </foreach>
  101. </select>
  102. <select id="listByCzrkId" resultMap="CzrkJzdzResult">
  103. <include refid="selectCzrkJzdzVo"/>
  104. where czrk_id = #{czrkId} and status = 'Y'
  105. </select>
  106. <insert id="insertCzrkJzdz" useGeneratedKeys="true" keyProperty="id">
  107. insert into czrk_jzdz
  108. <trim prefix="(" suffix=")" suffixOverrides=",">
  109. <if test="czrkId != null">czrk_id,</if>
  110. <if test="idCard != null">id_card,</if>
  111. <if test="userName != null">user_name,</if>
  112. <if test="sort != null">sort,</if>
  113. <if test="deptId != null">dept_id,</if>
  114. <if test="provinceId != null">province_id,</if>
  115. <if test="province != null">province,</if>
  116. <if test="cityId != null">city_id,</if>
  117. <if test="city != null">city,</if>
  118. <if test="regionId != null">region_id,</if>
  119. <if test="region != null">region,</if>
  120. <if test="townId != null">town_id,</if>
  121. <if test="town != null">town,</if>
  122. <if test="villageId != null">village_id,</if>
  123. <if test="village != null">village,</if>
  124. <if test="nowIn != null">now_in,</if>
  125. <if test="createBy != null">create_by,</if>
  126. <if test="updateBy != null">update_by,</if>
  127. <if test="updateTime != null">update_time,</if>
  128. <if test="status != null">status,</if>
  129. create_time
  130. </trim>
  131. <trim prefix="values (" suffix=")" suffixOverrides=",">
  132. <if test="czrkId != null">#{czrkId},</if>
  133. <if test="idCard != null">#{idCard},</if>
  134. <if test="userName != null">#{userName},</if>
  135. <if test="sort != null">#{sort},</if>
  136. <if test="deptId != null">#{deptId},</if>
  137. <if test="provinceId != null">#{provinceId},</if>
  138. <if test="province != null">#{province},</if>
  139. <if test="cityId != null">#{cityId},</if>
  140. <if test="city != null">#{city},</if>
  141. <if test="regionId != null">#{regionId},</if>
  142. <if test="region != null">#{region},</if>
  143. <if test="townId != null">#{townId},</if>
  144. <if test="town != null">#{town},</if>
  145. <if test="villageId != null">#{villageId},</if>
  146. <if test="village != null">#{village},</if>
  147. <if test="nowIn != null">#{nowIn},</if>
  148. <if test="createBy != null">#{createBy},</if>
  149. <if test="updateBy != null">#{updateBy},</if>
  150. <if test="updateTime != null">#{updateTime},</if>
  151. <if test="status != null">#{status},</if>
  152. sysdate()
  153. </trim>
  154. </insert>
  155. <update id="updateCzrkJzdz" >
  156. update czrk_jzdz
  157. <trim prefix="SET" suffixOverrides=",">
  158. <if test="czrkId != null">czrk_id = #{czrkId},</if>
  159. <if test="idCard != null">id_card = #{idCard},</if>
  160. <if test="userName != null">user_name = #{userName},</if>
  161. <if test="sort != null">sort = #{sort},</if>
  162. <if test="deptId != null">dept_id = #{deptId},</if>
  163. <if test="provinceId != null">province_id = #{provinceId},</if>
  164. <if test="province != null">province = #{province},</if>
  165. <if test="cityId != null">city_id = #{cityId},</if>
  166. <if test="city != null">city = #{city},</if>
  167. <if test="regionId != null">region_id = #{regionId},</if>
  168. <if test="region != null">region = #{region},</if>
  169. <if test="townId != null">town_id = #{townId},</if>
  170. <if test="town != null">town = #{town},</if>
  171. <if test="villageId != null">village_id = #{villageId},</if>
  172. <if test="village != null">village = #{village},</if>
  173. <if test="nowIn != null">now_in = #{nowIn},</if>
  174. <if test="createBy != null">create_by = #{createBy},</if>
  175. <if test="createTime != null">create_time = #{createTime},</if>
  176. <if test="updateBy != null">update_by = #{updateBy},</if>
  177. <if test="updateTime != null">update_time = sysdate(),</if>
  178. <if test="status != null">status = #{status},</if>
  179. </trim>
  180. where id = #{id}
  181. </update>
  182. <update id="updateByIdCard" >
  183. update czrk_jzdz
  184. <trim prefix="SET" suffixOverrides=",">
  185. <if test="czrkId != null">czrk_id = #{czrkId},</if>
  186. <if test="idCard != null">id_card = #{idCard},</if>
  187. <if test="userName != null">user_name = #{userName},</if>
  188. <if test="sort != null">sort = #{sort},</if>
  189. <if test="deptId != null">dept_id = #{deptId},</if>
  190. <if test="provinceId != null">province_id = #{provinceId},</if>
  191. <if test="province != null">province = #{province},</if>
  192. <if test="cityId != null">city_id = #{cityId},</if>
  193. <if test="city != null">city = #{city},</if>
  194. <if test="regionId != null">region_id = #{regionId},</if>
  195. <if test="region != null">region = #{region},</if>
  196. <if test="townId != null">town_id = #{townId},</if>
  197. <if test="town != null">town = #{town},</if>
  198. <if test="villageId != null">village_id = #{villageId},</if>
  199. <if test="village != null">village = #{village},</if>
  200. <if test="nowIn != null">now_in = #{nowIn},</if>
  201. <if test="createBy != null">create_by = #{createBy},</if>
  202. <if test="createTime != null">create_time = #{createTime},</if>
  203. <if test="updateBy != null">update_by = #{updateBy},</if>
  204. <if test="updateTime != null">update_time = sysdate(),</if>
  205. <if test="status != null">status = #{status},</if>
  206. </trim>
  207. where id_card = #{idCard}
  208. </update>
  209. <update id="updateByCzrkId" >
  210. update czrk_jzdz
  211. <trim prefix="SET" suffixOverrides=",">
  212. <if test="czrkId != null">czrk_id = #{czrkId},</if>
  213. <if test="idCard != null">id_card = #{idCard},</if>
  214. <if test="userName != null">user_name = #{userName},</if>
  215. <if test="sort != null">sort = #{sort},</if>
  216. <if test="deptId != null">dept_id = #{deptId},</if>
  217. <if test="provinceId != null">province_id = #{provinceId},</if>
  218. <if test="province != null">province = #{province},</if>
  219. <if test="cityId != null">city_id = #{cityId},</if>
  220. <if test="city != null">city = #{city},</if>
  221. <if test="regionId != null">region_id = #{regionId},</if>
  222. <if test="region != null">region = #{region},</if>
  223. <if test="townId != null">town_id = #{townId},</if>
  224. <if test="town != null">town = #{town},</if>
  225. <if test="villageId != null">village_id = #{villageId},</if>
  226. <if test="village != null">village = #{village},</if>
  227. <if test="nowIn != null">now_in = #{nowIn},</if>
  228. <if test="createBy != null">create_by = #{createBy},</if>
  229. <if test="createTime != null">create_time = #{createTime},</if>
  230. <if test="updateBy != null">update_by = #{updateBy},</if>
  231. <if test="updateTime != null">update_time = sysdate(),</if>
  232. <if test="status != null">status = #{status},</if>
  233. </trim>
  234. where czrk_id = #{czrkId}
  235. </update>
  236. <update id="updateHouseholdRegister">
  237. update czrk_jzdz
  238. set province_id = #{hzCzrkJzdz.provinceId},
  239. province = #{hzCzrkJzdz.province},
  240. city_id = #{hzCzrkJzdz.cityId},
  241. city = #{hzCzrkJzdz.city},
  242. region_id = #{hzCzrkJzdz.regionId},
  243. region = #{hzCzrkJzdz.region},
  244. town_id = #{hzCzrkJzdz.townId},
  245. town = #{hzCzrkJzdz.town},
  246. village_id = #{hzCzrkJzdz.villageId},
  247. village = #{hzCzrkJzdz.village},
  248. now_in = #{hzCzrkJzdz.nowIn}
  249. where id_card in
  250. <foreach item="idCard" collection="idCardList" open="(" separator="," close=")">
  251. #{idCard}
  252. </foreach>
  253. </update>
  254. <delete id="deleteCzrkJzdzById" parameterType="Long">
  255. delete from czrk_jzdz where id = #{id}
  256. </delete>
  257. <delete id="deleteByCzrkId" parameterType="Long">
  258. delete from czrk_jzdz where czrk_id = #{czrkId}
  259. </delete>
  260. <delete id="deleteCzrkJzdzByIds" parameterType="String">
  261. delete from czrk_jzdz where id in
  262. <foreach item="id" collection="array" open="(" separator="," close=")">
  263. #{id}
  264. </foreach>
  265. </delete>
  266. <select id="listCzrkIdByTypeAreaIdUserName" resultType="java.lang.Long">
  267. SELECT jzdz.czrk_id
  268. FROM czrk
  269. LEFT JOIN czrk_jzdz jzdz ON czrk.id = jzdz.czrk_id
  270. where czrk.is_del = 'N'
  271. <if test="userName != null and userName != ''">
  272. and jzdz.user_name like concat( #{userName}, '%')
  273. </if>
  274. <choose>
  275. <when test="type == 1">and jzdz.province_id = #{areaId}</when>
  276. <when test="type == 2">and jzdz.city_id = #{areaId}</when>
  277. <when test="type == 3">and jzdz.region_id = #{areaId}</when>
  278. <when test="type == 4">and jzdz.village_towns_id = #{areaId}</when>
  279. <when test="type == 5">and jzdz.village_id = #{areaId}</when>
  280. </choose>
  281. GROUP BY czrk.id
  282. </select>
  283. <select id="selectCzrkJzdzListPage" parameterType="Integer" resultMap="CzrkJzdzResult">
  284. select * from czrk_jzdz where village_id = '' and now_in != '' limit #{startNum}, #{endNum}
  285. </select>
  286. <select id="selectCzrkJzdzListByDeptId" resultMap="CzrkJzdzResult">
  287. select id, dept_id, create_time, status from czrk_jzdz
  288. where 1=1
  289. <if test="deptIdList != null and deptIdList.size() > 0">
  290. and dept_id in
  291. <foreach item="deptId" collection="deptIdList" open="(" separator="," close=")">
  292. #{deptId}
  293. </foreach>
  294. </if>
  295. </select>
  296. <select id="selectCzrkJzdzListByRegionId" resultMap="CzrkJzdzResult">
  297. SELECT
  298. MAX(ANY_VALUE(id)) as id,
  299. ANY_VALUE(dept_id) as dept_id,
  300. ANY_VALUE(region_id) as region_id,
  301. ANY_VALUE(region) as region,
  302. ANY_VALUE(town_id) as town_id,
  303. ANY_VALUE(town) as town,
  304. ANY_VALUE(village_id) as village_id,
  305. ANY_VALUE(village) as village,
  306. ANY_VALUE(create_time) as create_time,
  307. MAX(ANY_VALUE(update_time)) as update_time,
  308. ANY_VALUE(STATUS) as STATUS
  309. FROM
  310. czrk_jzdz
  311. where region_id = #{regionId}
  312. GROUP BY id_card
  313. </select>
  314. <select id="getCzrkJzdzByTime" resultMap="CzrkJzdzResult">
  315. select
  316. ANY_VALUE(id) as id,
  317. ANY_VALUE(czrk_id) as czrk_id,
  318. ANY_VALUE(id_card) as id_card,
  319. ANY_VALUE(user_name) as user_name,
  320. ANY_VALUE(sort) as sort,
  321. ANY_VALUE(dept_id) as dept_id,
  322. ANY_VALUE(province_id) as province_id,
  323. ANY_VALUE(province) as province,
  324. ANY_VALUE(city_id) as city_id,
  325. ANY_VALUE(city) as city,
  326. ANY_VALUE(region_id) as region_id,
  327. ANY_VALUE(region) as region,
  328. ANY_VALUE(town_id) as town_id,
  329. ANY_VALUE(town) as town,
  330. ANY_VALUE(village_id) as village_id,
  331. ANY_VALUE(village) as village,
  332. ANY_VALUE(now_in) as now_in,
  333. ANY_VALUE(create_by) as create_by,
  334. ANY_VALUE(create_time) as create_time,
  335. ANY_VALUE(update_by) as update_by,
  336. ANY_VALUE(update_time) as update_time,
  337. ANY_VALUE(status) as status
  338. from czrk_jzdz
  339. where 1=1 and status = #{status} and create_time &gt;= #{todayStartStr} and create_time &lt;= #{todayEndStr} and region_id = #{regionId}
  340. group by id_card
  341. </select>
  342. </mapper>