TUserProfileMapper.xml 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469
  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.ruoyi.system.mapper.TUserProfileMapper">
  6. <resultMap type="TUserProfile" id="TUserProfileResult">
  7. <result property="id" column="id"/>
  8. <result property="name" column="name"/>
  9. <result property="gender" column="gender"/>
  10. <result property="sfzid" column="sfzid"/>
  11. <result property="telOne" column="tel_one"/>
  12. <result property="telTwo" column="tel_two"/>
  13. <result property="telThree" column="tel_three"/>
  14. <result property="birthday" column="birthday"/>
  15. <result property="age" column="age"/>
  16. <result property="marrStatus" column="marr_status"/>
  17. <result property="national" column="national"/>
  18. <result property="local" column="local"/>
  19. <result property="clientType" column="client_type"/>
  20. <result property="liveStatus" column="live_status"/>
  21. <result property="familyAddress" column="family_address"/>
  22. <result property="detailAddress" column="detail_address"/>
  23. <result property="houseAddress" column="house_address"/>
  24. <result property="houseDetailAddress" column="house_detail_address"/>
  25. <result property="serviceid" column="serviceid"/>
  26. <result property="oldmenStatus" column="oldmen_status"/>
  27. <result property="changeContent" column="change_content"/>
  28. <result property="loseMonth" column="lose_month"/>
  29. <result property="treatMonth" column="treat_month"/>
  30. <result property="isTreat" column="is_treat"/>
  31. <result property="serviceType" column="service_type"/>
  32. <result property="treateSure" column="treate_sure"/>
  33. <result property="moneyCome" column="money_come"/>
  34. <result property="moneyMonth" column="money_month"/>
  35. <result property="cardCode" column="card_code"/>
  36. <result property="slowIllness" column="slow_illness"/>
  37. <result property="bloodType" column="blood_type"/>
  38. <result property="shiStatus" column="shi_status"/>
  39. <result property="disablityStatus" column="disablity_status"/>
  40. <result property="disablityEntry" column="disablity_entry"/>
  41. <result property="educaLevel" column="educa_level"/>
  42. <result property="special" column="special"/>
  43. <result property="title" column="title"/>
  44. <result property="unity" column="unity"/>
  45. <result property="natureHeart" column="nature_heart"/>
  46. <result property="eatPoint" column="eat_point"/>
  47. <result property="speciality" column="speciality"/>
  48. <result property="hobby" column="hobby"/>
  49. <result property="photo" column="photo"/>
  50. <result property="otherPhoto" column="other_photo"/>
  51. <result property="remarks" column="remarks"/>
  52. <result property="createTime" column="createtime"/>
  53. </resultMap>
  54. <resultMap id="TUserProfileTEmergentPeopleResult" type="TUserProfile" extends="TUserProfileResult">
  55. <collection property="tEmergentPeopleList" notNullColumn="sub_id" javaType="java.util.List"
  56. resultMap="TEmergentPeopleResult"/>
  57. </resultMap>
  58. <resultMap type="TEmergentPeople" id="TEmergentPeopleResult">
  59. <result property="id" column="sub_id"/>
  60. <result property="profileId" column="sub_profile_id"/>
  61. <result property="name" column="sub_name"/>
  62. <result property="telno" column="sub_telno"/>
  63. <result property="relation" column="sub_relation"/>
  64. <result property="isConn" column="sub_is_conn"/>
  65. </resultMap>
  66. <sql id="selectTUserProfileVo">
  67. select id,
  68. name,
  69. gender,
  70. sfzid,
  71. tel_one,
  72. tel_two,
  73. tel_three,
  74. birthday,
  75. age,
  76. marr_status, national, local, client_type, live_status, family_address, detail_address, house_address, house_detail_address, serviceid, oldmen_status, change_content, lose_month, treat_month, is_treat, service_type, treate_sure, money_come, money_month, card_code, slow_illness, blood_type, shi_status, disablity_status, disablity_entry, educa_level, special, title, unity, nature_heart, eat_point, speciality, hobby, photo, other_photo, remarks, createtime
  77. from t_user_profile
  78. </sql>
  79. <select id="selectTUserProfileList" parameterType="TUserProfile" resultMap="TUserProfileResult">
  80. <include refid="selectTUserProfileVo"/>
  81. <where>
  82. <if test="name != null and name != ''">and name like concat('%', #{name}, '%')</if>
  83. <if test="gender != null ">and gender = #{gender}</if>
  84. <if test="sfzid != null and sfzid != ''">and sfzid = #{sfzid}</if>
  85. <if test="telOne != null and telOne != ''">and tel_one = #{telOne}</if>
  86. <if test="telTwo != null and telTwo != ''">and tel_two = #{telTwo}</if>
  87. <if test="telThree != null and telThree != ''">and tel_three = #{telThree}</if>
  88. <if test="birthday != null and birthday != ''">and birthday = #{birthday}</if>
  89. <if test="age != null ">and age = #{age}</if>
  90. <if test="marrStatus != null ">and marr_status = #{marrStatus}</if>
  91. <if test="national != null ">and national = #{national}</if>
  92. <if test="local != null ">and local = #{local}</if>
  93. <if test="clientType != null ">and client_type = #{clientType}</if>
  94. <if test="liveStatus != null ">and live_status = #{liveStatus}</if>
  95. <if test="familyAddress != null and familyAddress != ''">and family_address = #{familyAddress}</if>
  96. <if test="detailAddress != null and detailAddress != ''">and detail_address = #{detailAddress}</if>
  97. <if test="houseAddress != null and houseAddress != ''">and house_address = #{houseAddress}</if>
  98. <if test="houseDetailAddress != null and houseDetailAddress != ''">and house_detail_address =
  99. #{houseDetailAddress}
  100. </if>
  101. <if test="serviceid != null ">and serviceid = #{serviceid}</if>
  102. <if test="oldmenStatus != null and oldmenStatus != ''">and oldmen_status = #{oldmenStatus}</if>
  103. <if test="changeContent != null and changeContent != ''">and change_content = #{changeContent}</if>
  104. <if test="loseMonth != null and loseMonth != ''">and lose_month = #{loseMonth}</if>
  105. <if test="treatMonth != null and treatMonth != ''">and treat_month = #{treatMonth}</if>
  106. <if test="isTreat != null ">and is_treat = #{isTreat}</if>
  107. <if test="serviceType != null ">and service_type = #{serviceType}</if>
  108. <if test="treateSure != null ">and treate_sure = #{treateSure}</if>
  109. <if test="moneyCome != null ">and money_come = #{moneyCome}</if>
  110. <if test="moneyMonth != null and moneyMonth != ''">and money_month = #{moneyMonth}</if>
  111. <if test="cardCode != null and cardCode != ''">and card_code = #{cardCode}</if>
  112. <if test="slowIllness != null and slowIllness != ''">and slow_illness = #{slowIllness}</if>
  113. <if test="bloodType != null ">and blood_type = #{bloodType}</if>
  114. <if test="shiStatus != null ">and shi_status = #{shiStatus}</if>
  115. <if test="disablityStatus != null ">and disablity_status = #{disablityStatus}</if>
  116. <if test="disablityEntry != null ">and disablity_entry = #{disablityEntry}</if>
  117. <if test="educaLevel != null ">and educa_level = #{educaLevel}</if>
  118. <if test="special != null and special != ''">and special = #{special}</if>
  119. <if test="title != null and title != ''">and title = #{title}</if>
  120. <if test="unity != null and unity != ''">and unity = #{unity}</if>
  121. <if test="natureHeart != null and natureHeart != ''">and nature_heart = #{natureHeart}</if>
  122. <if test="eatPoint != null and eatPoint != ''">and eat_point = #{eatPoint}</if>
  123. <if test="speciality != null and speciality != ''">and speciality = #{speciality}</if>
  124. <if test="hobby != null and hobby != ''">and hobby = #{hobby}</if>
  125. <if test="photo != null and photo != ''">and photo = #{photo}</if>
  126. <if test="otherPhoto != null and otherPhoto != ''">and other_photo = #{otherPhoto}</if>
  127. <if test="remarks != null and remarks != ''">and remarks = #{remarks}</if>
  128. <if test="createTime != null ">and createtime = #{createTime}</if>
  129. </where>
  130. order by createTime desc
  131. </select>
  132. <select id="selectTUserProfileById" parameterType="Integer" resultMap="TUserProfileTEmergentPeopleResult">
  133. select a.id,
  134. a.name,
  135. a.gender,
  136. a.sfzid,
  137. a.tel_one,
  138. a.tel_two,
  139. a.tel_three,
  140. a.birthday,
  141. a.age,
  142. a.marr_status,
  143. a.national,
  144. a.local,
  145. a.client_type,
  146. a.live_status,
  147. a.family_address,
  148. a.detail_address,
  149. a.house_address,
  150. a.house_detail_address,
  151. a.serviceid,
  152. a.oldmen_status,
  153. a.change_content,
  154. a.lose_month,
  155. a.treat_month,
  156. a.is_treat,
  157. a.service_type,
  158. a.treate_sure,
  159. a.money_come,
  160. a.money_month,
  161. a.card_code,
  162. a.slow_illness,
  163. a.blood_type,
  164. a.shi_status,
  165. a.disablity_status,
  166. a.disablity_entry,
  167. a.educa_level,
  168. a.special,
  169. a.title,
  170. a.unity,
  171. a.nature_heart,
  172. a.eat_point,
  173. a.speciality,
  174. a.hobby,
  175. a.photo,
  176. a.other_photo,
  177. a.remarks,
  178. a.createtime,
  179. b.id as sub_id,
  180. b.profile_id as sub_profile_id,
  181. b.name as sub_name,
  182. b.telno as sub_telno,
  183. b.relation as sub_relation,
  184. b.is_conn as sub_is_conn
  185. from t_user_profile a
  186. left join t_emergent_people b on b.profile_id = a.id
  187. where a.id = #{id}
  188. </select>
  189. <select id="selectTUserProfileListByDevice" resultType="com.ruoyi.system.domain.dto.TUserProfileDto">
  190. select id, name, gender, sfzid, tel_one, age, family_address from t_user_profile
  191. <where>
  192. <if test="name != null and name != ''">and name like concat('%', #{name}, '%')</if>
  193. <if test="gender != null ">and gender = #{gender}</if>
  194. <if test="sfzid != null and sfzid != ''">and sfzid = #{sfzid}</if>
  195. <if test="telOne != null and telOne != ''">and tel_one = #{telOne}</if>
  196. <if test="age != null ">and age = #{age}</if>
  197. <if test="familyAddress != null and familyAddress != ''">and family_address = #{familyAddress}</if>
  198. </where>
  199. </select>
  200. <select id="selectTUserProfileBySfzId" resultType="com.ruoyi.system.domain.TUserProfile">
  201. select *
  202. from t_user_profile
  203. where sfzid = #{sfzid}
  204. </select>
  205. <select id="selectTUserProfileBySfzIdV2" resultType="com.ruoyi.system.domain.TUserProfile">
  206. <include refid="selectTUserProfileVo"/>
  207. where sfzid = #{sfzid}
  208. </select>
  209. <select id="selectuserAgeDto" resultType="com.ruoyi.system.domain.dto.UserAgeDto">
  210. SELECT CASE
  211. WHEN age &lt; 20
  212. THEN
  213. '10'
  214. WHEN age &gt;= 20
  215. AND age &lt; 30 THEN
  216. '20'
  217. WHEN age &gt;= 30
  218. AND age &lt; 40 THEN
  219. '30'
  220. WHEN age &gt;= 40
  221. AND age &lt; 50 THEN
  222. '40'
  223. WHEN age &gt;= 50
  224. AND age &lt; 60 THEN
  225. '50'
  226. WHEN age &gt;= 60
  227. AND age &lt; 70 THEN
  228. '60'
  229. WHEN age &gt;= 70
  230. AND age &lt; 80 THEN
  231. '70'
  232. WHEN age &gt;= 80
  233. AND age &lt; 90 THEN
  234. '80'
  235. WHEN age &gt; 90 THEN
  236. '100以上'
  237. END AS age,
  238. count(*) AS count
  239. FROM
  240. t_user_profile
  241. GROUP BY
  242. CASE
  243. WHEN age &lt; 20
  244. THEN
  245. '10'
  246. WHEN age &gt;= 20
  247. AND age &lt; 30 THEN
  248. '20'
  249. WHEN age &gt;= 30
  250. AND age &lt; 40 THEN
  251. '30'
  252. WHEN age &gt;= 40
  253. AND age &lt; 50 THEN
  254. '40'
  255. WHEN age &gt;= 50
  256. AND age &lt; 60 THEN
  257. '50'
  258. WHEN age &gt;= 60
  259. AND age &lt; 70 THEN
  260. '60'
  261. WHEN age &gt;= 70
  262. AND age &lt; 80 THEN
  263. '70'
  264. WHEN age &gt;= 80
  265. AND age &lt; 90 THEN
  266. '80'
  267. WHEN age &gt; 90 THEN
  268. '100以上'
  269. END;
  270. </select>
  271. <select id="selectuserAgeCount" resultType="java.lang.Integer">
  272. select IFNULL(count(*), 0)
  273. from t_user_profile
  274. </select>
  275. <select id="selectAddUser" resultType="com.ruoyi.system.domain.dto.AddUserDto">
  276. SELECT DATE_FORMAT(createtime, '%Y-%m') AS month, COUNT(*) AS count
  277. FROM t_user_profile
  278. GROUP BY month;
  279. </select>
  280. <insert id="insertTUserProfile" parameterType="TUserProfile" useGeneratedKeys="true" keyProperty="id">
  281. insert into t_user_profile
  282. <trim prefix="(" suffix=")" suffixOverrides=",">
  283. <if test="name != null">name,</if>
  284. <if test="gender != null">gender,</if>
  285. <if test="sfzid != null">sfzid,</if>
  286. <if test="telOne != null">tel_one,</if>
  287. <if test="telTwo != null">tel_two,</if>
  288. <if test="telThree != null">tel_three,</if>
  289. <if test="birthday != null">birthday,</if>
  290. <if test="age != null">age,</if>
  291. <if test="marrStatus != null">marr_status,</if>
  292. <if test="national != null">national,</if>
  293. <if test="local != null">local,</if>
  294. <if test="clientType != null">client_type,</if>
  295. <if test="liveStatus != null">live_status,</if>
  296. <if test="familyAddress != null">family_address,</if>
  297. <if test="detailAddress != null">detail_address,</if>
  298. <if test="houseAddress != null">house_address,</if>
  299. <if test="houseDetailAddress != null">house_detail_address,</if>
  300. <if test="serviceid != null">serviceid,</if>
  301. <if test="oldmenStatus != null">oldmen_status,</if>
  302. <if test="changeContent != null">change_content,</if>
  303. <if test="loseMonth != null">lose_month,</if>
  304. <if test="treatMonth != null">treat_month,</if>
  305. <if test="isTreat != null">is_treat,</if>
  306. <if test="serviceType != null">service_type,</if>
  307. <if test="treateSure != null">treate_sure,</if>
  308. <if test="moneyCome != null">money_come,</if>
  309. <if test="moneyMonth != null">money_month,</if>
  310. <if test="cardCode != null">card_code,</if>
  311. <if test="slowIllness != null">slow_illness,</if>
  312. <if test="bloodType != null">blood_type,</if>
  313. <if test="shiStatus != null">shi_status,</if>
  314. <if test="disablityStatus != null">disablity_status,</if>
  315. <if test="disablityEntry != null">disablity_entry,</if>
  316. <if test="educaLevel != null">educa_level,</if>
  317. <if test="special != null">special,</if>
  318. <if test="title != null">title,</if>
  319. <if test="unity != null">unity,</if>
  320. <if test="natureHeart != null">nature_heart,</if>
  321. <if test="eatPoint != null">eat_point,</if>
  322. <if test="speciality != null">speciality,</if>
  323. <if test="hobby != null">hobby,</if>
  324. <if test="photo != null">photo,</if>
  325. <if test="otherPhoto != null">other_photo,</if>
  326. <if test="remarks != null">remarks,</if>
  327. <if test="createTime != null">createtime,</if>
  328. </trim>
  329. <trim prefix="values (" suffix=")" suffixOverrides=",">
  330. <if test="name != null">#{name},</if>
  331. <if test="gender != null">#{gender},</if>
  332. <if test="sfzid != null">#{sfzid},</if>
  333. <if test="telOne != null">#{telOne},</if>
  334. <if test="telTwo != null">#{telTwo},</if>
  335. <if test="telThree != null">#{telThree},</if>
  336. <if test="birthday != null">#{birthday},</if>
  337. <if test="age != null">#{age},</if>
  338. <if test="marrStatus != null">#{marrStatus},</if>
  339. <if test="national != null">#{national},</if>
  340. <if test="local != null">#{local},</if>
  341. <if test="clientType != null">#{clientType},</if>
  342. <if test="liveStatus != null">#{liveStatus},</if>
  343. <if test="familyAddress != null">#{familyAddress},</if>
  344. <if test="detailAddress != null">#{detailAddress},</if>
  345. <if test="houseAddress != null">#{houseAddress},</if>
  346. <if test="houseDetailAddress != null">#{houseDetailAddress},</if>
  347. <if test="serviceid != null">#{serviceid},</if>
  348. <if test="oldmenStatus != null">#{oldmenStatus},</if>
  349. <if test="changeContent != null">#{changeContent},</if>
  350. <if test="loseMonth != null">#{loseMonth},</if>
  351. <if test="treatMonth != null">#{treatMonth},</if>
  352. <if test="isTreat != null">#{isTreat},</if>
  353. <if test="serviceType != null">#{serviceType},</if>
  354. <if test="treateSure != null">#{treateSure},</if>
  355. <if test="moneyCome != null">#{moneyCome},</if>
  356. <if test="moneyMonth != null">#{moneyMonth},</if>
  357. <if test="cardCode != null">#{cardCode},</if>
  358. <if test="slowIllness != null">#{slowIllness},</if>
  359. <if test="bloodType != null">#{bloodType},</if>
  360. <if test="shiStatus != null">#{shiStatus},</if>
  361. <if test="disablityStatus != null">#{disablityStatus},</if>
  362. <if test="disablityEntry != null">#{disablityEntry},</if>
  363. <if test="educaLevel != null">#{educaLevel},</if>
  364. <if test="special != null">#{special},</if>
  365. <if test="title != null">#{title},</if>
  366. <if test="unity != null">#{unity},</if>
  367. <if test="natureHeart != null">#{natureHeart},</if>
  368. <if test="eatPoint != null">#{eatPoint},</if>
  369. <if test="speciality != null">#{speciality},</if>
  370. <if test="hobby != null">#{hobby},</if>
  371. <if test="photo != null">#{photo},</if>
  372. <if test="otherPhoto != null">#{otherPhoto},</if>
  373. <if test="remarks != null">#{remarks},</if>
  374. <if test="createTime != null">#{createTime},</if>
  375. </trim>
  376. </insert>
  377. <update id="updateTUserProfile" parameterType="TUserProfile">
  378. update t_user_profile
  379. <trim prefix="SET" suffixOverrides=",">
  380. <if test="name != null">name = #{name},</if>
  381. <if test="gender != null">gender = #{gender},</if>
  382. <if test="sfzid != null">sfzid = #{sfzid},</if>
  383. <if test="telOne != null">tel_one = #{telOne},</if>
  384. <if test="telTwo != null">tel_two = #{telTwo},</if>
  385. <if test="telThree != null">tel_three = #{telThree},</if>
  386. <if test="birthday != null">birthday = #{birthday},</if>
  387. <if test="age != null">age = #{age},</if>
  388. <if test="marrStatus != null">marr_status = #{marrStatus},</if>
  389. <if test="national != null">national = #{national},</if>
  390. <if test="local != null">local = #{local},</if>
  391. <if test="clientType != null">client_type = #{clientType},</if>
  392. <if test="liveStatus != null">live_status = #{liveStatus},</if>
  393. <if test="familyAddress != null">family_address = #{familyAddress},</if>
  394. <if test="detailAddress != null">detail_address = #{detailAddress},</if>
  395. <if test="houseAddress != null">house_address = #{houseAddress},</if>
  396. <if test="houseDetailAddress != null">house_detail_address = #{houseDetailAddress},</if>
  397. <if test="serviceid != null">serviceid = #{serviceid},</if>
  398. <if test="oldmenStatus != null">oldmen_status = #{oldmenStatus},</if>
  399. <if test="changeContent != null">change_content = #{changeContent},</if>
  400. <if test="loseMonth != null">lose_month = #{loseMonth},</if>
  401. <if test="treatMonth != null">treat_month = #{treatMonth},</if>
  402. <if test="isTreat != null">is_treat = #{isTreat},</if>
  403. <if test="serviceType != null">service_type = #{serviceType},</if>
  404. <if test="treateSure != null">treate_sure = #{treateSure},</if>
  405. <if test="moneyCome != null">money_come = #{moneyCome},</if>
  406. <if test="moneyMonth != null">money_month = #{moneyMonth},</if>
  407. <if test="cardCode != null">card_code = #{cardCode},</if>
  408. <if test="slowIllness != null">slow_illness = #{slowIllness},</if>
  409. <if test="bloodType != null">blood_type = #{bloodType},</if>
  410. <if test="shiStatus != null">shi_status = #{shiStatus},</if>
  411. <if test="disablityStatus != null">disablity_status = #{disablityStatus},</if>
  412. <if test="disablityEntry != null">disablity_entry = #{disablityEntry},</if>
  413. <if test="educaLevel != null">educa_level = #{educaLevel},</if>
  414. <if test="special != null">special = #{special},</if>
  415. <if test="title != null">title = #{title},</if>
  416. <if test="unity != null">unity = #{unity},</if>
  417. <if test="natureHeart != null">nature_heart = #{natureHeart},</if>
  418. <if test="eatPoint != null">eat_point = #{eatPoint},</if>
  419. <if test="speciality != null">speciality = #{speciality},</if>
  420. <if test="hobby != null">hobby = #{hobby},</if>
  421. <if test="photo != null">photo = #{photo},</if>
  422. <if test="otherPhoto != null">other_photo = #{otherPhoto},</if>
  423. <if test="remarks != null">remarks = #{remarks},</if>
  424. <if test="createTime != null">createtime = #{createTime},</if>
  425. </trim>
  426. where id = #{id}
  427. </update>
  428. <delete id="deleteTUserProfileById" parameterType="Integer">
  429. delete
  430. from t_user_profile
  431. where id = #{id}
  432. </delete>
  433. <delete id="deleteTUserProfileByIds" parameterType="String">
  434. delete from t_user_profile where id in
  435. <foreach item="id" collection="array" open="(" separator="," close=")">
  436. #{id}
  437. </foreach>
  438. </delete>
  439. <delete id="deleteTEmergentPeopleByProfileIds" parameterType="String">
  440. delete from t_emergent_people where profile_id in
  441. <foreach item="profileId" collection="array" open="(" separator="," close=")">
  442. #{profileId}
  443. </foreach>
  444. </delete>
  445. <delete id="deleteTEmergentPeopleByProfileId" parameterType="Integer">
  446. delete
  447. from t_emergent_people
  448. where profile_id = #{profileId}
  449. </delete>
  450. <insert id="batchTEmergentPeople">
  451. insert into t_emergent_people( id, profile_id, name, telno, relation, is_conn) values
  452. <foreach item="item" index="index" collection="list" separator=",">
  453. ( #{item.id}, #{item.profileId}, #{item.name}, #{item.telno}, #{item.relation}, #{item.isConn})
  454. </foreach>
  455. </insert>
  456. </mapper>