InsAreaCompanyMapper.xml 170 KB

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