|
@@ -755,6 +755,7 @@
|
|
|
|
|
|
|
|
<resultMap id="PayApplyUserReportDataMap" type="com.ydtech.modules.report.model.vo.PayApplyUserReportResVo">
|
|
<resultMap id="PayApplyUserReportDataMap" type="com.ydtech.modules.report.model.vo.PayApplyUserReportResVo">
|
|
|
<result property="institution" column="institution" jdbcType="VARCHAR"/>
|
|
<result property="institution" column="institution" jdbcType="VARCHAR"/>
|
|
|
|
|
+ <result property="institutionId" column="institutionId" jdbcType="VARCHAR"/>
|
|
|
<result property="deptname" column="deptname" jdbcType="VARCHAR"/>
|
|
<result property="deptname" column="deptname" jdbcType="VARCHAR"/>
|
|
|
<result property="username" column="username" jdbcType="VARCHAR"/>
|
|
<result property="username" column="username" jdbcType="VARCHAR"/>
|
|
|
<result property="waitPayCostsPremiums" column="wait_pay_costs_premiums" jdbcType="DECIMAL"/>
|
|
<result property="waitPayCostsPremiums" column="wait_pay_costs_premiums" jdbcType="DECIMAL"/>
|
|
@@ -767,10 +768,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
<select id="queryPayApplyUserReportData" resultMap="PayApplyUserReportDataMap">
|
|
<select id="queryPayApplyUserReportData" resultMap="PayApplyUserReportDataMap">
|
|
|
- SELECT deptid,
|
|
|
|
|
- <if test="reportReqVo.userId != null and reportReqVo.userId != ''">
|
|
|
|
|
- userid,
|
|
|
|
|
|
|
+ SELECT
|
|
|
|
|
+ <!--下钻查询时拼接-->
|
|
|
|
|
+ <if test="reportReqVo.isDrilling != null and reportReqVo.isDrilling == '1'.toString()">
|
|
|
|
|
+ <!--按团队下钻时-->
|
|
|
|
|
+ <if test="reportReqVo.drilType != null and reportReqVo.drilType == '1'.toString()">
|
|
|
|
|
+ p.`username`,p.userid userId,
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--按机构下钻时-->
|
|
|
|
|
+ <if test="reportReqVo.drilType != null and reportReqVo.drilType == '0'.toString()">
|
|
|
|
|
+ <!--下钻的是五级机构时,下钻到团队-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '5'.toString()">
|
|
|
|
|
+ p.deptid,
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--下钻的是四级机构时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '4'.toString()">
|
|
|
|
|
+ substr(p.deptid,1,11) institutionId,
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--下钻的是三级机构时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '3'.toString()">
|
|
|
|
|
+ substr(p.deptid,1,8) institutionId,
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--下钻的是二级机构时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '2'.toString()">
|
|
|
|
|
+ substr(p.deptid,1,6) institutionId,
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--下钻的是一级机构时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '1'.toString()">
|
|
|
|
|
+ substr(p.deptid,1,4) institutionId,
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--下钻的是总部时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == 'X'.toString()">
|
|
|
|
|
+ substr(p.deptid,1,2) institutionId,
|
|
|
|
|
+ </if>
|
|
|
</if>
|
|
</if>
|
|
|
|
|
+ <!--返回上层时-->
|
|
|
|
|
+ <if test="reportReqVo.drilType != null and reportReqVo.drilType == '2'.toString()">
|
|
|
|
|
+ <!--返回的是五级机构时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '5'.toString()">
|
|
|
|
|
+ substr(p.deptid,1,11) institutionId,
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--返回的是四级机构时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '4'.toString()">
|
|
|
|
|
+ substr(p.deptid,1,8) institutionId,
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--返回的是三级机构时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '3'.toString()">
|
|
|
|
|
+ substr(p.deptid,1,6) institutionId,
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--返回的是二级机构时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '2'.toString()">
|
|
|
|
|
+ substr(p.deptid,1,4) institutionId,
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--返回的是一级机构时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '1'.toString()">
|
|
|
|
|
+ substr(p.deptid,1,2) institutionId,
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--返回的是总部时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == 'X'.toString()">
|
|
|
|
|
+ substr(p.deptid,1,1) institutionId,
|
|
|
|
|
+ </if>
|
|
|
|
|
+ </if>
|
|
|
|
|
+ </if>
|
|
|
SUM( CASE feetype WHEN '1' THEN totalfee ELSE 0 END ) AS sum_costs_premiums,
|
|
SUM( CASE feetype WHEN '1' THEN totalfee ELSE 0 END ) AS sum_costs_premiums,
|
|
|
SUM( CASE feetype WHEN '1' THEN paidfee ELSE 0 END ) AS paid_costs_premiums,
|
|
SUM( CASE feetype WHEN '1' THEN paidfee ELSE 0 END ) AS paid_costs_premiums,
|
|
|
SUM( CASE feetype WHEN '1' THEN totalfee-paidfee ELSE 0 END ) AS wait_pay_costs_premiums,
|
|
SUM( CASE feetype WHEN '1' THEN totalfee-paidfee ELSE 0 END ) AS wait_pay_costs_premiums,
|
|
@@ -778,39 +837,221 @@
|
|
|
SUM( CASE feetype WHEN '2' THEN paidfee ELSE 0 END ) AS paid_retail_premiums,
|
|
SUM( CASE feetype WHEN '2' THEN paidfee ELSE 0 END ) AS paid_retail_premiums,
|
|
|
SUM( CASE feetype WHEN '2' THEN totalfee-paidfee ELSE 0 END ) AS wait_pay_retail_premiums
|
|
SUM( CASE feetype WHEN '2' THEN totalfee-paidfee ELSE 0 END ) AS wait_pay_retail_premiums
|
|
|
FROM report_payable_basedata p WHERE 1=1
|
|
FROM report_payable_basedata p WHERE 1=1
|
|
|
- <choose>
|
|
|
|
|
- <!--条件中团队不为空时,直接拼接团队-->
|
|
|
|
|
- <when test="reportReqVo.teamCode != null and reportReqVo.teamCode != ''">
|
|
|
|
|
- and p.deptid = #{reportReqVo.teamCode}
|
|
|
|
|
- </when>
|
|
|
|
|
- <!--条件中团队为空时,使用机构模糊查询-->
|
|
|
|
|
- <otherwise>
|
|
|
|
|
- <if test="reportReqVo.deptId != null and reportReqVo.deptId != ''">
|
|
|
|
|
- and p.deptid like #{reportReqVo.deptId}"%"
|
|
|
|
|
|
|
+ <!--下钻查询时拼接-->
|
|
|
|
|
+ <if test="reportReqVo.isDrilling != null and reportReqVo.isDrilling == '1'.toString()">
|
|
|
|
|
+ <!--按团队下钻时-->
|
|
|
|
|
+ <if test="reportReqVo.drilType != null and reportReqVo.drilType == '1'.toString()">
|
|
|
|
|
+ <if test="reportReqVo.teamCode != null and reportReqVo.teamCode != ''">
|
|
|
|
|
+ and p.deptid = #{reportReqVo.teamCode}
|
|
|
</if>
|
|
</if>
|
|
|
- </otherwise>
|
|
|
|
|
- </choose>
|
|
|
|
|
- <if test="reportReqVo.userId != null and reportReqVo.userId != ''">
|
|
|
|
|
- and p.userId = #{reportReqVo.userId}
|
|
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--按机构下钻时-->
|
|
|
|
|
+ <if test="reportReqVo.drilType != null and reportReqVo.drilType == '0'.toString()">
|
|
|
|
|
+ <!--下钻的是五级机构时,下钻到团队-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '5'.toString()">
|
|
|
|
|
+ and p.deptid in (SELECT id FROM `sys_dept` WHERE parent_id= #{reportReqVo.deptId} )
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--下钻的是四级机构时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '4'.toString()">
|
|
|
|
|
+ and substr(p.deptid,1,11) in (SELECT id FROM `sys_dept` WHERE parent_id= #{reportReqVo.deptId} )
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--下钻的是三级机构时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '3'.toString()">
|
|
|
|
|
+ and substr(p.deptid,1,8) in (SELECT id FROM `sys_dept` WHERE parent_id= #{reportReqVo.deptId} )
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--下钻的是二级机构时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '2'.toString()">
|
|
|
|
|
+ and substr(p.deptid,1,6) in (SELECT id FROM `sys_dept` WHERE parent_id= #{reportReqVo.deptId} )
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--下钻的是一级机构时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '1'.toString()">
|
|
|
|
|
+ and substr(p.deptid,1,4) in (SELECT id FROM `sys_dept` WHERE parent_id= #{reportReqVo.deptId} )
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--下钻的是总部时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == 'X'.toString()">
|
|
|
|
|
+ and substr(p.deptid,1,2) in (SELECT id FROM `sys_dept` WHERE parent_id= #{reportReqVo.deptId} )
|
|
|
|
|
+ </if>
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--返回上层时-->
|
|
|
|
|
+ <if test="reportReqVo.drilType != null and reportReqVo.drilType == '2'.toString()">
|
|
|
|
|
+ <!--返回的是五级机构时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '5'.toString()">
|
|
|
|
|
+ and substr(p.deptid,1,8) = #{reportReqVo.deptId}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--返回的是四级机构时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '4'.toString()">
|
|
|
|
|
+ and substr(p.deptid,1,6) = #{reportReqVo.deptId}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--返回的是三级机构时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '3'.toString()">
|
|
|
|
|
+ and substr(p.deptid,1,4) = #{reportReqVo.deptId}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--返回的是二级机构时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '2'.toString()">
|
|
|
|
|
+ and substr(p.deptid,1,2) = #{reportReqVo.deptId}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--返回的是一级机构时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '1'.toString()">
|
|
|
|
|
+ and substr(p.deptid,1,1) = #{reportReqVo.deptId}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--返回的是总部时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == 'X'.toString()">
|
|
|
|
|
+ and substr(p.deptid,1,1) = #{reportReqVo.deptId}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ </if>
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--非下钻查询时拼接-->
|
|
|
|
|
+ <if test="reportReqVo.isDrilling != null and reportReqVo.isDrilling == '0'.toString()">
|
|
|
|
|
+ <choose>
|
|
|
|
|
+ <!--条件中团队不为空时,直接拼接团队-->
|
|
|
|
|
+ <when test="reportReqVo.teamCode != null and reportReqVo.teamCode != ''">
|
|
|
|
|
+ and p.deptid = #{reportReqVo.teamCode}
|
|
|
|
|
+ </when>
|
|
|
|
|
+ <!--条件中团队为空时,使用机构模糊查询-->
|
|
|
|
|
+ <otherwise>
|
|
|
|
|
+ <if test="reportReqVo.deptId != null and reportReqVo.deptId != ''">
|
|
|
|
|
+ and p.deptid like #{reportReqVo.deptId}"%"
|
|
|
|
|
+ </if>
|
|
|
|
|
+ </otherwise>
|
|
|
|
|
+ </choose>
|
|
|
|
|
+ <if test="reportReqVo.userId != null and reportReqVo.userId != ''">
|
|
|
|
|
+ and p.userid = #{reportReqVo.userId}
|
|
|
|
|
+ </if>
|
|
|
</if>
|
|
</if>
|
|
|
|
|
+ <!--通用查询条件拼接-->
|
|
|
<if test="reportReqVo.insCompany != null and reportReqVo.insCompany != ''">
|
|
<if test="reportReqVo.insCompany != null and reportReqVo.insCompany != ''">
|
|
|
- and p.inscompany = #{reportReqVo.insCompany}
|
|
|
|
|
|
|
+ and p.company_id = #{reportReqVo.insCompany}
|
|
|
</if>
|
|
</if>
|
|
|
<if test="reportReqVo.quoteStartDate != null and reportReqVo.quoteEndDate != null">
|
|
<if test="reportReqVo.quoteStartDate != null and reportReqVo.quoteEndDate != null">
|
|
|
and p.signdate between #{reportReqVo.quoteStartDate} AND #{reportReqVo.quoteEndDate}
|
|
and p.signdate between #{reportReqVo.quoteStartDate} AND #{reportReqVo.quoteEndDate}
|
|
|
</if>
|
|
</if>
|
|
|
- group by deptid
|
|
|
|
|
- <if test="reportReqVo.userId != null and reportReqVo.userId != ''">
|
|
|
|
|
- ,userid
|
|
|
|
|
|
|
+ <!--下钻查询时拼接-->
|
|
|
|
|
+ <if test="reportReqVo.isDrilling != null and reportReqVo.isDrilling == '1'.toString()">
|
|
|
|
|
+ <!--按团队下钻时-->
|
|
|
|
|
+ <if test="reportReqVo.drilType != null and reportReqVo.drilType == '1'.toString()">
|
|
|
|
|
+ group by p.`username`,p.userid order by p.`username`
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--按机构下钻时-->
|
|
|
|
|
+ <if test="reportReqVo.drilType != null and reportReqVo.drilType == '0'.toString()">
|
|
|
|
|
+ <!--下钻的是五级机构时,下钻到团队-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '5'.toString()">
|
|
|
|
|
+ group by p.deptid order by p.deptid
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--下钻的是四级机构时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '4'.toString()">
|
|
|
|
|
+ group by substr(p.deptid,1,11) order by substr(p.deptid,1,11)
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--下钻的是三级机构时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '3'.toString()">
|
|
|
|
|
+ group by substr(p.deptid,1,8) order by substr(p.deptid,1,8)
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--下钻的是二级机构时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '2'.toString()">
|
|
|
|
|
+ group by substr(p.deptid,1,6) order by substr(p.deptid,1,6)
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--下钻的是一级机构时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '1'.toString()">
|
|
|
|
|
+ group by substr(p.deptid,1,4) order by substr(p.deptid,1,4)
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--下钻的是总部时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == 'X'.toString()">
|
|
|
|
|
+ group by substr(p.deptid,1,2) order by substr(p.deptid,1,2)
|
|
|
|
|
+ </if>
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--返回上层时-->
|
|
|
|
|
+ <if test="reportReqVo.drilType != null and reportReqVo.drilType == '2'.toString()">
|
|
|
|
|
+ <!--返回的是五级机构时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '5'.toString()">
|
|
|
|
|
+ group by substr(p.deptid,1,11) order by substr(p.deptid,1,11)
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--返回的是四级机构时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '4'.toString()">
|
|
|
|
|
+ group by substr(p.deptid,1,8) order by substr(p.deptid,1,8)
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--返回的是三级机构时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '3'.toString()">
|
|
|
|
|
+ group by substr(p.deptid,1,6) order by substr(p.deptid,1,6)
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--返回的是二级机构时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '2'.toString()">
|
|
|
|
|
+ group by substr(p.deptid,1,4) order by substr(p.deptid,1,4)
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--返回的是一级机构时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '1'.toString()">
|
|
|
|
|
+ group by substr(p.deptid,1,2) order by substr(p.deptid,1,2)
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--返回的是总部时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == 'X'.toString()">
|
|
|
|
|
+ group by substr(p.deptid,1,1) order by substr(p.deptid,1,1)
|
|
|
|
|
+ </if>
|
|
|
|
|
+ </if>
|
|
|
</if>
|
|
</if>
|
|
|
</select>
|
|
</select>
|
|
|
<select id="queryPayApplyUserReportDataCount" resultType="Long">
|
|
<select id="queryPayApplyUserReportDataCount" resultType="Long">
|
|
|
select
|
|
select
|
|
|
count(1)
|
|
count(1)
|
|
|
from (
|
|
from (
|
|
|
- SELECT deptid,
|
|
|
|
|
- <if test="reportReqVo.userId != null and reportReqVo.userId != ''">
|
|
|
|
|
- userid,
|
|
|
|
|
|
|
+ SELECT
|
|
|
|
|
+ <!--下钻查询时拼接-->
|
|
|
|
|
+ <if test="reportReqVo.isDrilling != null and reportReqVo.isDrilling == '1'.toString()">
|
|
|
|
|
+ <!--按团队下钻时-->
|
|
|
|
|
+ <if test="reportReqVo.drilType != null and reportReqVo.drilType == '1'.toString()">
|
|
|
|
|
+ p.`username`,p.userid userId,
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--按机构下钻时-->
|
|
|
|
|
+ <if test="reportReqVo.drilType != null and reportReqVo.drilType == '0'.toString()">
|
|
|
|
|
+ <!--下钻的是五级机构时,下钻到团队-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '5'.toString()">
|
|
|
|
|
+ p.deptid,
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--下钻的是四级机构时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '4'.toString()">
|
|
|
|
|
+ substr(p.deptid,1,11) institutionId,
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--下钻的是三级机构时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '3'.toString()">
|
|
|
|
|
+ substr(p.deptid,1,8) institutionId,
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--下钻的是二级机构时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '2'.toString()">
|
|
|
|
|
+ substr(p.deptid,1,6) institutionId,
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--下钻的是一级机构时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '1'.toString()">
|
|
|
|
|
+ substr(p.deptid,1,4) institutionId,
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--下钻的是总部时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == 'X'.toString()">
|
|
|
|
|
+ substr(p.deptid,1,2) institutionId,
|
|
|
|
|
+ </if>
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--返回上层时-->
|
|
|
|
|
+ <if test="reportReqVo.drilType != null and reportReqVo.drilType == '2'.toString()">
|
|
|
|
|
+ <!--返回的是五级机构时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '5'.toString()">
|
|
|
|
|
+ substr(p.deptid,1,11) institutionId,
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--返回的是四级机构时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '4'.toString()">
|
|
|
|
|
+ substr(p.deptid,1,8) institutionId,
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--返回的是三级机构时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '3'.toString()">
|
|
|
|
|
+ substr(p.deptid,1,6) institutionId,
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--返回的是二级机构时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '2'.toString()">
|
|
|
|
|
+ substr(p.deptid,1,4) institutionId,
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--返回的是一级机构时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '1'.toString()">
|
|
|
|
|
+ substr(p.deptid,1,2) institutionId,
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--返回的是总部时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == 'X'.toString()">
|
|
|
|
|
+ substr(p.deptid,1,1) institutionId,
|
|
|
|
|
+ </if>
|
|
|
|
|
+ </if>
|
|
|
</if>
|
|
</if>
|
|
|
SUM( CASE feetype WHEN '1' THEN totalfee ELSE 0 END ) AS sum_costs_premiums,
|
|
SUM( CASE feetype WHEN '1' THEN totalfee ELSE 0 END ) AS sum_costs_premiums,
|
|
|
SUM( CASE feetype WHEN '1' THEN paidfee ELSE 0 END ) AS paid_costs_premiums,
|
|
SUM( CASE feetype WHEN '1' THEN paidfee ELSE 0 END ) AS paid_costs_premiums,
|
|
@@ -819,30 +1060,154 @@
|
|
|
SUM( CASE feetype WHEN '2' THEN paidfee ELSE 0 END ) AS paid_retail_premiums,
|
|
SUM( CASE feetype WHEN '2' THEN paidfee ELSE 0 END ) AS paid_retail_premiums,
|
|
|
SUM( CASE feetype WHEN '2' THEN totalfee-paidfee ELSE 0 END ) AS wait_pay_retail_premiums
|
|
SUM( CASE feetype WHEN '2' THEN totalfee-paidfee ELSE 0 END ) AS wait_pay_retail_premiums
|
|
|
FROM report_payable_basedata p WHERE 1=1
|
|
FROM report_payable_basedata p WHERE 1=1
|
|
|
- <choose>
|
|
|
|
|
- <!--条件中团队不为空时,直接拼接团队-->
|
|
|
|
|
- <when test="reportReqVo.teamCode != null and reportReqVo.teamCode != ''">
|
|
|
|
|
- and p.deptid = #{reportReqVo.teamCode}
|
|
|
|
|
- </when>
|
|
|
|
|
- <!--条件中团队为空时,使用机构模糊查询-->
|
|
|
|
|
- <otherwise>
|
|
|
|
|
- <if test="reportReqVo.deptId != null and reportReqVo.deptId != ''">
|
|
|
|
|
- and p.deptid like #{reportReqVo.deptId}"%"
|
|
|
|
|
|
|
+ <!--下钻查询时拼接-->
|
|
|
|
|
+ <if test="reportReqVo.isDrilling != null and reportReqVo.isDrilling == '1'.toString()">
|
|
|
|
|
+ <!--按团队下钻时-->
|
|
|
|
|
+ <if test="reportReqVo.drilType != null and reportReqVo.drilType == '1'.toString()">
|
|
|
|
|
+ <if test="reportReqVo.teamCode != null and reportReqVo.teamCode != ''">
|
|
|
|
|
+ and p.deptid = #{reportReqVo.teamCode}
|
|
|
</if>
|
|
</if>
|
|
|
- </otherwise>
|
|
|
|
|
- </choose>
|
|
|
|
|
- <if test="reportReqVo.userId != null and reportReqVo.userId != ''">
|
|
|
|
|
- and p.userId = #{reportReqVo.userId}
|
|
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--按机构下钻时-->
|
|
|
|
|
+ <if test="reportReqVo.drilType != null and reportReqVo.drilType == '0'.toString()">
|
|
|
|
|
+ <!--下钻的是五级机构时,下钻到团队-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '5'.toString()">
|
|
|
|
|
+ and p.deptid in (SELECT id FROM `sys_dept` WHERE parent_id= #{reportReqVo.deptId} )
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--下钻的是四级机构时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '4'.toString()">
|
|
|
|
|
+ and substr(p.deptid,1,11) in (SELECT id FROM `sys_dept` WHERE parent_id= #{reportReqVo.deptId} )
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--下钻的是三级机构时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '3'.toString()">
|
|
|
|
|
+ and substr(p.deptid,1,8) in (SELECT id FROM `sys_dept` WHERE parent_id= #{reportReqVo.deptId} )
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--下钻的是二级机构时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '2'.toString()">
|
|
|
|
|
+ and substr(p.deptid,1,6) in (SELECT id FROM `sys_dept` WHERE parent_id= #{reportReqVo.deptId} )
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--下钻的是一级机构时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '1'.toString()">
|
|
|
|
|
+ and substr(p.deptid,1,4) in (SELECT id FROM `sys_dept` WHERE parent_id= #{reportReqVo.deptId} )
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--下钻的是总部时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == 'X'.toString()">
|
|
|
|
|
+ and substr(p.deptid,1,2) in (SELECT id FROM `sys_dept` WHERE parent_id= #{reportReqVo.deptId} )
|
|
|
|
|
+ </if>
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--返回上层时-->
|
|
|
|
|
+ <if test="reportReqVo.drilType != null and reportReqVo.drilType == '2'.toString()">
|
|
|
|
|
+ <!--返回的是五级机构时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '5'.toString()">
|
|
|
|
|
+ and substr(p.deptid,1,8) = #{reportReqVo.deptId}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--返回的是四级机构时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '4'.toString()">
|
|
|
|
|
+ and substr(p.deptid,1,6) = #{reportReqVo.deptId}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--返回的是三级机构时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '3'.toString()">
|
|
|
|
|
+ and substr(p.deptid,1,4) = #{reportReqVo.deptId}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--返回的是二级机构时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '2'.toString()">
|
|
|
|
|
+ and substr(p.deptid,1,2) = #{reportReqVo.deptId}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--返回的是一级机构时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '1'.toString()">
|
|
|
|
|
+ and substr(p.deptid,1,1) = #{reportReqVo.deptId}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--返回的是总部时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == 'X'.toString()">
|
|
|
|
|
+ and substr(p.deptid,1,1) = #{reportReqVo.deptId}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ </if>
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--非下钻查询时拼接-->
|
|
|
|
|
+ <if test="reportReqVo.isDrilling != null and reportReqVo.isDrilling == '0'.toString()">
|
|
|
|
|
+ <choose>
|
|
|
|
|
+ <!--条件中团队不为空时,直接拼接团队-->
|
|
|
|
|
+ <when test="reportReqVo.teamCode != null and reportReqVo.teamCode != ''">
|
|
|
|
|
+ and p.deptid = #{reportReqVo.teamCode}
|
|
|
|
|
+ </when>
|
|
|
|
|
+ <!--条件中团队为空时,使用机构模糊查询-->
|
|
|
|
|
+ <otherwise>
|
|
|
|
|
+ <if test="reportReqVo.deptId != null and reportReqVo.deptId != ''">
|
|
|
|
|
+ and p.deptid like #{reportReqVo.deptId}"%"
|
|
|
|
|
+ </if>
|
|
|
|
|
+ </otherwise>
|
|
|
|
|
+ </choose>
|
|
|
|
|
+ <if test="reportReqVo.userId != null and reportReqVo.userId != ''">
|
|
|
|
|
+ and p.userid = #{reportReqVo.userId}
|
|
|
|
|
+ </if>
|
|
|
</if>
|
|
</if>
|
|
|
|
|
+ <!--通用查询条件拼接-->
|
|
|
<if test="reportReqVo.insCompany != null and reportReqVo.insCompany != ''">
|
|
<if test="reportReqVo.insCompany != null and reportReqVo.insCompany != ''">
|
|
|
- and p.inscompany = #{reportReqVo.insCompany}
|
|
|
|
|
|
|
+ and p.company_id = #{reportReqVo.insCompany}
|
|
|
</if>
|
|
</if>
|
|
|
<if test="reportReqVo.quoteStartDate != null and reportReqVo.quoteEndDate != null">
|
|
<if test="reportReqVo.quoteStartDate != null and reportReqVo.quoteEndDate != null">
|
|
|
and p.signdate between #{reportReqVo.quoteStartDate} AND #{reportReqVo.quoteEndDate}
|
|
and p.signdate between #{reportReqVo.quoteStartDate} AND #{reportReqVo.quoteEndDate}
|
|
|
</if>
|
|
</if>
|
|
|
- group by deptid
|
|
|
|
|
- <if test="reportReqVo.userId != null and reportReqVo.userId != ''">
|
|
|
|
|
- ,userid
|
|
|
|
|
|
|
+ <!--下钻查询时拼接-->
|
|
|
|
|
+ <if test="reportReqVo.isDrilling != null and reportReqVo.isDrilling == '1'.toString()">
|
|
|
|
|
+ <!--按团队下钻时-->
|
|
|
|
|
+ <if test="reportReqVo.drilType != null and reportReqVo.drilType == '1'.toString()">
|
|
|
|
|
+ group by p.`username`,p.userid order by p.`username`
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--按机构下钻时-->
|
|
|
|
|
+ <if test="reportReqVo.drilType != null and reportReqVo.drilType == '0'.toString()">
|
|
|
|
|
+ <!--下钻的是五级机构时,下钻到团队-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '5'.toString()">
|
|
|
|
|
+ group by p.deptid order by p.deptid
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--下钻的是四级机构时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '4'.toString()">
|
|
|
|
|
+ group by substr(p.deptid,1,11) order by substr(p.deptid,1,11)
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--下钻的是三级机构时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '3'.toString()">
|
|
|
|
|
+ group by substr(p.deptid,1,8) order by substr(p.deptid,1,8)
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--下钻的是二级机构时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '2'.toString()">
|
|
|
|
|
+ group by substr(p.deptid,1,6) order by substr(p.deptid,1,6)
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--下钻的是一级机构时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '1'.toString()">
|
|
|
|
|
+ group by substr(p.deptid,1,4) order by substr(p.deptid,1,4)
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--下钻的是总部时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == 'X'.toString()">
|
|
|
|
|
+ group by substr(p.deptid,1,2) order by substr(p.deptid,1,2)
|
|
|
|
|
+ </if>
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--返回上层时-->
|
|
|
|
|
+ <if test="reportReqVo.drilType != null and reportReqVo.drilType == '2'.toString()">
|
|
|
|
|
+ <!--返回的是五级机构时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '5'.toString()">
|
|
|
|
|
+ group by substr(p.deptid,1,11) order by substr(p.deptid,1,11)
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--返回的是四级机构时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '4'.toString()">
|
|
|
|
|
+ group by substr(p.deptid,1,8) order by substr(p.deptid,1,8)
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--返回的是三级机构时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '3'.toString()">
|
|
|
|
|
+ group by substr(p.deptid,1,6) order by substr(p.deptid,1,6)
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--返回的是二级机构时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '2'.toString()">
|
|
|
|
|
+ group by substr(p.deptid,1,4) order by substr(p.deptid,1,4)
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--返回的是一级机构时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '1'.toString()">
|
|
|
|
|
+ group by substr(p.deptid,1,2) order by substr(p.deptid,1,2)
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <!--返回的是总部时-->
|
|
|
|
|
+ <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == 'X'.toString()">
|
|
|
|
|
+ group by substr(p.deptid,1,1) order by substr(p.deptid,1,1)
|
|
|
|
|
+ </if>
|
|
|
|
|
+ </if>
|
|
|
</if>
|
|
</if>
|
|
|
) as s
|
|
) as s
|
|
|
</select>
|
|
</select>
|