|
|
@@ -755,6 +755,7 @@
|
|
|
|
|
|
<resultMap id="PayApplyUserReportDataMap" type="com.ydtech.modules.report.model.vo.PayApplyUserReportResVo">
|
|
|
<result property="institution" column="institution" jdbcType="VARCHAR"/>
|
|
|
+ <result property="institutionId" column="institutionId" jdbcType="VARCHAR"/>
|
|
|
<result property="deptname" column="deptname" jdbcType="VARCHAR"/>
|
|
|
<result property="username" column="username" jdbcType="VARCHAR"/>
|
|
|
<result property="waitPayCostsPremiums" column="wait_pay_costs_premiums" jdbcType="DECIMAL"/>
|
|
|
@@ -767,10 +768,68 @@
|
|
|
|
|
|
|
|
|
<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 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 paidfee ELSE 0 END ) AS paid_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 totalfee-paidfee ELSE 0 END ) AS wait_pay_retail_premiums
|
|
|
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>
|
|
|
- </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 test="reportReqVo.insCompany != null and reportReqVo.insCompany != ''">
|
|
|
- and p.inscompany = #{reportReqVo.insCompany}
|
|
|
+ and p.company_id = #{reportReqVo.insCompany}
|
|
|
</if>
|
|
|
<if test="reportReqVo.quoteStartDate != null and reportReqVo.quoteEndDate != null">
|
|
|
and p.signdate between #{reportReqVo.quoteStartDate} AND #{reportReqVo.quoteEndDate}
|
|
|
</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>
|
|
|
</select>
|
|
|
<select id="queryPayApplyUserReportDataCount" resultType="Long">
|
|
|
select
|
|
|
count(1)
|
|
|
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>
|
|
|
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,
|
|
|
@@ -819,30 +1060,154 @@
|
|
|
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
|
|
|
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>
|
|
|
- </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 test="reportReqVo.insCompany != null and reportReqVo.insCompany != ''">
|
|
|
- and p.inscompany = #{reportReqVo.insCompany}
|
|
|
+ and p.company_id = #{reportReqVo.insCompany}
|
|
|
</if>
|
|
|
<if test="reportReqVo.quoteStartDate != null and reportReqVo.quoteEndDate != null">
|
|
|
and p.signdate between #{reportReqVo.quoteStartDate} AND #{reportReqVo.quoteEndDate}
|
|
|
</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>
|
|
|
) as s
|
|
|
</select>
|
|
|
@@ -893,38 +1258,96 @@
|
|
|
</select>
|
|
|
<!--===========================================分割线=======报表管理费=================================================-->
|
|
|
<resultMap id="PayApplyDeptReportDataMap" type="com.ydtech.modules.report.model.vo.PayApplyDeptReportResVo">
|
|
|
- <result property="institution" column="institution" jdbcType="VARCHAR"/>
|
|
|
- <result property="deptname" column="deptname" jdbcType="VARCHAR"/>
|
|
|
- <result property="username" column="username" jdbcType="VARCHAR"/>
|
|
|
+ <result property="institutionId" column="institutionId" jdbcType="VARCHAR"/>
|
|
|
<result property="waitPayCostsPremiums" column="wait_pay_costs_premiums" jdbcType="DECIMAL"/>
|
|
|
<result property="paidCostsPremiums" column="paid_costs_premiums" jdbcType="DECIMAL"/>
|
|
|
<result property="sumCostsPremiums" column="sum_costs_premiums" jdbcType="DECIMAL"/>
|
|
|
- <result property="waitPayRetailPremiums" column="wait_pay_retail_premiums" jdbcType="DECIMAL"/>
|
|
|
- <result property="paidRetailPremiums" column="paid_retail_premiums" jdbcType="DECIMAL"/>
|
|
|
- <result property="sumRetailPremiums" column="sum_retail_premiums" jdbcType="DECIMAL"/>
|
|
|
</resultMap>
|
|
|
<select id="queryPayApplyDeptReportData" resultMap="PayApplyDeptReportDataMap">
|
|
|
- SELECT
|
|
|
- count(distinct policyno) policy_count,
|
|
|
- SUM(p.`sumpremium`) sumpremium,
|
|
|
- SUM(p.`supervise_costs_premiums`) supervise_costs_premiums,
|
|
|
- SUM(p.`other_costs_premiums`) other_costs_premiums,
|
|
|
- SUM(p.`sum_costs_premiums`) sum_costs_premiums
|
|
|
- FROM
|
|
|
- report_payable_basedata p WHERE 1=1
|
|
|
+ SELECT comcode as institutionId,
|
|
|
+ sum( t.keepamount + t.addamount ) AS sum_costs_premiums,
|
|
|
+ sum( CASE WHEN settlestatus = '1' THEN t.keepamount + t.addamount ELSE 0 END ) AS paid_costs_premiums ,
|
|
|
+ sum( t.keepamount + t.addamount ) - sum( CASE WHEN settlestatus = '1' THEN t.keepamount + t.addamount ELSE 0 END ) as wait_pay_costs_premiums
|
|
|
+ FROM ins_deptfee t WHERE 1=1
|
|
|
+ <if test="reportReqVo.groupInsCompanyArr != null and reportReqVo.groupInsCompanyArr != ''">
|
|
|
+ and t.comcode in
|
|
|
+ <foreach collection="reportReqVo.groupInsCompanyArr" item="comcode" open="("
|
|
|
+ separator="," close=")">
|
|
|
+ #{comcode}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="reportReqVo.insCompany != null and reportReqVo.insCompany != ''">
|
|
|
+ and t.inscompany = #{reportReqVo.insCompany}
|
|
|
+ </if>
|
|
|
+ <if test="reportReqVo.quoteStartDate != null and reportReqVo.quoteEndDate != null">
|
|
|
+ and t.signdate between #{reportReqVo.quoteStartDate} AND #{reportReqVo.quoteEndDate}
|
|
|
+ </if>
|
|
|
+ group by comcode
|
|
|
</select>
|
|
|
<select id="queryPayApplyDeptReportDataCount" resultType="Long">
|
|
|
- select
|
|
|
- count(1)
|
|
|
- from (
|
|
|
+ select count(1) from (
|
|
|
+ SELECT comcode as institutionId,
|
|
|
+ sum( t.keepamount + t.addamount ) AS sum_costs_premiums,
|
|
|
+ sum( CASE WHEN settlestatus = '1' THEN t.keepamount + t.addamount ELSE 0 END ) AS paid_costs_premiums ,
|
|
|
+ sum( t.keepamount + t.addamount ) - sum( CASE WHEN settlestatus = '1' THEN t.keepamount + t.addamount ELSE 0 END ) as wait_pay_costs_premiums
|
|
|
+ FROM ins_deptfee t WHERE 1=1
|
|
|
+ <if test="reportReqVo.groupInsCompanyArr != null and reportReqVo.groupInsCompanyArr != ''">
|
|
|
+ and t.comcode in
|
|
|
+ <foreach collection="reportReqVo.groupInsCompanyArr" item="comcode" open="("
|
|
|
+ separator="," close=")">
|
|
|
+ #{comcode}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="reportReqVo.insCompany != null and reportReqVo.insCompany != ''">
|
|
|
+ and t.inscompany = #{reportReqVo.insCompany}
|
|
|
+ </if>
|
|
|
+ <if test="reportReqVo.quoteStartDate != null and reportReqVo.quoteEndDate != null">
|
|
|
+ and t.signdate between #{reportReqVo.quoteStartDate} AND #{reportReqVo.quoteEndDate}
|
|
|
+ </if>
|
|
|
+ group by comcode
|
|
|
+ ) as s
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <resultMap id="PayApplyDeptReportListResMap" type="com.ydtech.modules.report.model.vo.PayApplyDeptReportListResVo">
|
|
|
+ <result column="orderno" property="orderno" />
|
|
|
+ <result column="policyno" property="policyno" />
|
|
|
+ <result column="riskcode" property="riskcode" />
|
|
|
+ <result column="licenseno" property="licenseno" />
|
|
|
+ <result column="comlevel" property="comlevel" />
|
|
|
+ <result column="comcode" property="comcode" />
|
|
|
+ <result column="keeprate" property="keeprate" />
|
|
|
+ <result column="addrate" property="addrate" />
|
|
|
+ <result column="keepamount" property="keepamount" />
|
|
|
+ <result column="addamount" property="addamount" />
|
|
|
+ <result column="auditstatus" property="auditstatus" />
|
|
|
+ <result column="settlestatus" property="settlestatus" />
|
|
|
+ <result column="inscompany" property="inscompany" />
|
|
|
+ <result column="signDate" property="signDate" />
|
|
|
+ </resultMap>
|
|
|
+
|
|
|
+ <select id="exportPayApplyDeptReportListData" resultMap="PayApplyDeptReportListResMap">
|
|
|
SELECT
|
|
|
- count(distinct policyno) policy_count,
|
|
|
- SUM(p.`sumpremium`) sumpremium,
|
|
|
- SUM(p.`supervise_costs_premiums`) supervise_costs_premiums,
|
|
|
- SUM(p.`other_costs_premiums`) other_costs_premiums,
|
|
|
- SUM(p.`sum_costs_premiums`) sum_costs_premiums
|
|
|
+ p.orderno,
|
|
|
+ p.policyno,
|
|
|
+ p.riskcode,
|
|
|
+ p.licenseno,
|
|
|
+ p.comlevel,
|
|
|
+ p.comcode,
|
|
|
+ p.keeprate,
|
|
|
+ p.addrate,
|
|
|
+ p.keepamount,
|
|
|
+ p.addamount,
|
|
|
+ p.auditstatus,
|
|
|
+ p.settlestatus,
|
|
|
+ p.inscompany,
|
|
|
+ p.signDate
|
|
|
FROM
|
|
|
- report_payable_basedata p WHERE 1=1
|
|
|
- ) as s
|
|
|
+ ins_deptfee p WHERE 1=1
|
|
|
+ <if test="reportReqVo.deptId != null and reportReqVo.deptId != ''">
|
|
|
+ and p.comcode = #{reportReqVo.deptId}
|
|
|
+ </if>
|
|
|
+ <if test="reportReqVo.insCompany != null and reportReqVo.insCompany != ''">
|
|
|
+ and p.inscompany = #{reportReqVo.insCompany}
|
|
|
+ </if>
|
|
|
</select>
|
|
|
</mapper>
|