CzrkJzdzMapper.xml 19 KB

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