| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper
- PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
- "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.ydtech.modules.report.dao.ReportInsurancePolicyMapper">
- <resultMap id="BaseResultMap" type="com.ydtech.modules.report.model.ReportInsurancePolicy">
- <result property="companyId" column="company_id" jdbcType="VARCHAR"/>
- <result property="insCompany" column="ins_company" jdbcType="VARCHAR"/>
- <result property="agreementId" column="agreement_id" jdbcType="VARCHAR"/>
- <result property="agreementName" column="agreement_name" jdbcType="VARCHAR"/>
- <result property="policyno" column="policyno" jdbcType="VARCHAR"/>
- <result property="insidePayTime" column="inside_pay_time" jdbcType="TIMESTAMP"/>
- <result property="startDate" column="start_date" jdbcType="VARCHAR"/>
- <result property="endDate" column="end_date" jdbcType="VARCHAR"/>
- <result property="riskCode" column="risk_code" jdbcType="VARCHAR"/>
- <result property="riskName" column="risk_name" jdbcType="VARCHAR"/>
- <result property="sumpremium" column="sumpremium" jdbcType="DECIMAL"/>
- <result property="taxpremium" column="taxpremium" jdbcType="DECIMAL"/>
- <result property="taxLaterPremium" column="tax_later_premium" jdbcType="DECIMAL"/>
- <result property="insuranceSubAmount" column="insurance_sub_amount" jdbcType="VARCHAR"/>
- <result property="frameno" column="frameno" jdbcType="VARCHAR"/>
- <result property="licenseno" column="licenseno" jdbcType="VARCHAR"/>
- <result property="vehicleUse" column="vehicle_use" jdbcType="VARCHAR"/>
- <result property="powerType" column="power_type" jdbcType="VARCHAR"/>
- <result property="cimodelclass" column="cimodelclass" jdbcType="VARCHAR"/>
- <result property="limitLoad" column="limit_load" jdbcType="VARCHAR"/>
- <result property="appliName" column="appli_name" jdbcType="VARCHAR"/>
- <result property="insureName" column="insure_name" jdbcType="VARCHAR"/>
- <result property="deptid" column="deptid" jdbcType="VARCHAR"/>
- <result property="deptname" column="deptname" jdbcType="VARCHAR"/>
- <result property="userid" column="userid" jdbcType="VARCHAR"/>
- <result property="username" column="username" jdbcType="VARCHAR"/>
- <result property="productid" column="productid" jdbcType="VARCHAR"/>
- <result property="product" column="product" jdbcType="VARCHAR"/>
- <result property="operatorid" column="operatorid" jdbcType="VARCHAR"/>
- <result property="sumCostsPremiums" column="sum_costs_premiums" jdbcType="DECIMAL"/>
- <result property="superviseCostsPremiums" column="supervise_costs_premiums" jdbcType="DECIMAL"/>
- <result property="otherCostsPremiums" column="other_costs_premiums" jdbcType="DECIMAL"/>
- <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
- </resultMap>
- <select id="queryOrderAndCostData" resultMap="OrderAndCostDataMap">
- 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 test="reportReqVo.riskCode != null and reportReqVo.riskCode != ''">
- <if test="reportReqVo.riskCode!='ALL'.toString()">
- p.`risk_name` risk_name,
- </if>
- </if>
- 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_insurance_policy p WHERE 1=1
- <!--下钻查询时拼接-->
- <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>
- <!--按机构下钻时-->
- <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.company_id = #{reportReqVo.insCompany}
- </if>
- <if test="reportReqVo.riskCode != null and reportReqVo.riskCode != ''">
- <if test="reportReqVo.riskCode!='ALL'.toString()">
- and p.risk_code = #{reportReqVo.riskCode}
- </if>
- </if>
- <if test="reportReqVo.quoteStartDate != null and reportReqVo.quoteEndDate != null">
- and p.inside_pay_time between #{reportReqVo.quoteStartDate} AND #{reportReqVo.quoteEndDate}
- </if>
- <choose>
- <when test="reportReqVo.riskCode != null and reportReqVo.riskCode!='ALL'.toString()">
- GROUP BY p.`risk_name`
- <!--下钻查询时拼接-->
- <if test="reportReqVo.isDrilling != null and reportReqVo.isDrilling == '1'.toString()">
- <!--按团队下钻时-->
- <if test="reportReqVo.drilType != null and reportReqVo.drilType == '1'.toString()">
- ,p.`username`,p.userid order by p.`username`,p.`risk_name`
- </if>
- <!--按机构下钻时-->
- <if test="reportReqVo.drilType != null and reportReqVo.drilType == '0'.toString()">
- <!--下钻的是五级机构时,下钻到团队-->
- <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '5'.toString()">
- ,p.deptid order by p.deptid,p.`risk_name`
- </if>
- <!--下钻的是四级机构时-->
- <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '4'.toString()">
- ,substr(p.deptid,1,11) order by substr(p.deptid,1,11),p.`risk_name`
- </if>
- <!--下钻的是三级机构时-->
- <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '3'.toString()">
- ,substr(p.deptid,1,8) order by substr(p.deptid,1,8),p.`risk_name`
- </if>
- <!--下钻的是二级机构时-->
- <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '2'.toString()">
- ,substr(p.deptid,1,6) order by substr(p.deptid,1,6),p.`risk_name`
- </if>
- <!--下钻的是一级机构时-->
- <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '1'.toString()">
- ,substr(p.deptid,1,4) order by substr(p.deptid,1,4),p.`risk_name`
- </if>
- <!--下钻的是总部时-->
- <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == 'X'.toString()">
- ,substr(p.deptid,1,2) order by substr(p.deptid,1,2),p.`risk_name`
- </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) order by substr(p.deptid,1,11)
- </if>
- <!--返回的是四级机构时-->
- <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '4'.toString()">
- ,substr(p.deptid,1,8) order by substr(p.deptid,1,8)
- </if>
- <!--返回的是三级机构时-->
- <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '3'.toString()">
- ,substr(p.deptid,1,6) order by substr(p.deptid,1,6)
- </if>
- <!--返回的是二级机构时-->
- <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '2'.toString()">
- ,substr(p.deptid,1,4) order by substr(p.deptid,1,4)
- </if>
- <!--返回的是一级机构时-->
- <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '1'.toString()">
- ,substr(p.deptid,1,2) order by substr(p.deptid,1,2)
- </if>
- <!--返回的是总部时-->
- <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == 'X'.toString()">
- ,substr(p.deptid,1,1) order by substr(p.deptid,1,1)
- </if>
- </if>
- </if>
- </when>
- <otherwise>
- <!--下钻查询时拼接-->
- <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>
- </otherwise>
- </choose>
- </select>
- <resultMap id="OrderAndCostDataMap" type="com.ydtech.modules.report.model.vo.OrderVolumeAndCostStatisticsResVo">
- <result property="institution" column="institution" jdbcType="VARCHAR"/>
- <result property="deptname" column="deptname" jdbcType="VARCHAR"/>
- <result property="username" column="username" jdbcType="VARCHAR"/>
- <result property="riskName" column="risk_name" jdbcType="VARCHAR"/>
- <result property="policyCount" column="policy_count" jdbcType="DECIMAL"/>
- <result property="sumPremium" column="sumremium" jdbcType="DECIMAL"/>
- <result property="sumCostsPremiums" column="sum_costs_premiums" jdbcType="DECIMAL"/>
- <result property="superviseCostsPremiums" column="supervise_costs_premiums" jdbcType="DECIMAL"/>
- <result property="otherCostsPremiums" column="other_costs_premiums" jdbcType="DECIMAL"/>
- </resultMap>
- <select id="queryOrderAndCostDataCount" resultType="Long">
- select
- count(1)
- from (
- 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 test="reportReqVo.riskCode != null and reportReqVo.riskCode != ''">
- <if test="reportReqVo.riskCode!='ALL'.toString()">
- p.`risk_name` risk_name,
- </if>
- </if>
- 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_insurance_policy p WHERE 1=1
- <!--下钻查询时拼接-->
- <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>
- <!--按机构下钻时-->
- <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.company_id = #{reportReqVo.insCompany}
- </if>
- <if test="reportReqVo.riskCode != null and reportReqVo.riskCode != ''">
- <if test="reportReqVo.riskCode!='ALL'.toString()">
- and p.risk_code = #{reportReqVo.riskCode}
- </if>
- </if>
- <if test="reportReqVo.quoteStartDate != null and reportReqVo.quoteEndDate != null">
- and p.inside_pay_time between #{reportReqVo.quoteStartDate} AND #{reportReqVo.quoteEndDate}
- </if>
- <choose>
- <when test="reportReqVo.riskCode != null and reportReqVo.riskCode!='ALL'.toString()">
- GROUP BY p.`risk_name`
- <!--下钻查询时拼接-->
- <if test="reportReqVo.isDrilling != null and reportReqVo.isDrilling == '1'.toString()">
- <!--按团队下钻时-->
- <if test="reportReqVo.drilType != null and reportReqVo.drilType == '1'.toString()">
- ,p.`username`,p.userid order by p.`username`,p.`risk_name`
- </if>
- <!--按机构下钻时-->
- <if test="reportReqVo.drilType != null and reportReqVo.drilType == '0'.toString()">
- <!--下钻的是五级机构时,下钻到团队-->
- <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '5'.toString()">
- ,p.deptid order by p.deptid,p.`risk_name`
- </if>
- <!--下钻的是四级机构时-->
- <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '4'.toString()">
- ,substr(p.deptid,1,11) order by substr(p.deptid,1,11),p.`risk_name`
- </if>
- <!--下钻的是三级机构时-->
- <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '3'.toString()">
- ,substr(p.deptid,1,8) order by substr(p.deptid,1,8),p.`risk_name`
- </if>
- <!--下钻的是二级机构时-->
- <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '2'.toString()">
- ,substr(p.deptid,1,6) order by substr(p.deptid,1,6),p.`risk_name`
- </if>
- <!--下钻的是一级机构时-->
- <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '1'.toString()">
- ,substr(p.deptid,1,4) order by substr(p.deptid,1,4),p.`risk_name`
- </if>
- <!--下钻的是总部时-->
- <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == 'X'.toString()">
- ,substr(p.deptid,1,2) order by substr(p.deptid,1,2),p.`risk_name`
- </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) order by substr(p.deptid,1,11)
- </if>
- <!--返回的是四级机构时-->
- <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '4'.toString()">
- ,substr(p.deptid,1,8) order by substr(p.deptid,1,8)
- </if>
- <!--返回的是三级机构时-->
- <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '3'.toString()">
- ,substr(p.deptid,1,6) order by substr(p.deptid,1,6)
- </if>
- <!--返回的是二级机构时-->
- <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '2'.toString()">
- ,substr(p.deptid,1,4) order by substr(p.deptid,1,4)
- </if>
- <!--返回的是一级机构时-->
- <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == '1'.toString()">
- ,substr(p.deptid,1,2) order by substr(p.deptid,1,2)
- </if>
- <!--返回的是总部时-->
- <if test="reportReqVo.drilFlag != null and reportReqVo.drilFlag == 'X'.toString()">
- ,substr(p.deptid,1,1) order by substr(p.deptid,1,1)
- </if>
- </if>
- </if>
- </when>
- <otherwise>
- <!--下钻查询时拼接-->
- <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>
- </otherwise>
- </choose>
- ) as s
- </select>
- <resultMap id="OrderVolumeAndCostStatisticsListResMap" type="com.ydtech.modules.report.model.vo.OrderVolumeAndCostStatisticsListResVo">
- <result property="insCompany" column="ins_company" jdbcType="VARCHAR"/>
- <result property="agreementName" column="agreement_name" jdbcType="VARCHAR"/>
- <result property="policyno" column="policyno" jdbcType="VARCHAR"/>
- <result property="insidePayTime" column="inside_pay_time" jdbcType="VARCHAR"/>
- <result property="startDate" column="start_date" jdbcType="VARCHAR"/>
- <result property="endDate" column="end_date" jdbcType="VARCHAR"/>
- <result property="riskName" column="risk_name" jdbcType="VARCHAR"/>
- <result property="sumpremium" column="sumpremium" jdbcType="DECIMAL"/>
- <result property="taxpremium" column="taxpremium" jdbcType="DECIMAL"/>
- <result property="taxLaterPremium" column="tax_later_premium" jdbcType="DECIMAL"/>
- <result property="insuranceSubAmount" column="insurance_sub_amount" jdbcType="VARCHAR"/>
- <result property="frameno" column="frameno" jdbcType="VARCHAR"/>
- <result property="licenseno" column="licenseno" jdbcType="VARCHAR"/>
- <result property="vehicleUse" column="vehicle_use" jdbcType="VARCHAR"/>
- <result property="powerType" column="power_type" jdbcType="VARCHAR"/>
- <result property="cimodelclass" column="cimodelclass" jdbcType="VARCHAR"/>
- <result property="limitLoad" column="limit_load" jdbcType="VARCHAR"/>
- <result property="appliName" column="appli_name" jdbcType="VARCHAR"/>
- <result property="insureName" column="insure_name" jdbcType="VARCHAR"/>
- <result property="deptname" column="deptname" jdbcType="VARCHAR"/>
- <result property="username" column="username" jdbcType="VARCHAR"/>
- <result property="product" column="product" jdbcType="VARCHAR"/>
- <result property="sumCostsPremiums" column="sum_costs_premiums" jdbcType="DECIMAL"/>
- <result property="superviseCostsPremiums" column="supervise_costs_premiums" jdbcType="DECIMAL"/>
- <result property="otherCostsPremiums" column="other_costs_premiums" jdbcType="DECIMAL"/>
- </resultMap>
- <select id="queryOrderAndCostList" resultMap="OrderVolumeAndCostStatisticsListResMap">
- SELECT
- ins_company,
- agreement_name,
- policyno,
- DATE_FORMAT(inside_pay_time, '%Y-%m-%d') inside_pay_time,
- DATE_FORMAT(start_date, '%Y-%m-%d') start_date,
- DATE_FORMAT(end_date, '%Y-%m-%d') end_date,
- risk_name,
- sumpremium,
- taxpremium,
- tax_later_premium,
- insurance_sub_amount,
- frameno,
- licenseno,
- vehicle_use,
- power_type,
- cimodelclass,
- limit_load,
- appli_name,
- insure_name,
- deptname,
- username,
- product,
- sum_costs_premiums,
- supervise_costs_premiums,
- other_costs_premiums
- FROM
- report_insurance_policy 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>
- </otherwise>
- </choose>
- <if test="reportReqVo.userId != null and reportReqVo.userId != ''">
- and p.userid = #{reportReqVo.userId}
- </if>
- <!--通用查询条件拼接-->
- <if test="reportReqVo.insCompany != null and reportReqVo.insCompany != ''">
- and p.company_id = #{reportReqVo.insCompany}
- </if>
- <if test="reportReqVo.riskCode != null and reportReqVo.riskCode != ''">
- <if test="reportReqVo.riskCode!='ALL'.toString()">
- and p.risk_code = #{reportReqVo.riskCode}
- </if>
- </if>
- <if test="reportReqVo.quoteStartDate != null and reportReqVo.quoteEndDate != null">
- and p.inside_pay_time between #{reportReqVo.quoteStartDate} AND #{reportReqVo.quoteEndDate}
- </if>
- </select>
- <!--===========================================分割线=======报表手续费和分销费=================================================-->
- <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"/>
- <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="queryPayApplyUserReportData" resultMap="PayApplyUserReportDataMap">
- 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,
- SUM( CASE feetype WHEN '2' THEN totalfee ELSE 0 END ) AS sum_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
- FROM report_payable_basedata p WHERE 1=1
- <!--下钻查询时拼接-->
- <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>
- <!--按机构下钻时-->
- <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.company_id = #{reportReqVo.insCompany}
- </if>
- <if test="reportReqVo.quoteStartDate != null and reportReqVo.quoteEndDate != null">
- and p.signdate between #{reportReqVo.quoteStartDate} AND #{reportReqVo.quoteEndDate}
- </if>
- <!--下钻查询时拼接-->
- <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
- <!--下钻查询时拼接-->
- <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,
- SUM( CASE feetype WHEN '2' THEN totalfee ELSE 0 END ) AS sum_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
- FROM report_payable_basedata p WHERE 1=1
- <!--下钻查询时拼接-->
- <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>
- <!--按机构下钻时-->
- <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.company_id = #{reportReqVo.insCompany}
- </if>
- <if test="reportReqVo.quoteStartDate != null and reportReqVo.quoteEndDate != null">
- and p.signdate between #{reportReqVo.quoteStartDate} AND #{reportReqVo.quoteEndDate}
- </if>
- <!--下钻查询时拼接-->
- <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>
- <resultMap id="PayApplyUserReportListDataMap" type="com.ydtech.modules.report.model.vo.PayApplyUserReportResVo">
- <result property="institution" column="institution" jdbcType="VARCHAR"/>
- <result property="deptname" column="deptname" jdbcType="VARCHAR"/>
- <result property="username" column="username" jdbcType="VARCHAR"/>
- <result property="inscompany" column="inscompany" jdbcType="VARCHAR"/>
- <result property="policyno" column="policyno" jdbcType="VARCHAR"/>
- <result property="riskcode" column="riskcode" 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="queryPayApplyUserReportList" resultMap="PayApplyUserReportListDataMap">
- SELECT deptname,username,inscompany,policyno,riskcode,
- CASE feetype WHEN '1' THEN totalfee ELSE 0 END AS sum_costs_premiums,
- CASE feetype WHEN '1' THEN paidfee ELSE 0 END AS paid_costs_premiums,
- CASE feetype WHEN '1' THEN totalfee-paidfee ELSE 0 END AS wait_pay_costs_premiums,
- CASE feetype WHEN '2' THEN totalfee ELSE 0 END AS sum_retail_premiums,
- CASE feetype WHEN '2' THEN paidfee ELSE 0 END AS paid_retail_premiums,
- 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>
- </otherwise>
- </choose>
- <if test="reportReqVo.userId != null and reportReqVo.userId != ''">
- and p.userId = #{reportReqVo.userId}
- </if>
- <if test="reportReqVo.insCompany != null and reportReqVo.insCompany != ''">
- and p.inscompany = #{reportReqVo.insCompany}
- </if>
- <if test="reportReqVo.quoteStartDate != null and reportReqVo.quoteEndDate != null">
- and p.signdate between #{reportReqVo.quoteStartDate} AND #{reportReqVo.quoteEndDate}
- </if>
- </select>
- <!--===========================================分割线=======报表管理费=================================================-->
- <resultMap id="PayApplyDeptReportDataMap" type="com.ydtech.modules.report.model.vo.PayApplyDeptReportResVo">
- <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"/>
- </resultMap>
- <select id="queryPayApplyDeptReportData" resultMap="PayApplyDeptReportDataMap">
- 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 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
- 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
- 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>
|