FsCompanyCustomerMapper.xml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  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.fs.qw.mapper.FsCompanyCustomerMapper">
  6. <resultMap type="com.fs.qw.domain.FsCompanyCustomer" id="FsCompanyCustomerResult">
  7. <result property="id" column="id" />
  8. <result property="customerName" column="customer_name" />
  9. <result property="sex" column="sex" />
  10. <result property="age" column="age" />
  11. <result property="address" column="address" />
  12. <result property="phone" column="phone" />
  13. <result property="filingTime" column="filing_time" />
  14. <result property="companyUserId" column="company_user_id" />
  15. <result property="companyUserName" column="company_user_name" />
  16. <result property="appointmentTime" column="appointment_time" />
  17. <result property="doctorId" column="doctor_id" />
  18. <result property="doctorName" column="doctor_name" />
  19. <result property="presentIllness" column="present_illness" />
  20. <result property="currentMedication" column="current_medication" />
  21. <result property="allergyHistory" column="allergy_history" />
  22. <result property="createBy" column="create_by" />
  23. <result property="createTime" column="create_time" />
  24. <result property="updateBy" column="update_by" />
  25. <result property="updateTime" column="update_time" />
  26. <result property="remark" column="remark" />
  27. <result property="importMemberId" column="import_member_id" />
  28. <result property="buyCount" column="buy_count" />
  29. <result property="claimStatus" column="claim_status" />
  30. <result property="completeStatus" column="complete_status" />
  31. <result property="deptId" column="dept_id" />
  32. <result property="deptName" column="dept_name" />
  33. </resultMap>
  34. <sql id="selectFsCompanyCustomerVo">
  35. select id, customer_name, sex, age, address, phone, filing_time,
  36. company_user_id, company_user_name, appointment_time, doctor_id, doctor_name,
  37. present_illness, current_medication, allergy_history,
  38. create_by, create_time, update_by, update_time, remark, del_flag, import_member_id,
  39. buy_count, claim_status,
  40. complete_status, dept_id, dept_name
  41. from fs_company_customer
  42. </sql>
  43. <select id="selectFsCompanyCustomerList" parameterType="com.fs.qw.domain.FsCompanyCustomer" resultMap="FsCompanyCustomerResult">
  44. <include refid="selectFsCompanyCustomerVo"/>
  45. where del_flag = '0'
  46. <if test="customerName != null and customerName != ''">
  47. and customer_name like concat('%', #{customerName}, '%')
  48. </if>
  49. <if test="phone != null and phone != ''">
  50. and phone like concat('%', #{phone}, '%')
  51. </if>
  52. <if test="companyUserName != null and companyUserName != ''">
  53. and company_user_name like concat('%', #{companyUserName}, '%')
  54. </if>
  55. <if test="companyUserId != null">
  56. and company_user_id = #{companyUserId}
  57. </if>
  58. <if test="claimStatus != null">
  59. and claim_status = #{claimStatus}
  60. </if>
  61. <if test="beginTime != null and beginTime != ''">
  62. and filing_time &gt;= #{beginTime}
  63. </if>
  64. <if test="endTime != null and endTime != ''">
  65. and filing_time &lt;= #{endTime}
  66. </if>
  67. <if test="beginCreateTime != null and beginCreateTime != ''">
  68. and create_time &gt;= #{beginCreateTime}
  69. </if>
  70. <if test="endCreateTime != null and endCreateTime != ''">
  71. and create_time &lt;= #{endCreateTime}
  72. </if>
  73. <if test="purchased != null and purchased == true">
  74. and buy_count > 0
  75. </if>
  76. <if test="minBuyCount != null">
  77. and buy_count &gt;= #{minBuyCount}
  78. </if>
  79. <if test="maxBuyCount != null">
  80. and buy_count &lt;= #{maxBuyCount}
  81. </if>
  82. <if test="importMemberId != null">
  83. and import_member_id = #{importMemberId}
  84. </if>
  85. <if test="completeStatus != null">
  86. and complete_status = #{completeStatus}
  87. </if>
  88. order by filing_time desc
  89. </select>
  90. <select id="selectImportFsCompanyCustomerList" parameterType="com.fs.qw.domain.FsCompanyCustomer"
  91. resultMap="FsCompanyCustomerResult">
  92. <include refid="selectFsCompanyCustomerVo"/>
  93. where del_flag = '0' and import_member_id is not null
  94. <if test="customerName != null and customerName != ''">
  95. and customer_name like concat('%', #{customerName}, '%')
  96. </if>
  97. <if test="phone != null and phone != ''">
  98. and phone like concat('%', #{phone}, '%')
  99. </if>
  100. <if test="companyUserName != null and companyUserName != ''">
  101. and company_user_name like concat('%', #{companyUserName}, '%')
  102. </if>
  103. <if test="companyUserId != null">
  104. and company_user_id = #{companyUserId}
  105. </if>
  106. <if test="claimStatus != null">
  107. and claim_status = #{claimStatus}
  108. </if>
  109. <if test="beginTime != null and beginTime != ''">
  110. and filing_time &gt;= #{beginTime}
  111. </if>
  112. <if test="endTime != null and endTime != ''">
  113. and filing_time &lt;= #{endTime}
  114. </if>
  115. <if test="beginCreateTime != null and beginCreateTime != ''">
  116. and create_time &gt;= #{beginCreateTime}
  117. </if>
  118. <if test="endCreateTime != null and endCreateTime != ''">
  119. and create_time &lt;= #{endCreateTime}
  120. </if>
  121. <if test="purchased != null and purchased == true">
  122. and buy_count > 0
  123. </if>
  124. <if test="minBuyCount != null">
  125. and buy_count &gt;= #{minBuyCount}
  126. </if>
  127. <if test="maxBuyCount != null">
  128. and buy_count &lt;= #{maxBuyCount}
  129. </if>
  130. <if test="importMemberId != null">
  131. and import_member_id = #{importMemberId}
  132. </if>
  133. <if test="completeStatus != null">
  134. and complete_status = #{completeStatus}
  135. </if>
  136. order by filing_time desc
  137. </select>
  138. <select id="selectFsCompanyCustomerById" parameterType="Long" resultMap="FsCompanyCustomerResult">
  139. <include refid="selectFsCompanyCustomerVo"/>
  140. where id = #{id} and del_flag = '0'
  141. </select>
  142. <select id="selectFsCompanyCustomerListByCompanyUserIds" resultType="com.fs.qw.domain.FsCompanyCustomer">
  143. <include refid="selectFsCompanyCustomerVo"/>
  144. <where>
  145. del_flag = '0'
  146. <if test="companyUserIds != null and companyUserIds.size() > 0">
  147. and company_user_id IN
  148. <foreach collection="companyUserIds" item="id" open="(" separator="," close=")">
  149. #{id}
  150. </foreach>
  151. </if>
  152. <if test="customerName != null and customerName != ''">
  153. and customer_name like concat('%', #{customerName}, '%')
  154. </if>
  155. <if test="phone != null and phone != ''">
  156. and phone like concat('%', #{phone}, '%')
  157. </if>
  158. <if test="companyUserName != null and companyUserName != ''">
  159. and company_user_name like concat('%', #{companyUserName}, '%')
  160. </if>
  161. </where>
  162. </select>
  163. <select id="selectByIdForUpdate" resultMap="FsCompanyCustomerResult">
  164. SELECT * FROM fs_company_customer WHERE id = #{id} FOR UPDATE
  165. </select>
  166. <insert id="insertFsCompanyCustomer" parameterType="com.fs.qw.domain.FsCompanyCustomer" useGeneratedKeys="true" keyProperty="id">
  167. insert into fs_company_customer
  168. <trim prefix="(" suffix=")" suffixOverrides=",">
  169. <if test="customerName != null">customer_name,</if>
  170. <if test="sex != null">sex,</if>
  171. <if test="age != null">age,</if>
  172. <if test="address != null">address,</if>
  173. <if test="phone != null">phone,</if>
  174. <if test="filingTime != null">filing_time,</if>
  175. <if test="companyUserId != null">company_user_id,</if>
  176. <if test="companyUserName != null">company_user_name,</if>
  177. <if test="appointmentTime != null">appointment_time,</if>
  178. <if test="doctorId != null">doctor_id,</if>
  179. <if test="doctorName != null">doctor_name,</if>
  180. <if test="presentIllness != null">present_illness,</if>
  181. <if test="currentMedication != null">current_medication,</if>
  182. <if test="allergyHistory != null">allergy_history,</if>
  183. <if test="createBy != null">create_by,</if>
  184. <if test="remark != null">remark,</if>
  185. <if test="importMemberId != null">import_member_id,</if>
  186. <if test="buyCount != null">buy_count,</if>
  187. <if test="claimStatus != null">claim_status,</if>
  188. <if test="completeStatus != null">complete_status,</if>
  189. <if test="deptId != null">dept_id,</if>
  190. <if test="deptName != null">dept_name,</if>
  191. create_time
  192. </trim>
  193. <trim prefix="values (" suffix=")" suffixOverrides=",">
  194. <if test="customerName != null">#{customerName},</if>
  195. <if test="sex != null">#{sex},</if>
  196. <if test="age != null">#{age},</if>
  197. <if test="address != null">#{address},</if>
  198. <if test="phone != null">#{phone},</if>
  199. <if test="filingTime != null">#{filingTime},</if>
  200. <if test="companyUserId != null">#{companyUserId},</if>
  201. <if test="companyUserName != null">#{companyUserName},</if>
  202. <if test="appointmentTime != null">#{appointmentTime},</if>
  203. <if test="doctorId != null">#{doctorId},</if>
  204. <if test="doctorName != null">#{doctorName},</if>
  205. <if test="presentIllness != null">#{presentIllness},</if>
  206. <if test="currentMedication != null">#{currentMedication},</if>
  207. <if test="allergyHistory != null">#{allergyHistory},</if>
  208. <if test="createBy != null">#{createBy},</if>
  209. <if test="remark != null">#{remark},</if>
  210. <if test="importMemberId != null">#{importMemberId},</if>
  211. <if test="buyCount != null">#{buyCount},</if>
  212. <if test="claimStatus != null">#{claimStatus},</if>
  213. <if test="completeStatus != null">#{completeStatus},</if>
  214. <if test="deptId != null">#{deptId},</if>
  215. <if test="deptName != null">#{deptName},</if>
  216. sysdate()
  217. </trim>
  218. </insert>
  219. <!-- 批量新增-->
  220. <insert id="insertBatchFsCompanyCustomer" parameterType="list">
  221. INSERT IGNORE INTO fs_company_customer (
  222. customer_name, phone, address, create_time,
  223. import_member_id, present_illness, current_medication, allergy_history, claim_status
  224. ) VALUES
  225. <foreach collection="companyCustomers" item="item" separator=",">
  226. (
  227. #{item.customerName}, #{item.phone}, #{item.address}, #{item.createTime},
  228. #{item.importMemberId}, #{item.presentIllness}, #{item.currentMedication},
  229. #{item.allergyHistory}, #{item.claimStatus}
  230. )
  231. </foreach>
  232. </insert>
  233. <update id="updateFsCompanyCustomer" parameterType="com.fs.qw.domain.FsCompanyCustomer">
  234. update fs_company_customer
  235. <set>
  236. <if test="customerName != null and customerName != ''">customer_name = #{customerName},</if>
  237. <if test="sex != null">sex = #{sex},</if>
  238. <if test="age != null">age = #{age},</if>
  239. <if test="address != null">address = #{address},</if>
  240. <if test="phone != null">phone = #{phone},</if>
  241. <if test="filingTime != null">filing_time = #{filingTime},</if>
  242. <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
  243. <if test="companyUserName != null">company_user_name = #{companyUserName},</if>
  244. <if test="appointmentTime != null">appointment_time = #{appointmentTime},</if>
  245. <if test="doctorId != null">doctor_id = #{doctorId},</if>
  246. <if test="doctorName != null">doctor_name = #{doctorName},</if>
  247. <if test="presentIllness != null">present_illness = #{presentIllness},</if>
  248. <if test="currentMedication != null">current_medication = #{currentMedication},</if>
  249. <if test="allergyHistory != null">allergy_history = #{allergyHistory},</if>
  250. <if test="remark != null">remark = #{remark},</if>
  251. <if test="importMemberId != null">import_member_id = #{importMemberId},</if>
  252. <if test="buyCount != null">buy_count = #{buyCount},</if>
  253. <if test="claimStatus != null">claim_status = #{claimStatus},</if>
  254. <if test="completeStatus != null">complete_status = #{completeStatus},</if>
  255. <if test="deptId != null">dept_id = #{deptId},</if>
  256. <if test="deptName != null">dept_name = #{deptName},</if>
  257. <if test="updateBy != null">update_by = #{updateBy},</if>
  258. update_time = sysdate()
  259. </set>
  260. where id = #{id}
  261. </update>
  262. <update id="deleteFsCompanyCustomerById" parameterType="Long">
  263. update fs_company_customer set del_flag = '2' where id = #{id}
  264. </update>
  265. <update id="deleteFsCompanyCustomerByIds" parameterType="String">
  266. update fs_company_customer set del_flag = '2' where id in
  267. <foreach collection="array" item="id" open="(" separator="," close=")">
  268. #{id}
  269. </foreach>
  270. </update>
  271. <update id="updateCompanyUserIdByIds">
  272. update fs_company_customer
  273. set company_user_id = #{targetDoctorId},
  274. company_user_name = #{targetDoctorName},
  275. update_time = sysdate()
  276. where del_flag = '0'
  277. and id in
  278. <foreach collection="customerIds" item="id" open="(" separator="," close=")">
  279. #{id}
  280. </foreach>
  281. </update>
  282. <update id="updateBatchFsCompanyCustomer">
  283. UPDATE fs_company_customer
  284. <trim prefix="SET" suffixOverrides=",">
  285. <trim prefix="present_illness = CASE" suffix="END,">
  286. <foreach collection="companyCustomers" item="item">
  287. WHEN id = #{item.id} THEN #{item.presentIllness}
  288. </foreach>
  289. </trim>
  290. <trim prefix="current_medication = CASE" suffix="END,">
  291. <foreach collection="companyCustomers" item="item">
  292. WHEN id = #{item.id} THEN #{item.currentMedication}
  293. </foreach>
  294. </trim>
  295. <trim prefix="allergy_history = CASE" suffix="END,">
  296. <foreach collection="companyCustomers" item="item">
  297. WHEN id = #{item.id} THEN #{item.allergyHistory}
  298. </foreach>
  299. </trim>
  300. </trim>
  301. WHERE id IN
  302. <foreach collection="companyCustomers" item="item" open="(" separator="," close=")">
  303. #{item.id}
  304. </foreach>
  305. </update>
  306. </mapper>