ClueMapper.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.management.platform.mapper.ClueMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.management.platform.entity.Clue">
  6. <id column="id" property="id" />
  7. <result column="company_id" property="companyId" />
  8. <result column="clue_name" property="clueName" />
  9. <result column="clue_source_id" property="clueSourceId" />
  10. <result column="phone" property="phone" />
  11. <result column="email" property="email" />
  12. <result column="customer_industry_id" property="customerIndustryId" />
  13. <result column="customer_level_id" property="customerLevelId" />
  14. <result column="address" property="address" />
  15. <result column="incharger_id" property="inchargerId" />
  16. <result column="remark" property="remark" />
  17. <result column="is_delete" property="isDelete" />
  18. <result column="plate1" property="plate1" />
  19. <result column="plate2" property="plate2" />
  20. <result column="plate3" property="plate3" />
  21. <result column="plate4" property="plate4" />
  22. <result column="plate5" property="plate5" />
  23. <result column="company_name" property="companyName" />
  24. <result column="create_time" property="createTime" />
  25. <result column="create_id" property="createId" />
  26. </resultMap>
  27. <!-- 通用查询结果列 -->
  28. <sql id="Base_Column_List">
  29. id, company_id, clue_name, clue_source_id, phone , email, customer_industry_id, customer_level_id, address, incharger_id, remark, is_delete, plate1, plate2, plate3, plate4, plate5,create_time,createId
  30. </sql>
  31. <select id="list" resultType="com.management.platform.entity.Clue">
  32. select c.id,
  33. c.company_id,
  34. c.clue_name,
  35. c.clue_source_id,
  36. c.phone,
  37. c.email,
  38. c.customer_industry_id,
  39. c.customer_level_id,
  40. c.address,
  41. c.incharger_id,
  42. c.remark,
  43. c.is_delete,
  44. c.plate1,
  45. c.plate2,
  46. c.plate3,
  47. c.plate4,
  48. c.plate5,
  49. c.create_time,
  50. c.create_id,
  51. (select company_name from company where c.company_id = id) companyName,
  52. (select name from `user` where id = c.incharger_id) inchargerName,
  53. (select name from `user` where id = c.create_id) createName,
  54. (select name from sys_dict where c.clue_source_id = id and code = 'ClueSources') clueSourceValue,
  55. (select name from sys_dict where c.customer_industry_id = id and code = 'CustomIndustry') customerIndustryValue,
  56. (select name from sys_dict where c.customer_level_id = id and code = 'CustomLevel') customerLevelValue
  57. from clue c
  58. left join sys_dict sd on c.customer_level_id = sd.id
  59. where
  60. c.company_id = #{companyId} and is_delete = #{isDelete} and c.is_bo = 0
  61. <if test="inchargerId != null and inchargerId != '' ">
  62. and c.incharger_id =#{inchargerId}
  63. </if>
  64. <if test="startTime != null and endTime != null ">
  65. and c.create_time BETWEEN #{startTime} and #{endTime}
  66. </if>
  67. <if test="clueName != null and clueName != '' ">
  68. and c.clue_name LIKE CONCAT('%', #{clueName}, '%')
  69. </if>
  70. <if test="phone != null and phone != '' ">
  71. and c.phone LIKE CONCAT('%', #{phone}, '%')
  72. </if>
  73. <if test="customerLevelId != null and customerLevelId != '' ">
  74. and c.customer_level_id = #{customerLevelId}
  75. </if>
  76. <if test="email != null and email != '' ">
  77. and c.email LIKE CONCAT('%', #{email}, '%')
  78. </if>
  79. <if test="clueSourceId != null">
  80. and c.clue_source_id = #{clueSourceId}
  81. </if>
  82. <if test="customerIndustryId != null">
  83. and c.customer_industry_id = #{customerIndustryId}
  84. </if>
  85. ORDER BY
  86. <choose>
  87. <when test="isDesc == null ">
  88. c.id DESC
  89. </when>
  90. <when test="isDesc == 0">
  91. sd.seq ASC, c.id DESC
  92. </when>
  93. <when test="isDesc == 1">
  94. sd.seq DESC, c.id DESC
  95. </when>
  96. <otherwise>
  97. c.id DESC
  98. </otherwise>
  99. </choose>
  100. limit #{pageIndex},#{pageFrom}
  101. </select>
  102. <select id="list1" resultType="com.management.platform.entity.Clue">
  103. select c.id,
  104. c.company_id,
  105. (select company_name from company where company_id = c.id) companyName,
  106. c.clue_name,
  107. c.clue_source_id,
  108. c.phone,
  109. c.email,
  110. c.customer_industry_id,
  111. c.customer_level_id,
  112. c.address,
  113. c.incharger_id,
  114. c.remark,
  115. c.is_delete,
  116. c.plate1,
  117. c.plate2,
  118. c.plate3,
  119. c.plate4,
  120. c.plate5,
  121. c.create_time,
  122. c.create_id,
  123. (select name from `user` where id = c.incharger_id) inchargerName,
  124. (select name from `user` where id = c.create_id) createName,
  125. (select name from sys_dict where c.clue_source_id = id and code = 'ClueSources') clueSourceValue,
  126. (select name from sys_dict where c.customer_industry_id = id and code = 'CustomIndustry') customerIndustryValue,
  127. (select name from sys_dict where c.customer_level_id = id and code = 'CustomLevel') customerLevelValue
  128. from clue c
  129. left join sys_dict sd on c.customer_level_id = sd.id
  130. where
  131. c.company_id = #{clue.companyId} and c.is_delete = #{clue.isDelete} and c.is_bo = 0
  132. and (c.incharger_id in
  133. (SELECT id from `user` WHERE department_id = (SELECT department_id from `user` WHERe id = #{userId}))
  134. or c.incharger_id is null)
  135. <if test="clue.inchargerId != null and clue.inchargerId != '' ">
  136. and c.incharger_id =#{clue.inchargerId}
  137. </if>
  138. <if test="clue.startTime != null and clue.endTime != null ">
  139. and c.create_time BETWEEN #{clue.startTime} and #{clue.endTime}
  140. </if>
  141. <if test="clue.clueName != null and clue.clueName != '' ">
  142. and c.clue_name LIKE CONCAT('%', #{clue.clueName}, '%')
  143. </if>
  144. <if test="clue.clueSourceId != null">
  145. and c.clue_source_id = #{clue.clueSourceId}
  146. </if>
  147. <if test="clue.phone != null and clue.phone != '' ">
  148. and c.phone LIKE CONCAT('%', #{clue.phone}, '%')
  149. </if>
  150. <if test="clue.customerLevelId != null and clue.customerLevelId != '' ">
  151. and c.customer_level_id = #{clue.customerLevelId}
  152. </if>
  153. <if test="clue.email != null and clue.email != '' ">
  154. and c.email LIKE CONCAT('%', #{clue.email}, '%')
  155. </if>
  156. <if test="clue.customerIndustryId != null">
  157. and c.customer_industry_id = #{clue.customerIndustryId}
  158. </if>
  159. ORDER BY
  160. <choose>
  161. <when test="isDesc == null">
  162. c.id DESC
  163. </when>
  164. <when test="isDesc == 0">
  165. sd.seq ASC, c.id DESC
  166. </when>
  167. <when test="isDesc == 1">
  168. sd.seq DESC, c.id DESC
  169. </when>
  170. <otherwise>
  171. c.id DESC
  172. </otherwise>
  173. </choose>
  174. limit #{clue.pageIndex},#{clue.pageFrom}
  175. </select>
  176. <select id="list2" resultType="com.management.platform.entity.Clue">
  177. select c.id,
  178. c.company_id,
  179. (select company_name from company where c.company_id = c.id) companyName,
  180. c.clue_name,
  181. c.clue_source_id,
  182. c.phone,
  183. c.email,
  184. c.customer_industry_id,
  185. c.customer_level_id,
  186. c.address,
  187. c.incharger_id,
  188. c.remark,
  189. c.is_delete,
  190. c.plate1,
  191. c.plate2,
  192. c.plate3,
  193. c.plate4,
  194. c.plate5,
  195. c.create_time,
  196. c.create_id,
  197. (select name from `user` where id = c.incharger_id) inchargerName,
  198. (select name from `user` where id = c.create_id) createName,
  199. (select name from sys_dict where c.clue_source_id = id and code = 'ClueSources') clueSourceValue,
  200. (select name from sys_dict where c.customer_industry_id = id and code = 'CustomIndustry') customerIndustryValue,
  201. (select name from sys_dict where c.customer_level_id = id and code = 'CustomLevel') customerLevelValue
  202. from clue c
  203. left join sys_dict sd on c.customer_level_id = sd.id
  204. where
  205. c.company_id = #{clue.companyId} and c.is_delete = #{clue.isDelete} and c.is_bo = 0
  206. and (c.incharger_id = #{userId} or c.incharger_id is null)
  207. <if test="clue.inchargerId != null and clue.inchargerId != '' ">
  208. and c.incharger_id =#{clue.inchargerId}
  209. </if>
  210. <if test="clue.startTime != null and clue.endTime != null ">
  211. and c.create_time BETWEEN #{clue.startTime} and #{clue.endTime}
  212. </if>
  213. <if test="clue.clueName != null and clue.clueName != '' ">
  214. and c.clue_name LIKE CONCAT('%', #{clue.clueName}, '%')
  215. </if>
  216. <if test="clue.phone != null and clue.phone != '' ">
  217. and c.phone LIKE CONCAT('%', #{clue.phone}, '%')
  218. </if>
  219. <if test="clue.customerLevelId != null and clue.customerLevelId != '' ">
  220. and c.customer_level_id = #{clue.customerLevelId}
  221. </if>
  222. <if test="clue.email != null and clue.email != '' ">
  223. and c.email LIKE CONCAT('%', #{clue.email}, '%')
  224. </if>
  225. <if test="clue.clueSourceId != null">
  226. and c.clue_source_id = #{clue.clueSourceId}
  227. </if>
  228. <if test="clue.customerIndustryId != null">
  229. and c.customer_industry_id = #{clue.customerIndustryId}
  230. </if>
  231. ORDER BY
  232. <choose>
  233. <when test="clue.isDesc == null ">
  234. c.id DESC
  235. </when>
  236. <when test="clue.isDesc == 0">
  237. sd.seq ASC, c.id DESC
  238. </when>
  239. <when test="clue.isDesc == 1">
  240. sd.seq DESC, c.id DESC
  241. </when>
  242. <otherwise>
  243. c.id DESC
  244. </otherwise>
  245. </choose>
  246. limit #{clue.pageIndex},#{clue.pageFrom}
  247. </select>
  248. <select id="getTotal" resultType="java.lang.Integer">
  249. select count(*)
  250. from clue c
  251. where
  252. company_id = #{companyId} and is_delete = #{isDelete} and is_bo = 0
  253. <if test="inchargerId != null and inchargerId != '' ">
  254. and incharger_id = #{inchargerId}
  255. </if>
  256. <if test="startTime != null and endTime != null ">
  257. and create_time BETWEEN #{startTime} and #{endTime}
  258. </if>
  259. <if test="clueName != null and clueName != '' ">
  260. and clue_name LIKE CONCAT('%', #{clueName}, '%')
  261. </if>
  262. <if test="phone != null and phone != '' ">
  263. and phone LIKE CONCAT('%', #{phone}, '%')
  264. </if>
  265. <if test="email != null and email != '' ">
  266. and email LIKE CONCAT('%', #{email}, '%')
  267. </if>
  268. <if test="customerLevelId != null and customerLevelId != '' ">
  269. and customer_level_id = #{customerLevelId}
  270. </if>
  271. <if test="clueSourceId != null">
  272. and clue_source_id = #{clueSourceId}
  273. </if>
  274. <if test="customerIndustryId != null">
  275. and customer_industry_id = #{customerIndustryId}
  276. </if>
  277. </select>
  278. <select id="getTotal1" resultType="java.lang.Integer">
  279. select
  280. COUNT(c.id)
  281. from clue c
  282. where
  283. c.company_id = #{clue.companyId} and c.is_delete = #{clue.isDelete} and c.is_bo = 0
  284. and c.incharger_id in
  285. (SELECT id from `user` WHERE department_id = (SELECT department_id from `user` WHERe id = #{userId}))
  286. and c.incharger_id is null
  287. <if test="clue.inchargerId != null and clue.inchargerId != '' ">
  288. and c.incharger_id =#{clue.inchargerId}
  289. </if>
  290. <if test="clue.startTime != null and clue.endTime != null ">
  291. and c.create_time BETWEEN #{clue.startTime} and #{clue.endTime}
  292. </if>
  293. <if test="clue.clueName != null and clue.clueName != '' ">
  294. and c.clue_name LIKE CONCAT('%', #{clue.clueName}, '%')
  295. </if>
  296. <if test="clue.phone != null and clue.phone != '' ">
  297. and c.phone LIKE CONCAT('%', #{clue.phone}, '%')
  298. </if>
  299. <if test="clue.email != null and clue.email != '' ">
  300. and c.email LIKE CONCAT('%', #{clue.email}, '%')
  301. </if>
  302. <if test="clue.clueSourceId != null">
  303. and c.clue_source_id = #{clue.clueSourceId}
  304. </if>
  305. <if test="clue.customerIndustryId != null">
  306. and c.customer_industry_id = #{clue.customerIndustryId}
  307. </if>
  308. <if test="clue.customerLevelId != null">
  309. and c.customerLevelId = #{clue.customerLevelId}
  310. </if>
  311. </select>
  312. <select id="getTotal2" resultType="java.lang.Integer">
  313. select
  314. count(c.id)
  315. from clue c
  316. where
  317. c.company_id = #{clue.companyId} and c.is_delete = #{clue.isDelete} and c.is_bo = 0
  318. and (c.incharger_id = #{userId} or c.incharger_id is null)
  319. <if test="clue.inchargerId != null and clue.inchargerId != '' ">
  320. and c.incharger_id =#{clue.inchargerId}
  321. </if>
  322. <if test="clue.startTime != null and clue.endTime != null ">
  323. and c.create_time BETWEEN #{clue.startTime} and #{clue.endTime}
  324. </if>
  325. <if test="clue.clueName != null and clue.clueName != '' ">
  326. and c.clue_name LIKE CONCAT('%', #{clue.clueName}, '%')
  327. </if>
  328. <if test="clue.phone != null and clue.phone != '' ">
  329. and c.phone LIKE CONCAT('%', #{clue.phone}, '%')
  330. </if>
  331. <if test="clue.customerLevelId != null and clue.customerLevelId != '' ">
  332. and c.customer_level_id = #{clue.customerLevelId}
  333. </if>
  334. <if test="clue.email != null and clue.email != '' ">
  335. and c.email LIKE CONCAT('%', #{clue.email}, '%')
  336. </if>
  337. <if test="clue.clueSourceId != null">
  338. and c.clue_source_id = #{clue.clueSourceId}
  339. </if>
  340. <if test="clue.customerIndustryId != null">
  341. and c.customer_industry_id = #{clue.customerIndustryId}
  342. </if>
  343. </select>
  344. <select id="getDataSummary" resultType="java.util.Map">
  345. SELECT COUNT(*) newNum,SUM(bo.clue_id is not null) as changeNum
  346. FROM clue c
  347. left join business_opportunity bo on c.id=bo.clue_id
  348. WHERE c.company_id=#{companyId} and c.is_delete=0
  349. <if test="startDate!=null and startDate!='' and endDate!=null and endDate!=''">
  350. and DATE_FORMAT(c.create_time,'%Y-%m-%d') BETWEEN #{startDate} AND #{endDate}
  351. </if>
  352. <if test="userId!=null and userId!=''">
  353. and c.incharger_id=#{userId}
  354. </if>
  355. <if test="list!=null and list.size()>0">
  356. and c.incharger_id in
  357. <foreach collection="list" separator="," open="(" close=")" item="item">
  358. #{item}
  359. </foreach>
  360. </if>
  361. </select>
  362. <select id="getAllList" resultType="com.management.platform.entity.Clue">
  363. select id,
  364. clue_name
  365. from clue
  366. where company_id =#{companyId}
  367. </select>
  368. <select id="getAlllist1" resultType="com.management.platform.entity.Clue">
  369. select id,
  370. clue_name
  371. from clue c
  372. left join sys_dict sd on c.customer_level_id = sd.id
  373. where
  374. c.company_id = #{companyId} and is_delete = #{isDelete}
  375. and (c.incharger_id in
  376. (SELECT id from `user` WHERE department_id = (SELECT department_id from `user` WHERe id = #{userId}))
  377. or c.incharger_id is null)
  378. </select>
  379. <select id="getAllList2" resultType="com.management.platform.entity.Clue">
  380. select c.id,
  381. c.clue_name
  382. from clue c
  383. left join sys_dict sd on c.customer_level_id = sd.id
  384. where
  385. c.company_id = #{companyId} and c.is_delete = #{isDelete}
  386. and (c.incharger_id = #{userId} or c.incharger_id is null)
  387. </select>
  388. </mapper>