TaskMapper.xml 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  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.TaskMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.management.platform.entity.Task">
  6. <id column="id" property="id" />
  7. <result column="task_name" property="taskName" />
  8. <result column="company_id" property="companyId" />
  9. <result column="owner_id" property="ownerId" />
  10. <result column="contacts_id" property="contactsId" />
  11. <result column="executor_id" property="executorId" />
  12. <result column="clue_id" property="clueId" />
  13. <result column="custom_id" property="customId" />
  14. <result column="business_opportunity_id" property="businessOpportunityId" />
  15. <result column="order_id" property="orderId" />
  16. <result column="product_id" property="productId" />
  17. <result column="status" property="status" />
  18. <result column="priority" property="priority" />
  19. <result column="is_repeat" property="isRepeat" />
  20. <result column="repeat_type" property="repeatType" />
  21. <result column="repeat_end_never" property="repeatEndNever" />
  22. <result column="repeat_end_count" property="repeatEndCount" />
  23. <result column="repeat_end_date" property="repeatEndDate" />
  24. <result column="repeat_design_day" property="repeatDesignDay" />
  25. <result column="repeat_design_sameday" property="repeatDesignSameday" />
  26. <result column="task_desc" property="taskDesc" />
  27. <result column="creater_id" property="createrId" />
  28. <result column="creater_name" property="createrName" />
  29. <result column="create_date" property="createDate" />
  30. <result column="end_date" property="endDate" />
  31. <result column="start_date" property="startDate" />
  32. <result column="finish_date" property="finishDate" />
  33. <result column="is_delete" property="isDelete" />
  34. <result column="task_type" property="taskType" />
  35. <result column="end_type" property="endType" />
  36. <result column="plate1" property="plate1" />
  37. <result column="plate2" property="plate2" />
  38. <result column="plate3" property="plate3" />
  39. <result column="plate4" property="plate4" />
  40. <result column="plate5" property="plate5" />
  41. </resultMap>
  42. <!-- 通用查询结果列 -->
  43. <sql id="Base_Column_List">
  44. id, task_name, company_id, owner_id, contacts_id, executor_id, clue_id, custom_id, business_opportunity_id, order_id, product_id, status, priority, is_repeat, repeat_type, repeat_end_never, repeat_end_count, repeat_end_date, repeat_design_day, repeat_design_sameday, task_desc, creater_id, creater_name, create_date, end_date, start_date, finish_date, is_delete, task_type, end_type, plate1, plate2, plate3, plate4, plate5
  45. </sql>
  46. <resultMap id="TaskVoMap" type="com.management.platform.entity.vo.TasKVo">
  47. <id column="id" property="id" />
  48. <result column="task_name" property="taskName" />
  49. <result column="company_id" property="companyId" />
  50. <result column="owner_id" property="ownerId" />
  51. <result column="contacts_id" property="contactsId" />
  52. <result column="executor_id" property="executorId" />
  53. <result column="clue_id" property="clueId" />
  54. <result column="custom_id" property="customId" />
  55. <result column="business_opportunity_id" property="businessOpportunityId" />
  56. <result column="order_id" property="orderId" />
  57. <result column="product_id" property="productId" />
  58. <result column="status" property="status" />
  59. <result column="priority" property="priority" />
  60. <result column="is_repeat" property="isRepeat" />
  61. <result column="repeat_type" property="repeatType" />
  62. <result column="repeat_end_never" property="repeatEndNever" />
  63. <result column="repeat_end_count" property="repeatEndCount" />
  64. <result column="repeat_end_date" property="repeatEndDate" />
  65. <result column="repeat_design_day" property="repeatDesignDay" />
  66. <result column="repeat_design_sameday" property="repeatDesignSameday" />
  67. <result column="task_desc" property="taskDesc" />
  68. <result column="creater_id" property="createrId" />
  69. <result column="creater_name" property="createrName" />
  70. <result column="create_date" property="createDate" />
  71. <result column="end_date" property="endDate" />
  72. <result column="start_date" property="startDate" />
  73. <result column="finish_date" property="finishDate" />
  74. <result column="is_delete" property="isDelete" />
  75. <result column="task_type" property="taskType" />
  76. <result column="end_type" property="endType" />
  77. <result column="plate1" property="plate1" />
  78. <result column="plate2" property="plate2" />
  79. <result column="plate3" property="plate3" />
  80. <result column="plate4" property="plate4" />
  81. <result column="plate5" property="plate5" />
  82. <result column="custom_name" property="customName"/>
  83. <result column="businessName" property="businessName"/>
  84. <result column="order_name" property="orderName"/>
  85. <result column="clue_name" property="clueName"/>
  86. <result column="contacts_name" property="contactsName"/>
  87. <result column="contacts_phone" property="contactsPhone"/>
  88. </resultMap>
  89. <resultMap id="TaskPinVoMap" type="com.management.platform.entity.vo.TasKVo">
  90. <id column="id" property="id" />
  91. <result column="task_name" property="taskName" />
  92. <result column="company_id" property="companyId" />
  93. <result column="owner_id" property="ownerId" />
  94. <result column="contacts_id" property="contactsId" />
  95. <result column="executor_id" property="executorId" />
  96. <result column="clue_id" property="clueId" />
  97. <result column="custom_id" property="customId" />
  98. <result column="business_opportunity_id" property="businessOpportunityId" />
  99. <result column="order_id" property="orderId" />
  100. <result column="product_id" property="productId" />
  101. <result column="status" property="status" />
  102. <result column="priority" property="priority" />
  103. <result column="is_repeat" property="isRepeat" />
  104. <result column="repeat_type" property="repeatType" />
  105. <result column="repeat_end_never" property="repeatEndNever" />
  106. <result column="repeat_end_count" property="repeatEndCount" />
  107. <result column="repeat_end_date" property="repeatEndDate" />
  108. <result column="repeat_design_day" property="repeatDesignDay" />
  109. <result column="repeat_design_sameday" property="repeatDesignSameday" />
  110. <result column="task_desc" property="taskDesc" />
  111. <result column="creater_id" property="createrId" />
  112. <result column="creater_name" property="createrName" />
  113. <result column="create_date" property="createDate" />
  114. <result column="end_date" property="endDate" />
  115. <result column="start_date" property="startDate" />
  116. <result column="finish_date" property="finishDate" />
  117. <result column="is_delete" property="isDelete" />
  118. <result column="task_type" property="taskType" />
  119. <result column="end_type" property="endType" />
  120. <result column="plate1" property="plate1" />
  121. <result column="plate2" property="plate2" />
  122. <result column="plate3" property="plate3" />
  123. <result column="plate4" property="plate4" />
  124. <result column="plate5" property="plate5" />
  125. <result column="need_pin" property="needPin"></result>
  126. <result column="pin_time" property="pinTime"></result>
  127. <result column="custom_name" property="customName"/>
  128. <result column="businessName" property="businessName"/>
  129. <result column="order_name" property="orderName"/>
  130. <result column="clue_name" property="clueName"/>
  131. <result column="contacts_name" property="contactsName"/>
  132. <result column="contacts_phone" property="contactsPhone"/>
  133. </resultMap>
  134. <select id="getPageListTask" resultMap="TaskVoMap">
  135. select DISTINCT task.* ,
  136. custom.custom_name,
  137. business_opportunity.name businessName,
  138. `sales_order`.order_name ,
  139. clue.clue_name,
  140. contacts.name contacts_name ,contacts.phone contacts_phone
  141. from task
  142. left join custom on task.custom_id=custom.id
  143. left join business_opportunity on task.business_opportunity_id=business_opportunity.id
  144. left join `sales_order` on task.order_id=`sales_order`.id
  145. left join clue on task.clue_id=clue.id
  146. left join contacts on task.contacts_id=contacts.id
  147. <if test=" executorName!= null and executorName != '' " >
  148. inner join task_executor te on task.id=te.task_id
  149. </if>
  150. <if test=" departmentId!= null " >
  151. inner join task_executor on task.id=task_executor.task_id
  152. </if>
  153. <if test=" departmentIdByMyselfOrNull!= null and departmentIdByMyselfOrNull != '' " >
  154. inner join task_executor on task.id=task_executor.task_id
  155. </if>
  156. <where>
  157. and 1=1 and task.is_delete=0
  158. <if test=" taskName!= null and taskName != ''">
  159. AND task.task_name LIKE CONCAT('%', #{taskName}, '%')
  160. </if>
  161. <if test=" priority!= null ">
  162. AND task.priority =#{priority}
  163. </if>
  164. <if test=" customName!= null and customName != ''">
  165. AND custom.custom_name LIKE CONCAT('%', #{customName}, '%')
  166. </if>
  167. <if test=" contactsName!= null and contactsName != ''">
  168. AND contacts.name LIKE CONCAT('%', #{contactsName}, '%')
  169. </if>
  170. <if test=" businessName!= null and businessName != ''">
  171. AND business_opportunity.name LIKE CONCAT('%', #{businessName}, '%')
  172. </if>
  173. <if test=" orderName!= null and orderName != ''">
  174. AND `sales_order`.order_name LIKE CONCAT('%', #{orderName}, '%')
  175. </if>
  176. <if test=" clueName!= null and clueName != ''">
  177. AND clue.clue_name LIKE CONCAT('%', #{clueName}, '%')
  178. </if>
  179. <if test=" phone!= null and phone != ''">
  180. AND contacts.phone LIKE CONCAT('%', #{phone}, '%')
  181. </if>
  182. <if test=" status!= null ">
  183. AND task.status = #{status}
  184. </if>
  185. <if test=" executorName!= null and executorName != '' ">
  186. AND te.executor_name LIKE CONCAT('%', #{executorName}, '%')
  187. </if>
  188. <if test=" startDate!= null">
  189. AND task.start_date &gt; #{startDate}
  190. </if>
  191. <if test=" endDate!= null">
  192. AND task.end_date &lt; #{endDate}
  193. </if>
  194. <if test=" companyId!= null ">
  195. AND task.company_id = #{companyId}
  196. </if>
  197. <if test=" departmentId!= null " >
  198. AND task_executor.task_id in ( SELECT DISTINCT te.task_id FROM task_executor te
  199. LEFT JOIN `user` u ON u.id=te.executor_id
  200. where u.department_id = #{departmentId} )
  201. </if>
  202. <if test=" departmentIdByMyselfOrNull!= null and departmentIdByMyselfOrNull != '' " >
  203. AND task_executor.task_id in ( SELECT DISTINCT te.task_id FROM task_executor te
  204. where te.executor_id= #{departmentIdByMyselfOrNull } or te.executor_id is null )
  205. </if>
  206. </where>
  207. order by task.create_date desc
  208. <if test="pageIndex != null and pageSize != null">
  209. LIMIT #{pageIndex}, #{pageSize}
  210. </if>
  211. </select>
  212. <select id="getPageListTotalTask" resultMap="TaskVoMap">
  213. select DISTINCT task.id
  214. from task
  215. left join custom on task.custom_id=custom.id
  216. left join business_opportunity on task.business_opportunity_id=business_opportunity.id
  217. left join `sales_order` on task.order_id=`sales_order`.id
  218. left join clue on task.clue_id=clue.id
  219. left join contacts on task.contacts_id=contacts.id
  220. <if test=" executorName!= null and executorName != '' " >
  221. inner join task_executor te on task.id=te.task_id
  222. </if>
  223. <if test=" departmentId!= null " >
  224. inner join task_executor on task.id=task_executor.task_id
  225. </if>
  226. <if test=" departmentIdByMyselfOrNull!= null and departmentIdByMyselfOrNull != '' " >
  227. inner join task_executor on task.id=task_executor.task_id
  228. </if>
  229. <where>
  230. and 1=1 and task.is_delete=0
  231. <if test=" taskName!= null and taskName != ''">
  232. AND task.task_name LIKE CONCAT('%', #{taskName}, '%')
  233. </if>
  234. <if test=" priority!= null ">
  235. AND task.priority =#{priority}
  236. </if>
  237. <if test=" customName!= null and customName != ''">
  238. AND custom.custom_name LIKE CONCAT('%', #{customName}, '%')
  239. </if>
  240. <if test=" contactsName!= null and contactsName != ''">
  241. AND contacts.name LIKE CONCAT('%', #{contactsName}, '%')
  242. </if>
  243. <if test=" businessName!= null and businessName != ''">
  244. AND business_opportunity.name LIKE CONCAT('%', #{businessName}, '%')
  245. </if>
  246. <if test=" orderName!= null and orderName != ''">
  247. AND `sales_order`.order_name LIKE CONCAT('%', #{orderName}, '%')
  248. </if>
  249. <if test=" clueName!= null and clueName != ''">
  250. AND clue.clue_name LIKE CONCAT('%', #{clueName}, '%')
  251. </if>
  252. <if test=" phone!= null and phone != ''">
  253. AND contacts.phone LIKE CONCAT('%', #{phone}, '%')
  254. </if>
  255. <if test=" status!= null ">
  256. AND task.status = #{status}
  257. </if>
  258. <if test=" executorName!= null and executorName != '' ">
  259. AND te.executor_name LIKE CONCAT('%', #{executorName}, '%')
  260. </if>
  261. <if test=" startDate!= null ">
  262. AND task.start_date &gt; #{startDate}
  263. </if>
  264. <if test=" endDate!= null ">
  265. AND task.end_date &lt; #{endDate}
  266. </if>
  267. <if test=" companyId!= null ">
  268. AND task.company_id = #{companyId}
  269. </if>
  270. <if test=" departmentId!= null " >
  271. AND task_executor.task_id in ( SELECT DISTINCT te.task_id FROM task_executor te
  272. LEFT JOIN `user` u ON u.id=te.executor_id
  273. where u.department_id = #{departmentId} )
  274. </if>
  275. <if test=" departmentIdByMyselfOrNull!= null and departmentIdByMyselfOrNull != '' " >
  276. AND task_executor.task_id in ( SELECT DISTINCT te.task_id FROM task_executor te
  277. where te.executor_id= #{departmentIdByMyselfOrNull} or te.executor_id is null )
  278. </if>
  279. </where>
  280. </select>
  281. <select id="getListByTaskIds" resultType="com.management.platform.entity.vo.TasKVo">
  282. select task.* ,
  283. custom.custom_name,
  284. business_opportunity.name businessName,
  285. `sales_order`.order_name ,
  286. clue.clue_name,
  287. contacts.name contacts_name ,contacts.phone
  288. from task
  289. left join custom on task.custom_id=custom.id
  290. left join business_opportunity on task.business_opportunity_id=business_opportunity.id
  291. left join `sales_order` on task.order_id=`sales_order`.id
  292. left join clue on task.clue_id=clue.id
  293. left join contacts on task.contacts_id=contacts.id
  294. WHERE task.id IN
  295. <foreach item="taskId" collection="taskIdArray" open="(" separator="," close=")">
  296. #{taskId}
  297. </foreach>
  298. </select>
  299. <select id="getPageListTaskByPin" resultMap="TaskPinVoMap">
  300. select DISTINCT task.* ,
  301. custom.custom_name,
  302. business_opportunity.name businessName,
  303. `sales_order`.order_name ,
  304. clue.clue_name,
  305. contacts.name contacts_name ,contacts.phone contacts_phone
  306. from task
  307. left join custom on task.custom_id=custom.id
  308. left join business_opportunity on task.business_opportunity_id=business_opportunity.id
  309. left join `sales_order` on task.order_id=`sales_order`.id
  310. left join clue on task.clue_id=clue.id
  311. left join contacts on task.contacts_id=contacts.id
  312. <if test=" executorName!= null and executorName != '' " >
  313. inner join task_executor te on task.id=te.task_id
  314. </if>
  315. <if test=" departmentId!= null " >
  316. inner join task_executor on task.id=task_executor.task_id
  317. </if>
  318. <if test=" departmentIdByMyselfOrNull!= null and departmentIdByMyselfOrNull != '' " >
  319. inner join task_executor on task.id=task_executor.task_id
  320. </if>
  321. <where>
  322. and 1=1 and task.is_delete=0
  323. <if test=" taskName!= null and taskName != ''">
  324. AND task.task_name LIKE CONCAT('%', #{taskName}, '%')
  325. </if>
  326. <if test=" priority!= null ">
  327. AND task.priority =#{priority}
  328. </if>
  329. <if test=" customName!= null and customName != ''">
  330. AND custom.custom_name LIKE CONCAT('%', #{customName}, '%')
  331. </if>
  332. <if test=" contactsName!= null and contactsName != ''">
  333. AND contacts.name LIKE CONCAT('%', #{contactsName}, '%')
  334. </if>
  335. <if test=" businessName!= null and businessName != ''">
  336. AND business_opportunity.name LIKE CONCAT('%', #{businessName}, '%')
  337. </if>
  338. <if test=" orderName!= null and orderName != ''">
  339. AND `sales_order`.order_name LIKE CONCAT('%', #{orderName}, '%')
  340. </if>
  341. <if test=" clueName!= null and clueName != ''">
  342. AND clue.clue_name LIKE CONCAT('%', #{clueName}, '%')
  343. </if>
  344. <if test=" phone!= null and phone != ''">
  345. AND contacts.phone LIKE CONCAT('%', #{phone}, '%')
  346. </if>
  347. <if test=" status!= null ">
  348. AND task.status = #{status}
  349. </if>
  350. <if test=" executorName!= null and executorName != '' ">
  351. AND te.executor_name LIKE CONCAT('%', #{executorName}, '%')
  352. </if>
  353. <if test=" startDate!= null">
  354. AND task.start_date &gt; #{startDate}
  355. </if>
  356. <if test=" endDate!= null">
  357. AND task.end_date &lt; #{endDate}
  358. </if>
  359. <if test=" companyId!= null ">
  360. AND task.company_id = #{companyId}
  361. </if>
  362. <if test=" departmentId!= null " >
  363. AND task_executor.task_id in ( SELECT DISTINCT te.task_id FROM task_executor te
  364. LEFT JOIN `user` u ON u.id=te.executor_id
  365. where u.department_id = #{departmentId} )
  366. </if>
  367. <if test=" departmentIdByMyselfOrNull!= null and departmentIdByMyselfOrNull != '' " >
  368. AND task_executor.task_id in ( SELECT DISTINCT te.task_id FROM task_executor te
  369. where te.executor_id= #{departmentIdByMyselfOrNull } or te.executor_id is null )
  370. </if>
  371. </where>
  372. order by task.need_pin desc,task.pin_time desc,task.create_date desc
  373. <if test="pageIndex != null and pageSize != null">
  374. LIMIT #{pageIndex}, #{pageSize}
  375. </if>
  376. </select>
  377. <update id="updateRepeatConfig">
  378. update task
  379. <set>
  380. repeat_type=#{repeatType},repeat_end_never=#{repeatEndNever},repeat_end_count=#{repeatEndCount},
  381. repeat_end_date=#{repeatEndDate},repeat_design_day=#{repeatDesignDay},repeat_design_sameday=#{repeatDesignSameday},
  382. custom_id=#{customId},business_opportunity_id=#{businessOpportunityId},order_id=#{orderId},clue_id=#{clueId},contacts_id=#{contactsId}
  383. </set>
  384. where id=#{id}
  385. </update>
  386. </mapper>