| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613 |
- <?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.order.dao.InsAreaCompanyMapper">
- <resultMap id="BaseResultMap" type="com.ydtech.modules.order.entity.InsAreaCompany">
- <id property="id" column="id" jdbcType="VARCHAR"/>
- <result property="reqtxt" column="reqtxt" javaType="com.alibaba.fastjson.JSONObject"
- typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
- <result property="reptxt" column="reptxt" javaType="com.alibaba.fastjson.JSONObject"
- typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
- <result property="riskinfo" column="riskinfo" javaType="com.alibaba.fastjson.JSONArray"
- typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
- <result property="kindinfo" column="kindinfo" javaType="com.alibaba.fastjson.JSONArray"
- typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
- <result property="accidentInfo" column="accident_info" javaType="com.alibaba.fastjson.JSONArray"
- typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
- <result property="taxArrears" column="tax_arrears" javaType="com.alibaba.fastjson.JSONArray"
- typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
- <result property="crossInsurance" column="cross_insurance" javaType="com.alibaba.fastjson.JSONArray"
- typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
- <result property="orderno" column="orderno" jdbcType="VARCHAR"/>
- <result property="agreementId" column="agreement_id" jdbcType="BIGINT"/>
- <result property="apiType" column="api_type" jdbcType="TINYINT"/>
- <result property="orderstatus" column="orderstatus" jdbcType="VARCHAR"/>
- <result property="companyId" column="company_id" jdbcType="VARCHAR"/>
- <result property="inscompany" column="inscompany" jdbcType="VARCHAR"/>
- <result property="jqapplyno" column="jqapplyno" jdbcType="VARCHAR"/>
- <result property="jqpolicyno" column="jqpolicyno" jdbcType="VARCHAR"/>
- <result property="syapplyno" column="syapplyno" jdbcType="VARCHAR"/>
- <result property="sypolicyno" column="sypolicyno" jdbcType="VARCHAR"/>
- <result property="jqpremium" column="jqpremium" jdbcType="DECIMAL"/>
- <result property="sypremium" column="sypremium" jdbcType="DECIMAL"/>
- <result property="jypremium" column="jypremium" jdbcType="DECIMAL"/>
- <result property="sumpremium" column="sumpremium" jdbcType="DECIMAL"/>
- <result property="taxamount" column="taxamount" jdbcType="DECIMAL"/>
- <result property="jqdiscountrate" column="jqdiscountrate" jdbcType="DOUBLE"/>
- <result property="sydiscountrate" column="sydiscountrate" jdbcType="DOUBLE"/>
- <result property="feerate" column="feerate" jdbcType="DOUBLE"/>
- <result property="disrate" column="disrate" jdbcType="DOUBLE"/>
- <result property="auditid" column="auditid" jdbcType="VARCHAR"/>
- <result property="auditname" column="auditname" jdbcType="VARCHAR"/>
- <result property="audittime" column="audittime" jdbcType="TIMESTAMP"/>
- <result property="auditopinion" column="auditopinion" jdbcType="VARCHAR"/>
- <result property="jqappoint" column="jqappoint" jdbcType="VARCHAR"/>
- <result property="syappoint" column="syappoint" jdbcType="VARCHAR"/>
- <result property="createtime" column="createtime" jdbcType="TIMESTAMP"/>
- <result property="payDate" column="pay_date" jdbcType="TIMESTAMP"/>
- <result property="paymentLink" column="payment_link" jdbcType="VARCHAR"/>
- <result property="insOrderNo" column="ins_order_no" jdbcType="VARCHAR"/>
- <result property="attributionId" column="attribution_id" jdbcType="VARCHAR"/>
- <result property="jqStartDate" column="jq_start_date" jdbcType="VARCHAR"/>
- <result property="jqEndDate" column="jq_end_date" jdbcType="VARCHAR"/>
- <result property="syStartDate" column="sy_start_date" jdbcType="VARCHAR"/>
- <result property="syEndDate" column="sy_end_date" jdbcType="VARCHAR"/>
- <result property="accidentStrInfo" column="accident_str_info" jdbcType="VARCHAR"/>
- <result property="score" column="score" jdbcType="VARCHAR"/>
- <result property="jqScore" column="jq_score" jdbcType="VARCHAR"/>
- <result property="syScore" column="sy_score" jdbcType="VARCHAR"/>
- <result property="lossRation" column="loss_ration" jdbcType="DOUBLE"/>
- <result property="jqLossRation" column="jq_loss_ration" jdbcType="DOUBLE"/>
- <result property="syLossRation" column="sy_loss_ration" jdbcType="DOUBLE"/>
- <result property="totalAdjustRate" column="total_adjust_rate" jdbcType="DOUBLE"/>
- <result property="jqAdjustRate" column="jq_adjust_rate" jdbcType="DOUBLE"/>
- <result property="syAdjustRate" column="sy_adjust_rate" jdbcType="DOUBLE"/>
- <result property="insideOrderStatus" column="inside_order_status" jdbcType="TINYINT"/>
- <result property="insidePayTime" column="inside_pay_time" jdbcType="TIMESTAMP"/>
- <result property="signingTime" column="signing_time" jdbcType="TIMESTAMP"/>
- <result property="jqRenewal" column="jq_renewal" jdbcType="VARCHAR"/>
- <result property="syRenewal" column="sy_renewal" jdbcType="VARCHAR"/>
- <result property="jqClaims" column="jq_claims" jdbcType="VARCHAR"/>
- <result property="syClaims" column="sy_claims" jdbcType="VARCHAR"/>
- </resultMap>
- <resultMap id="InsAreaCompanyQueryDto" type="com.ydtech.modules.order.entity.dto.InsAreaCompanyQueryDto"
- extends="BaseResultMap">
- <result property="agreementName" column="agreement_name" jdbcType="VARCHAR"/>
- <result property="fileStatus" column="fileStatus" jdbcType="VARCHAR"/>
- </resultMap>
- <sql id="Base_Column_List">
- id,orderno,inscompany,
- reqtxt,reptxt,jqapplyno,
- jqpolicyno,syapplyno,sypolicyno,
- riskinfo,kindinfo,jqpremium,
- sypremium,taxamount,sumpremium,
- jqdiscountrate,sydiscountrate,feerate,
- disrate,auditid,auditname,
- audittime,auditopinion,jqappoint,
- syappoint,createtime,payment_link
- </sql>
- <select id="selectByOrderNo" resultMap="InsAreaCompanyQueryDto">
- SELECT iac.*, pa.agreement_name,
- (select IF(count(0)>0,'true','false') from pingan_sh_uploafile where sub_order_no=iac.id AND status=0) as fileStatus
- FROM ins_area_company as iac
- left join ptl_agreement as pa on pa.id = iac.agreement_id
- INNER JOIN (SELECT company_id, max(createtime) AS max_createtime
- FROM ins_area_company
- WHERE orderno = #{orderNo}
- GROUP BY company_id) t ON t.company_id = iac.company_id
- AND t.max_createtime = iac.createtime
- WHERE iac.orderno = #{orderNo}
- </select>
- <select id="selectAcceptInsurance" resultMap="InsAreaCompanyQueryDto">
- SELECT iac.*, pa.agreement_name,io.is_external,
- (select IF(count(0)>0,'true','false') from pingan_sh_uploafile where sub_order_no=iac.id AND status=0) as fileStatus
- FROM ins_area_company as iac
- left join ptl_agreement as pa on pa.id = iac.agreement_id
- left join ins_orders io on iac.orderno=io.orderno
- WHERE iac.orderstatus = 3
- and iac.orderno = #{orderNo};
- </select>
- <select id="queryLatestStatus" resultType="java.lang.String">
- SELECT iac.orderstatus
- FROM ins_area_company as iac
- INNER JOIN (SELECT company_id, max(createtime) AS max_createtime
- FROM ins_area_company
- WHERE orderno = #{orderNo}
- GROUP BY company_id) t ON t.company_id = iac.company_id
- AND t.max_createtime = iac.createtime
- WHERE iac.orderno = #{orderNo}
- ORDER BY orderstatus DESC
- LIMIT 1
- </select>
- <select id="getorDerIds" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
- SELECT a.id as "id",
- a.orderno as "orderno"
- FROM ins_area_company a
- LEFT JOIN ins_fee_order_new b ON a.id = b.ins_order_no
- WHERE a.orderstatus = '3'
- or a.orderstatus = '2'
- and b.id is not null
- </select>
- <select id="getAuditOrders" resultType="com.ydtech.modules.order.entity.InsOrders">
- SELECT
- iac.id as orderno,
- io.quoteno,
- io.orderstatus,
- io.company_id,
- io.ins_company,
- io.carinfo,
- io.userid,
- io.username,
- io.deptid,
- io.deptname,
- io.agreeid,
- iac.productid,
- iac.product,
- iac.createtime,
- io.frameno,
- io.licenseno,
- JSON_UNQUOTE(json_extract(io.insureinfo, '$.name')) as insuredname,
- io.is_external,
- iac.jq_start_date as jqstartdate,
- iac.jq_end_date as jqenddate,
- iac.sy_start_date as systartdate,
- iac.sy_end_date as syenddate,
- io.vehicle_and_vessel_tax,
- io.operatorid,
- iac.operator_name,
- sd.management_source,
- iac.problem_order,
- CASE ifa.audituser
- WHEN '自动审核' THEN ifa.audituser
- ELSE su2.name END
- AS auditUser,
- CASE ifa.audituser
- WHEN '自动审核' THEN '2'
- ELSE '1' END
- AS checkType,
- ifa.audittime as auditTime,
- ifa.auditstatus as auditStatus,
- eic.namesimple as partnerCompaniesName,
- iac.id as subOrderId,
- iac.signing_time as signingTime,
- iac.pay_date as payDate,
- pa.agreement_code as agreementCode,
- pa.agreement_name as agreementName,
- pa.business_description as businessDescription,
- pa.job_description as jobDescription,
- pa.agreement_title as agreementTitle,
- pa.docking_person as dockingPerson,
- io.entry_status
- FROM
- ins_fee_audit ifa
- LEFT JOIN ins_orders io ON io.orderno = ifa.orderno
- LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
- AND iac.orderstatus = 3
- LEFT JOIN sys_user su ON su.id = io.userid
- LEFT JOIN sys_dept sd ON sd.id = su.dept_id
- LEFT JOIN sys_user su2 ON ifa.audituser = su2.id
- LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
- LEFT JOIN esm_ins_company eic ON eic.id = pa.partner_companies_id
- WHERE
- iac.id = ifa.ins_order_no
- AND iac.orderstatus = 3
- <if test="params.auditStatus != null and params.auditStatus != ''">
- and ifa.auditstatus = #{params.auditStatus}
- </if>
- <if test="params.quoteStartDateStr != null and params.quoteStartDateStr != '' and params.quoteEndDateStr != null and params.quoteEndDateStr != ''">
- and DATE_FORMAT(iac.createtime, '%Y-%m-%d') between #{params.quoteStartDateStr} AND
- #{params.quoteEndDateStr}
- </if>
- <if test="params.orderNo != null and params.orderNo != ''">
- AND iac.id= #{params.orderNo}
- </if>
- <if test="params.licenseNo != null and params.licenseNo != ''">
- AND io.licenseno = #{params.licenseNo}
- </if>
- <if test="params.frameNo != null and params.frameNo != ''">
- AND io.frameno = #{params.frameNo}
- </if>
- <if test="params.insuredName != null and params.insuredName != ''">
- AND json_extract(io.insureinfo, '$.name') = #{params.insuredName}
- </if>
- <if test="params.companyId != null and params.companyId != ''">
- AND io.company_id = #{params.companyId}
- </if>
- <if test="params.engineNo != null and params.engineNo != ''">
- and JSON_EXTRACT( io.carinfo, '$.engineNo' ) = #{params.engineNo}
- </if>
- <if test="params.riskCode != null and params.riskCode != ''">
- and iac.product = #{params.riskCode}
- </if>
- <if test="params.attachStartDateStr != null and params.attachStartDateStr != '' and params.attachStartDateStr != null and params.attachStartDateStr != '' ">
- and ((
- DATE_FORMAT(iac.jq_start_date, '%Y-%m-%d') BETWEEN #{params.attachStartDateStr}
- AND #{params.attachEndDateStr}
- )
- OR ( DATE_FORMAT(iac.sy_start_date, '%Y-%m-%d') BETWEEN #{params.attachStartDateStr} AND
- #{params.attachEndDateStr} )
- )
- </if>
- <if test="params.provinceId != null and params.provinceId != ''">
- and io.deptid like "${params.provinceId}%"
- </if>
- <if test="params.problemOrder != null and params.problemOrder != ''">
- and iac.problem_order like "${params.problemOrder}%"
- </if>
- <if test="params.cityId != null and params.cityId != ''">
- and io.deptid like "${params.cityId}%"
- </if>
- <if test="params.countyId != null and params.countyId != ''">
- and io.deptid like "${params.countyId}%"
- </if>
- <if test="params.houseId != null and params.houseId != ''">
- and io.deptid like "${params.houseId}%"
- </if>
- <if test="params.operatorId != null and params.operatorId != ''">
- and io.userid = #{params.operatorId}
- </if>
- <if test="params.operatorName != null and params.operatorName != ''">
- and io.username = #{params.operatorName}
- </if>
- <if test="params.auditId != null and params.auditId != ''">
- and iac.new_operator_id = #{params.auditId}
- </if>
- <if test="params.agreeId != null and params.agreeId != ''">
- and iac.agreement_id = #{params.agreeId}
- </if>
- <if test="params.managementSource != null and params.managementSource != ''">
- and sd.management_source = #{params.managementSource}
- </if>
- <if test="params.signStartDateStr != null and params.signStartDateStr != '' and params.signEndDateStr != null and params.signEndDateStr != ''">
- and DATE_FORMAT(iac.signing_time, '%Y-%m-%d') between #{params.signStartDateStr} AND
- #{params.signEndDateStr}
- </if>
- <if test="params.payStartDateStr != null and params.payStartDateStr != '' and params.payEndDateStr != null and params.payEndDateStr != ''">
- and iac.pay_date between #{params.payStartDateStr} AND #{params.payEndDateStr}
- </if>
- <if test="params.isExternal != null and params.isExternal != ''">
- and io.is_external = #{params.isExternal}
- </if>
- <if test="params.jqPolicyNo != null and params.jqPolicyNo != ''">
- and iac.jqpolicyno = #{params.jqPolicyNo}
- </if>
- <if test="params.syPolicyNo != null and params.syPolicyNo != ''">
- and iac.sypolicyno = #{params.syPolicyNo}
- </if>
- <if test="params.noPolicyNo != null and params.noPolicyNo != ''">
- and iac.cross_insurance like concat('%', #{params.noPolicyNo}, '%')
- </if>
- <if test="params.checkUser != null and params.checkUser != ''">
- and CASE ifa.audituser WHEN '自动审核' THEN ifa.audituser
- ELSE su2.name END = #{params.checkUser}
- </if>
- <if test="params.checkType != null and params.checkType != ''">
- and CASE ifa.audituser
- WHEN '自动审核' THEN '2'
- ELSE '1' END = #{params.checkType}
- </if>
- order by iac.createtime desc
- </select>
- <select id="getByUserId" resultType="com.ydtech.modules.order.entity.InsOrders">
- SELECT
- io.*,
- sd.management_source
- FROM
- ins_orders io left join sys_user su on su.id = io.userid left join sys_dept sd on sd.id = su.dept_id
- WHERE
- orderno IN (
- SELECT
- orderno
- FROM
- ins_area_company
- WHERE
- id IN ( SELECT ins_order_no FROM ins_fee_order_new WHERE id NOT IN ( SELECT ins_order_no FROM ins_fee_audit ) )
- AND orderstatus = 3
- )
- AND
- io.orderstatus= 3
- <if test="orderNo != null and orderNo != ''">
- AND orderno = #{orderNo}
- </if>
- <if test="licenseNo != null and licenseNo != ''">
- AND licenseno = #{licenseNo}
- </if>
- <if test="frameNo != null and frameNo != ''">
- AND frameno = #{frameNo}
- </if>
- <if test="userId != null and userId != ''">
- AND userid = #{userId}
- </if>
- <if test="insuredname != null and insuredname != ''">
- AND insuredname = #{insuredname}
- </if>
- <if test="startDateStr != null and startDateStr != ''">
- AND createtime BETWEEN #{startDateStr} and #{endDateStr}
- </if>
- </select>
- <select id="selectFirstPromotionBy" resultType="com.ydtech.modules.order.entity.InsOrders">
- SELECT
- sum(a.first_detail_premiums) as "willFirstPremiums"
- FROM
- ins_fee_order_new a
- LEFT JOIN ins_area_company iac on iac.id=a.ins_order_no
- left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
- WHERE
- iff.auditstatus=0
- AND iac.orderstatus =3
- <if test="firstUserId != null and firstUserId != ''">
- AND a.first_level_user_id = #{firstUserId}
- </if>
- <if test="secondUserId != null and secondUserId != ''">
- AND a.two_level_user_id = #{secondUserId}
- </if>
- <if test="thirdUserId != null and thirdUserId != ''">
- AND a.three_level_user_id = #{thirdUserId}
- </if>
- <if test="id != null and id != ''">
- AND a.id = #{id}
- </if>
- </select>
- <select id="selectSecondPromotionBy" resultType="com.ydtech.modules.order.entity.InsOrders">
- SELECT
- sum( fee.p ) as "willFirstPremiums"
- FROM
- (
- SELECT
- sum( a.first_detail_premiums ) AS p
- FROM
- ins_fee_order_new a
- LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
- left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
- <where>
- iff.auditstatus=0
- and iac.orderstatus = '3'
- <if test="userId!=null and userId!= ''">
- AND a.first_level_user_id = #{userId}
- </if>
- <if test="id != null and id!=''">
- AND a.id =#{id}
- </if>
- </where>
- UNION
- SELECT
- sum( a.third_detail_premiums ) AS p
- FROM
- ins_fee_order_new a
- LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
- left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
- <where>
- iff.auditstatus=0
- and iac.orderstatus = '3'
- <if test="userId!=null and userId!= ''">
- AND a.three_level_user_id = #{userId}
- </if>
- <if test="id != null and id!=''">
- AND a.id =#{id}
- </if>
- </where>
- UNION
- SELECT
- sum( a.second_detail_premiums ) AS p
- FROM
- ins_fee_order_new a
- LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
- left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
- <where>
- iff.auditstatus=0
- and iac.orderstatus = '3'
- <if test="userId!=null and userId!= ''">
- AND a.two_level_user_id = #{userId}
- </if>
- <if test="id != null and id!=''">
- AND a.id =#{id}
- </if>
- </where>
- ) AS fee
- </select>
- <select id="selectThirdPromotionBy" resultType="com.ydtech.modules.order.entity.InsOrders">
- SELECT
- sum(a.third_detail_premiums) as "willThreePremiums"
- FROM
- ins_fee_order_new a
- LEFT JOIN ins_area_company iac on iac.id=a.ins_order_no
- left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
- WHERE
- iff.auditstatus=0
- AND iac.orderstatus =3
- <if test="firstUserId != null and firstUserId != ''">
- AND a.first_level_user_id = #{firstUserId}
- </if>
- <if test="secondUserId != null and secondUserId != ''">
- AND a.two_level_user_id = #{secondUserId}
- </if>
- <if test="thirdUserId != null and thirdUserId != ''">
- AND a.three_level_user_id = #{thirdUserId}
- </if>
- <if test="id != null and id != ''">
- AND a.id = #{id}
- </if>
- </select>
- <select id="getAlreadyAuditOrders" resultType="com.ydtech.modules.order.entity.InsOrders">
- SELECT
- io.*,
- sd.management_source,
- su2.name AS auditUser,
- ifa.audittime as auditTime
- FROM
- ins_orders io
- LEFT JOIN ins_fee_audit ifa ON ifa.orderno = io.orderno
- LEFT JOIN sys_user su ON su.id = io.userid
- LEFT JOIN sys_dept sd ON sd.id = su.dept_id
- LEFT JOIN sys_user su2 on ifa.audituser = su2.id
- WHERE
- io.orderno IN (
- SELECT
- orderno
- FROM
- ins_area_company
- WHERE
- id IN (
- SELECT
- ifon.ins_order_no
- FROM
- ins_fee_order_new ifon
- RIGHT JOIN ins_fee_audit ifa ON ifon.ins_order_no = ifa.ins_order_no
- WHERE
- ifa.auditstatus = #{params.auditStatus}
- )
- )
- AND orderstatus = 3
- <!-- <if test="params.orderNo != null and params.orderNo != ''">-->
- <!-- AND orderno = #{params.orderNo}-->
- <!-- </if>-->
- <if test="params.licenseNo != null and params.licenseNo != ''">
- AND licenseno = #{params.licenseNo}
- </if>
- <if test="params.frameNo != null and params.frameNo != ''">
- AND frameno = #{params.frameNo}
- </if>
- <if test="params.insuredName != null and params.insuredName != ''">
- AND insuredname = #{params.insuredName}
- </if>
- <if test="params.companyId != null and params.companyId != ''">
- AND company_id = #{params.companyId}
- </if>
- <if test="params.startDateStr != null and params.startDateStr != ''">
- AND createtime BETWEEN #{params.startDateStr} and #{params.endDateStr}
- </if>
- </select>
- <select id="selectListByDateStr" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
- -- 查询订单信息
- SELECT
- iac.*
- FROM
- ins_area_company iac
- left JOIN ins_orders AS io ON io.orderno = iac.orderno
- WHERE
- 1=1
- <if test="dateStr != null and dateStr != ''">
- AND DATE_FORMAT(io.createtime, '%Y-%m') =#{dateStr}
- </if>
- </select>
- <select id="selectListById" resultMap="BaseResultMap">
- SELECT
- iac.*
- FROM
- ins_area_company iac
- WHERE
- 1=1
- <if test="id != null and id != ''">
- AND iac.id =#{id}
- </if>
- </select>
- <select id="selectSecondPromotionByNew" resultType="com.ydtech.modules.order.entity.InsOrders">
- SELECT
- sum( fee.p ) as "willFirstPremiums"
- FROM
- (
- SELECT
- sum( a.first_detail_premiums ) AS p
- FROM
- ins_fee_order_new a
- LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
- left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
- <where>
- <choose>
- <when test='type == "1"'>
- iff.auditstatus=0
- </when>
- <otherwise>
- iff.auditstatus=1
- </otherwise>
- </choose>
- and iac.orderstatus = '3'
- <if test="userId!=null and userId!= ''">
- AND a.first_level_user_id = #{userId}
- </if>
- <if test="id != null and id!=''">
- AND a.id =#{id}
- </if>
- </where>
- UNION
- SELECT
- sum( a.third_detail_premiums ) AS p
- FROM
- ins_fee_order_new a
- LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
- left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
- <where>
- <choose>
- <when test='type == "1"'>
- iff.auditstatus=0
- </when>
- <otherwise>
- iff.auditstatus=1
- </otherwise>
- </choose>
- and iac.orderstatus = '3'
- <if test="userId!=null and userId!= ''">
- AND a.three_level_user_id = #{userId}
- </if>
- <if test="id != null and id!=''">
- AND a.id =#{id}
- </if>
- </where>
- UNION
- SELECT
- sum( a.second_detail_premiums ) AS p
- FROM
- ins_fee_order_new a
- LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
- left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
- <where>
- <choose>
- <when test='type == "1"'>
- iff.auditstatus=0
- </when>
- <otherwise>
- iff.auditstatus=1
- </otherwise>
- </choose>
- and iac.orderstatus = '3'
- <if test="userId!=null and userId!= ''">
- AND a.two_level_user_id = #{userId}
- </if>
- <if test="id != null and id!=''">
- AND a.id =#{id}
- </if>
- </where>
- ) AS fee
- </select>
- <select id="getSubOrderDetails" resultType="com.ydtech.modules.admin.model.vo.SubOrder">
- SELECT
- iac.id as subOrderId,
- iac.signing_time as signingTime,
- iac.jqpremium as jqpremium,
- iac.sypremium as sypremium,
- iac.jypremium as jypremium,
- io.licenseno as licenseno,
- io.userid as userId
- FROM
- ins_area_company iac
- LEFT JOIN ins_orders AS io ON io.orderno = iac.orderno
- WHERE
- iac.id=#{subOrderId}
- </select>
- <select id="premiumReportYear" resultType="com.ydtech.modules.admin.model.dto.PremiumReportDto">
- SELECT
- CONCAT(YEAR(iac.createtime),'-',LPAD(MONTH(iac.createtime), 2, '0')) reportDate,
- sum(jqpremium) jqpremium,
- sum(sypremium) sypremium,
- sum(sumpremium) sumpremium
- FROM
- ins_area_company iac left join ins_orders io on iac.orderno=io.orderno
- WHERE
- iac.orderstatus = 3 and
- iac.createtime >= #{beginTime} and iac.createtime <= #{endTime}
- and io.userid=#{userId}
- GROUP BY CONCAT(YEAR(iac.createtime),'-',LPAD(MONTH(iac.createtime), 2, '0'))
- </select>
- <select id="premiumReportMonth" resultType="com.ydtech.modules.admin.model.dto.PremiumReportDto">
- SELECT
- CONCAT(YEAR(iac.createtime),'-',LPAD(MONTH(iac.createtime), 2, '0'),'-',LPAD(Day(iac.createtime), 2, '0')) reportDate,
- sum(jqpremium) jqpremium,
- sum(sypremium) sypremium,
- sum(sumpremium) sumpremium
- FROM
- ins_area_company iac left join ins_orders io on iac.orderno=io.orderno
- WHERE
- iac.orderstatus = 3 and
- iac.createtime >= #{beginTime} and iac.createtime <= #{endTime}
- and io.userid=#{userId}
- GROUP BY CONCAT(YEAR(iac.createtime),'-',LPAD(MONTH(iac.createtime), 2, '0'),'-',LPAD(Day(iac.createtime), 2, '0'))
- </select>
- <select id="premiumReportDay" resultType="com.ydtech.modules.admin.model.dto.PremiumReportDto">
- SELECT
- CONCAT(YEAR ( iac.createtime ),'-',LPAD( MONTH ( iac.createtime ), 2, '0' ),'-',LPAD( DAY ( iac.createtime ), 2, '0' ),' ',LPAD( HOUR ( iac.createtime ), 2, '0' ))
- reportDate,
- sum( jqpremium ) jqpremium,
- sum( sypremium ) sypremium,
- sum( sumpremium ) sumpremium
- FROM
- ins_area_company iac left join ins_orders io on iac.orderno=io.orderno
- WHERE
- iac.orderstatus = 3 and
- iac.createtime >= #{beginTime} and iac.createtime <= #{endTime}
- and io.userid=#{userId}
- GROUP BY CONCAT(YEAR ( iac.createtime ),'-',LPAD( MONTH ( iac.createtime ), 2, '0' ),'-',LPAD( DAY ( iac.createtime ), 2, '0' ),' ',LPAD( HOUR ( iac.createtime ), 2, '0' ))
- </select>
- <select id="getAllpremium" resultType="com.ydtech.modules.admin.model.dto.AllpremiumDto">
- SELECT
- ifnull(sum( iac.jqpremium + iac.sypremium + iac.jypremium ),0) as sumPremium,
- count( 0 ) as sumCount
- FROM
- ins_area_company iac left join ins_orders io on iac.orderno=io.orderno
- WHERE
- iac.orderstatus = 3
- and io.userid=#{userId}
- AND YEAR (iac.createtime) = #{year}
- </select>
- <select id="getRejectOrder" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
- select
- iac.id,
- iac.orderno,
- iac.agreement_id,
- iac.jqpremium,
- iac.sypremium,
- iac.jypremium,
- iac.taxamount,
- iac.sumpremium,
- io.licenseno,
- ifa.audittime,
- ifa.audituser as auditname,
- ifa.rejectinfo,
- "1" as orderExternalStatus
- FROM
- ins_fee_audit ifa
- LEFT JOIN
- ins_area_company iac on iac.id = ifa.ins_order_no
- LEFT JOIN
- ins_orders io on iac.orderno = io.orderno
- left join
- sys_user su on su.id= ifa.audituser
- WHERE
- iac.operator_id = #{userId}
- AND
- ifa.auditstatus = 2 and IFNULL(iac.del_flag,'') != '0'
- <if test="vo.id != null and vo.id!=''">
- and iac.id = #{vo.id}
- </if>
- <if test="vo.licenseno != null and vo.licenseno!='' ">
- and io.licenseno like CONCAT('%', #{vo.licenseno}, '%')
- </if>
- <if test="vo.auditname != null and vo.auditname!='' ">
- and su.name like CONCAT('%', #{vo.auditname}, '%')
- </if>
- </select>
- <select id="queryBusinessDataPage"
- resultType="com.ydtech.modules.admin.model.report.opetationData.BusinessDataDto">
- SELECT
- <if test="flag != null and flag!='' and flag='1'">
- o.userid as userId,
- o.username as userName,
- </if>
- sum( iac.sumpremium ) as signeSumPremiumAmount,
- sum( iac.jqpremium ) as jqPremiumAmount,
- sum( iac.sypremium ) as syPremiumAmount,
- sum( iac.taxamount ) as taxAmount,
- sum( ion.no_premium ) as fcFeeAmount
- FROM
- ins_area_company iac
- LEFT JOIN ins_orders o ON iac.orderno = o.orderno
- LEFT JOIN ins_fee_order_new ion ON iac.id = ion.ins_order_no
- where iac.orderstatus = 3 and ion.id is not null
- <if test="userList != null and userList.size()>0 ">
- and o.userid IN
- <foreach item="item" collection="userList" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="flag != null and flag!='' and flag='1'">
- group by o.userid,o.username
- </if>
- </select>
- <select id="queryQuotationSubOrderCountDataPage"
- resultType="com.ydtech.modules.admin.model.report.opetationData.QuotationCountDataDto">
- SELECT
- <if test="flag != null and flag!='' and flag='1'">
- o.userid as userId,
- o.username as userName,
- </if>
- iac.orderstatus as orderStatus
- FROM
- ins_area_company iac
- LEFT JOIN ins_orders o ON iac.orderno = o.orderno
- where (iac.orderstatus = 0 or iac.orderstatus = 2 or iac.orderstatus = 3 )
- <if test="userList != null and userList.size()>0 ">
- and o.userid IN
- <foreach item="item" collection="userList" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="flag != null and flag!='' and flag='1'">
- group by o.userid,o.username,iac.orderstatus
- </if>
- </select>
- <select id="queryQuotationOrderCountDataPage"
- resultType="com.ydtech.modules.admin.model.report.opetationData.QuotationCountDataDto">
- SELECT
- a.userId as userId,
- a.userName as userName,
- b.qutationCount AS insOrderQutationCount,
- b.qutationInsureCount as insOrderQutationInsureCount,
- b.closeRate AS insOrderCloseRate as insOrderCloseRate,
- a.qutationCount as subOrderQutationCount,
- a.underwritingCount as subOrderUnderwritingCount,
- a.qutationInsureCount as subOrderQutationInsureCount,
- a.passRate as subOrderCloseRate,
- a.closeRate as subOrderPassRate,
- a.contributionRate as subOrderContributionRate
- FROM
- (
- SELECT
- inso.userid AS userId,
- inso.username AS userName,
- COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS qutationCount,
- COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
- COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
- COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END )/ count( iac.orderstatus ) AS passRate,
- COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )/ count( iac.orderstatus ) AS closeRate,
- COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )/ COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS contributionRate
- FROM
- ins_area_company iac
- LEFT JOIN ins_orders inso ON iac.orderno = inso.orderno
- <where>
- <if test="userList != null and userList.size()>0 ">
- and o.userid IN
- <foreach item="item" collection="userList" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- </where>
- GROUP BY
- inso.userid,
- inso.username
- ) a
- LEFT JOIN (
- SELECT
- inso.userid AS userId,
- inso.username AS userName,
- count( inso.orderstatus ) AS qutationCount,
- count( CASE WHEN inso.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
- COUNT( CASE WHEN inso.orderstatus = 3 THEN 1 END )/ count( inso.orderstatus ) AS closeRate
- FROM
- ins_orders inso
- <where>
- <if test="userList != null and userList.size()>0 ">
- and o.userid IN
- <foreach item="item" collection="userList" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- </where>
- GROUP BY
- inso.userid,
- inso.username
- ) b ON a.userId = b.userId
- </select>
- <select id="queryCompanyPremiumDataPage"
- resultType="com.ydtech.modules.admin.model.report.company.CompanyPremiumDataDto">
- SELECT
- agree.insurance_company_id AS companyId,
- agree.insurance_company AS companyName,
- agree.partner_companies_id AS parterCompanyId,
- ins.NAME AS parterCompanyName,
- sum( iac.sumpremium ) AS signeSumPremiumAmount
- FROM
- ins_area_company iac
- LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
- LEFT JOIN esm_ins_company ins ON agree.partner_companies_id = ins.id
- WHERE
- iac.orderstatus = 3
- and
- agree.id is not null
- <if test="vo.companyId != null and vo.companyId!='' ">
- agree.insurance_company_id = #{vo.companyId}
- </if>
- <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
- agree.insurance_company_id = #{vo.parterCompanyId}
- </if>
- GROUP BY
- agree.insurance_company_id,
- agree.insurance_company,
- agree.partner_companies_id,
- ins.NAME
- </select>
- <select id="queryCompanyQutationCountDataPage"
- resultType="com.ydtech.modules.admin.model.report.company.CompanyQutationCountDataDto">
- SELECT
- a.* ,
- (select ins.namesimple from esm_ins_company
- ins where a.parterCompanyId = ins.id) as "parterCompanyName"
- FROM
- (
- SELECT
- count(agree.partner_companies_id) as "orderSuccessNumber",
- agree.insurance_company AS companyName,
- agree.partner_companies_id AS parterCompanyId,
- iac.company_id as "companyId",
- count( iac.orderstatus ) AS qutationCount,
- count( iac.id ) AS orderSuccessNumberRate,
- COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) + COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS underwritingCount,
- COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
- (COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) + COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )) / count( iac.orderstatus ) AS passRate,
- COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) / (COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) + COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )) AS closeRate,
- COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )/ count( iac.orderstatus ) AS contributionRate,
- COUNT(CASE WHEN agree.audit_type =1 and ifa.auditstatus =1 and iac.orderstatus =3 THEN 1 END) as "numberManual"
- FROM
- ins_area_company iac
- LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
- LEFT JOIN ins_orders io ON iac.orderno = io.orderno
- LEFT JOIN sys_dept sd ON sd.id = io.deptid
- LEFT JOIN ins_fee_audit ifa on ifa.ins_order_no =iac.id
- WHERE
- agree.id IS NOT NULL
- <if test="vo.companyId != null and vo.companyId!='' ">
- AND agree.insurance_company_id = #{vo.companyId}
- </if>
- <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
- AND agree.partner_companies_id = #{vo.parterCompanyId}
- </if>
- <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
- AND iac.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
- </if>
- <if test="vo.managementSource != null and vo.managementSource!=''">
- AND sd.management_source =#{vo.managementSource}
- </if>
- <if test="vo.userId != null and vo.userId !=''">
- AND io.userid =#{vo.userId}
- </if>
- <if test="vo.deptId != null and vo.deptId !=''">
- AND io.deptId like concat('%',#{vo.deptId},'%')
- </if>
- <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
- AND sd.id in
- <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
- AND io.userid in
- <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- GROUP BY
- agree.insurance_company,
- iac.company_id,
- agree.partner_companies_id
- ) a
- order by a.parterCompanyId
- </select>
- <select id="getInsAreaCompanyError"
- resultType="com.ydtech.modules.admin.model.report.company.CompanyQutationCountDataDto">
- SELECT
- count(iace.id) as "areaCompanyErrNumber"
- FROM
- ins_area_company_error iace
- LEFT JOIN ptl_agreement agree ON iace.agreement_id = agree.id
- <where>
- 1=1
- <if test="vo.companyId != null and vo.companyId!='' ">
- AND agree.insurance_company_id = #{vo.companyId}
- </if>
- <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
- AND agree.partner_companies_id = #{vo.parterCompanyId}
- </if>
- <if test="vo.userId != null and vo.userId!=''">
- AND iace.user_id =#{vo.userId}
- </if>
- <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
- AND iace.create_time BETWEEN #{vo.beginDate} AND #{vo.endDate}
- </if>
- <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
- AND iace.dept_id in
- <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
- AND iace.user_id in
- <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- </where>
- </select>
- <select id="queryCompanyQutationCountDataPageTotal"
- resultType="java.lang.Long">
- SELECT
- count(0)
- FROM
- (
- SELECT
- agree.partner_companies_id
- FROM
- ins_area_company iac
- LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
- LEFT JOIN ins_orders io ON iac.orderno = io.orderno
- LEFT JOIN sys_dept sd ON sd.id = io.deptid
- WHERE
- agree.id IS NOT NULL
- <if test="vo.companyId != null and vo.companyId!='' ">
- AND agree.insurance_company_id = #{vo.companyId}
- </if>
- <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
- AND agree.partner_companies_id = #{vo.parterCompanyId}
- </if>
- <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
- AND iac.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
- </if>
- <if test="vo.managementSource != null and vo.managementSource!=''">
- AND sd.management_source =#{vo.managementSource}
- </if>
- <if test="vo.userId != null and vo.userId !=''">
- AND io.userid =#{vo.userId}
- </if>
- <if test="vo.deptId != null and vo.deptId !=''">
- AND io.deptId like concat('%',#{vo.deptId},'%')
- </if>
- <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
- AND sd.id in
- <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
- AND io.userid in
- <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- GROUP BY
- agree.partner_companies_id
- ) a
- </select>
- <select id="getStageOrder" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
- select
- iac.id,
- iac.orderno,
- iac.agreement_id,
- iac.jqpremium,
- iac.sypremium,
- iac.jypremium,
- iac.taxamount,
- iac.sumpremium,
- io.licenseno,
- iac.createtime,
- "0" as orderExternalStatus
- FROM
- ins_area_company iac
- LEFT JOIN
- ins_orders io on iac.orderno = io.orderno
- left join ptl_agreement agree on iac.agreement_id =agree.id
- WHERE
- iac.operator_id = #{userId}
- AND
- iac.orderstatus = 0
- and agree.is_external =1
- <if test="vo.id != null and vo.id!='' ">
- and iac.id = #{vo.id}
- </if>
- <if test="vo.licenseno != null and vo.licenseno!='' ">
- and io.licenseno like CONCAT('%', #{vo.licenseno}, '%')
- </if>
- </select>
- <select id="queryPageTaskStatistics" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
- select a.*, su.name as "userName",
- inf.url as "logo",
- sui.sex as "sex",
- su.leader_name as "leaderName"
- from (
- SELECT
- sd.NAME AS "deptName",
- io.userid AS "userId",
- sd.parent_id as "deptId",
- COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS qutationCount,
- COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
- COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
- COUNT( CASE WHEN iac.orderstatus = 4 THEN 1 END ) AS underwritingReturn,
- COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) / COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS "passingRate",
- COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) / COUNT( iac.orderstatus ) AS "closeRate",
- (COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) + COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ))/ COUNT( iac.orderstatus ) AS "contributionRate",
- COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) / COUNT( iac.orderstatus ) AS "quotationRate",
- COUNT(CASE WHEN io.order_source = 0 and iac.orderstatus = 0 THEN 1 END) as "pcOrderSource",
- COUNT(CASE WHEN io.order_source = 1 and iac.orderstatus = 0 THEN 1 END) as "appOrderSource",
- COUNT( CASE WHEN iac.orderstatus = 1 THEN 1 END ) AS "auditOrder"
- FROM
- ins_area_company iac
- LEFT JOIN ins_orders io ON io.orderno = iac.orderno
- LEFT JOIN sys_dept sd ON sd.id = io.deptid
- <where>
- sd.management_source = '1'
- <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
- and io.deptid like "${taskStatisticsVo.provinceId}%"
- </if>
- <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
- and io.deptid like "${taskStatisticsVo.cityId}%"
- </if>
- <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
- and io.deptid like "${taskStatisticsVo.countyId}%"
- </if>
- <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
- and io.deptid like "${taskStatisticsVo.houseId}%"
- </if>
- <if test="taskStatisticsVo.userId != null and taskStatisticsVo.userId != ''">
- and io.userid =#{taskStatisticsVo.userId}
- </if>
- <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
- AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
- </if>
- <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
- AND DATE_FORMAT( iac.signing_time, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
- </if>
- <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
- and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
- </if>
- <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
- AND sd.id in
- <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
- AND io.userid in
- <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
- <choose>
- <when test="taskStatisticsVo.days =='1'">
- and io.createtime >= DATE_SUB(NOW(), INTERVAL 1 DAY)
- </when>
- <when test="taskStatisticsVo.days =='7'">
- and io.createtime >= DATE_SUB(NOW(), INTERVAL 7 DAY)
- </when>
- <when test="taskStatisticsVo.days =='30'">
- and io.createtime >= DATE_SUB(NOW(), INTERVAL 30 DAY)
- </when>
- </choose>
- </if>
- </where>
- GROUP BY
- io.userid,
- sd.NAME,
- sd.id
- ) a
- left join sys_user su on su.id =a.userId
- LEFT JOIN ins_upload_files inf on su.head_sculpture =inf.id
- LEFT JOIN sys_user_info sui on sui .id =su.id
- <where>
- <if test='taskStatisticsVo.userName !=null and taskStatisticsVo.userName!="" '>
- and su.name like concat('%',#{taskStatisticsVo.userName},'%')
- </if>
- <if test='taskStatisticsVo.leaderId !=null and taskStatisticsVo.leaderId!="" '>
- and su.leader_id =#{taskStatisticsVo.leaderId}
- </if>
- <if test='taskStatisticsVo.userId !=null and taskStatisticsVo.userId!="" '>
- and su.id =#{taskStatisticsVo.userId}
- </if>
- </where>
- </select>
- <select id="queryPageTaskStatisticsTotal" resultType="java.lang.Long">
- select count(0) from (
- SELECT
- io.userid
- FROM
- ins_area_company iac
- LEFT JOIN ins_orders io ON io.orderno = iac.orderno
- LEFT JOIN sys_dept sd ON sd.id = io.deptid
- <where>
- sd.management_source = '1'
- <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
- and io.deptid like "${taskStatisticsVo.provinceId}%"
- </if>
- <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
- and io.deptid like "${taskStatisticsVo.cityId}%"
- </if>
- <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
- and io.deptid like "${taskStatisticsVo.countyId}%"
- </if>
- <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
- and io.deptid like "${taskStatisticsVo.houseId}%"
- </if>
- <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
- AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
- </if>
- <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
- AND DATE_FORMAT( iac.signing_time, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
- </if>
- <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
- and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
- </if>
- <if test="taskStatisticsVo.userId != null and taskStatisticsVo.userId != ''">
- and io.userid =#{taskStatisticsVo.userId}
- </if>
- <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
- AND sd.id in
- <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
- AND io.userid in
- <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
- <choose>
- <when test="taskStatisticsVo.days =='1'">
- and io.createtime >= DATE_SUB(NOW(), INTERVAL 1 DAY)
- </when>
- <when test="taskStatisticsVo.days =='7'">
- and io.createtime >= DATE_SUB(NOW(), INTERVAL 7 DAY)
- </when>
- <when test="taskStatisticsVo.days =='30'">
- and io.createtime >= DATE_SUB(NOW(), INTERVAL 30 DAY)
- </when>
- </choose>
- </if>
- </where>
- GROUP BY
- io.userid
- ) a
- </select>
- <select id="insuranceCompanyQueryPage" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
- SELECT
- a.*,
- ( SELECT eic.namesimple FROM esm_ins_company eic WHERE eic.id = a.partner_companies_id ) AS "partnerCompaniesName"
- FROM
- (
- SELECT
- pa.insurance_company_id,
- pa.partner_companies_id,
- pa.insurance_company AS "insuranceCompanyName",
- COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS qutationCount,
- COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
- COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
- COUNT( CASE WHEN iac.orderstatus = 4 THEN 1 END ) AS underwritingReturn,
- COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) / COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS "passingRate",
- COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) / COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS "closeRate",
- COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) / COUNT( iac.orderstatus ) AS "contributionRate",
- COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) / COUNT( iac.orderstatus ) AS "quotationRate",
- COUNT( CASE WHEN iac.orderstatus = 1 THEN 1 END ) AS "auditOrder"
- FROM
- ins_area_company iac
- LEFT JOIN ins_fee_audit ifa ON ifa.ins_order_no = iac.id
- LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
- LEFT JOIN ins_orders io ON io.orderno = iac.orderno
- <where>
- pa.insurance_company_id IS NOT NULL
- <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
- and io.deptid like concat('%', #{taskStatisticsVo.provinceId}, '%')
- </if>
- <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
- and io.deptid like concat('%', #{taskStatisticsVo.cityId}, '%')
- </if>
- <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
- and io.deptid like concat('%', #{taskStatisticsVo.countyId}, '%')
- </if>
- <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
- and io.deptid like concat('%', #{taskStatisticsVo.houseId}, '%')
- </if>
- <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
- AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
- </if>
- <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
- AND DATE_FORMAT( iac.signing_time, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
- </if>
- <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId != ''">
- AND iac.company_id =#{taskStatisticsVo.companyId}
- </if>
- <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
- and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
- </if>
- <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
- AND io.deptid in
- <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
- AND io.userid in
- <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- </where>
- GROUP BY
- pa.insurance_company_id,
- pa.partner_companies_id,
- pa.insurance_company
- ) a
- </select>
- <select id="insuranceCompanyQueryTotal" resultType="java.lang.Long">
- SELECT
- COUNT(0)
- FROM
- (
- SELECT
- pa.insurance_company_id,
- pa.partner_companies_id
- FROM
- ins_area_company iac
- LEFT JOIN ins_fee_audit ifa ON ifa.ins_order_no = iac.id
- LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
- LEFT JOIN ins_orders io ON io.orderno = iac.orderno
- <where>
- pa.insurance_company_id IS NOT NULL
- <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
- and io.deptid like concat('%', #{taskStatisticsVo.provinceId}, '%')
- </if>
- <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
- and io.deptid like concat('%', #{taskStatisticsVo.cityId}, '%')
- </if>
- <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
- and io.deptid like concat('%', #{taskStatisticsVo.countyId}, '%')
- </if>
- <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
- and io.deptid like concat('%', #{taskStatisticsVo.houseId}, '%')
- </if>
- <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
- AND io.createtime BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
- </if>
- <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
- AND iac.signing_time BETWEEN #{taskStatisticsVo.beginDate} AND #{taskStatisticsVo.endDate}
- </if>
- <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
- and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
- </if>
- <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
- AND io.deptid in
- <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
- AND io.userid in
- <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- </where>
- GROUP BY
- pa.insurance_company_id,
- pa.partner_companies_id
- ) total
- </select>
- <select id="agentStatisticsQueryPage" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
- SELECT
- sd.name as "deptName",
- su.name as "userName",
- io.userid as "userId",
- sd.id as "deptId",
- suLeader.name as "leaderName",
- COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS qutationCount,
- COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
- COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
- COUNT( CASE WHEN iac.orderstatus = 4 THEN 1 END ) AS underwritingReturn,
- (COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) +COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )) / COUNT(iac.orderstatus) as "passingRate",
- COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) / COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) as "closeRate",
- COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) / COUNT(iac.orderstatus) as "contributionRate",
- COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) / COUNT(iac.orderstatus) as "quotationRate",
- COUNT( CASE WHEN iac.orderstatus = 1 THEN 1 END ) as "auditOrder"
- FROM
- ins_area_company iac
- left join ins_orders io on io.orderno = iac.orderno
- left join sys_dept sd on sd.id=io.deptid
- left join sys_user su on su.id=io.userid
- left join sys_user suLeader on suLeader.id =su.leader_id
- <where>
- sd.management_source = '2'
- <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
- and io.deptid like "${taskStatisticsVo.provinceId}%"
- </if>
- <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
- and io.deptid like "${taskStatisticsVo.cityId}%"
- </if>
- <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
- and io.deptid like "${taskStatisticsVo.countyId}%"
- </if>
- <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
- and io.deptid like "${taskStatisticsVo.houseId}%"
- </if>
- <if test="taskStatisticsVo.userId !=null and taskStatisticsVo.userId!='' ">
- and io.userid =#{taskStatisticsVo.userId}
- </if>
- <if test='taskStatisticsVo.userName !=null and taskStatisticsVo.userName!="" '>
- and su.name like concat('%',#{taskStatisticsVo.userName},'%')
- </if>
- <if test='taskStatisticsVo.leaderId !=null and taskStatisticsVo.leaderId!="" '>
- and su.leader_id =#{taskStatisticsVo.leaderId}
- </if>
- <if test='taskStatisticsVo.userId !=null and taskStatisticsVo.userId!="" '>
- and su.id =#{taskStatisticsVo.userId}
- </if>
- <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
- AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
- </if>
- <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
- AND DATE_FORMAT( iac.signing_time, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
- </if>
- <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
- and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
- </if>
- <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
- AND sd.id in
- <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
- AND io.userid in
- <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
- <choose>
- <when test="taskStatisticsVo.days =='1'">
- and io.createtime >= DATE_SUB(NOW(), INTERVAL 1 DAY)
- </when>
- <when test="taskStatisticsVo.days =='7'">
- and io.createtime >= DATE_SUB(NOW(), INTERVAL 7 DAY)
- </when>
- <when test="taskStatisticsVo.days =='30'">
- and io.createtime >= DATE_SUB(NOW(), INTERVAL 30 DAY)
- </when>
- </choose>
- </if>
- </where>
- GROUP BY io.userid , su.name, sd.id , sd.name
- </select>
- <select id="agentStatisticsQueryPageTotal" resultType="java.lang.Long">
- select count(0) from (
- SELECT
- io.userid as "userId"
- FROM
- ins_area_company iac
- left join ins_orders io on io.orderno = iac.orderno
- left join sys_dept sd on sd.id=io.deptid
- left join sys_user su on su.id=io.userid
- <where>
- sd.management_source = '2'
- <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
- and io.deptid like "${taskStatisticsVo.provinceId}%"
- </if>
- <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
- and io.deptid like "${taskStatisticsVo.cityId}%"
- </if>
- <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
- and io.deptid like "${taskStatisticsVo.countyId}%"
- </if>
- <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
- and io.deptid like "${taskStatisticsVo.houseId}%"
- </if>
- <if test='taskStatisticsVo.userName !=null and taskStatisticsVo.userName!="" '>
- and su.name like concat('%',#{taskStatisticsVo.userName},'%')
- </if>
- <if test='taskStatisticsVo.leaderId !=null and taskStatisticsVo.leaderId!="" '>
- and su.leader_id =#{taskStatisticsVo.leaderId}
- </if>
- <if test='taskStatisticsVo.userId !=null and taskStatisticsVo.userId!="" '>
- and su.id =#{taskStatisticsVo.userId}
- </if>
- <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
- AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
- </if>
- <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
- AND DATE_FORMAT( iac.signing_time, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
- </if>
- <if test="taskStatisticsVo.userId !=null and taskStatisticsVo.userId!='' ">
- and io.userid =#{taskStatisticsVo.userId}
- </if>
- <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
- and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
- </if>
- <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
- <choose>
- <when test="taskStatisticsVo.days =='1'">
- and io.createtime >= DATE_SUB(NOW(), INTERVAL 1 DAY)
- </when>
- <when test="taskStatisticsVo.days =='7'">
- and io.createtime >= DATE_SUB(NOW(), INTERVAL 7 DAY)
- </when>
- <when test="taskStatisticsVo.days =='30'">
- and io.createtime >= DATE_SUB(NOW(), INTERVAL 30 DAY)
- </when>
- </choose>
- </if>
- </where>
- GROUP BY io.userid
- ) a
- </select>
- <select id="costCenter" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
- SELECT
- iac.company_id,
- iac.inscompany as "insuranceCompanyName",
- COUNT( CASE WHEN ifa.auditstatus = 1 THEN 1 END ) AS "auditstatusOrders",
- COUNT( CASE WHEN ifa.auditstatus = 0 THEN 1 END ) AS "auditOrder",
- COUNT( CASE WHEN ifa.auditstatus = 1 and ifa.audituser != '自动审核' THEN 1 END ) AS "persionAudit",
- COUNT( CASE WHEN ifa.audituser = '自动审核' THEN 1 END ) AS "automaticAudit"
- FROM
- ins_fee_audit ifa
- LEFT JOIN ins_orders io ON io.orderno = ifa.orderno
- LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
- AND iac.orderstatus = 3
- LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
- LEFT JOIN esm_ins_company eic ON eic.id = pa.partner_companies_id
- <where>
- 1=1
- and iac.id = ifa.ins_order_no
- AND iac.orderstatus = 3
- <if test="taskStatisticsVo.reviewer !=null and taskStatisticsVo.reviewer !=''">
- and ifa.audituser =#{taskStatisticsVo.reviewer}
- </if>
- <if test="taskStatisticsVo.audittime !=null and taskStatisticsVo.audittime !=''">
- and ifa.audittime =#{taskStatisticsVo.audittime}
- </if>
- <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId !=''">
- and iac.company_id =#{taskStatisticsVo.companyId}
- </if>
- <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
- AND DATE_FORMAT( ifa.audittime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.createtimeStart}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.createtimeEnd}, '%Y-%m-%d')
- </if>
- <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
- AND DATE_FORMAT( ifa.signing_time, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
- </if>
- <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
- AND io.deptid in
- <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
- AND su.id in
- <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <choose>
- <when test="taskStatisticsVo.riskCode != null and taskStatisticsVo.riskCode != '' and taskStatisticsVo.riskCode != 'all' ">
- and iac.product = #{taskStatisticsVo.riskCode}
- </when>
- </choose>
- </where>
- GROUP BY
- iac.company_id,
- iac.inscompany
- </select>
- <select id="getOrderManpower" resultType="com.ydtech.modules.admin.model.dto.QxFrontlineAgentDto">
- SELECT
- count( a.numberUserId ) as "orderManpower",
- sum( a.orderAmount ) as "totalPremium",
- sum( a.orderAmount )/ count( a.numberUserId ) as "averagePremium"
- FROM
- (
- SELECT
- count( io.userid ) AS "numberUserId",
- SUM(IFNULL(iac.jqpremium, 0)) +
- SUM(IFNULL(iac.sypremium, 0)) +
- SUM(IFNULL(iac.jypremium, 0)) AS "orderAmount"
- FROM
- `ins_area_company` iac
- LEFT JOIN ins_orders io ON io.orderno = iac.orderno
- <where>
- iac.orderstatus = '3'
- <if test="ids != null and ids.size()>0 ">
- AND io.userid IN
- <foreach item="item" collection="ids" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- </where>
- GROUP BY
- io.userid
- ) a
- </select>
- <select id="getOrderManpowerNew" resultType="com.ydtech.modules.admin.model.dto.QxFrontlineAgentDto">
- SELECT
- count( a.numberUserId ) as "orderManpower",
- IFNULL(sum( a.orderAmount ),0) as "totalPremium",
- ROUND(sum( a.orderAmount )/ sum(a.ordernoNumber),2) AS "averagePremium"
- FROM
- (
- SELECT
- count( io.userid ) AS "numberUserId",
- count( iac.orderno ) AS "ordernoNumber",
- SUM(IFNULL(iac.jqpremium, 0)
- +IFNULL(iac.sypremium, 0)
- +IFNULL(iac.jypremium, 0)
- ) AS "orderAmount"
- FROM
- `ins_area_company` iac
- LEFT JOIN ins_orders io ON io.orderno = iac.orderno
- <where>
- iac.orderstatus = '3'
- <if test="vo.ids != null and vo.ids.size()>0 ">
- AND io.userid IN
- <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
- AND iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
- </if>
- </where>
- GROUP BY
- io.userid
- ) a
- order by sum( a.orderAmount ) desc
- </select>
- <select id="getChannelOrderManpowerNew" resultType="com.ydtech.modules.admin.model.dto.QxFrontlineAgentDto">
- SELECT
- a.userId as "userId",
- a.userName as "name",
- a.orderNumber as "orderNumber",
- a.underwritingCount as "underwritingCount",
- a.qutationInsureCount as "qutationInsureCount",
- IFNULL(a.jqpremium,0) + IFNULL(a.sypremium,0) + IFNULL(a.jypremium,0) as "totalPremium",
- a.isFactorVerify as "isFactorVerify",
- a.isNotFactorVerify as "isNotFactorVerify"
- FROM
- (
- SELECT
- io.userid as "userId",
- io.username as "userName",
- count( iac.orderno ) AS "orderNumber",
- sum(CASE WHEN iac.orderstatus = 3 THEN iac.jqpremium END ) AS jqpremium,
- sum(CASE WHEN iac.orderstatus = 3 THEN iac.sypremium END ) AS sypremium,
- sum(CASE WHEN iac.orderstatus = 3 THEN iac.jypremium END ) AS jypremium,
- COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
- COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
- COUNT( CASE WHEN su.factor_verify = 1 THEN 1 END ) AS isFactorVerify,
- COUNT( CASE WHEN su.factor_verify = 0 THEN 1 END ) AS isNotFactorVerify
- FROM
- `ins_area_company` iac
- LEFT JOIN ins_orders io ON io.orderno = iac.orderno
- left join sys_user su on su.id=io.userid
- <where>
- <if test="vo.ids != null and vo.ids.size()>0 ">
- AND io.userid IN
- <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
- AND iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
- </if>
- <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
- AND iac.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
- </if>
- <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
- AND io.deptid in
- <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
- AND io.userid in
- <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- </where>
- GROUP BY
- io.userid,
- io.username
- ) a
- left join sys_user su on su.id=a.userId
- </select>
- <select id="NumberQuotations" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
- SELECT
- count(iac.id) as "orderNumber",
- COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
- COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
- sum( CASE WHEN iac.orderstatus = 3 THEN IFNULL(iac.jqpremium, 0) + IFNULL(iac.sypremium, 0) + IFNULL(iac.jypremium, 0) END ) AS totalPremium
- FROM
- ins_area_company iac
- left join ins_orders io on io.orderno = iac.orderno
- left join sys_dept sd on sd.id=io.deptid
- left join sys_user su on su.id=io.userid
- left join ins_fee_audit ifa on ifa .ins_order_no =iac.id
- <where>
- sd.management_source = '2'
- <if test="userId !=null and userId !=''">
- and io.userId =#{userId}
- </if>
- </where>
- </select>
- <select id="totalQuotation" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
- SELECT
- agree.insurance_company_id AS companyId,
- agree.insurance_company AS companyName,
- agree.partner_companies_id AS parterCompanyId,
- ins.namesimple AS parterCompanyName,
- count(iac.orderstatus) AS orderNumber,
- '-' as bigQutationCount,
- '-' as bigUnderwritingCount,
- '-' as bigCloseRate,
- COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
- COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
- COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END )/ count(iac.orderstatus) AS passRate,
- COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END )/ count(iac.orderstatus) AS underwritingCountRate,
- COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )/ count(iac.orderstatus) AS closeRate,
- COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )/ COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS
- contributionRate
- FROM
- ins_area_company iac
- LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
- LEFT JOIN ins_orders io on io.orderno = iac.orderno
- LEFT JOIN esm_ins_company ins ON agree.partner_companies_id = ins.id
- WHERE
- agree.id IS NOT NULL
- <if test="vo.companyId != null and vo.companyId!='' ">
- agree.insurance_company_id = #{vo.companyId}
- </if>
- <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
- agree.partner_companies_id = #{vo.parterCompanyId}
- </if>
- <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
- AND iac.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
- </if>
- <if test="vo.provinceId != null and vo.provinceId != ''">
- and io.deptid like "${vo.provinceId}%"
- </if>
- <if test="vo.cityId != null and vo.cityId != ''">
- and io.deptid like "${vo.cityId}%"
- </if>
- <if test="vo.countyId != null and vo.countyId != ''">
- and io.deptid like "${vo.countyId}%"
- </if>
- <if test="taskStatisticsVo.houseId != null and vo.houseId != ''">
- and io.deptid like "${vo.houseId}%"
- </if>
- GROUP BY
- agree.insurance_company_id,
- agree.insurance_company,
- agree.partner_companies_id,
- ins.NAME
- </select>
- <select id="getBusinessData" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
- select
- a.companyId as "companyId",
- a.insuranceCompanyName as "insuranceCompanyName",
- a.parterCompanyId as "parterCompanyId",
- a.partnerCompaniesName as "partnerCompaniesName",
- a.totalPremium as "totalPremium",
- a.qutationInsureCount as "qutationInsureCount",
- ROUND(a.averagePremium, 2) as "averagePremium",
- a.userNumber as "userNumber",
- ROUND(a.perCapitaAmount, 2) as "perCapitaAmount",
- c.docking_person as "dockingPerson",
- c.docking_phone as "dockingPhone",
- c.agreement_type as "agreementType",
- b.logo as "logo"
- from (
- SELECT
- agree.insurance_company_id AS "companyId",
- agree.insurance_company AS "insuranceCompanyName",
- agree.partner_companies_id AS "parterCompanyId",
- ins.namesimple AS "partnerCompaniesName",
- agree.id as "agreeId",
- IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0) as "totalPremium",
- COUNT(0 ) AS "qutationInsureCount",
- (IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0)) / COUNT(0 ) AS "averagePremium",
- COUNT(DISTINCT io.userId) AS "userNumber",
- (IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0)) / COUNT(DISTINCT io.userId) as "perCapitaAmount"
- FROM
- ins_area_company iac
- LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
- LEFT JOIN ins_orders io on io.orderno = iac.orderno
- LEFT JOIN esm_ins_company ins ON agree.partner_companies_id = ins.id
- WHERE
- agree.id IS NOT NULL
- and iac.orderstatus = '3'
- <if test="vo.companyId != null and vo.companyId!='' ">
- and agree.insurance_company_id = #{vo.companyId}
- </if>
- <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
- and agree.partner_companies_id = #{vo.parterCompanyId}
- </if>
- <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
- AND DATE_FORMAT( iac.signing_time, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{vo.createtimeStart}, '%Y-%m-%d') AND DATE_FORMAT( #{vo.createtimeEnd}, '%Y-%m-%d')
- </if>
- <if test="vo.provinceId != null and vo.provinceId != '' and vo.cityId == null and vo.countyId == null and vo.houseId == null ">
- and io.deptid like "${vo.provinceId}%"
- </if>
- <if test="vo.cityId != null and vo.cityId != '' and vo.countyId ==null and vo.houseId ==null">
- and io.deptid like "${vo.cityId}%"
- </if>
- <if test="vo.countyId != null and vo.countyId != '' and vo.houseId ==null">
- and io.deptid like "${vo.countyId}%"
- </if>
- <if test="vo.houseId != null and vo.houseId != ''">
- and io.deptid like "${vo.houseId}%"
- </if>
- <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
- AND io.deptid in
- <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
- AND io.userid in
- <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- GROUP BY
- agree.insurance_company_id,
- agree.insurance_company,
- agree.partner_companies_id,
- agree.id
- <choose>
- <when test="vo.orderSort != null and vo.orderSort != '' and vo.userNumberSort == null ">
- order by
- sum(sumpremium) ${vo.orderSort == 'asc' ? 'asc' : 'desc'}
- </when>
- <when test="vo.userNumberSort != null and vo.userNumberSort != '' and vo.orderSort == null ">
- order by
- COUNT(DISTINCT io.userId) ${vo.userNumberSort == 'asc' ? 'asc' : 'desc'}
- </when>
- <when test="vo.userNumberSort != null and vo.userNumberSort != '' and vo.orderSort != null and vo.orderSort != '' ">
- order by
- COUNT(DISTINCT io.userId) ${vo.userNumberSort == 'asc' ? 'asc' : 'desc'}, sum(sumpremium) ${vo.orderSort == 'asc' ? 'asc' : 'desc'}
- </when>
- </choose>
- ) a
- left join esm_ins_company b on b.id =a.companyId
- left join ptl_agreement c on c.id =a.agreeId
- </select>
- <select id="getDistribution" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
- SELECT
- agree.insurance_company_id AS "companyId",
- agree.insurance_company AS "insuranceCompanyName",
- agree.partner_companies_id AS "parterCompanyId",
- ins.namesimple AS "partnerCompaniesName",
- IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0) as "totalPremium",
- COUNT(0) AS "qutationInsureCount",
- ROUND((IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0)) / COUNT(0), 2) AS "averagePremium",
- COUNT(DISTINCT io.userId) AS "userNumber",
- ROUND((IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0)) / COUNT(DISTINCT io.userId) ,2) as "perCapitaAmount"
- FROM
- ins_area_company iac
- LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
- LEFT JOIN ins_orders io on io.orderno = iac.orderno
- LEFT JOIN esm_ins_company ins ON agree.partner_companies_id = ins.id
- WHERE
- agree.id IS NOT NULL
- <if test="vo.companyId != null and vo.companyId!='' ">
- and agree.insurance_company_id = #{vo.companyId}
- </if>
- <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
- and agree.partner_companies_id = #{vo.parterCompanyId}
- </if>
- <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
- AND DATE_FORMAT( iac.signing_time, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{vo.createtimeStart}, '%Y-%m-%d') AND DATE_FORMAT( #{vo.createtimeEnd}, '%Y-%m-%d')
- </if>
- <if test="vo.days !=null and vo.days !='' and vo.days != 0 ">
- and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{vo.days} DAY)
- </if>
- <if test="vo.provinceId != null and vo.provinceId != ''">
- and io.deptid like "${vo.provinceId}%"
- </if>
- <if test="vo.cityId != null and vo.cityId != ''">
- and io.deptid like "${vo.cityId}%"
- </if>
- <if test="vo.countyId != null and vo.countyId != ''">
- and io.deptid like "${vo.countyId}%"
- </if>
- <if test="vo.houseId != null and vo.houseId != ''">
- and io.deptid like "${vo.houseId}%"
- </if>
- <if test="vo.quotationStatus != null and vo.quotationStatus != ''">
- and iac.orderstatus =#{vo.quotationStatus}
- </if>
- <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
- AND io.deptid in
- <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
- AND io.userid in
- <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- GROUP BY
- agree.insurance_company_id,
- agree.insurance_company,
- agree.partner_companies_id,
- ins.namesimple
- </select>
- <select id="getOrderPremiumByUserIds" resultType="Double">
- SELECT
- IFNULL(
- SUM( IFNULL( iac.jqpremium, 0 ) + IFNULL( iac.sypremium, 0 ) + IFNULL( iac.jypremium, 0 ) ),
- 0
- ) AS "totalPremium"
- FROM
- `ins_area_company` iac
- LEFT JOIN ins_orders io ON io.orderno = iac.orderno
- <where>
- iac.orderstatus = '3'
- <if test="ids != null and ids.size()>0 ">
- AND io.userid IN
- <foreach item="item" collection="ids" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- </where>
- </select>
- <select id="querOrdersDataPage" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
- SELECT
- count( 0 ) AS "orderNumber",
- b.licenseno as "licenseno",
- b.frameno as "frameno",
- b.modelCode as "modelCode",
- b.modelcname as "modelcname"
- FROM
- (
- SELECT
- io.orderstatus AS orderstatus,
- io.frameno AS frameno,
- REPLACE(JSON_EXTRACT(io.carinfo, '$.engineNo'), '"', '') as "modelCode",
- REPLACE(JSON_EXTRACT(io.carinfo, '$.modelcname'), '"', '') as "modelcname",
- ifnull(io.licenseno, '') AS licenseno
- FROM
- ins_orders io
- LEFT JOIN sys_user su on io.userid=su.id
- <where>
- 1=1
- <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
- AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
- </if>
- <if test="vo.licenseno != null and vo.licenseno!='' ">
- AND io.licenseno =#{vo.licenseno}
- </if>
- <if test="vo.userId != null and vo.userId!='' ">
- AND io.userid =#{vo.userId}
- </if>
- <if test="vo.userName != null and vo.userName!='' ">
- AND su.name =#{vo.userName}
- </if>
- <if test="vo.mobile != null and vo.mobile!='' ">
- AND su.mobile =#{vo.mobile}
- </if>
- <if test="vo.frameno != null and vo.frameno!='' ">
- AND io.frameno =#{vo.frameno}
- </if>
- <if test="vo.deptId != null and vo.deptId!='' ">
- and io.deptid like concat('%', #{vo.deptId}, '%')
- </if>
- <if test="vo.year != null and vo.year!='' ">
- AND DATE_FORMAT( io.createtime, '%Y') =#{vo.year}
- </if>
- <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
- AND io.deptid in
- <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
- AND io.userid in
- <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- </where>
- ) b
- GROUP BY
- b.licenseno,
- b.frameno,
- b.modelCode,
- b.modelcname
- </select>
- <select id="getOrdersGroupByLicenseno" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
- SELECT
- io.licenseno AS "licenseno",
- io.frameno AS "frameno",
- io.orderstatus as "orderstatus",
- io.orderno as "orderno"
- FROM
- ins_orders io
- LEFT JOIN sys_user su on io.userid=su.id
- <where>
- io.licenseno is not null
- <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
- AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
- </if>
- <if test="vo.licenseno != null and vo.licenseno!='' ">
- AND io.licenseno =#{vo.licenseno}
- </if>
- <if test="vo.userId != null and vo.userId!='' ">
- AND io.userId =#{vo.userId}
- </if>
- <if test="vo.userName != null and vo.userName!='' ">
- AND su.name =#{vo.userName}
- </if>
- <if test="vo.mobile != null and vo.mobile!='' ">
- AND su.mobile =#{vo.mobile}
- </if>
- <if test="vo.frameno != null and vo.frameno!='' ">
- AND su.frameno =#{vo.frameno}
- </if>
- <if test="vo.deptId != null and vo.deptId!='' ">
- and io.deptid like concat('%', #{vo.deptId}, '%')
- </if>
- </where>
- </select>
- <select id="querOrdersamountTo" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
- select sum(a.orderNumber) as "orderNumber",
- count(a.licenseno) as "b.frameno"
- from (
- SELECT
- count( 0 ) AS "orderNumber",
- b.licenseno as "licenseno",
- b.frameno as "frameno"
- FROM
- (
- SELECT
- io.orderstatus AS orderstatus,
- io.frameno AS frameno,
- ifnull(io.licenseno, '') AS licenseno
- FROM
- ins_orders io
- LEFT JOIN sys_user su on io.userid=su.id
- <where>
- 1=1
- <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
- AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
- </if>
- <if test="vo.licenseno != null and vo.licenseno!='' ">
- AND io.licenseno =#{vo.licenseno}
- </if>
- <if test="vo.userId != null and vo.userId!='' ">
- AND io.userid =#{vo.userId}
- </if>
- <if test="vo.userName != null and vo.userName!='' ">
- AND su.name =#{vo.userName}
- </if>
- <if test="vo.mobile != null and vo.mobile!='' ">
- AND su.mobile =#{vo.mobile}
- </if>
- <if test="vo.frameno != null and vo.frameno!='' ">
- AND io.frameno =#{vo.frameno}
- </if>
- <if test="vo.deptId != null and vo.deptId!='' ">
- and io.deptid like concat('%', #{vo.deptId}, '%')
- </if>
- </where>
- ) b
- GROUP BY
- b.licenseno,
- b.frameno
- ) a
- </select>
- <select id="querResultOrderNumber" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
- SELECT
- count( io.orderno ) AS "orderNumber",
- IFNULL(count(CASE WHEN io.orderstatus = '3' THEN 1 ELSE 0 END),0) / (IFNULL(count(CASE WHEN io.orderstatus = '2' THEN 1 ELSE 0 END),0) + IFNULL(count(CASE WHEN io.orderstatus = '3' THEN 1 ELSE 0 END),0)) AS "closeRate"
- FROM
- ins_orders io
- LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
- LEFT JOIN sys_user su ON io.userid = su.id
- <where>
- 1=1
- <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
- AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
- </if>
- <if test="vo.licenseno != null and vo.licenseno!='' ">
- AND io.licenseno =#{vo.licenseno}
- </if>
- <if test="vo.userId != null and vo.userId!='' ">
- AND io.userid =#{vo.userId}
- </if>
- <if test="vo.userName != null and vo.userName!='' ">
- AND su.name =#{vo.userName}
- </if>
- <if test="vo.mobile != null and vo.mobile!='' ">
- AND su.mobile =#{vo.mobile}
- </if>
- <if test="vo.frameno != null and vo.frameno!='' ">
- AND su.frameno =#{vo.frameno}
- </if>
- <if test="vo.deptId != null and vo.deptId!='' ">
- and io.deptid like concat('%', #{vo.deptId}, '%')
- </if>
- </where>
- </select>
- <select id="numberQuotationsByUserIds" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
- SELECT
- count(iac.id) as "orderNumber",
- COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
- COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
- sum( CASE WHEN iac.orderstatus = 3 THEN IFNULL(iac.jqpremium, 0) + IFNULL(iac.sypremium, 0) + IFNULL(iac.jypremium, 0) END ) AS totalPremium
- FROM
- ins_area_company iac
- left join ins_orders io on io.orderno = iac.orderno
- <where>
- <if test="ids != null and ids.size()>0 ">
- AND io.userid IN
- <foreach item="item" collection="ids" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="month != null and month!='' ">
- AND DATE_FORMAT(iac.createtime, '%Y-%m') =#{month}
- </if>
- </where>
- </select>
- <select id="selectByOrdersDataVo" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
- select
- iac.inscompany as "namesimple"
- from
- ins_area_company iac
- <where>
- 1=1
- <if test="vo.orderstatus != null and vo.orderstatus != '' ">
- AND iac.orderstatus =#{vo.orderstatus}
- </if>
- <if test="vo.orderno !=null and vo.orderno !='' ">
- AND iac.orderno =#{vo.orderno}
- </if>
- </where>
- </select>
- <select id="channelExcel" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsExcel">
- select a.*,(select name from sys_user where id =a.userId) as "userName"
- from (
- SELECT
- sd.NAME AS "deptName",
- io.userid AS "userId",
- sd.parent_id as "deptId",
- COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS qutationCount,
- COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
- COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
- COUNT( CASE WHEN iac.orderstatus = 4 THEN 1 END ) AS underwritingReturn,
- (COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) / COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END )) * 100 AS "passingRate",
- (COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) / COUNT( iac.orderstatus )) * 100 AS "closeRate",
- ((COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) + COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ))/ COUNT( iac.orderstatus )) * 100 AS "contributionRate",
- (COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) / COUNT( iac.orderstatus )) * 100 AS "quotationRate",
- COUNT( CASE WHEN iac.orderstatus = 1 THEN 1 END ) AS "auditOrder"
- FROM
- ins_area_company iac
- LEFT JOIN ins_orders io ON io.orderno = iac.orderno
- LEFT JOIN sys_dept sd ON sd.id = io.deptid
- <where>
- 1=1
- <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
- and io.deptid like "${taskStatisticsVo.provinceId}%"
- </if>
- <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
- and io.deptid like "${taskStatisticsVo.cityId}%"
- </if>
- <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
- and io.deptid like "${taskStatisticsVo.countyId}%"
- </if>
- <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
- and io.deptid like "${taskStatisticsVo.houseId}%"
- </if>
- <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
- AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
- </if>
- <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
- AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
- </if>
- <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
- and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
- </if>
- <if test="taskStatisticsVo.managementSource!=null and taskStatisticsVo.managementSource!=''">
- and sd.management_source=#{taskStatisticsVo.managementSource}
- </if>
- <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
- <choose>
- <when test="taskStatisticsVo.days =='1'">
- and io.createtime >= DATE_SUB(NOW(), INTERVAL 1 DAY)
- </when>
- <when test="taskStatisticsVo.days =='7'">
- and io.createtime >= DATE_SUB(NOW(), INTERVAL 7 DAY)
- </when>
- <when test="taskStatisticsVo.days =='30'">
- and io.createtime >= DATE_SUB(NOW(), INTERVAL 30 DAY)
- </when>
- </choose>
- </if>
- </where>
- GROUP BY
- io.userid,
- sd.NAME,
- sd.id
- ) a
- </select>
- <select id="insuranceCompanyExcel" resultType="com.ydtech.modules.admin.model.dto.InsuranceCompanyExcel">
- SELECT
- a.*,
- ( SELECT eic.namesimple FROM esm_ins_company eic WHERE eic.id = a.partner_companies_id ) AS "partnerCompaniesName"
- FROM
- (
- SELECT
- pa.insurance_company_id,
- pa.partner_companies_id,
- pa.insurance_company AS "insuranceCompanyName",
- COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS qutationCount,
- COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCountRate,
- COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
- COUNT( CASE WHEN iac.orderstatus = 4 THEN 1 END ) AS underwritingReturn,
- COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) / COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS "passingRate",
- COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) / COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS "closeRate",
- COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) / COUNT( iac.orderstatus ) AS "contributionRate",
- COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) / COUNT( iac.orderstatus ) AS "quotationRate",
- COUNT( CASE WHEN ifa.auditstatus = 1 THEN 1 END ) AS "auditOrder"
- FROM
- ins_area_company iac
- LEFT JOIN ins_fee_audit ifa ON ifa.ins_order_no = iac.id
- LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
- <where>
- pa.insurance_company_id IS NOT NULL
- <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
- and io.deptid like "${taskStatisticsVo.provinceId}%"
- </if>
- <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
- and io.deptid like "${taskStatisticsVo.cityId}%"
- </if>
- <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
- and io.deptid like "${taskStatisticsVo.countyId}%"
- </if>
- <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
- and io.deptid like "${taskStatisticsVo.houseId}%"
- </if>
- <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
- AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
- </if>
- <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
- AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
- </if>
- <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId != ''">
- AND iac.company_id =#{taskStatisticsVo.companyId}
- </if>
- <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
- and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
- </if>
- </where>
- GROUP BY
- pa.insurance_company_id,
- pa.partner_companies_id,
- pa.insurance_company
- ) a
- </select>
- <select id="getSumBigOrderCount" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
- select count(0) as "orderNumber",
- GROUP_CONCAT(inscompany ORDER BY inscompany SEPARATOR ',') as "namesimple"
- from ins_area_company iac
- left join ins_orders io on io.orderno = iac.orderno
- <where>
- 1=1
- and iac.orderstatus ='3'
- and io.orderstatus ='3'
- <if test="vo.licenseno !=null and vo.licenseno!=''">
- AND io.licenseno =#{vo.licenseno}
- </if>
- <if test="vo.frameno !=null and vo.frameno!=''">
- AND io.frameno =#{vo.frameno}
- </if>
- <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
- AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
- </if>
- <if test="vo.year != null and vo.year!='' ">
- AND DATE_FORMAT( io.createtime, '%Y') =#{vo.year}
- </if>
- </where>
- limit 10
- </select>
- <select id="queryAgencyUserInsAreaPage" resultType="com.ydtech.modules.admin.model.vo.AgencyUserInsAreaVo">
- select
- io.userid as userId,
- io.username as userName,
- io.licenseno as licenseno,
- iac.id as companyId,
- iac.jqpremium as jqpremium,
- iac.sypremium as sypremium,
- iac.jypremium as jypremium,
- iac.createtime as createtime,
- iac.orderstatus as orderstatus
- from ins_area_company iac
- left join ins_orders io on io.orderno = iac.orderno
- <where>
- iac.orderstatus=3
- <if test="dto.userId !=null and dto.userId !=''">
- and io.userid = #{dto.userId}
- </if>
- <if test="dto.deptId !=null and dto.deptId !=''">
- and io.deptid like concat( #{dto.deptId}, '%')
- </if>
- <if test="dto.startTime !=null and dto.startTime !=''">
- and io.createtime >= #{dto.startTime}
- </if>
- </where>
- ORDER BY iac.createtime
- </select>
- <select id="querOrdersDataListExcel" resultType="com.ydtech.modules.admin.model.dto.OrdersDataExcel">
- SELECT
- count( 0 ) AS "orderNumber",
- b.licenseno as "licenseno",
- b.frameno as "frameno",
- b.modelCode as "modelCode",
- b.modelcname as "modelcname"
- FROM
- (
- SELECT
- io.orderstatus AS orderstatus,
- io.frameno AS frameno,
- REPLACE(JSON_EXTRACT(io.carinfo, '$.engineNo'), '"', '') as "modelCode",
- REPLACE(JSON_EXTRACT(io.carinfo, '$.modelcname'), '"', '') as "modelcname",
- ifnull(io.licenseno, '') AS licenseno
- FROM
- ins_orders io
- LEFT JOIN sys_user su on io.userid=su.id
- <where>
- 1=1
- <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
- AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
- </if>
- <if test="vo.licenseno != null and vo.licenseno!='' ">
- AND io.licenseno =#{vo.licenseno}
- </if>
- <if test="vo.userId != null and vo.userId!='' ">
- AND io.userid =#{vo.userId}
- </if>
- <if test="vo.userName != null and vo.userName!='' ">
- AND su.name =#{vo.userName}
- </if>
- <if test="vo.mobile != null and vo.mobile!='' ">
- AND su.mobile =#{vo.mobile}
- </if>
- <if test="vo.frameno != null and vo.frameno!='' ">
- AND io.frameno =#{vo.frameno}
- </if>
- <if test="vo.deptId != null and vo.deptId!='' ">
- and io.deptid like concat('%', #{vo.deptId}, '%')
- </if>
- <if test="vo.year != null and vo.year!='' ">
- AND DATE_FORMAT( io.createtime, '%Y') =#{vo.year}
- </if>
- <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
- AND io.deptid in
- <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
- AND io.userid in
- <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- </where>
- ) b
- GROUP BY
- b.licenseno,
- b.frameno,
- b.modelCode,
- b.modelcname
- </select>
- <select id="orderCheckPage" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
- select
- iac.id,
- iac.orderno,
- iac.agreement_id,
- iac.jqpremium,
- iac.sypremium,
- iac.jypremium,
- iac.taxamount,
- iac.sumpremium,
- io.licenseno,
- iac.createtime,
- su.name as auditname
- FROM
- ins_area_company iac
- LEFT JOIN
- ins_orders io on iac.orderno = io.orderno
- left join ptl_agreement agree on iac.agreement_id =agree.id
- left join ins_fee_audit ifa on iac.id = ifa.ins_order_no
- left join sys_user su on su.id= ifa.audituser
- WHERE
- iac.operator_id = #{userId}
- AND
- iac.orderstatus = 3
- and agree.is_external =1
- and auditstatus =1
- <if test="vo.id != null and vo.id!='' ">
- and iac.id = #{vo.id}
- </if>
- <if test="vo.licenseno != null and vo.licenseno!='' ">
- and io.licenseno like CONCAT('%', #{vo.licenseno}, '%')
- </if>
- </select>
- <select id="costCenterTotal" resultType="java.util.HashMap">
- SELECT
- COUNT( CASE WHEN ifa.auditstatus = 1 THEN 1 END ) AS "allAuditstatusOrders",
- COUNT( CASE WHEN ifa.auditstatus = 0 THEN 1 END ) AS "allAuditOrder",
- COUNT( CASE WHEN ifa.auditstatus = 1 and ifa.audituser != '自动审核' THEN 1 END ) AS "allPersionAudit",
- COUNT( CASE WHEN ifa.audituser = '自动审核' THEN 1 END ) AS "allAutomaticAudit"
- FROM
- ins_fee_audit ifa
- LEFT JOIN ins_orders io ON io.orderno = ifa.orderno
- LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
- AND iac.orderstatus = 3
- LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
- LEFT JOIN esm_ins_company eic ON eic.id = pa.partner_companies_id
- <where>
- 1=1
- and iac.id = ifa.ins_order_no
- AND iac.orderstatus = 3
- <if test="taskStatisticsVo.reviewer !=null and taskStatisticsVo.reviewer !=''">
- and ifa.audituser =#{taskStatisticsVo.reviewer}
- </if>
- <if test="taskStatisticsVo.audittime !=null and taskStatisticsVo.audittime !=''">
- and ifa.audittime =#{taskStatisticsVo.audittime}
- </if>
- <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId !=''">
- and iac.company_id =#{taskStatisticsVo.companyId}
- </if>
- <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
- AND DATE_FORMAT( ifa.audittime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.createtimeStart}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.createtimeEnd}, '%Y-%m-%d')
- </if>
- <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
- AND DATE_FORMAT( ifa.signing_time, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
- </if>
- <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
- AND io.deptid in
- <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
- AND su.id in
- <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <choose>
- <when test="taskStatisticsVo.riskCode != null and taskStatisticsVo.riskCode != '' and taskStatisticsVo.riskCode != 'all' ">
- and iac.product = #{taskStatisticsVo.riskCode}
- </when>
- </choose>
- </where>
- </select>
- <select id="getSubOrderCountDTO" resultType="com.ydtech.modules.order.entity.dto.SubOrderCountDTO">
- select orderno, orderstatus, count(*)as count
- from (select orderno, company_id, orderstatus
- from ins_area_company
- where orderno in
- <foreach collection="orderNo" open="(" separator="," close=")" item="item" index="index">
- #{item,jdbcType=VARCHAR}
- </foreach>
- and del_flag = '1'
- group by orderno, company_id, orderstatus) as iac
- group by orderno, orderstatus
- </select>
- <select id="getAllRejectOrders" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
- select
- iac.id,
- iac.orderno,
- iac.agreement_id,
- iac.jqpremium,
- iac.sypremium,
- iac.jypremium,
- iac.taxamount,
- iac.sumpremium,
- io.licenseno,
- ifa.audittime,
- ifa.audituser as auditname,
- ifa.rejectinfo,
- "1" as orderExternalStatus
- FROM
- ins_fee_audit ifa
- LEFT JOIN
- ins_area_company iac on iac.id = ifa.ins_order_no
- LEFT JOIN
- ins_orders io on iac.orderno = io.orderno
- left join
- sys_user su on su.id= ifa.audituser
- WHERE
- ifa.auditstatus = 2 and IFNULL(iac.del_flag,'') != '0'
- <if test="vo.id != null and vo.id!=''">
- and iac.id = #{vo.id}
- </if>
- <if test="vo.licenseno != null and vo.licenseno!='' ">
- and io.licenseno like CONCAT('%', #{vo.licenseno}, '%')
- </if>
- <if test="vo.auditname != null and vo.auditname!='' ">
- and su.name like CONCAT('%', #{vo.auditname}, '%')
- </if>
- order by io.createtime
- </select>
- </mapper>
|