InsAreaCompanyMapper.xml 190 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.ydtech.modules.order.dao.InsAreaCompanyMapper">
  6. <resultMap id="BaseResultMap" type="com.ydtech.modules.order.entity.InsAreaCompany">
  7. <id property="id" column="id" jdbcType="VARCHAR"/>
  8. <result property="reqtxt" column="reqtxt" javaType="com.alibaba.fastjson.JSONObject"
  9. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  10. <result property="reptxt" column="reptxt" javaType="com.alibaba.fastjson.JSONObject"
  11. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  12. <result property="riskinfo" column="riskinfo" javaType="com.alibaba.fastjson.JSONArray"
  13. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  14. <result property="kindinfo" column="kindinfo" javaType="com.alibaba.fastjson.JSONArray"
  15. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  16. <result property="accidentInfo" column="accident_info" javaType="com.alibaba.fastjson.JSONArray"
  17. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  18. <result property="taxArrears" column="tax_arrears" javaType="com.alibaba.fastjson.JSONArray"
  19. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  20. <result property="crossInsurance" column="cross_insurance" javaType="com.alibaba.fastjson.JSONArray"
  21. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  22. <result property="orderno" column="orderno" jdbcType="VARCHAR"/>
  23. <result property="agreementId" column="agreement_id" jdbcType="BIGINT"/>
  24. <result property="apiType" column="api_type" jdbcType="TINYINT"/>
  25. <result property="orderstatus" column="orderstatus" jdbcType="VARCHAR"/>
  26. <result property="companyId" column="company_id" jdbcType="VARCHAR"/>
  27. <result property="inscompany" column="inscompany" jdbcType="VARCHAR"/>
  28. <result property="jqapplyno" column="jqapplyno" jdbcType="VARCHAR"/>
  29. <result property="jqpolicyno" column="jqpolicyno" jdbcType="VARCHAR"/>
  30. <result property="syapplyno" column="syapplyno" jdbcType="VARCHAR"/>
  31. <result property="sypolicyno" column="sypolicyno" jdbcType="VARCHAR"/>
  32. <result property="jqpremium" column="jqpremium" jdbcType="DECIMAL"/>
  33. <result property="sypremium" column="sypremium" jdbcType="DECIMAL"/>
  34. <result property="jypremium" column="jypremium" jdbcType="DECIMAL"/>
  35. <result property="sumpremium" column="sumpremium" jdbcType="DECIMAL"/>
  36. <result property="taxamount" column="taxamount" jdbcType="DECIMAL"/>
  37. <result property="jqdiscountrate" column="jqdiscountrate" jdbcType="DOUBLE"/>
  38. <result property="sydiscountrate" column="sydiscountrate" jdbcType="DOUBLE"/>
  39. <result property="feerate" column="feerate" jdbcType="DOUBLE"/>
  40. <result property="disrate" column="disrate" jdbcType="DOUBLE"/>
  41. <result property="auditid" column="auditid" jdbcType="VARCHAR"/>
  42. <result property="auditname" column="auditname" jdbcType="VARCHAR"/>
  43. <result property="audittime" column="audittime" jdbcType="TIMESTAMP"/>
  44. <result property="auditopinion" column="auditopinion" jdbcType="VARCHAR"/>
  45. <result property="jqappoint" column="jqappoint" jdbcType="VARCHAR"/>
  46. <result property="syappoint" column="syappoint" jdbcType="VARCHAR"/>
  47. <result property="createtime" column="createtime" jdbcType="TIMESTAMP"/>
  48. <result property="payDate" column="pay_date" jdbcType="TIMESTAMP"/>
  49. <result property="paymentLink" column="payment_link" jdbcType="VARCHAR"/>
  50. <result property="insOrderNo" column="ins_order_no" jdbcType="VARCHAR"/>
  51. <result property="attributionId" column="attribution_id" jdbcType="VARCHAR"/>
  52. <result property="jqStartDate" column="jq_start_date" jdbcType="VARCHAR"/>
  53. <result property="jqEndDate" column="jq_end_date" jdbcType="VARCHAR"/>
  54. <result property="syStartDate" column="sy_start_date" jdbcType="VARCHAR"/>
  55. <result property="syEndDate" column="sy_end_date" jdbcType="VARCHAR"/>
  56. <result property="accidentStrInfo" column="accident_str_info" jdbcType="VARCHAR"/>
  57. <result property="score" column="score" jdbcType="VARCHAR"/>
  58. <result property="jqScore" column="jq_score" jdbcType="VARCHAR"/>
  59. <result property="syScore" column="sy_score" jdbcType="VARCHAR"/>
  60. <result property="lossRation" column="loss_ration" jdbcType="DOUBLE"/>
  61. <result property="jqLossRation" column="jq_loss_ration" jdbcType="DOUBLE"/>
  62. <result property="syLossRation" column="sy_loss_ration" jdbcType="DOUBLE"/>
  63. <result property="totalAdjustRate" column="total_adjust_rate" jdbcType="DOUBLE"/>
  64. <result property="jqAdjustRate" column="jq_adjust_rate" jdbcType="DOUBLE"/>
  65. <result property="syAdjustRate" column="sy_adjust_rate" jdbcType="DOUBLE"/>
  66. <result property="insideOrderStatus" column="inside_order_status" jdbcType="TINYINT"/>
  67. <result property="insidePayTime" column="inside_pay_time" jdbcType="TIMESTAMP"/>
  68. <result property="signingTime" column="signing_time" jdbcType="TIMESTAMP"/>
  69. <result property="jqRenewal" column="jq_renewal" jdbcType="VARCHAR"/>
  70. <result property="syRenewal" column="sy_renewal" jdbcType="VARCHAR"/>
  71. <result property="jqClaims" column="jq_claims" jdbcType="VARCHAR"/>
  72. <result property="syClaims" column="sy_claims" jdbcType="VARCHAR"/>
  73. <result property="feeMatchErrMsg" column="fee_match_err_msg" jdbcType="VARCHAR"/>
  74. <result property="quoteErrMsg" column="quote_err_msg" jdbcType="VARCHAR"/>
  75. </resultMap>
  76. <resultMap id="InsAreaCompanyQueryDto" type="com.ydtech.modules.order.entity.dto.InsAreaCompanyQueryDto"
  77. extends="BaseResultMap">
  78. <result property="agreementName" column="agreement_name" jdbcType="VARCHAR"/>
  79. <result property="fileStatus" column="fileStatus" jdbcType="VARCHAR"/>
  80. </resultMap>
  81. <sql id="Base_Column_List">
  82. id,orderno,inscompany,
  83. reqtxt,reptxt,jqapplyno,
  84. jqpolicyno,syapplyno,sypolicyno,
  85. riskinfo,kindinfo,jqpremium,
  86. sypremium,taxamount,sumpremium,
  87. jqdiscountrate,sydiscountrate,feerate,
  88. disrate,auditid,auditname,
  89. audittime,auditopinion,jqappoint,
  90. syappoint,createtime,payment_link
  91. </sql>
  92. <select id="selectByOrderNo" resultMap="InsAreaCompanyQueryDto">
  93. SELECT iac.*,
  94. pa.agreement_name,
  95. (select IF(count(0) > 0, 'true', 'false')
  96. from pingan_sh_uploafile
  97. where sub_order_no = iac.id
  98. AND status = 0) as fileStatus
  99. FROM ins_area_company as iac
  100. left join ptl_agreement as pa on pa.id = iac.agreement_id
  101. INNER JOIN (SELECT company_id, max(createtime) AS max_createtime
  102. FROM ins_area_company
  103. WHERE orderno = #{orderNo}
  104. GROUP BY company_id) t ON t.company_id = iac.company_id
  105. AND t.max_createtime = iac.createtime
  106. WHERE iac.orderno = #{orderNo}
  107. </select>
  108. <select id="selectAcceptInsurance" resultMap="InsAreaCompanyQueryDto">
  109. SELECT iac.*,
  110. pa.agreement_name,
  111. io.is_external,
  112. (select IF(count(0) > 0, 'true', 'false')
  113. from pingan_sh_uploafile
  114. where sub_order_no = iac.id
  115. AND status = 0) as fileStatus
  116. FROM ins_area_company as iac
  117. left join ptl_agreement as pa on pa.id = iac.agreement_id
  118. left join ins_orders io on iac.orderno = io.orderno
  119. WHERE iac.orderstatus = 3
  120. and iac.orderno = #{orderNo};
  121. </select>
  122. <select id="queryLatestStatus" resultType="java.lang.String">
  123. SELECT iac.orderstatus
  124. FROM ins_area_company as iac
  125. INNER JOIN (SELECT company_id, max(createtime) AS max_createtime
  126. FROM ins_area_company
  127. WHERE orderno = #{orderNo}
  128. GROUP BY company_id) t ON t.company_id = iac.company_id
  129. AND t.max_createtime = iac.createtime
  130. WHERE iac.orderno = #{orderNo}
  131. ORDER BY orderstatus DESC
  132. LIMIT 1
  133. </select>
  134. <select id="getorDerIds" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
  135. SELECT a.id as "id",
  136. a.orderno as "orderno"
  137. FROM ins_area_company a
  138. LEFT JOIN ins_fee_order_new b ON a.id = b.ins_order_no
  139. WHERE a.orderstatus = '3'
  140. or a.orderstatus = '2'
  141. and b.id is not null
  142. </select>
  143. <select id="getAuditOrders" resultType="com.ydtech.modules.order.entity.InsOrders">
  144. SELECT
  145. iac.id as orderno,
  146. io.quoteno,
  147. io.orderstatus,
  148. io.company_id,
  149. io.ins_company,
  150. io.carinfo,
  151. io.userid,
  152. io.username,
  153. io.deptid,
  154. io.deptname,
  155. io.agreeid,
  156. iac.productid,
  157. iac.product,
  158. iac.createtime,
  159. io.frameno,
  160. io.licenseno,
  161. JSON_UNQUOTE(json_extract(io.insureinfo, '$.name')) as insuredname,
  162. io.is_external,
  163. iac.jq_start_date as jqstartdate,
  164. iac.jq_end_date as jqenddate,
  165. iac.sy_start_date as systartdate,
  166. iac.sy_end_date as syenddate,
  167. io.vehicle_and_vessel_tax,
  168. io.operatorid,
  169. iac.operator_name,
  170. sd.management_source,
  171. iac.problem_order,
  172. CASE ifa.audituser
  173. WHEN '自动审核' THEN ifa.audituser
  174. ELSE su2.name END
  175. AS auditUser,
  176. CASE ifa.audituser
  177. WHEN '自动审核' THEN '2'
  178. ELSE '1' END
  179. AS checkType,
  180. ifa.audittime as auditTime,
  181. ifa.auditstatus as auditStatus,
  182. eic.namesimple as partnerCompaniesName,
  183. iac.id as subOrderId,
  184. iac.signing_time as signingTime,
  185. iac.pay_date as payDate,
  186. pa.agreement_code as agreementCode,
  187. pa.agreement_name as agreementName,
  188. pa.business_description as businessDescription,
  189. pa.job_description as jobDescription,
  190. pa.agreement_title as agreementTitle,
  191. pa.docking_person as dockingPerson,
  192. io.entry_status
  193. FROM
  194. ins_fee_audit ifa
  195. LEFT JOIN ins_orders io ON io.orderno = ifa.orderno
  196. LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
  197. AND iac.orderstatus = 3
  198. LEFT JOIN sys_user su ON su.id = io.userid
  199. LEFT JOIN sys_dept sd ON sd.id = su.dept_id
  200. LEFT JOIN sys_user su2 ON ifa.audituser = su2.id
  201. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  202. LEFT JOIN esm_ins_company eic ON eic.id = pa.partner_companies_id
  203. WHERE
  204. iac.id = ifa.ins_order_no
  205. AND iac.orderstatus = 3
  206. <if test="params.auditStatus != null and params.auditStatus != ''">
  207. and ifa.auditstatus = #{params.auditStatus}
  208. </if>
  209. <if test="params.quoteStartDateStr != null and params.quoteStartDateStr != '' and params.quoteEndDateStr != null and params.quoteEndDateStr != ''">
  210. and DATE_FORMAT(iac.createtime, '%Y-%m-%d') between #{params.quoteStartDateStr} AND
  211. #{params.quoteEndDateStr}
  212. </if>
  213. <if test="params.orderNo != null and params.orderNo != ''">
  214. AND iac.id= #{params.orderNo}
  215. </if>
  216. <if test="params.licenseNo != null and params.licenseNo != ''">
  217. AND io.licenseno = #{params.licenseNo}
  218. </if>
  219. <if test="params.frameNo != null and params.frameNo != ''">
  220. AND io.frameno = #{params.frameNo}
  221. </if>
  222. <if test="params.insuredName != null and params.insuredName != ''">
  223. AND json_extract(io.insureinfo, '$.name') = #{params.insuredName}
  224. </if>
  225. <if test="params.companyId != null and params.companyId != ''">
  226. AND io.company_id = #{params.companyId}
  227. </if>
  228. <if test="params.engineNo != null and params.engineNo != ''">
  229. and JSON_EXTRACT( io.carinfo, '$.engineNo' ) = #{params.engineNo}
  230. </if>
  231. <if test="params.riskCode != null and params.riskCode != ''">
  232. and iac.product = #{params.riskCode}
  233. </if>
  234. <if test="params.attachStartDateStr != null and params.attachStartDateStr != '' and params.attachStartDateStr != null and params.attachStartDateStr != '' ">
  235. and ((
  236. DATE_FORMAT(iac.jq_start_date, '%Y-%m-%d') BETWEEN #{params.attachStartDateStr}
  237. AND #{params.attachEndDateStr}
  238. )
  239. OR ( DATE_FORMAT(iac.sy_start_date, '%Y-%m-%d') BETWEEN #{params.attachStartDateStr} AND
  240. #{params.attachEndDateStr} )
  241. )
  242. </if>
  243. <if test="params.provinceId != null and params.provinceId != ''">
  244. and io.deptid like "${params.provinceId}%"
  245. </if>
  246. <if test="params.problemOrder != null and params.problemOrder != ''">
  247. and iac.problem_order like "${params.problemOrder}%"
  248. </if>
  249. <if test="params.cityId != null and params.cityId != ''">
  250. and io.deptid like "${params.cityId}%"
  251. </if>
  252. <if test="params.countyId != null and params.countyId != ''">
  253. and io.deptid like "${params.countyId}%"
  254. </if>
  255. <if test="params.houseId != null and params.houseId != ''">
  256. and io.deptid like "${params.houseId}%"
  257. </if>
  258. <if test="params.operatorId != null and params.operatorId != ''">
  259. and io.userid = #{params.operatorId}
  260. </if>
  261. <if test="params.operatorName != null and params.operatorName != ''">
  262. and io.username = #{params.operatorName}
  263. </if>
  264. <if test="params.auditId != null and params.auditId != ''">
  265. and iac.new_operator_id = #{params.auditId}
  266. </if>
  267. <if test="params.agreeId != null and params.agreeId != ''">
  268. and iac.agreement_id = #{params.agreeId}
  269. </if>
  270. <if test="params.managementSource != null and params.managementSource.size > 0">
  271. and sd.management_source in
  272. <foreach item="source" collection="params.managementSource" open="(" separator="," close=")">
  273. #{source}
  274. </foreach>
  275. </if>
  276. <if test="params.signStartDateStr != null and params.signStartDateStr != '' and params.signEndDateStr != null and params.signEndDateStr != ''">
  277. and DATE_FORMAT(iac.signing_time, '%Y-%m-%d') between #{params.signStartDateStr} AND
  278. #{params.signEndDateStr}
  279. </if>
  280. <if test="params.payStartDateStr != null and params.payStartDateStr != '' and params.payEndDateStr != null and params.payEndDateStr != ''">
  281. and iac.pay_date between #{params.payStartDateStr} AND #{params.payEndDateStr}
  282. </if>
  283. <if test="params.isExternal != null and params.isExternal != ''">
  284. and io.is_external = #{params.isExternal}
  285. </if>
  286. <if test="params.jqPolicyNo != null and params.jqPolicyNo != ''">
  287. and iac.jqpolicyno = #{params.jqPolicyNo}
  288. </if>
  289. <if test="params.syPolicyNo != null and params.syPolicyNo != ''">
  290. and iac.sypolicyno = #{params.syPolicyNo}
  291. </if>
  292. <if test="params.noPolicyNo != null and params.noPolicyNo != ''">
  293. and iac.cross_insurance like concat('%', #{params.noPolicyNo}, '%')
  294. </if>
  295. <if test="params.checkUser != null and params.checkUser != ''">
  296. and CASE ifa.audituser WHEN '自动审核' THEN ifa.audituser
  297. ELSE su2.name END = #{params.checkUser}
  298. </if>
  299. <if test="params.checkType != null and params.checkType != ''">
  300. and CASE ifa.audituser
  301. WHEN '自动审核' THEN '2'
  302. ELSE '1' END = #{params.checkType}
  303. </if>
  304. <if test="excludeKeys != null and excludeKeys.size() > 0">
  305. and iac.id not in
  306. <foreach item="key" collection="excludeKeys" open="(" separator="," close=")">
  307. #{key}
  308. </foreach>
  309. </if>
  310. order by iac.createtime desc
  311. </select>
  312. <select id="getByUserId" resultType="com.ydtech.modules.order.entity.InsOrders">
  313. SELECT
  314. io.*,
  315. sd.management_source
  316. FROM
  317. ins_orders io left join sys_user su on su.id = io.userid left join sys_dept sd on sd.id = su.dept_id
  318. WHERE
  319. orderno IN (
  320. SELECT
  321. orderno
  322. FROM
  323. ins_area_company
  324. WHERE
  325. id IN ( SELECT ins_order_no FROM ins_fee_order_new WHERE id NOT IN ( SELECT ins_order_no FROM ins_fee_audit ) )
  326. AND orderstatus = 3
  327. )
  328. AND
  329. io.orderstatus= 3
  330. <if test="orderNo != null and orderNo != ''">
  331. AND orderno = #{orderNo}
  332. </if>
  333. <if test="licenseNo != null and licenseNo != ''">
  334. AND licenseno = #{licenseNo}
  335. </if>
  336. <if test="frameNo != null and frameNo != ''">
  337. AND frameno = #{frameNo}
  338. </if>
  339. <if test="userId != null and userId != ''">
  340. AND userid = #{userId}
  341. </if>
  342. <if test="insuredname != null and insuredname != ''">
  343. AND insuredname = #{insuredname}
  344. </if>
  345. <if test="startDateStr != null and startDateStr != ''">
  346. AND createtime BETWEEN #{startDateStr} and #{endDateStr}
  347. </if>
  348. </select>
  349. <select id="selectFirstPromotionBy" resultType="com.ydtech.modules.order.entity.InsOrders">
  350. SELECT
  351. sum(a.first_detail_premiums) as "willFirstPremiums"
  352. FROM
  353. ins_fee_order_new a
  354. LEFT JOIN ins_area_company iac on iac.id=a.ins_order_no
  355. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  356. WHERE
  357. iff.auditstatus=0
  358. AND iac.orderstatus =3
  359. <if test="firstUserId != null and firstUserId != ''">
  360. AND a.first_level_user_id = #{firstUserId}
  361. </if>
  362. <if test="secondUserId != null and secondUserId != ''">
  363. AND a.two_level_user_id = #{secondUserId}
  364. </if>
  365. <if test="thirdUserId != null and thirdUserId != ''">
  366. AND a.three_level_user_id = #{thirdUserId}
  367. </if>
  368. <if test="id != null and id != ''">
  369. AND a.id = #{id}
  370. </if>
  371. </select>
  372. <select id="selectSecondPromotionBy" resultType="com.ydtech.modules.order.entity.InsOrders">
  373. SELECT
  374. sum( fee.p ) as "willFirstPremiums"
  375. FROM
  376. (
  377. SELECT
  378. sum( a.first_detail_premiums ) AS p
  379. FROM
  380. ins_fee_order_new a
  381. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  382. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  383. <where>
  384. iff.auditstatus=0
  385. and iac.orderstatus = '3'
  386. <if test="userId!=null and userId!= ''">
  387. AND a.first_level_user_id = #{userId}
  388. </if>
  389. <if test="id != null and id!=''">
  390. AND a.id =#{id}
  391. </if>
  392. </where>
  393. UNION
  394. SELECT
  395. sum( a.third_detail_premiums ) AS p
  396. FROM
  397. ins_fee_order_new a
  398. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  399. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  400. <where>
  401. iff.auditstatus=0
  402. and iac.orderstatus = '3'
  403. <if test="userId!=null and userId!= ''">
  404. AND a.three_level_user_id = #{userId}
  405. </if>
  406. <if test="id != null and id!=''">
  407. AND a.id =#{id}
  408. </if>
  409. </where>
  410. UNION
  411. SELECT
  412. sum( a.second_detail_premiums ) AS p
  413. FROM
  414. ins_fee_order_new a
  415. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  416. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  417. <where>
  418. iff.auditstatus=0
  419. and iac.orderstatus = '3'
  420. <if test="userId!=null and userId!= ''">
  421. AND a.two_level_user_id = #{userId}
  422. </if>
  423. <if test="id != null and id!=''">
  424. AND a.id =#{id}
  425. </if>
  426. </where>
  427. ) AS fee
  428. </select>
  429. <select id="selectThirdPromotionBy" resultType="com.ydtech.modules.order.entity.InsOrders">
  430. SELECT
  431. sum(a.third_detail_premiums) as "willThreePremiums"
  432. FROM
  433. ins_fee_order_new a
  434. LEFT JOIN ins_area_company iac on iac.id=a.ins_order_no
  435. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  436. WHERE
  437. iff.auditstatus=0
  438. AND iac.orderstatus =3
  439. <if test="firstUserId != null and firstUserId != ''">
  440. AND a.first_level_user_id = #{firstUserId}
  441. </if>
  442. <if test="secondUserId != null and secondUserId != ''">
  443. AND a.two_level_user_id = #{secondUserId}
  444. </if>
  445. <if test="thirdUserId != null and thirdUserId != ''">
  446. AND a.three_level_user_id = #{thirdUserId}
  447. </if>
  448. <if test="id != null and id != ''">
  449. AND a.id = #{id}
  450. </if>
  451. </select>
  452. <select id="getAlreadyAuditOrders" resultType="com.ydtech.modules.order.entity.InsOrders">
  453. SELECT
  454. io.*,
  455. sd.management_source,
  456. su2.name AS auditUser,
  457. ifa.audittime as auditTime
  458. FROM
  459. ins_orders io
  460. LEFT JOIN ins_fee_audit ifa ON ifa.orderno = io.orderno
  461. LEFT JOIN sys_user su ON su.id = io.userid
  462. LEFT JOIN sys_dept sd ON sd.id = su.dept_id
  463. LEFT JOIN sys_user su2 on ifa.audituser = su2.id
  464. WHERE
  465. io.orderno IN (
  466. SELECT
  467. orderno
  468. FROM
  469. ins_area_company
  470. WHERE
  471. id IN (
  472. SELECT
  473. ifon.ins_order_no
  474. FROM
  475. ins_fee_order_new ifon
  476. RIGHT JOIN ins_fee_audit ifa ON ifon.ins_order_no = ifa.ins_order_no
  477. WHERE
  478. ifa.auditstatus = #{params.auditStatus}
  479. )
  480. )
  481. AND orderstatus = 3
  482. <!-- <if test="params.orderNo != null and params.orderNo != ''">-->
  483. <!-- AND orderno = #{params.orderNo}-->
  484. <!-- </if>-->
  485. <if test="params.licenseNo != null and params.licenseNo != ''">
  486. AND licenseno = #{params.licenseNo}
  487. </if>
  488. <if test="params.frameNo != null and params.frameNo != ''">
  489. AND frameno = #{params.frameNo}
  490. </if>
  491. <if test="params.insuredName != null and params.insuredName != ''">
  492. AND insuredname = #{params.insuredName}
  493. </if>
  494. <if test="params.companyId != null and params.companyId != ''">
  495. AND company_id = #{params.companyId}
  496. </if>
  497. <if test="params.startDateStr != null and params.startDateStr != ''">
  498. AND createtime BETWEEN #{params.startDateStr} and #{params.endDateStr}
  499. </if>
  500. </select>
  501. <select id="selectListByDateStr" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
  502. -- 查询订单信息
  503. SELECT
  504. iac.*
  505. FROM
  506. ins_area_company iac
  507. left JOIN ins_orders AS io ON io.orderno = iac.orderno
  508. WHERE
  509. 1=1
  510. <if test="dateStr != null and dateStr != ''">
  511. AND DATE_FORMAT(io.createtime, '%Y-%m') =#{dateStr}
  512. </if>
  513. </select>
  514. <select id="selectListById" resultMap="BaseResultMap">
  515. SELECT
  516. iac.*
  517. FROM
  518. ins_area_company iac
  519. WHERE
  520. 1=1
  521. <if test="id != null and id != ''">
  522. AND iac.id =#{id}
  523. </if>
  524. </select>
  525. <select id="selectSecondPromotionByNew" resultType="com.ydtech.modules.order.entity.InsOrders">
  526. SELECT
  527. sum( fee.p ) as "willFirstPremiums"
  528. FROM
  529. (
  530. SELECT
  531. sum( a.first_detail_premiums ) AS p
  532. FROM
  533. ins_fee_order_new a
  534. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  535. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  536. <where>
  537. <choose>
  538. <when test='type == "1"'>
  539. iff.auditstatus=0
  540. </when>
  541. <otherwise>
  542. iff.auditstatus=1
  543. </otherwise>
  544. </choose>
  545. and iac.orderstatus = '3'
  546. <if test="userId!=null and userId!= ''">
  547. AND a.first_level_user_id = #{userId}
  548. </if>
  549. <if test="id != null and id!=''">
  550. AND a.id =#{id}
  551. </if>
  552. </where>
  553. UNION
  554. SELECT
  555. sum( a.third_detail_premiums ) AS p
  556. FROM
  557. ins_fee_order_new a
  558. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  559. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  560. <where>
  561. <choose>
  562. <when test='type == "1"'>
  563. iff.auditstatus=0
  564. </when>
  565. <otherwise>
  566. iff.auditstatus=1
  567. </otherwise>
  568. </choose>
  569. and iac.orderstatus = '3'
  570. <if test="userId!=null and userId!= ''">
  571. AND a.three_level_user_id = #{userId}
  572. </if>
  573. <if test="id != null and id!=''">
  574. AND a.id =#{id}
  575. </if>
  576. </where>
  577. UNION
  578. SELECT
  579. sum( a.second_detail_premiums ) AS p
  580. FROM
  581. ins_fee_order_new a
  582. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  583. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  584. <where>
  585. <choose>
  586. <when test='type == "1"'>
  587. iff.auditstatus=0
  588. </when>
  589. <otherwise>
  590. iff.auditstatus=1
  591. </otherwise>
  592. </choose>
  593. and iac.orderstatus = '3'
  594. <if test="userId!=null and userId!= ''">
  595. AND a.two_level_user_id = #{userId}
  596. </if>
  597. <if test="id != null and id!=''">
  598. AND a.id =#{id}
  599. </if>
  600. </where>
  601. ) AS fee
  602. </select>
  603. <select id="getSubOrderDetails" resultType="com.ydtech.modules.admin.model.vo.SubOrder">
  604. SELECT iac.id as subOrderId,
  605. iac.signing_time as signingTime,
  606. iac.jqpremium as jqpremium,
  607. iac.sypremium as sypremium,
  608. iac.jypremium as jypremium,
  609. io.licenseno as licenseno,
  610. io.userid as userId
  611. FROM ins_area_company iac
  612. LEFT JOIN ins_orders AS io ON io.orderno = iac.orderno
  613. WHERE iac.id = #{subOrderId}
  614. </select>
  615. <select id="premiumReportYear" resultType="com.ydtech.modules.admin.model.dto.PremiumReportDto">
  616. SELECT CONCAT(YEAR(iac.createtime), '-', LPAD(MONTH(iac.createtime), 2, '0')) reportDate,
  617. sum(jqpremium) jqpremium,
  618. sum(sypremium) sypremium,
  619. sum(sumpremium) sumpremium
  620. FROM ins_area_company iac
  621. left join ins_orders io on iac.orderno = io.orderno
  622. WHERE iac.orderstatus = 3
  623. and iac.createtime &gt;= #{beginTime}
  624. and iac.createtime &lt;= #{endTime}
  625. and io.userid = #{userId}
  626. GROUP BY CONCAT(YEAR(iac.createtime), '-', LPAD(MONTH(iac.createtime), 2, '0'))
  627. </select>
  628. <select id="premiumReportMonth" resultType="com.ydtech.modules.admin.model.dto.PremiumReportDto">
  629. SELECT CONCAT(YEAR(iac.createtime), '-', LPAD(MONTH(iac.createtime), 2, '0'), '-',
  630. LPAD(Day(iac.createtime), 2, '0')) reportDate,
  631. sum(jqpremium) jqpremium,
  632. sum(sypremium) sypremium,
  633. sum(sumpremium) sumpremium
  634. FROM ins_area_company iac
  635. left join ins_orders io on iac.orderno = io.orderno
  636. WHERE iac.orderstatus = 3
  637. and iac.createtime &gt;= #{beginTime}
  638. and iac.createtime &lt;= #{endTime}
  639. and io.userid = #{userId}
  640. GROUP BY CONCAT(YEAR(iac.createtime), '-', LPAD(MONTH(iac.createtime), 2, '0'), '-',
  641. LPAD(Day(iac.createtime), 2, '0'))
  642. </select>
  643. <select id="premiumReportDay" resultType="com.ydtech.modules.admin.model.dto.PremiumReportDto">
  644. SELECT CONCAT(YEAR(iac.createtime), '-', LPAD(MONTH(iac.createtime), 2, '0'), '-',
  645. LPAD(DAY(iac.createtime), 2, '0'), ' ', LPAD(HOUR(iac.createtime), 2, '0'))
  646. reportDate,
  647. sum(jqpremium) jqpremium,
  648. sum(sypremium) sypremium,
  649. sum(sumpremium) sumpremium
  650. FROM ins_area_company iac
  651. left join ins_orders io on iac.orderno = io.orderno
  652. WHERE iac.orderstatus = 3
  653. and iac.createtime &gt;= #{beginTime}
  654. and iac.createtime &lt;= #{endTime}
  655. and io.userid = #{userId}
  656. GROUP BY CONCAT(YEAR(iac.createtime), '-', LPAD(MONTH(iac.createtime), 2, '0'), '-',
  657. LPAD(DAY(iac.createtime), 2, '0'), ' ', LPAD(HOUR(iac.createtime), 2, '0'))
  658. </select>
  659. <select id="getAllpremium" resultType="com.ydtech.modules.admin.model.dto.AllpremiumDto">
  660. SELECT ifnull(sum(iac.jqpremium + iac.sypremium + iac.jypremium), 0) as sumPremium,
  661. count(0) as sumCount
  662. FROM ins_area_company iac
  663. left join ins_orders io on iac.orderno = io.orderno
  664. WHERE iac.orderstatus = 3
  665. and io.userid = #{userId}
  666. AND YEAR(iac.createtime) = #{year}
  667. </select>
  668. <select id="getRejectOrder" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
  669. select
  670. iac.id,
  671. iac.orderno,
  672. iac.agreement_id,
  673. iac.jqpremium,
  674. iac.sypremium,
  675. iac.jypremium,
  676. iac.taxamount,
  677. iac.sumpremium,
  678. io.licenseno,
  679. ifa.audittime,
  680. ifa.audituser as auditname,
  681. ifa.rejectinfo,
  682. "1" as orderExternalStatus
  683. FROM
  684. ins_fee_audit ifa
  685. LEFT JOIN
  686. ins_area_company iac on iac.id = ifa.ins_order_no
  687. LEFT JOIN
  688. ins_orders io on iac.orderno = io.orderno
  689. left join
  690. sys_user su on su.id= ifa.audituser
  691. WHERE
  692. iac.operator_id = #{userId}
  693. AND
  694. ifa.auditstatus = 2 and IFNULL(iac.del_flag,'') != '0'
  695. <if test="vo.id != null and vo.id!=''">
  696. and iac.id = #{vo.id}
  697. </if>
  698. <if test="vo.licenseno != null and vo.licenseno!='' ">
  699. and io.licenseno like CONCAT('%', #{vo.licenseno}, '%')
  700. </if>
  701. <if test="vo.auditname != null and vo.auditname!='' ">
  702. and su.name like CONCAT('%', #{vo.auditname}, '%')
  703. </if>
  704. </select>
  705. <select id="queryBusinessDataPage"
  706. resultType="com.ydtech.modules.admin.model.report.opetationData.BusinessDataDto">
  707. SELECT
  708. <if test="flag != null and flag!='' and flag='1'">
  709. o.userid as userId,
  710. o.username as userName,
  711. </if>
  712. sum( iac.sumpremium ) as signeSumPremiumAmount,
  713. sum( iac.jqpremium ) as jqPremiumAmount,
  714. sum( iac.sypremium ) as syPremiumAmount,
  715. sum( iac.taxamount ) as taxAmount,
  716. sum( ion.no_premium ) as fcFeeAmount
  717. FROM
  718. ins_area_company iac
  719. LEFT JOIN ins_orders o ON iac.orderno = o.orderno
  720. LEFT JOIN ins_fee_order_new ion ON iac.id = ion.ins_order_no
  721. where iac.orderstatus = 3 and ion.id is not null
  722. <if test="userList != null and userList.size()>0 ">
  723. and o.userid IN
  724. <foreach item="item" collection="userList" open="(" separator="," close=")">
  725. #{item}
  726. </foreach>
  727. </if>
  728. <if test="flag != null and flag!='' and flag='1'">
  729. group by o.userid,o.username
  730. </if>
  731. </select>
  732. <select id="queryQuotationSubOrderCountDataPage"
  733. resultType="com.ydtech.modules.admin.model.report.opetationData.QuotationCountDataDto">
  734. SELECT
  735. <if test="flag != null and flag!='' and flag='1'">
  736. o.userid as userId,
  737. o.username as userName,
  738. </if>
  739. iac.orderstatus as orderStatus
  740. FROM
  741. ins_area_company iac
  742. LEFT JOIN ins_orders o ON iac.orderno = o.orderno
  743. where (iac.orderstatus = 0 or iac.orderstatus = 2 or iac.orderstatus = 3 )
  744. <if test="userList != null and userList.size()>0 ">
  745. and o.userid IN
  746. <foreach item="item" collection="userList" open="(" separator="," close=")">
  747. #{item}
  748. </foreach>
  749. </if>
  750. <if test="flag != null and flag!='' and flag='1'">
  751. group by o.userid,o.username,iac.orderstatus
  752. </if>
  753. </select>
  754. <select id="queryQuotationOrderCountDataPage"
  755. resultType="com.ydtech.modules.admin.model.report.opetationData.QuotationCountDataDto">
  756. SELECT
  757. a.userId as userId,
  758. a.userName as userName,
  759. b.qutationCount AS insOrderQutationCount,
  760. b.qutationInsureCount as insOrderQutationInsureCount,
  761. b.closeRate AS insOrderCloseRate as insOrderCloseRate,
  762. a.qutationCount as subOrderQutationCount,
  763. a.underwritingCount as subOrderUnderwritingCount,
  764. a.qutationInsureCount as subOrderQutationInsureCount,
  765. a.passRate as subOrderCloseRate,
  766. a.closeRate as subOrderPassRate,
  767. a.contributionRate as subOrderContributionRate
  768. FROM
  769. (
  770. SELECT
  771. inso.userid AS userId,
  772. inso.username AS userName,
  773. COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS qutationCount,
  774. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
  775. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  776. COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END )/ count( iac.orderstatus ) AS passRate,
  777. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )/ count( iac.orderstatus ) AS closeRate,
  778. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )/ COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS
  779. contributionRate
  780. FROM
  781. ins_area_company iac
  782. LEFT JOIN ins_orders inso ON iac.orderno = inso.orderno
  783. <where>
  784. <if test="userList != null and userList.size()>0 ">
  785. and o.userid IN
  786. <foreach item="item" collection="userList" open="(" separator="," close=")">
  787. #{item}
  788. </foreach>
  789. </if>
  790. </where>
  791. GROUP BY
  792. inso.userid,
  793. inso.username
  794. ) a
  795. LEFT JOIN (
  796. SELECT
  797. inso.userid AS userId,
  798. inso.username AS userName,
  799. count( inso.orderstatus ) AS qutationCount,
  800. count( CASE WHEN inso.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  801. COUNT( CASE WHEN inso.orderstatus = 3 THEN 1 END )/ count( inso.orderstatus ) AS closeRate
  802. FROM
  803. ins_orders inso
  804. <where>
  805. <if test="userList != null and userList.size()>0 ">
  806. and o.userid IN
  807. <foreach item="item" collection="userList" open="(" separator="," close=")">
  808. #{item}
  809. </foreach>
  810. </if>
  811. </where>
  812. GROUP BY
  813. inso.userid,
  814. inso.username
  815. ) b ON a.userId = b.userId
  816. </select>
  817. <select id="queryCompanyPremiumDataPage"
  818. resultType="com.ydtech.modules.admin.model.report.company.CompanyPremiumDataDto">
  819. SELECT
  820. agree.insurance_company_id AS companyId,
  821. agree.insurance_company AS companyName,
  822. agree.partner_companies_id AS parterCompanyId,
  823. ins.NAME AS parterCompanyName,
  824. sum( iac.sumpremium ) AS signeSumPremiumAmount
  825. FROM
  826. ins_area_company iac
  827. LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
  828. LEFT JOIN esm_ins_company ins ON agree.partner_companies_id = ins.id
  829. WHERE
  830. iac.orderstatus = 3
  831. and
  832. agree.id is not null
  833. <if test="vo.companyId != null and vo.companyId!='' ">
  834. agree.insurance_company_id = #{vo.companyId}
  835. </if>
  836. <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
  837. agree.insurance_company_id = #{vo.parterCompanyId}
  838. </if>
  839. GROUP BY
  840. agree.insurance_company_id,
  841. agree.insurance_company,
  842. agree.partner_companies_id,
  843. ins.NAME
  844. </select>
  845. <select id="queryCompanyQutationCountDataPage"
  846. resultType="com.ydtech.modules.admin.model.report.company.CompanyQutationCountDataDto">
  847. SELECT
  848. a.* ,
  849. (select ins.namesimple from esm_ins_company
  850. ins where a.parterCompanyId = ins.id) as "parterCompanyName"
  851. FROM
  852. (
  853. SELECT
  854. agree.insurance_company AS companyName,
  855. agree.partner_companies_id AS parterCompanyId,
  856. iac.company_id as "companyId",
  857. count( iac.orderstatus ) AS qutationCount,
  858. count( iac.id ) AS allNumber,
  859. count( CASE WHEN iac.orderstatus != '10' THEN 1 END ) AS orderSuccessNumber,
  860. count( CASE WHEN iac.orderstatus != '10' THEN 1 END ) / count( iac.id ) as "orderSuccessNumberRate",
  861. count( CASE WHEN iac.orderstatus = '10' THEN 1 END ) AS areaCompanyErrNumber,
  862. COUNT( CASE WHEN iac.orderstatus = '2' THEN 1 END ) + COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS
  863. underwritingCount,
  864. COUNT( CASE WHEN iac.orderstatus = '3' THEN 1 END ) AS qutationInsureCount,
  865. (COUNT( CASE WHEN iac.orderstatus = '2' THEN 1 END ) + COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )) /
  866. count( iac.orderstatus ) AS passRate,
  867. COUNT( CASE WHEN iac.orderstatus = '3' THEN 1 END ) / (COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) +
  868. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )) AS closeRate,
  869. COUNT( CASE WHEN iac.orderstatus = '3' THEN 1 END ) / count( iac.orderstatus ) AS contributionRate,
  870. COUNT(CASE WHEN agree.audit_type ='1' and ifa.auditstatus =1 and iac.orderstatus =3 THEN 1 END) as
  871. "numberManual"
  872. FROM
  873. ins_area_company iac
  874. LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
  875. LEFT JOIN ins_orders io ON iac.orderno = io.orderno
  876. LEFT JOIN sys_dept sd ON sd.id = io.deptid
  877. LEFT JOIN ins_fee_audit ifa on ifa.ins_order_no =iac.id
  878. WHERE
  879. agree.id IS NOT NULL
  880. and (iac.del_flag = '1' or io.del_flag IS NULL or io.del_flag = 1)
  881. <if test="vo.companyId != null and vo.companyId!='' ">
  882. AND agree.insurance_company_id = #{vo.companyId}
  883. </if>
  884. <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
  885. AND agree.partner_companies_id = #{vo.parterCompanyId}
  886. </if>
  887. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  888. AND iac.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  889. </if>
  890. <if test="vo.signingTimeStart !=null and vo.signingTimeStart != '' and vo.signingTimeEnd !=null and vo.signingTimeEnd != ''">
  891. AND iac.signing_time BETWEEN #{vo.signingTimeStart} AND #{vo.signingTimeEnd}
  892. </if>
  893. <if test="vo.managementSource != null and vo.managementSource!=''">
  894. AND sd.management_source =#{vo.managementSource}
  895. </if>
  896. <if test="vo.userId != null and vo.userId !=''">
  897. AND io.userid =#{vo.userId}
  898. </if>
  899. <if test="vo.deptId != null and vo.deptId !=''">
  900. AND io.deptId like concat('%',#{vo.deptId},'%')
  901. </if>
  902. <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
  903. AND sd.id in
  904. <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
  905. #{item}
  906. </foreach>
  907. </if>
  908. <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
  909. AND iac.leader_id in
  910. <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
  911. #{item}
  912. </foreach>
  913. </if>
  914. GROUP BY
  915. agree.insurance_company,
  916. iac.company_id,
  917. agree.partner_companies_id
  918. ) a
  919. order by a.parterCompanyId
  920. </select>
  921. <select id="quotationDetailsExcel" resultType="com.ydtech.modules.admin.model.dto.QuotationDetailsExcel">
  922. select
  923. iac.id as "orderno",
  924. io.orderno as "bigOrderno",
  925. iac.agreement_id as "agreementId",
  926. iac.orderstatus as "orderstatus",
  927. iac.company_id as "companyId",
  928. agree.partner_companies_id as "partnerCompaniesId",
  929. ins.namesimple as "partnerCompaniesName",
  930. agree.insurance_company as "inscompany",
  931. iac.jqpolicyno as "jqpolicyno",
  932. iac.sypolicyno as "sypolicyno",
  933. iac.sumpremium as "sumpremium",
  934. iac.jqpremium as "jqpremium",
  935. iac.sypremium as "sypremium",
  936. iac.jypremium as "jypremium",
  937. iac.createtime as "createtime",
  938. iac.signing_time as "signingTime",
  939. sd.management_source as "managementSource",
  940. agree.audit_type as "auditType",
  941. ifa.auditstatus as "auditstatus",
  942. io.licenseno as "licenseno",
  943. su1.name as "userName",
  944. su1.leader_name as "leaderName"
  945. from
  946. ins_area_company iac
  947. LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
  948. LEFT JOIN ins_orders io ON iac.orderno = io.orderno
  949. LEFT JOIN sys_user su1 on su1.id=io.userid
  950. LEFT JOIN sys_dept sd ON sd.id = io.deptid
  951. LEFT JOIN ins_fee_audit ifa on ifa.ins_order_no = iac.id
  952. LEFT JOIN esm_ins_company ins ON agree.partner_companies_id = ins.id
  953. <where>
  954. agree.id IS NOT NULL
  955. and (iac.del_flag = '1' or io.del_flag IS NULL or io.del_flag = 1)
  956. <if test="vo.companyId != null and vo.companyId!='' ">
  957. AND agree.insurance_company_id = #{vo.companyId}
  958. </if>
  959. <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
  960. AND agree.partner_companies_id = #{vo.parterCompanyId}
  961. </if>
  962. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  963. AND iac.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  964. </if>
  965. <if test="vo.managementSource != null and vo.managementSource!=''">
  966. AND sd.management_source =#{vo.managementSource}
  967. </if>
  968. <if test="vo.userId != null and vo.userId !=''">
  969. AND io.userid =#{vo.userId}
  970. </if>
  971. <if test="vo.deptId != null and vo.deptId !=''">
  972. AND io.deptId like concat('%',#{vo.deptId},'%')
  973. </if>
  974. <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
  975. AND sd.id in
  976. <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
  977. #{item}
  978. </foreach>
  979. </if>
  980. <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
  981. AND io.userid in
  982. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  983. #{item}
  984. </foreach>
  985. </if>
  986. </where>
  987. </select>
  988. <select id="getInsAreaCompanyError"
  989. resultType="com.ydtech.modules.admin.model.report.company.CompanyQutationCountDataDto">
  990. SELECT
  991. count(iace.id) as "areaCompanyErrNumber"
  992. FROM
  993. ins_area_company_error iace
  994. LEFT JOIN ptl_agreement agree ON iace.agreement_id = agree.id
  995. <where>
  996. 1=1
  997. <if test="vo.companyId != null and vo.companyId!='' ">
  998. AND agree.insurance_company_id = #{vo.companyId}
  999. </if>
  1000. <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
  1001. AND agree.partner_companies_id = #{vo.parterCompanyId}
  1002. </if>
  1003. <if test="vo.userId != null and vo.userId!=''">
  1004. AND iace.user_id =#{vo.userId}
  1005. </if>
  1006. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  1007. AND iace.create_time BETWEEN #{vo.beginDate} AND #{vo.endDate}
  1008. </if>
  1009. <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
  1010. AND iace.dept_id in
  1011. <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
  1012. #{item}
  1013. </foreach>
  1014. </if>
  1015. <if test="vo.deptId != null and vo.deptId !=''">
  1016. AND iace.dept_id like concat('%',#{vo.deptId},'%')
  1017. </if>
  1018. <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
  1019. AND iace.user_id in
  1020. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  1021. #{item}
  1022. </foreach>
  1023. </if>
  1024. </where>
  1025. </select>
  1026. <select id="queryCompanyQutationCountDataPageTotal"
  1027. resultType="java.lang.Long">
  1028. SELECT
  1029. count(0)
  1030. FROM
  1031. (
  1032. SELECT
  1033. agree.partner_companies_id
  1034. FROM
  1035. ins_area_company iac
  1036. LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
  1037. LEFT JOIN ins_orders io ON iac.orderno = io.orderno
  1038. LEFT JOIN sys_dept sd ON sd.id = io.deptid
  1039. WHERE
  1040. agree.id IS NOT NULL
  1041. and (iac.del_flag = '1' or io.del_flag IS NULL or io.del_flag = 1)
  1042. <if test="vo.companyId != null and vo.companyId!='' ">
  1043. AND agree.insurance_company_id = #{vo.companyId}
  1044. </if>
  1045. <if test="vo.signingTimeStart !=null and vo.signingTimeStart != '' and vo.signingTimeEnd !=null and vo.signingTimeEnd != ''">
  1046. AND DATE_FORMAT( iac.signing_time, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{vo.signingTimeStart}, '%Y-%m-%d') AND
  1047. DATE_FORMAT( #{vo.signingTimeEnd}, '%Y-%m-%d')
  1048. </if>
  1049. <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
  1050. AND agree.partner_companies_id = #{vo.parterCompanyId}
  1051. </if>
  1052. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  1053. AND iac.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  1054. </if>
  1055. <if test="vo.managementSource != null and vo.managementSource!=''">
  1056. AND sd.management_source =#{vo.managementSource}
  1057. </if>
  1058. <if test="vo.userId != null and vo.userId !=''">
  1059. AND io.userid =#{vo.userId}
  1060. </if>
  1061. <if test="vo.deptId != null and vo.deptId !=''">
  1062. AND io.deptId like concat('%',#{vo.deptId},'%')
  1063. </if>
  1064. <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
  1065. AND sd.id in
  1066. <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
  1067. #{item}
  1068. </foreach>
  1069. </if>
  1070. <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
  1071. AND io.userid in
  1072. <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
  1073. #{item}
  1074. </foreach>
  1075. </if>
  1076. GROUP BY
  1077. agree.partner_companies_id
  1078. ) a
  1079. </select>
  1080. <select id="getStageOrder" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
  1081. select
  1082. iac.id,
  1083. iac.orderno,
  1084. iac.agreement_id,
  1085. iac.jqpremium,
  1086. iac.sypremium,
  1087. iac.jypremium,
  1088. iac.taxamount,
  1089. iac.sumpremium,
  1090. io.licenseno,
  1091. iac.createtime,
  1092. "0" as orderExternalStatus
  1093. FROM
  1094. ins_area_company iac
  1095. LEFT JOIN
  1096. ins_orders io on iac.orderno = io.orderno
  1097. left join ptl_agreement agree on iac.agreement_id =agree.id
  1098. WHERE
  1099. iac.operator_id = #{userId}
  1100. AND
  1101. iac.orderstatus = 0
  1102. and agree.is_external =1
  1103. AND
  1104. io.del_flag is null
  1105. <if test="vo.id != null and vo.id!='' ">
  1106. and iac.id = #{vo.id}
  1107. </if>
  1108. <if test="vo.licenseno != null and vo.licenseno!='' ">
  1109. and io.licenseno like CONCAT('%', #{vo.licenseno}, '%')
  1110. </if>
  1111. </select>
  1112. <select id="queryPageTaskStatistics" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  1113. select a.*,
  1114. su.name as "userName",
  1115. inf.url as "logo",
  1116. sui.sex as "sex",
  1117. su.leader_name as "leaderName",
  1118. su2.mobile as "leaderMobile"
  1119. from (
  1120. SELECT
  1121. sd.NAME AS "deptName",
  1122. io.userid AS "userId",
  1123. sd.parent_id as "deptId",
  1124. sd.management_source as "managementSource",
  1125. COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS qutationCount,
  1126. COUNT( CASE WHEN iot.order_status ='2' THEN 1 END ) AS underwritingCount,
  1127. COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) AS qutationInsureCount,
  1128. COUNT( CASE WHEN iot.order_status = '4' THEN 1 END ) AS underwritingReturn,
  1129. COUNT( CASE WHEN iot.order_status ='2' THEN 1 END ) / COUNT( CASE WHEN iot.order_status ='0' THEN 1 END ) AS
  1130. "passingRate",
  1131. COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) / COUNT( CASE WHEN iot.order_status in
  1132. ('0','1','2','3','4') THEN 1 END ) AS "closeRate",
  1133. (COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) + COUNT( CASE WHEN iot.order_status = '2' THEN 1 END ))/
  1134. COUNT(CASE WHEN iot.order_status in ('0','1','2','3','4') THEN 1 END) AS "contributionRate",
  1135. COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) / COUNT(CASE WHEN iot.order_status in ('0','1','2','3','4')
  1136. THEN 1 END ) AS "quotationRate",
  1137. COUNT(CASE WHEN io.order_source = 0 and iot.order_status ='0' THEN 1 END) as "pcOrderSource",
  1138. COUNT(CASE WHEN io.order_source = 1 and iot.order_status ='0' THEN 1 END) as "appOrderSource",
  1139. COUNT(CASE WHEN iac.entry_status = '2' THEN 1 END) as "sumEntryStatus",
  1140. COUNT( CASE WHEN iot.order_status = '1' THEN 1 END ) AS "auditOrder"
  1141. FROM
  1142. (
  1143. select iot.suborder,iot.order_status from `ins_orders_track` iot
  1144. left join ins_area_company iac ON iac.id = iot.suborder
  1145. where true
  1146. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1147. AND iac.createtime BETWEEN #{taskStatisticsVo.beginDate} AND #{taskStatisticsVo.endDate}
  1148. </if>
  1149. <if test="taskStatisticsVo.signingTimeStart !=null and taskStatisticsVo.signingTimeStart != '' and taskStatisticsVo.signingTimeEnd !=null and taskStatisticsVo.signingTimeEnd != ''">
  1150. AND iac.signing_time BETWEEN #{taskStatisticsVo.signingTimeStart} AND #{taskStatisticsVo.signingTimeEnd},
  1151. </if>
  1152. GROUP BY iot.suborder ,iot.order_status
  1153. ) iot
  1154. left join ins_area_company iac ON iac.id = iot.suborder
  1155. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  1156. LEFT JOIN sys_dept sd ON sd.id = io.deptid
  1157. <where>
  1158. sd.management_source = '1'
  1159. and (iac.del_flag = '1' or io.del_flag IS NULL or io.del_flag = 1)
  1160. <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
  1161. and io.deptid like "${taskStatisticsVo.provinceId}%"
  1162. </if>
  1163. <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
  1164. and io.deptid like "${taskStatisticsVo.cityId}%"
  1165. </if>
  1166. <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
  1167. and io.deptid like "${taskStatisticsVo.countyId}%"
  1168. </if>
  1169. <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
  1170. and io.deptid like "${taskStatisticsVo.houseId}%"
  1171. </if>
  1172. <if test="taskStatisticsVo.userId != null and taskStatisticsVo.userId != ''">
  1173. and io.userid =#{taskStatisticsVo.userId}
  1174. </if>
  1175. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1176. AND io.createtime BETWEEN #{taskStatisticsVo.createtimeStart} AND
  1177. #{taskStatisticsVo.createtimeEnd}
  1178. </if>
  1179. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1180. AND iac.createtime BETWEEN #{taskStatisticsVo.beginDate} AND #{taskStatisticsVo.endDate}
  1181. </if>
  1182. <if test="taskStatisticsVo.signingTimeStart !=null and taskStatisticsVo.signingTimeStart != '' and taskStatisticsVo.signingTimeEnd !=null and taskStatisticsVo.signingTimeEnd != ''">
  1183. AND iac.signing_time BETWEEN #{taskStatisticsVo.signingTimeStart} AND
  1184. #{taskStatisticsVo.signingTimeEnd},
  1185. </if>
  1186. <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
  1187. AND sd.id in
  1188. <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
  1189. #{item}
  1190. </foreach>
  1191. </if>
  1192. <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
  1193. AND io.userid in
  1194. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  1195. #{item}
  1196. </foreach>
  1197. </if>
  1198. </where>
  1199. GROUP BY
  1200. io.userid,
  1201. sd.NAME,
  1202. sd.id,
  1203. sd.management_source
  1204. ) a
  1205. left join sys_user su on su.id =a.userId
  1206. LEFT JOIN ins_upload_files inf on su.head_sculpture =inf.id
  1207. LEFT JOIN sys_user_info sui on sui .id =su.id
  1208. LEFT JOIN sys_user su2 on su2.id =su.leader_id
  1209. <where>
  1210. <if test='taskStatisticsVo.userName !=null and taskStatisticsVo.userName!="" '>
  1211. and su.name like concat('%',#{taskStatisticsVo.userName},'%')
  1212. </if>
  1213. <!-- <if test='taskStatisticsVo.leaderId !=null and taskStatisticsVo.leaderId!="" '>-->
  1214. <!-- and su.leader_id =#{taskStatisticsVo.leaderId}-->
  1215. <!-- </if>-->
  1216. <if test="taskStatisticsVo.leaderIds != null and taskStatisticsVo.leaderIds != '' and taskStatisticsVo.leaderIds.size() > 0">
  1217. AND su.leader_id in
  1218. <foreach collection="taskStatisticsVo.leaderIds" item="item" open="(" separator="," close=")">
  1219. #{item}
  1220. </foreach>
  1221. </if>
  1222. <if test='taskStatisticsVo.userId !=null and taskStatisticsVo.userId!="" '>
  1223. and su.id =#{taskStatisticsVo.userId}
  1224. </if>
  1225. </where>
  1226. </select>
  1227. <select id="queryPageElectric" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  1228. select a.*, su.name as "userName",
  1229. inf.url as "logo",
  1230. sui.sex as "sex",
  1231. su.leader_name as "leaderName",
  1232. su2.mobile as "leaderMobile"
  1233. from (
  1234. SELECT
  1235. sd.NAME AS "deptName",
  1236. io.userid AS "userId",
  1237. sd.parent_id as "deptId",
  1238. sd.management_source as "managementSource",
  1239. COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS qutationCount,
  1240. COUNT( CASE WHEN iot.order_status ='2' THEN 1 END ) AS underwritingCount,
  1241. COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) AS qutationInsureCount,
  1242. COUNT( CASE WHEN iot.order_status = '4' THEN 1 END ) AS underwritingReturn,
  1243. COUNT( CASE WHEN iot.order_status = '2' THEN 1 END ) / COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS
  1244. "passingRate",
  1245. COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) / COUNT( CASE WHEN iot.order_status in
  1246. ('0','1','2','3','4') THEN 1 END) AS "closeRate",
  1247. (COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) + COUNT( CASE WHEN iot.order_status = '2' THEN 1 END ))/
  1248. COUNT(CASE WHEN iot.order_status in ('0','1','2','3','4') THEN 1 END) AS "contributionRate",
  1249. COUNT( CASE WHEN iot.order_status ='0' THEN 1 END ) / COUNT(CASE WHEN iot.order_status in ('0','1','2','3','4')
  1250. THEN 1 END ) AS "quotationRate",
  1251. COUNT(CASE WHEN io.order_source = 0 and iot.order_status = '0' THEN 1 END) as "pcOrderSource",
  1252. COUNT(CASE WHEN io.order_source = 1 and iot.order_status = '0' THEN 1 END) as "appOrderSource",
  1253. COUNT( CASE WHEN iot.order_status ='1' THEN 1 END ) AS "auditOrder"
  1254. FROM
  1255. (
  1256. select iot.suborder,iot.order_status from `ins_orders_track` iot
  1257. left join ins_area_company iac ON iac.id = iot.suborder
  1258. where true
  1259. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1260. AND iac.createtime BETWEEN #{taskStatisticsVo.beginDate} AND #{taskStatisticsVo.endDate}
  1261. </if>
  1262. <if test="taskStatisticsVo.signingTimeStart !=null and taskStatisticsVo.signingTimeStart != '' and taskStatisticsVo.signingTimeEnd !=null and taskStatisticsVo.signingTimeEnd != ''">
  1263. AND iac.signing_time BETWEEN #{taskStatisticsVo.signingTimeStart} AND #{taskStatisticsVo.signingTimeEnd},
  1264. </if>
  1265. GROUP BY iot.suborder ,iot.order_status
  1266. ) iot
  1267. left join ins_area_company iac ON iac.id = iot.suborder
  1268. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  1269. LEFT JOIN sys_dept sd ON sd.id = io.deptid
  1270. <where>
  1271. sd.management_source = '3'
  1272. and (iac.del_flag = '1' or io.del_flag IS NULL or io.del_flag = 1)
  1273. <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
  1274. and io.deptid like "${taskStatisticsVo.provinceId}%"
  1275. </if>
  1276. <if test="taskStatisticsVo.signingTimeStart !=null and taskStatisticsVo.signingTimeStart != '' and taskStatisticsVo.signingTimeEnd !=null and taskStatisticsVo.signingTimeEnd != ''">
  1277. iac.signing_time BETWEEN #{taskStatisticsVo.signingTimeStart} AND #{taskStatisticsVo.signingTimeEnd}
  1278. </if>
  1279. <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
  1280. and io.deptid like "${taskStatisticsVo.cityId}%"
  1281. </if>
  1282. <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
  1283. and io.deptid like "${taskStatisticsVo.countyId}%"
  1284. </if>
  1285. <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
  1286. and io.deptid like "${taskStatisticsVo.houseId}%"
  1287. </if>
  1288. <if test="taskStatisticsVo.userId != null and taskStatisticsVo.userId != ''">
  1289. and io.userid =#{taskStatisticsVo.userId}
  1290. </if>
  1291. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1292. AND io.createtime BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
  1293. </if>
  1294. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1295. AND iac.createtime BETWEEN #{taskStatisticsVo.beginDate} AND #{taskStatisticsVo.endDate}
  1296. </if>
  1297. <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
  1298. AND sd.id in
  1299. <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
  1300. #{item}
  1301. </foreach>
  1302. </if>
  1303. <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
  1304. AND io.userid in
  1305. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  1306. #{item}
  1307. </foreach>
  1308. </if>
  1309. </where>
  1310. GROUP BY
  1311. io.userid,
  1312. sd.NAME,
  1313. sd.id,
  1314. sd.management_source
  1315. ) a
  1316. left join sys_user su on su.id =a.userId
  1317. LEFT JOIN ins_upload_files inf on su.head_sculpture =inf.id
  1318. LEFT JOIN sys_user_info sui on sui .id =su.id
  1319. LEFT JOIN sys_user su2 on su2.id =su.leader_id
  1320. <where>
  1321. <if test='taskStatisticsVo.userName !=null and taskStatisticsVo.userName!="" '>
  1322. and su.name like concat('%',#{taskStatisticsVo.userName},'%')
  1323. </if>
  1324. <!-- <if test='taskStatisticsVo.leaderId !=null and taskStatisticsVo.leaderId!="" '>-->
  1325. <!-- and su.leader_id =#{taskStatisticsVo.leaderId}-->
  1326. <!-- </if>-->
  1327. <if test="taskStatisticsVo.leaderIds != null and taskStatisticsVo.leaderIds != '' and taskStatisticsVo.leaderIds.size() > 0">
  1328. AND su.leader_id in
  1329. <foreach collection="taskStatisticsVo.leaderIds" item="item" open="(" separator="," close=")">
  1330. #{item}
  1331. </foreach>
  1332. </if>
  1333. <if test='taskStatisticsVo.userId !=null and taskStatisticsVo.userId!="" '>
  1334. and su.id =#{taskStatisticsVo.userId}
  1335. </if>
  1336. </where>
  1337. </select>
  1338. <select id="queryPageElectricTotal" resultType="java.lang.Long">
  1339. select count(0) from (
  1340. SELECT
  1341. io.userid
  1342. FROM
  1343. ins_area_company iac
  1344. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  1345. LEFT JOIN sys_dept sd ON sd.id = io.deptid
  1346. <where>
  1347. sd.management_source = '3'
  1348. <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
  1349. and io.deptid like "${taskStatisticsVo.provinceId}%"
  1350. </if>
  1351. <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
  1352. and io.deptid like "${taskStatisticsVo.cityId}%"
  1353. </if>
  1354. <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
  1355. and io.deptid like "${taskStatisticsVo.countyId}%"
  1356. </if>
  1357. <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
  1358. and io.deptid like "${taskStatisticsVo.houseId}%"
  1359. </if>
  1360. <if test="taskStatisticsVo.leaderIds != null and taskStatisticsVo.leaderIds != '' and taskStatisticsVo.leaderIds.size() > 0">
  1361. AND su.leader_id in
  1362. <foreach collection="taskStatisticsVo.leaderIds" item="item" open="(" separator="," close=")">
  1363. #{item}
  1364. </foreach>
  1365. </if>
  1366. <if test="taskStatisticsVo.signingTimeStart !=null and taskStatisticsVo.signingTimeStart != '' and taskStatisticsVo.signingTimeEnd !=null and taskStatisticsVo.signingTimeEnd != ''">
  1367. AND iac.signing_time BETWEEN #{taskStatisticsVo.signingTimeStart} AND #{taskStatisticsVo.signingTimeEnd}
  1368. </if>
  1369. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1370. AND io.createtime BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
  1371. </if>
  1372. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1373. AND iac.createtime BETWEEN #{taskStatisticsVo.beginDate} AND #{taskStatisticsVo.endDate}
  1374. </if>
  1375. <if test="taskStatisticsVo.userId != null and taskStatisticsVo.userId != ''">
  1376. and io.userid =#{taskStatisticsVo.userId}
  1377. </if>
  1378. <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
  1379. AND sd.id in
  1380. <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
  1381. #{item}
  1382. </foreach>
  1383. </if>
  1384. <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
  1385. AND io.userid in
  1386. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  1387. #{item}
  1388. </foreach>
  1389. </if>
  1390. </where>
  1391. GROUP BY
  1392. io.userid
  1393. ) a
  1394. </select>
  1395. <select id="queryPageTaskStatisticsTotal" resultType="java.lang.Long">
  1396. select count(0) from (
  1397. SELECT
  1398. io.userid
  1399. FROM
  1400. ins_area_company iac
  1401. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  1402. LEFT JOIN sys_dept sd ON sd.id = io.deptid
  1403. left join sys_user su on su.id = io.userid
  1404. <where>
  1405. sd.management_source = '1'
  1406. and (iac.del_flag = '1' or io.del_flag IS NULL or io.del_flag = 1)
  1407. <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
  1408. and io.deptid like "${taskStatisticsVo.provinceId}%"
  1409. </if>
  1410. <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
  1411. and io.deptid like "${taskStatisticsVo.cityId}%"
  1412. </if>
  1413. <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
  1414. and io.deptid like "${taskStatisticsVo.countyId}%"
  1415. </if>
  1416. <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
  1417. and io.deptid like "${taskStatisticsVo.houseId}%"
  1418. </if>
  1419. <if test="taskStatisticsVo.signingTimeStart !=null and taskStatisticsVo.signingTimeStart != '' and taskStatisticsVo.signingTimeEnd !=null and taskStatisticsVo.signingTimeEnd != ''">
  1420. AND iac.signing_time BETWEEN #{taskStatisticsVo.signingTimeStart} AND #{taskStatisticsVo.signingTimeEnd}
  1421. </if>
  1422. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1423. AND io.createtime BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
  1424. </if>
  1425. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1426. AND iac.createtime BETWEEN #{taskStatisticsVo.beginDate} AND #{taskStatisticsVo.endDate}
  1427. </if>
  1428. <if test="taskStatisticsVo.userId != null and taskStatisticsVo.userId != ''">
  1429. and io.userid =#{taskStatisticsVo.userId}
  1430. </if>
  1431. <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
  1432. AND sd.id in
  1433. <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
  1434. #{item}
  1435. </foreach>
  1436. </if>
  1437. <if test="taskStatisticsVo.leaderIds != null and taskStatisticsVo.leaderIds != '' and taskStatisticsVo.leaderIds.size() > 0">
  1438. AND su.leader_id in
  1439. <foreach collection="taskStatisticsVo.leaderIds" item="item" open="(" separator="," close=")">
  1440. #{item}
  1441. </foreach>
  1442. </if>
  1443. <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
  1444. AND io.userid in
  1445. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  1446. #{item}
  1447. </foreach>
  1448. </if>
  1449. </where>
  1450. GROUP BY
  1451. io.userid
  1452. ) a
  1453. </select>
  1454. <select id="insuranceCompanyQueryPage" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  1455. select
  1456. a.*,
  1457. ( SELECT eic.namesimple FROM esm_ins_company eic WHERE eic.id = a.partner_companies_id ) AS
  1458. "partnerCompaniesName"
  1459. FROM
  1460. (
  1461. SELECT
  1462. pa.insurance_company_id,
  1463. pa.partner_companies_id,
  1464. pa.insurance_company AS "insuranceCompanyName",
  1465. COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS qutationCount,
  1466. COUNT( CASE WHEN iot.order_status = '1' THEN 1 END ) AS "auditOrder",
  1467. COUNT( CASE WHEN iot.order_status = '2' THEN 1 END ) AS underwritingCount,
  1468. COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) AS qutationInsureCount,
  1469. COUNT( CASE WHEN iot.order_status = '4' THEN 1 END ) AS underwritingReturn,
  1470. COUNT( CASE WHEN iot.order_status ='2' THEN 1 END ) / COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS
  1471. "passingRate",
  1472. COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) / COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS
  1473. "closeRate",
  1474. (COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) + COUNT( CASE WHEN iot.order_status = '2' THEN 1 END )) /
  1475. COUNT( iot.order_status ) AS "contributionRate",
  1476. COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) / COUNT( iot.order_status ) AS "quotationRate"
  1477. FROM
  1478. (
  1479. select iot.suborder,iot.order_status from `ins_orders_track` iot
  1480. left join ins_area_company iac ON iac.id = iot.suborder
  1481. where true
  1482. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1483. AND iac.createtime BETWEEN #{taskStatisticsVo.beginDate} AND #{taskStatisticsVo.endDate}
  1484. </if>
  1485. <if test="taskStatisticsVo.signingTimeStart !=null and taskStatisticsVo.signingTimeStart != '' and taskStatisticsVo.signingTimeEnd !=null and taskStatisticsVo.signingTimeEnd != ''">
  1486. AND iac.signing_time BETWEEN #{taskStatisticsVo.signingTimeStart} AND #{taskStatisticsVo.signingTimeEnd},
  1487. </if>
  1488. GROUP BY iot.suborder ,iot.order_status
  1489. ) iot
  1490. LEFT JOIN ins_area_company iac ON iac.id = iot.suborder
  1491. LEFT JOIN ins_fee_audit ifa ON ifa.ins_order_no = iac.id
  1492. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  1493. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  1494. <where>
  1495. pa.insurance_company_id IS NOT NULL
  1496. and (iac.del_flag = '1' or io.del_flag IS NULL or io.del_flag = 1)
  1497. <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
  1498. and io.deptid like concat('%', #{taskStatisticsVo.provinceId}, '%')
  1499. </if>
  1500. <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
  1501. and io.deptid like concat('%', #{taskStatisticsVo.cityId}, '%')
  1502. </if>
  1503. <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
  1504. and io.deptid like concat('%', #{taskStatisticsVo.countyId}, '%')
  1505. </if>
  1506. <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
  1507. and io.deptid like concat('%', #{taskStatisticsVo.houseId}, '%')
  1508. </if>
  1509. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1510. AND iac.createtime BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
  1511. </if>
  1512. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1513. AND iac.createtime BETWEEN #{taskStatisticsVo.beginDate} AND #{taskStatisticsVo.endDate}
  1514. </if>
  1515. <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId != ''">
  1516. AND iac.company_id =#{taskStatisticsVo.companyId}
  1517. </if>
  1518. <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
  1519. AND io.deptid in
  1520. <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
  1521. #{item}
  1522. </foreach>
  1523. </if>
  1524. <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
  1525. AND io.userid in
  1526. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  1527. #{item}
  1528. </foreach>
  1529. </if>
  1530. </where>
  1531. GROUP BY
  1532. pa.insurance_company_id,
  1533. pa.partner_companies_id,
  1534. pa.insurance_company
  1535. ) a
  1536. </select>
  1537. <select id="insuranceCompanyQueryTotal" resultType="java.lang.Long">
  1538. SELECT
  1539. COUNT(0)
  1540. FROM
  1541. (
  1542. SELECT
  1543. pa.insurance_company_id,
  1544. pa.partner_companies_id
  1545. FROM
  1546. ins_area_company iac
  1547. LEFT JOIN ins_fee_audit ifa ON ifa.ins_order_no = iac.id
  1548. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  1549. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  1550. <where>
  1551. pa.insurance_company_id IS NOT NULL
  1552. and (iac.del_flag = '1' or io.del_flag IS NULL or io.del_flag = 1)
  1553. <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
  1554. and io.deptid like concat('%', #{taskStatisticsVo.provinceId}, '%')
  1555. </if>
  1556. <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
  1557. and io.deptid like concat('%', #{taskStatisticsVo.cityId}, '%')
  1558. </if>
  1559. <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
  1560. and io.deptid like concat('%', #{taskStatisticsVo.countyId}, '%')
  1561. </if>
  1562. <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId != ''">
  1563. AND iac.company_id =#{taskStatisticsVo.companyId}
  1564. </if>
  1565. <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
  1566. and io.deptid like concat('%', #{taskStatisticsVo.houseId}, '%')
  1567. </if>
  1568. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1569. AND iac.createtime BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
  1570. </if>
  1571. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1572. AND iac.createtime BETWEEN #{taskStatisticsVo.beginDate} AND #{taskStatisticsVo.endDate}
  1573. </if>
  1574. <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
  1575. AND io.deptid in
  1576. <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
  1577. #{item}
  1578. </foreach>
  1579. </if>
  1580. <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
  1581. AND io.userid in
  1582. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  1583. #{item}
  1584. </foreach>
  1585. </if>
  1586. </where>
  1587. GROUP BY
  1588. pa.insurance_company_id,
  1589. pa.partner_companies_id
  1590. ) total
  1591. </select>
  1592. <select id="agentStatisticsQueryPage" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  1593. SELECT
  1594. sd.name AS "deptName",
  1595. su.name AS "userName",
  1596. io.userid AS "userId",
  1597. sd.id AS "deptId",
  1598. suLeader.name AS "leaderName",
  1599. suLeader.mobile AS "leaderMobile",
  1600. sd.management_source AS "managementSource",
  1601. COUNT(CASE WHEN iot.order_status = '0' THEN 1 END) AS qutationCount,
  1602. COUNT(CASE WHEN iot.order_status = '2' THEN 1 END) AS underwritingCount,
  1603. COUNT(CASE WHEN iot.order_status = '3' THEN 1 END) AS qutationInsureCount,
  1604. COUNT(CASE WHEN iot.order_status = '4' THEN 1 END) AS underwritingReturn,
  1605. COUNT(CASE WHEN iot.order_status = '2' THEN 1 END) / COUNT(CASE WHEN iot.order_status IN ('0', '1', '2', '3',
  1606. '4') THEN 1 END) AS "passingRate",
  1607. COUNT(CASE WHEN iot.order_status = '3' THEN 1 END) / COUNT(CASE WHEN iot.order_status = '0' THEN 1 END) AS
  1608. "closeRate",
  1609. COUNT(CASE WHEN iot.order_status = '3' THEN 1 END) / COUNT(CASE WHEN iot.order_status IN ('0', '1', '2', '3',
  1610. '4') THEN 1 END) AS "contributionRate",
  1611. COUNT(CASE WHEN iot.order_status = '0' THEN 1 END) / COUNT(CASE WHEN iot.order_status IN ('0', '1', '2', '3',
  1612. '4') THEN 1 END) AS "quotationRate",
  1613. COUNT(CASE WHEN iot.order_status = '1' THEN 1 END) AS "auditOrder"
  1614. FROM
  1615. (
  1616. SELECT iot.suborder, iot.order_status
  1617. FROM ins_orders_track iot
  1618. LEFT JOIN ins_area_company iac ON iac.id = iot.suborder
  1619. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  1620. LEFT JOIN sys_dept sd ON sd.id = io.deptid
  1621. LEFT JOIN sys_user su ON su.id = io.userid
  1622. WHERE
  1623. sd.management_source = '2'
  1624. AND (iac.del_flag = '1' OR io.del_flag IS NULL OR io.del_flag = 1)
  1625. <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
  1626. AND io.deptid LIKE '${taskStatisticsVo.provinceId}%'
  1627. </if>
  1628. <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
  1629. AND io.deptid LIKE '${taskStatisticsVo.cityId}%'
  1630. </if>
  1631. <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
  1632. AND io.deptid LIKE '${taskStatisticsVo.countyId}%'
  1633. </if>
  1634. <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
  1635. AND io.deptid LIKE '${taskStatisticsVo.houseId}%'
  1636. </if>
  1637. <if test="taskStatisticsVo.userId != null and taskStatisticsVo.userId != ''">
  1638. AND io.userid = #{taskStatisticsVo.userId}
  1639. </if>
  1640. <if test="taskStatisticsVo.userName != null and taskStatisticsVo.userName != ''">
  1641. AND su.name LIKE CONCAT('%', #{taskStatisticsVo.userName}, '%')
  1642. </if>
  1643. <if test="taskStatisticsVo.leaderId != null and taskStatisticsVo.leaderId != ''">
  1644. AND su.leader_id = #{taskStatisticsVo.leaderId}
  1645. </if>
  1646. <if test="taskStatisticsVo.leaderIds != null and taskStatisticsVo.leaderIds != '' and taskStatisticsVo.leaderIds.size() > 0">
  1647. AND su.leader_id IN
  1648. <foreach collection="taskStatisticsVo.leaderIds" item="item" open="(" separator="," close=")">
  1649. #{item}
  1650. </foreach>
  1651. </if>
  1652. <if test="taskStatisticsVo.createtimeStart != null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd != null and taskStatisticsVo.createtimeEnd != ''">
  1653. AND io.createtime BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
  1654. </if>
  1655. <if test="taskStatisticsVo.beginDate != null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate != null and taskStatisticsVo.endDate != ''">
  1656. AND iac.createtime BETWEEN #{taskStatisticsVo.beginDate} AND #{taskStatisticsVo.endDate}
  1657. </if>
  1658. <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
  1659. AND sd.id in ( select dept_id from sys_user_dept_relationship where user_id
  1660. =#{taskStatisticsVo.relationUserId} )
  1661. </if>
  1662. <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
  1663. AND io.userid IN
  1664. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  1665. #{item}
  1666. </foreach>
  1667. </if>
  1668. GROUP BY iot.suborder, iot.order_status
  1669. ) iot
  1670. LEFT JOIN ins_area_company iac ON iac.id = iot.suborder
  1671. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  1672. LEFT JOIN sys_dept sd ON sd.id = io.deptid
  1673. LEFT JOIN sys_user su ON su.id = io.userid
  1674. LEFT JOIN sys_user suLeader ON suLeader.id = su.leader_id
  1675. GROUP BY io.userid, su.name, sd.id, sd.name, suLeader.name, suLeader.mobile, sd.management_source
  1676. </select>
  1677. <select id="agentStatisticsQueryPageTotal" resultType="java.lang.Long">
  1678. select count(0) from (
  1679. SELECT
  1680. io.userid as "userId"
  1681. FROM
  1682. ins_area_company iac
  1683. left join ins_orders io on io.orderno = iac.orderno
  1684. left join sys_dept sd on sd.id=io.deptid
  1685. left join sys_user su on su.id=io.userid
  1686. <where>
  1687. sd.management_source = '2'
  1688. and (iac.del_flag = '1' or io.del_flag IS NULL or io.del_flag = 1)
  1689. <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
  1690. and io.deptid like "${taskStatisticsVo.provinceId}%"
  1691. </if>
  1692. <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
  1693. and io.deptid like "${taskStatisticsVo.cityId}%"
  1694. </if>
  1695. <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
  1696. and io.deptid like "${taskStatisticsVo.countyId}%"
  1697. </if>
  1698. <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
  1699. and io.deptid like "${taskStatisticsVo.houseId}%"
  1700. </if>
  1701. <if test='taskStatisticsVo.userName !=null and taskStatisticsVo.userName!="" '>
  1702. and su.name like concat('%',#{taskStatisticsVo.userName},'%')
  1703. </if>
  1704. <!-- <if test='taskStatisticsVo.leaderId !=null and taskStatisticsVo.leaderId!="" '>-->
  1705. <!-- and su.leader_id =#{taskStatisticsVo.leaderId}-->
  1706. <!-- </if>-->
  1707. <if test="taskStatisticsVo.leaderIds != null and taskStatisticsVo.leaderIds != '' and taskStatisticsVo.leaderIds.size() > 0">
  1708. AND su.leader_id in
  1709. <foreach collection="taskStatisticsVo.leaderIds" item="item" open="(" separator="," close=")">
  1710. #{item}
  1711. </foreach>
  1712. </if>
  1713. <if test='taskStatisticsVo.userId !=null and taskStatisticsVo.userId!="" '>
  1714. and su.id =#{taskStatisticsVo.userId}
  1715. </if>
  1716. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1717. io.createtime BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
  1718. </if>
  1719. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1720. AND iac.createtime BETWEEN #{taskStatisticsVo.beginDate} AND #{taskStatisticsVo.endDate}
  1721. </if>
  1722. <if test="taskStatisticsVo.userId !=null and taskStatisticsVo.userId!='' ">
  1723. and io.userid =#{taskStatisticsVo.userId}
  1724. </if>
  1725. </where>
  1726. GROUP BY io.userid
  1727. ) a
  1728. </select>
  1729. <select id="costCenter" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  1730. SELECT
  1731. iac.company_id,
  1732. iac.inscompany as "insuranceCompanyName",
  1733. COUNT( CASE WHEN ifa.auditstatus = 1 THEN 1 END ) AS "auditstatusOrders",
  1734. COUNT( CASE WHEN ifa.auditstatus = 0 THEN 1 END ) AS "auditOrder",
  1735. COUNT( CASE WHEN ifa.auditstatus = 1 and ifa.audituser != '自动审核' THEN 1 END ) AS "persionAudit",
  1736. COUNT( CASE WHEN ifa.audituser = '自动审核' THEN 1 END ) AS "automaticAudit"
  1737. FROM
  1738. ins_fee_audit ifa
  1739. LEFT JOIN ins_orders io ON io.orderno = ifa.orderno
  1740. LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
  1741. AND iac.orderstatus = 3
  1742. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  1743. LEFT JOIN esm_ins_company eic ON eic.id = pa.partner_companies_id
  1744. left join sys_user su on su.id =ifa.audituser
  1745. <where>
  1746. 1=1
  1747. and iac.id = ifa.ins_order_no
  1748. AND iac.orderstatus = 3
  1749. and (iac.del_flag = '1' or io.del_flag IS NULL or io.del_flag = 1)
  1750. <if test="taskStatisticsVo.reviewer !=null and taskStatisticsVo.reviewer !=''">
  1751. and su.name =#{taskStatisticsVo.reviewer}
  1752. </if>
  1753. <if test="taskStatisticsVo.audittime !=null and taskStatisticsVo.audittime !=''">
  1754. and ifa.audittime =#{taskStatisticsVo.audittime}
  1755. </if>
  1756. <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId !=''">
  1757. and iac.company_id =#{taskStatisticsVo.companyId}
  1758. </if>
  1759. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1760. AND iac.signing_time BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
  1761. </if>
  1762. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1763. AND iac.signing_time BETWEEN #{taskStatisticsVo.beginDate} AND #{taskStatisticsVo.endDate}
  1764. </if>
  1765. <if test="taskStatisticsVo.auditTimeStart !=null and taskStatisticsVo.auditTimeEnd != '' and taskStatisticsVo.auditTimeStart !=null and taskStatisticsVo.auditTimeEnd != ''">
  1766. AND ifa.audittime BETWEEN #{taskStatisticsVo.auditTimeStart} AND #{taskStatisticsVo.auditTimeEnd}
  1767. </if>
  1768. <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
  1769. AND io.deptid in
  1770. <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
  1771. #{item}
  1772. </foreach>
  1773. </if>
  1774. <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
  1775. AND su.id in
  1776. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  1777. #{item}
  1778. </foreach>
  1779. </if>
  1780. <choose>
  1781. <when test="taskStatisticsVo.riskCode != null and taskStatisticsVo.riskCode != '' and taskStatisticsVo.riskCode != 'all' ">
  1782. and iac.product = #{taskStatisticsVo.riskCode}
  1783. </when>
  1784. </choose>
  1785. </where>
  1786. GROUP BY
  1787. iac.company_id,
  1788. iac.inscompany
  1789. </select>
  1790. <select id="costCenterDetails" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  1791. SELECT
  1792. ifa.audituser as "audituser",
  1793. su.name as "audituserName",
  1794. su.mobile as "audituserMobile",
  1795. iac.inscompany as "insuranceCompanyName",
  1796. COUNT( CASE WHEN ifa.auditstatus = 1 THEN 1 END ) AS "auditstatusOrders",
  1797. COUNT( CASE WHEN ifa.auditstatus = 0 THEN 1 END ) AS "auditOrder"
  1798. FROM
  1799. ins_fee_audit ifa
  1800. LEFT JOIN ins_orders io ON io.orderno = ifa.orderno
  1801. LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
  1802. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  1803. LEFT JOIN esm_ins_company eic ON eic.id = pa.partner_companies_id
  1804. left join sys_user su on su.id =ifa.audituser
  1805. <where>
  1806. 1=1
  1807. and iac.id = ifa.ins_order_no
  1808. AND iac.orderstatus = 3
  1809. and (iac.del_flag = '1' or io.del_flag IS NULL or io.del_flag = 1)
  1810. AND (ifa.auditstatus ='1' or ifa.auditstatus ='0')
  1811. <if test="taskStatisticsVo.reviewer !=null and taskStatisticsVo.reviewer !=''">
  1812. and su.name =#{taskStatisticsVo.reviewer}
  1813. </if>
  1814. <if test="taskStatisticsVo.auditTimeStart !=null and taskStatisticsVo.auditTimeEnd != '' and taskStatisticsVo.auditTimeStart !=null and taskStatisticsVo.auditTimeEnd != ''">
  1815. AND DATE_FORMAT( ifa.audittime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.auditTimeStart},
  1816. '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.auditTimeEnd}, '%Y-%m-%d')
  1817. </if>
  1818. <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId !=''">
  1819. and iac.company_id =#{taskStatisticsVo.companyId}
  1820. </if>
  1821. <if test="taskStatisticsVo.audittime !=null and taskStatisticsVo.audittime !=''">
  1822. and ifa.audittime =#{taskStatisticsVo.audittime}
  1823. </if>
  1824. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1825. AND DATE_FORMAT( ifa.audittime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.createtimeStart},
  1826. '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.createtimeEnd}, '%Y-%m-%d')
  1827. </if>
  1828. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1829. AND DATE_FORMAT( iac.signing_time, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate},
  1830. '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
  1831. </if>
  1832. <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
  1833. AND io.deptid in
  1834. <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
  1835. #{item}
  1836. </foreach>
  1837. </if>
  1838. <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
  1839. AND su.id in
  1840. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  1841. #{item}
  1842. </foreach>
  1843. </if>
  1844. <choose>
  1845. <when test="taskStatisticsVo.riskCode != null and taskStatisticsVo.riskCode != '' and taskStatisticsVo.riskCode != 'all' ">
  1846. and iac.product = #{taskStatisticsVo.riskCode}
  1847. </when>
  1848. </choose>
  1849. </where>
  1850. GROUP BY
  1851. ifa.audituser,su.name,su.mobile,iac.inscompany
  1852. </select>
  1853. <select id="costCenterDetailsExcel" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDtoExcel">
  1854. SELECT
  1855. ifa.audituser as "audituser",
  1856. su.name as "audituserName",
  1857. su.mobile as "audituserMobile",
  1858. iac.inscompany as "insuranceCompanyName",
  1859. COUNT( CASE WHEN ifa.auditstatus = 1 THEN 1 END ) AS "auditstatusOrders",
  1860. COUNT( CASE WHEN ifa.auditstatus = 0 THEN 1 END ) AS "auditOrder"
  1861. FROM
  1862. ins_fee_audit ifa
  1863. LEFT JOIN ins_orders io ON io.orderno = ifa.orderno
  1864. LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
  1865. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  1866. LEFT JOIN esm_ins_company eic ON eic.id = pa.partner_companies_id
  1867. left join sys_user su on su.id =ifa.audituser
  1868. <where>
  1869. 1=1
  1870. and iac.id = ifa.ins_order_no
  1871. AND iac.orderstatus = 3
  1872. AND ifa.audituser != '自动审核'
  1873. AND (ifa.auditstatus ='1' or ifa.auditstatus ='0')
  1874. <if test="taskStatisticsVo.reviewer !=null and taskStatisticsVo.reviewer !=''">
  1875. and su.name =#{taskStatisticsVo.reviewer}
  1876. </if>
  1877. <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId !=''">
  1878. and iac.company_id =#{taskStatisticsVo.companyId}
  1879. </if>
  1880. <if test="taskStatisticsVo.audittime !=null and taskStatisticsVo.audittime !=''">
  1881. and ifa.audittime =#{taskStatisticsVo.audittime}
  1882. </if>
  1883. <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId !=''">
  1884. and iac.company_id =#{taskStatisticsVo.companyId}
  1885. </if>
  1886. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1887. AND ifa.audittime BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
  1888. </if>
  1889. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1890. AND iac.signing_time BETWEEN #{taskStatisticsVo.beginDate} AND #{taskStatisticsVo.endDate}
  1891. </if>
  1892. <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
  1893. AND io.deptid in
  1894. <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
  1895. #{item}
  1896. </foreach>
  1897. </if>
  1898. <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
  1899. AND su.id in
  1900. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  1901. #{item}
  1902. </foreach>
  1903. </if>
  1904. <choose>
  1905. <when test="taskStatisticsVo.riskCode != null and taskStatisticsVo.riskCode != '' and taskStatisticsVo.riskCode != 'all' ">
  1906. and iac.product = #{taskStatisticsVo.riskCode}
  1907. </when>
  1908. </choose>
  1909. </where>
  1910. GROUP BY
  1911. ifa.audituser,su.name,su.mobile,iac.inscompany
  1912. </select>
  1913. <select id="costCenterDetailsLicense" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  1914. SELECT
  1915. io.licenseno as "licenseno",
  1916. iot.createTime as "createTime",
  1917. ifa.audittime as "auditTime",
  1918. IFNULL(TIMESTAMPDIFF(SECOND, iot.createTime, ifa.audittime),0) as "timeDifference"
  1919. FROM
  1920. ins_fee_audit ifa
  1921. LEFT JOIN ins_orders io ON io.orderno = ifa.orderno
  1922. LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
  1923. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  1924. LEFT JOIN esm_ins_company eic ON eic.id = pa.partner_companies_id
  1925. left join (
  1926. SELECT
  1927. suborder AS "suborder",
  1928. min(create_time) AS "createTime"
  1929. FROM
  1930. ins_orders_track iot_
  1931. WHERE
  1932. order_status =3
  1933. GROUP BY
  1934. suborder
  1935. ) iot on iot.suborder = iac.id
  1936. left join sys_user su on su.id =ifa.audituser
  1937. <where>
  1938. 1=1
  1939. and iac.id = ifa.ins_order_no
  1940. AND iac.orderstatus = 3
  1941. AND (ifa.auditstatus ='1' or ifa.auditstatus ='0')
  1942. <if test="taskStatisticsVo.reviewer !=null and taskStatisticsVo.reviewer !=''">
  1943. and su.name =#{taskStatisticsVo.reviewer}
  1944. </if>
  1945. <if test="taskStatisticsVo.audituser !=null and taskStatisticsVo.audituser !=''">
  1946. and ifa.audituser =#{taskStatisticsVo.audituser}
  1947. </if>
  1948. <if test="taskStatisticsVo.reviewType ==null">
  1949. AND ifa.audituser != '自动审核'
  1950. </if>
  1951. <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId !=''">
  1952. and iac.company_id =#{taskStatisticsVo.companyId}
  1953. </if>
  1954. <if test="taskStatisticsVo.audittime !=null and taskStatisticsVo.audittime !=''">
  1955. and ifa.audittime =#{taskStatisticsVo.audittime}
  1956. </if>
  1957. <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId !=''">
  1958. and iac.company_id =#{taskStatisticsVo.companyId}
  1959. </if>
  1960. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1961. AND DATE_FORMAT( ifa.audittime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.createtimeStart},
  1962. '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.createtimeEnd}, '%Y-%m-%d')
  1963. </if>
  1964. <if test="taskStatisticsVo.auditTimeStart !=null and taskStatisticsVo.auditTimeEnd != '' and taskStatisticsVo.auditTimeStart !=null and taskStatisticsVo.auditTimeEnd != ''">
  1965. AND DATE_FORMAT( ifa.audittime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.auditTimeStart},
  1966. '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.auditTimeEnd}, '%Y-%m-%d')
  1967. </if>
  1968. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1969. AND DATE_FORMAT( iac.signing_time, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate},
  1970. '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
  1971. </if>
  1972. <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
  1973. AND io.deptid in
  1974. <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
  1975. #{item}
  1976. </foreach>
  1977. </if>
  1978. <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
  1979. AND su.id in
  1980. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  1981. #{item}
  1982. </foreach>
  1983. </if>
  1984. <choose>
  1985. <when test="taskStatisticsVo.riskCode != null and taskStatisticsVo.riskCode != '' and taskStatisticsVo.riskCode != 'all' ">
  1986. and iac.product = #{taskStatisticsVo.riskCode}
  1987. </when>
  1988. </choose>
  1989. </where>
  1990. </select>
  1991. <select id="costCenterSecond" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDtoNew">
  1992. SELECT
  1993. IFNULL(count(io.licenseno),0) as "orderNumber",
  1994. IFNULL(sum(TIMESTAMPDIFF(SECOND, iot.createTime, ifa.audittime)),0) as "sumSecond",
  1995. ROUND(IFNULL(sum(TIMESTAMPDIFF(SECOND, iot.createTime, ifa.audittime)),0) / count(io.licenseno),2) as
  1996. "averageSecond"
  1997. FROM
  1998. ins_fee_audit ifa
  1999. LEFT JOIN ins_orders io ON io.orderno = ifa.orderno
  2000. LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
  2001. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  2002. LEFT JOIN esm_ins_company eic ON eic.id = pa.partner_companies_id
  2003. left join sys_user su on su.id =ifa.audituser
  2004. left join (
  2005. SELECT
  2006. suborder AS "suborder",
  2007. min(create_time) AS "createTime"
  2008. FROM
  2009. ins_orders_track iot_
  2010. WHERE
  2011. order_status =3
  2012. GROUP BY
  2013. suborder
  2014. ) iot on iot.suborder = iac.id
  2015. <where>
  2016. 1=1
  2017. and iac.id = ifa.ins_order_no
  2018. AND iac.orderstatus = 3
  2019. AND ifa.audituser != '自动审核'
  2020. AND (ifa.auditstatus ='1' or ifa.auditstatus ='0')
  2021. <if test="taskStatisticsVo.reviewer !=null and taskStatisticsVo.reviewer !=''">
  2022. and su.name =#{taskStatisticsVo.reviewer}
  2023. </if>
  2024. <if test="taskStatisticsVo.audituser !=null and taskStatisticsVo.audituser !=''">
  2025. and ifa.audituser =#{taskStatisticsVo.audituser}
  2026. </if>
  2027. <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId !=''">
  2028. and iac.company_id =#{taskStatisticsVo.companyId}
  2029. </if>
  2030. <if test="taskStatisticsVo.auditTimeStart !=null and taskStatisticsVo.auditTimeEnd != '' and taskStatisticsVo.auditTimeStart !=null and taskStatisticsVo.auditTimeEnd != ''">
  2031. AND DATE_FORMAT( ifa.audittime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.auditTimeStart},
  2032. '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.auditTimeEnd}, '%Y-%m-%d')
  2033. </if>
  2034. <if test="taskStatisticsVo.audittime !=null and taskStatisticsVo.audittime !=''">
  2035. and ifa.audittime =#{taskStatisticsVo.audittime}
  2036. </if>
  2037. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  2038. AND DATE_FORMAT( ifa.audittime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.createtimeStart},
  2039. '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.createtimeEnd}, '%Y-%m-%d')
  2040. </if>
  2041. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  2042. AND DATE_FORMAT( iac.signing_time, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate},
  2043. '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
  2044. </if>
  2045. <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
  2046. AND io.deptid in
  2047. <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
  2048. #{item}
  2049. </foreach>
  2050. </if>
  2051. <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
  2052. AND su.id in
  2053. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  2054. #{item}
  2055. </foreach>
  2056. </if>
  2057. <choose>
  2058. <when test="taskStatisticsVo.riskCode != null and taskStatisticsVo.riskCode != '' and taskStatisticsVo.riskCode != 'all' ">
  2059. and iac.product = #{taskStatisticsVo.riskCode}
  2060. </when>
  2061. </choose>
  2062. </where>
  2063. </select>
  2064. <select id="getOrderManpower" resultType="com.ydtech.modules.admin.model.dto.QxFrontlineAgentDto">
  2065. SELECT
  2066. count( a.numberUserId ) as "orderManpower",
  2067. sum( a.orderAmount ) as "totalPremium",
  2068. sum( a.orderAmount )/ count( a.numberUserId ) as "averagePremium"
  2069. FROM
  2070. (
  2071. SELECT
  2072. count( io.userid ) AS "numberUserId",
  2073. SUM(IFNULL(iac.jqpremium, 0)) +
  2074. SUM(IFNULL(iac.sypremium, 0)) +
  2075. SUM(IFNULL(iac.jypremium, 0)) AS "orderAmount"
  2076. FROM
  2077. `ins_area_company` iac
  2078. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  2079. <where>
  2080. iac.orderstatus = '3'
  2081. <if test="ids != null and ids.size()>0 ">
  2082. AND io.userid IN
  2083. <foreach item="item" collection="ids" open="(" separator="," close=")">
  2084. #{item}
  2085. </foreach>
  2086. </if>
  2087. </where>
  2088. GROUP BY
  2089. io.userid
  2090. ) a
  2091. </select>
  2092. <select id="getOrderManpowerNew" resultType="com.ydtech.modules.admin.model.dto.QxFrontlineAgentDto">
  2093. SELECT
  2094. count( a.numberUserId ) as "orderManpower",
  2095. IFNULL(sum( a.orderAmount ),0) as "totalPremium",
  2096. ROUND(sum( a.orderAmount )/ sum(a.ordernoNumber),2) AS "averagePremium"
  2097. FROM
  2098. (
  2099. SELECT
  2100. count( io.userid ) AS "numberUserId",
  2101. count( iac.orderno ) AS "ordernoNumber",
  2102. SUM(IFNULL(iac.jqpremium, 0)
  2103. +IFNULL(iac.sypremium, 0)
  2104. +IFNULL(iac.jypremium, 0)
  2105. ) AS "orderAmount"
  2106. FROM
  2107. `ins_area_company` iac
  2108. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  2109. <where>
  2110. iac.orderstatus = '3'
  2111. and (iac.del_flag = '1' or io.del_flag IS NULL or io.del_flag = 1)
  2112. <if test="vo.ids != null and vo.ids.size()>0 ">
  2113. AND io.userid IN
  2114. <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
  2115. #{item}
  2116. </foreach>
  2117. </if>
  2118. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  2119. AND iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
  2120. </if>
  2121. </where>
  2122. GROUP BY
  2123. io.userid
  2124. ) a
  2125. <where>
  2126. <if test="vo.outThere != null and vo.outThere!=''">
  2127. <choose>
  2128. <when test=" vo.outThere == 0">
  2129. AND IFNULL(a.orderAmount,0) = 0
  2130. </when>
  2131. <when test="vo.outThere == 1">
  2132. AND IFNULL(a.orderAmount,0) > 0
  2133. </when>
  2134. </choose>
  2135. </if>
  2136. </where>
  2137. order by sum( a.orderAmount ) desc
  2138. </select>
  2139. <select id="getChannelOrderManpowerNew" resultType="com.ydtech.modules.admin.model.dto.QxFrontlineAgentDto">
  2140. SELECT
  2141. a.userId as "userId",
  2142. a.userName as "name",
  2143. a.orderNumber as "orderNumber",
  2144. a.underwritingCount as "underwritingCount",
  2145. a.qutationInsureCount as "qutationInsureCount",
  2146. IFNULL(a.jqpremium,0) + IFNULL(a.sypremium,0) + IFNULL(a.jypremium,0) as "totalPremium",
  2147. a.isFactorVerify as "isFactorVerify",
  2148. a.isNotFactorVerify as "isNotFactorVerify"
  2149. FROM
  2150. (
  2151. SELECT
  2152. io.userid as "userId",
  2153. io.username as "userName",
  2154. count( iac.orderno ) AS "orderNumber",
  2155. sum(CASE WHEN iac.orderstatus = 3 THEN iac.jqpremium END ) AS jqpremium,
  2156. sum(CASE WHEN iac.orderstatus = 3 THEN iac.sypremium END ) AS sypremium,
  2157. sum(CASE WHEN iac.orderstatus = 3 THEN iac.jypremium END ) AS jypremium,
  2158. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
  2159. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  2160. COUNT( CASE WHEN su.factor_verify = 1 THEN 1 END ) AS isFactorVerify,
  2161. COUNT( CASE WHEN su.factor_verify = 0 THEN 1 END ) AS isNotFactorVerify
  2162. FROM
  2163. `ins_area_company` iac
  2164. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  2165. left join sys_user su on su.id=io.userid
  2166. <where>
  2167. (iac.del_flag = '1' or io.del_flag IS NULL or io.del_flag = 1)
  2168. <if test="vo.ids != null and vo.ids.size()>0 ">
  2169. AND io.userid IN
  2170. <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
  2171. #{item}
  2172. </foreach>
  2173. </if>
  2174. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  2175. AND iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
  2176. </if>
  2177. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  2178. AND iac.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  2179. </if>
  2180. <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
  2181. AND io.deptid in
  2182. <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
  2183. #{item}
  2184. </foreach>
  2185. </if>
  2186. <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
  2187. AND io.userid in
  2188. <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
  2189. #{item}
  2190. </foreach>
  2191. </if>
  2192. </where>
  2193. GROUP BY
  2194. io.userid,
  2195. io.username
  2196. ) a
  2197. left join sys_user su on su.id=a.userId
  2198. </select>
  2199. <select id="NumberQuotations" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  2200. SELECT
  2201. count(iac.id) as "orderNumber",
  2202. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
  2203. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  2204. sum( CASE WHEN iac.orderstatus = 3 THEN IFNULL(iac.jqpremium, 0) + IFNULL(iac.sypremium, 0) +
  2205. IFNULL(iac.jypremium, 0) END ) AS totalPremium
  2206. FROM
  2207. ins_area_company iac
  2208. left join ins_orders io on io.orderno = iac.orderno
  2209. left join sys_dept sd on sd.id=io.deptid
  2210. left join sys_user su on su.id=io.userid
  2211. left join ins_fee_audit ifa on ifa .ins_order_no =iac.id
  2212. <where>
  2213. sd.management_source = '2'
  2214. <if test="userId !=null and userId !=''">
  2215. and io.userId =#{userId}
  2216. </if>
  2217. </where>
  2218. </select>
  2219. <select id="totalQuotation" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  2220. SELECT
  2221. agree.insurance_company_id AS companyId,
  2222. agree.insurance_company AS companyName,
  2223. agree.partner_companies_id AS parterCompanyId,
  2224. ins.namesimple AS parterCompanyName,
  2225. count(iac.orderstatus) AS orderNumber,
  2226. '-' as bigQutationCount,
  2227. '-' as bigUnderwritingCount,
  2228. '-' as bigCloseRate,
  2229. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
  2230. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  2231. COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END )/ count(iac.orderstatus) AS passRate,
  2232. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END )/ count(iac.orderstatus) AS underwritingCountRate,
  2233. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )/ count(iac.orderstatus) AS closeRate,
  2234. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )/ COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS
  2235. contributionRate
  2236. FROM
  2237. ins_area_company iac
  2238. LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
  2239. LEFT JOIN ins_orders io on io.orderno = iac.orderno
  2240. LEFT JOIN esm_ins_company ins ON agree.partner_companies_id = ins.id
  2241. WHERE
  2242. agree.id IS NOT NULL
  2243. <if test="vo.companyId != null and vo.companyId!='' ">
  2244. agree.insurance_company_id = #{vo.companyId}
  2245. </if>
  2246. <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
  2247. agree.partner_companies_id = #{vo.parterCompanyId}
  2248. </if>
  2249. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  2250. AND iac.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  2251. </if>
  2252. <if test="vo.provinceId != null and vo.provinceId != ''">
  2253. and io.deptid like "${vo.provinceId}%"
  2254. </if>
  2255. <if test="vo.cityId != null and vo.cityId != ''">
  2256. and io.deptid like "${vo.cityId}%"
  2257. </if>
  2258. <if test="vo.countyId != null and vo.countyId != ''">
  2259. and io.deptid like "${vo.countyId}%"
  2260. </if>
  2261. <if test="taskStatisticsVo.houseId != null and vo.houseId != ''">
  2262. and io.deptid like "${vo.houseId}%"
  2263. </if>
  2264. GROUP BY
  2265. agree.insurance_company_id,
  2266. agree.insurance_company,
  2267. agree.partner_companies_id,
  2268. ins.NAME
  2269. </select>
  2270. <select id="getBusinessData" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  2271. select
  2272. a.dockingPerson as "dockingPerson",
  2273. a.dockingPhone as "dockingPhone",
  2274. a.agreementType as "agreementType",
  2275. a.logo as "logo",
  2276. a.companyId as "companyId",
  2277. a.insuranceCompanyName as "insuranceCompanyName",
  2278. a.parterCompanyId as "parterCompanyId",
  2279. a.partnerCompaniesName as "partnerCompaniesName",
  2280. sum(a.totalPremium) as "totalPremium",
  2281. sum(a.qutationInsureCount) as "qutationInsureCount",
  2282. ROUND(sum(a.totalPremium) / sum(a.qutationInsureCount), 2) AS "averagePremium",
  2283. ROUND(sum(a.totalPremium) / sum(a.userNumber),2) as "perCapitaAmount",
  2284. sum(a.userNumber) as "userNumber"
  2285. from (
  2286. select
  2287. a.companyId as "companyId",
  2288. a.insuranceCompanyName as "insuranceCompanyName",
  2289. a.parterCompanyId as "parterCompanyId",
  2290. a.partnerCompaniesName as "partnerCompaniesName",
  2291. a.totalPremium as "totalPremium",
  2292. a.qutationInsureCount as "qutationInsureCount",
  2293. a.userNumber as "userNumber",
  2294. c.docking_person as "dockingPerson",
  2295. c.docking_phone as "dockingPhone",
  2296. c.agreement_type as "agreementType",
  2297. b.logo as "logo"
  2298. from (
  2299. SELECT
  2300. agree.insurance_company_id AS "companyId",
  2301. agree.insurance_company AS "insuranceCompanyName",
  2302. agree.partner_companies_id AS "parterCompanyId",
  2303. ins.namesimple AS "partnerCompaniesName",
  2304. agree.id as "agreeId",
  2305. IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0) as "totalPremium",
  2306. COUNT(0 ) AS "qutationInsureCount",
  2307. (IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0)) / COUNT(0 ) AS
  2308. "averagePremium",
  2309. COUNT(DISTINCT io.userId) AS "userNumber",
  2310. (IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0)) / COUNT(DISTINCT
  2311. io.userId) as "perCapitaAmount"
  2312. FROM
  2313. ins_area_company iac
  2314. LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
  2315. LEFT JOIN ins_orders io on io.orderno = iac.orderno
  2316. LEFT JOIN sys_user su on io.userid =su.id
  2317. LEFT JOIN ins_fee_audit ifa on ifa.ins_order_no =iac.id
  2318. LEFT JOIN esm_ins_company ins ON agree.partner_companies_id = ins.id
  2319. WHERE
  2320. agree.id IS NOT NULL
  2321. and iac.orderstatus = '3'
  2322. and ifa.auditstatus != '2'
  2323. and (iac.del_flag = '1' or io.del_flag IS NULL or io.del_flag = 1)
  2324. <if test="vo.companyId != null and vo.companyId!='' ">
  2325. and agree.insurance_company_id = #{vo.companyId}
  2326. </if>
  2327. <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
  2328. and agree.partner_companies_id = #{vo.parterCompanyId}
  2329. </if>
  2330. <if test="vo.signingTimeStart != null and vo.signingTimeStart!='' and vo.signingTimeEnd != null and vo.signingTimeEnd != ''">
  2331. AND iac.signing_time BETWEEN #{vo.signingTimeStart} AND #{vo.signingTimeEnd}
  2332. </if>
  2333. <if test="vo.enterTimeStart != null and vo.enterTimeStart!='' and vo.enterTimeEnd != null and vo.enterTimeEnd != ''">
  2334. AND iac.createtime BETWEEN #{vo.enterTimeStart} AND #{vo.enterTimeEnd}
  2335. </if>
  2336. <if test="vo.leaderName != null and vo.leaderName!='' ">
  2337. AND iac.leader_name = #{vo.leaderName}
  2338. </if>
  2339. <if test="vo.provinceId != null and vo.provinceId != '' and vo.cityId == null and vo.countyId == null and vo.houseId == null ">
  2340. and io.deptid like concat('%',#{vo.provinceId},'%')
  2341. </if>
  2342. <if test="vo.cityId != null and vo.cityId != '' and vo.countyId ==null and vo.houseId ==null">
  2343. and io.deptid like concat('%',#{vo.cityId},'%')
  2344. </if>
  2345. <if test="vo.countyId != null and vo.countyId != '' and vo.houseId ==null">
  2346. and io.deptid like concat('%',#{vo.countyId},'%')
  2347. </if>
  2348. <if test="vo.houseId != null and vo.houseId != ''">
  2349. and io.deptid like concat('%',#{vo.houseId},'%')
  2350. </if>
  2351. <if test="vo.parterProvinceId != null and vo.parterProvinceId != '' and vo.parterCityId == null and vo.parterCountyId == null ">
  2352. and agree.partner_companies_id like concat('%',#{vo.parterProvinceId},'%')
  2353. </if>
  2354. <if test="vo.parterCityId != null and vo.parterCityId != '' and vo.parterCountyId ==null ">
  2355. and agree.partner_companies_id like concat('%',#{vo.parterCityId},'%')
  2356. </if>
  2357. <if test="vo.parterCountyId != null and vo.parterCountyId != '' ">
  2358. and agree.partner_companies_id like concat('%',#{vo.parterCountyId},'%')
  2359. </if>
  2360. <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
  2361. AND io.deptid in
  2362. <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
  2363. #{item}
  2364. </foreach>
  2365. </if>
  2366. <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
  2367. AND su.leader_id in
  2368. <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
  2369. #{item}
  2370. </foreach>
  2371. </if>
  2372. GROUP BY
  2373. agree.insurance_company_id,
  2374. agree.insurance_company,
  2375. agree.partner_companies_id,
  2376. agree.id
  2377. <choose>
  2378. <when test="vo.orderSort != null and vo.orderSort != '' and vo.userNumberSort == null ">
  2379. order by
  2380. sum(sumpremium) ${vo.orderSort == 'asc' ? 'asc' : 'desc'}
  2381. </when>
  2382. <when test="vo.userNumberSort != null and vo.userNumberSort != '' and vo.orderSort == null ">
  2383. order by
  2384. COUNT(DISTINCT io.userId) ${vo.userNumberSort == 'asc' ? 'asc' : 'desc'}
  2385. </when>
  2386. <when test="vo.userNumberSort != null and vo.userNumberSort != '' and vo.orderSort != null and vo.orderSort != '' ">
  2387. order by
  2388. COUNT(DISTINCT io.userId) ${vo.userNumberSort == 'asc' ? 'asc' : 'desc'}, sum(sumpremium)
  2389. ${vo.orderSort == 'asc' ? 'asc' : 'desc'}
  2390. </when>
  2391. </choose>
  2392. ) a
  2393. left join esm_ins_company b on b.id =a.companyId
  2394. left join ptl_agreement c on c.id =a.agreeId
  2395. ) a
  2396. group by
  2397. a.companyId,a.insuranceCompanyName,a.parterCompanyId,a.partnerCompaniesName,a.logo,a.dockingPerson,a.dockingPhone,a.agreementType
  2398. </select>
  2399. <select id="getCountBusinessData" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  2400. select
  2401. sum(a.totalPremium) as "totalPremium",
  2402. sum(a.qutationInsureCount) as "qutationInsureCount",
  2403. ROUND(sum( a.totalPremium ) / sum( a.qutationInsureCount ),2) AS "averagePremium",
  2404. sum(a.userNumber) as "userNumber",
  2405. count(DISTINCT a.insuranceCompanyName) as "insuranceCompanyNumber",
  2406. ROUND(sum(a.totalPremium)/sum(a.userNumber),0) as "perCapitaAmount"
  2407. from (
  2408. SELECT
  2409. agree.insurance_company AS "insuranceCompanyName",
  2410. IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0) as "totalPremium",
  2411. COUNT(0 ) AS "qutationInsureCount",
  2412. COUNT(DISTINCT io.userId) AS "userNumber"
  2413. FROM
  2414. ins_area_company iac
  2415. LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
  2416. LEFT JOIN ins_orders io on io.orderno = iac.orderno
  2417. LEFT JOIN sys_user su on io.userid =su.id
  2418. LEFT JOIN ins_fee_audit ifa on ifa.ins_order_no =iac.id
  2419. WHERE
  2420. agree.id IS NOT NULL
  2421. and iac.orderstatus = '3'
  2422. and ifa.auditstatus != '2'
  2423. and (iac.del_flag = '1' or io.del_flag IS NULL or io.del_flag = 1)
  2424. <if test="vo.companyId != null and vo.companyId!='' ">
  2425. and agree.insurance_company_id = #{vo.companyId}
  2426. </if>
  2427. <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
  2428. and agree.partner_companies_id = #{vo.parterCompanyId}
  2429. </if>
  2430. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  2431. AND iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
  2432. </if>
  2433. <if test="vo.signingTimeStart != null and vo.signingTimeStart!='' and vo.signingTimeEnd != null and vo.signingTimeEnd != ''">
  2434. AND iac.signing_time BETWEEN #{vo.signingTimeStart} AND #{vo.signingTimeEnd}
  2435. </if>
  2436. <if test="vo.enterTimeStart != null and vo.enterTimeStart!='' and vo.enterTimeEnd != null and vo.enterTimeEnd != ''">
  2437. AND iac.createtime BETWEEN #{vo.enterTimeStart} AND #{vo.enterTimeEnd}
  2438. </if>
  2439. <if test="vo.leaderName != null and vo.leaderName!='' ">
  2440. AND iac.leader_name = #{vo.leaderName}
  2441. </if>
  2442. <if test="vo.provinceId != null and vo.provinceId != '' and vo.cityId == null and vo.countyId == null and vo.houseId == null ">
  2443. and io.deptid like concat('%',#{vo.provinceId},'%')
  2444. </if>
  2445. <if test="vo.cityId != null and vo.cityId != '' and vo.countyId ==null and vo.houseId ==null">
  2446. and io.deptid like concat('%',#{vo.cityId},'%')
  2447. </if>
  2448. <if test="vo.countyId != null and vo.countyId != '' and vo.houseId ==null">
  2449. and io.deptid like concat('%',#{vo.countyId},'%')
  2450. </if>
  2451. <if test="vo.houseId != null and vo.houseId != ''">
  2452. and io.deptid like concat('%',#{vo.houseId},'%')
  2453. </if>
  2454. <if test="vo.parterProvinceId != null and vo.parterProvinceId != '' and vo.parterCityId == null and vo.parterCountyId == null ">
  2455. and agree.partner_companies_id like concat('%',#{vo.parterProvinceId},'%')
  2456. </if>
  2457. <if test="vo.parterCityId != null and vo.parterCityId != '' and vo.parterCountyId ==null ">
  2458. and agree.partner_companies_id like concat('%',#{vo.parterCityId},'%')
  2459. </if>
  2460. <if test="vo.parterCountyId != null and vo.parterCountyId != '' ">
  2461. and agree.partner_companies_id like concat('%',#{vo.parterCountyId},'%')
  2462. </if>
  2463. <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
  2464. AND io.deptid in
  2465. <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
  2466. #{item}
  2467. </foreach>
  2468. </if>
  2469. <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
  2470. AND su.leader_id in
  2471. <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
  2472. #{item}
  2473. </foreach>
  2474. </if>
  2475. group by
  2476. agree.insurance_company,
  2477. agree.partner_companies_id
  2478. ) a
  2479. </select>
  2480. <select id="getUserNumber" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  2481. SELECT
  2482. COUNT(DISTINCT io.userId) AS "userNumber"
  2483. FROM
  2484. ins_area_company iac
  2485. LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
  2486. LEFT JOIN ins_orders io on io.orderno = iac.orderno
  2487. LEFT JOIN ins_fee_audit ifa on ifa.ins_order_no =iac.id
  2488. LEFT JOIN sys_user su on io.userid =su.id
  2489. WHERE
  2490. agree.id IS NOT NULL
  2491. and iac.orderstatus = '3'
  2492. and ifa.auditstatus != '2'
  2493. and iac.del_flag = '1'
  2494. <if test="vo.companyId != null and vo.companyId!='' ">
  2495. and agree.insurance_company_id = #{vo.companyId}
  2496. </if>
  2497. <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
  2498. and agree.partner_companies_id = #{vo.parterCompanyId}
  2499. </if>
  2500. <if test="vo.signingTimeStart != null and vo.signingTimeStart!='' and vo.signingTimeEnd != null and vo.signingTimeEnd != ''">
  2501. AND iac.signing_time BETWEEN #{vo.signingTimeStart} AND #{vo.signingTimeEnd}
  2502. </if>
  2503. <if test="vo.enterTimeStart != null and vo.enterTimeStart!='' and vo.enterTimeEnd != null and vo.enterTimeEnd != ''">
  2504. AND iac.createtime BETWEEN #{vo.enterTimeStart} AND #{vo.enterTimeEnd}
  2505. </if>
  2506. <if test="vo.provinceId != null and vo.provinceId != '' and vo.cityId == null and vo.countyId == null and vo.houseId == null ">
  2507. and io.deptid like concat('%',#{vo.provinceId},'%')
  2508. </if>
  2509. <if test="vo.cityId != null and vo.cityId != '' and vo.countyId ==null and vo.houseId ==null">
  2510. and io.deptid like concat('%',#{vo.cityId},'%')
  2511. </if>
  2512. <if test="vo.leaderName != null and vo.leaderName!='' ">
  2513. AND iac.leader_name = #{vo.leaderName}
  2514. </if>
  2515. <if test="vo.countyId != null and vo.countyId != '' and vo.houseId ==null">
  2516. and io.deptid like concat('%',#{vo.countyId},'%')
  2517. </if>
  2518. <if test="vo.houseId != null and vo.houseId != ''">
  2519. and io.deptid like concat('%',#{vo.houseId},'%')
  2520. </if>
  2521. <if test="vo.parterProvinceId != null and vo.parterProvinceId != '' and vo.parterCityId == null and vo.parterCountyId == null ">
  2522. and agree.partner_companies_id like concat('%',#{vo.parterProvinceId},'%')
  2523. </if>
  2524. <if test="vo.parterCityId != null and vo.parterCityId != '' and vo.parterCountyId ==null ">
  2525. and agree.partner_companies_id like concat('%',#{vo.parterCityId},'%')
  2526. </if>
  2527. <if test="vo.parterCountyId != null and vo.parterCountyId != '' ">
  2528. and agree.partner_companies_id like concat('%',#{vo.parterCountyId},'%')
  2529. </if>
  2530. <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
  2531. AND io.deptid in
  2532. <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
  2533. #{item}
  2534. </foreach>
  2535. </if>
  2536. <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
  2537. AND su.leader_id in
  2538. <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
  2539. #{item}
  2540. </foreach>
  2541. </if>
  2542. </select>
  2543. <select id="getDistribution" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  2544. SELECT
  2545. agree.insurance_company_id AS "companyId",
  2546. agree.insurance_company AS "insuranceCompanyName",
  2547. agree.partner_companies_id AS "parterCompanyId",
  2548. ins.namesimple AS "partnerCompaniesName",
  2549. IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0) as "totalPremium",
  2550. COUNT(0) AS "qutationInsureCount",
  2551. ROUND((IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0)) / COUNT(0), 2)
  2552. AS "averagePremium",
  2553. COUNT(DISTINCT io.userId) AS "userNumber",
  2554. ROUND((IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0)) /
  2555. COUNT(DISTINCT io.userId) ,2) as "perCapitaAmount"
  2556. FROM
  2557. ins_area_company iac
  2558. LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
  2559. LEFT JOIN ins_orders io on io.orderno = iac.orderno
  2560. LEFT JOIN esm_ins_company ins ON agree.partner_companies_id = ins.id
  2561. LEFT JOIN ins_fee_audit ifa on ifa.ins_order_no =iac.id
  2562. LEFT JOIN sys_user su ON io.userid = su.id
  2563. WHERE
  2564. agree.id IS NOT NULL
  2565. and ifa.auditstatus != '2'
  2566. and (iac.del_flag = '1' or io.del_flag IS NULL or io.del_flag = 1)
  2567. <if test="vo.companyId != null and vo.companyId!='' ">
  2568. and agree.insurance_company_id = #{vo.companyId}
  2569. </if>
  2570. <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
  2571. and agree.partner_companies_id = #{vo.parterCompanyId}
  2572. </if>
  2573. <if test="vo.signingTimeStart != null and vo.signingTimeStart!='' and vo.signingTimeEnd != null and vo.signingTimeEnd != ''">
  2574. AND DATE_FORMAT(iac.signing_time, '%Y-%m-%d') BETWEEN DATE_FORMAT(#{vo.signingTimeStart}, '%Y-%m-%d') AND
  2575. DATE_FORMAT(#{vo.signingTimeEnd}, '%Y-%m-%d')
  2576. </if>
  2577. <if test="vo.enterTimeStart != null and vo.enterTimeStart!='' and vo.enterTimeEnd != null and vo.enterTimeEnd != ''">
  2578. AND DATE_FORMAT(iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT(#{vo.enterTimeStart}, '%Y-%m-%d') AND
  2579. DATE_FORMAT(#{vo.enterTimeEnd}, '%Y-%m-%d')
  2580. </if>
  2581. <if test="vo.provinceId != null and vo.provinceId != ''">
  2582. and io.deptid like "${vo.provinceId}%"
  2583. </if>
  2584. <if test="vo.cityId != null and vo.cityId != ''">
  2585. and io.deptid like "${vo.cityId}%"
  2586. </if>
  2587. <if test="vo.countyId != null and vo.countyId != ''">
  2588. and io.deptid like "${vo.countyId}%"
  2589. </if>
  2590. <if test="vo.houseId != null and vo.houseId != ''">
  2591. and io.deptid like "${vo.houseId}%"
  2592. </if>
  2593. <if test="vo.quotationStatus != null and vo.quotationStatus != ''">
  2594. and iac.orderstatus =#{vo.quotationStatus}
  2595. </if>
  2596. <if test="vo.dockingPerson != null and vo.dockingPerson != ''">
  2597. and agree.docking_person =#{vo.dockingPerson}
  2598. </if>
  2599. <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
  2600. AND io.deptid in
  2601. <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
  2602. #{item}
  2603. </foreach>
  2604. </if>
  2605. <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
  2606. AND su.leader_id in
  2607. <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
  2608. #{item}
  2609. </foreach>
  2610. </if>
  2611. <if test="vo.riskCode != null and vo.riskCode != '' and vo.riskCode != 'all'">
  2612. and iac.product = #{vo.riskCode}
  2613. </if>
  2614. GROUP BY
  2615. agree.insurance_company_id,
  2616. agree.insurance_company,
  2617. agree.partner_companies_id,
  2618. ins.namesimple
  2619. </select>
  2620. <select id="getOrderPremiumByUserIds" resultType="Double">
  2621. SELECT
  2622. IFNULL(
  2623. SUM( IFNULL( iac.jqpremium, 0 ) + IFNULL( iac.sypremium, 0 ) + IFNULL( iac.jypremium, 0 ) ),
  2624. 0
  2625. ) AS "totalPremium"
  2626. FROM
  2627. `ins_area_company` iac
  2628. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  2629. <where>
  2630. iac.orderstatus = '3'
  2631. and (iac.del_flag = '1' or io.del_flag IS NULL or io.del_flag = 1)
  2632. <if test="vo.ids != null and vo.ids.size()>0 ">
  2633. AND io.userid IN
  2634. <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
  2635. #{item}
  2636. </foreach>
  2637. </if>
  2638. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  2639. AND iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
  2640. </if>
  2641. </where>
  2642. </select>
  2643. <select id="querOrdersDataPage" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
  2644. SELECT
  2645. count( 0 ) AS "orderNumber",
  2646. b.licenseno as "licenseno",
  2647. b.frameno as "frameno",
  2648. b.modelCode as "modelCode",
  2649. b.modelcname as "modelcname"
  2650. FROM
  2651. (
  2652. SELECT
  2653. io.frameno AS frameno,
  2654. REPLACE(JSON_EXTRACT(io.carinfo, '$.engineNo'), '"', '') as "modelCode",
  2655. REPLACE(JSON_EXTRACT(io.carinfo, '$.modelcname'), '"', '') as "modelcname",
  2656. ifnull(io.licenseno, '') AS licenseno
  2657. FROM
  2658. ins_orders io
  2659. LEFT JOIN sys_user su on io.userid=su.id
  2660. <where>
  2661. 1=1
  2662. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  2663. AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  2664. </if>
  2665. <if test="vo.licenseno != null and vo.licenseno!='' ">
  2666. AND io.licenseno =#{vo.licenseno}
  2667. </if>
  2668. <if test="vo.userId != null and vo.userId!='' ">
  2669. AND io.userid =#{vo.userId}
  2670. </if>
  2671. <if test="vo.userName != null and vo.userName!='' ">
  2672. AND su.name =#{vo.userName}
  2673. </if>
  2674. <if test="vo.mobile != null and vo.mobile!='' ">
  2675. AND su.mobile =#{vo.mobile}
  2676. </if>
  2677. <if test="vo.frameno != null and vo.frameno!='' ">
  2678. AND io.frameno =#{vo.frameno}
  2679. </if>
  2680. <if test="vo.deptId != null and vo.deptId!='' ">
  2681. and io.deptid like concat('%', #{vo.deptId}, '%')
  2682. </if>
  2683. <if test="vo.year != null and vo.year!='' ">
  2684. AND DATE_FORMAT( io.createtime, '%Y') =#{vo.year}
  2685. </if>
  2686. <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
  2687. AND io.deptid in
  2688. <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
  2689. #{item}
  2690. </foreach>
  2691. </if>
  2692. <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
  2693. AND io.userid in
  2694. <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
  2695. #{item}
  2696. </foreach>
  2697. </if>
  2698. </where>
  2699. ) b
  2700. GROUP BY
  2701. b.licenseno,
  2702. b.frameno,
  2703. b.modelCode,
  2704. b.modelcname
  2705. </select>
  2706. <select id="getOrdersGroupByLicenseno" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
  2707. SELECT
  2708. io.licenseno AS "licenseno",
  2709. io.frameno AS "frameno",
  2710. io.orderstatus as "orderstatus",
  2711. io.orderno as "orderno"
  2712. FROM
  2713. ins_orders io
  2714. LEFT JOIN sys_user su on io.userid=su.id
  2715. <where>
  2716. io.licenseno is not null
  2717. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  2718. AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  2719. </if>
  2720. <if test="vo.licenseno != null and vo.licenseno!='' ">
  2721. AND io.licenseno =#{vo.licenseno}
  2722. </if>
  2723. <if test="vo.userId != null and vo.userId!='' ">
  2724. AND io.userId =#{vo.userId}
  2725. </if>
  2726. <if test="vo.userName != null and vo.userName!='' ">
  2727. AND su.name =#{vo.userName}
  2728. </if>
  2729. <if test="vo.mobile != null and vo.mobile!='' ">
  2730. AND su.mobile =#{vo.mobile}
  2731. </if>
  2732. <if test="vo.frameno != null and vo.frameno!='' ">
  2733. AND su.frameno =#{vo.frameno}
  2734. </if>
  2735. <if test="vo.deptId != null and vo.deptId!='' ">
  2736. and io.deptid like concat('%', #{vo.deptId}, '%')
  2737. </if>
  2738. </where>
  2739. </select>
  2740. <select id="querOrdersamountTo" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
  2741. select sum(a.orderNumber) as "orderNumber",
  2742. count(a.licenseno) as "b.frameno"
  2743. from (
  2744. SELECT
  2745. count( 0 ) AS "orderNumber",
  2746. b.licenseno as "licenseno",
  2747. b.frameno as "frameno"
  2748. FROM
  2749. (
  2750. SELECT
  2751. io.orderstatus AS orderstatus,
  2752. io.frameno AS frameno,
  2753. ifnull(io.licenseno, '') AS licenseno
  2754. FROM
  2755. ins_orders io
  2756. LEFT JOIN sys_user su on io.userid=su.id
  2757. <where>
  2758. 1=1
  2759. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  2760. AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  2761. </if>
  2762. <if test="vo.licenseno != null and vo.licenseno!='' ">
  2763. AND io.licenseno =#{vo.licenseno}
  2764. </if>
  2765. <if test="vo.userId != null and vo.userId!='' ">
  2766. AND io.userid =#{vo.userId}
  2767. </if>
  2768. <if test="vo.userName != null and vo.userName!='' ">
  2769. AND su.name =#{vo.userName}
  2770. </if>
  2771. <if test="vo.mobile != null and vo.mobile!='' ">
  2772. AND su.mobile =#{vo.mobile}
  2773. </if>
  2774. <if test="vo.frameno != null and vo.frameno!='' ">
  2775. AND io.frameno =#{vo.frameno}
  2776. </if>
  2777. <if test="vo.deptId != null and vo.deptId!='' ">
  2778. and io.deptid like concat('%', #{vo.deptId}, '%')
  2779. </if>
  2780. </where>
  2781. ) b
  2782. GROUP BY
  2783. b.licenseno,
  2784. b.frameno
  2785. ) a
  2786. </select>
  2787. <select id="querResultOrderNumber" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
  2788. SELECT
  2789. count( io.orderno ) AS "orderNumber",
  2790. IFNULL(count(CASE WHEN io.orderstatus = '3' THEN 1 ELSE 0 END),0) / (IFNULL(count(CASE WHEN io.orderstatus = '2'
  2791. THEN 1 ELSE 0 END),0) + IFNULL(count(CASE WHEN io.orderstatus = '3' THEN 1 ELSE 0 END),0)) AS "closeRate"
  2792. FROM
  2793. ins_orders io
  2794. LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
  2795. LEFT JOIN sys_user su ON io.userid = su.id
  2796. <where>
  2797. 1=1
  2798. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  2799. AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  2800. </if>
  2801. <if test="vo.licenseno != null and vo.licenseno!='' ">
  2802. AND io.licenseno =#{vo.licenseno}
  2803. </if>
  2804. <if test="vo.userId != null and vo.userId!='' ">
  2805. AND io.userid =#{vo.userId}
  2806. </if>
  2807. <if test="vo.userName != null and vo.userName!='' ">
  2808. AND su.name =#{vo.userName}
  2809. </if>
  2810. <if test="vo.mobile != null and vo.mobile!='' ">
  2811. AND su.mobile =#{vo.mobile}
  2812. </if>
  2813. <if test="vo.frameno != null and vo.frameno!='' ">
  2814. AND su.frameno =#{vo.frameno}
  2815. </if>
  2816. <if test="vo.deptId != null and vo.deptId!='' ">
  2817. and io.deptid like concat('%', #{vo.deptId}, '%')
  2818. </if>
  2819. </where>
  2820. </select>
  2821. <select id="numberQuotationsByUserIds" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  2822. SELECT
  2823. count(iac.id) as "orderNumber",
  2824. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
  2825. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  2826. sum( CASE WHEN iac.orderstatus = 3 THEN IFNULL(iac.jqpremium, 0) + IFNULL(iac.sypremium, 0) +
  2827. IFNULL(iac.jypremium, 0) END ) AS totalPremium
  2828. FROM
  2829. ins_area_company iac
  2830. left join ins_orders io on io.orderno = iac.orderno
  2831. <where>
  2832. (iac.del_flag = '1' or io.del_flag IS NULL or io.del_flag = 1)
  2833. <if test="ids != null and ids.size()>0 ">
  2834. AND io.userid IN
  2835. <foreach item="item" collection="ids" open="(" separator="," close=")">
  2836. #{item}
  2837. </foreach>
  2838. </if>
  2839. <if test="month != null and month!='' ">
  2840. AND DATE_FORMAT(iac.createtime, '%Y-%m') =#{month}
  2841. </if>
  2842. </where>
  2843. </select>
  2844. <select id="selectByOrdersDataVo" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
  2845. select
  2846. iac.inscompany as "namesimple"
  2847. from
  2848. ins_area_company iac
  2849. <where>
  2850. 1=1
  2851. <if test="vo.orderstatus != null and vo.orderstatus != '' ">
  2852. AND iac.orderstatus =#{vo.orderstatus}
  2853. </if>
  2854. <if test="vo.orderno !=null and vo.orderno !='' ">
  2855. AND iac.orderno =#{vo.orderno}
  2856. </if>
  2857. </where>
  2858. </select>
  2859. <select id="channelExcel" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsExcel">
  2860. select a.*,(select name from sys_user where id =a.userId) as "userName"
  2861. from (
  2862. SELECT
  2863. sd.NAME AS "deptName",
  2864. io.userid AS "userId",
  2865. sd.parent_id as "deptId",
  2866. sd.management_source as "managementSource",
  2867. COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS qutationCount,
  2868. COUNT( CASE WHEN iot.order_status ='2' THEN 1 END ) AS underwritingCount,
  2869. COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) AS qutationInsureCount,
  2870. COUNT( CASE WHEN iot.order_status = '4' THEN 1 END ) AS underwritingReturn,
  2871. COUNT( CASE WHEN iot.order_status ='2' THEN 1 END ) / COUNT( CASE WHEN iot.order_status ='0' THEN 1 END ) AS
  2872. "passingRate",
  2873. COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) / COUNT( CASE WHEN iot.order_status in
  2874. ('0','1','2','3','4') THEN 1 END ) AS "closeRate",
  2875. (COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) + COUNT( CASE WHEN iot.order_status = '2' THEN 1 END ))/
  2876. COUNT(CASE WHEN iot.order_status in ('0','1','2','3','4') THEN 1 END) AS "contributionRate",
  2877. COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) / COUNT(CASE WHEN iot.order_status in ('0','1','2','3','4')
  2878. THEN 1 END ) AS "quotationRate",
  2879. COUNT(CASE WHEN io.order_source = 0 and iot.order_status ='0' THEN 1 END) as "pcOrderSource",
  2880. COUNT(CASE WHEN io.order_source = 1 and iot.order_status ='0' THEN 1 END) as "appOrderSource",
  2881. COUNT( CASE WHEN iot.order_status = '1' THEN 1 END ) AS "auditOrder"
  2882. FROM
  2883. (
  2884. select iot.suborder,iot.order_status from `ins_orders_track` iot
  2885. left join ins_area_company iac ON iac.id = iot.suborder
  2886. where true
  2887. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  2888. AND iac.createtime BETWEEN #{taskStatisticsVo.beginDate} AND #{taskStatisticsVo.endDate}
  2889. </if>
  2890. <if test="taskStatisticsVo.signingTimeStart !=null and taskStatisticsVo.signingTimeStart != '' and taskStatisticsVo.signingTimeEnd !=null and taskStatisticsVo.signingTimeEnd != ''">
  2891. AND iac.signing_time BETWEEN #{taskStatisticsVo.signingTimeStart} AND #{taskStatisticsVo.signingTimeEnd},
  2892. </if>
  2893. GROUP BY iot.suborder ,iot.order_status
  2894. ) iot
  2895. left join ins_area_company iac ON iac.id = iot.suborder
  2896. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  2897. LEFT JOIN sys_dept sd ON sd.id = io.deptid
  2898. <where>
  2899. (iac.del_flag = '1' or io.del_flag IS NULL or io.del_flag = 1)
  2900. <if test="taskStatisticsVo.managementSource != null and taskStatisticsVo.managementSource!=''">
  2901. AND sd.management_source =#{taskStatisticsVo.managementSource}
  2902. </if>
  2903. <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
  2904. and io.deptid like "${taskStatisticsVo.provinceId}%"
  2905. </if>
  2906. <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
  2907. and io.deptid like "${taskStatisticsVo.cityId}%"
  2908. </if>
  2909. <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
  2910. and io.deptid like "${taskStatisticsVo.countyId}%"
  2911. </if>
  2912. <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
  2913. and io.deptid like "${taskStatisticsVo.houseId}%"
  2914. </if>
  2915. <if test="taskStatisticsVo.userId != null and taskStatisticsVo.userId != ''">
  2916. and io.userid =#{taskStatisticsVo.userId}
  2917. </if>
  2918. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  2919. AND io.createtime BETWEEN #{taskStatisticsVo.createtimeStart} AND
  2920. #{taskStatisticsVo.createtimeEnd}
  2921. </if>
  2922. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  2923. AND iac.createtime BETWEEN #{taskStatisticsVo.beginDate} AND #{taskStatisticsVo.endDate}
  2924. </if>
  2925. <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
  2926. AND sd.id in
  2927. <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
  2928. #{item}
  2929. </foreach>
  2930. </if>
  2931. <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
  2932. AND io.userid in
  2933. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  2934. #{item}
  2935. </foreach>
  2936. </if>
  2937. </where>
  2938. GROUP BY
  2939. io.userid,
  2940. sd.NAME,
  2941. sd.id,
  2942. sd.management_source
  2943. ) a
  2944. left join sys_user su on su.id =a.userId
  2945. LEFT JOIN ins_upload_files inf on su.head_sculpture =inf.id
  2946. LEFT JOIN sys_user_info sui on sui .id =su.id
  2947. LEFT JOIN sys_user su2 on su2.id =su.leader_id
  2948. <where>
  2949. <if test='taskStatisticsVo.userName !=null and taskStatisticsVo.userName!="" '>
  2950. and su.name like concat('%',#{taskStatisticsVo.userName},'%')
  2951. </if>
  2952. <if test='taskStatisticsVo.leaderId !=null and taskStatisticsVo.leaderId!="" '>
  2953. and su.leader_id =#{taskStatisticsVo.leaderId}
  2954. </if>
  2955. <if test='taskStatisticsVo.userId !=null and taskStatisticsVo.userId!="" '>
  2956. and su.id =#{taskStatisticsVo.userId}
  2957. </if>
  2958. </where>
  2959. </select>
  2960. <select id="insuranceCompanyExcel" resultType="com.ydtech.modules.admin.model.dto.InsuranceCompanyExcel">
  2961. SELECT
  2962. a.*,
  2963. ( SELECT eic.namesimple FROM esm_ins_company eic WHERE eic.id = a.partner_companies_id ) AS
  2964. "partnerCompaniesName"
  2965. FROM
  2966. (
  2967. SELECT
  2968. pa.insurance_company_id,
  2969. pa.partner_companies_id,
  2970. pa.insurance_company AS "insuranceCompanyName",
  2971. COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS qutationCount,
  2972. COUNT( CASE WHEN iot.order_status = '1' THEN 1 END ) AS "auditOrder",
  2973. COUNT( CASE WHEN iot.order_status = '2' THEN 1 END ) AS underwritingCount,
  2974. COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) AS qutationInsureCount,
  2975. COUNT( CASE WHEN iot.order_status = '4' THEN 1 END ) AS underwritingReturn,
  2976. COUNT( CASE WHEN iot.order_status ='2' THEN 1 END ) / COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS
  2977. "passingRate",
  2978. COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) / COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS
  2979. "closeRate",
  2980. (COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) + COUNT( CASE WHEN iot.order_status = '2' THEN 1 END )) /
  2981. COUNT( iot.order_status ) AS "contributionRate",
  2982. COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) / COUNT( iot.order_status ) AS "quotationRate"
  2983. FROM
  2984. (
  2985. select iot.suborder,iot.order_status from `ins_orders_track` iot
  2986. left join ins_area_company iac ON iac.id = iot.suborder
  2987. where true
  2988. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  2989. AND iac.createtime BETWEEN #{taskStatisticsVo.beginDate} AND #{taskStatisticsVo.endDate}
  2990. </if>
  2991. <if test="taskStatisticsVo.signingTimeStart !=null and taskStatisticsVo.signingTimeStart != '' and taskStatisticsVo.signingTimeEnd !=null and taskStatisticsVo.signingTimeEnd != ''">
  2992. AND iac.signing_time BETWEEN #{taskStatisticsVo.signingTimeStart} AND #{taskStatisticsVo.signingTimeEnd},
  2993. </if>
  2994. GROUP BY iot.suborder ,iot.order_status
  2995. ) iot
  2996. LEFT JOIN ins_area_company iac ON iac.id = iot.suborder
  2997. LEFT JOIN ins_fee_audit ifa ON ifa.ins_order_no = iac.id
  2998. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  2999. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  3000. <where>
  3001. pa.insurance_company_id IS NOT NULL
  3002. and (iac.del_flag = '1' or io.del_flag IS NULL or io.del_flag = 1)
  3003. <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
  3004. and io.deptid like concat('%', #{taskStatisticsVo.provinceId}, '%')
  3005. </if>
  3006. <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
  3007. and io.deptid like concat('%', #{taskStatisticsVo.cityId}, '%')
  3008. </if>
  3009. <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
  3010. and io.deptid like concat('%', #{taskStatisticsVo.countyId}, '%')
  3011. </if>
  3012. <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
  3013. and io.deptid like concat('%', #{taskStatisticsVo.houseId}, '%')
  3014. </if>
  3015. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  3016. AND iac.createtime BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
  3017. </if>
  3018. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  3019. AND iac.createtime BETWEEN #{taskStatisticsVo.beginDate} AND #{taskStatisticsVo.endDate}
  3020. </if>
  3021. <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId != ''">
  3022. AND iac.company_id =#{taskStatisticsVo.companyId}
  3023. </if>
  3024. <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
  3025. AND io.deptid in
  3026. <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
  3027. #{item}
  3028. </foreach>
  3029. </if>
  3030. <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
  3031. AND io.userid in
  3032. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  3033. #{item}
  3034. </foreach>
  3035. </if>
  3036. </where>
  3037. GROUP BY
  3038. pa.insurance_company_id,
  3039. pa.partner_companies_id,
  3040. pa.insurance_company
  3041. ) a
  3042. </select>
  3043. <select id="getSumBigOrderCount" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
  3044. select count(0) as "orderNumber",
  3045. GROUP_CONCAT(inscompany ORDER BY inscompany SEPARATOR ',') as "namesimple"
  3046. from ins_area_company iac
  3047. left join ins_orders io on io.orderno = iac.orderno
  3048. left join sys_user su on su.id =io.userid
  3049. <where>
  3050. iac.orderstatus ='3'
  3051. <if test="vo.licenseno !=null and vo.licenseno!=''">
  3052. AND io.licenseno =#{vo.licenseno}
  3053. </if>
  3054. <if test="vo.frameno !=null and vo.frameno!=''">
  3055. AND io.frameno =#{vo.frameno}
  3056. </if>
  3057. <if test="vo.userId !=null and vo.userId!=''">
  3058. AND io.userId =#{vo.userId}
  3059. </if>
  3060. <if test="vo.userName != null and vo.userName!='' ">
  3061. AND su.name =#{vo.userName}
  3062. </if>
  3063. <if test="vo.mobile != null and vo.mobile!='' ">
  3064. AND su.mobile =#{vo.mobile}
  3065. </if>
  3066. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  3067. AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  3068. </if>
  3069. <if test="vo.year != null and vo.year!='' ">
  3070. AND DATE_FORMAT( io.createtime, '%Y') =#{vo.year}
  3071. </if>
  3072. </where>
  3073. limit 10
  3074. </select>
  3075. <select id="queryAgencyUserInsAreaPage" resultType="com.ydtech.modules.admin.model.vo.AgencyUserInsAreaVo">
  3076. select
  3077. io.userid as userId,
  3078. io.username as userName,
  3079. io.licenseno as licenseno,
  3080. iac.id as companyId,
  3081. iac.jqpremium as jqpremium,
  3082. iac.sypremium as sypremium,
  3083. iac.jypremium as jypremium,
  3084. iac.createtime as createtime,
  3085. iac.orderstatus as orderstatus
  3086. from ins_area_company iac
  3087. left join ins_orders io on io.orderno = iac.orderno
  3088. <where>
  3089. iac.orderstatus=3
  3090. <if test="dto.userId !=null and dto.userId !=''">
  3091. and io.userid = #{dto.userId}
  3092. </if>
  3093. <if test="dto.deptId !=null and dto.deptId !=''">
  3094. and io.deptid like concat( #{dto.deptId}, '%')
  3095. </if>
  3096. <if test="dto.startTime !=null and dto.startTime !=''">
  3097. and io.createtime >= #{dto.startTime}
  3098. </if>
  3099. </where>
  3100. ORDER BY iac.createtime
  3101. </select>
  3102. <select id="querOrdersDataListExcel" resultType="com.ydtech.modules.admin.model.dto.OrdersDataExcel">
  3103. SELECT
  3104. count( 0 ) AS "orderNumber",
  3105. b.licenseno as "licenseno",
  3106. b.frameno as "frameno",
  3107. b.modelCode as "modelCode",
  3108. b.modelcname as "modelcname"
  3109. FROM
  3110. (
  3111. SELECT
  3112. io.orderstatus AS orderstatus,
  3113. io.frameno AS frameno,
  3114. REPLACE(JSON_EXTRACT(io.carinfo, '$.engineNo'), '"', '') as "modelCode",
  3115. REPLACE(JSON_EXTRACT(io.carinfo, '$.modelcname'), '"', '') as "modelcname",
  3116. ifnull(io.licenseno, '') AS licenseno
  3117. FROM
  3118. ins_orders io
  3119. LEFT JOIN sys_user su on io.userid=su.id
  3120. <where>
  3121. 1=1
  3122. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  3123. AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  3124. </if>
  3125. <if test="vo.licenseno != null and vo.licenseno!='' ">
  3126. AND io.licenseno =#{vo.licenseno}
  3127. </if>
  3128. <if test="vo.userId != null and vo.userId!='' ">
  3129. AND io.userid =#{vo.userId}
  3130. </if>
  3131. <if test="vo.userName != null and vo.userName!='' ">
  3132. AND su.name =#{vo.userName}
  3133. </if>
  3134. <if test="vo.mobile != null and vo.mobile!='' ">
  3135. AND su.mobile =#{vo.mobile}
  3136. </if>
  3137. <if test="vo.frameno != null and vo.frameno!='' ">
  3138. AND io.frameno =#{vo.frameno}
  3139. </if>
  3140. <if test="vo.deptId != null and vo.deptId!='' ">
  3141. and io.deptid like concat('%', #{vo.deptId}, '%')
  3142. </if>
  3143. <if test="vo.year != null and vo.year!='' ">
  3144. AND DATE_FORMAT( io.createtime, '%Y') =#{vo.year}
  3145. </if>
  3146. <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
  3147. AND io.deptid in
  3148. <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
  3149. #{item}
  3150. </foreach>
  3151. </if>
  3152. <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
  3153. AND io.userid in
  3154. <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
  3155. #{item}
  3156. </foreach>
  3157. </if>
  3158. </where>
  3159. ) b
  3160. GROUP BY
  3161. b.licenseno,
  3162. b.frameno,
  3163. b.modelCode,
  3164. b.modelcname
  3165. </select>
  3166. <select id="orderCheckPage" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
  3167. select
  3168. iac.id,
  3169. iac.orderno,
  3170. iac.agreement_id,
  3171. iac.jqpremium,
  3172. iac.sypremium,
  3173. iac.jypremium,
  3174. iac.taxamount,
  3175. iac.sumpremium,
  3176. io.licenseno,
  3177. iac.createtime,
  3178. su.name as auditname
  3179. FROM
  3180. ins_area_company iac
  3181. LEFT JOIN
  3182. ins_orders io on iac.orderno = io.orderno
  3183. left join ptl_agreement agree on iac.agreement_id =agree.id
  3184. left join ins_fee_audit ifa on iac.id = ifa.ins_order_no
  3185. left join sys_user su on su.id= ifa.audituser
  3186. WHERE
  3187. iac.operator_id = #{userId}
  3188. AND
  3189. iac.orderstatus = 3
  3190. and agree.is_external =1
  3191. and auditstatus =1
  3192. <if test="vo.id != null and vo.id!='' ">
  3193. and iac.id = #{vo.id}
  3194. </if>
  3195. <if test="vo.licenseno != null and vo.licenseno!='' ">
  3196. and io.licenseno like CONCAT('%', #{vo.licenseno}, '%')
  3197. </if>
  3198. </select>
  3199. <select id="costCenterTotal" resultType="java.util.HashMap">
  3200. SELECT
  3201. COUNT( CASE WHEN ifa.auditstatus = 1 THEN 1 END ) AS "allAuditstatusOrders",
  3202. COUNT( CASE WHEN ifa.auditstatus = 0 THEN 1 END ) AS "allAuditOrder",
  3203. COUNT( CASE WHEN ifa.auditstatus = 1 and ifa.audituser != '自动审核' THEN 1 END ) AS "allPersionAudit",
  3204. COUNT( CASE WHEN ifa.audituser = '自动审核' THEN 1 END ) AS "allAutomaticAudit"
  3205. FROM
  3206. ins_fee_audit ifa
  3207. LEFT JOIN ins_orders io ON io.orderno = ifa.orderno
  3208. LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
  3209. AND iac.orderstatus = 3
  3210. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  3211. LEFT JOIN esm_ins_company eic ON eic.id = pa.partner_companies_id
  3212. left join sys_user su on su.id =ifa.audituser
  3213. <where>
  3214. 1=1
  3215. and iac.id = ifa.ins_order_no
  3216. AND iac.orderstatus = 3
  3217. <if test="taskStatisticsVo.reviewer !=null and taskStatisticsVo.reviewer !=''">
  3218. and su.name =#{taskStatisticsVo.reviewer}
  3219. </if>
  3220. <if test="taskStatisticsVo.audittime !=null and taskStatisticsVo.audittime !=''">
  3221. and ifa.audittime =#{taskStatisticsVo.audittime}
  3222. </if>
  3223. <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId !=''">
  3224. and iac.company_id =#{taskStatisticsVo.companyId}
  3225. </if>
  3226. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  3227. AND DATE_FORMAT( iac.signing_time, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.createtimeStart},
  3228. '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.createtimeEnd}, '%Y-%m-%d')
  3229. </if>
  3230. <if test="taskStatisticsVo.auditTimeStart !=null and taskStatisticsVo.auditTimeEnd != '' and taskStatisticsVo.auditTimeStart !=null and taskStatisticsVo.auditTimeEnd != ''">
  3231. AND DATE_FORMAT( ifa.audittime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.auditTimeStart},
  3232. '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.auditTimeEnd}, '%Y-%m-%d')
  3233. </if>
  3234. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  3235. AND DATE_FORMAT( iac.signing_time, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate},
  3236. '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
  3237. </if>
  3238. <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
  3239. AND io.deptid in
  3240. <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
  3241. #{item}
  3242. </foreach>
  3243. </if>
  3244. <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
  3245. AND su.id in
  3246. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  3247. #{item}
  3248. </foreach>
  3249. </if>
  3250. <choose>
  3251. <when test="taskStatisticsVo.riskCode != null and taskStatisticsVo.riskCode != '' and taskStatisticsVo.riskCode != 'all' ">
  3252. and iac.product = #{taskStatisticsVo.riskCode}
  3253. </when>
  3254. </choose>
  3255. </where>
  3256. </select>
  3257. <select id="getSubOrderCountDTO" resultType="com.ydtech.modules.order.entity.dto.SubOrderCountDTO">
  3258. select orderno, orderstatus, count(*)as count
  3259. from (select orderno, company_id, orderstatus
  3260. from ins_area_company
  3261. where orderno in
  3262. <foreach collection="orderNo" open="(" separator="," close=")" item="item" index="index">
  3263. #{item,jdbcType=VARCHAR}
  3264. </foreach>
  3265. and del_flag = '1'
  3266. group by orderno, company_id, orderstatus) as iac
  3267. group by orderno, orderstatus
  3268. </select>
  3269. <select id="getAllRejectOrders" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
  3270. select
  3271. iac.id,
  3272. iac.orderno,
  3273. iac.agreement_id,
  3274. iac.jqpremium,
  3275. iac.sypremium,
  3276. iac.jypremium,
  3277. iac.taxamount,
  3278. iac.sumpremium,
  3279. io.licenseno,
  3280. ifa.audittime,
  3281. ifa.audituser as auditname,
  3282. ifa.rejectinfo,
  3283. "1" as orderExternalStatus,
  3284. iac.operator_name as recorder
  3285. FROM
  3286. ins_fee_audit ifa
  3287. LEFT JOIN
  3288. ins_area_company iac on iac.id = ifa.ins_order_no
  3289. LEFT JOIN
  3290. ins_orders io on iac.orderno = io.orderno
  3291. left join
  3292. sys_user su on su.id= ifa.audituser
  3293. WHERE
  3294. ifa.auditstatus = 2 and IFNULL(iac.del_flag,'') != '0'
  3295. <if test="vo.id != null and vo.id!=''">
  3296. and iac.id = #{vo.id}
  3297. </if>
  3298. <if test="vo.licenseno != null and vo.licenseno!='' ">
  3299. and io.licenseno like CONCAT('%', #{vo.licenseno}, '%')
  3300. </if>
  3301. <if test="vo.auditname != null and vo.auditname!='' ">
  3302. and su.name like CONCAT('%', #{vo.auditname}, '%')
  3303. </if>
  3304. order by ifa.audittime desc
  3305. </select>
  3306. <select id="queryPageOrderCB" resultType="com.ydtech.modules.order.entity.InsOrders">
  3307. SELECT
  3308. iac.id as orderno,
  3309. io.quoteno,
  3310. iac.orderstatus,
  3311. iac.company_id,
  3312. iac.inscompany,
  3313. io.carinfo,
  3314. io.userid,
  3315. io.username,
  3316. io.deptid,
  3317. io.deptname,
  3318. io.agreeid,
  3319. iac.productid,
  3320. iac.product,
  3321. iac.createtime,
  3322. io.frameno,
  3323. io.licenseno,
  3324. JSON_UNQUOTE(json_extract(io.insureinfo, '$.name')) as insuredname,
  3325. io.is_external,
  3326. iac.jq_start_date as jqstartdate,
  3327. iac.jq_end_date as jqenddate,
  3328. iac.sy_start_date as systartdate,
  3329. iac.sy_end_date as syenddate,
  3330. io.vehicle_and_vessel_tax,
  3331. io.operatorid,
  3332. iac.operator_name,
  3333. sd.management_source,
  3334. iac.problem_order,
  3335. eic.namesimple as partnerCompaniesName,
  3336. iac.id as subOrderId,
  3337. iac.signing_time as signingTime,
  3338. iac.pay_date as payDate,
  3339. pa.agreement_code as agreementCode,
  3340. pa.agreement_name as agreementName,
  3341. pa.business_description as businessDescription,
  3342. pa.job_description as jobDescription,
  3343. pa.agreement_title as agreementTitle,
  3344. pa.docking_person as dockingPerson,
  3345. io.entry_status
  3346. FROM
  3347. ins_area_company iac
  3348. LEFT JOIN ins_orders io ON iac.orderno = io.orderno
  3349. LEFT JOIN sys_user su ON su.id = io.userid
  3350. LEFT JOIN sys_dept sd ON sd.id = su.dept_id
  3351. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  3352. LEFT JOIN esm_ins_company eic ON eic.id = pa.partner_companies_id
  3353. WHERE
  3354. iac.orderstatus = 3
  3355. <if test="params.quoteStartDateStr != null and params.quoteStartDateStr != '' and params.quoteEndDateStr != null and params.quoteEndDateStr != ''">
  3356. and DATE_FORMAT(iac.createtime, '%Y-%m-%d') between #{params.quoteStartDateStr} AND
  3357. #{params.quoteEndDateStr}
  3358. </if>
  3359. <if test="params.orderNo != null and params.orderNo != ''">
  3360. AND iac.id= #{params.orderNo}
  3361. </if>
  3362. <if test="params.licenseNo != null and params.licenseNo != ''">
  3363. AND io.licenseno = #{params.licenseNo}
  3364. </if>
  3365. <if test="params.frameNo != null and params.frameNo != ''">
  3366. AND io.frameno = #{params.frameNo}
  3367. </if>
  3368. <if test="params.insuredName != null and params.insuredName != ''">
  3369. AND json_extract(io.insureinfo, '$.name') = #{params.insuredName}
  3370. </if>
  3371. <if test="params.companyId != null and params.companyId != ''">
  3372. AND iac.company_id = #{params.companyId}
  3373. </if>
  3374. <if test="params.engineNo != null and params.engineNo != ''">
  3375. and JSON_EXTRACT( io.carinfo, '$.engineNo' ) = #{params.engineNo}
  3376. </if>
  3377. <if test="params.riskCode != null and params.riskCode != ''">
  3378. and iac.product = #{params.riskCode}
  3379. </if>
  3380. <if test="params.attachStartDateStr != null and params.attachStartDateStr != '' and params.attachStartDateStr != null and params.attachStartDateStr != '' ">
  3381. and ((
  3382. DATE_FORMAT(iac.jq_start_date, '%Y-%m-%d') BETWEEN #{params.attachStartDateStr}
  3383. AND #{params.attachEndDateStr}
  3384. )
  3385. OR ( DATE_FORMAT(iac.sy_start_date, '%Y-%m-%d') BETWEEN #{params.attachStartDateStr} AND
  3386. #{params.attachEndDateStr} )
  3387. )
  3388. </if>
  3389. <if test="params.provinceId != null and params.provinceId != ''">
  3390. and io.deptid like "${params.provinceId}%"
  3391. </if>
  3392. <if test="params.problemOrder != null and params.problemOrder != ''">
  3393. and iac.problem_order like "${params.problemOrder}%"
  3394. </if>
  3395. <if test="params.cityId != null and params.cityId != ''">
  3396. and io.deptid like "${params.cityId}%"
  3397. </if>
  3398. <if test="params.countyId != null and params.countyId != ''">
  3399. and io.deptid like "${params.countyId}%"
  3400. </if>
  3401. <if test="params.houseId != null and params.houseId != ''">
  3402. and io.deptid like "${params.houseId}%"
  3403. </if>
  3404. <if test="params.operatorId != null and params.operatorId != ''">
  3405. and io.userid = #{params.operatorId}
  3406. </if>
  3407. <if test="params.operatorName != null and params.operatorName != ''">
  3408. and io.username = #{params.operatorName}
  3409. </if>
  3410. <if test="params.auditId != null and params.auditId != ''">
  3411. and iac.new_operator_id = #{params.auditId}
  3412. </if>
  3413. <if test="params.agreeId != null and params.agreeId != ''">
  3414. and iac.agreement_id = #{params.agreeId}
  3415. </if>
  3416. <if test="params.managementSource != null and params.managementSource != ''">
  3417. and sd.management_source = #{params.managementSource}
  3418. </if>
  3419. <if test="params.signStartDateStr != null and params.signStartDateStr != '' and params.signEndDateStr != null and params.signEndDateStr != ''">
  3420. and DATE_FORMAT(iac.signing_time, '%Y-%m-%d') between #{params.signStartDateStr} AND
  3421. #{params.signEndDateStr}
  3422. </if>
  3423. <if test="params.payStartDateStr != null and params.payStartDateStr != '' and params.payEndDateStr != null and params.payEndDateStr != ''">
  3424. and iac.pay_date between #{params.payStartDateStr} AND #{params.payEndDateStr}
  3425. </if>
  3426. <if test="params.isExternal != null and params.isExternal != ''">
  3427. and io.is_external = #{params.isExternal}
  3428. </if>
  3429. <if test="params.jqPolicyNo != null and params.jqPolicyNo != ''">
  3430. and iac.jqpolicyno = #{params.jqPolicyNo}
  3431. </if>
  3432. <if test="params.syPolicyNo != null and params.syPolicyNo != ''">
  3433. and iac.sypolicyno = #{params.syPolicyNo}
  3434. </if>
  3435. <if test="params.noPolicyNo != null and params.noPolicyNo != ''">
  3436. and iac.cross_insurance like concat('%', #{params.noPolicyNo}, '%')
  3437. </if>
  3438. order by iac.createtime desc
  3439. </select>
  3440. <select id="getExpectNetProfit" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
  3441. select
  3442. ROUND(sum(IFNULL(ifon.jq_costs_premiums,0) + IFNULL(ifon.sy_costs_premiums,0) + IFNULL
  3443. (ifon.no_costs_premiums,0)),2) as "entranceAllFee",
  3444. ROUND(sum(IFNULL(jq_export_other_costs_premiums,0) + IFNULL(jq_export_supervise_costs_premiums,0)
  3445. +IFNULL(sy_export_other_costs_premiums,0) +IFNULL(sy_export_supervise_costs_premiums,0)
  3446. +IFNULL(no_export_other_costs_premiums,0)+IFNULL(no_export_supervise_costs_premiums,0) ),2) as
  3447. "exportAllFee",
  3448. ROUND(sum(IFNULL(b.distributionAmount,0)),2) as "distributionAmount"
  3449. from ins_area_company iac
  3450. left join ins_orders io on io.orderno = iac.orderno
  3451. LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
  3452. LEFT JOIN (
  3453. select IFNULL(a.firstDetailPremiums,0) + IFNULL(b.secondDetailPremiums,0) +IFNULL(c.thirdDetailPremiums,0) as
  3454. "distributionAmount",
  3455. a.firstLevelUserId
  3456. from (
  3457. select
  3458. sum(ifon.first_detail_premiums) as "firstDetailPremiums",
  3459. ifon.first_level_user_id as "firstLevelUserId"
  3460. from ins_area_company iac
  3461. left join ins_orders io on io.orderno = iac.orderno
  3462. LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
  3463. <where>
  3464. iac.orderstatus = 3
  3465. <if test="vo.userId !=null and vo.userId !=''">
  3466. AND ifon.first_level_user_id =#{vo.userId}
  3467. </if>
  3468. <if test="vo.ids != null and vo.ids.size()>0 ">
  3469. AND ifon.first_level_user_id IN
  3470. <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
  3471. #{item}
  3472. </foreach>
  3473. </if>
  3474. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  3475. AND iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
  3476. </if>
  3477. </where>
  3478. group by ifon.first_level_user_id
  3479. ) a
  3480. left join (
  3481. select
  3482. sum(IFNULL(second_detail_premiums,0)) as "secondDetailPremiums",
  3483. ifon.two_level_user_id as "twoLevelUserId"
  3484. from ins_area_company iac
  3485. left join ins_orders io on io.orderno = iac.orderno
  3486. LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
  3487. <where>
  3488. iac.orderstatus = 3
  3489. <if test="vo.userId !=null and vo.userId !=''">
  3490. AND ifon.two_level_user_id =#{vo.userId}
  3491. </if>
  3492. <if test="vo.ids != null and vo.ids.size()>0 ">
  3493. AND ifon.two_level_user_id IN
  3494. <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
  3495. #{item}
  3496. </foreach>
  3497. </if>
  3498. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  3499. AND iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
  3500. </if>
  3501. </where>
  3502. group by ifon.two_level_user_id
  3503. ) b on b.twoLevelUserId =a.firstLevelUserId
  3504. left join (
  3505. select
  3506. sum(IFNULL(third_detail_premiums,0)) as "thirdDetailPremiums",
  3507. ifon.three_level_user_id as "threeLevelUserId"
  3508. from ins_area_company iac
  3509. left join ins_orders io on io.orderno = iac.orderno
  3510. LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
  3511. <where>
  3512. iac.orderstatus = 3
  3513. <if test="vo.userId !=null and vo.userId !=''">
  3514. AND ifon.three_level_user_id =#{vo.userId}
  3515. </if>
  3516. <if test="vo.ids != null and vo.ids.size()>0 ">
  3517. AND ifon.three_level_user_id IN
  3518. <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
  3519. #{item}
  3520. </foreach>
  3521. </if>
  3522. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  3523. AND iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
  3524. </if>
  3525. </where>
  3526. group by ifon.three_level_user_id
  3527. ) c on c.threeLevelUserId = a.firstLevelUserId
  3528. ) b on b.firstLevelUserId =iac.leader_id
  3529. <where>
  3530. iac.orderstatus = 3
  3531. <if test="vo.userId !=null and vo.userId !=''">
  3532. AND io.userid =#{vo.userId}
  3533. </if>
  3534. <if test="vo.ids != null and vo.ids.size()>0 ">
  3535. AND io.userid IN
  3536. <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
  3537. #{item}
  3538. </foreach>
  3539. </if>
  3540. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  3541. AND iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
  3542. </if>
  3543. </where>
  3544. </select>
  3545. <select id="getDistributionAllAmount" resultType="java.util.HashMap">
  3546. select IFNULL(a.firstDetailPremiums,0) + IFNULL(b.secondDetailPremiums,0) +IFNULL(c.thirdDetailPremiums,0) as
  3547. "distributionAmount",
  3548. a.firstLevelUserId
  3549. from (
  3550. select
  3551. sum(ifon.first_detail_premiums) as "firstDetailPremiums",
  3552. ifon.first_level_user_id as "firstLevelUserId"
  3553. from ins_area_company iac
  3554. left join ins_orders io on io.orderno = iac.orderno
  3555. LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
  3556. <where>
  3557. <if test="vo.userId !=null and vo.userId !=''">
  3558. ifon.first_level_user_id =#{vo.userId}
  3559. </if>
  3560. <if test="vo.ids != null and vo.ids.size()>0 ">
  3561. AND io.userid IN
  3562. <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
  3563. #{item}
  3564. </foreach>
  3565. </if>
  3566. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  3567. AND iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
  3568. </if>
  3569. </where>
  3570. group by ifon.first_level_user_id
  3571. ) a
  3572. left join (
  3573. select
  3574. sum(IFNULL(second_detail_premiums,0)) as "secondDetailPremiums",
  3575. ifon.two_level_user_id as "twoLevelUserId"
  3576. from ins_area_company iac
  3577. left join ins_orders io on io.orderno = iac.orderno
  3578. LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
  3579. <where>
  3580. <if test="vo.userId !=null and vo.userId !=''">
  3581. ifon.two_level_user_id =#{vo.userId}
  3582. </if>
  3583. <if test="vo.ids != null and vo.ids.size()>0 ">
  3584. AND io.userid IN
  3585. <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
  3586. #{item}
  3587. </foreach>
  3588. </if>
  3589. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  3590. AND iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
  3591. </if>
  3592. </where>
  3593. group by ifon.two_level_user_id
  3594. ) b on b.twoLevelUserId =a.firstLevelUserId
  3595. left join (
  3596. select
  3597. sum(IFNULL(third_detail_premiums,0)) as "thirdDetailPremiums",
  3598. ifon.three_level_user_id as "threeLevelUserId"
  3599. from ins_area_company iac
  3600. left join ins_orders io on io.orderno = iac.orderno
  3601. LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
  3602. <where>
  3603. <if test="vo.userId !=null and vo.userId !=''">
  3604. ifon.three_level_user_id =#{vo.userId}
  3605. </if>
  3606. <if test="vo.ids != null and vo.ids.size()>0 ">
  3607. AND io.userid IN
  3608. <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
  3609. #{item}
  3610. </foreach>
  3611. </if>
  3612. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  3613. AND iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
  3614. </if>
  3615. </where>
  3616. group by ifon.three_level_user_id
  3617. ) c on c.threeLevelUserId = a.firstLevelUserId
  3618. </select>
  3619. <select id="findListByDate" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
  3620. SELECT
  3621. iac.*
  3622. FROM ins_area_company as iac
  3623. <where>
  3624. iac.orderstatus = 3
  3625. and iac.signing_time IS NULL
  3626. <if test="benginDate != null and benginDate!='' and endDate != null and endDate!=''">
  3627. AND iac.createtime BETWEEN #{benginDate} AND #{endDate}
  3628. </if>
  3629. </where>
  3630. order by iac.createtime
  3631. </select>
  3632. <select id="getSumEntryStatus" resultType="java.util.HashMap">
  3633. select ifnull( COUNT( CASE WHEN io.entry_status = '2' THEN 1 END ),0) as "entryStatus",
  3634. ifnull(COUNT( CASE WHEN io.entry_status = '3' THEN 1 END ),0) as "outStatus"
  3635. from ins_area_company iac
  3636. left join ins_orders io on iac.orderno =io.orderno
  3637. <where>
  3638. iac.orderstatus = '3'
  3639. <if test="taskStatisticsVo.userId !=null and taskStatisticsVo.userId != ''">
  3640. and io.userid =#{taskStatisticsVo.userId}
  3641. </if>
  3642. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  3643. AND io.createtime BETWEEN #{taskStatisticsVo.createtimeStart} AND
  3644. #{taskStatisticsVo.createtimeEnd}
  3645. </if>
  3646. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  3647. AND iac.signing_time BETWEEN #{taskStatisticsVo.beginDate} AND #{taskStatisticsVo.endDate}
  3648. </if>
  3649. </where>
  3650. </select>
  3651. <select id="getBusinessDataList" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  3652. select
  3653. a.dockingPerson as "dockingPerson",
  3654. a.dockingPhone as "dockingPhone",
  3655. a.agreementType as "agreementType",
  3656. a.logo as "logo",
  3657. a.companyId as "companyId",
  3658. a.insuranceCompanyName as "insuranceCompanyName",
  3659. a.parterCompanyId as "parterCompanyId",
  3660. a.partnerCompaniesName as "partnerCompaniesName",
  3661. sum(a.totalPremium) as "totalPremium",
  3662. sum(a.qutationInsureCount) as "qutationInsureCount",
  3663. sum(a.totalPremium) / sum(a.qutationInsureCount) AS "averagePremium",
  3664. sum(a.totalPremium) / sum(a.userNumber) as "perCapitaAmount",
  3665. sum(a.userNumber) as "userNumber"
  3666. from (
  3667. select
  3668. a.companyId as "companyId",
  3669. a.insuranceCompanyName as "insuranceCompanyName",
  3670. a.parterCompanyId as "parterCompanyId",
  3671. a.partnerCompaniesName as "partnerCompaniesName",
  3672. a.totalPremium as "totalPremium",
  3673. a.qutationInsureCount as "qutationInsureCount",
  3674. a.userNumber as "userNumber",
  3675. c.docking_person as "dockingPerson",
  3676. c.docking_phone as "dockingPhone",
  3677. c.agreement_type as "agreementType",
  3678. b.logo as "logo"
  3679. from (
  3680. SELECT
  3681. agree.insurance_company_id AS "companyId",
  3682. agree.insurance_company AS "insuranceCompanyName",
  3683. agree.partner_companies_id AS "parterCompanyId",
  3684. ins.namesimple AS "partnerCompaniesName",
  3685. agree.id as "agreeId",
  3686. IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0) as "totalPremium",
  3687. COUNT(0 ) AS "qutationInsureCount",
  3688. (IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0)) / COUNT(0 ) AS
  3689. "averagePremium",
  3690. COUNT(DISTINCT io.userId) AS "userNumber",
  3691. (IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0)) / COUNT(DISTINCT
  3692. io.userId) as "perCapitaAmount"
  3693. FROM
  3694. ins_area_company iac
  3695. LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
  3696. LEFT JOIN ins_orders io on io.orderno = iac.orderno
  3697. LEFT JOIN sys_user su on io.userid =su.id
  3698. LEFT JOIN ins_fee_audit ifa on ifa.ins_order_no =iac.id
  3699. LEFT JOIN esm_ins_company ins ON agree.partner_companies_id = ins.id
  3700. WHERE
  3701. agree.id IS NOT NULL
  3702. and iac.orderstatus = '3'
  3703. and ifa.auditstatus != '2'
  3704. <if test="vo.companyId != null and vo.companyId!='' ">
  3705. and agree.insurance_company_id = #{vo.companyId}
  3706. </if>
  3707. <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
  3708. and agree.partner_companies_id = #{vo.parterCompanyId}
  3709. </if>
  3710. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  3711. iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
  3712. </if>
  3713. <if test="vo.provinceId != null and vo.provinceId != '' and vo.cityId == null and vo.countyId == null and vo.houseId == null ">
  3714. and io.deptid like concat('%',#{vo.provinceId},'%')
  3715. </if>
  3716. <if test="vo.cityId != null and vo.cityId != '' and vo.countyId ==null and vo.houseId ==null">
  3717. and io.deptid like concat('%',#{vo.cityId},'%')
  3718. </if>
  3719. <if test="vo.countyId != null and vo.countyId != '' and vo.houseId ==null">
  3720. and io.deptid like concat('%',#{vo.countyId},'%')
  3721. </if>
  3722. <if test="vo.houseId != null and vo.houseId != ''">
  3723. and io.deptid like concat('%',#{vo.houseId},'%')
  3724. </if>
  3725. <if test="vo.parterProvinceId != null and vo.parterProvinceId != '' and vo.parterCityId == null and vo.parterCountyId == null ">
  3726. and agree.partner_companies_id like concat('%',#{vo.parterProvinceId},'%')
  3727. </if>
  3728. <if test="vo.parterCityId != null and vo.parterCityId != '' and vo.parterCountyId ==null ">
  3729. and agree.partner_companies_id like concat('%',#{vo.parterCityId},'%')
  3730. </if>
  3731. <if test="vo.parterCountyId != null and vo.parterCountyId != '' ">
  3732. and agree.partner_companies_id like concat('%',#{vo.parterCountyId},'%')
  3733. </if>
  3734. <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
  3735. AND io.deptid in
  3736. <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
  3737. #{item}
  3738. </foreach>
  3739. </if>
  3740. <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
  3741. AND su.leader_id in
  3742. <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
  3743. #{item}
  3744. </foreach>
  3745. </if>
  3746. GROUP BY
  3747. agree.insurance_company_id,
  3748. agree.insurance_company,
  3749. agree.partner_companies_id,
  3750. agree.id
  3751. <choose>
  3752. <when test="vo.orderSort != null and vo.orderSort != '' and vo.userNumberSort == null ">
  3753. order by
  3754. sum(sumpremium) ${vo.orderSort == 'asc' ? 'asc' : 'desc'}
  3755. </when>
  3756. <when test="vo.userNumberSort != null and vo.userNumberSort != '' and vo.orderSort == null ">
  3757. order by
  3758. COUNT(DISTINCT io.userId) ${vo.userNumberSort == 'asc' ? 'asc' : 'desc'}
  3759. </when>
  3760. <when test="vo.userNumberSort != null and vo.userNumberSort != '' and vo.orderSort != null and vo.orderSort != '' ">
  3761. order by
  3762. COUNT(DISTINCT io.userId) ${vo.userNumberSort == 'asc' ? 'asc' : 'desc'}, sum(sumpremium)
  3763. ${vo.orderSort == 'asc' ? 'asc' : 'desc'}
  3764. </when>
  3765. </choose>
  3766. ) a
  3767. left join esm_ins_company b on b.id =a.companyId
  3768. left join ptl_agreement c on c.id =a.agreeId
  3769. ) a
  3770. group by
  3771. a.companyId,a.insuranceCompanyName,a.parterCompanyId,a.partnerCompaniesName,a.logo,a.dockingPerson,a.dockingPhone,a.agreementType
  3772. </select>
  3773. <select id="costReviewer" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  3774. SELECT
  3775. ifa.audituser as "audituser",
  3776. su.name as "audituserName",
  3777. su.mobile as "mobile",
  3778. COUNT( CASE WHEN ifa.auditstatus = 1 THEN 1 END ) AS "auditstatusOrders",
  3779. COUNT( CASE WHEN ifa.auditstatus = 0 THEN 1 END ) AS "auditOrder",
  3780. COUNT( CASE WHEN ifa.auditstatus = 1 and ifa.audituser != '自动审核' THEN 1 END ) AS "persionAudit",
  3781. COUNT( CASE WHEN ifa.audituser = '自动审核' THEN 1 END ) AS "automaticAudit"
  3782. FROM
  3783. ins_fee_audit ifa
  3784. LEFT JOIN ins_orders io ON io.orderno = ifa.orderno
  3785. LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
  3786. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  3787. LEFT JOIN esm_ins_company eic ON eic.id = pa.partner_companies_id
  3788. left join sys_user su on su.id =ifa.audituser
  3789. <where>
  3790. 1=1
  3791. and iac.id = ifa.ins_order_no
  3792. and iac.orderstatus = 3
  3793. and (iac.del_flag = '1' or io.del_flag IS NULL or io.del_flag = 1)
  3794. <if test="taskStatisticsVo.reviewer !=null and taskStatisticsVo.reviewer !=''">
  3795. and su.name =#{taskStatisticsVo.reviewer}
  3796. </if>
  3797. <if test="taskStatisticsVo.audittime !=null and taskStatisticsVo.audittime !=''">
  3798. and ifa.audittime =#{taskStatisticsVo.audittime}
  3799. </if>
  3800. <if test="taskStatisticsVo.audituserName !=null and taskStatisticsVo.audituserName !=''">
  3801. AND su.name like concat('%',#{taskStatisticsVo.audituserName},'%')
  3802. </if>
  3803. <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId !=''">
  3804. and iac.company_id =#{taskStatisticsVo.companyId}
  3805. </if>
  3806. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  3807. AND iac.signing_time BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
  3808. </if>
  3809. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  3810. AND iac.signing_time BETWEEN #{taskStatisticsVo.beginDate} AND #{taskStatisticsVo.endDate}
  3811. </if>
  3812. <if test="taskStatisticsVo.auditTimeStart !=null and taskStatisticsVo.auditTimeEnd != '' and taskStatisticsVo.auditTimeStart !=null and taskStatisticsVo.auditTimeEnd != ''">
  3813. and ifa.audittime BETWEEN#{taskStatisticsVo.auditTimeStart} AND #{taskStatisticsVo.auditTimeEnd}
  3814. </if>
  3815. <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
  3816. AND io.deptid in
  3817. <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
  3818. #{item}
  3819. </foreach>
  3820. </if>
  3821. <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
  3822. AND su.id in
  3823. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  3824. #{item}
  3825. </foreach>
  3826. </if>
  3827. <choose>
  3828. <when test="taskStatisticsVo.riskCode != null and taskStatisticsVo.riskCode != '' and taskStatisticsVo.riskCode != 'all' ">
  3829. and iac.product = #{taskStatisticsVo.riskCode}
  3830. </when>
  3831. </choose>
  3832. </where>
  3833. GROUP BY
  3834. ifa.audituser
  3835. </select>
  3836. <select id="getSumEntryStatusNew" resultType="com.ydtech.modules.admin.model.dto.RecordSummaryDto">
  3837. select
  3838. io.userid as userId,
  3839. ifnull( COUNT( CASE WHEN io.entry_status = '2' THEN 1 END ), 0) as "entryStatus",
  3840. ifnull(COUNT( CASE WHEN io.entry_status = '3' THEN 1 END ), 0) as "outStatus"
  3841. from ins_area_company iac
  3842. left join ins_orders io on iac.orderno =io.orderno
  3843. <where>
  3844. iac.orderstatus = '3'
  3845. <if test="sumEntryStatusDo.userIdList != null and !sumEntryStatusDo.userIdList.isEmpty()">
  3846. and io.userid in
  3847. <foreach item="userId" collection="sumEntryStatusDo.userIdList" open="(" separator="," close=")">
  3848. #{userId}
  3849. </foreach>
  3850. </if>
  3851. <if test="sumEntryStatusDo.createtimeStart !=null and sumEntryStatusDo.createtimeStart != '' and sumEntryStatusDo.createtimeEnd !=null and sumEntryStatusDo.createtimeEnd != ''">
  3852. AND io.createtime BETWEEN #{sumEntryStatusDo.createtimeStart} AND
  3853. #{sumEntryStatusDo.createtimeEnd}
  3854. </if>
  3855. <if test="sumEntryStatusDo.beginDate !=null and sumEntryStatusDo.beginDate != '' and sumEntryStatusDo.endDate !=null and sumEntryStatusDo.endDate != ''">
  3856. AND iac.signing_time BETWEEN #{sumEntryStatusDo.beginDate} AND #{sumEntryStatusDo.endDate}
  3857. </if>
  3858. </where>
  3859. group by io.userid
  3860. </select>
  3861. </mapper>