InsAreaCompanyMapper.xml 175 KB

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