InsAreaCompanyMapper.xml 175 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773
  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
  1771. suborder AS "suborder",
  1772. min(create_time) AS "createTime"
  1773. FROM
  1774. ins_orders_track iot_
  1775. WHERE
  1776. order_status =3
  1777. GROUP BY
  1778. suborder
  1779. ) iot on iot.suborder = iac.id
  1780. left join sys_user su on su.id =ifa.audituser
  1781. <where>
  1782. 1=1
  1783. and iac.id = ifa.ins_order_no
  1784. AND iac.orderstatus = 3
  1785. AND ifa.audituser != '自动审核'
  1786. AND (ifa.auditstatus ='1' or ifa.auditstatus ='0')
  1787. <if test="taskStatisticsVo.reviewer !=null and taskStatisticsVo.reviewer !=''">
  1788. and su.name =#{taskStatisticsVo.reviewer}
  1789. </if>
  1790. <if test="taskStatisticsVo.audituser !=null and taskStatisticsVo.audituser !=''">
  1791. and ifa.audituser =#{taskStatisticsVo.audituser}
  1792. </if>
  1793. <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId !=''">
  1794. and iac.company_id =#{taskStatisticsVo.companyId}
  1795. </if>
  1796. <if test="taskStatisticsVo.audittime !=null and taskStatisticsVo.audittime !=''">
  1797. and ifa.audittime =#{taskStatisticsVo.audittime}
  1798. </if>
  1799. <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId !=''">
  1800. and iac.company_id =#{taskStatisticsVo.companyId}
  1801. </if>
  1802. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1803. AND DATE_FORMAT( ifa.audittime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.createtimeStart}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.createtimeEnd}, '%Y-%m-%d')
  1804. </if>
  1805. <if test="taskStatisticsVo.auditTimeStart !=null and taskStatisticsVo.auditTimeEnd != '' and taskStatisticsVo.auditTimeStart !=null and taskStatisticsVo.auditTimeEnd != ''">
  1806. AND DATE_FORMAT( ifa.audittime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.auditTimeStart}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.auditTimeEnd}, '%Y-%m-%d')
  1807. </if>
  1808. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1809. 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')
  1810. </if>
  1811. <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
  1812. AND io.deptid in
  1813. <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
  1814. #{item}
  1815. </foreach>
  1816. </if>
  1817. <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
  1818. AND su.id in
  1819. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  1820. #{item}
  1821. </foreach>
  1822. </if>
  1823. <choose>
  1824. <when test="taskStatisticsVo.riskCode != null and taskStatisticsVo.riskCode != '' and taskStatisticsVo.riskCode != 'all' ">
  1825. and iac.product = #{taskStatisticsVo.riskCode}
  1826. </when>
  1827. </choose>
  1828. </where>
  1829. </select>
  1830. <select id="costCenterSecond" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDtoNew">
  1831. SELECT
  1832. IFNULL(count(io.licenseno),0) as "orderNumber",
  1833. IFNULL(sum(TIMESTAMPDIFF(SECOND, iot.createTime, ifa.audittime)),0) as "sumSecond",
  1834. ROUND(IFNULL(sum(TIMESTAMPDIFF(SECOND, iot.createTime, ifa.audittime)),0) / count(io.licenseno),2) as "averageSecond"
  1835. FROM
  1836. ins_fee_audit ifa
  1837. LEFT JOIN ins_orders io ON io.orderno = ifa.orderno
  1838. LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
  1839. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  1840. LEFT JOIN esm_ins_company eic ON eic.id = pa.partner_companies_id
  1841. left join sys_user su on su.id =ifa.audituser
  1842. left join (
  1843. SELECT
  1844. suborder AS "suborder",
  1845. min(create_time) AS "createTime"
  1846. FROM
  1847. ins_orders_track iot_
  1848. WHERE
  1849. order_status =3
  1850. GROUP BY
  1851. suborder
  1852. ) iot on iot.suborder = iac.id
  1853. <where>
  1854. 1=1
  1855. and iac.id = ifa.ins_order_no
  1856. AND iac.orderstatus = 3
  1857. AND ifa.audituser != '自动审核'
  1858. AND (ifa.auditstatus ='1' or ifa.auditstatus ='0')
  1859. <if test="taskStatisticsVo.reviewer !=null and taskStatisticsVo.reviewer !=''">
  1860. and su.name =#{taskStatisticsVo.reviewer}
  1861. </if>
  1862. <if test="taskStatisticsVo.audituser !=null and taskStatisticsVo.audituser !=''">
  1863. and ifa.audituser =#{taskStatisticsVo.audituser}
  1864. </if>
  1865. <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId !=''">
  1866. and iac.company_id =#{taskStatisticsVo.companyId}
  1867. </if>
  1868. <if test="taskStatisticsVo.audittime !=null and taskStatisticsVo.audittime !=''">
  1869. and ifa.audittime =#{taskStatisticsVo.audittime}
  1870. </if>
  1871. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1872. AND DATE_FORMAT( ifa.audittime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.createtimeStart}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.createtimeEnd}, '%Y-%m-%d')
  1873. </if>
  1874. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1875. 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')
  1876. </if>
  1877. <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
  1878. AND io.deptid in
  1879. <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
  1880. #{item}
  1881. </foreach>
  1882. </if>
  1883. <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
  1884. AND su.id in
  1885. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  1886. #{item}
  1887. </foreach>
  1888. </if>
  1889. <choose>
  1890. <when test="taskStatisticsVo.riskCode != null and taskStatisticsVo.riskCode != '' and taskStatisticsVo.riskCode != 'all' ">
  1891. and iac.product = #{taskStatisticsVo.riskCode}
  1892. </when>
  1893. </choose>
  1894. </where>
  1895. </select>
  1896. <select id="getOrderManpower" resultType="com.ydtech.modules.admin.model.dto.QxFrontlineAgentDto">
  1897. SELECT
  1898. count( a.numberUserId ) as "orderManpower",
  1899. sum( a.orderAmount ) as "totalPremium",
  1900. sum( a.orderAmount )/ count( a.numberUserId ) as "averagePremium"
  1901. FROM
  1902. (
  1903. SELECT
  1904. count( io.userid ) AS "numberUserId",
  1905. SUM(IFNULL(iac.jqpremium, 0)) +
  1906. SUM(IFNULL(iac.sypremium, 0)) +
  1907. SUM(IFNULL(iac.jypremium, 0)) AS "orderAmount"
  1908. FROM
  1909. `ins_area_company` iac
  1910. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  1911. <where>
  1912. iac.orderstatus = '3'
  1913. <if test="ids != null and ids.size()>0 ">
  1914. AND io.userid IN
  1915. <foreach item="item" collection="ids" open="(" separator="," close=")">
  1916. #{item}
  1917. </foreach>
  1918. </if>
  1919. </where>
  1920. GROUP BY
  1921. io.userid
  1922. ) a
  1923. </select>
  1924. <select id="getOrderManpowerNew" resultType="com.ydtech.modules.admin.model.dto.QxFrontlineAgentDto">
  1925. SELECT
  1926. count( a.numberUserId ) as "orderManpower",
  1927. IFNULL(sum( a.orderAmount ),0) as "totalPremium",
  1928. ROUND(sum( a.orderAmount )/ sum(a.ordernoNumber),2) AS "averagePremium"
  1929. FROM
  1930. (
  1931. SELECT
  1932. count( io.userid ) AS "numberUserId",
  1933. count( iac.orderno ) AS "ordernoNumber",
  1934. SUM(IFNULL(iac.jqpremium, 0)
  1935. +IFNULL(iac.sypremium, 0)
  1936. +IFNULL(iac.jypremium, 0)
  1937. ) AS "orderAmount"
  1938. FROM
  1939. `ins_area_company` iac
  1940. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  1941. <where>
  1942. iac.orderstatus = '3'
  1943. <if test="vo.ids != null and vo.ids.size()>0 ">
  1944. AND io.userid IN
  1945. <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
  1946. #{item}
  1947. </foreach>
  1948. </if>
  1949. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  1950. AND iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
  1951. </if>
  1952. </where>
  1953. GROUP BY
  1954. io.userid
  1955. ) a
  1956. <where>
  1957. <if test="vo.outThere != null and vo.outThere!=''">
  1958. <choose>
  1959. <when test=" vo.outThere == 0">
  1960. AND IFNULL(a.orderAmount,0) = 0
  1961. </when>
  1962. <when test="vo.outThere == 1">
  1963. AND IFNULL(a.orderAmount,0) > 0
  1964. </when>
  1965. </choose>
  1966. </if>
  1967. </where>
  1968. order by sum( a.orderAmount ) desc
  1969. </select>
  1970. <select id="getChannelOrderManpowerNew" resultType="com.ydtech.modules.admin.model.dto.QxFrontlineAgentDto">
  1971. SELECT
  1972. a.userId as "userId",
  1973. a.userName as "name",
  1974. a.orderNumber as "orderNumber",
  1975. a.underwritingCount as "underwritingCount",
  1976. a.qutationInsureCount as "qutationInsureCount",
  1977. IFNULL(a.jqpremium,0) + IFNULL(a.sypremium,0) + IFNULL(a.jypremium,0) as "totalPremium",
  1978. a.isFactorVerify as "isFactorVerify",
  1979. a.isNotFactorVerify as "isNotFactorVerify"
  1980. FROM
  1981. (
  1982. SELECT
  1983. io.userid as "userId",
  1984. io.username as "userName",
  1985. count( iac.orderno ) AS "orderNumber",
  1986. sum(CASE WHEN iac.orderstatus = 3 THEN iac.jqpremium END ) AS jqpremium,
  1987. sum(CASE WHEN iac.orderstatus = 3 THEN iac.sypremium END ) AS sypremium,
  1988. sum(CASE WHEN iac.orderstatus = 3 THEN iac.jypremium END ) AS jypremium,
  1989. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
  1990. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  1991. COUNT( CASE WHEN su.factor_verify = 1 THEN 1 END ) AS isFactorVerify,
  1992. COUNT( CASE WHEN su.factor_verify = 0 THEN 1 END ) AS isNotFactorVerify
  1993. FROM
  1994. `ins_area_company` iac
  1995. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  1996. left join sys_user su on su.id=io.userid
  1997. <where>
  1998. <if test="vo.ids != null and vo.ids.size()>0 ">
  1999. AND io.userid IN
  2000. <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
  2001. #{item}
  2002. </foreach>
  2003. </if>
  2004. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  2005. AND iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
  2006. </if>
  2007. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  2008. AND iac.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  2009. </if>
  2010. <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
  2011. AND io.deptid in
  2012. <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
  2013. #{item}
  2014. </foreach>
  2015. </if>
  2016. <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
  2017. AND io.userid in
  2018. <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
  2019. #{item}
  2020. </foreach>
  2021. </if>
  2022. </where>
  2023. GROUP BY
  2024. io.userid,
  2025. io.username
  2026. ) a
  2027. left join sys_user su on su.id=a.userId
  2028. </select>
  2029. <select id="NumberQuotations" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  2030. SELECT
  2031. count(iac.id) as "orderNumber",
  2032. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
  2033. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  2034. sum( CASE WHEN iac.orderstatus = 3 THEN IFNULL(iac.jqpremium, 0) + IFNULL(iac.sypremium, 0) + IFNULL(iac.jypremium, 0) END ) AS totalPremium
  2035. FROM
  2036. ins_area_company iac
  2037. left join ins_orders io on io.orderno = iac.orderno
  2038. left join sys_dept sd on sd.id=io.deptid
  2039. left join sys_user su on su.id=io.userid
  2040. left join ins_fee_audit ifa on ifa .ins_order_no =iac.id
  2041. <where>
  2042. sd.management_source = '2'
  2043. <if test="userId !=null and userId !=''">
  2044. and io.userId =#{userId}
  2045. </if>
  2046. </where>
  2047. </select>
  2048. <select id="totalQuotation" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  2049. SELECT
  2050. agree.insurance_company_id AS companyId,
  2051. agree.insurance_company AS companyName,
  2052. agree.partner_companies_id AS parterCompanyId,
  2053. ins.namesimple AS parterCompanyName,
  2054. count(iac.orderstatus) AS orderNumber,
  2055. '-' as bigQutationCount,
  2056. '-' as bigUnderwritingCount,
  2057. '-' as bigCloseRate,
  2058. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
  2059. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  2060. COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END )/ count(iac.orderstatus) AS passRate,
  2061. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END )/ count(iac.orderstatus) AS underwritingCountRate,
  2062. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )/ count(iac.orderstatus) AS closeRate,
  2063. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )/ COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS
  2064. contributionRate
  2065. FROM
  2066. ins_area_company iac
  2067. LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
  2068. LEFT JOIN ins_orders io on io.orderno = iac.orderno
  2069. LEFT JOIN esm_ins_company ins ON agree.partner_companies_id = ins.id
  2070. WHERE
  2071. agree.id IS NOT NULL
  2072. <if test="vo.companyId != null and vo.companyId!='' ">
  2073. agree.insurance_company_id = #{vo.companyId}
  2074. </if>
  2075. <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
  2076. agree.partner_companies_id = #{vo.parterCompanyId}
  2077. </if>
  2078. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  2079. AND iac.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  2080. </if>
  2081. <if test="vo.provinceId != null and vo.provinceId != ''">
  2082. and io.deptid like "${vo.provinceId}%"
  2083. </if>
  2084. <if test="vo.cityId != null and vo.cityId != ''">
  2085. and io.deptid like "${vo.cityId}%"
  2086. </if>
  2087. <if test="vo.countyId != null and vo.countyId != ''">
  2088. and io.deptid like "${vo.countyId}%"
  2089. </if>
  2090. <if test="taskStatisticsVo.houseId != null and vo.houseId != ''">
  2091. and io.deptid like "${vo.houseId}%"
  2092. </if>
  2093. GROUP BY
  2094. agree.insurance_company_id,
  2095. agree.insurance_company,
  2096. agree.partner_companies_id,
  2097. ins.NAME
  2098. </select>
  2099. <select id="getBusinessData" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  2100. select
  2101. a.dockingPerson as "dockingPerson",
  2102. a.dockingPhone as "dockingPhone",
  2103. a.agreementType as "agreementType",
  2104. a.logo as "logo",
  2105. a.companyId as "companyId",
  2106. a.insuranceCompanyName as "insuranceCompanyName",
  2107. a.parterCompanyId as "parterCompanyId",
  2108. a.partnerCompaniesName as "partnerCompaniesName",
  2109. sum(a.totalPremium) as "totalPremium",
  2110. sum(a.qutationInsureCount) as "qutationInsureCount",
  2111. ROUND(sum(a.totalPremium) / sum(a.qutationInsureCount), 2) AS "averagePremium",
  2112. ROUND(sum(a.totalPremium) / sum(a.userNumber),2) as "perCapitaAmount",
  2113. sum(a.userNumber) as "userNumber"
  2114. from (
  2115. select
  2116. a.companyId as "companyId",
  2117. a.insuranceCompanyName as "insuranceCompanyName",
  2118. a.parterCompanyId as "parterCompanyId",
  2119. a.partnerCompaniesName as "partnerCompaniesName",
  2120. a.totalPremium as "totalPremium",
  2121. a.qutationInsureCount as "qutationInsureCount",
  2122. a.userNumber as "userNumber",
  2123. c.docking_person as "dockingPerson",
  2124. c.docking_phone as "dockingPhone",
  2125. c.agreement_type as "agreementType",
  2126. b.logo as "logo"
  2127. from (
  2128. SELECT
  2129. agree.insurance_company_id AS "companyId",
  2130. agree.insurance_company AS "insuranceCompanyName",
  2131. agree.partner_companies_id AS "parterCompanyId",
  2132. ins.namesimple AS "partnerCompaniesName",
  2133. agree.id as "agreeId",
  2134. IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0) as "totalPremium",
  2135. COUNT(0 ) AS "qutationInsureCount",
  2136. (IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0)) / COUNT(0 ) AS "averagePremium",
  2137. COUNT(DISTINCT io.userId) AS "userNumber",
  2138. (IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0)) / COUNT(DISTINCT io.userId) as "perCapitaAmount"
  2139. FROM
  2140. ins_area_company iac
  2141. LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
  2142. LEFT JOIN ins_orders io on io.orderno = iac.orderno
  2143. LEFT JOIN sys_user su on io.userid =su.id
  2144. LEFT JOIN ins_fee_audit ifa on ifa.ins_order_no =iac.id
  2145. LEFT JOIN esm_ins_company ins ON agree.partner_companies_id = ins.id
  2146. WHERE
  2147. agree.id IS NOT NULL
  2148. and iac.orderstatus = '3'
  2149. and ifa.auditstatus != '2'
  2150. <if test="vo.companyId != null and vo.companyId!='' ">
  2151. and agree.insurance_company_id = #{vo.companyId}
  2152. </if>
  2153. <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
  2154. and agree.partner_companies_id = #{vo.parterCompanyId}
  2155. </if>
  2156. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  2157. 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')
  2158. </if>
  2159. <if test="vo.provinceId != null and vo.provinceId != '' and vo.cityId == null and vo.countyId == null and vo.houseId == null ">
  2160. and io.deptid like concat('%',#{vo.provinceId},'%')
  2161. </if>
  2162. <if test="vo.cityId != null and vo.cityId != '' and vo.countyId ==null and vo.houseId ==null">
  2163. and io.deptid like concat('%',#{vo.cityId},'%')
  2164. </if>
  2165. <if test="vo.countyId != null and vo.countyId != '' and vo.houseId ==null">
  2166. and io.deptid like concat('%',#{vo.countyId},'%')
  2167. </if>
  2168. <if test="vo.houseId != null and vo.houseId != ''">
  2169. and io.deptid like concat('%',#{vo.houseId},'%')
  2170. </if>
  2171. <if test="vo.parterProvinceId != null and vo.parterProvinceId != '' and vo.parterCityId == null and vo.parterCountyId == null ">
  2172. and agree.partner_companies_id like concat('%',#{vo.parterProvinceId},'%')
  2173. </if>
  2174. <if test="vo.parterCityId != null and vo.parterCityId != '' and vo.parterCountyId ==null ">
  2175. and agree.partner_companies_id like concat('%',#{vo.parterCityId},'%')
  2176. </if>
  2177. <if test="vo.parterCountyId != null and vo.parterCountyId != '' ">
  2178. and agree.partner_companies_id like concat('%',#{vo.parterCountyId},'%')
  2179. </if>
  2180. <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
  2181. AND io.deptid in
  2182. <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
  2183. #{item}
  2184. </foreach>
  2185. </if>
  2186. <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
  2187. AND su.leader_id in
  2188. <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
  2189. #{item}
  2190. </foreach>
  2191. </if>
  2192. GROUP BY
  2193. agree.insurance_company_id,
  2194. agree.insurance_company,
  2195. agree.partner_companies_id,
  2196. agree.id
  2197. <choose>
  2198. <when test="vo.orderSort != null and vo.orderSort != '' and vo.userNumberSort == null ">
  2199. order by
  2200. sum(sumpremium) ${vo.orderSort == 'asc' ? 'asc' : 'desc'}
  2201. </when>
  2202. <when test="vo.userNumberSort != null and vo.userNumberSort != '' and vo.orderSort == null ">
  2203. order by
  2204. COUNT(DISTINCT io.userId) ${vo.userNumberSort == 'asc' ? 'asc' : 'desc'}
  2205. </when>
  2206. <when test="vo.userNumberSort != null and vo.userNumberSort != '' and vo.orderSort != null and vo.orderSort != '' ">
  2207. order by
  2208. COUNT(DISTINCT io.userId) ${vo.userNumberSort == 'asc' ? 'asc' : 'desc'}, sum(sumpremium) ${vo.orderSort == 'asc' ? 'asc' : 'desc'}
  2209. </when>
  2210. </choose>
  2211. ) a
  2212. left join esm_ins_company b on b.id =a.companyId
  2213. left join ptl_agreement c on c.id =a.agreeId
  2214. ) a
  2215. group by a.companyId,a.insuranceCompanyName,a.parterCompanyId,a.partnerCompaniesName,a.logo,a.dockingPerson,a.dockingPhone,a.agreementType
  2216. </select>
  2217. <select id="getCountBusinessData" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  2218. select
  2219. sum(a.totalPremium) as "totalPremium",
  2220. sum(a.qutationInsureCount) as "qutationInsureCount",
  2221. ROUND(sum( a.totalPremium ) / sum( a.qutationInsureCount ),2) AS "averagePremium",
  2222. sum(a.userNumber) as "userNumber",
  2223. count(DISTINCT a.insuranceCompanyName) as "insuranceCompanyNumber",
  2224. ROUND(sum(a.totalPremium)/sum(a.userNumber),0) as "perCapitaAmount"
  2225. from (
  2226. SELECT
  2227. agree.insurance_company AS "insuranceCompanyName",
  2228. IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0) as "totalPremium",
  2229. COUNT(0 ) AS "qutationInsureCount",
  2230. COUNT(DISTINCT io.userId) AS "userNumber"
  2231. FROM
  2232. ins_area_company iac
  2233. LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
  2234. LEFT JOIN ins_orders io on io.orderno = iac.orderno
  2235. LEFT JOIN sys_user su on io.userid =su.id
  2236. LEFT JOIN ins_fee_audit ifa on ifa.ins_order_no =iac.id
  2237. WHERE
  2238. agree.id IS NOT NULL
  2239. and iac.orderstatus = '3'
  2240. and ifa.auditstatus != '2'
  2241. <if test="vo.companyId != null and vo.companyId!='' ">
  2242. and agree.insurance_company_id = #{vo.companyId}
  2243. </if>
  2244. <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
  2245. and agree.partner_companies_id = #{vo.parterCompanyId}
  2246. </if>
  2247. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  2248. 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')
  2249. </if>
  2250. <if test="vo.provinceId != null and vo.provinceId != '' and vo.cityId == null and vo.countyId == null and vo.houseId == null ">
  2251. and io.deptid like concat('%',#{vo.provinceId},'%')
  2252. </if>
  2253. <if test="vo.cityId != null and vo.cityId != '' and vo.countyId ==null and vo.houseId ==null">
  2254. and io.deptid like concat('%',#{vo.cityId},'%')
  2255. </if>
  2256. <if test="vo.countyId != null and vo.countyId != '' and vo.houseId ==null">
  2257. and io.deptid like concat('%',#{vo.countyId},'%')
  2258. </if>
  2259. <if test="vo.houseId != null and vo.houseId != ''">
  2260. and io.deptid like concat('%',#{vo.houseId},'%')
  2261. </if>
  2262. <if test="vo.parterProvinceId != null and vo.parterProvinceId != '' and vo.parterCityId == null and vo.parterCountyId == null ">
  2263. and agree.partner_companies_id like concat('%',#{vo.parterProvinceId},'%')
  2264. </if>
  2265. <if test="vo.parterCityId != null and vo.parterCityId != '' and vo.parterCountyId ==null ">
  2266. and agree.partner_companies_id like concat('%',#{vo.parterCityId},'%')
  2267. </if>
  2268. <if test="vo.parterCountyId != null and vo.parterCountyId != '' ">
  2269. and agree.partner_companies_id like concat('%',#{vo.parterCountyId},'%')
  2270. </if>
  2271. <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
  2272. AND io.deptid in
  2273. <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
  2274. #{item}
  2275. </foreach>
  2276. </if>
  2277. <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
  2278. AND su.leader_id in
  2279. <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
  2280. #{item}
  2281. </foreach>
  2282. </if>
  2283. group by
  2284. agree.insurance_company,
  2285. agree.partner_companies_id
  2286. ) a
  2287. </select>
  2288. <select id="getUserNumber" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  2289. SELECT
  2290. COUNT(DISTINCT io.userId) AS "userNumber"
  2291. FROM
  2292. ins_area_company iac
  2293. LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
  2294. LEFT JOIN ins_orders io on io.orderno = iac.orderno
  2295. LEFT JOIN ins_fee_audit ifa on ifa.ins_order_no =iac.id
  2296. LEFT JOIN sys_user su on io.userid =su.id
  2297. WHERE
  2298. agree.id IS NOT NULL
  2299. and iac.orderstatus = '3'
  2300. and ifa.auditstatus != '2'
  2301. <if test="vo.companyId != null and vo.companyId!='' ">
  2302. and agree.insurance_company_id = #{vo.companyId}
  2303. </if>
  2304. <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
  2305. and agree.partner_companies_id = #{vo.parterCompanyId}
  2306. </if>
  2307. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  2308. 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')
  2309. </if>
  2310. <if test="vo.provinceId != null and vo.provinceId != '' and vo.cityId == null and vo.countyId == null and vo.houseId == null ">
  2311. and io.deptid like concat('%',#{vo.provinceId},'%')
  2312. </if>
  2313. <if test="vo.cityId != null and vo.cityId != '' and vo.countyId ==null and vo.houseId ==null">
  2314. and io.deptid like concat('%',#{vo.cityId},'%')
  2315. </if>
  2316. <if test="vo.countyId != null and vo.countyId != '' and vo.houseId ==null">
  2317. and io.deptid like concat('%',#{vo.countyId},'%')
  2318. </if>
  2319. <if test="vo.houseId != null and vo.houseId != ''">
  2320. and io.deptid like concat('%',#{vo.houseId},'%')
  2321. </if>
  2322. <if test="vo.parterProvinceId != null and vo.parterProvinceId != '' and vo.parterCityId == null and vo.parterCountyId == null ">
  2323. and agree.partner_companies_id like concat('%',#{vo.parterProvinceId},'%')
  2324. </if>
  2325. <if test="vo.parterCityId != null and vo.parterCityId != '' and vo.parterCountyId ==null ">
  2326. and agree.partner_companies_id like concat('%',#{vo.parterCityId},'%')
  2327. </if>
  2328. <if test="vo.parterCountyId != null and vo.parterCountyId != '' ">
  2329. and agree.partner_companies_id like concat('%',#{vo.parterCountyId},'%')
  2330. </if>
  2331. <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
  2332. AND io.deptid in
  2333. <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
  2334. #{item}
  2335. </foreach>
  2336. </if>
  2337. <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
  2338. AND su.leader_id in
  2339. <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
  2340. #{item}
  2341. </foreach>
  2342. </if>
  2343. </select>
  2344. <select id="getDistribution" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  2345. SELECT
  2346. agree.insurance_company_id AS "companyId",
  2347. agree.insurance_company AS "insuranceCompanyName",
  2348. agree.partner_companies_id AS "parterCompanyId",
  2349. ins.namesimple AS "partnerCompaniesName",
  2350. IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0) as "totalPremium",
  2351. COUNT(0) AS "qutationInsureCount",
  2352. ROUND((IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0)) / COUNT(0), 2) AS "averagePremium",
  2353. COUNT(DISTINCT io.userId) AS "userNumber",
  2354. ROUND((IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0)) / COUNT(DISTINCT io.userId) ,2) as "perCapitaAmount"
  2355. FROM
  2356. ins_area_company iac
  2357. LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
  2358. LEFT JOIN ins_orders io on io.orderno = iac.orderno
  2359. LEFT JOIN esm_ins_company ins ON agree.partner_companies_id = ins.id
  2360. LEFT JOIN ins_fee_audit ifa on ifa.ins_order_no =iac.id
  2361. WHERE
  2362. agree.id IS NOT NULL
  2363. and ifa.auditstatus != '2'
  2364. <if test="vo.companyId != null and vo.companyId!='' ">
  2365. and agree.insurance_company_id = #{vo.companyId}
  2366. </if>
  2367. <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
  2368. and agree.partner_companies_id = #{vo.parterCompanyId}
  2369. </if>
  2370. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  2371. 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')
  2372. </if>
  2373. <if test="vo.provinceId != null and vo.provinceId != ''">
  2374. and io.deptid like "${vo.provinceId}%"
  2375. </if>
  2376. <if test="vo.cityId != null and vo.cityId != ''">
  2377. and io.deptid like "${vo.cityId}%"
  2378. </if>
  2379. <if test="vo.countyId != null and vo.countyId != ''">
  2380. and io.deptid like "${vo.countyId}%"
  2381. </if>
  2382. <if test="vo.houseId != null and vo.houseId != ''">
  2383. and io.deptid like "${vo.houseId}%"
  2384. </if>
  2385. <if test="vo.quotationStatus != null and vo.quotationStatus != ''">
  2386. and iac.orderstatus =#{vo.quotationStatus}
  2387. </if>
  2388. <if test="vo.dockingPerson != null and vo.dockingPerson != ''">
  2389. and agree.docking_person =#{vo.dockingPerson}
  2390. </if>
  2391. <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
  2392. AND io.deptid in
  2393. <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
  2394. #{item}
  2395. </foreach>
  2396. </if>
  2397. <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
  2398. AND io.userid in
  2399. <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
  2400. #{item}
  2401. </foreach>
  2402. </if>
  2403. <if test="vo.riskCode != null and vo.riskCode != '' and vo.riskCode != 'all'">
  2404. and iac.product = #{vo.riskCode}
  2405. </if>
  2406. GROUP BY
  2407. agree.insurance_company_id,
  2408. agree.insurance_company,
  2409. agree.partner_companies_id,
  2410. ins.namesimple
  2411. </select>
  2412. <select id="getOrderPremiumByUserIds" resultType="Double">
  2413. SELECT
  2414. IFNULL(
  2415. SUM( IFNULL( iac.jqpremium, 0 ) + IFNULL( iac.sypremium, 0 ) + IFNULL( iac.jypremium, 0 ) ),
  2416. 0
  2417. ) AS "totalPremium"
  2418. FROM
  2419. `ins_area_company` iac
  2420. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  2421. <where>
  2422. iac.orderstatus = '3'
  2423. <if test="vo.ids != null and vo.ids.size()>0 ">
  2424. AND io.userid IN
  2425. <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
  2426. #{item}
  2427. </foreach>
  2428. </if>
  2429. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  2430. AND iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
  2431. </if>
  2432. </where>
  2433. </select>
  2434. <select id="querOrdersDataPage" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
  2435. SELECT
  2436. count( 0 ) AS "orderNumber",
  2437. b.licenseno as "licenseno",
  2438. b.frameno as "frameno",
  2439. b.modelCode as "modelCode",
  2440. b.modelcname as "modelcname"
  2441. FROM
  2442. (
  2443. SELECT
  2444. io.orderstatus AS orderstatus,
  2445. io.frameno AS frameno,
  2446. REPLACE(JSON_EXTRACT(io.carinfo, '$.engineNo'), '"', '') as "modelCode",
  2447. REPLACE(JSON_EXTRACT(io.carinfo, '$.modelcname'), '"', '') as "modelcname",
  2448. ifnull(io.licenseno, '') AS licenseno
  2449. FROM
  2450. ins_orders io
  2451. LEFT JOIN sys_user su on io.userid=su.id
  2452. <where>
  2453. 1=1
  2454. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  2455. AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  2456. </if>
  2457. <if test="vo.licenseno != null and vo.licenseno!='' ">
  2458. AND io.licenseno =#{vo.licenseno}
  2459. </if>
  2460. <if test="vo.userId != null and vo.userId!='' ">
  2461. AND io.userid =#{vo.userId}
  2462. </if>
  2463. <if test="vo.userName != null and vo.userName!='' ">
  2464. AND su.name =#{vo.userName}
  2465. </if>
  2466. <if test="vo.mobile != null and vo.mobile!='' ">
  2467. AND su.mobile =#{vo.mobile}
  2468. </if>
  2469. <if test="vo.frameno != null and vo.frameno!='' ">
  2470. AND io.frameno =#{vo.frameno}
  2471. </if>
  2472. <if test="vo.deptId != null and vo.deptId!='' ">
  2473. and io.deptid like concat('%', #{vo.deptId}, '%')
  2474. </if>
  2475. <if test="vo.year != null and vo.year!='' ">
  2476. AND DATE_FORMAT( io.createtime, '%Y') =#{vo.year}
  2477. </if>
  2478. <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
  2479. AND io.deptid in
  2480. <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
  2481. #{item}
  2482. </foreach>
  2483. </if>
  2484. <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
  2485. AND io.userid in
  2486. <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
  2487. #{item}
  2488. </foreach>
  2489. </if>
  2490. </where>
  2491. ) b
  2492. GROUP BY
  2493. b.licenseno,
  2494. b.frameno,
  2495. b.modelCode,
  2496. b.modelcname
  2497. </select>
  2498. <select id="getOrdersGroupByLicenseno" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
  2499. SELECT
  2500. io.licenseno AS "licenseno",
  2501. io.frameno AS "frameno",
  2502. io.orderstatus as "orderstatus",
  2503. io.orderno as "orderno"
  2504. FROM
  2505. ins_orders io
  2506. LEFT JOIN sys_user su on io.userid=su.id
  2507. <where>
  2508. io.licenseno is not null
  2509. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  2510. AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  2511. </if>
  2512. <if test="vo.licenseno != null and vo.licenseno!='' ">
  2513. AND io.licenseno =#{vo.licenseno}
  2514. </if>
  2515. <if test="vo.userId != null and vo.userId!='' ">
  2516. AND io.userId =#{vo.userId}
  2517. </if>
  2518. <if test="vo.userName != null and vo.userName!='' ">
  2519. AND su.name =#{vo.userName}
  2520. </if>
  2521. <if test="vo.mobile != null and vo.mobile!='' ">
  2522. AND su.mobile =#{vo.mobile}
  2523. </if>
  2524. <if test="vo.frameno != null and vo.frameno!='' ">
  2525. AND su.frameno =#{vo.frameno}
  2526. </if>
  2527. <if test="vo.deptId != null and vo.deptId!='' ">
  2528. and io.deptid like concat('%', #{vo.deptId}, '%')
  2529. </if>
  2530. </where>
  2531. </select>
  2532. <select id="querOrdersamountTo" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
  2533. select sum(a.orderNumber) as "orderNumber",
  2534. count(a.licenseno) as "b.frameno"
  2535. from (
  2536. SELECT
  2537. count( 0 ) AS "orderNumber",
  2538. b.licenseno as "licenseno",
  2539. b.frameno as "frameno"
  2540. FROM
  2541. (
  2542. SELECT
  2543. io.orderstatus AS orderstatus,
  2544. io.frameno AS frameno,
  2545. ifnull(io.licenseno, '') AS licenseno
  2546. FROM
  2547. ins_orders io
  2548. LEFT JOIN sys_user su on io.userid=su.id
  2549. <where>
  2550. 1=1
  2551. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  2552. AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  2553. </if>
  2554. <if test="vo.licenseno != null and vo.licenseno!='' ">
  2555. AND io.licenseno =#{vo.licenseno}
  2556. </if>
  2557. <if test="vo.userId != null and vo.userId!='' ">
  2558. AND io.userid =#{vo.userId}
  2559. </if>
  2560. <if test="vo.userName != null and vo.userName!='' ">
  2561. AND su.name =#{vo.userName}
  2562. </if>
  2563. <if test="vo.mobile != null and vo.mobile!='' ">
  2564. AND su.mobile =#{vo.mobile}
  2565. </if>
  2566. <if test="vo.frameno != null and vo.frameno!='' ">
  2567. AND io.frameno =#{vo.frameno}
  2568. </if>
  2569. <if test="vo.deptId != null and vo.deptId!='' ">
  2570. and io.deptid like concat('%', #{vo.deptId}, '%')
  2571. </if>
  2572. </where>
  2573. ) b
  2574. GROUP BY
  2575. b.licenseno,
  2576. b.frameno
  2577. ) a
  2578. </select>
  2579. <select id="querResultOrderNumber" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
  2580. SELECT
  2581. count( io.orderno ) AS "orderNumber",
  2582. 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"
  2583. FROM
  2584. ins_orders io
  2585. LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
  2586. LEFT JOIN sys_user su ON io.userid = su.id
  2587. <where>
  2588. 1=1
  2589. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  2590. AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  2591. </if>
  2592. <if test="vo.licenseno != null and vo.licenseno!='' ">
  2593. AND io.licenseno =#{vo.licenseno}
  2594. </if>
  2595. <if test="vo.userId != null and vo.userId!='' ">
  2596. AND io.userid =#{vo.userId}
  2597. </if>
  2598. <if test="vo.userName != null and vo.userName!='' ">
  2599. AND su.name =#{vo.userName}
  2600. </if>
  2601. <if test="vo.mobile != null and vo.mobile!='' ">
  2602. AND su.mobile =#{vo.mobile}
  2603. </if>
  2604. <if test="vo.frameno != null and vo.frameno!='' ">
  2605. AND su.frameno =#{vo.frameno}
  2606. </if>
  2607. <if test="vo.deptId != null and vo.deptId!='' ">
  2608. and io.deptid like concat('%', #{vo.deptId}, '%')
  2609. </if>
  2610. </where>
  2611. </select>
  2612. <select id="numberQuotationsByUserIds" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  2613. SELECT
  2614. count(iac.id) as "orderNumber",
  2615. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
  2616. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  2617. sum( CASE WHEN iac.orderstatus = 3 THEN IFNULL(iac.jqpremium, 0) + IFNULL(iac.sypremium, 0) + IFNULL(iac.jypremium, 0) END ) AS totalPremium
  2618. FROM
  2619. ins_area_company iac
  2620. left join ins_orders io on io.orderno = iac.orderno
  2621. <where>
  2622. <if test="ids != null and ids.size()>0 ">
  2623. AND io.userid IN
  2624. <foreach item="item" collection="ids" open="(" separator="," close=")">
  2625. #{item}
  2626. </foreach>
  2627. </if>
  2628. <if test="month != null and month!='' ">
  2629. AND DATE_FORMAT(iac.createtime, '%Y-%m') =#{month}
  2630. </if>
  2631. </where>
  2632. </select>
  2633. <select id="selectByOrdersDataVo" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
  2634. select
  2635. iac.inscompany as "namesimple"
  2636. from
  2637. ins_area_company iac
  2638. <where>
  2639. 1=1
  2640. <if test="vo.orderstatus != null and vo.orderstatus != '' ">
  2641. AND iac.orderstatus =#{vo.orderstatus}
  2642. </if>
  2643. <if test="vo.orderno !=null and vo.orderno !='' ">
  2644. AND iac.orderno =#{vo.orderno}
  2645. </if>
  2646. </where>
  2647. </select>
  2648. <select id="channelExcel" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsExcel">
  2649. select a.*,(select name from sys_user where id =a.userId) as "userName"
  2650. from (
  2651. SELECT
  2652. sd.NAME AS "deptName",
  2653. io.userid AS "userId",
  2654. sd.parent_id as "deptId",
  2655. sd.management_source as "managementSource",
  2656. COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS qutationCount,
  2657. COUNT( CASE WHEN iot.order_status ='2' THEN 1 END ) AS underwritingCount,
  2658. COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) AS qutationInsureCount,
  2659. COUNT( CASE WHEN iot.order_status = '4' THEN 1 END ) AS underwritingReturn,
  2660. COUNT( CASE WHEN iot.order_status ='2' THEN 1 END ) / COUNT( CASE WHEN iot.order_status ='0' THEN 1 END ) AS "passingRate",
  2661. 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",
  2662. (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",
  2663. 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",
  2664. COUNT(CASE WHEN io.order_source = 0 and iot.order_status ='0' THEN 1 END) as "pcOrderSource",
  2665. COUNT(CASE WHEN io.order_source = 1 and iot.order_status ='0' THEN 1 END) as "appOrderSource",
  2666. COUNT( CASE WHEN iot.order_status = '1' THEN 1 END ) AS "auditOrder"
  2667. FROM
  2668. (
  2669. select iot.suborder,iot.order_status from `ins_orders_track` iot
  2670. GROUP BY iot.suborder ,iot.order_status
  2671. ) iot
  2672. left join ins_area_company iac ON iac.id = iot.suborder
  2673. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  2674. LEFT JOIN sys_dept sd ON sd.id = io.deptid
  2675. <where>
  2676. <if test="taskStatisticsVo.managementSource != null and taskStatisticsVo.managementSource!=''">
  2677. AND sd.management_source =#{taskStatisticsVo.managementSource}
  2678. </if>
  2679. <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
  2680. and io.deptid like "${taskStatisticsVo.provinceId}%"
  2681. </if>
  2682. <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
  2683. and io.deptid like "${taskStatisticsVo.cityId}%"
  2684. </if>
  2685. <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
  2686. and io.deptid like "${taskStatisticsVo.countyId}%"
  2687. </if>
  2688. <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
  2689. and io.deptid like "${taskStatisticsVo.houseId}%"
  2690. </if>
  2691. <if test="taskStatisticsVo.userId != null and taskStatisticsVo.userId != ''">
  2692. and io.userid =#{taskStatisticsVo.userId}
  2693. </if>
  2694. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  2695. AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
  2696. </if>
  2697. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  2698. 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')
  2699. </if>
  2700. <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
  2701. AND sd.id in
  2702. <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
  2703. #{item}
  2704. </foreach>
  2705. </if>
  2706. <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
  2707. AND io.userid in
  2708. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  2709. #{item}
  2710. </foreach>
  2711. </if>
  2712. </where>
  2713. GROUP BY
  2714. io.userid,
  2715. sd.NAME,
  2716. sd.id,
  2717. sd.management_source
  2718. ) a
  2719. left join sys_user su on su.id =a.userId
  2720. LEFT JOIN ins_upload_files inf on su.head_sculpture =inf.id
  2721. LEFT JOIN sys_user_info sui on sui .id =su.id
  2722. LEFT JOIN sys_user su2 on su2.id =su.leader_id
  2723. <where>
  2724. <if test='taskStatisticsVo.userName !=null and taskStatisticsVo.userName!="" '>
  2725. and su.name like concat('%',#{taskStatisticsVo.userName},'%')
  2726. </if>
  2727. <if test='taskStatisticsVo.leaderId !=null and taskStatisticsVo.leaderId!="" '>
  2728. and su.leader_id =#{taskStatisticsVo.leaderId}
  2729. </if>
  2730. <if test='taskStatisticsVo.userId !=null and taskStatisticsVo.userId!="" '>
  2731. and su.id =#{taskStatisticsVo.userId}
  2732. </if>
  2733. </where>
  2734. </select>
  2735. <select id="insuranceCompanyExcel" resultType="com.ydtech.modules.admin.model.dto.InsuranceCompanyExcel">
  2736. SELECT
  2737. a.*,
  2738. ( SELECT eic.namesimple FROM esm_ins_company eic WHERE eic.id = a.partner_companies_id ) AS "partnerCompaniesName"
  2739. FROM
  2740. (
  2741. SELECT
  2742. pa.insurance_company_id,
  2743. pa.partner_companies_id,
  2744. pa.insurance_company AS "insuranceCompanyName",
  2745. COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS qutationCount,
  2746. COUNT( CASE WHEN iot.order_status = '1' THEN 1 END ) AS "auditOrder",
  2747. COUNT( CASE WHEN iot.order_status = '2' THEN 1 END ) AS underwritingCount,
  2748. COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) AS qutationInsureCount,
  2749. COUNT( CASE WHEN iot.order_status = '4' THEN 1 END ) AS underwritingReturn,
  2750. COUNT( CASE WHEN iot.order_status ='2' THEN 1 END ) / COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS "passingRate",
  2751. COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) / COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS "closeRate",
  2752. (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",
  2753. COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) / COUNT( iot.order_status ) AS "quotationRate"
  2754. FROM
  2755. (
  2756. select iot.suborder,iot.order_status from `ins_orders_track` iot
  2757. GROUP BY iot.suborder ,iot.order_status
  2758. ) iot
  2759. LEFT JOIN ins_area_company iac ON iac.id = iot.suborder
  2760. LEFT JOIN ins_fee_audit ifa ON ifa.ins_order_no = iac.id
  2761. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  2762. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  2763. <where>
  2764. pa.insurance_company_id IS NOT NULL
  2765. <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
  2766. and io.deptid like concat('%', #{taskStatisticsVo.provinceId}, '%')
  2767. </if>
  2768. <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
  2769. and io.deptid like concat('%', #{taskStatisticsVo.cityId}, '%')
  2770. </if>
  2771. <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
  2772. and io.deptid like concat('%', #{taskStatisticsVo.countyId}, '%')
  2773. </if>
  2774. <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
  2775. and io.deptid like concat('%', #{taskStatisticsVo.houseId}, '%')
  2776. </if>
  2777. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  2778. AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT(#{taskStatisticsVo.createtimeStart},'%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.createtimeEnd}, '%Y-%m-%d')
  2779. </if>
  2780. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  2781. AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
  2782. </if>
  2783. <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId != ''">
  2784. AND iac.company_id =#{taskStatisticsVo.companyId}
  2785. </if>
  2786. <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
  2787. AND io.deptid in
  2788. <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
  2789. #{item}
  2790. </foreach>
  2791. </if>
  2792. <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
  2793. AND io.userid in
  2794. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  2795. #{item}
  2796. </foreach>
  2797. </if>
  2798. </where>
  2799. GROUP BY
  2800. pa.insurance_company_id,
  2801. pa.partner_companies_id,
  2802. pa.insurance_company
  2803. ) a
  2804. </select>
  2805. <select id="getSumBigOrderCount" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
  2806. select count(0) as "orderNumber",
  2807. GROUP_CONCAT(inscompany ORDER BY inscompany SEPARATOR ',') as "namesimple"
  2808. from ins_area_company iac
  2809. left join ins_orders io on io.orderno = iac.orderno
  2810. <where>
  2811. 1=1
  2812. and iac.orderstatus ='3'
  2813. and io.orderstatus ='3'
  2814. <if test="vo.licenseno !=null and vo.licenseno!=''">
  2815. AND io.licenseno =#{vo.licenseno}
  2816. </if>
  2817. <if test="vo.frameno !=null and vo.frameno!=''">
  2818. AND io.frameno =#{vo.frameno}
  2819. </if>
  2820. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  2821. AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  2822. </if>
  2823. <if test="vo.year != null and vo.year!='' ">
  2824. AND DATE_FORMAT( io.createtime, '%Y') =#{vo.year}
  2825. </if>
  2826. </where>
  2827. limit 10
  2828. </select>
  2829. <select id="queryAgencyUserInsAreaPage" resultType="com.ydtech.modules.admin.model.vo.AgencyUserInsAreaVo">
  2830. select
  2831. io.userid as userId,
  2832. io.username as userName,
  2833. io.licenseno as licenseno,
  2834. iac.id as companyId,
  2835. iac.jqpremium as jqpremium,
  2836. iac.sypremium as sypremium,
  2837. iac.jypremium as jypremium,
  2838. iac.createtime as createtime,
  2839. iac.orderstatus as orderstatus
  2840. from ins_area_company iac
  2841. left join ins_orders io on io.orderno = iac.orderno
  2842. <where>
  2843. iac.orderstatus=3
  2844. <if test="dto.userId !=null and dto.userId !=''">
  2845. and io.userid = #{dto.userId}
  2846. </if>
  2847. <if test="dto.deptId !=null and dto.deptId !=''">
  2848. and io.deptid like concat( #{dto.deptId}, '%')
  2849. </if>
  2850. <if test="dto.startTime !=null and dto.startTime !=''">
  2851. and io.createtime >= #{dto.startTime}
  2852. </if>
  2853. </where>
  2854. ORDER BY iac.createtime
  2855. </select>
  2856. <select id="querOrdersDataListExcel" resultType="com.ydtech.modules.admin.model.dto.OrdersDataExcel">
  2857. SELECT
  2858. count( 0 ) AS "orderNumber",
  2859. b.licenseno as "licenseno",
  2860. b.frameno as "frameno",
  2861. b.modelCode as "modelCode",
  2862. b.modelcname as "modelcname"
  2863. FROM
  2864. (
  2865. SELECT
  2866. io.orderstatus AS orderstatus,
  2867. io.frameno AS frameno,
  2868. REPLACE(JSON_EXTRACT(io.carinfo, '$.engineNo'), '"', '') as "modelCode",
  2869. REPLACE(JSON_EXTRACT(io.carinfo, '$.modelcname'), '"', '') as "modelcname",
  2870. ifnull(io.licenseno, '') AS licenseno
  2871. FROM
  2872. ins_orders io
  2873. LEFT JOIN sys_user su on io.userid=su.id
  2874. <where>
  2875. 1=1
  2876. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  2877. AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  2878. </if>
  2879. <if test="vo.licenseno != null and vo.licenseno!='' ">
  2880. AND io.licenseno =#{vo.licenseno}
  2881. </if>
  2882. <if test="vo.userId != null and vo.userId!='' ">
  2883. AND io.userid =#{vo.userId}
  2884. </if>
  2885. <if test="vo.userName != null and vo.userName!='' ">
  2886. AND su.name =#{vo.userName}
  2887. </if>
  2888. <if test="vo.mobile != null and vo.mobile!='' ">
  2889. AND su.mobile =#{vo.mobile}
  2890. </if>
  2891. <if test="vo.frameno != null and vo.frameno!='' ">
  2892. AND io.frameno =#{vo.frameno}
  2893. </if>
  2894. <if test="vo.deptId != null and vo.deptId!='' ">
  2895. and io.deptid like concat('%', #{vo.deptId}, '%')
  2896. </if>
  2897. <if test="vo.year != null and vo.year!='' ">
  2898. AND DATE_FORMAT( io.createtime, '%Y') =#{vo.year}
  2899. </if>
  2900. <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
  2901. AND io.deptid in
  2902. <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
  2903. #{item}
  2904. </foreach>
  2905. </if>
  2906. <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
  2907. AND io.userid in
  2908. <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
  2909. #{item}
  2910. </foreach>
  2911. </if>
  2912. </where>
  2913. ) b
  2914. GROUP BY
  2915. b.licenseno,
  2916. b.frameno,
  2917. b.modelCode,
  2918. b.modelcname
  2919. </select>
  2920. <select id="orderCheckPage" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
  2921. select
  2922. iac.id,
  2923. iac.orderno,
  2924. iac.agreement_id,
  2925. iac.jqpremium,
  2926. iac.sypremium,
  2927. iac.jypremium,
  2928. iac.taxamount,
  2929. iac.sumpremium,
  2930. io.licenseno,
  2931. iac.createtime,
  2932. su.name as auditname
  2933. FROM
  2934. ins_area_company iac
  2935. LEFT JOIN
  2936. ins_orders io on iac.orderno = io.orderno
  2937. left join ptl_agreement agree on iac.agreement_id =agree.id
  2938. left join ins_fee_audit ifa on iac.id = ifa.ins_order_no
  2939. left join sys_user su on su.id= ifa.audituser
  2940. WHERE
  2941. iac.operator_id = #{userId}
  2942. AND
  2943. iac.orderstatus = 3
  2944. and agree.is_external =1
  2945. and auditstatus =1
  2946. <if test="vo.id != null and vo.id!='' ">
  2947. and iac.id = #{vo.id}
  2948. </if>
  2949. <if test="vo.licenseno != null and vo.licenseno!='' ">
  2950. and io.licenseno like CONCAT('%', #{vo.licenseno}, '%')
  2951. </if>
  2952. </select>
  2953. <select id="costCenterTotal" resultType="java.util.HashMap">
  2954. SELECT
  2955. COUNT( CASE WHEN ifa.auditstatus = 1 THEN 1 END ) AS "allAuditstatusOrders",
  2956. COUNT( CASE WHEN ifa.auditstatus = 0 THEN 1 END ) AS "allAuditOrder",
  2957. COUNT( CASE WHEN ifa.auditstatus = 1 and ifa.audituser != '自动审核' THEN 1 END ) AS "allPersionAudit",
  2958. COUNT( CASE WHEN ifa.audituser = '自动审核' THEN 1 END ) AS "allAutomaticAudit"
  2959. FROM
  2960. ins_fee_audit ifa
  2961. LEFT JOIN ins_orders io ON io.orderno = ifa.orderno
  2962. LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
  2963. AND iac.orderstatus = 3
  2964. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  2965. LEFT JOIN esm_ins_company eic ON eic.id = pa.partner_companies_id
  2966. left join sys_user su on su.id =ifa.audituser
  2967. <where>
  2968. 1=1
  2969. and iac.id = ifa.ins_order_no
  2970. AND iac.orderstatus = 3
  2971. <if test="taskStatisticsVo.reviewer !=null and taskStatisticsVo.reviewer !=''">
  2972. and su.name =#{taskStatisticsVo.reviewer}
  2973. </if>
  2974. <if test="taskStatisticsVo.audittime !=null and taskStatisticsVo.audittime !=''">
  2975. and ifa.audittime =#{taskStatisticsVo.audittime}
  2976. </if>
  2977. <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId !=''">
  2978. and iac.company_id =#{taskStatisticsVo.companyId}
  2979. </if>
  2980. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  2981. 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')
  2982. </if>
  2983. <if test="taskStatisticsVo.auditTimeStart !=null and taskStatisticsVo.auditTimeEnd != '' and taskStatisticsVo.auditTimeStart !=null and taskStatisticsVo.auditTimeEnd != ''">
  2984. AND DATE_FORMAT( ifa.audittime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.auditTimeStart}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.auditTimeEnd}, '%Y-%m-%d')
  2985. </if>
  2986. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  2987. 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')
  2988. </if>
  2989. <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
  2990. AND io.deptid in
  2991. <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
  2992. #{item}
  2993. </foreach>
  2994. </if>
  2995. <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
  2996. AND su.id in
  2997. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  2998. #{item}
  2999. </foreach>
  3000. </if>
  3001. <choose>
  3002. <when test="taskStatisticsVo.riskCode != null and taskStatisticsVo.riskCode != '' and taskStatisticsVo.riskCode != 'all' ">
  3003. and iac.product = #{taskStatisticsVo.riskCode}
  3004. </when>
  3005. </choose>
  3006. </where>
  3007. </select>
  3008. <select id="getSubOrderCountDTO" resultType="com.ydtech.modules.order.entity.dto.SubOrderCountDTO">
  3009. select orderno, orderstatus, count(*)as count
  3010. from (select orderno, company_id, orderstatus
  3011. from ins_area_company
  3012. where orderno in
  3013. <foreach collection="orderNo" open="(" separator="," close=")" item="item" index="index">
  3014. #{item,jdbcType=VARCHAR}
  3015. </foreach>
  3016. and del_flag = '1'
  3017. group by orderno, company_id, orderstatus) as iac
  3018. group by orderno, orderstatus
  3019. </select>
  3020. <select id="getAllRejectOrders" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
  3021. select
  3022. iac.id,
  3023. iac.orderno,
  3024. iac.agreement_id,
  3025. iac.jqpremium,
  3026. iac.sypremium,
  3027. iac.jypremium,
  3028. iac.taxamount,
  3029. iac.sumpremium,
  3030. io.licenseno,
  3031. ifa.audittime,
  3032. ifa.audituser as auditname,
  3033. ifa.rejectinfo,
  3034. "1" as orderExternalStatus
  3035. FROM
  3036. ins_fee_audit ifa
  3037. LEFT JOIN
  3038. ins_area_company iac on iac.id = ifa.ins_order_no
  3039. LEFT JOIN
  3040. ins_orders io on iac.orderno = io.orderno
  3041. left join
  3042. sys_user su on su.id= ifa.audituser
  3043. WHERE
  3044. ifa.auditstatus = 2 and IFNULL(iac.del_flag,'') != '0'
  3045. <if test="vo.id != null and vo.id!=''">
  3046. and iac.id = #{vo.id}
  3047. </if>
  3048. <if test="vo.licenseno != null and vo.licenseno!='' ">
  3049. and io.licenseno like CONCAT('%', #{vo.licenseno}, '%')
  3050. </if>
  3051. <if test="vo.auditname != null and vo.auditname!='' ">
  3052. and su.name like CONCAT('%', #{vo.auditname}, '%')
  3053. </if>
  3054. order by io.createtime
  3055. </select>
  3056. <select id="queryPageOrderCB" resultType="com.ydtech.modules.order.entity.InsOrders">
  3057. SELECT
  3058. iac.id as orderno,
  3059. io.quoteno,
  3060. iac.orderstatus,
  3061. iac.company_id,
  3062. iac.inscompany,
  3063. io.carinfo,
  3064. io.userid,
  3065. io.username,
  3066. io.deptid,
  3067. io.deptname,
  3068. io.agreeid,
  3069. iac.productid,
  3070. iac.product,
  3071. iac.createtime,
  3072. io.frameno,
  3073. io.licenseno,
  3074. JSON_UNQUOTE(json_extract(io.insureinfo, '$.name')) as insuredname,
  3075. io.is_external,
  3076. iac.jq_start_date as jqstartdate,
  3077. iac.jq_end_date as jqenddate,
  3078. iac.sy_start_date as systartdate,
  3079. iac.sy_end_date as syenddate,
  3080. io.vehicle_and_vessel_tax,
  3081. io.operatorid,
  3082. iac.operator_name,
  3083. sd.management_source,
  3084. iac.problem_order,
  3085. eic.namesimple as partnerCompaniesName,
  3086. iac.id as subOrderId,
  3087. iac.signing_time as signingTime,
  3088. iac.pay_date as payDate,
  3089. pa.agreement_code as agreementCode,
  3090. pa.agreement_name as agreementName,
  3091. pa.business_description as businessDescription,
  3092. pa.job_description as jobDescription,
  3093. pa.agreement_title as agreementTitle,
  3094. pa.docking_person as dockingPerson,
  3095. io.entry_status
  3096. FROM
  3097. ins_area_company iac
  3098. LEFT JOIN ins_orders io ON iac.orderno = io.orderno
  3099. LEFT JOIN sys_user su ON su.id = io.userid
  3100. LEFT JOIN sys_dept sd ON sd.id = su.dept_id
  3101. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  3102. LEFT JOIN esm_ins_company eic ON eic.id = pa.partner_companies_id
  3103. WHERE
  3104. iac.orderstatus = 3
  3105. <if test="params.quoteStartDateStr != null and params.quoteStartDateStr != '' and params.quoteEndDateStr != null and params.quoteEndDateStr != ''">
  3106. and DATE_FORMAT(iac.createtime, '%Y-%m-%d') between #{params.quoteStartDateStr} AND
  3107. #{params.quoteEndDateStr}
  3108. </if>
  3109. <if test="params.orderNo != null and params.orderNo != ''">
  3110. AND iac.id= #{params.orderNo}
  3111. </if>
  3112. <if test="params.licenseNo != null and params.licenseNo != ''">
  3113. AND io.licenseno = #{params.licenseNo}
  3114. </if>
  3115. <if test="params.frameNo != null and params.frameNo != ''">
  3116. AND io.frameno = #{params.frameNo}
  3117. </if>
  3118. <if test="params.insuredName != null and params.insuredName != ''">
  3119. AND json_extract(io.insureinfo, '$.name') = #{params.insuredName}
  3120. </if>
  3121. <if test="params.companyId != null and params.companyId != ''">
  3122. AND iac.company_id = #{params.companyId}
  3123. </if>
  3124. <if test="params.engineNo != null and params.engineNo != ''">
  3125. and JSON_EXTRACT( io.carinfo, '$.engineNo' ) = #{params.engineNo}
  3126. </if>
  3127. <if test="params.riskCode != null and params.riskCode != ''">
  3128. and iac.product = #{params.riskCode}
  3129. </if>
  3130. <if test="params.attachStartDateStr != null and params.attachStartDateStr != '' and params.attachStartDateStr != null and params.attachStartDateStr != '' ">
  3131. and ((
  3132. DATE_FORMAT(iac.jq_start_date, '%Y-%m-%d') BETWEEN #{params.attachStartDateStr}
  3133. AND #{params.attachEndDateStr}
  3134. )
  3135. OR ( DATE_FORMAT(iac.sy_start_date, '%Y-%m-%d') BETWEEN #{params.attachStartDateStr} AND
  3136. #{params.attachEndDateStr} )
  3137. )
  3138. </if>
  3139. <if test="params.provinceId != null and params.provinceId != ''">
  3140. and io.deptid like "${params.provinceId}%"
  3141. </if>
  3142. <if test="params.problemOrder != null and params.problemOrder != ''">
  3143. and iac.problem_order like "${params.problemOrder}%"
  3144. </if>
  3145. <if test="params.cityId != null and params.cityId != ''">
  3146. and io.deptid like "${params.cityId}%"
  3147. </if>
  3148. <if test="params.countyId != null and params.countyId != ''">
  3149. and io.deptid like "${params.countyId}%"
  3150. </if>
  3151. <if test="params.houseId != null and params.houseId != ''">
  3152. and io.deptid like "${params.houseId}%"
  3153. </if>
  3154. <if test="params.operatorId != null and params.operatorId != ''">
  3155. and io.userid = #{params.operatorId}
  3156. </if>
  3157. <if test="params.operatorName != null and params.operatorName != ''">
  3158. and io.username = #{params.operatorName}
  3159. </if>
  3160. <if test="params.auditId != null and params.auditId != ''">
  3161. and iac.new_operator_id = #{params.auditId}
  3162. </if>
  3163. <if test="params.agreeId != null and params.agreeId != ''">
  3164. and iac.agreement_id = #{params.agreeId}
  3165. </if>
  3166. <if test="params.managementSource != null and params.managementSource != ''">
  3167. and sd.management_source = #{params.managementSource}
  3168. </if>
  3169. <if test="params.signStartDateStr != null and params.signStartDateStr != '' and params.signEndDateStr != null and params.signEndDateStr != ''">
  3170. and DATE_FORMAT(iac.signing_time, '%Y-%m-%d') between #{params.signStartDateStr} AND
  3171. #{params.signEndDateStr}
  3172. </if>
  3173. <if test="params.payStartDateStr != null and params.payStartDateStr != '' and params.payEndDateStr != null and params.payEndDateStr != ''">
  3174. and iac.pay_date between #{params.payStartDateStr} AND #{params.payEndDateStr}
  3175. </if>
  3176. <if test="params.isExternal != null and params.isExternal != ''">
  3177. and io.is_external = #{params.isExternal}
  3178. </if>
  3179. <if test="params.jqPolicyNo != null and params.jqPolicyNo != ''">
  3180. and iac.jqpolicyno = #{params.jqPolicyNo}
  3181. </if>
  3182. <if test="params.syPolicyNo != null and params.syPolicyNo != ''">
  3183. and iac.sypolicyno = #{params.syPolicyNo}
  3184. </if>
  3185. <if test="params.noPolicyNo != null and params.noPolicyNo != ''">
  3186. and iac.cross_insurance like concat('%', #{params.noPolicyNo}, '%')
  3187. </if>
  3188. order by iac.createtime desc
  3189. </select>
  3190. <select id="getExpectNetProfit" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
  3191. select
  3192. ROUND(sum(IFNULL(ifon.jq_costs_premiums,0) + IFNULL(ifon.sy_costs_premiums,0) + IFNULL (ifon.no_costs_premiums,0)),2) as "entranceAllFee",
  3193. ROUND(sum(IFNULL(jq_export_other_costs_premiums,0) + IFNULL(jq_export_supervise_costs_premiums,0)
  3194. +IFNULL(sy_export_other_costs_premiums,0) +IFNULL(sy_export_supervise_costs_premiums,0)
  3195. +IFNULL(no_export_other_costs_premiums,0)+IFNULL(no_export_supervise_costs_premiums,0) ),2) as
  3196. "exportAllFee",
  3197. ROUND(sum(IFNULL(b.distributionAmount,0)),2) as "distributionAmount"
  3198. from ins_area_company iac
  3199. left join ins_orders io on io.orderno = iac.orderno
  3200. LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
  3201. LEFT JOIN (
  3202. select IFNULL(a.firstDetailPremiums,0) + IFNULL(b.secondDetailPremiums,0) +IFNULL(c.thirdDetailPremiums,0) as "distributionAmount",
  3203. a.firstLevelUserId
  3204. from (
  3205. select
  3206. sum(ifon.first_detail_premiums) as "firstDetailPremiums",
  3207. ifon.first_level_user_id as "firstLevelUserId"
  3208. from ins_area_company iac
  3209. left join ins_orders io on io.orderno = iac.orderno
  3210. LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
  3211. <where>
  3212. iac.orderstatus = 3
  3213. <if test="vo.userId !=null and vo.userId !=''">
  3214. AND ifon.first_level_user_id =#{vo.userId}
  3215. </if>
  3216. <if test="vo.ids != null and vo.ids.size()>0 ">
  3217. AND ifon.first_level_user_id IN
  3218. <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
  3219. #{item}
  3220. </foreach>
  3221. </if>
  3222. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  3223. AND iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
  3224. </if>
  3225. </where>
  3226. group by ifon.first_level_user_id
  3227. ) a
  3228. left join (
  3229. select
  3230. sum(IFNULL(second_detail_premiums,0)) as "secondDetailPremiums",
  3231. ifon.two_level_user_id as "twoLevelUserId"
  3232. from ins_area_company iac
  3233. left join ins_orders io on io.orderno = iac.orderno
  3234. LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
  3235. <where>
  3236. iac.orderstatus = 3
  3237. <if test="vo.userId !=null and vo.userId !=''">
  3238. AND ifon.two_level_user_id =#{vo.userId}
  3239. </if>
  3240. <if test="vo.ids != null and vo.ids.size()>0 ">
  3241. AND ifon.two_level_user_id IN
  3242. <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
  3243. #{item}
  3244. </foreach>
  3245. </if>
  3246. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  3247. AND iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
  3248. </if>
  3249. </where>
  3250. group by ifon.two_level_user_id
  3251. ) b on b.twoLevelUserId =a.firstLevelUserId
  3252. left join (
  3253. select
  3254. sum(IFNULL(third_detail_premiums,0)) as "thirdDetailPremiums",
  3255. ifon.three_level_user_id as "threeLevelUserId"
  3256. from ins_area_company iac
  3257. left join ins_orders io on io.orderno = iac.orderno
  3258. LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
  3259. <where>
  3260. iac.orderstatus = 3
  3261. <if test="vo.userId !=null and vo.userId !=''">
  3262. AND ifon.three_level_user_id =#{vo.userId}
  3263. </if>
  3264. <if test="vo.ids != null and vo.ids.size()>0 ">
  3265. AND ifon.three_level_user_id IN
  3266. <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
  3267. #{item}
  3268. </foreach>
  3269. </if>
  3270. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  3271. AND iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
  3272. </if>
  3273. </where>
  3274. group by ifon.three_level_user_id
  3275. ) c on c.threeLevelUserId = a.firstLevelUserId
  3276. ) b on b.firstLevelUserId =iac.leader_id
  3277. <where>
  3278. iac.orderstatus = 3
  3279. <if test="vo.userId !=null and vo.userId !=''">
  3280. AND io.userid =#{vo.userId}
  3281. </if>
  3282. <if test="vo.ids != null and vo.ids.size()>0 ">
  3283. AND io.userid IN
  3284. <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
  3285. #{item}
  3286. </foreach>
  3287. </if>
  3288. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  3289. AND iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
  3290. </if>
  3291. </where>
  3292. </select>
  3293. <select id="getDistributionAllAmount" resultType="java.util.HashMap">
  3294. select IFNULL(a.firstDetailPremiums,0) + IFNULL(b.secondDetailPremiums,0) +IFNULL(c.thirdDetailPremiums,0) as "distributionAmount",
  3295. a.firstLevelUserId
  3296. from (
  3297. select
  3298. sum(ifon.first_detail_premiums) as "firstDetailPremiums",
  3299. ifon.first_level_user_id as "firstLevelUserId"
  3300. from ins_area_company iac
  3301. left join ins_orders io on io.orderno = iac.orderno
  3302. LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
  3303. <where>
  3304. <if test="vo.userId !=null and vo.userId !=''">
  3305. ifon.first_level_user_id =#{vo.userId}
  3306. </if>
  3307. <if test="vo.ids != null and vo.ids.size()>0 ">
  3308. AND io.userid IN
  3309. <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
  3310. #{item}
  3311. </foreach>
  3312. </if>
  3313. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  3314. AND iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
  3315. </if>
  3316. </where>
  3317. group by ifon.first_level_user_id
  3318. ) a
  3319. left join (
  3320. select
  3321. sum(IFNULL(second_detail_premiums,0)) as "secondDetailPremiums",
  3322. ifon.two_level_user_id as "twoLevelUserId"
  3323. from ins_area_company iac
  3324. left join ins_orders io on io.orderno = iac.orderno
  3325. LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
  3326. <where>
  3327. <if test="vo.userId !=null and vo.userId !=''">
  3328. ifon.two_level_user_id =#{vo.userId}
  3329. </if>
  3330. <if test="vo.ids != null and vo.ids.size()>0 ">
  3331. AND io.userid IN
  3332. <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
  3333. #{item}
  3334. </foreach>
  3335. </if>
  3336. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  3337. AND iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
  3338. </if>
  3339. </where>
  3340. group by ifon.two_level_user_id
  3341. ) b on b.twoLevelUserId =a.firstLevelUserId
  3342. left join (
  3343. select
  3344. sum(IFNULL(third_detail_premiums,0)) as "thirdDetailPremiums",
  3345. ifon.three_level_user_id as "threeLevelUserId"
  3346. from ins_area_company iac
  3347. left join ins_orders io on io.orderno = iac.orderno
  3348. LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
  3349. <where>
  3350. <if test="vo.userId !=null and vo.userId !=''">
  3351. ifon.three_level_user_id =#{vo.userId}
  3352. </if>
  3353. <if test="vo.ids != null and vo.ids.size()>0 ">
  3354. AND io.userid IN
  3355. <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
  3356. #{item}
  3357. </foreach>
  3358. </if>
  3359. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  3360. AND iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
  3361. </if>
  3362. </where>
  3363. group by ifon.three_level_user_id
  3364. ) c on c.threeLevelUserId = a.firstLevelUserId
  3365. </select>
  3366. <select id="findListByDate" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
  3367. SELECT
  3368. iac.*
  3369. FROM ins_area_company as iac
  3370. <where>
  3371. iac.orderstatus = 3
  3372. and iac.signing_time IS NULL
  3373. <if test="benginDate != null and benginDate!='' and endDate != null and endDate!=''">
  3374. AND iac.createtime BETWEEN #{benginDate} AND #{endDate}
  3375. </if>
  3376. </where>
  3377. order by iac.createtime
  3378. </select>
  3379. <select id="getSumEntryStatus" resultType="java.util.HashMap">
  3380. select ifnull( COUNT( CASE WHEN io.entry_status = '2' THEN 1 END ),0) as "entryStatus",
  3381. ifnull(COUNT( CASE WHEN io.entry_status = '3' THEN 1 END ),0) as "outStatus"
  3382. from ins_area_company iac
  3383. left join ins_orders io on iac.orderno =io.orderno
  3384. <where>
  3385. iac.orderstatus ='3'
  3386. <if test="taskStatisticsVo.userId !=null and taskStatisticsVo.userId != ''">
  3387. and io.userid =#{taskStatisticsVo.userId}
  3388. </if>
  3389. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  3390. AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
  3391. </if>
  3392. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  3393. 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')
  3394. </if>
  3395. </where>
  3396. </select>
  3397. <select id="getBusinessDataList" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  3398. select
  3399. a.dockingPerson as "dockingPerson",
  3400. a.dockingPhone as "dockingPhone",
  3401. a.agreementType as "agreementType",
  3402. a.logo as "logo",
  3403. a.companyId as "companyId",
  3404. a.insuranceCompanyName as "insuranceCompanyName",
  3405. a.parterCompanyId as "parterCompanyId",
  3406. a.partnerCompaniesName as "partnerCompaniesName",
  3407. sum(a.totalPremium) as "totalPremium",
  3408. sum(a.qutationInsureCount) as "qutationInsureCount",
  3409. sum(a.totalPremium) / sum(a.qutationInsureCount) AS "averagePremium",
  3410. sum(a.totalPremium) / sum(a.userNumber) as "perCapitaAmount",
  3411. sum(a.userNumber) as "userNumber"
  3412. from (
  3413. select
  3414. a.companyId as "companyId",
  3415. a.insuranceCompanyName as "insuranceCompanyName",
  3416. a.parterCompanyId as "parterCompanyId",
  3417. a.partnerCompaniesName as "partnerCompaniesName",
  3418. a.totalPremium as "totalPremium",
  3419. a.qutationInsureCount as "qutationInsureCount",
  3420. a.userNumber as "userNumber",
  3421. c.docking_person as "dockingPerson",
  3422. c.docking_phone as "dockingPhone",
  3423. c.agreement_type as "agreementType",
  3424. b.logo as "logo"
  3425. from (
  3426. SELECT
  3427. agree.insurance_company_id AS "companyId",
  3428. agree.insurance_company AS "insuranceCompanyName",
  3429. agree.partner_companies_id AS "parterCompanyId",
  3430. ins.namesimple AS "partnerCompaniesName",
  3431. agree.id as "agreeId",
  3432. IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0) as "totalPremium",
  3433. COUNT(0 ) AS "qutationInsureCount",
  3434. (IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0)) / COUNT(0 ) AS "averagePremium",
  3435. COUNT(DISTINCT io.userId) AS "userNumber",
  3436. (IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0)) / COUNT(DISTINCT io.userId) as "perCapitaAmount"
  3437. FROM
  3438. ins_area_company iac
  3439. LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
  3440. LEFT JOIN ins_orders io on io.orderno = iac.orderno
  3441. LEFT JOIN sys_user su on io.userid =su.id
  3442. LEFT JOIN ins_fee_audit ifa on ifa.ins_order_no =iac.id
  3443. LEFT JOIN esm_ins_company ins ON agree.partner_companies_id = ins.id
  3444. WHERE
  3445. agree.id IS NOT NULL
  3446. and iac.orderstatus = '3'
  3447. and ifa.auditstatus != '2'
  3448. <if test="vo.companyId != null and vo.companyId!='' ">
  3449. and agree.insurance_company_id = #{vo.companyId}
  3450. </if>
  3451. <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
  3452. and agree.partner_companies_id = #{vo.parterCompanyId}
  3453. </if>
  3454. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  3455. 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')
  3456. </if>
  3457. <if test="vo.provinceId != null and vo.provinceId != '' and vo.cityId == null and vo.countyId == null and vo.houseId == null ">
  3458. and io.deptid like concat('%',#{vo.provinceId},'%')
  3459. </if>
  3460. <if test="vo.cityId != null and vo.cityId != '' and vo.countyId ==null and vo.houseId ==null">
  3461. and io.deptid like concat('%',#{vo.cityId},'%')
  3462. </if>
  3463. <if test="vo.countyId != null and vo.countyId != '' and vo.houseId ==null">
  3464. and io.deptid like concat('%',#{vo.countyId},'%')
  3465. </if>
  3466. <if test="vo.houseId != null and vo.houseId != ''">
  3467. and io.deptid like concat('%',#{vo.houseId},'%')
  3468. </if>
  3469. <if test="vo.parterProvinceId != null and vo.parterProvinceId != '' and vo.parterCityId == null and vo.parterCountyId == null ">
  3470. and agree.partner_companies_id like concat('%',#{vo.parterProvinceId},'%')
  3471. </if>
  3472. <if test="vo.parterCityId != null and vo.parterCityId != '' and vo.parterCountyId ==null ">
  3473. and agree.partner_companies_id like concat('%',#{vo.parterCityId},'%')
  3474. </if>
  3475. <if test="vo.parterCountyId != null and vo.parterCountyId != '' ">
  3476. and agree.partner_companies_id like concat('%',#{vo.parterCountyId},'%')
  3477. </if>
  3478. <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
  3479. AND io.deptid in
  3480. <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
  3481. #{item}
  3482. </foreach>
  3483. </if>
  3484. <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
  3485. AND su.leader_id in
  3486. <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
  3487. #{item}
  3488. </foreach>
  3489. </if>
  3490. GROUP BY
  3491. agree.insurance_company_id,
  3492. agree.insurance_company,
  3493. agree.partner_companies_id,
  3494. agree.id
  3495. <choose>
  3496. <when test="vo.orderSort != null and vo.orderSort != '' and vo.userNumberSort == null ">
  3497. order by
  3498. sum(sumpremium) ${vo.orderSort == 'asc' ? 'asc' : 'desc'}
  3499. </when>
  3500. <when test="vo.userNumberSort != null and vo.userNumberSort != '' and vo.orderSort == null ">
  3501. order by
  3502. COUNT(DISTINCT io.userId) ${vo.userNumberSort == 'asc' ? 'asc' : 'desc'}
  3503. </when>
  3504. <when test="vo.userNumberSort != null and vo.userNumberSort != '' and vo.orderSort != null and vo.orderSort != '' ">
  3505. order by
  3506. COUNT(DISTINCT io.userId) ${vo.userNumberSort == 'asc' ? 'asc' : 'desc'}, sum(sumpremium) ${vo.orderSort == 'asc' ? 'asc' : 'desc'}
  3507. </when>
  3508. </choose>
  3509. ) a
  3510. left join esm_ins_company b on b.id =a.companyId
  3511. left join ptl_agreement c on c.id =a.agreeId
  3512. ) a
  3513. group by a.companyId,a.insuranceCompanyName,a.parterCompanyId,a.partnerCompaniesName,a.logo,a.dockingPerson,a.dockingPhone,a.agreementType
  3514. </select>
  3515. </mapper>