123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.fjhx.from.mapper.EmployeeProductivityMapper">
- <select id="getList" resultType="com.fjhx.form.entity.EmployeeProductivity">
- SELECT
- su.user_id,
- su.nick_name as userName,
- ( SELECT
- count( 1 )
- FROM
- bytesailing_sale.sale_quotation sq
- WHERE create_user = su.user_id
- <if test="dto.beginTime != null">
- AND create_time >= #{dto.beginTime}
- </if>
- <if test="dto.endTime != null">
- AND create_time <= #{dto.endTime}
- </if>
- ) AS quotationCount,
- ( SELECT
- count( 1 )
- FROM
- bytesailing_customer.customer
- WHERE create_user = su.user_id
- <if test="dto.beginTime != null">
- AND create_time >= #{dto.beginTime}
- </if>
- <if test="dto.endTime != null">
- AND create_time <= #{dto.endTime}
- </if>
- ) AS newCustomerCount,
- ( SELECT
- COUNT( buy_corporation_id )
- FROM
- bytesailing_sale.sample
- WHERE create_user = su.user_id
- <if test="dto.beginTime != null">
- AND create_time >= #{dto.beginTime}
- </if>
- <if test="dto.endTime != null">
- AND create_time <= #{dto.endTime}
- </if>
- ) AS sampleCustomerCount,
- (
- SELECT
- count( c.buy_corporation_id )
- FROM
- bytesailing_sale.contract c
- WHERE
- c.buy_corporation_id IN ( SELECT c.id FROM bytesailing_customer.customer c WHERE c.user_id = su.user_id
- <if test="dto.beginTime != null">AND c.create_time >= #{dto.beginTime}</if>
- <if test="dto.endTime != null">AND c.create_time <= #{dto.endTime}</if>
- )
- <if test="dto.beginTime != null">
- AND c.create_time >= #{dto.beginTime}
- </if>
- <if test="dto.endTime != null">
- AND c.create_time <= #{dto.endTime}
- </if>
- AND NOT c.`status` IN ( 0, 70, 88 )
- AND c.del_flag=0
- ) AS newDealCustomerCount,
- (
- SELECT
- count( c.buy_corporation_id )
- FROM
- bytesailing_sale.contract c
- WHERE
- c.create_user = su.user_id
- <if test="dto.beginTime != null">
- AND c.create_time >= #{dto.beginTime}
- </if>
- <if test="dto.endTime != null">
- AND c.create_time <= #{dto.endTime}
- </if>
- AND NOT c.`status` IN ( 0, 70, 88 )
- AND c.del_flag = 0
- ) as contractCustomerCount,
- ( SELECT count( 1 ) FROM bytesailing_customer.customer WHERE user_id = su.user_id AND del_flag = 0 ) AS
- customerCount,
- ( SELECT
- count( 1 )
- FROM bytesailing_sale.sample
- WHERE create_user = su.user_id
- <if test="dto.beginTime != null">
- AND create_time >= #{dto.beginTime}
- </if>
- <if test="dto.endTime != null">
- AND create_time <= #{dto.endTime}
- </if>
- AND del_flag = 0
- ) AS sampleCount,
- (
- SELECT
- count( 1 )
- FROM
- bytesailing_sale.contract c
- WHERE
- c.buy_corporation_id IN ( SELECT c.id FROM bytesailing_customer.customer c WHERE c.user_id = su.user_id
- <if test="dto.beginTime != null">AND c.create_time >= #{dto.beginTime}</if>
- <if test="dto.endTime != null">AND c.create_time <= #{dto.endTime}</if>
- )
- <if test="dto.beginTime != null">
- AND c.create_time >= #{dto.beginTime}
- </if>
- <if test="dto.endTime != null">
- AND c.create_time <= #{dto.endTime}
- </if>
- AND NOT c.`status` IN ( 0, 70, 88 )
- AND c.del_flag = 0
- ) AS newCustomerContractCount,
- (
- SELECT
- IFNULL( sum( c.amount * c.rate ), 0 )
- FROM
- bytesailing_sale.contract c
- WHERE
- c.buy_corporation_id IN ( SELECT c.id FROM bytesailing_customer.customer c WHERE c.user_id = su.user_id
- <if test="dto.beginTime != null">AND c.create_time >= #{dto.beginTime}</if>
- <if test="dto.endTime != null">AND c.create_time <= #{dto.endTime}</if>
- )
- <if test="dto.beginTime != null">
- AND c.create_time >= #{dto.beginTime}
- </if>
- <if test="dto.endTime != null">
- AND c.create_time <= #{dto.endTime}
- </if>
- AND NOT c.`status` IN ( 0, 70, 88 )
- AND c.del_flag = 0
- ) AS newCustomerContractCnyAmount,
- (
- SELECT
- count( 1 )
- FROM
- bytesailing_sale.contract c
- WHERE
- NOT c.buy_corporation_id IN ( SELECT c.id FROM bytesailing_customer.customer c WHERE c.user_id = su.user_id
- <if test="dto.beginTime != null">AND c.create_time >= #{dto.beginTime}</if>
- <if test="dto.endTime != null">AND c.create_time <= #{dto.endTime}</if>
- )
- <if test="dto.beginTime != null">
- AND c.create_time >= #{dto.beginTime}
- </if>
- <if test="dto.endTime != null">
- AND c.create_time <= #{dto.endTime}
- </if>
- AND NOT c.`status` IN ( 0, 70, 88 )
- AND c.del_flag = 0
- ) AS oldCustomerContractCount,
- (
- SELECT
- IFNULL( sum( c.amount * c.rate ), 0 )
- FROM
- bytesailing_sale.contract c
- WHERE
- NOT c.buy_corporation_id IN ( SELECT c.id FROM bytesailing_customer.customer c WHERE c.user_id = su.user_id
- <if test="dto.beginTime != null">AND c.create_time >= #{dto.beginTime}</if>
- <if test="dto.endTime != null">AND c.create_time <= #{dto.endTime}</if>
- )
- <if test="dto.beginTime != null">
- AND c.create_time >= #{dto.beginTime}
- </if>
- <if test="dto.endTime != null">
- AND c.create_time <= #{dto.endTime}
- </if>
- AND NOT c.`status` IN ( 0, 70, 88 )
- AND c.del_flag = 0
- ) AS oldCustomerContractCnyAmount,
- (
- SELECT
- count(1)
- FROM
- bytesailing_sale.contract c
- WHERE
- <if test="dto.beginTime != null">
- c.create_time >= #{dto.beginTime}
- </if>
- <if test="dto.endTime != null">
- AND c.create_time <= #{dto.endTime}
- </if>
- AND NOT c.`status` IN ( 0, 70, 88 )
- AND c.del_flag = 0
- ) AS contractCount
- FROM
- sys_user su
- JOIN sys_user_role sur ON sur.user_id = su.user_id
- JOIN sys_role sr ON sr.role_id = sur.role_id
- ${ew.customSqlSegment}
- </select>
- <select id="getUserEmailCount" resultType="com.fjhx.form.entity.EmailCount">
- SELECT count(1) count,
- t1.user_id
- FROM
- (
- SELECT
- em.id, em.send_date, em.from_email, emb.user_id, CONCAT( emb.mail_user_prefix, '@', ed.domain_name ) AS mail_user
- FROM
- enterprise_message em
- JOIN enterprise_mailbox emb ON em.mailbox_id = emb.id
- JOIN enterprise_domain ed ON emb.domain_id = ed.id UNION ALL
- SELECT
- pm.id, pm.send_date, pm.from_email, pmb.user_id, pmb.mail_user
- FROM
- personal_message pm
- JOIN personal_mailbox pmb ON pm.mailbox_id = pmb.id
- ) t1
- ${ew.customSqlSegment}
- </select>
- </mapper>
|