EmployeeProductivityMapperMapper.xml 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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.fjhx.from.mapper.EmployeeProductivityMapper">
  4. <select id="getList" resultType="com.fjhx.form.entity.EmployeeProductivity">
  5. SELECT
  6. su.user_id,
  7. su.nick_name as userName,
  8. ( SELECT
  9. count( 1 )
  10. FROM
  11. bytesailing_sale.sale_quotation sq
  12. WHERE create_user = su.user_id
  13. <if test="dto.beginTime != null">
  14. AND create_time >= #{dto.beginTime}
  15. </if>
  16. <if test="dto.endTime != null">
  17. AND create_time &lt;= #{dto.endTime}
  18. </if>
  19. ) AS quotationCount,
  20. ( SELECT
  21. count( 1 )
  22. FROM
  23. bytesailing_customer.customer
  24. WHERE create_user = su.user_id
  25. <if test="dto.beginTime != null">
  26. AND create_time >= #{dto.beginTime}
  27. </if>
  28. <if test="dto.endTime != null">
  29. AND create_time &lt;= #{dto.endTime}
  30. </if>
  31. ) AS newCustomerCount,
  32. ( SELECT
  33. COUNT( buy_corporation_id )
  34. FROM
  35. bytesailing_sale.sample
  36. WHERE create_user = su.user_id
  37. <if test="dto.beginTime != null">
  38. AND create_time >= #{dto.beginTime}
  39. </if>
  40. <if test="dto.endTime != null">
  41. AND create_time &lt;= #{dto.endTime}
  42. </if>
  43. ) AS sampleCustomerCount,
  44. (
  45. SELECT
  46. count( c.buy_corporation_id )
  47. FROM
  48. bytesailing_sale.contract c
  49. WHERE
  50. c.buy_corporation_id IN ( SELECT c.id FROM bytesailing_customer.customer c WHERE c.user_id = su.user_id
  51. <if test="dto.beginTime != null">AND c.create_time >= #{dto.beginTime}</if>
  52. <if test="dto.endTime != null">AND c.create_time &lt;= #{dto.endTime}</if>
  53. )
  54. <if test="dto.beginTime != null">
  55. AND c.create_time >= #{dto.beginTime}
  56. </if>
  57. <if test="dto.endTime != null">
  58. AND c.create_time &lt;= #{dto.endTime}
  59. </if>
  60. AND NOT c.`status` IN ( 0, 70, 88 )
  61. AND c.del_flag=0
  62. ) AS newDealCustomerCount,
  63. (
  64. SELECT
  65. count( c.buy_corporation_id )
  66. FROM
  67. bytesailing_sale.contract c
  68. WHERE
  69. c.create_user = su.user_id
  70. <if test="dto.beginTime != null">
  71. AND c.create_time >= #{dto.beginTime}
  72. </if>
  73. <if test="dto.endTime != null">
  74. AND c.create_time &lt;= #{dto.endTime}
  75. </if>
  76. AND NOT c.`status` IN ( 0, 70, 88 )
  77. AND c.del_flag = 0
  78. ) as contractCustomerCount,
  79. ( SELECT count( 1 ) FROM bytesailing_customer.customer WHERE user_id = su.user_id AND del_flag = 0 ) AS
  80. customerCount,
  81. ( SELECT
  82. count( 1 )
  83. FROM bytesailing_sale.sample
  84. WHERE create_user = su.user_id
  85. <if test="dto.beginTime != null">
  86. AND create_time >= #{dto.beginTime}
  87. </if>
  88. <if test="dto.endTime != null">
  89. AND create_time &lt;= #{dto.endTime}
  90. </if>
  91. AND del_flag = 0
  92. ) AS sampleCount,
  93. (
  94. SELECT
  95. count( 1 )
  96. FROM
  97. bytesailing_sale.contract c
  98. WHERE
  99. c.buy_corporation_id IN ( SELECT c.id FROM bytesailing_customer.customer c WHERE c.user_id = su.user_id
  100. <if test="dto.beginTime != null">AND c.create_time >= #{dto.beginTime}</if>
  101. <if test="dto.endTime != null">AND c.create_time &lt;= #{dto.endTime}</if>
  102. )
  103. <if test="dto.beginTime != null">
  104. AND c.create_time >= #{dto.beginTime}
  105. </if>
  106. <if test="dto.endTime != null">
  107. AND c.create_time &lt;= #{dto.endTime}
  108. </if>
  109. AND NOT c.`status` IN ( 0, 70, 88 )
  110. AND c.del_flag = 0
  111. ) AS newCustomerContractCount,
  112. (
  113. SELECT
  114. IFNULL( sum( c.amount * c.rate ), 0 )
  115. FROM
  116. bytesailing_sale.contract c
  117. WHERE
  118. c.buy_corporation_id IN ( SELECT c.id FROM bytesailing_customer.customer c WHERE c.user_id = su.user_id
  119. <if test="dto.beginTime != null">AND c.create_time >= #{dto.beginTime}</if>
  120. <if test="dto.endTime != null">AND c.create_time &lt;= #{dto.endTime}</if>
  121. )
  122. <if test="dto.beginTime != null">
  123. AND c.create_time >= #{dto.beginTime}
  124. </if>
  125. <if test="dto.endTime != null">
  126. AND c.create_time &lt;= #{dto.endTime}
  127. </if>
  128. AND NOT c.`status` IN ( 0, 70, 88 )
  129. AND c.del_flag = 0
  130. ) AS newCustomerContractCnyAmount,
  131. (
  132. SELECT
  133. count( 1 )
  134. FROM
  135. bytesailing_sale.contract c
  136. WHERE
  137. NOT c.buy_corporation_id IN ( SELECT c.id FROM bytesailing_customer.customer c WHERE c.user_id = su.user_id
  138. <if test="dto.beginTime != null">AND c.create_time >= #{dto.beginTime}</if>
  139. <if test="dto.endTime != null">AND c.create_time &lt;= #{dto.endTime}</if>
  140. )
  141. <if test="dto.beginTime != null">
  142. AND c.create_time >= #{dto.beginTime}
  143. </if>
  144. <if test="dto.endTime != null">
  145. AND c.create_time &lt;= #{dto.endTime}
  146. </if>
  147. AND NOT c.`status` IN ( 0, 70, 88 )
  148. AND c.del_flag = 0
  149. ) AS oldCustomerContractCount,
  150. (
  151. SELECT
  152. IFNULL( sum( c.amount * c.rate ), 0 )
  153. FROM
  154. bytesailing_sale.contract c
  155. WHERE
  156. NOT c.buy_corporation_id IN ( SELECT c.id FROM bytesailing_customer.customer c WHERE c.user_id = su.user_id
  157. <if test="dto.beginTime != null">AND c.create_time >= #{dto.beginTime}</if>
  158. <if test="dto.endTime != null">AND c.create_time &lt;= #{dto.endTime}</if>
  159. )
  160. <if test="dto.beginTime != null">
  161. AND c.create_time >= #{dto.beginTime}
  162. </if>
  163. <if test="dto.endTime != null">
  164. AND c.create_time &lt;= #{dto.endTime}
  165. </if>
  166. AND NOT c.`status` IN ( 0, 70, 88 )
  167. AND c.del_flag = 0
  168. ) AS oldCustomerContractCnyAmount,
  169. (
  170. SELECT
  171. count(1)
  172. FROM
  173. bytesailing_sale.contract c
  174. WHERE
  175. <if test="dto.beginTime != null">
  176. c.create_time >= #{dto.beginTime}
  177. </if>
  178. <if test="dto.endTime != null">
  179. AND c.create_time &lt;= #{dto.endTime}
  180. </if>
  181. AND NOT c.`status` IN ( 0, 70, 88 )
  182. AND c.del_flag = 0
  183. ) AS contractCount
  184. FROM
  185. sys_user su
  186. JOIN sys_user_role sur ON sur.user_id = su.user_id
  187. JOIN sys_role sr ON sr.role_id = sur.role_id
  188. ${ew.customSqlSegment}
  189. </select>
  190. <select id="getUserEmailCount" resultType="com.fjhx.form.entity.EmailCount">
  191. SELECT count(1) count,
  192. t1.user_id
  193. FROM
  194. (
  195. SELECT
  196. em.id, em.send_date, em.from_email, emb.user_id, CONCAT( emb.mail_user_prefix, '@', ed.domain_name ) AS mail_user
  197. FROM
  198. enterprise_message em
  199. JOIN enterprise_mailbox emb ON em.mailbox_id = emb.id
  200. JOIN enterprise_domain ed ON emb.domain_id = ed.id UNION ALL
  201. SELECT
  202. pm.id, pm.send_date, pm.from_email, pmb.user_id, pmb.mail_user
  203. FROM
  204. personal_message pm
  205. JOIN personal_mailbox pmb ON pm.mailbox_id = pmb.id
  206. ) t1
  207. ${ew.customSqlSegment}
  208. </select>
  209. </mapper>