CzrkMapper.xml 36 KB

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