| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340 |
- <?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.ydtech.modules.admin.dao.TaskStatisticsMapper">
- <select id="getBusinessAgentData" resultType="com.ydtech.modules.admin.model.vo.BusinessAgentData">
- select
- io.userid as "userId",
- su.name as "userName",
- sum(IFNULL(jqpremium, 0) + IFNULL(sypremium, 0)+ IFNULL(jypremium, 0)) as "sumpremium",
- IFNULL(sum(jqpremium),0) as "jqpremium",
- IFNULL(sum(sypremium),0) as "sypremium",
- IFNULL(sum(taxamount),0) as "taxamount",
- IFNULL(sum(jypremium),0) as "jypremium"
- from ins_area_company iac
- left join ins_orders io on io.orderno =iac.orderno
- left join sys_user su on io.userid =su.id
- left join sys_dept sd on sd.id =su.dept_id
- <where>
- iac.orderstatus = '3'
- <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
- AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{vo.createtimeStart}, '%Y-%m-%d') AND
- DATE_FORMAT( #{vo.createtimeEnd}, '%Y-%m-%d')
- </if>
- <if test="vo.days !=null and vo.days !='' and vo.days != 0 ">
- and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{vo.days} DAY)
- </if>
- <if test="vo.userId !=null and vo.userId!=''">
- and su.id=#{vo.userId}
- </if>
- <if test="vo.managementSource !=null and vo.managementSource!=''">
- and sd.management_source=#{vo.managementSource}
- </if>
- <if test="vo.userIds !=null and vo.userIds!='' and vo.userIds.size()>0">
- and su.id in
- <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="vo.userName !=null and vo.userName!=''">
- and su.name=#{vo.userName}
- </if>
- </where>
- group by io.userid,su.name
- </select>
- <select id="getBusinessAgentDataTotal" resultType="java.lang.Long">
- select
- count(0)
- from (
- select
- io.userid
- from ins_area_company iac
- left join ins_orders io on io.orderno =iac.orderno
- left join sys_user su on io.userid =su.id
- left join sys_dept sd on sd.id =su.dept_id
- <where>
- iac.orderstatus = '3'
- <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
- AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{vo.createtimeStart}, '%Y-%m-%d') AND
- DATE_FORMAT( #{vo.createtimeEnd}, '%Y-%m-%d')
- </if>
- <if test="vo.days !=null and vo.days !='' and vo.days != 0 ">
- and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{vo.days} DAY)
- </if>
- <if test="vo.userName !=null and vo.userName!=''">
- and su.name=#{vo.userName}
- </if>
- <if test="vo.userId !=null and vo.userId!=''">
- and su.id=#{vo.userId}
- </if>
- <if test="vo.userIds !=null and vo.userIds!='' and vo.userIds.size()>0">
- and su.id in
- <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="vo.managementSource !=null and vo.managementSource!=''">
- and sd.management_source=#{vo.managementSource}
- </if>
- </where>
- group by io.userid
- ) a
- </select>
- <select id="getBusinessAgentDataTotalAdd" resultType="com.ydtech.modules.admin.model.vo.BusinessAgentData">
- select
- sum(IFNULL(jqpremium, 0) + IFNULL(sypremium, 0)+ IFNULL(jypremium, 0)) as "sumpremium",
- IFNULL(sum(jqpremium),0) as "jqpremium",
- IFNULL(sum(sypremium),0) as "sypremium",
- IFNULL(sum(taxamount),0) as "taxamount",
- IFNULL(sum(jypremium),0) as "jypremium"
- from ins_area_company iac
- left join ins_orders io on io.orderno =iac.orderno
- left join sys_user su on io.userid =su.id
- left join sys_dept sd on sd.id =su.dept_id
- <where>
- iac.orderstatus = '3'
- and io.orderstatus = '3'
- <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
- AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{vo.createtimeStart}, '%Y-%m-%d') AND
- DATE_FORMAT( #{vo.createtimeEnd}, '%Y-%m-%d')
- </if>
- <if test="vo.days !=null and vo.days !='' and vo.days != 0 ">
- and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{vo.days} DAY)
- </if>
- <if test="vo.userName !=null and vo.userName!=''">
- and su.name=#{vo.userName}
- </if>
- <if test="vo.userIds !=null and vo.userIds!='' and vo.userIds.size()>0">
- and su.id in
- <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="vo.userId !=null and vo.userId!=''">
- and su.id=#{vo.userId}
- </if>
- <if test="vo.managementSource !=null and vo.managementSource!=''">
- and sd.management_source=#{vo.managementSource}
- </if>
- </where>
- </select>
- <select id="getAllsumPremium" resultType="com.ydtech.modules.admin.model.vo.BusinessAgentData">
- select
- sum(IFNULL(iac.jqpremium, 0) + IFNULL(iac.sypremium, 0)+ IFNULL(iac.jypremium, 0)) as "sumpremium"
- from ins_area_company iac
- left join ins_orders io on io.orderno =iac.orderno
- left join sys_user su on io.userid =su.id
- left join sys_dept sd on sd.id =su.dept_id
- <where>
- 1=1
- <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
- AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{vo.createtimeStart}, '%Y-%m-%d') AND
- DATE_FORMAT( #{vo.createtimeEnd}, '%Y-%m-%d')
- </if>
- <if test="vo.userName !=null and vo.userName!=''">
- and su.name=#{vo.userName}
- </if>
- <if test="vo.userId !=null and vo.userId!=''">
- and su.id=#{vo.userId}
- </if>
- <if test="vo.userIds !=null and vo.userIds!='' and vo.userIds.size()>0">
- and su.id in
- <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="vo.managementSource !=null and vo.managementSource!=''">
- and sd.management_source=#{vo.managementSource}
- </if>
- </where>
- </select>
- <select id="getBusinessAgentDataDetails" resultType="com.ydtech.modules.admin.model.vo.BusinessAgentData">
- select
- a.insurance_company as "insuranceCompany",
- (IFNULL(a.jqpremium, 0) + IFNULL(a.sypremium, 0)+ IFNULL(a.jypremium, 0)) as "sumpremium",
- a.jqpremium as "jqpremium",
- a.sypremium as "sypremium",
- a.taxamount as "taxamount",
- a.jypremium as "jypremium",
- eic.namesimple as "partnerCompaniesName",
- eic.logo as "logo",
- a.userId as "userId",
- a.userName as "userName"
- from (select pa.insurance_company,
- pa.partner_companies_id,
- su.id as "userId",
- su.name as "userName",
- IFNULL(sum(sumpremium), 0) as "sumpremium",
- IFNULL(sum(jqpremium), 0) as "jqpremium",
- IFNULL(sum(sypremium), 0) as "sypremium",
- IFNULL(sum(taxamount), 0) as "taxamount",
- IFNULL(sum(jypremium), 0) as "jypremium"
- from ins_area_company iac
- left join ins_orders io on io.orderno = iac.orderno
- left join ptl_agreement pa on pa.id = iac.agreement_id
- left join sys_user su on io.userid =su.id
- left join sys_dept sd on sd.id =su.dept_id
- LEFT JOIN esm_ins_company eic on eic.id = pa.partner_companies_id
- <where>
- iac.orderstatus = '3'
- and io.orderstatus = '3'
- <if test="vo.userId !=null and vo.userId!=''">
- and su.id=#{vo.userId}
- </if>
- <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
- AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{vo.createtimeStart}, '%Y-%m-%d') AND
- DATE_FORMAT( #{vo.createtimeEnd}, '%Y-%m-%d')
- </if>
- <if test="vo.managementSource !=null and vo.managementSource!=''">
- and sd.management_source=#{vo.managementSource}
- </if>
- <if test="vo.userIds !=null and vo.userIds!='' and vo.userIds.size()>0">
- and su.id in
- <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- </where>
- group by pa.insurance_company, pa.partner_companies_id ,su.id,su.name) a
- LEFT JOIN esm_ins_company eic ON eic.id = a.partner_companies_id
- </select>
- <select id="getBusinessAgentDataDetailsAdd" resultType="java.lang.Long">
- select
- count(0)
- from (select pa.insurance_company,
- pa.partner_companies_id
- from ins_area_company iac
- left join ins_orders io on io.orderno = iac.orderno
- left join ptl_agreement pa on pa.id = iac.agreement_id
- left join sys_user su on io.userid =su.id
- <where>
- iac.orderstatus = '3'
- and io.orderstatus = '3'
- <if test="vo.userId !=null and vo.userId!=''">
- and su.id=#{vo.userId}
- </if>
- <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
- AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{vo.createtimeStart}, '%Y-%m-%d') AND
- DATE_FORMAT( #{vo.createtimeEnd}, '%Y-%m-%d')
- </if>
- <if test="vo.managementSource !=null and vo.managementSource!=''">
- and sd.management_source=#{vo.managementSource}
- </if>
- </where>
- group by pa.insurance_company, pa.partner_companies_id) a
- </select>
- <select id="channelAgentDetails" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
- SELECT
- iac.inscompany,
- COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS qutationCount,
- COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
- COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
- COUNT( CASE WHEN iac.orderstatus = 4 THEN 1 END ) AS underwritingReturn,
- COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) / COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS "passingRate",
- COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) / COUNT( iac.orderstatus ) AS "closeRate",
- (COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) + COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ))/ COUNT(
- iac.orderstatus ) AS "contributionRate",
- COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) / COUNT( iac.orderstatus ) AS "quotationRate",
- COUNT(CASE WHEN io.order_source = 0 and iac.orderstatus = 0 THEN 1 END) as "pcOrderSource",
- COUNT(CASE WHEN io.order_source = 1 and iac.orderstatus = 0 THEN 1 END) as "appOrderSource",
- COUNT( CASE WHEN iac.orderstatus = 1 THEN 1 END ) AS "auditOrder"
- FROM
- ins_area_company iac
- LEFT JOIN ins_orders io ON io.orderno = iac.orderno
- LEFT JOIN sys_dept sd ON sd.id = io.deptid
- <where>
- 1=1
- <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
- and io.deptid like "${taskStatisticsVo.provinceId}%"
- </if>
- <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
- and io.deptid like "${taskStatisticsVo.cityId}%"
- </if>
- <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
- and io.deptid like "${taskStatisticsVo.countyId}%"
- </if>
- <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
- and io.deptid like "${taskStatisticsVo.houseId}%"
- </if>
- <if test="taskStatisticsVo.userId != null and taskStatisticsVo.userId != ''">
- and io.userid =#{taskStatisticsVo.userId}
- </if>
- <if test="taskStatisticsVo.managementSource != null and taskStatisticsVo.managementSource != ''">
- and sd.management_source =#{taskStatisticsVo.managementSource}
- </if>
- <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
- AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND
- #{taskStatisticsVo.createtimeEnd}
- </if>
- <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
- AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate},
- '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
- </if>
- <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
- and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
- </if>
- <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
- <choose>
- <when test="taskStatisticsVo.days =='1'">
- and io.createtime >= DATE_SUB(NOW(), INTERVAL 1 DAY)
- </when>
- <when test="taskStatisticsVo.days =='7'">
- and io.createtime >= DATE_SUB(NOW(), INTERVAL 7 DAY)
- </when>
- <when test="taskStatisticsVo.days =='30'">
- and io.createtime >= DATE_SUB(NOW(), INTERVAL 30 DAY)
- </when>
- </choose>
- </if>
- </where>
- GROUP BY
- iac.inscompany
- </select>
- </mapper>
|