CzrkMapper.xml 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669
  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.CzrkMapper">
  6. <resultMap type="com.boman.domain.Czrk" id="CzrkResult">
  7. <result property="id" column="id" />
  8. <result property="userName" column="user_name" />
  9. <result property="gender" column="gender" />
  10. <result property="age" column="age" />
  11. <result property="birthday" column="birthday" />
  12. <result property="deptId" column="dept_id" />
  13. <result property="idCard" column="id_card" />
  14. <result property="phoneNum" column="phone_num" />
  15. <result property="code" column="code" />
  16. <result property="houseType" column="house_type" />
  17. <result property="rlr" column="rlr" />
  18. <result property="rlTime" column="rl_time" />
  19. <result property="keyIndustries" column="key_industries" />
  20. <result property="yhzgx" column="yhzgx" />
  21. <result property="workUnit" column="work_unit" />
  22. <result property="provinceId" column="province_id" />
  23. <result property="province" column="province" />
  24. <result property="cityId" column="city_id" />
  25. <result property="city" column="city" />
  26. <result property="regionId" column="region_id" />
  27. <result property="isRl" column="is_rl" />
  28. <result property="region" column="region" />
  29. <result property="villageTownsId" column="village_towns_id" />
  30. <result property="villageTowns" column="village_towns" />
  31. <result property="villageId" column="village_id" />
  32. <result property="village" column="village" />
  33. <result property="villagerGroupId" column="villager_group_id" />
  34. <result property="villagerGroup" column="villager_group" />
  35. <result property="nowIn" column="now_in" />
  36. <result property="remark" column="remark" />
  37. <result property="gridId" column="grid_id" />
  38. <result property="status" column="status" />
  39. <result property="createBy" column="create_by" />
  40. <result property="createTime" column="create_time" />
  41. <result property="updateBy" column="update_by" />
  42. <result property="updateTime" column="update_time" />
  43. <result property="isDel" column="is_del" />
  44. <result property="deleteReason" column="delete_reason" />
  45. <collection property="czrkJzdzList" javaType="java.util.List" resultMap="CzrkJzdzResult" />
  46. </resultMap>
  47. <resultMap type="com.boman.domain.CzrkJzdz" id="CzrkJzdzResult">
  48. <result property="provinceId" column="province_id_jzdz" />
  49. <result property="province" column="province_jzdz" />
  50. <result property="cityId" column="city_id_jzdz" />
  51. <result property="city" column="city_jzdz" />
  52. <result property="regionId" column="region_id_jzdz" />
  53. <result property="region" column="region_jzdz" />
  54. <result property="townId" column="town_id_jzdz" />
  55. <result property="town" column="town_jzdz" />
  56. <result property="villageId" column="village_id_jzdz" />
  57. <result property="village" column="village_jzdz" />
  58. <result property="nowIn" column="now_in_jzdz" />
  59. </resultMap>
  60. <sql id="selectCzrkVo">
  61. select id, user_name, gender, age, birthday,dept_id, id_card, phone_num, code, house_type, rlr, rl_time, yhzgx
  62. , work_unit, province_id, province, city_id, city, region_id, region, village_towns_id, village_towns
  63. , village_id, village, villager_group_id, villager_group, now_in, remark,grid_id, status, create_by, create_time
  64. , update_by, update_time, is_del, delete_reason, dept_id, is_rl, key_industries from czrk
  65. </sql>
  66. <select id="listByRlry" resultMap="CzrkResult">
  67. select id, user_name, phone_num,dept_id, id_card, gender, province, city, region,grid_id
  68. , house_type, update_by, code, rlr, update_time, delete_reason, now_in
  69. from czrk
  70. <where>
  71. <!-- 已认领 -->
  72. <if test="isRl != null and isRl != ''">and is_rl = #{isRl}</if>
  73. <if test="userName != null and userName != ''">
  74. and (user_name like concat('%', #{userName}, '%') or id_card like concat('%', #{userName}, '%'))
  75. </if>
  76. <if test="params.startAge != null and params.startAge != ''">and age &gt;= #{params.startAge}</if>
  77. <if test="params.endAge != null and params.endAge != ''">and age &lt;= #{params.endAge}</if>
  78. <if test="gender != null and gender != ''"> and gender = #{gender}</if>
  79. <if test="age != null "> and age = #{age}</if>
  80. <if test="birthday != null "> and birthday = #{birthday}</if>
  81. <if test="idCard != null and idCard != ''"> and id_card = #{idCard}</if>
  82. <if test="phoneNum != null and phoneNum != ''"> and phone_num = #{phoneNum}</if>
  83. <if test="code != null and code != ''"> and code = #{code}</if>
  84. <if test="houseType != null and houseType != ''"> and house_type = #{houseType}</if>
  85. <if test="rlr != null and rlr != ''"> and rlr = #{rlr}</if>
  86. <if test="rlTime != null "> and rl_time = #{rlTime}</if>
  87. <if test="yhzgx != null and yhzgx != ''"> and yhzgx = #{yhzgx}</if>
  88. <if test="workUnit != null and workUnit != ''"> and work_unit = #{workUnit}</if>
  89. <if test="provinceId != null and provinceId != ''"> and province_id = #{provinceId}</if>
  90. <if test="province != null and province != ''"> and province = #{province}</if>
  91. <if test="cityId != null and cityId != ''"> and city_id = #{cityId}</if>
  92. <if test="city != null and city != ''"> and city = #{city}</if>
  93. <if test="regionId != null and regionId != ''"> and region_id = #{regionId}</if>
  94. <if test="region != null and region != ''"> and region = #{region}</if>
  95. <if test="villageTownsId != null and villageTownsId != ''"> and village_towns_id = #{villageTownsId}</if>
  96. <if test="villageTowns != null and villageTowns != ''"> and village_towns = #{villageTowns}</if>
  97. <if test="villageId != null and villageId != ''"> and village_id = #{villageId}</if>
  98. <if test="village != null and village != ''"> and village = #{village}</if>
  99. <if test="villagerGroupId != null and villagerGroupId != ''"> and villager_group_id = #{villagerGroupId}</if>
  100. <if test="villagerGroup != null and villagerGroup != ''"> and villager_group = #{villagerGroup}</if>
  101. <if test="nowIn != null and nowIn != ''"> and now_in = #{nowIn}</if>
  102. <if test="status != null and status != ''"> and status = #{status}</if>
  103. <if test="isDel != null and isDel != ''"> and is_del = #{isDel}</if>
  104. <if test="deleteReason != null and deleteReason != ''"> and delete_reason = #{deleteReason}</if>
  105. <if test="gridId != null and gridId != ''"> and grid_id = #{gridId}</if>
  106. <if test="deptIdList != null and deptIdList.size() > 0">
  107. and dept_id in
  108. <foreach item="deptId" collection="deptIdList" open="(" separator="," close=")">
  109. #{deptId}
  110. </foreach>
  111. </if>
  112. </where>
  113. order by create_time DESC
  114. </select>
  115. <select id="listByRlryRel" resultType="com.boman.domain.Czrk">
  116. SELECT
  117. czrk.id,
  118. ANY_VALUE(czrk.user_name) userName,
  119. ANY_VALUE(czrk.phone_num) phoneNum,
  120. ANY_VALUE(czrk.id_card) idCard,
  121. ANY_VALUE(czrk.gender),
  122. ANY_VALUE(czrk.province),
  123. ANY_VALUE(czrk.is_rl),
  124. ANY_VALUE(czrk.city),
  125. ANY_VALUE(czrk.region),
  126. ANY_VALUE(czrk.house_type) houseType,
  127. ANY_VALUE(czrk.update_by) updateBy,
  128. ANY_VALUE(czrk. CODE),
  129. ANY_VALUE(czrk.rlr),
  130. ANY_VALUE(czrk.update_time) updateTime,
  131. ANY_VALUE(czrk.delete_reason) deleteReason,
  132. ANY_VALUE(czrk.now_in) nowIn,
  133. ANY_VALUE(jzdz.province) provinceXjd,
  134. ANY_VALUE(jzdz.city) cityXjd,
  135. ANY_VALUE(jzdz.region) regionXjd,
  136. ANY_VALUE(jzdz.town) villageTownsXjd,
  137. ANY_VALUE(jzdz.village) villageXjd,
  138. ANY_VALUE(jzdz.now_in) domicile
  139. from czrk
  140. left join czrk_jzdz jzdz on czrk.id = jzdz.czrk_id
  141. <where>
  142. <!-- 已认领 -->
  143. <if test="isRl != null and isRl != ''">and czrk.is_rl = #{isRl}</if>
  144. <if test="userName != null and userName != ''">
  145. and (czrk.user_name like concat('%', #{userName}, '%') or czrk.id_card like concat('%', #{userName}, '%'))
  146. </if>
  147. <if test="params.startAge != null and params.startAge != ''">and czrk.age &gt;= #{params.startAge}</if>
  148. <if test="params.endAge != null and params.endAge != ''">and czrk.age &lt;= #{params.endAge}</if>
  149. <if test="gender != null and gender != ''"> and czrk.gender = #{gender}</if>
  150. <if test="age != null "> and czrk.age = #{age}</if>
  151. <if test="birthday != null "> and czrk.birthday = #{birthday}</if>
  152. <if test="idCard != null and idCard != ''"> and czrk.id_card = #{idCard}</if>
  153. <if test="phoneNum != null and phoneNum != ''"> and czrk.phone_num = #{phoneNum}</if>
  154. <if test="code != null and code != ''"> and czrk.code = #{code}</if>
  155. <if test="houseType != null and houseType != ''"> and czrk.house_type = #{houseType}</if>
  156. <if test="rlr != null and rlr != ''"> and czrk.rlr = #{rlr}</if>
  157. <if test="rlTime != null "> and czrk.rl_time = #{rlTime}</if>
  158. <if test="yhzgx != null and yhzgx != ''"> and czrk.yhzgx = #{yhzgx}</if>
  159. <if test="workUnit != null and workUnit != ''"> and czrk.work_unit = #{workUnit}</if>
  160. <if test="provinceId != null and provinceId != ''"> and czrk.province_id = #{provinceId}</if>
  161. <if test="provinceIdXjd != null and provinceIdXjd != ''"> and jzdz.province_id = #{provinceId}</if>
  162. <if test="cityIdXjd != null and cityIdXjd != ''"> and jzdz.city_id = #{cityIdXjd}</if>
  163. <if test="regionIdXjd != null and regionIdXjd != ''"> and jzdz.region_id = #{regionIdXjd}</if>
  164. <if test="villageTownsIdXjd != null and villageTownsIdXjd != ''"> and jzdz.town_id = #{villageTownsIdXjd}</if>
  165. <if test="villageIdXjd != null and villageIdXjd != ''"> and jzdz.village_id = #{villageIdXjd}</if>
  166. <if test="province != null and province != ''"> and czrk.province = #{province}</if>
  167. <if test="cityId != null and cityId != ''"> and czrk.city_id = #{cityId}</if>
  168. <if test="city != null and city != ''"> and czrk.city = #{city}</if>
  169. <if test="regionId != null and regionId != ''"> and czrk.region_id = #{regionId}</if>
  170. <if test="region != null and region != ''"> and czrk.region = #{region}</if>
  171. <if test="villageTownsId != null and villageTownsId != ''"> and czrk.village_towns_id = #{villageTownsId}</if>
  172. <if test="villageTowns != null and villageTowns != ''"> and czrk.village_towns = #{villageTowns}</if>
  173. <if test="villageId != null and villageId != ''"> and czrk.village_id = #{villageId}</if>
  174. <if test="village != null and village != ''"> and czrk.village = #{village}</if>
  175. <if test="villagerGroupId != null and villagerGroupId != ''"> and czrk.villager_group_id = #{villagerGroupId}</if>
  176. <if test="villagerGroup != null and villagerGroup != ''"> and czrk.villager_group = #{villagerGroup}</if>
  177. <if test="nowIn != null and nowIn != ''"> and czrk.now_in = #{nowIn}</if>
  178. <if test="status != null and status != ''"> and czrk.status = #{status}</if>
  179. <if test="isDel != null and isDel != ''"> and czrk.is_del = #{isDel}</if>
  180. <if test="deleteReason != null and deleteReason != ''"> and czrk.delete_reason = #{deleteReason}</if>
  181. <if test="gridId != null and gridId != ''"> and czrk.grid_id = #{gridId}</if>
  182. <if test="deptIdList != null and deptIdList.size() > 0">
  183. and czrk.dept_id in
  184. <foreach item="deptId" collection="deptIdList" open="(" separator="," close=")">
  185. #{deptId}
  186. </foreach>
  187. </if>
  188. </where>
  189. GROUP BY czrk.id ORDER BY czrk.update_time DESC
  190. </select>
  191. <select id="listByXz" resultMap="CzrkResult">
  192. select vi.id, vi.create_time, vi.update_time, vi.is_del, vi.update_by, vi.user_name, vi.phone_num, vi.id_card
  193. , vi.gender, vi.province, vi.city, vi.region, vi.now_in, vi.house_type, vi.update_by, vi.code
  194. from czrk vi
  195. where vi.is_del = 'N' and vi.create_time &gt;= #{startTime} and vi.create_time &lt;= #{endTime}
  196. <if test="userName != null and userName != ''">
  197. and (vi.user_name like concat('%', #{userName}, '%') or vi.id_card like concat('%', #{userName}, '%'))
  198. </if>
  199. <if test="villageTowns != null and villageTowns != ''">
  200. and vi.village_towns = #{villageTowns}
  201. </if>
  202. <if test="village != null and village != ''"> and vi.village = #{village}</if>
  203. <if test="villagerGroup != null and villagerGroup != ''"> and vi.villager_group = #{villagerGroup}</if>
  204. <if test="houseType != null and houseType != ''"> and vi.house_type = #{houseType}</if>
  205. <if test="province != null and province != ''"> and vi.province = #{province}</if>
  206. <if test="city != null and city != ''"> and vi.city = #{city}</if>
  207. <if test="region != null and region != ''"> and vi.region = #{region}</if>
  208. <if test="gender != null and gender != ''"> and vi.gender = #{gender}</if>
  209. <if test="idCard != null and idCard != ''"> and vi.id_card like concat('%', #{idCard}, '%')</if>
  210. <if test="phoneNum != null and phoneNum != ''"> and vi.phone_num = #{phoneNum}</if>
  211. <!--<if test="params.startAge != null and params.startAge != ''"> and vi.age &gt;= #{params.startAge}</if>
  212. <if test="params.endAge != null and params.endAge != ''"> and vi.age &lt;= #{params.endAge}</if>-->
  213. <if test="status != null and status != ''"> and vi.status = #{status}</if>
  214. <if test="code != null and code != ''"> and vi.code = #{code}</if>
  215. <if test="birthday != null and birthday != ''"> and vi.birthday = #{birthday}</if>
  216. <if test="workUnit != null and workUnit != ''"> and vi.work_unit = #{workUnit}</if>
  217. <if test="nowIn != null and nowIn != ''"> and vi.now_in = #{nowIn}</if>
  218. <if test="gridId != null and gridId != ''"> and vi.grid_id = #{gridId}</if>
  219. <if test="deptIdList != null and deptIdList.size() > 0">
  220. and vi.dept_id in
  221. <foreach item="deptId" collection="deptIdList" open="(" separator="," close=")">
  222. #{deptId}
  223. </foreach>
  224. </if>
  225. </select>
  226. <select id="countByCzXz" resultType="int">
  227. select count(1)
  228. from czrk vi
  229. where vi.is_del = 'N' and vi.create_time &gt;= #{startTime} and vi.create_time &lt;= #{endTime}
  230. <choose>
  231. <when test="type == 1">and vi.province_id = #{areaId}</when>
  232. <when test="type == 2">and vi.city_id = #{areaId}</when>
  233. <when test="type == 3">and vi.region_id = #{areaId}</when>
  234. <when test="type == 4">and vi.village_towns_id = #{areaId}</when>
  235. <when test="type == 5">and vi.village_id = #{areaId}</when>
  236. </choose>
  237. </select>
  238. <select id="listByCzXz" resultMap="CzrkResult">
  239. select vi.id, vi.create_time
  240. from czrk vi
  241. where vi.is_del = 'N' and vi.create_time &gt;= #{startTime} and vi.create_time &lt;= #{endTime}
  242. <choose>
  243. <when test="type == 1">and vi.province_id = #{areaId}</when>
  244. <when test="type == 2">and vi.city_id = #{areaId}</when>
  245. <when test="type == 3">and vi.region_id = #{areaId}</when>
  246. <when test="type == 4">and vi.village_towns_id = #{areaId}</when>
  247. <when test="type == 5">and vi.village_id = #{areaId}</when>
  248. </choose>
  249. </select>
  250. <select id="listByJs" resultMap="CzrkResult">
  251. select vi.id, vi.create_time, vi.update_time, vi.is_del, vi.update_by, vi.user_name, vi.phone_num, vi.id_card
  252. , vi.gender, vi.province, vi.city, vi.region, vi.now_in, vi.house_type, vi.update_by, vi.code
  253. from czrk vi
  254. where vi.is_del = 'Y' and vi.update_time &gt;= #{startTime} and vi.update_time &lt;= #{endTime}
  255. <if test="userName != null and userName != ''">
  256. and (vi.user_name like concat('%', #{userName}, '%') or vi.id_card like concat('%', #{userName}, '%'))
  257. </if>
  258. <if test="villageTowns != null and villageTowns != ''">
  259. and vi.village_towns = #{villageTowns}
  260. </if>
  261. <if test="village != null and village != ''"> and vi.village = #{village}</if>
  262. <if test="villagerGroup != null and villagerGroup != ''"> and vi.villager_group = #{villagerGroup}</if>
  263. <if test="houseType != null and houseType != ''"> and vi.house_type = #{houseType}</if>
  264. <if test="province != null and province != ''"> and vi.province = #{province}</if>
  265. <if test="city != null and city != ''"> and vi.city = #{city}</if>
  266. <if test="region != null and region != ''"> and vi.region = #{region}</if>
  267. <if test="userName != null and userName != ''"> and vi.user_name like concat('%', #{userName}, '%')</if>
  268. <if test="gender != null and gender != ''"> and vi.gender = #{gender}</if>
  269. <if test="idCard != null and idCard != ''"> and vi.id_card like concat('%', #{idCard}, '%')</if>
  270. <if test="phoneNum != null and phoneNum != ''"> and vi.phone_num = #{phoneNum}</if>
  271. <!--<if test="params.startAge != null and params.startAge != ''"> and vi.age &gt;= #{params.startAge}</if>
  272. <if test="params.endAge != null and params.endAge != ''"> and vi.age &lt;= #{params.endAge}</if>-->
  273. <if test="status != null and status != ''"> and vi.status = #{status}</if>
  274. <if test="code != null and code != ''"> and vi.code = #{code}</if>
  275. <if test="birthday != null and birthday != ''"> and vi.birthday = #{birthday}</if>
  276. <if test="workUnit != null and workUnit != ''"> and vi.work_unit = #{workUnit}</if>
  277. <if test="nowIn != null and nowIn != ''"> and vi.now_in = #{nowIn}</if>
  278. <if test="gridId != null and gridId != ''"> and vi.grid_id = #{gridId}</if>
  279. <if test="deptIdList != null and deptIdList.size() > 0">
  280. and vi.dept_id in
  281. <foreach item="deptId" collection="deptIdList" open="(" separator="," close=")">
  282. #{deptId}
  283. </foreach>
  284. </if>
  285. </select>
  286. <select id="countByCzJs" resultType="int">
  287. select count(1)
  288. from czrk vi
  289. where vi.is_del = 'Y' and vi.update_time &gt;= #{startTime} and vi.update_time &lt;= #{endTime}
  290. <choose>
  291. <when test="type == 1">and vi.province_id = #{areaId}</when>
  292. <when test="type == 2">and vi.city_id = #{areaId}</when>
  293. <when test="type == 3">and vi.region_id = #{areaId}</when>
  294. <when test="type == 4">and vi.village_towns_id = #{areaId}</when>
  295. <when test="type == 5">and vi.village_id = #{areaId}</when>
  296. </choose>
  297. </select>
  298. <select id="listByCzJs" resultMap="CzrkResult">
  299. select vi.id, vi.update_time
  300. from czrk vi
  301. where vi.is_del = 'Y' and vi.update_time &gt;= #{startTime} and vi.update_time &lt;= #{endTime}
  302. <choose>
  303. <when test="type == 1">and vi.province_id = #{areaId}</when>
  304. <when test="type == 2">and vi.city_id = #{areaId}</when>
  305. <when test="type == 3">and vi.region_id = #{areaId}</when>
  306. <when test="type == 4">and vi.village_towns_id = #{areaId}</when>
  307. <when test="type == 5">and vi.village_id = #{areaId}</when>
  308. </choose>
  309. </select>
  310. <select id="listByCode" resultMap="CzrkResult">
  311. select vi.id, vi.user_name, vi.phone_num, vi.id_card, vi.gender, vi.province, vi.city, vi.region, vi.now_in
  312. , vi.house_type, vi.update_by, vi.code, vi.rlr, vi.yhzgx
  313. from czrk vi
  314. <!--把户主放第一位-->
  315. where vi.is_del = 'N' and code = #{code} order by house_type desc;
  316. </select>
  317. <select id="countCzrk" resultType="int">
  318. select count(vi.id)
  319. from czrk vi
  320. where vi.is_del = 'N'
  321. <choose>
  322. <when test="type == 1">and vi.province_id = #{areaId}</when>
  323. <when test="type == 2">and vi.city_id = #{areaId}</when>
  324. <when test="type == 3">and vi.region_id = #{areaId}</when>
  325. <when test="type == 4">and vi.village_towns_id = #{areaId}</when>
  326. <when test="type == 5">and vi.village_id = #{areaId}</when>
  327. </choose>
  328. </select>
  329. <select id="selectCzrkById" parameterType="Long" resultMap="CzrkResult">
  330. <include refid="selectCzrkVo"/>
  331. where id = #{id} limit 1
  332. </select>
  333. <select id="countIdCard" resultType="int">
  334. select count(vi.id) from czrk vi where vi.is_del = 'N' and id_card = #{idCard}
  335. </select>
  336. <select id="stsByYrl" resultType="int">
  337. select count(vi.id)
  338. from czrk vi
  339. where vi.is_del = 'N'
  340. <!-- 已认领 -->
  341. and vi.is_rl = '是'
  342. <if test="userName != null and userName != ''">
  343. and (vi.user_name like concat('%', #{userName}, '%') or vi.id_card like concat('%', #{userName}, '%'))
  344. </if>
  345. <choose>
  346. <when test="type == 1">and vi.province_id = #{areaId}</when>
  347. <when test="type == 2">and vi.city_id = #{areaId}</when>
  348. <when test="type == 3">and vi.region_id = #{areaId}</when>
  349. <when test="type == 4">and vi.village_towns_id = #{areaId}</when>
  350. <when test="type == 5">and vi.village_id = #{areaId}</when>
  351. </choose>
  352. </select>
  353. <select id="listIsRl" resultMap="CzrkResult">
  354. SELECT id, is_rl
  355. from czrk
  356. where is_del = 'N'
  357. <if test="userName != null and userName != ''">
  358. and user_name like concat('%', #{userName}, '%')
  359. </if>
  360. <choose>
  361. <when test="type == 1">and province_id = #{areaId}</when>
  362. <when test="type == 2">and city_id = #{areaId}</when>
  363. <when test="type == 3">and region_id = #{areaId}</when>
  364. <when test="type == 4">and village_towns_id = #{areaId}</when>
  365. <when test="type == 5">and village_id = #{areaId}</when>
  366. </choose>
  367. </select>
  368. <select id="stsByWrl" resultType="int">
  369. select count(vi.id)
  370. from czrk vi
  371. where vi.is_del = 'N'
  372. <!-- 未认领 -->
  373. and vi.is_rl = '否'
  374. <if test="userName != null and userName != ''">
  375. and (vi.user_name like concat('%', #{userName}, '%') or vi.id_card like concat('%', #{userName}, '%'))
  376. </if>
  377. <choose>
  378. <when test="type == 1">and vi.province_id = #{areaId}</when>
  379. <when test="type == 2">and vi.city_id = #{areaId}</when>
  380. <when test="type == 3">and vi.region_id = #{areaId}</when>
  381. <when test="type == 4">and vi.village_towns_id = #{areaId}</when>
  382. <when test="type == 5">and vi.village_id = #{areaId}</when>
  383. </choose>
  384. </select>
  385. <insert id="insertCzrk" useGeneratedKeys="true" keyProperty="id">
  386. insert into czrk
  387. <trim prefix="(" suffix=")" suffixOverrides=",">
  388. <if test="userName != null">user_name,</if>
  389. <if test="gender != null">gender,</if>
  390. <if test="age != null">age,</if>
  391. <if test="birthday != null">birthday,</if>
  392. <if test="deptId != null">dept_id,</if>
  393. <if test="idCard != null">id_card,</if>
  394. <if test="phoneNum != null">phone_num,</if>
  395. <if test="code != null">code,</if>
  396. <if test="keyIndustries != null">key_Industries,</if>
  397. <if test="houseType != null">house_type,</if>
  398. <if test="rlr != null">rlr,</if>
  399. <if test="rlTime != null">rl_time,</if>
  400. <if test="yhzgx != null">yhzgx,</if>
  401. <if test="workUnit != null">work_unit,</if>
  402. <if test="provinceId != null">province_id,</if>
  403. <if test="province != null">province,</if>
  404. <if test="cityId != null">city_id,</if>
  405. <if test="city != null">city,</if>
  406. <if test="regionId != null">region_id,</if>
  407. <if test="region != null">region,</if>
  408. <if test="villageTownsId != null">village_towns_id,</if>
  409. <if test="villageTowns != null">village_towns,</if>
  410. <if test="villageId != null">village_id,</if>
  411. <if test="village != null">village,</if>
  412. <if test="villagerGroupId != null">villager_group_id,</if>
  413. <if test="villagerGroup != null">villager_group,</if>
  414. <if test="nowIn != null">now_in,</if>
  415. <if test="remark != null">remark,</if>
  416. <if test="gridId != null">grid_id,</if>
  417. <if test="status != null">status,</if>
  418. <if test="createBy != null">create_by,</if>
  419. <if test="updateBy != null">update_by,</if>
  420. <if test="isDel != null and isDel != ''">is_del,</if>
  421. <if test="deleteReason != null">delete_reason,</if>
  422. create_time, update_time
  423. </trim>
  424. <trim prefix="values (" suffix=")" suffixOverrides=",">
  425. <if test="userName != null">#{userName},</if>
  426. <if test="gender != null">#{gender},</if>
  427. <if test="age != null">#{age},</if>
  428. <if test="birthday != null">#{birthday},</if>
  429. <if test="deptId != null">#{deptId},</if>
  430. <if test="idCard != null">#{idCard},</if>
  431. <if test="phoneNum != null">#{phoneNum},</if>
  432. <if test="code != null">#{code},</if>
  433. <if test="keyIndustries != null">#{keyIndustries},</if>
  434. <if test="houseType != null">#{houseType},</if>
  435. <if test="rlr != null">#{rlr},</if>
  436. <if test="rlTime != null">#{rlTime},</if>
  437. <if test="yhzgx != null">#{yhzgx},</if>
  438. <if test="workUnit != null">#{workUnit},</if>
  439. <if test="provinceId != null">#{provinceId},</if>
  440. <if test="province != null">#{province},</if>
  441. <if test="cityId != null">#{cityId},</if>
  442. <if test="city != null">#{city},</if>
  443. <if test="regionId != null">#{regionId},</if>
  444. <if test="region != null">#{region},</if>
  445. <if test="villageTownsId != null">#{villageTownsId},</if>
  446. <if test="villageTowns != null">#{villageTowns},</if>
  447. <if test="villageId != null">#{villageId},</if>
  448. <if test="village != null">#{village},</if>
  449. <if test="villagerGroupId != null">#{villagerGroupId},</if>
  450. <if test="villagerGroup != null">#{villagerGroup},</if>
  451. <if test="nowIn != null">#{nowIn},</if>
  452. <if test="remark != null">#{remark},</if>
  453. <if test="gridId != null">#{gridId},</if>
  454. <if test="status != null">#{status},</if>
  455. <if test="createBy != null">#{createBy},</if>
  456. <if test="updateBy != null">#{updateBy},</if>
  457. <if test="isDel != null and isDel != ''">#{isDel},</if>
  458. <if test="deleteReason != null">#{deleteReason},</if>
  459. sysdate(), sysdate()
  460. </trim>
  461. </insert>
  462. <update id="updateCzrk" >
  463. update czrk
  464. <trim prefix="SET" suffixOverrides=",">
  465. <if test="userName != null">user_name = #{userName},</if>
  466. <if test="gender != null">gender = #{gender},</if>
  467. <if test="age != null">age = #{age},</if>
  468. <if test="birthday != null">birthday = #{birthday},</if>
  469. <if test="idCard != null">id_card = #{idCard},</if>
  470. <if test="phoneNum != null">phone_num = #{phoneNum},</if>
  471. <if test="code != null">code = #{code},</if>
  472. <if test="keyIndustries != null">key_industries = #{keyIndustries},</if>
  473. <if test="houseType != null">house_type = #{houseType},</if>
  474. <if test="rlr != null">rlr = #{rlr},</if>
  475. <if test="rlTime != null">rl_time = #{rlTime},</if>
  476. <if test="yhzgx != null">yhzgx = #{yhzgx},</if>
  477. <if test="workUnit != null">work_unit = #{workUnit},</if>
  478. <if test="provinceId != null">province_id = #{provinceId},</if>
  479. <if test="province != null">province = #{province},</if>
  480. <if test="cityId != null">city_id = #{cityId},</if>
  481. <if test="city != null">city = #{city},</if>
  482. <if test="regionId != null">region_id = #{regionId},</if>
  483. <if test="region != null">region = #{region},</if>
  484. <if test="villageTownsId != null">village_towns_id = #{villageTownsId},</if>
  485. <if test="villageTowns != null">village_towns = #{villageTowns},</if>
  486. <if test="villageId != null">village_id = #{villageId},</if>
  487. <if test="village != null">village = #{village},</if>
  488. <if test="villagerGroupId != null">villager_group_id = #{villagerGroupId},</if>
  489. <if test="villagerGroup != null">villager_group = #{villagerGroup},</if>
  490. <if test="nowIn != null">now_in = #{nowIn},</if>
  491. <if test="remark != null">remark = #{remark},</if>
  492. <if test="gridId != null">grid_id = #{gridId},</if>
  493. <if test="status != null">status = #{status},</if>
  494. <if test="createBy != null">create_by = #{createBy},</if>
  495. <if test="createTime != null">create_time = #{createTime},</if>
  496. <if test="updateBy != null">update_by = #{updateBy},</if>
  497. <if test="updateTime != null">update_time = sysdate(),</if>
  498. <if test="isDel != null and isDel != ''">is_del = #{isDel},</if>
  499. <if test="deleteReason != null">delete_reason = #{deleteReason},</if>
  500. </trim>
  501. where id = #{id}
  502. </update>
  503. <delete id="deleteCzrkById" parameterType="Long">
  504. delete from czrk where id = #{id}
  505. </delete>
  506. <update id="reduction">
  507. update czrk
  508. set is_del = 'N'
  509. , update_by = #{updateBy}
  510. , update_time = sysdate()
  511. where id = #{id}
  512. </update>
  513. <!-- <delete id="deleteCzrk" parameterType="String">-->
  514. <!-- delete from czrk where id in -->
  515. <!-- <foreach item="id" collection="array" open="(" separator="," close=")">-->
  516. <!-- #{id}-->
  517. <!-- </foreach>-->
  518. <!-- </delete>-->
  519. <update id="deleteCzrk">
  520. update czrk
  521. set is_del = 'Y'
  522. , delete_reason = #{deleteReason}
  523. , update_by = #{updateBy}
  524. , update_time = sysdate()
  525. where id = #{id}
  526. </update>
  527. <select id="findHjInfo" resultMap="CzrkResult">
  528. select c.id, c.user_name ,c.gender, c.birthday,c.age,c.code,c.phone_num,c.key_industries,c.province_id,c.province,c.city_id,c.city,c.region_id,c.region,c.village_towns_id,c.village_towns,c.village_id,c.village,c.villager_group_id,c.villager_group,
  529. c.now_in,c.house_type,c.code,c.yhzgx,c.remark,
  530. cj.province_id as province_id_jzdz,cj.province as province_jzdz,cj.city_id as city_id_jzdz,cj.city as city_jzdz,cj.region_id as region_id_jzdz,cj.region as region_jzdz,cj.town_id as town_id_jzdz,cj.town as town_jzdz,cj.village_id as village_id_jzdz,cj.village as village_jzdz,cj.now_in as now_in_jzdz
  531. from czrk c left join czrk_jzdz cj on c.id_card = cj.id_card
  532. <where>
  533. c.is_del = 'N'
  534. and cj.status = 'Y'
  535. <if test="idCard != null and idCard != '' "> and c.id_card = #{idCard}</if>
  536. </where>
  537. </select>
  538. <select id="stsByAppletCz" resultMap="CzrkResult">
  539. SELECT
  540. czrk.id,
  541. czrk.is_rl
  542. from czrk
  543. left join czrk_jzdz jzdz on czrk.id = jzdz.czrk_id
  544. <where>
  545. czrk.is_del = 'N'
  546. <if test="userName != null and userName != ''">
  547. and (czrk.user_name like concat('%', #{userName}, '%') or czrk.id_card like concat('%', #{userName}, '%'))
  548. </if>
  549. <choose>
  550. <when test="type == 1">and jzdz.province_id = #{areaId}</when>
  551. <when test="type == 2">and jzdz.city_id = #{areaId}</when>
  552. <when test="type == 3">and jzdz.region_id = #{areaId}</when>
  553. <when test="type == 4">and jzdz.town_id = #{areaId}</when>
  554. <when test="type == 5">and jzdz.village_id = #{areaId}</when>
  555. </choose>
  556. <!-- <if test="provinceIdXjd != null and provinceIdXjd != ''"> and jzdz.province_id = #{areaId}</if>
  557. <if test="cityIdXjd != null and cityIdXjd != ''"> and jzdz.city_id = #{areaId}</if>
  558. <if test="regionIdXjd != null and regionIdXjd != ''"> and jzdz.region_id = #{areaId}</if>
  559. <if test="villageTownsIdXjd != null and villageTownsIdXjd != ''"> and jzdz.town_id = #{areaId}</if>
  560. <if test="villageIdXjd != null and villageIdXjd != ''"> and jzdz.village_id = #{areaId}</if>-->
  561. <!-- <if test="provinceId != null and provinceId != ''"> and czrk.province_id = #{areaId}</if>
  562. <if test="cityId != null and cityId != ''"> and czrk.city_id = #{areaId}</if>
  563. <if test="regionId != null and regionId != ''"> and czrk.region_id = #{areaId}</if>
  564. <if test="villageTownsId != null and villageTownsId != ''"> and czrk.village_towns_id = #{areaId}</if>
  565. <if test="villageId != null and villageId != ''"> and czrk.village_id = #{areaId}</if>
  566. <if test="villagerGroupId != null and villagerGroupId != ''"> and czrk.villager_group_id = #{villagerGroupId}</if>-->
  567. </where>
  568. GROUP BY czrk.id
  569. </select>
  570. <select id="countByHjXz" resultMap="CzrkResult">
  571. SELECT czrk.id, czrk.create_time
  572. from czrk
  573. left join czrk_jzdz jzdz on czrk.id = jzdz.czrk_id
  574. where czrk.is_del = 'N' and czrk.create_time &gt;= #{startTime} and czrk.create_time &lt;= #{endTime}
  575. <!-- <if test="userName != null and userName != ''">
  576. and (czrk.user_name like concat('%', #{userName}, '%') or czrk.id_card like concat('%', #{userName}, '%'))
  577. </if>-->
  578. <choose>
  579. <when test="type == 1">and jzdz.province_id = #{areaId}</when>
  580. <when test="type == 2">and jzdz.city_id = #{areaId}</when>
  581. <when test="type == 3">and jzdz.region_id = #{areaId}</when>
  582. <when test="type == 4">and jzdz.town_id = #{areaId}</when>
  583. <when test="type == 5">and jzdz.village_id = #{areaId}</when>
  584. </choose>
  585. GROUP BY czrk.id
  586. </select>
  587. <select id="countByHjJs" resultMap="CzrkResult">
  588. SELECT czrk.id, czrk.update_time
  589. from czrk
  590. left join czrk_jzdz jzdz on czrk.id = jzdz.czrk_id
  591. where czrk.is_del = 'Y' and czrk.update_time &gt;= #{startTime} and czrk.update_time &lt;= #{endTime}
  592. <!-- <if test="userName != null and userName != ''">
  593. and (czrk.user_name like concat('%', #{userName}, '%') or czrk.id_card like concat('%', #{userName}, '%'))
  594. </if>-->
  595. <choose>
  596. <when test="type == 1">and jzdz.province_id = #{areaId}</when>
  597. <when test="type == 2">and jzdz.city_id = #{areaId}</when>
  598. <when test="type == 3">and jzdz.region_id = #{areaId}</when>
  599. <when test="type == 4">and jzdz.town_id = #{areaId}</when>
  600. <when test="type == 5">and jzdz.village_id = #{areaId}</when>
  601. </choose>
  602. GROUP BY czrk.id
  603. </select>
  604. <select id="countHj" resultMap="CzrkResult">
  605. SELECT czrk.id
  606. from czrk
  607. left join czrk_jzdz jzdz on czrk.id = jzdz.czrk_id
  608. where czrk.is_del = 'N'
  609. <!--<if test="userName != null and userName != ''">
  610. and (czrk.user_name like concat('%', #{userName}, '%') or czrk.id_card like concat('%', #{userName}, '%'))
  611. </if>-->
  612. <choose>
  613. <when test="type == 1">and jzdz.province_id = #{areaId}</when>
  614. <when test="type == 2">and jzdz.city_id = #{areaId}</when>
  615. <when test="type == 3">and jzdz.region_id = #{areaId}</when>
  616. <when test="type == 4">and jzdz.town_id = #{areaId}</when>
  617. <when test="type == 5">and jzdz.village_id = #{areaId}</when>
  618. </choose>
  619. GROUP BY czrk.id
  620. </select>
  621. </mapper>