| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107 |
- <?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"/>
- <result property="feeMatchErrMsg" column="fee_match_err_msg" jdbcType="VARCHAR"/>
- <result property="quoteErrMsg" column="quote_err_msg" 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.size > 0">
- and sd.management_source in
- <foreach item="source" collection="params.managementSource" open="(" separator="," close=")">
- #{source}
- </foreach>
- </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>
- <if test="excludeKeys != null and excludeKeys.size() > 0">
- and iac.id not in
- <foreach item="key" collection="excludeKeys" open="(" separator="," close=")">
- #{key}
- </foreach>
- </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
- 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 allNumber,
- count( CASE WHEN iac.orderstatus != '10' THEN 1 END ) AS orderSuccessNumber,
- count( CASE WHEN iac.orderstatus != '10' THEN 1 END ) / count( iac.id ) as "orderSuccessNumberRate",
- count( CASE WHEN iac.orderstatus = '10' THEN 1 END ) AS areaCompanyErrNumber,
- 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
- and (iac.del_flag = '1' or io.del_flag IS NULL or io.del_flag = 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.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.signingTimeStart !=null and vo.signingTimeStart != '' and vo.signingTimeEnd !=null and vo.signingTimeEnd != ''">
- AND iac.signing_time BETWEEN #{vo.signingTimeStart} AND #{vo.signingTimeEnd}
- </if>
- <if test="vo.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 iac.leader_id in
- <foreach collection="vo.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="quotationDetailsExcel" resultType="com.ydtech.modules.admin.model.dto.QuotationDetailsExcel">
- select
- iac.id as "orderno",
- io.orderno as "bigOrderno",
- iac.agreement_id as "agreementId",
- iac.orderstatus as "orderstatus",
- iac.company_id as "companyId",
- agree.partner_companies_id as "partnerCompaniesId",
- ins.namesimple as "partnerCompaniesName",
- agree.insurance_company as "inscompany",
- iac.jqpolicyno as "jqpolicyno",
- iac.sypolicyno as "sypolicyno",
- iac.sumpremium as "sumpremium",
- iac.jqpremium as "jqpremium",
- iac.sypremium as "sypremium",
- iac.jypremium as "jypremium",
- iac.createtime as "createtime",
- iac.signing_time as "signingTime",
- sd.management_source as "managementSource",
- agree.audit_type as "auditType",
- ifa.auditstatus as "auditstatus",
- io.licenseno as "licenseno",
- su1.name as "userName",
- su1.leader_name as "leaderName"
- 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_user su1 on su1.id=io.userid
- LEFT JOIN sys_dept sd ON sd.id = io.deptid
- LEFT JOIN ins_fee_audit ifa on ifa.ins_order_no = iac.id
- LEFT JOIN esm_ins_company ins ON agree.partner_companies_id = ins.id
- <where>
- agree.id IS NOT NULL
- and (iac.del_flag = '1' or io.del_flag IS NULL or io.del_flag = 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.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>
- </where>
- </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.deptId != null and vo.deptId !=''">
- AND iace.dept_id like concat('%',#{vo.deptId},'%')
- </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
- and (iac.del_flag = '1' or io.del_flag IS NULL or io.del_flag = 1)
- <if test="vo.companyId != null and vo.companyId!='' ">
- AND agree.insurance_company_id = #{vo.companyId}
- </if>
- <if test="vo.signingTimeStart !=null and vo.signingTimeStart != '' and vo.signingTimeEnd !=null and vo.signingTimeEnd != ''">
- AND DATE_FORMAT( iac.signing_time, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{vo.signingTimeStart}, '%Y-%m-%d') AND
- DATE_FORMAT( #{vo.signingTimeEnd}, '%Y-%m-%d')
- </if>
- <if test="vo.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="vo.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
- AND
- io.del_flag is null
- <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",
- su2.mobile as "leaderMobile"
- from (
- SELECT
- sd.NAME AS "deptName",
- io.userid AS "userId",
- sd.parent_id as "deptId",
- sd.management_source as "managementSource",
- COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS qutationCount,
- COUNT( CASE WHEN iot.order_status ='2' THEN 1 END ) AS underwritingCount,
- COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) AS qutationInsureCount,
- COUNT( CASE WHEN iot.order_status = '4' THEN 1 END ) AS underwritingReturn,
- COUNT( CASE WHEN iot.order_status ='2' THEN 1 END ) / COUNT( CASE WHEN iot.order_status ='0' THEN 1 END ) AS
- "passingRate",
- COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) / COUNT( CASE WHEN iot.order_status in
- ('0','1','2','3','4') THEN 1 END ) AS "closeRate",
- (COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) + COUNT( CASE WHEN iot.order_status = '2' THEN 1 END ))/
- COUNT(CASE WHEN iot.order_status in ('0','1','2','3','4') THEN 1 END) AS "contributionRate",
- COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) / COUNT(CASE WHEN iot.order_status in ('0','1','2','3','4')
- THEN 1 END ) AS "quotationRate",
- COUNT(CASE WHEN io.order_source = 0 and iot.order_status ='0' THEN 1 END) as "pcOrderSource",
- COUNT(CASE WHEN io.order_source = 1 and iot.order_status ='0' THEN 1 END) as "appOrderSource",
- COUNT(CASE WHEN iac.entry_status = '2' THEN 1 END) as "sumEntryStatus",
- COUNT( CASE WHEN iot.order_status = '1' THEN 1 END ) AS "auditOrder"
- FROM
- (
- select iot.suborder,iot.order_status from `ins_orders_track` iot
- left join ins_area_company iac ON iac.id = iot.suborder
- where true
- <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
- AND iac.createtime BETWEEN #{taskStatisticsVo.beginDate} AND #{taskStatisticsVo.endDate}
- </if>
- <if test="taskStatisticsVo.signingTimeStart !=null and taskStatisticsVo.signingTimeStart != '' and taskStatisticsVo.signingTimeEnd !=null and taskStatisticsVo.signingTimeEnd != ''">
- AND iac.signing_time BETWEEN #{taskStatisticsVo.signingTimeStart} AND #{taskStatisticsVo.signingTimeEnd},
- </if>
- GROUP BY iot.suborder ,iot.order_status
- ) iot
- left join ins_area_company iac ON iac.id = iot.suborder
- 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'
- and (iac.del_flag = '1' or io.del_flag IS NULL or io.del_flag = 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 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.createtime BETWEEN #{taskStatisticsVo.beginDate} AND #{taskStatisticsVo.endDate}
- </if>
- <if test="taskStatisticsVo.signingTimeStart !=null and taskStatisticsVo.signingTimeStart != '' and taskStatisticsVo.signingTimeEnd !=null and taskStatisticsVo.signingTimeEnd != ''">
- AND iac.signing_time BETWEEN #{taskStatisticsVo.signingTimeStart} AND
- #{taskStatisticsVo.signingTimeEnd},
- </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>
- </where>
- GROUP BY
- io.userid,
- sd.NAME,
- sd.id,
- sd.management_source
- ) 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
- LEFT JOIN sys_user su2 on su2.id =su.leader_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.leaderIds != null and taskStatisticsVo.leaderIds != '' and taskStatisticsVo.leaderIds.size() > 0">
- AND su.leader_id in
- <foreach collection="taskStatisticsVo.leaderIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test='taskStatisticsVo.userId !=null and taskStatisticsVo.userId!="" '>
- and su.id =#{taskStatisticsVo.userId}
- </if>
- </where>
- </select>
- <select id="queryPageElectric" 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",
- su2.mobile as "leaderMobile"
- from (
- SELECT
- sd.NAME AS "deptName",
- io.userid AS "userId",
- sd.parent_id as "deptId",
- sd.management_source as "managementSource",
- COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS qutationCount,
- COUNT( CASE WHEN iot.order_status ='2' THEN 1 END ) AS underwritingCount,
- COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) AS qutationInsureCount,
- COUNT( CASE WHEN iot.order_status = '4' THEN 1 END ) AS underwritingReturn,
- COUNT( CASE WHEN iot.order_status = '2' THEN 1 END ) / COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS
- "passingRate",
- COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) / COUNT( CASE WHEN iot.order_status in
- ('0','1','2','3','4') THEN 1 END) AS "closeRate",
- (COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) + COUNT( CASE WHEN iot.order_status = '2' THEN 1 END ))/
- COUNT(CASE WHEN iot.order_status in ('0','1','2','3','4') THEN 1 END) AS "contributionRate",
- COUNT( CASE WHEN iot.order_status ='0' THEN 1 END ) / COUNT(CASE WHEN iot.order_status in ('0','1','2','3','4')
- THEN 1 END ) AS "quotationRate",
- COUNT(CASE WHEN io.order_source = 0 and iot.order_status = '0' THEN 1 END) as "pcOrderSource",
- COUNT(CASE WHEN io.order_source = 1 and iot.order_status = '0' THEN 1 END) as "appOrderSource",
- COUNT( CASE WHEN iot.order_status ='1' THEN 1 END ) AS "auditOrder"
- FROM
- (
- select iot.suborder,iot.order_status from `ins_orders_track` iot
- left join ins_area_company iac ON iac.id = iot.suborder
- where true
- <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
- AND iac.createtime BETWEEN #{taskStatisticsVo.beginDate} AND #{taskStatisticsVo.endDate}
- </if>
- <if test="taskStatisticsVo.signingTimeStart !=null and taskStatisticsVo.signingTimeStart != '' and taskStatisticsVo.signingTimeEnd !=null and taskStatisticsVo.signingTimeEnd != ''">
- AND iac.signing_time BETWEEN #{taskStatisticsVo.signingTimeStart} AND #{taskStatisticsVo.signingTimeEnd},
- </if>
- GROUP BY iot.suborder ,iot.order_status
- ) iot
- left join ins_area_company iac ON iac.id = iot.suborder
- LEFT JOIN ins_orders io ON io.orderno = iac.orderno
- LEFT JOIN sys_dept sd ON sd.id = io.deptid
- <where>
- sd.management_source = '3'
- and (iac.del_flag = '1' or io.del_flag IS NULL or io.del_flag = 1)
- <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
- and io.deptid like "${taskStatisticsVo.provinceId}%"
- </if>
- <if test="taskStatisticsVo.signingTimeStart !=null and taskStatisticsVo.signingTimeStart != '' and taskStatisticsVo.signingTimeEnd !=null and taskStatisticsVo.signingTimeEnd != ''">
- iac.signing_time BETWEEN #{taskStatisticsVo.signingTimeStart} AND #{taskStatisticsVo.signingTimeEnd}
- </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 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.createtime BETWEEN #{taskStatisticsVo.beginDate} AND #{taskStatisticsVo.endDate}
- </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>
- </where>
- GROUP BY
- io.userid,
- sd.NAME,
- sd.id,
- sd.management_source
- ) 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
- LEFT JOIN sys_user su2 on su2.id =su.leader_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.leaderIds != null and taskStatisticsVo.leaderIds != '' and taskStatisticsVo.leaderIds.size() > 0">
- AND su.leader_id in
- <foreach collection="taskStatisticsVo.leaderIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test='taskStatisticsVo.userId !=null and taskStatisticsVo.userId!="" '>
- and su.id =#{taskStatisticsVo.userId}
- </if>
- </where>
- </select>
- <select id="queryPageElectricTotal" 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 = '3'
- <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.leaderIds != null and taskStatisticsVo.leaderIds != '' and taskStatisticsVo.leaderIds.size() > 0">
- AND su.leader_id in
- <foreach collection="taskStatisticsVo.leaderIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="taskStatisticsVo.signingTimeStart !=null and taskStatisticsVo.signingTimeStart != '' and taskStatisticsVo.signingTimeEnd !=null and taskStatisticsVo.signingTimeEnd != ''">
- AND iac.signing_time BETWEEN #{taskStatisticsVo.signingTimeStart} AND #{taskStatisticsVo.signingTimeEnd}
- </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.createtime BETWEEN #{taskStatisticsVo.beginDate} AND #{taskStatisticsVo.endDate}
- </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>
- </where>
- GROUP BY
- io.userid
- ) a
- </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
- left join sys_user su on su.id = io.userid
- <where>
- sd.management_source = '1'
- and (iac.del_flag = '1' or io.del_flag IS NULL or io.del_flag = 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.signingTimeStart !=null and taskStatisticsVo.signingTimeStart != '' and taskStatisticsVo.signingTimeEnd !=null and taskStatisticsVo.signingTimeEnd != ''">
- AND iac.signing_time BETWEEN #{taskStatisticsVo.signingTimeStart} AND #{taskStatisticsVo.signingTimeEnd}
- </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.createtime BETWEEN #{taskStatisticsVo.beginDate} AND #{taskStatisticsVo.endDate}
- </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.leaderIds != null and taskStatisticsVo.leaderIds != '' and taskStatisticsVo.leaderIds.size() > 0">
- AND su.leader_id in
- <foreach collection="taskStatisticsVo.leaderIds" 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
- 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 iot.order_status = '0' THEN 1 END ) AS qutationCount,
- COUNT( CASE WHEN iot.order_status = '1' THEN 1 END ) AS "auditOrder",
- COUNT( CASE WHEN iot.order_status = '2' THEN 1 END ) AS underwritingCount,
- COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) AS qutationInsureCount,
- COUNT( CASE WHEN iot.order_status = '4' THEN 1 END ) AS underwritingReturn,
- COUNT( CASE WHEN iot.order_status ='2' THEN 1 END ) / COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS
- "passingRate",
- COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) / COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS
- "closeRate",
- (COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) + COUNT( CASE WHEN iot.order_status = '2' THEN 1 END )) /
- COUNT( iot.order_status ) AS "contributionRate",
- COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) / COUNT( iot.order_status ) AS "quotationRate"
- FROM
- (
- select iot.suborder,iot.order_status from `ins_orders_track` iot
- left join ins_area_company iac ON iac.id = iot.suborder
- where true
- <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
- AND iac.createtime BETWEEN #{taskStatisticsVo.beginDate} AND #{taskStatisticsVo.endDate}
- </if>
- <if test="taskStatisticsVo.signingTimeStart !=null and taskStatisticsVo.signingTimeStart != '' and taskStatisticsVo.signingTimeEnd !=null and taskStatisticsVo.signingTimeEnd != ''">
- AND iac.signing_time BETWEEN #{taskStatisticsVo.signingTimeStart} AND #{taskStatisticsVo.signingTimeEnd},
- </if>
- GROUP BY iot.suborder ,iot.order_status
- ) iot
- LEFT JOIN ins_area_company iac ON iac.id = iot.suborder
- 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
- and (iac.del_flag = '1' or io.del_flag IS NULL or io.del_flag = 1)
- <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 iac.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.createtime BETWEEN #{taskStatisticsVo.beginDate} AND #{taskStatisticsVo.endDate}
- </if>
- <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId != ''">
- AND iac.company_id =#{taskStatisticsVo.companyId}
- </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
- and (iac.del_flag = '1' or io.del_flag IS NULL or io.del_flag = 1)
- <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.companyId !=null and taskStatisticsVo.companyId != ''">
- AND iac.company_id =#{taskStatisticsVo.companyId}
- </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 iac.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.createtime BETWEEN #{taskStatisticsVo.beginDate} AND #{taskStatisticsVo.endDate}
- </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",
- suLeader.mobile AS "leaderMobile",
- sd.management_source AS "managementSource",
- COUNT(CASE WHEN iot.order_status = '0' THEN 1 END) AS qutationCount,
- COUNT(CASE WHEN iot.order_status = '2' THEN 1 END) AS underwritingCount,
- COUNT(CASE WHEN iot.order_status = '3' THEN 1 END) AS qutationInsureCount,
- COUNT(CASE WHEN iot.order_status = '4' THEN 1 END) AS underwritingReturn,
- COUNT(CASE WHEN iot.order_status = '2' THEN 1 END) / COUNT(CASE WHEN iot.order_status IN ('0', '1', '2', '3',
- '4') THEN 1 END) AS "passingRate",
- COUNT(CASE WHEN iot.order_status = '3' THEN 1 END) / COUNT(CASE WHEN iot.order_status = '0' THEN 1 END) AS
- "closeRate",
- COUNT(CASE WHEN iot.order_status = '3' THEN 1 END) / COUNT(CASE WHEN iot.order_status IN ('0', '1', '2', '3',
- '4') THEN 1 END) AS "contributionRate",
- COUNT(CASE WHEN iot.order_status = '0' THEN 1 END) / COUNT(CASE WHEN iot.order_status IN ('0', '1', '2', '3',
- '4') THEN 1 END) AS "quotationRate",
- COUNT(CASE WHEN iot.order_status = '1' THEN 1 END) AS "auditOrder"
- FROM
- (
- SELECT iot.suborder, iot.order_status
- FROM ins_orders_track iot
- LEFT JOIN ins_area_company iac ON iac.id = iot.suborder
- 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'
- AND (iac.del_flag = '1' OR io.del_flag IS NULL OR io.del_flag = 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.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.leaderIds != null and taskStatisticsVo.leaderIds != '' and taskStatisticsVo.leaderIds.size() > 0">
- AND su.leader_id IN
- <foreach collection="taskStatisticsVo.leaderIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </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.createtime BETWEEN #{taskStatisticsVo.beginDate} AND #{taskStatisticsVo.endDate}
- </if>
- <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
- AND sd.id in ( select dept_id from sys_user_dept_relationship where user_id
- =#{taskStatisticsVo.relationUserId} )
- </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>
- GROUP BY iot.suborder, iot.order_status
- ) iot
- LEFT JOIN ins_area_company iac ON iac.id = iot.suborder
- 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
- GROUP BY io.userid, su.name, sd.id, sd.name, suLeader.name, suLeader.mobile, sd.management_source
- </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'
- and (iac.del_flag = '1' or io.del_flag IS NULL or io.del_flag = 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.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.leaderIds != null and taskStatisticsVo.leaderIds != '' and taskStatisticsVo.leaderIds.size() > 0">
- AND su.leader_id in
- <foreach collection="taskStatisticsVo.leaderIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </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 != ''">
- 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.createtime BETWEEN #{taskStatisticsVo.beginDate} AND #{taskStatisticsVo.endDate}
- </if>
- <if test="taskStatisticsVo.userId !=null and taskStatisticsVo.userId!='' ">
- and io.userid =#{taskStatisticsVo.userId}
- </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
- left join sys_user su on su.id =ifa.audituser
- <where>
- 1=1
- and iac.id = ifa.ins_order_no
- AND iac.orderstatus = 3
- and (iac.del_flag = '1' or io.del_flag IS NULL or io.del_flag = 1)
- <if test="taskStatisticsVo.reviewer !=null and taskStatisticsVo.reviewer !=''">
- and su.name =#{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 iac.signing_time 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.auditTimeStart !=null and taskStatisticsVo.auditTimeEnd != '' and taskStatisticsVo.auditTimeStart !=null and taskStatisticsVo.auditTimeEnd != ''">
- AND ifa.audittime BETWEEN #{taskStatisticsVo.auditTimeStart} AND #{taskStatisticsVo.auditTimeEnd}
- </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="costCenterDetails" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
- SELECT
- ifa.audituser as "audituser",
- su.name as "audituserName",
- su.mobile as "audituserMobile",
- 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"
- 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
- LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
- LEFT JOIN esm_ins_company eic ON eic.id = pa.partner_companies_id
- left join sys_user su on su.id =ifa.audituser
- <where>
- 1=1
- and iac.id = ifa.ins_order_no
- AND iac.orderstatus = 3
- and (iac.del_flag = '1' or io.del_flag IS NULL or io.del_flag = 1)
- AND (ifa.auditstatus ='1' or ifa.auditstatus ='0')
- <if test="taskStatisticsVo.reviewer !=null and taskStatisticsVo.reviewer !=''">
- and su.name =#{taskStatisticsVo.reviewer}
- </if>
- <if test="taskStatisticsVo.auditTimeStart !=null and taskStatisticsVo.auditTimeEnd != '' and taskStatisticsVo.auditTimeStart !=null and taskStatisticsVo.auditTimeEnd != ''">
- AND DATE_FORMAT( ifa.audittime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.auditTimeStart},
- '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.auditTimeEnd}, '%Y-%m-%d')
- </if>
- <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId !=''">
- and iac.company_id =#{taskStatisticsVo.companyId}
- </if>
- <if test="taskStatisticsVo.audittime !=null and taskStatisticsVo.audittime !=''">
- and ifa.audittime =#{taskStatisticsVo.audittime}
- </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( 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.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
- ifa.audituser,su.name,su.mobile,iac.inscompany
- </select>
- <select id="costCenterDetailsExcel" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDtoExcel">
- SELECT
- ifa.audituser as "audituser",
- su.name as "audituserName",
- su.mobile as "audituserMobile",
- 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"
- 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
- LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
- LEFT JOIN esm_ins_company eic ON eic.id = pa.partner_companies_id
- left join sys_user su on su.id =ifa.audituser
- <where>
- 1=1
- and iac.id = ifa.ins_order_no
- AND iac.orderstatus = 3
- AND ifa.audituser != '自动审核'
- AND (ifa.auditstatus ='1' or ifa.auditstatus ='0')
- <if test="taskStatisticsVo.reviewer !=null and taskStatisticsVo.reviewer !=''">
- and su.name =#{taskStatisticsVo.reviewer}
- </if>
- <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId !=''">
- and iac.company_id =#{taskStatisticsVo.companyId}
- </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 ifa.audittime 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.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
- ifa.audituser,su.name,su.mobile,iac.inscompany
- </select>
- <select id="costCenterDetailsLicense" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
- SELECT
- io.licenseno as "licenseno",
- iot.createTime as "createTime",
- ifa.audittime as "auditTime",
- IFNULL(TIMESTAMPDIFF(SECOND, iot.createTime, ifa.audittime),0) as "timeDifference"
- 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
- LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
- LEFT JOIN esm_ins_company eic ON eic.id = pa.partner_companies_id
- left join (
- SELECT
- suborder AS "suborder",
- min(create_time) AS "createTime"
- FROM
- ins_orders_track iot_
- WHERE
- order_status =3
- GROUP BY
- suborder
- ) iot on iot.suborder = iac.id
- left join sys_user su on su.id =ifa.audituser
- <where>
- 1=1
- and iac.id = ifa.ins_order_no
- AND iac.orderstatus = 3
- AND (ifa.auditstatus ='1' or ifa.auditstatus ='0')
- <if test="taskStatisticsVo.reviewer !=null and taskStatisticsVo.reviewer !=''">
- and su.name =#{taskStatisticsVo.reviewer}
- </if>
- <if test="taskStatisticsVo.audituser !=null and taskStatisticsVo.audituser !=''">
- and ifa.audituser =#{taskStatisticsVo.audituser}
- </if>
- <if test="taskStatisticsVo.reviewType ==null">
- AND ifa.audituser != '自动审核'
- </if>
- <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId !=''">
- and iac.company_id =#{taskStatisticsVo.companyId}
- </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.auditTimeStart !=null and taskStatisticsVo.auditTimeEnd != '' and taskStatisticsVo.auditTimeStart !=null and taskStatisticsVo.auditTimeEnd != ''">
- AND DATE_FORMAT( ifa.audittime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.auditTimeStart},
- '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.auditTimeEnd}, '%Y-%m-%d')
- </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.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="costCenterSecond" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDtoNew">
- SELECT
- IFNULL(count(io.licenseno),0) as "orderNumber",
- IFNULL(sum(TIMESTAMPDIFF(SECOND, iot.createTime, ifa.audittime)),0) as "sumSecond",
- ROUND(IFNULL(sum(TIMESTAMPDIFF(SECOND, iot.createTime, ifa.audittime)),0) / count(io.licenseno),2) as
- "averageSecond"
- 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
- LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
- LEFT JOIN esm_ins_company eic ON eic.id = pa.partner_companies_id
- left join sys_user su on su.id =ifa.audituser
- left join (
- SELECT
- suborder AS "suborder",
- min(create_time) AS "createTime"
- FROM
- ins_orders_track iot_
- WHERE
- order_status =3
- GROUP BY
- suborder
- ) iot on iot.suborder = iac.id
- <where>
- 1=1
- and iac.id = ifa.ins_order_no
- AND iac.orderstatus = 3
- AND ifa.audituser != '自动审核'
- AND (ifa.auditstatus ='1' or ifa.auditstatus ='0')
- <if test="taskStatisticsVo.reviewer !=null and taskStatisticsVo.reviewer !=''">
- and su.name =#{taskStatisticsVo.reviewer}
- </if>
- <if test="taskStatisticsVo.audituser !=null and taskStatisticsVo.audituser !=''">
- and ifa.audituser =#{taskStatisticsVo.audituser}
- </if>
- <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId !=''">
- and iac.company_id =#{taskStatisticsVo.companyId}
- </if>
- <if test="taskStatisticsVo.auditTimeStart !=null and taskStatisticsVo.auditTimeEnd != '' and taskStatisticsVo.auditTimeStart !=null and taskStatisticsVo.auditTimeEnd != ''">
- AND DATE_FORMAT( ifa.audittime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.auditTimeStart},
- '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.auditTimeEnd}, '%Y-%m-%d')
- </if>
- <if test="taskStatisticsVo.audittime !=null and taskStatisticsVo.audittime !=''">
- and ifa.audittime =#{taskStatisticsVo.audittime}
- </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( 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.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="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'
- and (iac.del_flag = '1' or io.del_flag IS NULL or io.del_flag = 1)
- <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
- <where>
- <if test="vo.outThere != null and vo.outThere!=''">
- <choose>
- <when test=" vo.outThere == 0">
- AND IFNULL(a.orderAmount,0) = 0
- </when>
- <when test="vo.outThere == 1">
- AND IFNULL(a.orderAmount,0) > 0
- </when>
- </choose>
- </if>
- </where>
- 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>
- (iac.del_flag = '1' or io.del_flag IS NULL or io.del_flag = 1)
- <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.dockingPerson as "dockingPerson",
- a.dockingPhone as "dockingPhone",
- a.agreementType as "agreementType",
- a.logo as "logo",
- a.companyId as "companyId",
- a.insuranceCompanyName as "insuranceCompanyName",
- a.parterCompanyId as "parterCompanyId",
- a.partnerCompaniesName as "partnerCompaniesName",
- sum(a.totalPremium) as "totalPremium",
- sum(a.qutationInsureCount) as "qutationInsureCount",
- ROUND(sum(a.totalPremium) / sum(a.qutationInsureCount), 2) AS "averagePremium",
- ROUND(sum(a.totalPremium) / sum(a.userNumber),2) as "perCapitaAmount",
- sum(a.userNumber) as "userNumber"
- from (
- 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",
- a.userNumber as "userNumber",
- 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 sys_user su on io.userid =su.id
- LEFT JOIN ins_fee_audit ifa on ifa.ins_order_no =iac.id
- LEFT JOIN esm_ins_company ins ON agree.partner_companies_id = ins.id
- WHERE
- agree.id IS NOT NULL
- and iac.orderstatus = '3'
- and ifa.auditstatus != '2'
- and (iac.del_flag = '1' or io.del_flag IS NULL or io.del_flag = 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.signingTimeStart != null and vo.signingTimeStart!='' and vo.signingTimeEnd != null and vo.signingTimeEnd != ''">
- AND iac.signing_time BETWEEN #{vo.signingTimeStart} AND #{vo.signingTimeEnd}
- </if>
- <if test="vo.enterTimeStart != null and vo.enterTimeStart!='' and vo.enterTimeEnd != null and vo.enterTimeEnd != ''">
- AND iac.createtime BETWEEN #{vo.enterTimeStart} AND #{vo.enterTimeEnd}
- </if>
- <if test="vo.leaderName != null and vo.leaderName!='' ">
- AND iac.leader_name = #{vo.leaderName}
- </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 concat('%',#{vo.provinceId},'%')
- </if>
- <if test="vo.cityId != null and vo.cityId != '' and vo.countyId ==null and vo.houseId ==null">
- and io.deptid like concat('%',#{vo.cityId},'%')
- </if>
- <if test="vo.countyId != null and vo.countyId != '' and vo.houseId ==null">
- and io.deptid like concat('%',#{vo.countyId},'%')
- </if>
- <if test="vo.houseId != null and vo.houseId != ''">
- and io.deptid like concat('%',#{vo.houseId},'%')
- </if>
- <if test="vo.parterProvinceId != null and vo.parterProvinceId != '' and vo.parterCityId == null and vo.parterCountyId == null ">
- and agree.partner_companies_id like concat('%',#{vo.parterProvinceId},'%')
- </if>
- <if test="vo.parterCityId != null and vo.parterCityId != '' and vo.parterCountyId ==null ">
- and agree.partner_companies_id like concat('%',#{vo.parterCityId},'%')
- </if>
- <if test="vo.parterCountyId != null and vo.parterCountyId != '' ">
- and agree.partner_companies_id like concat('%',#{vo.parterCountyId},'%')
- </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 su.leader_id 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
- ) a
- group by
- a.companyId,a.insuranceCompanyName,a.parterCompanyId,a.partnerCompaniesName,a.logo,a.dockingPerson,a.dockingPhone,a.agreementType
- </select>
- <select id="getCountBusinessData" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
- select
- sum(a.totalPremium) as "totalPremium",
- sum(a.qutationInsureCount) as "qutationInsureCount",
- ROUND(sum( a.totalPremium ) / sum( a.qutationInsureCount ),2) AS "averagePremium",
- sum(a.userNumber) as "userNumber",
- count(DISTINCT a.insuranceCompanyName) as "insuranceCompanyNumber",
- ROUND(sum(a.totalPremium)/sum(a.userNumber),0) as "perCapitaAmount"
- from (
- SELECT
- agree.insurance_company AS "insuranceCompanyName",
- IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0) as "totalPremium",
- COUNT(0 ) AS "qutationInsureCount",
- COUNT(DISTINCT io.userId) AS "userNumber"
- 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 sys_user su on io.userid =su.id
- LEFT JOIN ins_fee_audit ifa on ifa.ins_order_no =iac.id
- WHERE
- agree.id IS NOT NULL
- and iac.orderstatus = '3'
- and ifa.auditstatus != '2'
- and (iac.del_flag = '1' or io.del_flag IS NULL or io.del_flag = 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.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.signingTimeStart != null and vo.signingTimeStart!='' and vo.signingTimeEnd != null and vo.signingTimeEnd != ''">
- AND iac.signing_time BETWEEN #{vo.signingTimeStart} AND #{vo.signingTimeEnd}
- </if>
- <if test="vo.enterTimeStart != null and vo.enterTimeStart!='' and vo.enterTimeEnd != null and vo.enterTimeEnd != ''">
- AND iac.createtime BETWEEN #{vo.enterTimeStart} AND #{vo.enterTimeEnd}
- </if>
- <if test="vo.leaderName != null and vo.leaderName!='' ">
- AND iac.leader_name = #{vo.leaderName}
- </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 concat('%',#{vo.provinceId},'%')
- </if>
- <if test="vo.cityId != null and vo.cityId != '' and vo.countyId ==null and vo.houseId ==null">
- and io.deptid like concat('%',#{vo.cityId},'%')
- </if>
- <if test="vo.countyId != null and vo.countyId != '' and vo.houseId ==null">
- and io.deptid like concat('%',#{vo.countyId},'%')
- </if>
- <if test="vo.houseId != null and vo.houseId != ''">
- and io.deptid like concat('%',#{vo.houseId},'%')
- </if>
- <if test="vo.parterProvinceId != null and vo.parterProvinceId != '' and vo.parterCityId == null and vo.parterCountyId == null ">
- and agree.partner_companies_id like concat('%',#{vo.parterProvinceId},'%')
- </if>
- <if test="vo.parterCityId != null and vo.parterCityId != '' and vo.parterCountyId ==null ">
- and agree.partner_companies_id like concat('%',#{vo.parterCityId},'%')
- </if>
- <if test="vo.parterCountyId != null and vo.parterCountyId != '' ">
- and agree.partner_companies_id like concat('%',#{vo.parterCountyId},'%')
- </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 su.leader_id in
- <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- group by
- agree.insurance_company,
- agree.partner_companies_id
- ) a
- </select>
- <select id="getUserNumber" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
- SELECT
- COUNT(DISTINCT io.userId) AS "userNumber"
- 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 ins_fee_audit ifa on ifa.ins_order_no =iac.id
- LEFT JOIN sys_user su on io.userid =su.id
- WHERE
- agree.id IS NOT NULL
- and iac.orderstatus = '3'
- and ifa.auditstatus != '2'
- and iac.del_flag = '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.signingTimeStart != null and vo.signingTimeStart!='' and vo.signingTimeEnd != null and vo.signingTimeEnd != ''">
- AND iac.signing_time BETWEEN #{vo.signingTimeStart} AND #{vo.signingTimeEnd}
- </if>
- <if test="vo.enterTimeStart != null and vo.enterTimeStart!='' and vo.enterTimeEnd != null and vo.enterTimeEnd != ''">
- AND iac.createtime BETWEEN #{vo.enterTimeStart} AND #{vo.enterTimeEnd}
- </if>
- <if test="vo.provinceId != null and vo.provinceId != '' and vo.cityId == null and vo.countyId == null and vo.houseId == null ">
- and io.deptid like concat('%',#{vo.provinceId},'%')
- </if>
- <if test="vo.cityId != null and vo.cityId != '' and vo.countyId ==null and vo.houseId ==null">
- and io.deptid like concat('%',#{vo.cityId},'%')
- </if>
- <if test="vo.leaderName != null and vo.leaderName!='' ">
- AND iac.leader_name = #{vo.leaderName}
- </if>
- <if test="vo.countyId != null and vo.countyId != '' and vo.houseId ==null">
- and io.deptid like concat('%',#{vo.countyId},'%')
- </if>
- <if test="vo.houseId != null and vo.houseId != ''">
- and io.deptid like concat('%',#{vo.houseId},'%')
- </if>
- <if test="vo.parterProvinceId != null and vo.parterProvinceId != '' and vo.parterCityId == null and vo.parterCountyId == null ">
- and agree.partner_companies_id like concat('%',#{vo.parterProvinceId},'%')
- </if>
- <if test="vo.parterCityId != null and vo.parterCityId != '' and vo.parterCountyId ==null ">
- and agree.partner_companies_id like concat('%',#{vo.parterCityId},'%')
- </if>
- <if test="vo.parterCountyId != null and vo.parterCountyId != '' ">
- and agree.partner_companies_id like concat('%',#{vo.parterCountyId},'%')
- </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 su.leader_id in
- <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- </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
- LEFT JOIN ins_fee_audit ifa on ifa.ins_order_no =iac.id
- LEFT JOIN sys_user su ON io.userid = su.id
- WHERE
- agree.id IS NOT NULL
- and ifa.auditstatus != '2'
- and (iac.del_flag = '1' or io.del_flag IS NULL or io.del_flag = 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.signingTimeStart != null and vo.signingTimeStart!='' and vo.signingTimeEnd != null and vo.signingTimeEnd != ''">
- AND DATE_FORMAT(iac.signing_time, '%Y-%m-%d') BETWEEN DATE_FORMAT(#{vo.signingTimeStart}, '%Y-%m-%d') AND
- DATE_FORMAT(#{vo.signingTimeEnd}, '%Y-%m-%d')
- </if>
- <if test="vo.enterTimeStart != null and vo.enterTimeStart!='' and vo.enterTimeEnd != null and vo.enterTimeEnd != ''">
- AND DATE_FORMAT(iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT(#{vo.enterTimeStart}, '%Y-%m-%d') AND
- DATE_FORMAT(#{vo.enterTimeEnd}, '%Y-%m-%d')
- </if>
- <if test="vo.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.dockingPerson != null and vo.dockingPerson != ''">
- and agree.docking_person =#{vo.dockingPerson}
- </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 su.leader_id in
- <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="vo.riskCode != null and vo.riskCode != '' and vo.riskCode != 'all'">
- and iac.product = #{vo.riskCode}
- </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'
- and (iac.del_flag = '1' or io.del_flag IS NULL or io.del_flag = 1)
- <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>
- </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.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>
- (iac.del_flag = '1' or io.del_flag IS NULL or io.del_flag = 1)
- <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",
- sd.management_source as "managementSource",
- COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS qutationCount,
- COUNT( CASE WHEN iot.order_status ='2' THEN 1 END ) AS underwritingCount,
- COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) AS qutationInsureCount,
- COUNT( CASE WHEN iot.order_status = '4' THEN 1 END ) AS underwritingReturn,
- COUNT( CASE WHEN iot.order_status ='2' THEN 1 END ) / COUNT( CASE WHEN iot.order_status ='0' THEN 1 END ) AS
- "passingRate",
- COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) / COUNT( CASE WHEN iot.order_status in
- ('0','1','2','3','4') THEN 1 END ) AS "closeRate",
- (COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) + COUNT( CASE WHEN iot.order_status = '2' THEN 1 END ))/
- COUNT(CASE WHEN iot.order_status in ('0','1','2','3','4') THEN 1 END) AS "contributionRate",
- COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) / COUNT(CASE WHEN iot.order_status in ('0','1','2','3','4')
- THEN 1 END ) AS "quotationRate",
- COUNT(CASE WHEN io.order_source = 0 and iot.order_status ='0' THEN 1 END) as "pcOrderSource",
- COUNT(CASE WHEN io.order_source = 1 and iot.order_status ='0' THEN 1 END) as "appOrderSource",
- COUNT( CASE WHEN iot.order_status = '1' THEN 1 END ) AS "auditOrder"
- FROM
- (
- select iot.suborder,iot.order_status from `ins_orders_track` iot
- left join ins_area_company iac ON iac.id = iot.suborder
- where true
- <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
- AND iac.createtime BETWEEN #{taskStatisticsVo.beginDate} AND #{taskStatisticsVo.endDate}
- </if>
- <if test="taskStatisticsVo.signingTimeStart !=null and taskStatisticsVo.signingTimeStart != '' and taskStatisticsVo.signingTimeEnd !=null and taskStatisticsVo.signingTimeEnd != ''">
- AND iac.signing_time BETWEEN #{taskStatisticsVo.signingTimeStart} AND #{taskStatisticsVo.signingTimeEnd},
- </if>
- GROUP BY iot.suborder ,iot.order_status
- ) iot
- left join ins_area_company iac ON iac.id = iot.suborder
- LEFT JOIN ins_orders io ON io.orderno = iac.orderno
- LEFT JOIN sys_dept sd ON sd.id = io.deptid
- <where>
- (iac.del_flag = '1' or io.del_flag IS NULL or io.del_flag = 1)
- <if test="taskStatisticsVo.managementSource != null and taskStatisticsVo.managementSource!=''">
- AND sd.management_source =#{taskStatisticsVo.managementSource}
- </if>
- <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 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.createtime BETWEEN #{taskStatisticsVo.beginDate} AND #{taskStatisticsVo.endDate}
- </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>
- </where>
- GROUP BY
- io.userid,
- sd.NAME,
- sd.id,
- sd.management_source
- ) 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
- LEFT JOIN sys_user su2 on su2.id =su.leader_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="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 iot.order_status = '0' THEN 1 END ) AS qutationCount,
- COUNT( CASE WHEN iot.order_status = '1' THEN 1 END ) AS "auditOrder",
- COUNT( CASE WHEN iot.order_status = '2' THEN 1 END ) AS underwritingCount,
- COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) AS qutationInsureCount,
- COUNT( CASE WHEN iot.order_status = '4' THEN 1 END ) AS underwritingReturn,
- COUNT( CASE WHEN iot.order_status ='2' THEN 1 END ) / COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS
- "passingRate",
- COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) / COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS
- "closeRate",
- (COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) + COUNT( CASE WHEN iot.order_status = '2' THEN 1 END )) /
- COUNT( iot.order_status ) AS "contributionRate",
- COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) / COUNT( iot.order_status ) AS "quotationRate"
- FROM
- (
- select iot.suborder,iot.order_status from `ins_orders_track` iot
- left join ins_area_company iac ON iac.id = iot.suborder
- where true
- <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
- AND iac.createtime BETWEEN #{taskStatisticsVo.beginDate} AND #{taskStatisticsVo.endDate}
- </if>
- <if test="taskStatisticsVo.signingTimeStart !=null and taskStatisticsVo.signingTimeStart != '' and taskStatisticsVo.signingTimeEnd !=null and taskStatisticsVo.signingTimeEnd != ''">
- AND iac.signing_time BETWEEN #{taskStatisticsVo.signingTimeStart} AND #{taskStatisticsVo.signingTimeEnd},
- </if>
- GROUP BY iot.suborder ,iot.order_status
- ) iot
- LEFT JOIN ins_area_company iac ON iac.id = iot.suborder
- 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
- and (iac.del_flag = '1' or io.del_flag IS NULL or io.del_flag = 1)
- <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 iac.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.createtime BETWEEN #{taskStatisticsVo.beginDate} AND #{taskStatisticsVo.endDate}
- </if>
- <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId != ''">
- AND iac.company_id =#{taskStatisticsVo.companyId}
- </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="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
- left join sys_user su on su.id =io.userid
- <where>
- iac.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.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.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
- left join sys_user su on su.id =ifa.audituser
- <where>
- 1=1
- and iac.id = ifa.ins_order_no
- AND iac.orderstatus = 3
- <if test="taskStatisticsVo.reviewer !=null and taskStatisticsVo.reviewer !=''">
- and su.name =#{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( iac.signing_time, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.createtimeStart},
- '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.createtimeEnd}, '%Y-%m-%d')
- </if>
- <if test="taskStatisticsVo.auditTimeStart !=null and taskStatisticsVo.auditTimeEnd != '' and taskStatisticsVo.auditTimeStart !=null and taskStatisticsVo.auditTimeEnd != ''">
- AND DATE_FORMAT( ifa.audittime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.auditTimeStart},
- '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.auditTimeEnd}, '%Y-%m-%d')
- </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.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,
- iac.operator_name as recorder
- 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 ifa.audittime desc
- </select>
- <select id="queryPageOrderCB" resultType="com.ydtech.modules.order.entity.InsOrders">
- SELECT
- iac.id as orderno,
- io.quoteno,
- iac.orderstatus,
- iac.company_id,
- iac.inscompany,
- 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,
- 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_area_company iac
- LEFT JOIN ins_orders io ON iac.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 ptl_agreement pa ON pa.id = iac.agreement_id
- LEFT JOIN esm_ins_company eic ON eic.id = pa.partner_companies_id
- WHERE
- iac.orderstatus = 3
- <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 iac.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>
- order by iac.createtime desc
- </select>
- <select id="getExpectNetProfit" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
- select
- ROUND(sum(IFNULL(ifon.jq_costs_premiums,0) + IFNULL(ifon.sy_costs_premiums,0) + IFNULL
- (ifon.no_costs_premiums,0)),2) as "entranceAllFee",
- ROUND(sum(IFNULL(jq_export_other_costs_premiums,0) + IFNULL(jq_export_supervise_costs_premiums,0)
- +IFNULL(sy_export_other_costs_premiums,0) +IFNULL(sy_export_supervise_costs_premiums,0)
- +IFNULL(no_export_other_costs_premiums,0)+IFNULL(no_export_supervise_costs_premiums,0) ),2) as
- "exportAllFee",
- ROUND(sum(IFNULL(b.distributionAmount,0)),2) as "distributionAmount"
- from ins_area_company iac
- left join ins_orders io on io.orderno = iac.orderno
- LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
- LEFT JOIN (
- select IFNULL(a.firstDetailPremiums,0) + IFNULL(b.secondDetailPremiums,0) +IFNULL(c.thirdDetailPremiums,0) as
- "distributionAmount",
- a.firstLevelUserId
- from (
- select
- sum(ifon.first_detail_premiums) as "firstDetailPremiums",
- ifon.first_level_user_id as "firstLevelUserId"
- from ins_area_company iac
- left join ins_orders io on io.orderno = iac.orderno
- LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
- <where>
- iac.orderstatus = 3
- <if test="vo.userId !=null and vo.userId !=''">
- AND ifon.first_level_user_id =#{vo.userId}
- </if>
- <if test="vo.ids != null and vo.ids.size()>0 ">
- AND ifon.first_level_user_id 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 ifon.first_level_user_id
- ) a
- left join (
- select
- sum(IFNULL(second_detail_premiums,0)) as "secondDetailPremiums",
- ifon.two_level_user_id as "twoLevelUserId"
- from ins_area_company iac
- left join ins_orders io on io.orderno = iac.orderno
- LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
- <where>
- iac.orderstatus = 3
- <if test="vo.userId !=null and vo.userId !=''">
- AND ifon.two_level_user_id =#{vo.userId}
- </if>
- <if test="vo.ids != null and vo.ids.size()>0 ">
- AND ifon.two_level_user_id 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 ifon.two_level_user_id
- ) b on b.twoLevelUserId =a.firstLevelUserId
- left join (
- select
- sum(IFNULL(third_detail_premiums,0)) as "thirdDetailPremiums",
- ifon.three_level_user_id as "threeLevelUserId"
- from ins_area_company iac
- left join ins_orders io on io.orderno = iac.orderno
- LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
- <where>
- iac.orderstatus = 3
- <if test="vo.userId !=null and vo.userId !=''">
- AND ifon.three_level_user_id =#{vo.userId}
- </if>
- <if test="vo.ids != null and vo.ids.size()>0 ">
- AND ifon.three_level_user_id 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 ifon.three_level_user_id
- ) c on c.threeLevelUserId = a.firstLevelUserId
- ) b on b.firstLevelUserId =iac.leader_id
- <where>
- iac.orderstatus = 3
- <if test="vo.userId !=null and vo.userId !=''">
- AND io.userid =#{vo.userId}
- </if>
- <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>
- </select>
- <select id="getDistributionAllAmount" resultType="java.util.HashMap">
- select IFNULL(a.firstDetailPremiums,0) + IFNULL(b.secondDetailPremiums,0) +IFNULL(c.thirdDetailPremiums,0) as
- "distributionAmount",
- a.firstLevelUserId
- from (
- select
- sum(ifon.first_detail_premiums) as "firstDetailPremiums",
- ifon.first_level_user_id as "firstLevelUserId"
- from ins_area_company iac
- left join ins_orders io on io.orderno = iac.orderno
- LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
- <where>
- <if test="vo.userId !=null and vo.userId !=''">
- ifon.first_level_user_id =#{vo.userId}
- </if>
- <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 ifon.first_level_user_id
- ) a
- left join (
- select
- sum(IFNULL(second_detail_premiums,0)) as "secondDetailPremiums",
- ifon.two_level_user_id as "twoLevelUserId"
- from ins_area_company iac
- left join ins_orders io on io.orderno = iac.orderno
- LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
- <where>
- <if test="vo.userId !=null and vo.userId !=''">
- ifon.two_level_user_id =#{vo.userId}
- </if>
- <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 ifon.two_level_user_id
- ) b on b.twoLevelUserId =a.firstLevelUserId
- left join (
- select
- sum(IFNULL(third_detail_premiums,0)) as "thirdDetailPremiums",
- ifon.three_level_user_id as "threeLevelUserId"
- from ins_area_company iac
- left join ins_orders io on io.orderno = iac.orderno
- LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
- <where>
- <if test="vo.userId !=null and vo.userId !=''">
- ifon.three_level_user_id =#{vo.userId}
- </if>
- <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 ifon.three_level_user_id
- ) c on c.threeLevelUserId = a.firstLevelUserId
- </select>
- <select id="findListByDate" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
- SELECT
- iac.*
- FROM ins_area_company as iac
- <where>
- iac.orderstatus = 3
- and iac.signing_time IS NULL
- <if test="benginDate != null and benginDate!='' and endDate != null and endDate!=''">
- AND iac.createtime BETWEEN #{benginDate} AND #{endDate}
- </if>
- </where>
- order by iac.createtime
- </select>
- <select id="getSumEntryStatus" resultType="java.util.HashMap">
- select ifnull( COUNT( CASE WHEN io.entry_status = '2' THEN 1 END ),0) as "entryStatus",
- ifnull(COUNT( CASE WHEN io.entry_status = '3' THEN 1 END ),0) as "outStatus"
- from ins_area_company iac
- left join ins_orders io on iac.orderno =io.orderno
- <where>
- iac.orderstatus = '3'
- <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 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>
- </where>
- </select>
- <select id="getBusinessDataList" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
- select
- a.dockingPerson as "dockingPerson",
- a.dockingPhone as "dockingPhone",
- a.agreementType as "agreementType",
- a.logo as "logo",
- a.companyId as "companyId",
- a.insuranceCompanyName as "insuranceCompanyName",
- a.parterCompanyId as "parterCompanyId",
- a.partnerCompaniesName as "partnerCompaniesName",
- sum(a.totalPremium) as "totalPremium",
- sum(a.qutationInsureCount) as "qutationInsureCount",
- sum(a.totalPremium) / sum(a.qutationInsureCount) AS "averagePremium",
- sum(a.totalPremium) / sum(a.userNumber) as "perCapitaAmount",
- sum(a.userNumber) as "userNumber"
- from (
- 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",
- a.userNumber as "userNumber",
- 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 sys_user su on io.userid =su.id
- LEFT JOIN ins_fee_audit ifa on ifa.ins_order_no =iac.id
- LEFT JOIN esm_ins_company ins ON agree.partner_companies_id = ins.id
- WHERE
- agree.id IS NOT NULL
- and iac.orderstatus = '3'
- and ifa.auditstatus != '2'
- <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!=''">
- iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
- </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 concat('%',#{vo.provinceId},'%')
- </if>
- <if test="vo.cityId != null and vo.cityId != '' and vo.countyId ==null and vo.houseId ==null">
- and io.deptid like concat('%',#{vo.cityId},'%')
- </if>
- <if test="vo.countyId != null and vo.countyId != '' and vo.houseId ==null">
- and io.deptid like concat('%',#{vo.countyId},'%')
- </if>
- <if test="vo.houseId != null and vo.houseId != ''">
- and io.deptid like concat('%',#{vo.houseId},'%')
- </if>
- <if test="vo.parterProvinceId != null and vo.parterProvinceId != '' and vo.parterCityId == null and vo.parterCountyId == null ">
- and agree.partner_companies_id like concat('%',#{vo.parterProvinceId},'%')
- </if>
- <if test="vo.parterCityId != null and vo.parterCityId != '' and vo.parterCountyId ==null ">
- and agree.partner_companies_id like concat('%',#{vo.parterCityId},'%')
- </if>
- <if test="vo.parterCountyId != null and vo.parterCountyId != '' ">
- and agree.partner_companies_id like concat('%',#{vo.parterCountyId},'%')
- </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 su.leader_id 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
- ) a
- group by
- a.companyId,a.insuranceCompanyName,a.parterCompanyId,a.partnerCompaniesName,a.logo,a.dockingPerson,a.dockingPhone,a.agreementType
- </select>
- <select id="costReviewer" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
- SELECT
- ifa.audituser as "audituser",
- su.name as "audituserName",
- su.mobile as "mobile",
- 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
- LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
- LEFT JOIN esm_ins_company eic ON eic.id = pa.partner_companies_id
- left join sys_user su on su.id =ifa.audituser
- <where>
- 1=1
- and iac.id = ifa.ins_order_no
- and iac.orderstatus = 3
- and (iac.del_flag = '1' or io.del_flag IS NULL or io.del_flag = 1)
- <if test="taskStatisticsVo.reviewer !=null and taskStatisticsVo.reviewer !=''">
- and su.name =#{taskStatisticsVo.reviewer}
- </if>
- <if test="taskStatisticsVo.audittime !=null and taskStatisticsVo.audittime !=''">
- and ifa.audittime =#{taskStatisticsVo.audittime}
- </if>
- <if test="taskStatisticsVo.audituserName !=null and taskStatisticsVo.audituserName !=''">
- AND su.name like concat('%',#{taskStatisticsVo.audituserName},'%')
- </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 iac.signing_time 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.auditTimeStart !=null and taskStatisticsVo.auditTimeEnd != '' and taskStatisticsVo.auditTimeStart !=null and taskStatisticsVo.auditTimeEnd != ''">
- and ifa.audittime BETWEEN#{taskStatisticsVo.auditTimeStart} AND #{taskStatisticsVo.auditTimeEnd}
- </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
- ifa.audituser
- </select>
- <select id="getSumEntryStatusNew" resultType="com.ydtech.modules.admin.model.dto.RecordSummaryDto">
- select
- io.userid as userId,
- ifnull( COUNT( CASE WHEN io.entry_status = '2' THEN 1 END ), 0) as "entryStatus",
- ifnull(COUNT( CASE WHEN io.entry_status = '3' THEN 1 END ), 0) as "outStatus"
- from ins_area_company iac
- left join ins_orders io on iac.orderno =io.orderno
- <where>
- iac.orderstatus = '3'
- <if test="sumEntryStatusDo.userIdList != null and !sumEntryStatusDo.userIdList.isEmpty()">
- and io.userid in
- <foreach item="userId" collection="sumEntryStatusDo.userIdList" open="(" separator="," close=")">
- #{userId}
- </foreach>
- </if>
- <if test="sumEntryStatusDo.createtimeStart !=null and sumEntryStatusDo.createtimeStart != '' and sumEntryStatusDo.createtimeEnd !=null and sumEntryStatusDo.createtimeEnd != ''">
- AND io.createtime BETWEEN #{sumEntryStatusDo.createtimeStart} AND
- #{sumEntryStatusDo.createtimeEnd}
- </if>
- <if test="sumEntryStatusDo.beginDate !=null and sumEntryStatusDo.beginDate != '' and sumEntryStatusDo.endDate !=null and sumEntryStatusDo.endDate != ''">
- AND iac.signing_time BETWEEN #{sumEntryStatusDo.beginDate} AND #{sumEntryStatusDo.endDate}
- </if>
- </where>
- group by io.userid
- </select>
- </mapper>
|