|
@@ -5,170 +5,167 @@
|
|
|
<mapper namespace="com.ydtech.modules.admin.dao.TaskStatisticsMapper">
|
|
<mapper namespace="com.ydtech.modules.admin.dao.TaskStatisticsMapper">
|
|
|
|
|
|
|
|
<select id="getBusinessAgentData" resultType="com.ydtech.modules.admin.model.vo.BusinessAgentData">
|
|
<select id="getBusinessAgentData" resultType="com.ydtech.modules.admin.model.vo.BusinessAgentData">
|
|
|
- select
|
|
|
|
|
- su.id as "userId",
|
|
|
|
|
- su.name as "userName",
|
|
|
|
|
- sd.id as "deptId",
|
|
|
|
|
- su.leader_name as "leaderName",
|
|
|
|
|
- IFNULL(a.sumpremium,0) as "sumpremium",
|
|
|
|
|
- IFNULL(a.jqpremium,0) as "jqpremium",
|
|
|
|
|
- IFNULL(a.sypremium,0) as "sypremium",
|
|
|
|
|
- IFNULL(a.taxamount,0) as "taxamount",
|
|
|
|
|
- IFNULL(a.jypremium,0) as "jypremium",
|
|
|
|
|
- IFNULL(a.riskCodeJs,0) as "riskCodeJs",
|
|
|
|
|
- IFNULL(a.riskCodeDj,0) as "riskCodeDj" ,
|
|
|
|
|
- IFNULL(a.riskCodeJshang,0) as "riskCodeJshang",
|
|
|
|
|
- IFNULL(a.riskCodeDs,0) as "riskCodeDs",
|
|
|
|
|
- IFNULL(a.riskCodeDsan,0) as "riskCodeDsan",
|
|
|
|
|
- sd.management_source as "managementSource",
|
|
|
|
|
- IFNULL(IFNULL(a.entranceAllFee,0) -IFNULL(a.exportAllFee,0),0) as "distributionAmount",
|
|
|
|
|
- (IFNULL(IFNULL(a.entranceAllFee,0) -IFNULL(a.exportAllFee,0),0)) / a.sumpremium as "distributionAmountRate"
|
|
|
|
|
- from sys_user su
|
|
|
|
|
- left join sys_dept sd on sd.id =su.dept_id
|
|
|
|
|
- LEFT JOIN sys_user_role sur ON sur.user_id = su.id
|
|
|
|
|
- left join (
|
|
|
|
|
- select
|
|
|
|
|
- io.userid as "userId",
|
|
|
|
|
- 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",
|
|
|
|
|
- COUNT( CASE WHEN iac.product = '交三' THEN 1 END ) AS "riskCodeJs",
|
|
|
|
|
- COUNT( CASE WHEN iac.product = '单交' THEN 1 END ) AS "riskCodeDj",
|
|
|
|
|
- COUNT( CASE WHEN iac.product = '交商' THEN 1 END ) AS "riskCodeJshang",
|
|
|
|
|
- COUNT( CASE WHEN iac.product = '单商' THEN 1 END ) AS "riskCodeDs",
|
|
|
|
|
- COUNT( CASE WHEN iac.product = '单三' THEN 1 END ) AS "riskCodeDsan",
|
|
|
|
|
- ROUND(sum(IFNULL(ifon.jq_costs_premiums,0) + IFNULL(ifon.sy_costs_premiums,0) + IFNULL
|
|
|
|
|
- (ifon.no_costs_premiums,0)),2) as "entranceAllFee",
|
|
|
|
|
- ROUND(sum(IFNULL(jq_export_other_costs_premiums,0) + IFNULL(jq_export_supervise_costs_premiums,0)
|
|
|
|
|
- +IFNULL(sy_export_other_costs_premiums,0) +IFNULL(sy_export_supervise_costs_premiums,0)
|
|
|
|
|
- +IFNULL(no_export_other_costs_premiums,0)+IFNULL(no_export_supervise_costs_premiums,0) ),2) as "exportAllFee"
|
|
|
|
|
- from ins_area_company iac
|
|
|
|
|
- left join ins_orders io on io.orderno =iac.orderno
|
|
|
|
|
- left join sys_user su on su.id =io.userid
|
|
|
|
|
|
|
+ SELECT
|
|
|
|
|
+ a.userId as "userId",
|
|
|
|
|
+ su.name AS "userName",
|
|
|
|
|
+ sd.id AS "deptId",
|
|
|
|
|
+ su.leader_name AS "leaderName",
|
|
|
|
|
+ a.sumpremium,
|
|
|
|
|
+ a.jqpremium,
|
|
|
|
|
+ a.sypremium,
|
|
|
|
|
+ a.taxamount,
|
|
|
|
|
+ a.jypremium,
|
|
|
|
|
+ a.riskCodeJs,
|
|
|
|
|
+ a.riskCodeDj,
|
|
|
|
|
+ a.riskCodeJshang,
|
|
|
|
|
+ a.riskCodeDs,
|
|
|
|
|
+ a.riskCodeDsan,
|
|
|
|
|
+ sd.management_source AS "managementSource",
|
|
|
|
|
+ a.distributionAmount,
|
|
|
|
|
+ CASE WHEN a.sumpremium = 0 THEN 0 ELSE a.distributionAmount / a.sumpremium END AS "distributionAmountRate"
|
|
|
|
|
+ FROM (
|
|
|
|
|
+ SELECT
|
|
|
|
|
+ io.userid AS "userId",
|
|
|
|
|
+ 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",
|
|
|
|
|
+ COUNT(CASE WHEN iac.product = '交三' THEN 1 END) AS "riskCodeJs",
|
|
|
|
|
+ COUNT(CASE WHEN iac.product = '单交' THEN 1 END) AS "riskCodeDj",
|
|
|
|
|
+ COUNT(CASE WHEN iac.product = '交商' THEN 1 END) AS "riskCodeJshang",
|
|
|
|
|
+ COUNT(CASE WHEN iac.product = '单商' THEN 1 END) AS "riskCodeDs",
|
|
|
|
|
+ COUNT(CASE WHEN iac.product = '单三' THEN 1 END) AS "riskCodeDsan",
|
|
|
|
|
+ ROUND(SUM(IFNULL(ifon.jq_costs_premiums, 0) + IFNULL(ifon.sy_costs_premiums, 0) + IFNULL(ifon.no_costs_premiums, 0)), 2) AS "entranceAllFee",
|
|
|
|
|
+ ROUND(SUM(IFNULL(jq_export_other_costs_premiums, 0) + IFNULL(jq_export_supervise_costs_premiums, 0) + IFNULL(sy_export_other_costs_premiums, 0) + IFNULL(sy_export_supervise_costs_premiums, 0) + IFNULL(no_export_other_costs_premiums, 0) + IFNULL(no_export_supervise_costs_premiums, 0)), 2) AS "exportAllFee",
|
|
|
|
|
+ IFNULL(IFNULL(SUM(IFNULL(ifon.jq_costs_premiums, 0) + IFNULL(ifon.sy_costs_premiums, 0) + IFNULL(ifon.no_costs_premiums, 0)), 0) - IFNULL(SUM(IFNULL(jq_export_other_costs_premiums, 0) + IFNULL(jq_export_supervise_costs_premiums, 0) + IFNULL(sy_export_other_costs_premiums, 0) + IFNULL(sy_export_supervise_costs_premiums, 0) + IFNULL(no_export_other_costs_premiums, 0) + IFNULL(no_export_supervise_costs_premiums, 0)), 0), 0) AS "distributionAmount"
|
|
|
|
|
+ FROM
|
|
|
|
|
+ ins_area_company iac
|
|
|
|
|
+ LEFT JOIN ins_orders io ON io.orderno = iac.orderno
|
|
|
|
|
+ LEFT JOIN sys_user su ON su.id = io.userid
|
|
|
LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
|
|
LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
|
|
|
- <where>
|
|
|
|
|
- iac.orderstatus = '3'
|
|
|
|
|
- and (iac.del_flag = '1' or io.del_flag IS NULL or io.del_flag = 1)
|
|
|
|
|
- <if test="vo.signingTimeStart != null and vo.signingTimeStart!='' and vo.signingTimeEnd != null and vo.signingTimeEnd != ''">
|
|
|
|
|
- AND DATE_FORMAT(iac.signing_time, '%Y-%m-%d') BETWEEN DATE_FORMAT(#{vo.signingTimeStart}, '%Y-%m-%d') AND DATE_FORMAT(#{vo.signingTimeEnd}, '%Y-%m-%d')
|
|
|
|
|
- </if>
|
|
|
|
|
- <if test="vo.enterTimeStart != null and vo.enterTimeStart!='' and vo.enterTimeEnd != null and vo.enterTimeEnd != ''">
|
|
|
|
|
- AND DATE_FORMAT(iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT(#{vo.enterTimeStart}, '%Y-%m-%d') AND DATE_FORMAT(#{vo.enterTimeEnd}, '%Y-%m-%d')
|
|
|
|
|
- </if>
|
|
|
|
|
-
|
|
|
|
|
- <if test="vo.userIds !=null and vo.userIds!='' and vo.userIds.size()>0">
|
|
|
|
|
- and su.leader_id in
|
|
|
|
|
- <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
|
|
|
|
|
- #{item}
|
|
|
|
|
- </foreach>
|
|
|
|
|
- </if>
|
|
|
|
|
-
|
|
|
|
|
- </where>
|
|
|
|
|
- group by io.userid
|
|
|
|
|
- ) a on a.userId =su.id
|
|
|
|
|
- <where>
|
|
|
|
|
- 1=1
|
|
|
|
|
- <if test="vo.userId !=null and vo.userId!=''">
|
|
|
|
|
- and su.id=#{vo.userId}
|
|
|
|
|
- </if>
|
|
|
|
|
-
|
|
|
|
|
- <if test="vo.userName !=null and vo.userName!=''">
|
|
|
|
|
- and su.name=#{vo.userName}
|
|
|
|
|
- </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.leader_id in
|
|
|
|
|
- <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
|
|
|
|
|
- #{item}
|
|
|
|
|
- </foreach>
|
|
|
|
|
- </if>
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- <if test="vo.leaderName !=null and vo.leaderName!=''">
|
|
|
|
|
- and su.leader_name=#{vo.leaderName}
|
|
|
|
|
- </if>
|
|
|
|
|
-
|
|
|
|
|
- <choose>
|
|
|
|
|
- <when test='vo.managementSource == "2"'>
|
|
|
|
|
- and (sur.role_id = 20 or sur.role_id = 21)
|
|
|
|
|
- </when>
|
|
|
|
|
- <when test='vo.managementSource == "1"'>
|
|
|
|
|
- and (sur.role_id = 19 or sur.role_id = 21)
|
|
|
|
|
- </when>
|
|
|
|
|
- <otherwise>
|
|
|
|
|
- </otherwise>
|
|
|
|
|
- </choose>
|
|
|
|
|
-
|
|
|
|
|
- <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
|
|
|
|
|
- AND sd.id in
|
|
|
|
|
- <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
|
|
|
|
|
- #{item}
|
|
|
|
|
- </foreach>
|
|
|
|
|
- </if>
|
|
|
|
|
-
|
|
|
|
|
- <if test="vo.deptId !=null and vo.deptId!=''">
|
|
|
|
|
- and sd.id like concat('%',#{vo.deptId},'%')
|
|
|
|
|
- </if>
|
|
|
|
|
- </where>
|
|
|
|
|
- order by a.sumpremium desc ,su.id
|
|
|
|
|
|
|
+ WHERE
|
|
|
|
|
+ iac.orderstatus = '3'
|
|
|
|
|
+ AND (iac.del_flag = '1' OR io.del_flag IS NULL OR io.del_flag = 1)
|
|
|
|
|
+ <if test="vo.signingTimeStart != null and vo.signingTimeStart!='' and vo.signingTimeEnd != null and vo.signingTimeEnd != ''">
|
|
|
|
|
+ AND iac.signing_time BETWEEN #{vo.signingTimeStart} AND #{vo.signingTimeEnd}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.enterTimeStart != null and vo.enterTimeStart!='' and vo.enterTimeEnd != null and vo.enterTimeEnd != ''">
|
|
|
|
|
+ AND iac.createtime BETWEEN #{vo.enterTimeStart} AND #{vo.enterTimeEnd}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.userIds !=null and vo.userIds!='' and vo.userIds.size()>0">
|
|
|
|
|
+ AND su.leader_id IN
|
|
|
|
|
+ <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
|
|
|
|
|
+ #{item}
|
|
|
|
|
+ </foreach>
|
|
|
|
|
+ </if>
|
|
|
|
|
+ GROUP BY
|
|
|
|
|
+ io.userid
|
|
|
|
|
+ ) a
|
|
|
|
|
+ LEFT JOIN sys_user su ON a.userId = su.id
|
|
|
|
|
+ LEFT JOIN sys_dept sd ON sd.id = su.dept_id
|
|
|
|
|
+ LEFT JOIN sys_user_role sur ON sur.user_id = su.id
|
|
|
|
|
+ WHERE
|
|
|
|
|
+ 1 = 1
|
|
|
|
|
+ <if test="vo.userId !=null and vo.userId!=''">
|
|
|
|
|
+ AND su.id = #{vo.userId}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.userName !=null and vo.userName!=''">
|
|
|
|
|
+ AND su.name = #{vo.userName}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.managementSource !=null and vo.managementSource!=''">
|
|
|
|
|
+ AND sd.management_source = #{vo.managementSource}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <choose>
|
|
|
|
|
+ <when test='vo.managementSource == "2"'>
|
|
|
|
|
+ AND (sur.role_id = 20 OR sur.role_id = 21)
|
|
|
|
|
+ </when>
|
|
|
|
|
+ <when test='vo.managementSource == "1"'>
|
|
|
|
|
+ AND (sur.role_id = 19 OR sur.role_id = 21)
|
|
|
|
|
+ </when>
|
|
|
|
|
+ <otherwise>
|
|
|
|
|
+ </otherwise>
|
|
|
|
|
+ </choose>
|
|
|
|
|
+ <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
|
|
|
|
|
+ AND sd.id IN
|
|
|
|
|
+ <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
|
|
|
|
|
+ #{item}
|
|
|
|
|
+ </foreach>
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.deptId !=null and vo.deptId!=''">
|
|
|
|
|
+ AND sd.id LIKE CONCAT('%', #{vo.deptId}, '%')
|
|
|
|
|
+ </if>
|
|
|
|
|
+ ORDER BY
|
|
|
|
|
+ a.sumpremium DESC,
|
|
|
|
|
+ a.userId
|
|
|
</select>
|
|
</select>
|
|
|
|
|
|
|
|
<select id="getBusinessAgentDataTotal" resultType="java.lang.Long">
|
|
<select id="getBusinessAgentDataTotal" resultType="java.lang.Long">
|
|
|
- select
|
|
|
|
|
|
|
+ SELECT
|
|
|
COUNT(0)
|
|
COUNT(0)
|
|
|
- from sys_user su
|
|
|
|
|
- left join sys_dept sd on sd.id =su.dept_id
|
|
|
|
|
|
|
+ FROM (
|
|
|
|
|
+ SELECT
|
|
|
|
|
+ a.userId as "userId"
|
|
|
|
|
+ FROM (
|
|
|
|
|
+ SELECT
|
|
|
|
|
+ io.userid AS "userId"
|
|
|
|
|
+ FROM
|
|
|
|
|
+ ins_area_company iac
|
|
|
|
|
+ LEFT JOIN ins_orders io ON io.orderno = iac.orderno
|
|
|
|
|
+ LEFT JOIN sys_user su ON su.id = io.userid
|
|
|
|
|
+ LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
|
|
|
|
|
+ WHERE
|
|
|
|
|
+ iac.orderstatus = '3'
|
|
|
|
|
+ AND (iac.del_flag = '1' OR io.del_flag IS NULL OR io.del_flag = 1)
|
|
|
|
|
+ <if test="vo.signingTimeStart != null and vo.signingTimeStart!='' and vo.signingTimeEnd != null and vo.signingTimeEnd != ''">
|
|
|
|
|
+ AND iac.signing_time BETWEEN #{vo.signingTimeStart} AND #{vo.signingTimeEnd}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.enterTimeStart != null and vo.enterTimeStart!='' and vo.enterTimeEnd != null and vo.enterTimeEnd != ''">
|
|
|
|
|
+ AND iac.createtime BETWEEN #{vo.enterTimeStart} AND #{vo.enterTimeEnd}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.userIds !=null and vo.userIds!='' and vo.userIds.size()>0">
|
|
|
|
|
+ AND su.leader_id IN
|
|
|
|
|
+ <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
|
|
|
|
|
+ #{item}
|
|
|
|
|
+ </foreach>
|
|
|
|
|
+ </if>
|
|
|
|
|
+ GROUP BY
|
|
|
|
|
+ io.userid
|
|
|
|
|
+ ) a
|
|
|
|
|
+ LEFT JOIN sys_user su ON a.userId = su.id
|
|
|
|
|
+ LEFT JOIN sys_dept sd ON sd.id = su.dept_id
|
|
|
LEFT JOIN sys_user_role sur ON sur.user_id = su.id
|
|
LEFT JOIN sys_user_role sur ON sur.user_id = su.id
|
|
|
- <where>
|
|
|
|
|
- 1=1
|
|
|
|
|
- <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.leader_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>
|
|
|
|
|
-
|
|
|
|
|
- <if test="vo.managementSource !=null and vo.managementSource!=''">
|
|
|
|
|
- and sd.management_source=#{vo.managementSource}
|
|
|
|
|
- </if>
|
|
|
|
|
-
|
|
|
|
|
- <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
|
|
|
|
|
- AND sd.id in
|
|
|
|
|
- <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
|
|
|
|
|
- #{item}
|
|
|
|
|
- </foreach>
|
|
|
|
|
- </if>
|
|
|
|
|
-
|
|
|
|
|
- <if test="vo.leaderName !=null and vo.leaderName!=''">
|
|
|
|
|
- and su.leader_name=#{vo.leaderName}
|
|
|
|
|
- </if>
|
|
|
|
|
-
|
|
|
|
|
- <if test="vo.deptId !=null and vo.deptId!=''">
|
|
|
|
|
- and sd.id like concat('%',#{vo.deptId},'%')
|
|
|
|
|
- </if>
|
|
|
|
|
- <choose>
|
|
|
|
|
- <when test='vo.managementSource == "2"'>
|
|
|
|
|
- and (sur.role_id = 20 or sur.role_id = 21)
|
|
|
|
|
- </when>
|
|
|
|
|
- <when test='vo.managementSource == "1"'>
|
|
|
|
|
- and (sur.role_id = 19 or sur.role_id = 21)
|
|
|
|
|
- </when>
|
|
|
|
|
- <otherwise>
|
|
|
|
|
- </otherwise>
|
|
|
|
|
- </choose>
|
|
|
|
|
- </where>
|
|
|
|
|
|
|
+ WHERE
|
|
|
|
|
+ 1 = 1
|
|
|
|
|
+ <if test="vo.userId !=null and vo.userId!=''">
|
|
|
|
|
+ AND su.id = #{vo.userId}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.userName !=null and vo.userName!=''">
|
|
|
|
|
+ AND su.name = #{vo.userName}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.managementSource !=null and vo.managementSource!=''">
|
|
|
|
|
+ AND sd.management_source = #{vo.managementSource}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <choose>
|
|
|
|
|
+ <when test='vo.managementSource == "2"'>
|
|
|
|
|
+ AND (sur.role_id = 20 OR sur.role_id = 21)
|
|
|
|
|
+ </when>
|
|
|
|
|
+ <when test='vo.managementSource == "1"'>
|
|
|
|
|
+ AND (sur.role_id = 19 OR sur.role_id = 21)
|
|
|
|
|
+ </when>
|
|
|
|
|
+ <otherwise>
|
|
|
|
|
+ </otherwise>
|
|
|
|
|
+ </choose>
|
|
|
|
|
+ <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
|
|
|
|
|
+ AND sd.id IN
|
|
|
|
|
+ <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
|
|
|
|
|
+ #{item}
|
|
|
|
|
+ </foreach>
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.deptId !=null and vo.deptId!=''">
|
|
|
|
|
+ AND sd.id LIKE CONCAT('%', #{vo.deptId}, '%')
|
|
|
|
|
+ </if>
|
|
|
|
|
+ ) a
|
|
|
</select>
|
|
</select>
|
|
|
|
|
|
|
|
<select id="getBusinessAgentDataTotalAdd" resultType="com.ydtech.modules.admin.model.vo.BusinessAgentData">
|
|
<select id="getBusinessAgentDataTotalAdd" resultType="com.ydtech.modules.admin.model.vo.BusinessAgentData">
|
|
@@ -185,17 +182,16 @@
|
|
|
+IFNULL(no_export_other_costs_premiums,0)+IFNULL(no_export_supervise_costs_premiums,0) ),2) as "exportAllFee"
|
|
+IFNULL(no_export_other_costs_premiums,0)+IFNULL(no_export_supervise_costs_premiums,0) ),2) as "exportAllFee"
|
|
|
from ins_area_company iac
|
|
from ins_area_company iac
|
|
|
left join ins_orders io on io.orderno =iac.orderno
|
|
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
|
|
|
|
|
|
|
+ left join sys_dept sd on sd.id =io.deptid
|
|
|
LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
|
|
LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
|
|
|
<where>
|
|
<where>
|
|
|
iac.orderstatus = '3'
|
|
iac.orderstatus = '3'
|
|
|
- and (iac.del_flag = '1' or io.del_flag IS NULL or io.del_flag = 1)
|
|
|
|
|
|
|
+ and (iac.del_flag = '1' )
|
|
|
<if test="vo.signingTimeStart != null and vo.signingTimeStart!='' and vo.signingTimeEnd != null and vo.signingTimeEnd != ''">
|
|
<if test="vo.signingTimeStart != null and vo.signingTimeStart!='' and vo.signingTimeEnd != null and vo.signingTimeEnd != ''">
|
|
|
- AND DATE_FORMAT(iac.signing_time, '%Y-%m-%d') BETWEEN DATE_FORMAT(#{vo.signingTimeStart}, '%Y-%m-%d') AND DATE_FORMAT(#{vo.signingTimeEnd}, '%Y-%m-%d')
|
|
|
|
|
|
|
+ AND iac.signing_time BETWEEN #{vo.signingTimeStart} AND #{vo.signingTimeEnd}
|
|
|
</if>
|
|
</if>
|
|
|
<if test="vo.enterTimeStart != null and vo.enterTimeStart!='' and vo.enterTimeEnd != null and vo.enterTimeEnd != ''">
|
|
<if test="vo.enterTimeStart != null and vo.enterTimeStart!='' and vo.enterTimeEnd != null and vo.enterTimeEnd != ''">
|
|
|
- AND DATE_FORMAT(iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT(#{vo.enterTimeStart}, '%Y-%m-%d') AND DATE_FORMAT(#{vo.enterTimeEnd}, '%Y-%m-%d')
|
|
|
|
|
|
|
+ AND iac.createtime BETWEEN #{vo.enterTimeStart} AND #{vo.enterTimeEnd}
|
|
|
</if>
|
|
</if>
|
|
|
|
|
|
|
|
<if test="vo.days !=null and vo.days !='' and vo.days != 0 ">
|
|
<if test="vo.days !=null and vo.days !='' and vo.days != 0 ">
|
|
@@ -203,15 +199,15 @@
|
|
|
</if>
|
|
</if>
|
|
|
|
|
|
|
|
<if test="vo.userName !=null and vo.userName!=''">
|
|
<if test="vo.userName !=null and vo.userName!=''">
|
|
|
- and su.name=#{vo.userName}
|
|
|
|
|
|
|
+ and io.userName=#{vo.userName}
|
|
|
</if>
|
|
</if>
|
|
|
|
|
|
|
|
- <if test="vo.userId !=null and vo.userId!=''">
|
|
|
|
|
- and su.id=#{vo.userId}
|
|
|
|
|
|
|
+ <if test="vo.userId !=null and vo.userId !=''">
|
|
|
|
|
+ and io.userid=#{vo.userId}
|
|
|
</if>
|
|
</if>
|
|
|
|
|
|
|
|
<if test="vo.userIds !=null and vo.userIds!='' and vo.userIds.size()>0">
|
|
<if test="vo.userIds !=null and vo.userIds!='' and vo.userIds.size()>0">
|
|
|
- and su.leader_id in
|
|
|
|
|
|
|
+ and iac.leader_id in
|
|
|
<foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
|
|
<foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
|
|
|
#{item}
|
|
#{item}
|
|
|
</foreach>
|
|
</foreach>
|
|
@@ -231,7 +227,7 @@
|
|
|
</foreach>
|
|
</foreach>
|
|
|
</if>
|
|
</if>
|
|
|
<if test="vo.leaderName !=null and vo.leaderName!=''">
|
|
<if test="vo.leaderName !=null and vo.leaderName!=''">
|
|
|
- and su.leader_name=#{vo.leaderName}
|
|
|
|
|
|
|
+ and iac.leader_name=#{vo.leaderName}
|
|
|
</if>
|
|
</if>
|
|
|
</where>
|
|
</where>
|
|
|
</select>
|
|
</select>
|
|
@@ -249,33 +245,26 @@
|
|
|
and iac.orderstatus ='3'
|
|
and iac.orderstatus ='3'
|
|
|
and iac.del_flag = '1'
|
|
and iac.del_flag = '1'
|
|
|
<if test="vo.signingTimeStart != null and vo.signingTimeStart!='' and vo.signingTimeEnd != null and vo.signingTimeEnd != ''">
|
|
<if test="vo.signingTimeStart != null and vo.signingTimeStart!='' and vo.signingTimeEnd != null and vo.signingTimeEnd != ''">
|
|
|
- AND DATE_FORMAT(iac.signing_time, '%Y-%m-%d') BETWEEN DATE_FORMAT(#{vo.signingTimeStart}, '%Y-%m-%d') AND DATE_FORMAT(#{vo.signingTimeEnd}, '%Y-%m-%d')
|
|
|
|
|
|
|
+ AND iac.signing_time BETWEEN #{vo.signingTimeStart} AND #{vo.signingTimeEnd}
|
|
|
</if>
|
|
</if>
|
|
|
<if test="vo.enterTimeStart != null and vo.enterTimeStart!='' and vo.enterTimeEnd != null and vo.enterTimeEnd != ''">
|
|
<if test="vo.enterTimeStart != null and vo.enterTimeStart!='' and vo.enterTimeEnd != null and vo.enterTimeEnd != ''">
|
|
|
- AND DATE_FORMAT(iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT(#{vo.enterTimeStart}, '%Y-%m-%d') AND DATE_FORMAT(#{vo.enterTimeEnd}, '%Y-%m-%d')
|
|
|
|
|
|
|
+ AND iac.createtime BETWEEN #{vo.enterTimeStart} AND #{vo.enterTimeEnd}
|
|
|
</if>
|
|
</if>
|
|
|
-
|
|
|
|
|
<if test="vo.leaderName !=null and vo.leaderName!=''">
|
|
<if test="vo.leaderName !=null and vo.leaderName!=''">
|
|
|
and su.leader_name=#{vo.leaderName}
|
|
and su.leader_name=#{vo.leaderName}
|
|
|
</if>
|
|
</if>
|
|
|
-
|
|
|
|
|
<if test="vo.userName !=null and vo.userName!=''">
|
|
<if test="vo.userName !=null and vo.userName!=''">
|
|
|
and su.name=#{vo.userName}
|
|
and su.name=#{vo.userName}
|
|
|
</if>
|
|
</if>
|
|
|
-
|
|
|
|
|
<if test="vo.userId !=null and vo.userId!=''">
|
|
<if test="vo.userId !=null and vo.userId!=''">
|
|
|
and su.id=#{vo.userId}
|
|
and su.id=#{vo.userId}
|
|
|
</if>
|
|
</if>
|
|
|
-
|
|
|
|
|
<if test="vo.proportionUserIds !=null and vo.proportionUserIds!='' and vo.proportionUserIds.size()>0">
|
|
<if test="vo.proportionUserIds !=null and vo.proportionUserIds!='' and vo.proportionUserIds.size()>0">
|
|
|
and su.id in
|
|
and su.id in
|
|
|
<foreach collection="vo.proportionUserIds" item="item" open="(" separator="," close=")">
|
|
<foreach collection="vo.proportionUserIds" item="item" open="(" separator="," close=")">
|
|
|
#{item}
|
|
#{item}
|
|
|
</foreach>
|
|
</foreach>
|
|
|
</if>
|
|
</if>
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
<!-- <if test="vo.userIds !=null and vo.userIds!='' and vo.userIds.size()>0">-->
|
|
<!-- <if test="vo.userIds !=null and vo.userIds!='' and vo.userIds.size()>0">-->
|
|
|
<!-- and su.leader_id in-->
|
|
<!-- and su.leader_id in-->
|
|
|
<!-- <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">-->
|
|
<!-- <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">-->
|
|
@@ -331,10 +320,10 @@
|
|
|
</if>
|
|
</if>
|
|
|
|
|
|
|
|
<if test="vo.signingTimeStart != null and vo.signingTimeStart!='' and vo.signingTimeEnd != null and vo.signingTimeEnd != ''">
|
|
<if test="vo.signingTimeStart != null and vo.signingTimeStart!='' and vo.signingTimeEnd != null and vo.signingTimeEnd != ''">
|
|
|
- AND DATE_FORMAT(iac.signing_time, '%Y-%m-%d') BETWEEN DATE_FORMAT(#{vo.signingTimeStart}, '%Y-%m-%d') AND DATE_FORMAT(#{vo.signingTimeEnd}, '%Y-%m-%d')
|
|
|
|
|
|
|
+ AND iac.signing_time BETWEEN#{vo.signingTimeStart} AND #{vo.signingTimeEnd}
|
|
|
</if>
|
|
</if>
|
|
|
<if test="vo.enterTimeStart != null and vo.enterTimeStart!='' and vo.enterTimeEnd != null and vo.enterTimeEnd != ''">
|
|
<if test="vo.enterTimeStart != null and vo.enterTimeStart!='' and vo.enterTimeEnd != null and vo.enterTimeEnd != ''">
|
|
|
- AND DATE_FORMAT(iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT(#{vo.enterTimeStart}, '%Y-%m-%d') AND DATE_FORMAT(#{vo.enterTimeEnd}, '%Y-%m-%d')
|
|
|
|
|
|
|
+ AND iac.createtime BETWEEN #{vo.enterTimeStart} AND #{vo.enterTimeEnd}
|
|
|
</if>
|
|
</if>
|
|
|
|
|
|
|
|
<if test="vo.managementSource !=null and vo.managementSource!=''">
|
|
<if test="vo.managementSource !=null and vo.managementSource!=''">
|
|
@@ -372,10 +361,10 @@
|
|
|
</if>
|
|
</if>
|
|
|
|
|
|
|
|
<if test="vo.signingTimeStart != null and vo.signingTimeStart!='' and vo.signingTimeEnd != null and vo.signingTimeEnd != ''">
|
|
<if test="vo.signingTimeStart != null and vo.signingTimeStart!='' and vo.signingTimeEnd != null and vo.signingTimeEnd != ''">
|
|
|
- AND DATE_FORMAT(iac.signing_time, '%Y-%m-%d') BETWEEN DATE_FORMAT(#{vo.signingTimeStart}, '%Y-%m-%d') AND DATE_FORMAT(#{vo.signingTimeEnd}, '%Y-%m-%d')
|
|
|
|
|
|
|
+ AND iac.signing_time BETWEEN #{vo.signingTimeStart} AND DATE_FORMAT(#{vo.signingTimeEnd}
|
|
|
</if>
|
|
</if>
|
|
|
<if test="vo.enterTimeStart != null and vo.enterTimeStart!='' and vo.enterTimeEnd != null and vo.enterTimeEnd != ''">
|
|
<if test="vo.enterTimeStart != null and vo.enterTimeStart!='' and vo.enterTimeEnd != null and vo.enterTimeEnd != ''">
|
|
|
- AND DATE_FORMAT(iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT(#{vo.enterTimeStart}, '%Y-%m-%d') AND DATE_FORMAT(#{vo.enterTimeEnd}, '%Y-%m-%d')
|
|
|
|
|
|
|
+ AND iac.createtime BETWEEN #{vo.enterTimeStart} AND DATE_FORMAT(#{vo.enterTimeEnd}
|
|
|
</if>
|
|
</if>
|
|
|
|
|
|
|
|
<if test="vo.managementSource !=null and vo.managementSource!=''">
|
|
<if test="vo.managementSource !=null and vo.managementSource!=''">
|
|
@@ -393,11 +382,15 @@
|
|
|
COUNT( CASE WHEN iot.order_status = '2' THEN 1 END ) AS underwritingCount,
|
|
COUNT( CASE WHEN iot.order_status = '2' THEN 1 END ) AS underwritingCount,
|
|
|
COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) AS qutationInsureCount,
|
|
COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) AS qutationInsureCount,
|
|
|
COUNT( CASE WHEN iot.order_status = '4' THEN 1 END ) AS underwritingReturn,
|
|
COUNT( CASE WHEN iot.order_status = '4' THEN 1 END ) AS underwritingReturn,
|
|
|
- COUNT( CASE WHEN iot.order_status = '2' THEN 1 END ) / COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS "passingRate",
|
|
|
|
|
- COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) / COUNT( CASE WHEN iot.order_status in ('0','1','2','3','4') THEN 1 END ) AS "closeRate",
|
|
|
|
|
- (COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) + COUNT( CASE WHEN iot.order_status = '2' THEN 1 END ))/ COUNT(
|
|
|
|
|
- CASE WHEN iot.order_status in ('0','1','2','3','4') THEN 1 END ) AS "contributionRate",
|
|
|
|
|
- COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) / COUNT( CASE WHEN iot.order_status in ('0','1','2','3','4') THEN 1 END ) AS "quotationRate",
|
|
|
|
|
|
|
+ COUNT( CASE WHEN iot.order_status = '2' THEN 1 END ) / COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS
|
|
|
|
|
+ "passingRate",
|
|
|
|
|
+ COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) / COUNT( CASE WHEN iot.order_status in
|
|
|
|
|
+ ('0','1','2','3','4') THEN 1 END ) AS "closeRate",
|
|
|
|
|
+ (COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) + COUNT( CASE WHEN iot.order_status = '2' THEN 1 END ))/
|
|
|
|
|
+ COUNT(
|
|
|
|
|
+ CASE WHEN iot.order_status in ('0','1','2','3','4') THEN 1 END ) AS "contributionRate",
|
|
|
|
|
+ COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) / COUNT( CASE WHEN iot.order_status in
|
|
|
|
|
+ ('0','1','2','3','4') THEN 1 END ) AS "quotationRate",
|
|
|
COUNT(CASE WHEN io.order_source = 0 and iot.order_status = '0' THEN 1 END) as "pcOrderSource",
|
|
COUNT(CASE WHEN io.order_source = 0 and iot.order_status = '0' THEN 1 END) as "pcOrderSource",
|
|
|
COUNT(CASE WHEN io.order_source = 1 and iot.order_status = '0' THEN 1 END) as "appOrderSource",
|
|
COUNT(CASE WHEN io.order_source = 1 and iot.order_status = '0' THEN 1 END) as "appOrderSource",
|
|
|
COUNT( CASE WHEN iot.order_status = '1' THEN 1 END ) AS "auditOrder"
|
|
COUNT( CASE WHEN iot.order_status = '1' THEN 1 END ) AS "auditOrder"
|
|
@@ -406,7 +399,7 @@
|
|
|
select iot.suborder,iot.order_status from `ins_orders_track` iot
|
|
select iot.suborder,iot.order_status from `ins_orders_track` iot
|
|
|
GROUP BY iot.suborder ,iot.order_status
|
|
GROUP BY iot.suborder ,iot.order_status
|
|
|
) iot
|
|
) iot
|
|
|
- left join ins_area_company iac ON iac.id = iot.suborder
|
|
|
|
|
|
|
+ left join ins_area_company iac ON iac.id = iot.suborder
|
|
|
LEFT JOIN ins_orders io ON io.orderno = iac.orderno
|
|
LEFT JOIN ins_orders io ON io.orderno = iac.orderno
|
|
|
LEFT JOIN sys_dept sd ON sd.id = io.deptid
|
|
LEFT JOIN sys_dept sd ON sd.id = io.deptid
|
|
|
<where>
|
|
<where>
|
|
@@ -432,12 +425,10 @@
|
|
|
</if>
|
|
</if>
|
|
|
|
|
|
|
|
<if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
|
|
<if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
|
|
|
- AND DATE_FORMAT( ica.signing_time, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND
|
|
|
|
|
- #{taskStatisticsVo.createtimeEnd}
|
|
|
|
|
|
|
+ AND ica.signing_time BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
|
|
|
</if>
|
|
</if>
|
|
|
<if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
|
|
<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')
|
|
|
|
|
|
|
+ AND iac.createtime BETWEEN #{taskStatisticsVo.beginDate} AND #{taskStatisticsVo.endDate}
|
|
|
</if>
|
|
</if>
|
|
|
</where>
|
|
</where>
|
|
|
GROUP BY
|
|
GROUP BY
|
|
@@ -486,12 +477,10 @@
|
|
|
AND su.id = #{vo.userId}
|
|
AND su.id = #{vo.userId}
|
|
|
</if>
|
|
</if>
|
|
|
<if test="vo.signingTimeStart != null and vo.signingTimeStart!='' and vo.signingTimeEnd != null and vo.signingTimeEnd != ''">
|
|
<if test="vo.signingTimeStart != null and vo.signingTimeStart!='' and vo.signingTimeEnd != null and vo.signingTimeEnd != ''">
|
|
|
- AND DATE_FORMAT(iac.signing_time, '%Y-%m-%d') BETWEEN DATE_FORMAT(#{vo.signingTimeStart}, '%Y-%m-%d')
|
|
|
|
|
- AND DATE_FORMAT(#{vo.signingTimeEnd}, '%Y-%m-%d')
|
|
|
|
|
|
|
+ AND iac.signing_time BETWEEN #{vo.signingTimeStart} AND #{vo.signingTimeEnd}
|
|
|
</if>
|
|
</if>
|
|
|
<if test="vo.enterTimeStart != null and vo.enterTimeStart!='' and vo.enterTimeEnd != null and vo.enterTimeEnd != ''">
|
|
<if test="vo.enterTimeStart != null and vo.enterTimeStart!='' and vo.enterTimeEnd != null and vo.enterTimeEnd != ''">
|
|
|
- AND DATE_FORMAT(iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT(#{vo.enterTimeStart}, '%Y-%m-%d')
|
|
|
|
|
- AND DATE_FORMAT(#{vo.enterTimeEnd}, '%Y-%m-%d')
|
|
|
|
|
|
|
+ AND iac.createtime BETWEEN #{vo.enterTimeStart} AND #{vo.enterTimeEnd}
|
|
|
</if>
|
|
</if>
|
|
|
</where>
|
|
</where>
|
|
|
GROUP BY
|
|
GROUP BY
|
|
@@ -530,135 +519,127 @@
|
|
|
|
|
|
|
|
<select id="getBusinessAgentDataExcel" resultType="com.ydtech.modules.admin.model.vo.BusinessAgentData">
|
|
<select id="getBusinessAgentDataExcel" resultType="com.ydtech.modules.admin.model.vo.BusinessAgentData">
|
|
|
select
|
|
select
|
|
|
- su.id as "userId",
|
|
|
|
|
- su.name as "userName",
|
|
|
|
|
- sd.id as "deptId",
|
|
|
|
|
- su.leader_name as "leaderName",
|
|
|
|
|
- IFNULL(a.sumpremium,0) as "sumpremium",
|
|
|
|
|
- IFNULL(a.jqpremium,0) as "jqpremium",
|
|
|
|
|
- IFNULL(a.sypremium,0) as "sypremium",
|
|
|
|
|
- IFNULL(a.taxamount,0) as "taxamount",
|
|
|
|
|
- IFNULL(a.jypremium,0) as "jypremium",
|
|
|
|
|
- IFNULL(a.riskCodeJs,0) as "riskCodeJs",
|
|
|
|
|
- IFNULL(a.riskCodeDj,0) as "riskCodeDj" ,
|
|
|
|
|
- IFNULL(a.riskCodeJshang,0) as "riskCodeJshang",
|
|
|
|
|
- IFNULL(a.riskCodeDs,0) as "riskCodeDs",
|
|
|
|
|
- IFNULL(a.riskCodeDsan,0) as "riskCodeDsan",
|
|
|
|
|
- sd.management_source as "managementSource",
|
|
|
|
|
- IFNULL(IFNULL(a.entranceAllFee,0) -IFNULL(a.exportAllFee,0),0) as "distributionAmount",
|
|
|
|
|
- (IFNULL(IFNULL(a.entranceAllFee,0) -IFNULL(a.exportAllFee,0),0)) / a.sumpremium as "distributionAmountRate"
|
|
|
|
|
- from sys_user su
|
|
|
|
|
- left join sys_dept sd on sd.id =su.dept_id
|
|
|
|
|
- LEFT JOIN sys_user_role sur ON sur.user_id = su.id
|
|
|
|
|
- left join (
|
|
|
|
|
|
|
+ a.userId as "userId",
|
|
|
|
|
+ a.userName as "userName",
|
|
|
|
|
+ a.deptId as "deptId",
|
|
|
|
|
+ a.leaderName as "leaderName",
|
|
|
|
|
+ COALESCE(a.sumpremium, 0) as "sumpremium",
|
|
|
|
|
+ COALESCE(a.jqpremium, 0) as "jqpremium",
|
|
|
|
|
+ COALESCE(a.sypremium, 0) as "sypremium",
|
|
|
|
|
+ COALESCE(a.taxamount, 0) as "taxamount",
|
|
|
|
|
+ COALESCE(a.jypremium, 0) as "jypremium",
|
|
|
|
|
+ COALESCE(a.riskCodeJs, 0) as "riskCodeJs",
|
|
|
|
|
+ COALESCE(a.riskCodeDj, 0) as "riskCodeDj",
|
|
|
|
|
+ COALESCE(a.riskCodeJshang, 0) as "riskCodeJshang",
|
|
|
|
|
+ COALESCE(a.riskCodeDs, 0) as "riskCodeDs",
|
|
|
|
|
+ COALESCE(a.riskCodeDsan, 0) as "riskCodeDsan",
|
|
|
|
|
+ a.managementSource as "managementSource",
|
|
|
|
|
+ COALESCE(a.entranceAllFee - a.exportAllFee, 0) as "distributionAmount",
|
|
|
|
|
+ CASE WHEN a.sumpremium > 0 THEN (COALESCE(a.entranceAllFee - a.exportAllFee, 0) / a.sumpremium) ELSE 0 END as "distributionAmountRate"
|
|
|
|
|
+ from (
|
|
|
select
|
|
select
|
|
|
io.userid as "userId",
|
|
io.userid as "userId",
|
|
|
- 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",
|
|
|
|
|
- COUNT( CASE WHEN iac.product = '交三' THEN 1 END ) AS "riskCodeJs",
|
|
|
|
|
- COUNT( CASE WHEN iac.product = '单交' THEN 1 END ) AS "riskCodeDj",
|
|
|
|
|
- COUNT( CASE WHEN iac.product = '交商' THEN 1 END ) AS "riskCodeJshang",
|
|
|
|
|
- COUNT( CASE WHEN iac.product = '单商' THEN 1 END ) AS "riskCodeDs",
|
|
|
|
|
- COUNT( CASE WHEN iac.product = '单三' THEN 1 END ) AS "riskCodeDsan",
|
|
|
|
|
- ROUND(sum(IFNULL(ifon.jq_costs_premiums,0) + IFNULL(ifon.sy_costs_premiums,0) + IFNULL
|
|
|
|
|
- (ifon.no_costs_premiums,0)),2) as "entranceAllFee",
|
|
|
|
|
- ROUND(sum(IFNULL(jq_export_other_costs_premiums,0) + IFNULL(jq_export_supervise_costs_premiums,0)
|
|
|
|
|
- +IFNULL(sy_export_other_costs_premiums,0) +IFNULL(sy_export_supervise_costs_premiums,0)
|
|
|
|
|
- +IFNULL(no_export_other_costs_premiums,0)+IFNULL(no_export_supervise_costs_premiums,0) ),2) as "exportAllFee"
|
|
|
|
|
- from ins_area_company iac
|
|
|
|
|
- left join ins_orders io on io.orderno =iac.orderno
|
|
|
|
|
- left join sys_user su on su.id =io.userid
|
|
|
|
|
|
|
+ io.username as "userName",
|
|
|
|
|
+ sd.id as "deptId",
|
|
|
|
|
+ sd.management_source as "managementSource",
|
|
|
|
|
+ iac.leader_name as "leaderName",
|
|
|
|
|
+ sum(COALESCE(jqpremium, 0) + COALESCE(sypremium, 0) + COALESCE(jypremium, 0)) as "sumpremium",
|
|
|
|
|
+ sum(COALESCE(jqpremium, 0)) as "jqpremium",
|
|
|
|
|
+ sum(COALESCE(sypremium, 0)) as "sypremium",
|
|
|
|
|
+ sum(COALESCE(taxamount, 0)) as "taxamount",
|
|
|
|
|
+ sum(COALESCE(jypremium, 0)) as "jypremium",
|
|
|
|
|
+ COUNT(CASE WHEN iac.product = '交三' THEN 1 END) AS "riskCodeJs",
|
|
|
|
|
+ COUNT(CASE WHEN iac.product = '单交' THEN 1 END) AS "riskCodeDj",
|
|
|
|
|
+ COUNT(CASE WHEN iac.product = '交商' THEN 1 END) AS "riskCodeJshang",
|
|
|
|
|
+ COUNT(CASE WHEN iac.product = '单商' THEN 1 END) AS "riskCodeDs",
|
|
|
|
|
+ COUNT(CASE WHEN iac.product = '单三' THEN 1 END) AS "riskCodeDsan",
|
|
|
|
|
+ ROUND(sum(COALESCE(ifon.jq_costs_premiums, 0) + COALESCE(ifon.sy_costs_premiums, 0) + COALESCE(ifon.no_costs_premiums, 0)), 2) as "entranceAllFee",
|
|
|
|
|
+ ROUND(sum(COALESCE(jq_export_other_costs_premiums, 0) + COALESCE(jq_export_supervise_costs_premiums, 0)
|
|
|
|
|
+ + COALESCE(sy_export_other_costs_premiums, 0) + COALESCE(sy_export_supervise_costs_premiums, 0)
|
|
|
|
|
+ + COALESCE(no_export_other_costs_premiums, 0) + COALESCE(no_export_supervise_costs_premiums, 0)), 2) as "exportAllFee"
|
|
|
|
|
+ from (
|
|
|
|
|
+ select *
|
|
|
|
|
+ from ins_area_company
|
|
|
|
|
+ where orderstatus = '3'
|
|
|
|
|
+ and (del_flag = '1')
|
|
|
|
|
+ <if test="vo.signingTimeStart != null and vo.signingTimeStart!='' and vo.signingTimeEnd != null and vo.signingTimeEnd != ''">
|
|
|
|
|
+ AND signing_time BETWEEN #{vo.signingTimeStart} AND #{vo.signingTimeEnd}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.enterTimeStart != null and vo.enterTimeStart!='' and vo.enterTimeEnd != null and vo.enterTimeEnd != ''">
|
|
|
|
|
+ AND createtime BETWEEN #{vo.enterTimeStart} AND #{vo.enterTimeEnd}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.userIds !=null and vo.userIds!='' and vo.userIds.size()>0">
|
|
|
|
|
+ and leader_id in
|
|
|
|
|
+ <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
|
|
|
|
|
+ #{item}
|
|
|
|
|
+ </foreach>
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.leaderName !=null and vo.leaderName!=''">
|
|
|
|
|
+ and leader_name=#{vo.leaderName}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ ) iac
|
|
|
|
|
+ left join ins_orders io on io.orderno = iac.orderno
|
|
|
LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
|
|
LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
|
|
|
|
|
+ left join sys_dept sd on sd.id = io.deptid
|
|
|
|
|
+ LEFT JOIN sys_user_role sur ON sur.user_id = io.userid
|
|
|
<where>
|
|
<where>
|
|
|
- iac.orderstatus = '3'
|
|
|
|
|
- <if test="vo.signingTimeStart != null and vo.signingTimeStart!='' and vo.signingTimeEnd != null and vo.signingTimeEnd != ''">
|
|
|
|
|
- AND DATE_FORMAT(iac.signing_time, '%Y-%m-%d') BETWEEN DATE_FORMAT(#{vo.signingTimeStart}, '%Y-%m-%d') AND DATE_FORMAT(#{vo.signingTimeEnd}, '%Y-%m-%d')
|
|
|
|
|
- </if>
|
|
|
|
|
- <if test="vo.enterTimeStart != null and vo.enterTimeStart!='' and vo.enterTimeEnd != null and vo.enterTimeEnd != ''">
|
|
|
|
|
- AND DATE_FORMAT(iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT(#{vo.enterTimeStart}, '%Y-%m-%d') AND DATE_FORMAT(#{vo.enterTimeEnd}, '%Y-%m-%d')
|
|
|
|
|
- </if>
|
|
|
|
|
-
|
|
|
|
|
- <if test="vo.userIds !=null and vo.userIds!='' and vo.userIds.size()>0">
|
|
|
|
|
- and su.leader_id in
|
|
|
|
|
- <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
|
|
|
|
|
- #{item}
|
|
|
|
|
- </foreach>
|
|
|
|
|
- </if>
|
|
|
|
|
-
|
|
|
|
|
- </where>
|
|
|
|
|
- group by io.userid
|
|
|
|
|
- ) a on a.userId =su.id
|
|
|
|
|
- <where>
|
|
|
|
|
- 1=1
|
|
|
|
|
<if test="vo.userId !=null and vo.userId!=''">
|
|
<if test="vo.userId !=null and vo.userId!=''">
|
|
|
- and su.id=#{vo.userId}
|
|
|
|
|
|
|
+ and io.userid=#{vo.userId}
|
|
|
</if>
|
|
</if>
|
|
|
-
|
|
|
|
|
<if test="vo.userName !=null and vo.userName!=''">
|
|
<if test="vo.userName !=null and vo.userName!=''">
|
|
|
- and su.name=#{vo.userName}
|
|
|
|
|
|
|
+ and io.username=#{vo.userName}
|
|
|
</if>
|
|
</if>
|
|
|
-
|
|
|
|
|
<if test="vo.managementSource !=null and vo.managementSource!=''">
|
|
<if test="vo.managementSource !=null and vo.managementSource!=''">
|
|
|
and sd.management_source=#{vo.managementSource}
|
|
and sd.management_source=#{vo.managementSource}
|
|
|
</if>
|
|
</if>
|
|
|
-
|
|
|
|
|
- <if test="vo.userIds !=null and vo.userIds!='' and vo.userIds.size()>0">
|
|
|
|
|
- and su.leader_id in
|
|
|
|
|
- <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
|
|
|
|
|
- #{item}
|
|
|
|
|
- </foreach>
|
|
|
|
|
- </if>
|
|
|
|
|
-
|
|
|
|
|
<choose>
|
|
<choose>
|
|
|
- <when test='vo.managementSource == "2"'>
|
|
|
|
|
- and (sur.role_id = 20 or sur.role_id = 21)
|
|
|
|
|
|
|
+ <when test='vo.managementSource == "2"'>
|
|
|
|
|
+ and (sur.role_id = 20 or sur.role_id = 21)
|
|
|
</when>
|
|
</when>
|
|
|
- <when test='vo.managementSource == "1"'>
|
|
|
|
|
- and (sur.role_id = 19 or sur.role_id = 21)
|
|
|
|
|
|
|
+ <when test='vo.managementSource == "1"'>
|
|
|
|
|
+ and (sur.role_id = 19 or sur.role_id = 21)
|
|
|
</when>
|
|
</when>
|
|
|
<otherwise>
|
|
<otherwise>
|
|
|
</otherwise>
|
|
</otherwise>
|
|
|
</choose>
|
|
</choose>
|
|
|
-
|
|
|
|
|
<if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
|
|
<if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
|
|
|
AND sd.id in
|
|
AND sd.id in
|
|
|
<foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
|
|
<foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
|
|
|
#{item}
|
|
#{item}
|
|
|
</foreach>
|
|
</foreach>
|
|
|
</if>
|
|
</if>
|
|
|
-
|
|
|
|
|
<if test="vo.deptId !=null and vo.deptId!=''">
|
|
<if test="vo.deptId !=null and vo.deptId!=''">
|
|
|
- and sd.id like concat('%',#{vo.deptId},'%')
|
|
|
|
|
|
|
+ and sd.id like concat('%', #{vo.deptId}, '%')
|
|
|
</if>
|
|
</if>
|
|
|
</where>
|
|
</where>
|
|
|
- order by a.sumpremium desc ,su.id
|
|
|
|
|
|
|
+ group by io.userid, io.username, io.deptid, iac.leader_name, sd.management_source
|
|
|
|
|
+ ) a
|
|
|
|
|
+ order by a.sumpremium desc, a.userId
|
|
|
</select>
|
|
</select>
|
|
|
|
|
|
|
|
<select id="ordersDetailsExcel" resultType="com.ydtech.modules.admin.model.dto.OrdersDetailsExcel">
|
|
<select id="ordersDetailsExcel" resultType="com.ydtech.modules.admin.model.dto.OrdersDetailsExcel">
|
|
|
select
|
|
select
|
|
|
- io.userid as "userId",
|
|
|
|
|
- iac.leader_name as "leaderName",
|
|
|
|
|
- su.name as "userName",
|
|
|
|
|
- io.licenseno as "licenseno",
|
|
|
|
|
- sd.management_source as "managementSource",
|
|
|
|
|
- io.orderno as "orderno",
|
|
|
|
|
- iot.order_status as "orderStatus",
|
|
|
|
|
- io.order_source as "orderSource",
|
|
|
|
|
- iac.entry_status as "entryStatus",
|
|
|
|
|
- ins.namesimple as "partnerCompaniesName",
|
|
|
|
|
- agree.insurance_company as "inscompany"
|
|
|
|
|
- from (select iot.suborder, iot.order_status from `ins_orders_track` iot GROUP BY iot.suborder, iot.order_status) iot
|
|
|
|
|
- left join ins_area_company iac ON iac.id = iot.suborder
|
|
|
|
|
- LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
|
|
|
|
|
- LEFT JOIN ins_orders io ON io.orderno = iac.orderno
|
|
|
|
|
- LEFT JOIN sys_dept sd ON sd.id = io.deptid
|
|
|
|
|
- LEFT JOIN sys_user su on su.id =io.userid
|
|
|
|
|
- LEFT JOIN esm_ins_company ins ON agree.partner_companies_id = ins.id
|
|
|
|
|
|
|
+ io.userid as "userId",
|
|
|
|
|
+ iac.leader_name as "leaderName",
|
|
|
|
|
+ su.name as "userName",
|
|
|
|
|
+ io.licenseno as "licenseno",
|
|
|
|
|
+ sd.management_source as "managementSource",
|
|
|
|
|
+ io.orderno as "orderno",
|
|
|
|
|
+ iot.order_status as "orderStatus",
|
|
|
|
|
+ io.order_source as "orderSource",
|
|
|
|
|
+ iac.entry_status as "entryStatus",
|
|
|
|
|
+ ins.namesimple as "partnerCompaniesName",
|
|
|
|
|
+ agree.insurance_company as "inscompany"
|
|
|
|
|
+ from (select iot.suborder, iot.order_status from `ins_orders_track` iot GROUP BY iot.suborder, iot.order_status)
|
|
|
|
|
+ iot
|
|
|
|
|
+ left join ins_area_company iac ON iac.id = iot.suborder
|
|
|
|
|
+ LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
|
|
|
|
|
+ LEFT JOIN ins_orders io ON io.orderno = iac.orderno
|
|
|
|
|
+ LEFT JOIN sys_dept sd ON sd.id = io.deptid
|
|
|
|
|
+ LEFT JOIN sys_user su on su.id =io.userid
|
|
|
|
|
+ LEFT JOIN esm_ins_company ins ON agree.partner_companies_id = ins.id
|
|
|
<where>
|
|
<where>
|
|
|
- (iac.del_flag = '1' or io.del_flag IS NULL or io.del_flag = 1)
|
|
|
|
|
|
|
+ (iac.del_flag = '1' or io.del_flag IS NULL or io.del_flag = 1)
|
|
|
<if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
|
|
<if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
|
|
|
and io.deptid like "${taskStatisticsVo.provinceId}%"
|
|
and io.deptid like "${taskStatisticsVo.provinceId}%"
|
|
|
</if>
|
|
</if>
|
|
@@ -677,20 +658,20 @@
|
|
|
</if>
|
|
</if>
|
|
|
|
|
|
|
|
<if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
|
|
<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}
|
|
|
|
|
|
|
+ AND io.createtime BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
|
|
|
</if>
|
|
</if>
|
|
|
<if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
|
|
<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')
|
|
|
|
|
|
|
+ AND iac.createtime BETWEEN #{taskStatisticsVo.beginDate} AND #{taskStatisticsVo.endDate}
|
|
|
</if>
|
|
</if>
|
|
|
|
|
|
|
|
<if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
|
|
<if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
|
|
|
- AND sd.id in
|
|
|
|
|
|
|
+ AND sd.id in
|
|
|
<foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
|
|
<foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
|
|
|
#{item}
|
|
#{item}
|
|
|
</foreach>
|
|
</foreach>
|
|
|
</if>
|
|
</if>
|
|
|
<if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
|
|
<if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
|
|
|
- AND io.userid in
|
|
|
|
|
|
|
+ AND io.userid in
|
|
|
<foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
|
|
<foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
|
|
|
#{item}
|
|
#{item}
|
|
|
</foreach>
|
|
</foreach>
|