InsAreaCompanyMapper.xml 173 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736
  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. </where>
  1083. GROUP BY
  1084. io.userid,
  1085. sd.NAME,
  1086. sd.id,
  1087. sd.management_source
  1088. ) a
  1089. left join sys_user su on su.id =a.userId
  1090. LEFT JOIN ins_upload_files inf on su.head_sculpture =inf.id
  1091. LEFT JOIN sys_user_info sui on sui .id =su.id
  1092. LEFT JOIN sys_user su2 on su2.id =su.leader_id
  1093. <where>
  1094. <if test='taskStatisticsVo.userName !=null and taskStatisticsVo.userName!="" '>
  1095. and su.name like concat('%',#{taskStatisticsVo.userName},'%')
  1096. </if>
  1097. <!-- <if test='taskStatisticsVo.leaderId !=null and taskStatisticsVo.leaderId!="" '>-->
  1098. <!-- and su.leader_id =#{taskStatisticsVo.leaderId}-->
  1099. <!-- </if>-->
  1100. <if test="taskStatisticsVo.leaderIds != null and taskStatisticsVo.leaderIds != '' and taskStatisticsVo.leaderIds.size() > 0">
  1101. AND su.leader_id in
  1102. <foreach collection="taskStatisticsVo.leaderIds" item="item" open="(" separator="," close=")">
  1103. #{item}
  1104. </foreach>
  1105. </if>
  1106. <if test='taskStatisticsVo.userId !=null and taskStatisticsVo.userId!="" '>
  1107. and su.id =#{taskStatisticsVo.userId}
  1108. </if>
  1109. </where>
  1110. </select>
  1111. <select id="queryPageElectric" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  1112. select a.*, su.name as "userName",
  1113. inf.url as "logo",
  1114. sui.sex as "sex",
  1115. su.leader_name as "leaderName",
  1116. su2.mobile as "leaderMobile"
  1117. from (
  1118. SELECT
  1119. sd.NAME AS "deptName",
  1120. io.userid AS "userId",
  1121. sd.parent_id as "deptId",
  1122. sd.management_source as "managementSource",
  1123. COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS qutationCount,
  1124. COUNT( CASE WHEN iot.order_status ='2' THEN 1 END ) AS underwritingCount,
  1125. COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) AS qutationInsureCount,
  1126. COUNT( CASE WHEN iot.order_status = '4' THEN 1 END ) AS underwritingReturn,
  1127. COUNT( CASE WHEN iot.order_status = '2' THEN 1 END ) / COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS "passingRate",
  1128. 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",
  1129. (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",
  1130. 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",
  1131. COUNT(CASE WHEN io.order_source = 0 and iot.order_status = '0' THEN 1 END) as "pcOrderSource",
  1132. COUNT(CASE WHEN io.order_source = 1 and iot.order_status = '0' THEN 1 END) as "appOrderSource",
  1133. COUNT( CASE WHEN iot.order_status ='1' THEN 1 END ) AS "auditOrder"
  1134. FROM
  1135. (
  1136. select iot.suborder,iot.order_status from `ins_orders_track` iot
  1137. GROUP BY iot.suborder ,iot.order_status
  1138. ) iot
  1139. left join ins_area_company iac ON iac.id = iot.suborder
  1140. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  1141. LEFT JOIN sys_dept sd ON sd.id = io.deptid
  1142. <where>
  1143. sd.management_source = '3'
  1144. <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
  1145. and io.deptid like "${taskStatisticsVo.provinceId}%"
  1146. </if>
  1147. <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
  1148. and io.deptid like "${taskStatisticsVo.cityId}%"
  1149. </if>
  1150. <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
  1151. and io.deptid like "${taskStatisticsVo.countyId}%"
  1152. </if>
  1153. <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
  1154. and io.deptid like "${taskStatisticsVo.houseId}%"
  1155. </if>
  1156. <if test="taskStatisticsVo.userId != null and taskStatisticsVo.userId != ''">
  1157. and io.userid =#{taskStatisticsVo.userId}
  1158. </if>
  1159. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1160. AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
  1161. </if>
  1162. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1163. 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')
  1164. </if>
  1165. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1166. and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
  1167. </if>
  1168. <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
  1169. AND sd.id in
  1170. <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
  1171. #{item}
  1172. </foreach>
  1173. </if>
  1174. <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
  1175. AND io.userid in
  1176. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  1177. #{item}
  1178. </foreach>
  1179. </if>
  1180. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1181. <choose>
  1182. <when test="taskStatisticsVo.days =='1'">
  1183. and io.createtime >= DATE_SUB(NOW(), INTERVAL 1 DAY)
  1184. </when>
  1185. <when test="taskStatisticsVo.days =='7'">
  1186. and io.createtime >= DATE_SUB(NOW(), INTERVAL 7 DAY)
  1187. </when>
  1188. <when test="taskStatisticsVo.days =='30'">
  1189. and io.createtime >= DATE_SUB(NOW(), INTERVAL 30 DAY)
  1190. </when>
  1191. </choose>
  1192. </if>
  1193. </where>
  1194. GROUP BY
  1195. io.userid,
  1196. sd.NAME,
  1197. sd.id,
  1198. sd.management_source
  1199. ) a
  1200. left join sys_user su on su.id =a.userId
  1201. LEFT JOIN ins_upload_files inf on su.head_sculpture =inf.id
  1202. LEFT JOIN sys_user_info sui on sui .id =su.id
  1203. LEFT JOIN sys_user su2 on su2.id =su.leader_id
  1204. <where>
  1205. <if test='taskStatisticsVo.userName !=null and taskStatisticsVo.userName!="" '>
  1206. and su.name like concat('%',#{taskStatisticsVo.userName},'%')
  1207. </if>
  1208. <!-- <if test='taskStatisticsVo.leaderId !=null and taskStatisticsVo.leaderId!="" '>-->
  1209. <!-- and su.leader_id =#{taskStatisticsVo.leaderId}-->
  1210. <!-- </if>-->
  1211. <if test="taskStatisticsVo.leaderIds != null and taskStatisticsVo.leaderIds != '' and taskStatisticsVo.leaderIds.size() > 0">
  1212. AND su.leader_id in
  1213. <foreach collection="taskStatisticsVo.leaderIds" item="item" open="(" separator="," close=")">
  1214. #{item}
  1215. </foreach>
  1216. </if>
  1217. <if test='taskStatisticsVo.userId !=null and taskStatisticsVo.userId!="" '>
  1218. and su.id =#{taskStatisticsVo.userId}
  1219. </if>
  1220. </where>
  1221. </select>
  1222. <select id="queryPageElectricTotal" resultType="java.lang.Long">
  1223. select count(0) from (
  1224. SELECT
  1225. io.userid
  1226. FROM
  1227. ins_area_company iac
  1228. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  1229. LEFT JOIN sys_dept sd ON sd.id = io.deptid
  1230. <where>
  1231. sd.management_source = '3'
  1232. <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
  1233. and io.deptid like "${taskStatisticsVo.provinceId}%"
  1234. </if>
  1235. <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
  1236. and io.deptid like "${taskStatisticsVo.cityId}%"
  1237. </if>
  1238. <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
  1239. and io.deptid like "${taskStatisticsVo.countyId}%"
  1240. </if>
  1241. <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
  1242. and io.deptid like "${taskStatisticsVo.houseId}%"
  1243. </if>
  1244. <if test="taskStatisticsVo.leaderIds != null and taskStatisticsVo.leaderIds != '' and taskStatisticsVo.leaderIds.size() > 0">
  1245. AND su.leader_id in
  1246. <foreach collection="taskStatisticsVo.leaderIds" item="item" open="(" separator="," close=")">
  1247. #{item}
  1248. </foreach>
  1249. </if>
  1250. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1251. AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
  1252. </if>
  1253. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1254. 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')
  1255. </if>
  1256. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1257. and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
  1258. </if>
  1259. <if test="taskStatisticsVo.userId != null and taskStatisticsVo.userId != ''">
  1260. and io.userid =#{taskStatisticsVo.userId}
  1261. </if>
  1262. <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
  1263. AND sd.id in
  1264. <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
  1265. #{item}
  1266. </foreach>
  1267. </if>
  1268. <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
  1269. AND io.userid in
  1270. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  1271. #{item}
  1272. </foreach>
  1273. </if>
  1274. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1275. <choose>
  1276. <when test="taskStatisticsVo.days =='1'">
  1277. and io.createtime >= DATE_SUB(NOW(), INTERVAL 1 DAY)
  1278. </when>
  1279. <when test="taskStatisticsVo.days =='7'">
  1280. and io.createtime >= DATE_SUB(NOW(), INTERVAL 7 DAY)
  1281. </when>
  1282. <when test="taskStatisticsVo.days =='30'">
  1283. and io.createtime >= DATE_SUB(NOW(), INTERVAL 30 DAY)
  1284. </when>
  1285. </choose>
  1286. </if>
  1287. </where>
  1288. GROUP BY
  1289. io.userid
  1290. ) a
  1291. </select>
  1292. <select id="queryPageTaskStatisticsTotal" resultType="java.lang.Long">
  1293. select count(0) from (
  1294. SELECT
  1295. io.userid
  1296. FROM
  1297. ins_area_company iac
  1298. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  1299. LEFT JOIN sys_dept sd ON sd.id = io.deptid
  1300. left join sys_user su on su.id = io.userid
  1301. <where>
  1302. sd.management_source = '1'
  1303. <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
  1304. and io.deptid like "${taskStatisticsVo.provinceId}%"
  1305. </if>
  1306. <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
  1307. and io.deptid like "${taskStatisticsVo.cityId}%"
  1308. </if>
  1309. <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
  1310. and io.deptid like "${taskStatisticsVo.countyId}%"
  1311. </if>
  1312. <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
  1313. and io.deptid like "${taskStatisticsVo.houseId}%"
  1314. </if>
  1315. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1316. AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
  1317. </if>
  1318. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1319. 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')
  1320. </if>
  1321. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1322. and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
  1323. </if>
  1324. <if test="taskStatisticsVo.userId != null and taskStatisticsVo.userId != ''">
  1325. and io.userid =#{taskStatisticsVo.userId}
  1326. </if>
  1327. <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
  1328. AND sd.id in
  1329. <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
  1330. #{item}
  1331. </foreach>
  1332. </if>
  1333. <if test="taskStatisticsVo.leaderIds != null and taskStatisticsVo.leaderIds != '' and taskStatisticsVo.leaderIds.size() > 0">
  1334. AND su.leader_id in
  1335. <foreach collection="taskStatisticsVo.leaderIds" item="item" open="(" separator="," close=")">
  1336. #{item}
  1337. </foreach>
  1338. </if>
  1339. <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
  1340. AND io.userid in
  1341. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  1342. #{item}
  1343. </foreach>
  1344. </if>
  1345. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1346. <choose>
  1347. <when test="taskStatisticsVo.days =='1'">
  1348. and io.createtime >= DATE_SUB(NOW(), INTERVAL 1 DAY)
  1349. </when>
  1350. <when test="taskStatisticsVo.days =='7'">
  1351. and io.createtime >= DATE_SUB(NOW(), INTERVAL 7 DAY)
  1352. </when>
  1353. <when test="taskStatisticsVo.days =='30'">
  1354. and io.createtime >= DATE_SUB(NOW(), INTERVAL 30 DAY)
  1355. </when>
  1356. </choose>
  1357. </if>
  1358. </where>
  1359. GROUP BY
  1360. io.userid
  1361. ) a
  1362. </select>
  1363. <select id="insuranceCompanyQueryPage" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  1364. select
  1365. a.*,
  1366. ( SELECT eic.namesimple FROM esm_ins_company eic WHERE eic.id = a.partner_companies_id ) AS "partnerCompaniesName"
  1367. FROM
  1368. (
  1369. SELECT
  1370. pa.insurance_company_id,
  1371. pa.partner_companies_id,
  1372. pa.insurance_company AS "insuranceCompanyName",
  1373. COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS qutationCount,
  1374. COUNT( CASE WHEN iot.order_status = '1' THEN 1 END ) AS "auditOrder",
  1375. COUNT( CASE WHEN iot.order_status = '2' THEN 1 END ) AS underwritingCount,
  1376. COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) AS qutationInsureCount,
  1377. COUNT( CASE WHEN iot.order_status = '4' THEN 1 END ) AS underwritingReturn,
  1378. COUNT( CASE WHEN iot.order_status ='2' THEN 1 END ) / COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS "passingRate",
  1379. COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) / COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS "closeRate",
  1380. (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",
  1381. COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) / COUNT( iot.order_status ) AS "quotationRate"
  1382. FROM
  1383. (
  1384. select iot.suborder,iot.order_status from `ins_orders_track` iot
  1385. GROUP BY iot.suborder ,iot.order_status
  1386. ) iot
  1387. LEFT JOIN ins_area_company iac ON iac.id = iot.suborder
  1388. LEFT JOIN ins_fee_audit ifa ON ifa.ins_order_no = iac.id
  1389. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  1390. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  1391. <where>
  1392. pa.insurance_company_id IS NOT NULL
  1393. <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
  1394. and io.deptid like concat('%', #{taskStatisticsVo.provinceId}, '%')
  1395. </if>
  1396. <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
  1397. and io.deptid like concat('%', #{taskStatisticsVo.cityId}, '%')
  1398. </if>
  1399. <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
  1400. and io.deptid like concat('%', #{taskStatisticsVo.countyId}, '%')
  1401. </if>
  1402. <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
  1403. and io.deptid like concat('%', #{taskStatisticsVo.houseId}, '%')
  1404. </if>
  1405. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1406. AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT(#{taskStatisticsVo.createtimeStart},'%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.createtimeEnd}, '%Y-%m-%d')
  1407. </if>
  1408. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1409. AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
  1410. </if>
  1411. <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId != ''">
  1412. AND iac.company_id =#{taskStatisticsVo.companyId}
  1413. </if>
  1414. <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
  1415. AND io.deptid in
  1416. <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
  1417. #{item}
  1418. </foreach>
  1419. </if>
  1420. <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
  1421. AND io.userid in
  1422. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  1423. #{item}
  1424. </foreach>
  1425. </if>
  1426. </where>
  1427. GROUP BY
  1428. pa.insurance_company_id,
  1429. pa.partner_companies_id,
  1430. pa.insurance_company
  1431. ) a
  1432. </select>
  1433. <select id="insuranceCompanyQueryTotal" resultType="java.lang.Long">
  1434. SELECT
  1435. COUNT(0)
  1436. FROM
  1437. (
  1438. SELECT
  1439. pa.insurance_company_id,
  1440. pa.partner_companies_id
  1441. FROM
  1442. ins_area_company iac
  1443. LEFT JOIN ins_fee_audit ifa ON ifa.ins_order_no = iac.id
  1444. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  1445. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  1446. <where>
  1447. pa.insurance_company_id IS NOT NULL
  1448. <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
  1449. and io.deptid like concat('%', #{taskStatisticsVo.provinceId}, '%')
  1450. </if>
  1451. <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
  1452. and io.deptid like concat('%', #{taskStatisticsVo.cityId}, '%')
  1453. </if>
  1454. <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
  1455. and io.deptid like concat('%', #{taskStatisticsVo.countyId}, '%')
  1456. </if>
  1457. <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId != ''">
  1458. AND iac.company_id =#{taskStatisticsVo.companyId}
  1459. </if>
  1460. <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
  1461. and io.deptid like concat('%', #{taskStatisticsVo.houseId}, '%')
  1462. </if>
  1463. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1464. AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT(#{taskStatisticsVo.createtimeStart},'%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.createtimeEnd}, '%Y-%m-%d')
  1465. </if>
  1466. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1467. AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
  1468. </if>
  1469. <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
  1470. AND io.deptid in
  1471. <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
  1472. #{item}
  1473. </foreach>
  1474. </if>
  1475. <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
  1476. AND io.userid in
  1477. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  1478. #{item}
  1479. </foreach>
  1480. </if>
  1481. </where>
  1482. GROUP BY
  1483. pa.insurance_company_id,
  1484. pa.partner_companies_id
  1485. ) total
  1486. </select>
  1487. <select id="agentStatisticsQueryPage" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  1488. SELECT
  1489. sd.name as "deptName",
  1490. su.name as "userName",
  1491. io.userid as "userId",
  1492. sd.id as "deptId",
  1493. suLeader.name as "leaderName",
  1494. suLeader.mobile as "leaderMobile",
  1495. sd.management_source as "managementSource",
  1496. COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS qutationCount,
  1497. COUNT( CASE WHEN iot.order_status = '2' THEN 1 END ) AS underwritingCount,
  1498. COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) AS qutationInsureCount,
  1499. COUNT( CASE WHEN iot.order_status = '4' THEN 1 END ) AS underwritingReturn,
  1500. 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",
  1501. COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) / COUNT( CASE WHEN iot.order_status ='0' THEN 1 END ) as "closeRate",
  1502. 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",
  1503. 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",
  1504. COUNT( CASE WHEN iot.order_status = '1' THEN 1 END ) as "auditOrder"
  1505. FROM
  1506. (
  1507. select iot.suborder,iot.order_status from `ins_orders_track` iot
  1508. GROUP BY iot.suborder ,iot.order_status
  1509. ) iot
  1510. LEFT JOIN ins_area_company iac ON iac.id = iot.suborder
  1511. left join ins_orders io on io.orderno = iac.orderno
  1512. left join sys_dept sd on sd.id=io.deptid
  1513. left join sys_user su on su.id=io.userid
  1514. left join sys_user suLeader on suLeader.id =su.leader_id
  1515. <where>
  1516. sd.management_source = '2'
  1517. <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
  1518. and io.deptid like "${taskStatisticsVo.provinceId}%"
  1519. </if>
  1520. <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
  1521. and io.deptid like "${taskStatisticsVo.cityId}%"
  1522. </if>
  1523. <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
  1524. and io.deptid like "${taskStatisticsVo.countyId}%"
  1525. </if>
  1526. <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
  1527. and io.deptid like "${taskStatisticsVo.houseId}%"
  1528. </if>
  1529. <if test="taskStatisticsVo.userId !=null and taskStatisticsVo.userId!='' ">
  1530. and io.userid =#{taskStatisticsVo.userId}
  1531. </if>
  1532. <if test='taskStatisticsVo.userName !=null and taskStatisticsVo.userName!="" '>
  1533. and su.name like concat('%',#{taskStatisticsVo.userName},'%')
  1534. </if>
  1535. <if test='taskStatisticsVo.leaderId !=null and taskStatisticsVo.leaderId!="" '>
  1536. and su.leader_id =#{taskStatisticsVo.leaderId}
  1537. </if>
  1538. <!-- -->
  1539. <!-- <if test='taskStatisticsVo.userId !=null and taskStatisticsVo.userId!="" '>-->
  1540. <!-- and su.id =#{taskStatisticsVo.userId}-->
  1541. <!-- </if>-->
  1542. <if test="taskStatisticsVo.leaderIds != null and taskStatisticsVo.leaderIds != '' and taskStatisticsVo.leaderIds.size() > 0">
  1543. AND su.leader_id in
  1544. <foreach collection="taskStatisticsVo.leaderIds" item="item" open="(" separator="," close=")">
  1545. #{item}
  1546. </foreach>
  1547. </if>
  1548. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1549. AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
  1550. </if>
  1551. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1552. 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')
  1553. </if>
  1554. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1555. and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
  1556. </if>
  1557. <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
  1558. AND sd.id in
  1559. <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
  1560. #{item}
  1561. </foreach>
  1562. </if>
  1563. <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
  1564. AND io.userid in
  1565. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  1566. #{item}
  1567. </foreach>
  1568. </if>
  1569. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1570. <choose>
  1571. <when test="taskStatisticsVo.days =='1'">
  1572. and io.createtime >= DATE_SUB(NOW(), INTERVAL 1 DAY)
  1573. </when>
  1574. <when test="taskStatisticsVo.days =='7'">
  1575. and io.createtime >= DATE_SUB(NOW(), INTERVAL 7 DAY)
  1576. </when>
  1577. <when test="taskStatisticsVo.days =='30'">
  1578. and io.createtime >= DATE_SUB(NOW(), INTERVAL 30 DAY)
  1579. </when>
  1580. </choose>
  1581. </if>
  1582. </where>
  1583. GROUP BY io.userid , su.name, sd.id , sd.name,suLeader.name,suLeader.mobile,sd.management_source
  1584. </select>
  1585. <select id="agentStatisticsQueryPageTotal" resultType="java.lang.Long">
  1586. select count(0) from (
  1587. SELECT
  1588. io.userid as "userId"
  1589. FROM
  1590. ins_area_company iac
  1591. left join ins_orders io on io.orderno = iac.orderno
  1592. left join sys_dept sd on sd.id=io.deptid
  1593. left join sys_user su on su.id=io.userid
  1594. <where>
  1595. sd.management_source = '2'
  1596. <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
  1597. and io.deptid like "${taskStatisticsVo.provinceId}%"
  1598. </if>
  1599. <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
  1600. and io.deptid like "${taskStatisticsVo.cityId}%"
  1601. </if>
  1602. <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
  1603. and io.deptid like "${taskStatisticsVo.countyId}%"
  1604. </if>
  1605. <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
  1606. and io.deptid like "${taskStatisticsVo.houseId}%"
  1607. </if>
  1608. <if test='taskStatisticsVo.userName !=null and taskStatisticsVo.userName!="" '>
  1609. and su.name like concat('%',#{taskStatisticsVo.userName},'%')
  1610. </if>
  1611. <!-- <if test='taskStatisticsVo.leaderId !=null and taskStatisticsVo.leaderId!="" '>-->
  1612. <!-- and su.leader_id =#{taskStatisticsVo.leaderId}-->
  1613. <!-- </if>-->
  1614. <if test="taskStatisticsVo.leaderIds != null and taskStatisticsVo.leaderIds != '' and taskStatisticsVo.leaderIds.size() > 0">
  1615. AND su.leader_id in
  1616. <foreach collection="taskStatisticsVo.leaderIds" item="item" open="(" separator="," close=")">
  1617. #{item}
  1618. </foreach>
  1619. </if>
  1620. <if test='taskStatisticsVo.userId !=null and taskStatisticsVo.userId!="" '>
  1621. and su.id =#{taskStatisticsVo.userId}
  1622. </if>
  1623. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1624. AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
  1625. </if>
  1626. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1627. 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')
  1628. </if>
  1629. <if test="taskStatisticsVo.userId !=null and taskStatisticsVo.userId!='' ">
  1630. and io.userid =#{taskStatisticsVo.userId}
  1631. </if>
  1632. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1633. and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
  1634. </if>
  1635. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1636. <choose>
  1637. <when test="taskStatisticsVo.days =='1'">
  1638. and io.createtime >= DATE_SUB(NOW(), INTERVAL 1 DAY)
  1639. </when>
  1640. <when test="taskStatisticsVo.days =='7'">
  1641. and io.createtime >= DATE_SUB(NOW(), INTERVAL 7 DAY)
  1642. </when>
  1643. <when test="taskStatisticsVo.days =='30'">
  1644. and io.createtime >= DATE_SUB(NOW(), INTERVAL 30 DAY)
  1645. </when>
  1646. </choose>
  1647. </if>
  1648. </where>
  1649. GROUP BY io.userid
  1650. ) a
  1651. </select>
  1652. <select id="costCenter" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  1653. SELECT
  1654. iac.company_id,
  1655. iac.inscompany as "insuranceCompanyName",
  1656. COUNT( CASE WHEN ifa.auditstatus = 1 THEN 1 END ) AS "auditstatusOrders",
  1657. COUNT( CASE WHEN ifa.auditstatus = 0 THEN 1 END ) AS "auditOrder",
  1658. COUNT( CASE WHEN ifa.auditstatus = 1 and ifa.audituser != '自动审核' THEN 1 END ) AS "persionAudit",
  1659. COUNT( CASE WHEN ifa.audituser = '自动审核' THEN 1 END ) AS "automaticAudit"
  1660. FROM
  1661. ins_fee_audit ifa
  1662. LEFT JOIN ins_orders io ON io.orderno = ifa.orderno
  1663. LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
  1664. AND iac.orderstatus = 3
  1665. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  1666. LEFT JOIN esm_ins_company eic ON eic.id = pa.partner_companies_id
  1667. left join sys_user su on su.id =ifa.audituser
  1668. <where>
  1669. 1=1
  1670. and iac.id = ifa.ins_order_no
  1671. AND iac.orderstatus = 3
  1672. <if test="taskStatisticsVo.reviewer !=null and taskStatisticsVo.reviewer !=''">
  1673. and su.name =#{taskStatisticsVo.reviewer}
  1674. </if>
  1675. <if test="taskStatisticsVo.audittime !=null and taskStatisticsVo.audittime !=''">
  1676. and ifa.audittime =#{taskStatisticsVo.audittime}
  1677. </if>
  1678. <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId !=''">
  1679. and iac.company_id =#{taskStatisticsVo.companyId}
  1680. </if>
  1681. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1682. 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')
  1683. </if>
  1684. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1685. 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')
  1686. </if>
  1687. <if test="taskStatisticsVo.auditTimeStart !=null and taskStatisticsVo.auditTimeEnd != '' and taskStatisticsVo.auditTimeStart !=null and taskStatisticsVo.auditTimeEnd != ''">
  1688. AND DATE_FORMAT( ifa.audittime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.auditTimeStart}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.auditTimeEnd}, '%Y-%m-%d')
  1689. </if>
  1690. <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
  1691. AND io.deptid in
  1692. <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
  1693. #{item}
  1694. </foreach>
  1695. </if>
  1696. <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
  1697. AND su.id in
  1698. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  1699. #{item}
  1700. </foreach>
  1701. </if>
  1702. <choose>
  1703. <when test="taskStatisticsVo.riskCode != null and taskStatisticsVo.riskCode != '' and taskStatisticsVo.riskCode != 'all' ">
  1704. and iac.product = #{taskStatisticsVo.riskCode}
  1705. </when>
  1706. </choose>
  1707. </where>
  1708. GROUP BY
  1709. iac.company_id,
  1710. iac.inscompany
  1711. </select>
  1712. <select id="costCenterDetails" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  1713. SELECT
  1714. ifa.audituser as "audituser",
  1715. su.name as "audituserName",
  1716. su.mobile as "audituserMobile",
  1717. iac.inscompany as "insuranceCompanyName",
  1718. COUNT( CASE WHEN ifa.auditstatus = 1 THEN 1 END ) AS "auditstatusOrders",
  1719. COUNT( CASE WHEN ifa.auditstatus = 0 THEN 1 END ) AS "auditOrder"
  1720. FROM
  1721. ins_fee_audit ifa
  1722. LEFT JOIN ins_orders io ON io.orderno = ifa.orderno
  1723. LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
  1724. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  1725. LEFT JOIN esm_ins_company eic ON eic.id = pa.partner_companies_id
  1726. left join sys_user su on su.id =ifa.audituser
  1727. <where>
  1728. 1=1
  1729. and iac.id = ifa.ins_order_no
  1730. AND iac.orderstatus = 3
  1731. AND ifa.audituser != '自动审核'
  1732. AND (ifa.auditstatus ='1' or ifa.auditstatus ='0')
  1733. <if test="taskStatisticsVo.reviewer !=null and taskStatisticsVo.reviewer !=''">
  1734. and su.name =#{taskStatisticsVo.reviewer}
  1735. </if>
  1736. <if test="taskStatisticsVo.auditTimeStart !=null and taskStatisticsVo.auditTimeEnd != '' and taskStatisticsVo.auditTimeStart !=null and taskStatisticsVo.auditTimeEnd != ''">
  1737. AND DATE_FORMAT( ifa.audittime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.auditTimeStart}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.auditTimeEnd}, '%Y-%m-%d')
  1738. </if>
  1739. <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId !=''">
  1740. and iac.company_id =#{taskStatisticsVo.companyId}
  1741. </if>
  1742. <if test="taskStatisticsVo.audittime !=null and taskStatisticsVo.audittime !=''">
  1743. and ifa.audittime =#{taskStatisticsVo.audittime}
  1744. </if>
  1745. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1746. AND DATE_FORMAT( ifa.audittime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.createtimeStart}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.createtimeEnd}, '%Y-%m-%d')
  1747. </if>
  1748. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1749. 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')
  1750. </if>
  1751. <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
  1752. AND io.deptid in
  1753. <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
  1754. #{item}
  1755. </foreach>
  1756. </if>
  1757. <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
  1758. AND su.id in
  1759. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  1760. #{item}
  1761. </foreach>
  1762. </if>
  1763. <choose>
  1764. <when test="taskStatisticsVo.riskCode != null and taskStatisticsVo.riskCode != '' and taskStatisticsVo.riskCode != 'all' ">
  1765. and iac.product = #{taskStatisticsVo.riskCode}
  1766. </when>
  1767. </choose>
  1768. </where>
  1769. GROUP BY
  1770. ifa.audituser,su.name,su.mobile,iac.inscompany
  1771. </select>
  1772. <select id="costCenterDetailsExcel" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDtoExcel">
  1773. SELECT
  1774. ifa.audituser as "audituser",
  1775. su.name as "audituserName",
  1776. su.mobile as "audituserMobile",
  1777. iac.inscompany as "insuranceCompanyName",
  1778. COUNT( CASE WHEN ifa.auditstatus = 1 THEN 1 END ) AS "auditstatusOrders",
  1779. COUNT( CASE WHEN ifa.auditstatus = 0 THEN 1 END ) AS "auditOrder"
  1780. FROM
  1781. ins_fee_audit ifa
  1782. LEFT JOIN ins_orders io ON io.orderno = ifa.orderno
  1783. LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
  1784. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  1785. LEFT JOIN esm_ins_company eic ON eic.id = pa.partner_companies_id
  1786. left join sys_user su on su.id =ifa.audituser
  1787. <where>
  1788. 1=1
  1789. and iac.id = ifa.ins_order_no
  1790. AND iac.orderstatus = 3
  1791. AND ifa.audituser != '自动审核'
  1792. AND (ifa.auditstatus ='1' or ifa.auditstatus ='0')
  1793. <if test="taskStatisticsVo.reviewer !=null and taskStatisticsVo.reviewer !=''">
  1794. and su.name =#{taskStatisticsVo.reviewer}
  1795. </if>
  1796. <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId !=''">
  1797. and iac.company_id =#{taskStatisticsVo.companyId}
  1798. </if>
  1799. <if test="taskStatisticsVo.audittime !=null and taskStatisticsVo.audittime !=''">
  1800. and ifa.audittime =#{taskStatisticsVo.audittime}
  1801. </if>
  1802. <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId !=''">
  1803. and iac.company_id =#{taskStatisticsVo.companyId}
  1804. </if>
  1805. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1806. AND DATE_FORMAT( ifa.audittime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.createtimeStart}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.createtimeEnd}, '%Y-%m-%d')
  1807. </if>
  1808. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1809. AND DATE_FORMAT( iac.signing_time, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
  1810. </if>
  1811. <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
  1812. AND io.deptid in
  1813. <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
  1814. #{item}
  1815. </foreach>
  1816. </if>
  1817. <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
  1818. AND su.id in
  1819. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  1820. #{item}
  1821. </foreach>
  1822. </if>
  1823. <choose>
  1824. <when test="taskStatisticsVo.riskCode != null and taskStatisticsVo.riskCode != '' and taskStatisticsVo.riskCode != 'all' ">
  1825. and iac.product = #{taskStatisticsVo.riskCode}
  1826. </when>
  1827. </choose>
  1828. </where>
  1829. GROUP BY
  1830. ifa.audituser,su.name,su.mobile,iac.inscompany
  1831. </select>
  1832. <select id="costCenterDetailsLicense" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  1833. SELECT
  1834. io.licenseno as "licenseno",
  1835. iot.createTime as "createTime",
  1836. ifa.audittime as "auditTime",
  1837. IFNULL(TIMESTAMPDIFF(SECOND, iot.createTime, ifa.audittime),0) as "timeDifference"
  1838. FROM
  1839. ins_fee_audit ifa
  1840. LEFT JOIN ins_orders io ON io.orderno = ifa.orderno
  1841. LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
  1842. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  1843. LEFT JOIN esm_ins_company eic ON eic.id = pa.partner_companies_id
  1844. left join (
  1845. select distinct suborder as "suborder" , order_status as "orderStatus",create_time as "createTime" from ins_orders_track
  1846. ) iot on iot.suborder = iac.id
  1847. left join sys_user su on su.id =ifa.audituser
  1848. <where>
  1849. 1=1
  1850. and iac.id = ifa.ins_order_no
  1851. AND iac.orderstatus = 3
  1852. AND io.orderstatus = 3
  1853. AND iot.orderStatus ='3'
  1854. AND ifa.audituser != '自动审核'
  1855. AND (ifa.auditstatus ='1' or ifa.auditstatus ='0')
  1856. <if test="taskStatisticsVo.reviewer !=null and taskStatisticsVo.reviewer !=''">
  1857. and su.name =#{taskStatisticsVo.reviewer}
  1858. </if>
  1859. <if test="taskStatisticsVo.audituser !=null and taskStatisticsVo.audituser !=''">
  1860. and ifa.audituser =#{taskStatisticsVo.audituser}
  1861. </if>
  1862. <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId !=''">
  1863. and iac.company_id =#{taskStatisticsVo.companyId}
  1864. </if>
  1865. <if test="taskStatisticsVo.audittime !=null and taskStatisticsVo.audittime !=''">
  1866. and ifa.audittime =#{taskStatisticsVo.audittime}
  1867. </if>
  1868. <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId !=''">
  1869. and iac.company_id =#{taskStatisticsVo.companyId}
  1870. </if>
  1871. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1872. AND DATE_FORMAT( ifa.audittime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.createtimeStart}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.createtimeEnd}, '%Y-%m-%d')
  1873. </if>
  1874. <if test="taskStatisticsVo.auditTimeStart !=null and taskStatisticsVo.auditTimeEnd != '' and taskStatisticsVo.auditTimeStart !=null and taskStatisticsVo.auditTimeEnd != ''">
  1875. AND DATE_FORMAT( ifa.audittime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.auditTimeStart}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.auditTimeEnd}, '%Y-%m-%d')
  1876. </if>
  1877. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1878. 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')
  1879. </if>
  1880. <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
  1881. AND io.deptid in
  1882. <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
  1883. #{item}
  1884. </foreach>
  1885. </if>
  1886. <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
  1887. AND su.id in
  1888. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  1889. #{item}
  1890. </foreach>
  1891. </if>
  1892. <choose>
  1893. <when test="taskStatisticsVo.riskCode != null and taskStatisticsVo.riskCode != '' and taskStatisticsVo.riskCode != 'all' ">
  1894. and iac.product = #{taskStatisticsVo.riskCode}
  1895. </when>
  1896. </choose>
  1897. </where>
  1898. </select>
  1899. <select id="costCenterSecond" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDtoNew">
  1900. SELECT
  1901. IFNULL(count(io.licenseno),0) as "orderNumber",
  1902. IFNULL(sum(TIMESTAMPDIFF(SECOND, iot.createTime, ifa.audittime)),0) as "sumSecond",
  1903. ROUND(IFNULL(sum(TIMESTAMPDIFF(SECOND, iot.createTime, ifa.audittime)),0) / count(io.licenseno),2) as "averageSecond"
  1904. FROM
  1905. ins_fee_audit ifa
  1906. LEFT JOIN ins_orders io ON io.orderno = ifa.orderno
  1907. LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
  1908. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  1909. LEFT JOIN esm_ins_company eic ON eic.id = pa.partner_companies_id
  1910. left join sys_user su on su.id =ifa.audituser
  1911. left join (
  1912. select distinct suborder as "suborder" , order_status as "orderStatus",create_time as "createTime" from ins_orders_track
  1913. ) iot on iot.suborder = iac.id
  1914. <where>
  1915. 1=1
  1916. and iac.id = ifa.ins_order_no
  1917. AND iac.orderstatus = 3
  1918. AND io.orderstatus = 3
  1919. AND ifa.audituser != '自动审核'
  1920. AND iot.orderStatus ='3'
  1921. AND (ifa.auditstatus ='1' or ifa.auditstatus ='0')
  1922. <if test="taskStatisticsVo.reviewer !=null and taskStatisticsVo.reviewer !=''">
  1923. and su.name =#{taskStatisticsVo.reviewer}
  1924. </if>
  1925. <if test="taskStatisticsVo.audituser !=null and taskStatisticsVo.audituser !=''">
  1926. and ifa.audituser =#{taskStatisticsVo.audituser}
  1927. </if>
  1928. <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId !=''">
  1929. and iac.company_id =#{taskStatisticsVo.companyId}
  1930. </if>
  1931. <if test="taskStatisticsVo.audittime !=null and taskStatisticsVo.audittime !=''">
  1932. and ifa.audittime =#{taskStatisticsVo.audittime}
  1933. </if>
  1934. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1935. AND DATE_FORMAT( ifa.audittime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.createtimeStart}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.createtimeEnd}, '%Y-%m-%d')
  1936. </if>
  1937. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1938. 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')
  1939. </if>
  1940. <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
  1941. AND io.deptid in
  1942. <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
  1943. #{item}
  1944. </foreach>
  1945. </if>
  1946. <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
  1947. AND su.id in
  1948. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  1949. #{item}
  1950. </foreach>
  1951. </if>
  1952. <choose>
  1953. <when test="taskStatisticsVo.riskCode != null and taskStatisticsVo.riskCode != '' and taskStatisticsVo.riskCode != 'all' ">
  1954. and iac.product = #{taskStatisticsVo.riskCode}
  1955. </when>
  1956. </choose>
  1957. </where>
  1958. </select>
  1959. <select id="getOrderManpower" resultType="com.ydtech.modules.admin.model.dto.QxFrontlineAgentDto">
  1960. SELECT
  1961. count( a.numberUserId ) as "orderManpower",
  1962. sum( a.orderAmount ) as "totalPremium",
  1963. sum( a.orderAmount )/ count( a.numberUserId ) as "averagePremium"
  1964. FROM
  1965. (
  1966. SELECT
  1967. count( io.userid ) AS "numberUserId",
  1968. SUM(IFNULL(iac.jqpremium, 0)) +
  1969. SUM(IFNULL(iac.sypremium, 0)) +
  1970. SUM(IFNULL(iac.jypremium, 0)) AS "orderAmount"
  1971. FROM
  1972. `ins_area_company` iac
  1973. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  1974. <where>
  1975. iac.orderstatus = '3'
  1976. <if test="ids != null and ids.size()>0 ">
  1977. AND io.userid IN
  1978. <foreach item="item" collection="ids" open="(" separator="," close=")">
  1979. #{item}
  1980. </foreach>
  1981. </if>
  1982. </where>
  1983. GROUP BY
  1984. io.userid
  1985. ) a
  1986. </select>
  1987. <select id="getOrderManpowerNew" resultType="com.ydtech.modules.admin.model.dto.QxFrontlineAgentDto">
  1988. SELECT
  1989. count( a.numberUserId ) as "orderManpower",
  1990. IFNULL(sum( a.orderAmount ),0) as "totalPremium",
  1991. ROUND(sum( a.orderAmount )/ sum(a.ordernoNumber),2) AS "averagePremium"
  1992. FROM
  1993. (
  1994. SELECT
  1995. count( io.userid ) AS "numberUserId",
  1996. count( iac.orderno ) AS "ordernoNumber",
  1997. SUM(IFNULL(iac.jqpremium, 0)
  1998. +IFNULL(iac.sypremium, 0)
  1999. +IFNULL(iac.jypremium, 0)
  2000. ) AS "orderAmount"
  2001. FROM
  2002. `ins_area_company` iac
  2003. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  2004. <where>
  2005. iac.orderstatus = '3'
  2006. <if test="vo.ids != null and vo.ids.size()>0 ">
  2007. AND io.userid IN
  2008. <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
  2009. #{item}
  2010. </foreach>
  2011. </if>
  2012. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  2013. AND iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
  2014. </if>
  2015. </where>
  2016. GROUP BY
  2017. io.userid
  2018. ) a
  2019. <where>
  2020. <if test="vo.outThere != null and vo.outThere!=''">
  2021. <choose>
  2022. <when test=" vo.outThere == 0">
  2023. AND IFNULL(a.orderAmount,0) = 0
  2024. </when>
  2025. <when test="vo.outThere == 1">
  2026. AND IFNULL(a.orderAmount,0) > 0
  2027. </when>
  2028. </choose>
  2029. </if>
  2030. </where>
  2031. order by sum( a.orderAmount ) desc
  2032. </select>
  2033. <select id="getChannelOrderManpowerNew" resultType="com.ydtech.modules.admin.model.dto.QxFrontlineAgentDto">
  2034. SELECT
  2035. a.userId as "userId",
  2036. a.userName as "name",
  2037. a.orderNumber as "orderNumber",
  2038. a.underwritingCount as "underwritingCount",
  2039. a.qutationInsureCount as "qutationInsureCount",
  2040. IFNULL(a.jqpremium,0) + IFNULL(a.sypremium,0) + IFNULL(a.jypremium,0) as "totalPremium",
  2041. a.isFactorVerify as "isFactorVerify",
  2042. a.isNotFactorVerify as "isNotFactorVerify"
  2043. FROM
  2044. (
  2045. SELECT
  2046. io.userid as "userId",
  2047. io.username as "userName",
  2048. count( iac.orderno ) AS "orderNumber",
  2049. sum(CASE WHEN iac.orderstatus = 3 THEN iac.jqpremium END ) AS jqpremium,
  2050. sum(CASE WHEN iac.orderstatus = 3 THEN iac.sypremium END ) AS sypremium,
  2051. sum(CASE WHEN iac.orderstatus = 3 THEN iac.jypremium END ) AS jypremium,
  2052. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
  2053. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  2054. COUNT( CASE WHEN su.factor_verify = 1 THEN 1 END ) AS isFactorVerify,
  2055. COUNT( CASE WHEN su.factor_verify = 0 THEN 1 END ) AS isNotFactorVerify
  2056. FROM
  2057. `ins_area_company` iac
  2058. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  2059. left join sys_user su on su.id=io.userid
  2060. <where>
  2061. <if test="vo.ids != null and vo.ids.size()>0 ">
  2062. AND io.userid IN
  2063. <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
  2064. #{item}
  2065. </foreach>
  2066. </if>
  2067. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  2068. AND iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
  2069. </if>
  2070. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  2071. AND iac.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  2072. </if>
  2073. <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
  2074. AND io.deptid in
  2075. <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
  2076. #{item}
  2077. </foreach>
  2078. </if>
  2079. <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
  2080. AND io.userid in
  2081. <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
  2082. #{item}
  2083. </foreach>
  2084. </if>
  2085. </where>
  2086. GROUP BY
  2087. io.userid,
  2088. io.username
  2089. ) a
  2090. left join sys_user su on su.id=a.userId
  2091. </select>
  2092. <select id="NumberQuotations" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  2093. SELECT
  2094. count(iac.id) as "orderNumber",
  2095. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
  2096. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  2097. sum( CASE WHEN iac.orderstatus = 3 THEN IFNULL(iac.jqpremium, 0) + IFNULL(iac.sypremium, 0) + IFNULL(iac.jypremium, 0) END ) AS totalPremium
  2098. FROM
  2099. ins_area_company iac
  2100. left join ins_orders io on io.orderno = iac.orderno
  2101. left join sys_dept sd on sd.id=io.deptid
  2102. left join sys_user su on su.id=io.userid
  2103. left join ins_fee_audit ifa on ifa .ins_order_no =iac.id
  2104. <where>
  2105. sd.management_source = '2'
  2106. <if test="userId !=null and userId !=''">
  2107. and io.userId =#{userId}
  2108. </if>
  2109. </where>
  2110. </select>
  2111. <select id="totalQuotation" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  2112. SELECT
  2113. agree.insurance_company_id AS companyId,
  2114. agree.insurance_company AS companyName,
  2115. agree.partner_companies_id AS parterCompanyId,
  2116. ins.namesimple AS parterCompanyName,
  2117. count(iac.orderstatus) AS orderNumber,
  2118. '-' as bigQutationCount,
  2119. '-' as bigUnderwritingCount,
  2120. '-' as bigCloseRate,
  2121. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
  2122. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  2123. COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END )/ count(iac.orderstatus) AS passRate,
  2124. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END )/ count(iac.orderstatus) AS underwritingCountRate,
  2125. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )/ count(iac.orderstatus) AS closeRate,
  2126. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )/ COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS
  2127. contributionRate
  2128. FROM
  2129. ins_area_company iac
  2130. LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
  2131. LEFT JOIN ins_orders io on io.orderno = iac.orderno
  2132. LEFT JOIN esm_ins_company ins ON agree.partner_companies_id = ins.id
  2133. WHERE
  2134. agree.id IS NOT NULL
  2135. <if test="vo.companyId != null and vo.companyId!='' ">
  2136. agree.insurance_company_id = #{vo.companyId}
  2137. </if>
  2138. <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
  2139. agree.partner_companies_id = #{vo.parterCompanyId}
  2140. </if>
  2141. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  2142. AND iac.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  2143. </if>
  2144. <if test="vo.provinceId != null and vo.provinceId != ''">
  2145. and io.deptid like "${vo.provinceId}%"
  2146. </if>
  2147. <if test="vo.cityId != null and vo.cityId != ''">
  2148. and io.deptid like "${vo.cityId}%"
  2149. </if>
  2150. <if test="vo.countyId != null and vo.countyId != ''">
  2151. and io.deptid like "${vo.countyId}%"
  2152. </if>
  2153. <if test="taskStatisticsVo.houseId != null and vo.houseId != ''">
  2154. and io.deptid like "${vo.houseId}%"
  2155. </if>
  2156. GROUP BY
  2157. agree.insurance_company_id,
  2158. agree.insurance_company,
  2159. agree.partner_companies_id,
  2160. ins.NAME
  2161. </select>
  2162. <select id="getBusinessData" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  2163. select
  2164. a.dockingPerson as "dockingPerson",
  2165. a.dockingPhone as "dockingPhone",
  2166. a.agreementType as "agreementType",
  2167. a.logo as "logo",
  2168. a.companyId as "companyId",
  2169. a.insuranceCompanyName as "insuranceCompanyName",
  2170. a.parterCompanyId as "parterCompanyId",
  2171. a.partnerCompaniesName as "partnerCompaniesName",
  2172. sum(a.totalPremium) as "totalPremium",
  2173. sum(a.qutationInsureCount) as "qutationInsureCount",
  2174. sum(a.totalPremium) / sum(a.qutationInsureCount) AS "averagePremium",
  2175. sum(a.totalPremium) / sum(a.userNumber) as "perCapitaAmount",
  2176. sum(a.userNumber) as "userNumber"
  2177. from (
  2178. select
  2179. a.companyId as "companyId",
  2180. a.insuranceCompanyName as "insuranceCompanyName",
  2181. a.parterCompanyId as "parterCompanyId",
  2182. a.partnerCompaniesName as "partnerCompaniesName",
  2183. a.totalPremium as "totalPremium",
  2184. a.qutationInsureCount as "qutationInsureCount",
  2185. a.userNumber as "userNumber",
  2186. c.docking_person as "dockingPerson",
  2187. c.docking_phone as "dockingPhone",
  2188. c.agreement_type as "agreementType",
  2189. b.logo as "logo"
  2190. from (
  2191. SELECT
  2192. agree.insurance_company_id AS "companyId",
  2193. agree.insurance_company AS "insuranceCompanyName",
  2194. agree.partner_companies_id AS "parterCompanyId",
  2195. ins.namesimple AS "partnerCompaniesName",
  2196. agree.id as "agreeId",
  2197. IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0) as "totalPremium",
  2198. COUNT(0 ) AS "qutationInsureCount",
  2199. (IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0)) / COUNT(0 ) AS "averagePremium",
  2200. COUNT(DISTINCT io.userId) AS "userNumber",
  2201. (IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0)) / COUNT(DISTINCT io.userId) as "perCapitaAmount"
  2202. FROM
  2203. ins_area_company iac
  2204. LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
  2205. LEFT JOIN ins_orders io on io.orderno = iac.orderno
  2206. LEFT JOIN ins_fee_audit ifa on ifa.ins_order_no =iac.id
  2207. LEFT JOIN esm_ins_company ins ON agree.partner_companies_id = ins.id
  2208. WHERE
  2209. agree.id IS NOT NULL
  2210. and iac.orderstatus = '3'
  2211. and ifa.auditstatus != '2'
  2212. <if test="vo.companyId != null and vo.companyId!='' ">
  2213. and agree.insurance_company_id = #{vo.companyId}
  2214. </if>
  2215. <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
  2216. and agree.partner_companies_id = #{vo.parterCompanyId}
  2217. </if>
  2218. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  2219. 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')
  2220. </if>
  2221. <if test="vo.provinceId != null and vo.provinceId != '' and vo.cityId == null and vo.countyId == null and vo.houseId == null ">
  2222. and io.deptid like concat('%',#{vo.provinceId},'%')
  2223. </if>
  2224. <if test="vo.cityId != null and vo.cityId != '' and vo.countyId ==null and vo.houseId ==null">
  2225. and io.deptid like concat('%',#{vo.cityId},'%')
  2226. </if>
  2227. <if test="vo.countyId != null and vo.countyId != '' and vo.houseId ==null">
  2228. and io.deptid like concat('%',#{vo.countyId},'%')
  2229. </if>
  2230. <if test="vo.houseId != null and vo.houseId != ''">
  2231. and io.deptid like concat('%',#{vo.houseId},'%')
  2232. </if>
  2233. <if test="vo.parterProvinceId != null and vo.parterProvinceId != '' and vo.parterCityId == null and vo.parterCountyId == null ">
  2234. and agree.partner_companies_id like concat('%',#{vo.parterProvinceId},'%')
  2235. </if>
  2236. <if test="vo.parterCityId != null and vo.parterCityId != '' and vo.parterCountyId ==null ">
  2237. and agree.partner_companies_id like concat('%',#{vo.parterCityId},'%')
  2238. </if>
  2239. <if test="vo.parterCountyId != null and vo.parterCountyId != '' ">
  2240. and agree.partner_companies_id like concat('%',#{vo.parterCountyId},'%')
  2241. </if>
  2242. <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
  2243. AND io.deptid in
  2244. <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
  2245. #{item}
  2246. </foreach>
  2247. </if>
  2248. <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
  2249. AND io.userid in
  2250. <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
  2251. #{item}
  2252. </foreach>
  2253. </if>
  2254. GROUP BY
  2255. agree.insurance_company_id,
  2256. agree.insurance_company,
  2257. agree.partner_companies_id,
  2258. agree.id
  2259. <choose>
  2260. <when test="vo.orderSort != null and vo.orderSort != '' and vo.userNumberSort == null ">
  2261. order by
  2262. sum(sumpremium) ${vo.orderSort == 'asc' ? 'asc' : 'desc'}
  2263. </when>
  2264. <when test="vo.userNumberSort != null and vo.userNumberSort != '' and vo.orderSort == null ">
  2265. order by
  2266. COUNT(DISTINCT io.userId) ${vo.userNumberSort == 'asc' ? 'asc' : 'desc'}
  2267. </when>
  2268. <when test="vo.userNumberSort != null and vo.userNumberSort != '' and vo.orderSort != null and vo.orderSort != '' ">
  2269. order by
  2270. COUNT(DISTINCT io.userId) ${vo.userNumberSort == 'asc' ? 'asc' : 'desc'}, sum(sumpremium) ${vo.orderSort == 'asc' ? 'asc' : 'desc'}
  2271. </when>
  2272. </choose>
  2273. ) a
  2274. left join esm_ins_company b on b.id =a.companyId
  2275. left join ptl_agreement c on c.id =a.agreeId
  2276. ) a
  2277. group by a.companyId,a.insuranceCompanyName,a.parterCompanyId,a.partnerCompaniesName,a.logo,a.dockingPerson,a.dockingPhone,a.agreementType
  2278. </select>
  2279. <select id="getCountBusinessData" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  2280. select
  2281. sum(a.totalPremium) as "totalPremium",
  2282. sum(a.qutationInsureCount) as "qutationInsureCount",
  2283. ROUND(sum( a.totalPremium ) / sum( a.qutationInsureCount ),2) AS "averagePremium",
  2284. sum(a.userNumber) as "userNumber",
  2285. count(DISTINCT a.insuranceCompanyName) as "insuranceCompanyNumber",
  2286. ROUND(sum(a.totalPremium)/sum(a.userNumber),0) as "perCapitaAmount"
  2287. from (
  2288. SELECT
  2289. agree.insurance_company AS "insuranceCompanyName",
  2290. IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0) as "totalPremium",
  2291. COUNT(0 ) AS "qutationInsureCount",
  2292. COUNT(DISTINCT io.userId) AS "userNumber"
  2293. FROM
  2294. ins_area_company iac
  2295. LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
  2296. LEFT JOIN ins_orders io on io.orderno = iac.orderno
  2297. LEFT JOIN ins_fee_audit ifa on ifa.ins_order_no =iac.id
  2298. WHERE
  2299. agree.id IS NOT NULL
  2300. and iac.orderstatus = '3'
  2301. and ifa.auditstatus != '2'
  2302. <if test="vo.companyId != null and vo.companyId!='' ">
  2303. and agree.insurance_company_id = #{vo.companyId}
  2304. </if>
  2305. <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
  2306. and agree.partner_companies_id = #{vo.parterCompanyId}
  2307. </if>
  2308. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  2309. 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')
  2310. </if>
  2311. <if test="vo.provinceId != null and vo.provinceId != '' and vo.cityId == null and vo.countyId == null and vo.houseId == null ">
  2312. and io.deptid like concat('%',#{vo.provinceId},'%')
  2313. </if>
  2314. <if test="vo.cityId != null and vo.cityId != '' and vo.countyId ==null and vo.houseId ==null">
  2315. and io.deptid like concat('%',#{vo.cityId},'%')
  2316. </if>
  2317. <if test="vo.countyId != null and vo.countyId != '' and vo.houseId ==null">
  2318. and io.deptid like concat('%',#{vo.countyId},'%')
  2319. </if>
  2320. <if test="vo.houseId != null and vo.houseId != ''">
  2321. and io.deptid like concat('%',#{vo.houseId},'%')
  2322. </if>
  2323. <if test="vo.parterProvinceId != null and vo.parterProvinceId != '' and vo.parterCityId == null and vo.parterCountyId == null ">
  2324. and agree.partner_companies_id like concat('%',#{vo.parterProvinceId},'%')
  2325. </if>
  2326. <if test="vo.parterCityId != null and vo.parterCityId != '' and vo.parterCountyId ==null ">
  2327. and agree.partner_companies_id like concat('%',#{vo.parterCityId},'%')
  2328. </if>
  2329. <if test="vo.parterCountyId != null and vo.parterCountyId != '' ">
  2330. and agree.partner_companies_id like concat('%',#{vo.parterCountyId},'%')
  2331. </if>
  2332. <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
  2333. AND io.deptid in
  2334. <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
  2335. #{item}
  2336. </foreach>
  2337. </if>
  2338. <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
  2339. AND io.userid in
  2340. <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
  2341. #{item}
  2342. </foreach>
  2343. </if>
  2344. group by
  2345. agree.insurance_company,
  2346. agree.partner_companies_id
  2347. ) a
  2348. </select>
  2349. <select id="getUserNumber" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  2350. SELECT
  2351. COUNT(DISTINCT io.userId) AS "userNumber"
  2352. FROM
  2353. ins_area_company iac
  2354. LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
  2355. LEFT JOIN ins_orders io on io.orderno = iac.orderno
  2356. LEFT JOIN ins_fee_audit ifa on ifa.ins_order_no =iac.id
  2357. WHERE
  2358. agree.id IS NOT NULL
  2359. and iac.orderstatus = '3'
  2360. and ifa.auditstatus != '2'
  2361. <if test="vo.companyId != null and vo.companyId!='' ">
  2362. and agree.insurance_company_id = #{vo.companyId}
  2363. </if>
  2364. <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
  2365. and agree.partner_companies_id = #{vo.parterCompanyId}
  2366. </if>
  2367. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  2368. 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')
  2369. </if>
  2370. <if test="vo.provinceId != null and vo.provinceId != '' and vo.cityId == null and vo.countyId == null and vo.houseId == null ">
  2371. and io.deptid like concat('%',#{vo.provinceId},'%')
  2372. </if>
  2373. <if test="vo.cityId != null and vo.cityId != '' and vo.countyId ==null and vo.houseId ==null">
  2374. and io.deptid like concat('%',#{vo.cityId},'%')
  2375. </if>
  2376. <if test="vo.countyId != null and vo.countyId != '' and vo.houseId ==null">
  2377. and io.deptid like concat('%',#{vo.countyId},'%')
  2378. </if>
  2379. <if test="vo.houseId != null and vo.houseId != ''">
  2380. and io.deptid like concat('%',#{vo.houseId},'%')
  2381. </if>
  2382. <if test="vo.parterProvinceId != null and vo.parterProvinceId != '' and vo.parterCityId == null and vo.parterCountyId == null ">
  2383. and agree.partner_companies_id like concat('%',#{vo.parterProvinceId},'%')
  2384. </if>
  2385. <if test="vo.parterCityId != null and vo.parterCityId != '' and vo.parterCountyId ==null ">
  2386. and agree.partner_companies_id like concat('%',#{vo.parterCityId},'%')
  2387. </if>
  2388. <if test="vo.parterCountyId != null and vo.parterCountyId != '' ">
  2389. and agree.partner_companies_id like concat('%',#{vo.parterCountyId},'%')
  2390. </if>
  2391. <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
  2392. AND io.deptid in
  2393. <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
  2394. #{item}
  2395. </foreach>
  2396. </if>
  2397. <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
  2398. AND io.userid in
  2399. <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
  2400. #{item}
  2401. </foreach>
  2402. </if>
  2403. </select>
  2404. <select id="getDistribution" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  2405. SELECT
  2406. agree.insurance_company_id AS "companyId",
  2407. agree.insurance_company AS "insuranceCompanyName",
  2408. agree.partner_companies_id AS "parterCompanyId",
  2409. ins.namesimple AS "partnerCompaniesName",
  2410. IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0) as "totalPremium",
  2411. COUNT(0) AS "qutationInsureCount",
  2412. ROUND((IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0)) / COUNT(0), 2) AS "averagePremium",
  2413. COUNT(DISTINCT io.userId) AS "userNumber",
  2414. ROUND((IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0)) / COUNT(DISTINCT io.userId) ,2) as "perCapitaAmount"
  2415. FROM
  2416. ins_area_company iac
  2417. LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
  2418. LEFT JOIN ins_orders io on io.orderno = iac.orderno
  2419. LEFT JOIN esm_ins_company ins ON agree.partner_companies_id = ins.id
  2420. LEFT JOIN ins_fee_audit ifa on ifa.ins_order_no =iac.id
  2421. WHERE
  2422. agree.id IS NOT NULL
  2423. and ifa.auditstatus != '2'
  2424. <if test="vo.companyId != null and vo.companyId!='' ">
  2425. and agree.insurance_company_id = #{vo.companyId}
  2426. </if>
  2427. <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
  2428. and agree.partner_companies_id = #{vo.parterCompanyId}
  2429. </if>
  2430. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  2431. AND DATE_FORMAT( iac.signing_time, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{vo.createtimeStart}, '%Y-%m-%d') AND DATE_FORMAT( #{vo.createtimeEnd}, '%Y-%m-%d')
  2432. </if>
  2433. <if test="vo.days !=null and vo.days !='' and vo.days != 0 ">
  2434. and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{vo.days} DAY)
  2435. </if>
  2436. <if test="vo.provinceId != null and vo.provinceId != ''">
  2437. and io.deptid like "${vo.provinceId}%"
  2438. </if>
  2439. <if test="vo.cityId != null and vo.cityId != ''">
  2440. and io.deptid like "${vo.cityId}%"
  2441. </if>
  2442. <if test="vo.countyId != null and vo.countyId != ''">
  2443. and io.deptid like "${vo.countyId}%"
  2444. </if>
  2445. <if test="vo.houseId != null and vo.houseId != ''">
  2446. and io.deptid like "${vo.houseId}%"
  2447. </if>
  2448. <if test="vo.quotationStatus != null and vo.quotationStatus != ''">
  2449. and iac.orderstatus =#{vo.quotationStatus}
  2450. </if>
  2451. <if test="vo.dockingPerson != null and vo.dockingPerson != ''">
  2452. and agree.docking_person =#{vo.dockingPerson}
  2453. </if>
  2454. <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
  2455. AND io.deptid in
  2456. <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
  2457. #{item}
  2458. </foreach>
  2459. </if>
  2460. <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
  2461. AND io.userid in
  2462. <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
  2463. #{item}
  2464. </foreach>
  2465. </if>
  2466. <if test="vo.riskCode != null and vo.riskCode != '' and vo.riskCode != 'all'">
  2467. and iac.product = #{vo.riskCode}
  2468. </if>
  2469. GROUP BY
  2470. agree.insurance_company_id,
  2471. agree.insurance_company,
  2472. agree.partner_companies_id,
  2473. ins.namesimple
  2474. </select>
  2475. <select id="getOrderPremiumByUserIds" resultType="Double">
  2476. SELECT
  2477. IFNULL(
  2478. SUM( IFNULL( iac.jqpremium, 0 ) + IFNULL( iac.sypremium, 0 ) + IFNULL( iac.jypremium, 0 ) ),
  2479. 0
  2480. ) AS "totalPremium"
  2481. FROM
  2482. `ins_area_company` iac
  2483. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  2484. <where>
  2485. iac.orderstatus = '3'
  2486. <if test="vo.ids != null and vo.ids.size()>0 ">
  2487. AND io.userid IN
  2488. <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
  2489. #{item}
  2490. </foreach>
  2491. </if>
  2492. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  2493. AND iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
  2494. </if>
  2495. </where>
  2496. </select>
  2497. <select id="querOrdersDataPage" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
  2498. SELECT
  2499. count( 0 ) AS "orderNumber",
  2500. b.licenseno as "licenseno",
  2501. b.frameno as "frameno",
  2502. b.modelCode as "modelCode",
  2503. b.modelcname as "modelcname"
  2504. FROM
  2505. (
  2506. SELECT
  2507. io.orderstatus AS orderstatus,
  2508. io.frameno AS frameno,
  2509. REPLACE(JSON_EXTRACT(io.carinfo, '$.engineNo'), '"', '') as "modelCode",
  2510. REPLACE(JSON_EXTRACT(io.carinfo, '$.modelcname'), '"', '') as "modelcname",
  2511. ifnull(io.licenseno, '') AS licenseno
  2512. FROM
  2513. ins_orders io
  2514. LEFT JOIN sys_user su on io.userid=su.id
  2515. <where>
  2516. 1=1
  2517. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  2518. AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  2519. </if>
  2520. <if test="vo.licenseno != null and vo.licenseno!='' ">
  2521. AND io.licenseno =#{vo.licenseno}
  2522. </if>
  2523. <if test="vo.userId != null and vo.userId!='' ">
  2524. AND io.userid =#{vo.userId}
  2525. </if>
  2526. <if test="vo.userName != null and vo.userName!='' ">
  2527. AND su.name =#{vo.userName}
  2528. </if>
  2529. <if test="vo.mobile != null and vo.mobile!='' ">
  2530. AND su.mobile =#{vo.mobile}
  2531. </if>
  2532. <if test="vo.frameno != null and vo.frameno!='' ">
  2533. AND io.frameno =#{vo.frameno}
  2534. </if>
  2535. <if test="vo.deptId != null and vo.deptId!='' ">
  2536. and io.deptid like concat('%', #{vo.deptId}, '%')
  2537. </if>
  2538. <if test="vo.year != null and vo.year!='' ">
  2539. AND DATE_FORMAT( io.createtime, '%Y') =#{vo.year}
  2540. </if>
  2541. <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
  2542. AND io.deptid in
  2543. <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
  2544. #{item}
  2545. </foreach>
  2546. </if>
  2547. <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
  2548. AND io.userid in
  2549. <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
  2550. #{item}
  2551. </foreach>
  2552. </if>
  2553. </where>
  2554. ) b
  2555. GROUP BY
  2556. b.licenseno,
  2557. b.frameno,
  2558. b.modelCode,
  2559. b.modelcname
  2560. </select>
  2561. <select id="getOrdersGroupByLicenseno" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
  2562. SELECT
  2563. io.licenseno AS "licenseno",
  2564. io.frameno AS "frameno",
  2565. io.orderstatus as "orderstatus",
  2566. io.orderno as "orderno"
  2567. FROM
  2568. ins_orders io
  2569. LEFT JOIN sys_user su on io.userid=su.id
  2570. <where>
  2571. io.licenseno is not null
  2572. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  2573. AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  2574. </if>
  2575. <if test="vo.licenseno != null and vo.licenseno!='' ">
  2576. AND io.licenseno =#{vo.licenseno}
  2577. </if>
  2578. <if test="vo.userId != null and vo.userId!='' ">
  2579. AND io.userId =#{vo.userId}
  2580. </if>
  2581. <if test="vo.userName != null and vo.userName!='' ">
  2582. AND su.name =#{vo.userName}
  2583. </if>
  2584. <if test="vo.mobile != null and vo.mobile!='' ">
  2585. AND su.mobile =#{vo.mobile}
  2586. </if>
  2587. <if test="vo.frameno != null and vo.frameno!='' ">
  2588. AND su.frameno =#{vo.frameno}
  2589. </if>
  2590. <if test="vo.deptId != null and vo.deptId!='' ">
  2591. and io.deptid like concat('%', #{vo.deptId}, '%')
  2592. </if>
  2593. </where>
  2594. </select>
  2595. <select id="querOrdersamountTo" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
  2596. select sum(a.orderNumber) as "orderNumber",
  2597. count(a.licenseno) as "b.frameno"
  2598. from (
  2599. SELECT
  2600. count( 0 ) AS "orderNumber",
  2601. b.licenseno as "licenseno",
  2602. b.frameno as "frameno"
  2603. FROM
  2604. (
  2605. SELECT
  2606. io.orderstatus AS orderstatus,
  2607. io.frameno AS frameno,
  2608. ifnull(io.licenseno, '') AS licenseno
  2609. FROM
  2610. ins_orders io
  2611. LEFT JOIN sys_user su on io.userid=su.id
  2612. <where>
  2613. 1=1
  2614. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  2615. AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  2616. </if>
  2617. <if test="vo.licenseno != null and vo.licenseno!='' ">
  2618. AND io.licenseno =#{vo.licenseno}
  2619. </if>
  2620. <if test="vo.userId != null and vo.userId!='' ">
  2621. AND io.userid =#{vo.userId}
  2622. </if>
  2623. <if test="vo.userName != null and vo.userName!='' ">
  2624. AND su.name =#{vo.userName}
  2625. </if>
  2626. <if test="vo.mobile != null and vo.mobile!='' ">
  2627. AND su.mobile =#{vo.mobile}
  2628. </if>
  2629. <if test="vo.frameno != null and vo.frameno!='' ">
  2630. AND io.frameno =#{vo.frameno}
  2631. </if>
  2632. <if test="vo.deptId != null and vo.deptId!='' ">
  2633. and io.deptid like concat('%', #{vo.deptId}, '%')
  2634. </if>
  2635. </where>
  2636. ) b
  2637. GROUP BY
  2638. b.licenseno,
  2639. b.frameno
  2640. ) a
  2641. </select>
  2642. <select id="querResultOrderNumber" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
  2643. SELECT
  2644. count( io.orderno ) AS "orderNumber",
  2645. 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"
  2646. FROM
  2647. ins_orders io
  2648. LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
  2649. LEFT JOIN sys_user su ON io.userid = su.id
  2650. <where>
  2651. 1=1
  2652. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  2653. AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  2654. </if>
  2655. <if test="vo.licenseno != null and vo.licenseno!='' ">
  2656. AND io.licenseno =#{vo.licenseno}
  2657. </if>
  2658. <if test="vo.userId != null and vo.userId!='' ">
  2659. AND io.userid =#{vo.userId}
  2660. </if>
  2661. <if test="vo.userName != null and vo.userName!='' ">
  2662. AND su.name =#{vo.userName}
  2663. </if>
  2664. <if test="vo.mobile != null and vo.mobile!='' ">
  2665. AND su.mobile =#{vo.mobile}
  2666. </if>
  2667. <if test="vo.frameno != null and vo.frameno!='' ">
  2668. AND su.frameno =#{vo.frameno}
  2669. </if>
  2670. <if test="vo.deptId != null and vo.deptId!='' ">
  2671. and io.deptid like concat('%', #{vo.deptId}, '%')
  2672. </if>
  2673. </where>
  2674. </select>
  2675. <select id="numberQuotationsByUserIds" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  2676. SELECT
  2677. count(iac.id) as "orderNumber",
  2678. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
  2679. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  2680. sum( CASE WHEN iac.orderstatus = 3 THEN IFNULL(iac.jqpremium, 0) + IFNULL(iac.sypremium, 0) + IFNULL(iac.jypremium, 0) END ) AS totalPremium
  2681. FROM
  2682. ins_area_company iac
  2683. left join ins_orders io on io.orderno = iac.orderno
  2684. <where>
  2685. <if test="ids != null and ids.size()>0 ">
  2686. AND io.userid IN
  2687. <foreach item="item" collection="ids" open="(" separator="," close=")">
  2688. #{item}
  2689. </foreach>
  2690. </if>
  2691. <if test="month != null and month!='' ">
  2692. AND DATE_FORMAT(iac.createtime, '%Y-%m') =#{month}
  2693. </if>
  2694. </where>
  2695. </select>
  2696. <select id="selectByOrdersDataVo" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
  2697. select
  2698. iac.inscompany as "namesimple"
  2699. from
  2700. ins_area_company iac
  2701. <where>
  2702. 1=1
  2703. <if test="vo.orderstatus != null and vo.orderstatus != '' ">
  2704. AND iac.orderstatus =#{vo.orderstatus}
  2705. </if>
  2706. <if test="vo.orderno !=null and vo.orderno !='' ">
  2707. AND iac.orderno =#{vo.orderno}
  2708. </if>
  2709. </where>
  2710. </select>
  2711. <select id="channelExcel" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsExcel">
  2712. select a.*,(select name from sys_user where id =a.userId) as "userName"
  2713. from (
  2714. SELECT
  2715. sd.NAME AS "deptName",
  2716. io.userid AS "userId",
  2717. sd.parent_id as "deptId",
  2718. sd.management_source as "managementSource",
  2719. COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS qutationCount,
  2720. COUNT( CASE WHEN iot.order_status ='2' THEN 1 END ) AS underwritingCount,
  2721. COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) AS qutationInsureCount,
  2722. COUNT( CASE WHEN iot.order_status = '4' THEN 1 END ) AS underwritingReturn,
  2723. COUNT( CASE WHEN iot.order_status ='2' THEN 1 END ) / COUNT( CASE WHEN iot.order_status ='0' THEN 1 END ) AS "passingRate",
  2724. 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",
  2725. (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",
  2726. 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",
  2727. COUNT(CASE WHEN io.order_source = 0 and iot.order_status ='0' THEN 1 END) as "pcOrderSource",
  2728. COUNT(CASE WHEN io.order_source = 1 and iot.order_status ='0' THEN 1 END) as "appOrderSource",
  2729. COUNT( CASE WHEN iot.order_status = '1' THEN 1 END ) AS "auditOrder"
  2730. FROM
  2731. (
  2732. select iot.suborder,iot.order_status from `ins_orders_track` iot
  2733. GROUP BY iot.suborder ,iot.order_status
  2734. ) iot
  2735. left join ins_area_company iac ON iac.id = iot.suborder
  2736. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  2737. LEFT JOIN sys_dept sd ON sd.id = io.deptid
  2738. <where>
  2739. <if test="taskStatisticsVo.managementSource != null and taskStatisticsVo.managementSource!=''">
  2740. AND sd.management_source =#{taskStatisticsVo.managementSource}
  2741. </if>
  2742. <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
  2743. and io.deptid like "${taskStatisticsVo.provinceId}%"
  2744. </if>
  2745. <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
  2746. and io.deptid like "${taskStatisticsVo.cityId}%"
  2747. </if>
  2748. <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
  2749. and io.deptid like "${taskStatisticsVo.countyId}%"
  2750. </if>
  2751. <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
  2752. and io.deptid like "${taskStatisticsVo.houseId}%"
  2753. </if>
  2754. <if test="taskStatisticsVo.userId != null and taskStatisticsVo.userId != ''">
  2755. and io.userid =#{taskStatisticsVo.userId}
  2756. </if>
  2757. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  2758. AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
  2759. </if>
  2760. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  2761. 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')
  2762. </if>
  2763. <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
  2764. AND sd.id in
  2765. <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
  2766. #{item}
  2767. </foreach>
  2768. </if>
  2769. <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
  2770. AND io.userid in
  2771. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  2772. #{item}
  2773. </foreach>
  2774. </if>
  2775. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  2776. <choose>
  2777. <when test="taskStatisticsVo.days =='1'">
  2778. and io.createtime >= DATE_SUB(NOW(), INTERVAL 1 DAY)
  2779. </when>
  2780. <when test="taskStatisticsVo.days =='7'">
  2781. and io.createtime >= DATE_SUB(NOW(), INTERVAL 7 DAY)
  2782. </when>
  2783. <when test="taskStatisticsVo.days =='30'">
  2784. and io.createtime >= DATE_SUB(NOW(), INTERVAL 30 DAY)
  2785. </when>
  2786. </choose>
  2787. </if>
  2788. </where>
  2789. GROUP BY
  2790. io.userid,
  2791. sd.NAME,
  2792. sd.id,
  2793. sd.management_source
  2794. ) a
  2795. left join sys_user su on su.id =a.userId
  2796. LEFT JOIN ins_upload_files inf on su.head_sculpture =inf.id
  2797. LEFT JOIN sys_user_info sui on sui .id =su.id
  2798. LEFT JOIN sys_user su2 on su2.id =su.leader_id
  2799. <where>
  2800. <if test='taskStatisticsVo.userName !=null and taskStatisticsVo.userName!="" '>
  2801. and su.name like concat('%',#{taskStatisticsVo.userName},'%')
  2802. </if>
  2803. <if test='taskStatisticsVo.leaderId !=null and taskStatisticsVo.leaderId!="" '>
  2804. and su.leader_id =#{taskStatisticsVo.leaderId}
  2805. </if>
  2806. <if test='taskStatisticsVo.userId !=null and taskStatisticsVo.userId!="" '>
  2807. and su.id =#{taskStatisticsVo.userId}
  2808. </if>
  2809. </where>
  2810. </select>
  2811. <select id="insuranceCompanyExcel" resultType="com.ydtech.modules.admin.model.dto.InsuranceCompanyExcel">
  2812. SELECT
  2813. a.*,
  2814. ( SELECT eic.namesimple FROM esm_ins_company eic WHERE eic.id = a.partner_companies_id ) AS "partnerCompaniesName"
  2815. FROM
  2816. (
  2817. SELECT
  2818. pa.insurance_company_id,
  2819. pa.partner_companies_id,
  2820. pa.insurance_company AS "insuranceCompanyName",
  2821. COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS qutationCount,
  2822. COUNT( CASE WHEN iot.order_status = '1' THEN 1 END ) AS "auditOrder",
  2823. COUNT( CASE WHEN iot.order_status = '2' THEN 1 END ) AS underwritingCount,
  2824. COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) AS qutationInsureCount,
  2825. COUNT( CASE WHEN iot.order_status = '4' THEN 1 END ) AS underwritingReturn,
  2826. COUNT( CASE WHEN iot.order_status ='2' THEN 1 END ) / COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS "passingRate",
  2827. COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) / COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS "closeRate",
  2828. (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",
  2829. COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) / COUNT( iot.order_status ) AS "quotationRate"
  2830. FROM
  2831. (
  2832. select iot.suborder,iot.order_status from `ins_orders_track` iot
  2833. GROUP BY iot.suborder ,iot.order_status
  2834. ) iot
  2835. LEFT JOIN ins_area_company iac ON iac.id = iot.suborder
  2836. LEFT JOIN ins_fee_audit ifa ON ifa.ins_order_no = iac.id
  2837. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  2838. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  2839. <where>
  2840. pa.insurance_company_id IS NOT NULL
  2841. <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
  2842. and io.deptid like concat('%', #{taskStatisticsVo.provinceId}, '%')
  2843. </if>
  2844. <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
  2845. and io.deptid like concat('%', #{taskStatisticsVo.cityId}, '%')
  2846. </if>
  2847. <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
  2848. and io.deptid like concat('%', #{taskStatisticsVo.countyId}, '%')
  2849. </if>
  2850. <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
  2851. and io.deptid like concat('%', #{taskStatisticsVo.houseId}, '%')
  2852. </if>
  2853. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  2854. AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT(#{taskStatisticsVo.createtimeStart},'%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.createtimeEnd}, '%Y-%m-%d')
  2855. </if>
  2856. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  2857. AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
  2858. </if>
  2859. <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId != ''">
  2860. AND iac.company_id =#{taskStatisticsVo.companyId}
  2861. </if>
  2862. <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
  2863. AND io.deptid in
  2864. <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
  2865. #{item}
  2866. </foreach>
  2867. </if>
  2868. <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
  2869. AND io.userid in
  2870. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  2871. #{item}
  2872. </foreach>
  2873. </if>
  2874. </where>
  2875. GROUP BY
  2876. pa.insurance_company_id,
  2877. pa.partner_companies_id,
  2878. pa.insurance_company
  2879. ) a
  2880. </select>
  2881. <select id="getSumBigOrderCount" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
  2882. select count(0) as "orderNumber",
  2883. GROUP_CONCAT(inscompany ORDER BY inscompany SEPARATOR ',') as "namesimple"
  2884. from ins_area_company iac
  2885. left join ins_orders io on io.orderno = iac.orderno
  2886. <where>
  2887. 1=1
  2888. and iac.orderstatus ='3'
  2889. and io.orderstatus ='3'
  2890. <if test="vo.licenseno !=null and vo.licenseno!=''">
  2891. AND io.licenseno =#{vo.licenseno}
  2892. </if>
  2893. <if test="vo.frameno !=null and vo.frameno!=''">
  2894. AND io.frameno =#{vo.frameno}
  2895. </if>
  2896. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  2897. AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  2898. </if>
  2899. <if test="vo.year != null and vo.year!='' ">
  2900. AND DATE_FORMAT( io.createtime, '%Y') =#{vo.year}
  2901. </if>
  2902. </where>
  2903. limit 10
  2904. </select>
  2905. <select id="queryAgencyUserInsAreaPage" resultType="com.ydtech.modules.admin.model.vo.AgencyUserInsAreaVo">
  2906. select
  2907. io.userid as userId,
  2908. io.username as userName,
  2909. io.licenseno as licenseno,
  2910. iac.id as companyId,
  2911. iac.jqpremium as jqpremium,
  2912. iac.sypremium as sypremium,
  2913. iac.jypremium as jypremium,
  2914. iac.createtime as createtime,
  2915. iac.orderstatus as orderstatus
  2916. from ins_area_company iac
  2917. left join ins_orders io on io.orderno = iac.orderno
  2918. <where>
  2919. iac.orderstatus=3
  2920. <if test="dto.userId !=null and dto.userId !=''">
  2921. and io.userid = #{dto.userId}
  2922. </if>
  2923. <if test="dto.deptId !=null and dto.deptId !=''">
  2924. and io.deptid like concat( #{dto.deptId}, '%')
  2925. </if>
  2926. <if test="dto.startTime !=null and dto.startTime !=''">
  2927. and io.createtime >= #{dto.startTime}
  2928. </if>
  2929. </where>
  2930. ORDER BY iac.createtime
  2931. </select>
  2932. <select id="querOrdersDataListExcel" resultType="com.ydtech.modules.admin.model.dto.OrdersDataExcel">
  2933. SELECT
  2934. count( 0 ) AS "orderNumber",
  2935. b.licenseno as "licenseno",
  2936. b.frameno as "frameno",
  2937. b.modelCode as "modelCode",
  2938. b.modelcname as "modelcname"
  2939. FROM
  2940. (
  2941. SELECT
  2942. io.orderstatus AS orderstatus,
  2943. io.frameno AS frameno,
  2944. REPLACE(JSON_EXTRACT(io.carinfo, '$.engineNo'), '"', '') as "modelCode",
  2945. REPLACE(JSON_EXTRACT(io.carinfo, '$.modelcname'), '"', '') as "modelcname",
  2946. ifnull(io.licenseno, '') AS licenseno
  2947. FROM
  2948. ins_orders io
  2949. LEFT JOIN sys_user su on io.userid=su.id
  2950. <where>
  2951. 1=1
  2952. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  2953. AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  2954. </if>
  2955. <if test="vo.licenseno != null and vo.licenseno!='' ">
  2956. AND io.licenseno =#{vo.licenseno}
  2957. </if>
  2958. <if test="vo.userId != null and vo.userId!='' ">
  2959. AND io.userid =#{vo.userId}
  2960. </if>
  2961. <if test="vo.userName != null and vo.userName!='' ">
  2962. AND su.name =#{vo.userName}
  2963. </if>
  2964. <if test="vo.mobile != null and vo.mobile!='' ">
  2965. AND su.mobile =#{vo.mobile}
  2966. </if>
  2967. <if test="vo.frameno != null and vo.frameno!='' ">
  2968. AND io.frameno =#{vo.frameno}
  2969. </if>
  2970. <if test="vo.deptId != null and vo.deptId!='' ">
  2971. and io.deptid like concat('%', #{vo.deptId}, '%')
  2972. </if>
  2973. <if test="vo.year != null and vo.year!='' ">
  2974. AND DATE_FORMAT( io.createtime, '%Y') =#{vo.year}
  2975. </if>
  2976. <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
  2977. AND io.deptid in
  2978. <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
  2979. #{item}
  2980. </foreach>
  2981. </if>
  2982. <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
  2983. AND io.userid in
  2984. <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
  2985. #{item}
  2986. </foreach>
  2987. </if>
  2988. </where>
  2989. ) b
  2990. GROUP BY
  2991. b.licenseno,
  2992. b.frameno,
  2993. b.modelCode,
  2994. b.modelcname
  2995. </select>
  2996. <select id="orderCheckPage" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
  2997. select
  2998. iac.id,
  2999. iac.orderno,
  3000. iac.agreement_id,
  3001. iac.jqpremium,
  3002. iac.sypremium,
  3003. iac.jypremium,
  3004. iac.taxamount,
  3005. iac.sumpremium,
  3006. io.licenseno,
  3007. iac.createtime,
  3008. su.name as auditname
  3009. FROM
  3010. ins_area_company iac
  3011. LEFT JOIN
  3012. ins_orders io on iac.orderno = io.orderno
  3013. left join ptl_agreement agree on iac.agreement_id =agree.id
  3014. left join ins_fee_audit ifa on iac.id = ifa.ins_order_no
  3015. left join sys_user su on su.id= ifa.audituser
  3016. WHERE
  3017. iac.operator_id = #{userId}
  3018. AND
  3019. iac.orderstatus = 3
  3020. and agree.is_external =1
  3021. and auditstatus =1
  3022. <if test="vo.id != null and vo.id!='' ">
  3023. and iac.id = #{vo.id}
  3024. </if>
  3025. <if test="vo.licenseno != null and vo.licenseno!='' ">
  3026. and io.licenseno like CONCAT('%', #{vo.licenseno}, '%')
  3027. </if>
  3028. </select>
  3029. <select id="costCenterTotal" resultType="java.util.HashMap">
  3030. SELECT
  3031. COUNT( CASE WHEN ifa.auditstatus = 1 THEN 1 END ) AS "allAuditstatusOrders",
  3032. COUNT( CASE WHEN ifa.auditstatus = 0 THEN 1 END ) AS "allAuditOrder",
  3033. COUNT( CASE WHEN ifa.auditstatus = 1 and ifa.audituser != '自动审核' THEN 1 END ) AS "allPersionAudit",
  3034. COUNT( CASE WHEN ifa.audituser = '自动审核' THEN 1 END ) AS "allAutomaticAudit"
  3035. FROM
  3036. ins_fee_audit ifa
  3037. LEFT JOIN ins_orders io ON io.orderno = ifa.orderno
  3038. LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
  3039. AND iac.orderstatus = 3
  3040. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  3041. LEFT JOIN esm_ins_company eic ON eic.id = pa.partner_companies_id
  3042. left join sys_user su on su.id =ifa.audituser
  3043. <where>
  3044. 1=1
  3045. and iac.id = ifa.ins_order_no
  3046. AND iac.orderstatus = 3
  3047. <if test="taskStatisticsVo.reviewer !=null and taskStatisticsVo.reviewer !=''">
  3048. and su.name =#{taskStatisticsVo.reviewer}
  3049. </if>
  3050. <if test="taskStatisticsVo.audittime !=null and taskStatisticsVo.audittime !=''">
  3051. and ifa.audittime =#{taskStatisticsVo.audittime}
  3052. </if>
  3053. <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId !=''">
  3054. and iac.company_id =#{taskStatisticsVo.companyId}
  3055. </if>
  3056. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  3057. 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')
  3058. </if>
  3059. <if test="taskStatisticsVo.auditTimeStart !=null and taskStatisticsVo.auditTimeEnd != '' and taskStatisticsVo.auditTimeStart !=null and taskStatisticsVo.auditTimeEnd != ''">
  3060. AND DATE_FORMAT( ifa.audittime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.auditTimeStart}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.auditTimeEnd}, '%Y-%m-%d')
  3061. </if>
  3062. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  3063. 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')
  3064. </if>
  3065. <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
  3066. AND io.deptid in
  3067. <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
  3068. #{item}
  3069. </foreach>
  3070. </if>
  3071. <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
  3072. AND su.id in
  3073. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  3074. #{item}
  3075. </foreach>
  3076. </if>
  3077. <choose>
  3078. <when test="taskStatisticsVo.riskCode != null and taskStatisticsVo.riskCode != '' and taskStatisticsVo.riskCode != 'all' ">
  3079. and iac.product = #{taskStatisticsVo.riskCode}
  3080. </when>
  3081. </choose>
  3082. </where>
  3083. </select>
  3084. <select id="getSubOrderCountDTO" resultType="com.ydtech.modules.order.entity.dto.SubOrderCountDTO">
  3085. select orderno, orderstatus, count(*)as count
  3086. from (select orderno, company_id, orderstatus
  3087. from ins_area_company
  3088. where orderno in
  3089. <foreach collection="orderNo" open="(" separator="," close=")" item="item" index="index">
  3090. #{item,jdbcType=VARCHAR}
  3091. </foreach>
  3092. and del_flag = '1'
  3093. group by orderno, company_id, orderstatus) as iac
  3094. group by orderno, orderstatus
  3095. </select>
  3096. <select id="getAllRejectOrders" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
  3097. select
  3098. iac.id,
  3099. iac.orderno,
  3100. iac.agreement_id,
  3101. iac.jqpremium,
  3102. iac.sypremium,
  3103. iac.jypremium,
  3104. iac.taxamount,
  3105. iac.sumpremium,
  3106. io.licenseno,
  3107. ifa.audittime,
  3108. ifa.audituser as auditname,
  3109. ifa.rejectinfo,
  3110. "1" as orderExternalStatus
  3111. FROM
  3112. ins_fee_audit ifa
  3113. LEFT JOIN
  3114. ins_area_company iac on iac.id = ifa.ins_order_no
  3115. LEFT JOIN
  3116. ins_orders io on iac.orderno = io.orderno
  3117. left join
  3118. sys_user su on su.id= ifa.audituser
  3119. WHERE
  3120. ifa.auditstatus = 2 and IFNULL(iac.del_flag,'') != '0'
  3121. <if test="vo.id != null and vo.id!=''">
  3122. and iac.id = #{vo.id}
  3123. </if>
  3124. <if test="vo.licenseno != null and vo.licenseno!='' ">
  3125. and io.licenseno like CONCAT('%', #{vo.licenseno}, '%')
  3126. </if>
  3127. <if test="vo.auditname != null and vo.auditname!='' ">
  3128. and su.name like CONCAT('%', #{vo.auditname}, '%')
  3129. </if>
  3130. order by io.createtime
  3131. </select>
  3132. <select id="queryPageOrderCB" resultType="com.ydtech.modules.order.entity.InsOrders">
  3133. SELECT
  3134. iac.id as orderno,
  3135. io.quoteno,
  3136. iac.orderstatus,
  3137. iac.company_id,
  3138. iac.inscompany,
  3139. io.carinfo,
  3140. io.userid,
  3141. io.username,
  3142. io.deptid,
  3143. io.deptname,
  3144. io.agreeid,
  3145. iac.productid,
  3146. iac.product,
  3147. iac.createtime,
  3148. io.frameno,
  3149. io.licenseno,
  3150. JSON_UNQUOTE(json_extract(io.insureinfo, '$.name')) as insuredname,
  3151. io.is_external,
  3152. iac.jq_start_date as jqstartdate,
  3153. iac.jq_end_date as jqenddate,
  3154. iac.sy_start_date as systartdate,
  3155. iac.sy_end_date as syenddate,
  3156. io.vehicle_and_vessel_tax,
  3157. io.operatorid,
  3158. iac.operator_name,
  3159. sd.management_source,
  3160. iac.problem_order,
  3161. eic.namesimple as partnerCompaniesName,
  3162. iac.id as subOrderId,
  3163. iac.signing_time as signingTime,
  3164. iac.pay_date as payDate,
  3165. pa.agreement_code as agreementCode,
  3166. pa.agreement_name as agreementName,
  3167. pa.business_description as businessDescription,
  3168. pa.job_description as jobDescription,
  3169. pa.agreement_title as agreementTitle,
  3170. pa.docking_person as dockingPerson,
  3171. io.entry_status
  3172. FROM
  3173. ins_area_company iac
  3174. LEFT JOIN ins_orders io ON iac.orderno = io.orderno
  3175. LEFT JOIN sys_user su ON su.id = io.userid
  3176. LEFT JOIN sys_dept sd ON sd.id = su.dept_id
  3177. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  3178. LEFT JOIN esm_ins_company eic ON eic.id = pa.partner_companies_id
  3179. WHERE
  3180. iac.orderstatus = 3
  3181. <if test="params.quoteStartDateStr != null and params.quoteStartDateStr != '' and params.quoteEndDateStr != null and params.quoteEndDateStr != ''">
  3182. and DATE_FORMAT(iac.createtime, '%Y-%m-%d') between #{params.quoteStartDateStr} AND
  3183. #{params.quoteEndDateStr}
  3184. </if>
  3185. <if test="params.orderNo != null and params.orderNo != ''">
  3186. AND iac.id= #{params.orderNo}
  3187. </if>
  3188. <if test="params.licenseNo != null and params.licenseNo != ''">
  3189. AND io.licenseno = #{params.licenseNo}
  3190. </if>
  3191. <if test="params.frameNo != null and params.frameNo != ''">
  3192. AND io.frameno = #{params.frameNo}
  3193. </if>
  3194. <if test="params.insuredName != null and params.insuredName != ''">
  3195. AND json_extract(io.insureinfo, '$.name') = #{params.insuredName}
  3196. </if>
  3197. <if test="params.companyId != null and params.companyId != ''">
  3198. AND iac.company_id = #{params.companyId}
  3199. </if>
  3200. <if test="params.engineNo != null and params.engineNo != ''">
  3201. and JSON_EXTRACT( io.carinfo, '$.engineNo' ) = #{params.engineNo}
  3202. </if>
  3203. <if test="params.riskCode != null and params.riskCode != ''">
  3204. and iac.product = #{params.riskCode}
  3205. </if>
  3206. <if test="params.attachStartDateStr != null and params.attachStartDateStr != '' and params.attachStartDateStr != null and params.attachStartDateStr != '' ">
  3207. and ((
  3208. DATE_FORMAT(iac.jq_start_date, '%Y-%m-%d') BETWEEN #{params.attachStartDateStr}
  3209. AND #{params.attachEndDateStr}
  3210. )
  3211. OR ( DATE_FORMAT(iac.sy_start_date, '%Y-%m-%d') BETWEEN #{params.attachStartDateStr} AND
  3212. #{params.attachEndDateStr} )
  3213. )
  3214. </if>
  3215. <if test="params.provinceId != null and params.provinceId != ''">
  3216. and io.deptid like "${params.provinceId}%"
  3217. </if>
  3218. <if test="params.problemOrder != null and params.problemOrder != ''">
  3219. and iac.problem_order like "${params.problemOrder}%"
  3220. </if>
  3221. <if test="params.cityId != null and params.cityId != ''">
  3222. and io.deptid like "${params.cityId}%"
  3223. </if>
  3224. <if test="params.countyId != null and params.countyId != ''">
  3225. and io.deptid like "${params.countyId}%"
  3226. </if>
  3227. <if test="params.houseId != null and params.houseId != ''">
  3228. and io.deptid like "${params.houseId}%"
  3229. </if>
  3230. <if test="params.operatorId != null and params.operatorId != ''">
  3231. and io.userid = #{params.operatorId}
  3232. </if>
  3233. <if test="params.operatorName != null and params.operatorName != ''">
  3234. and io.username = #{params.operatorName}
  3235. </if>
  3236. <if test="params.auditId != null and params.auditId != ''">
  3237. and iac.new_operator_id = #{params.auditId}
  3238. </if>
  3239. <if test="params.agreeId != null and params.agreeId != ''">
  3240. and iac.agreement_id = #{params.agreeId}
  3241. </if>
  3242. <if test="params.managementSource != null and params.managementSource != ''">
  3243. and sd.management_source = #{params.managementSource}
  3244. </if>
  3245. <if test="params.signStartDateStr != null and params.signStartDateStr != '' and params.signEndDateStr != null and params.signEndDateStr != ''">
  3246. and DATE_FORMAT(iac.signing_time, '%Y-%m-%d') between #{params.signStartDateStr} AND
  3247. #{params.signEndDateStr}
  3248. </if>
  3249. <if test="params.payStartDateStr != null and params.payStartDateStr != '' and params.payEndDateStr != null and params.payEndDateStr != ''">
  3250. and iac.pay_date between #{params.payStartDateStr} AND #{params.payEndDateStr}
  3251. </if>
  3252. <if test="params.isExternal != null and params.isExternal != ''">
  3253. and io.is_external = #{params.isExternal}
  3254. </if>
  3255. <if test="params.jqPolicyNo != null and params.jqPolicyNo != ''">
  3256. and iac.jqpolicyno = #{params.jqPolicyNo}
  3257. </if>
  3258. <if test="params.syPolicyNo != null and params.syPolicyNo != ''">
  3259. and iac.sypolicyno = #{params.syPolicyNo}
  3260. </if>
  3261. <if test="params.noPolicyNo != null and params.noPolicyNo != ''">
  3262. and iac.cross_insurance like concat('%', #{params.noPolicyNo}, '%')
  3263. </if>
  3264. order by iac.createtime desc
  3265. </select>
  3266. <select id="getExpectNetProfit" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
  3267. select
  3268. ROUND(sum(IFNULL(ifon.jq_costs_premiums,0) + IFNULL(ifon.sy_costs_premiums,0) + IFNULL (ifon.no_costs_premiums,0)),2) as "entranceAllFee",
  3269. ROUND(sum(IFNULL(jq_export_other_costs_premiums,0) + IFNULL(jq_export_supervise_costs_premiums,0)
  3270. +IFNULL(sy_export_other_costs_premiums,0) +IFNULL(sy_export_supervise_costs_premiums,0)
  3271. +IFNULL(no_export_other_costs_premiums,0)+IFNULL(no_export_supervise_costs_premiums,0) ),2) as
  3272. "exportAllFee",
  3273. ROUND(sum(IFNULL(b.distributionAmount,0)),2) as "distributionAmount"
  3274. from ins_area_company iac
  3275. left join ins_orders io on io.orderno = iac.orderno
  3276. LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
  3277. LEFT JOIN (
  3278. select IFNULL(a.firstDetailPremiums,0) + IFNULL(b.secondDetailPremiums,0) +IFNULL(c.thirdDetailPremiums,0) as "distributionAmount",
  3279. a.firstLevelUserId
  3280. from (
  3281. select
  3282. sum(ifon.first_detail_premiums) as "firstDetailPremiums",
  3283. ifon.first_level_user_id as "firstLevelUserId"
  3284. from ins_area_company iac
  3285. left join ins_orders io on io.orderno = iac.orderno
  3286. LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
  3287. <where>
  3288. iac.orderstatus = 3
  3289. <if test="vo.userId !=null and vo.userId !=''">
  3290. AND ifon.first_level_user_id =#{vo.userId}
  3291. </if>
  3292. <if test="vo.ids != null and vo.ids.size()>0 ">
  3293. AND ifon.first_level_user_id IN
  3294. <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
  3295. #{item}
  3296. </foreach>
  3297. </if>
  3298. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  3299. AND iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
  3300. </if>
  3301. </where>
  3302. group by ifon.first_level_user_id
  3303. ) a
  3304. left join (
  3305. select
  3306. sum(IFNULL(second_detail_premiums,0)) as "secondDetailPremiums",
  3307. ifon.two_level_user_id as "twoLevelUserId"
  3308. from ins_area_company iac
  3309. left join ins_orders io on io.orderno = iac.orderno
  3310. LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
  3311. <where>
  3312. iac.orderstatus = 3
  3313. <if test="vo.userId !=null and vo.userId !=''">
  3314. AND ifon.two_level_user_id =#{vo.userId}
  3315. </if>
  3316. <if test="vo.ids != null and vo.ids.size()>0 ">
  3317. AND ifon.two_level_user_id IN
  3318. <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
  3319. #{item}
  3320. </foreach>
  3321. </if>
  3322. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  3323. AND iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
  3324. </if>
  3325. </where>
  3326. group by ifon.two_level_user_id
  3327. ) b on b.twoLevelUserId =a.firstLevelUserId
  3328. left join (
  3329. select
  3330. sum(IFNULL(third_detail_premiums,0)) as "thirdDetailPremiums",
  3331. ifon.three_level_user_id as "threeLevelUserId"
  3332. from ins_area_company iac
  3333. left join ins_orders io on io.orderno = iac.orderno
  3334. LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
  3335. <where>
  3336. iac.orderstatus = 3
  3337. <if test="vo.userId !=null and vo.userId !=''">
  3338. AND ifon.three_level_user_id =#{vo.userId}
  3339. </if>
  3340. <if test="vo.ids != null and vo.ids.size()>0 ">
  3341. AND ifon.three_level_user_id IN
  3342. <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
  3343. #{item}
  3344. </foreach>
  3345. </if>
  3346. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  3347. AND iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
  3348. </if>
  3349. </where>
  3350. group by ifon.three_level_user_id
  3351. ) c on c.threeLevelUserId = a.firstLevelUserId
  3352. ) b on b.firstLevelUserId =iac.leader_id
  3353. <where>
  3354. iac.orderstatus = 3
  3355. <if test="vo.userId !=null and vo.userId !=''">
  3356. AND io.userid =#{vo.userId}
  3357. </if>
  3358. <if test="vo.ids != null and vo.ids.size()>0 ">
  3359. AND io.userid IN
  3360. <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
  3361. #{item}
  3362. </foreach>
  3363. </if>
  3364. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  3365. AND iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
  3366. </if>
  3367. </where>
  3368. </select>
  3369. <select id="getDistributionAllAmount" resultType="java.util.HashMap">
  3370. select IFNULL(a.firstDetailPremiums,0) + IFNULL(b.secondDetailPremiums,0) +IFNULL(c.thirdDetailPremiums,0) as "distributionAmount",
  3371. a.firstLevelUserId
  3372. from (
  3373. select
  3374. sum(ifon.first_detail_premiums) as "firstDetailPremiums",
  3375. ifon.first_level_user_id as "firstLevelUserId"
  3376. from ins_area_company iac
  3377. left join ins_orders io on io.orderno = iac.orderno
  3378. LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
  3379. <where>
  3380. <if test="vo.userId !=null and vo.userId !=''">
  3381. ifon.first_level_user_id =#{vo.userId}
  3382. </if>
  3383. <if test="vo.ids != null and vo.ids.size()>0 ">
  3384. AND io.userid IN
  3385. <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
  3386. #{item}
  3387. </foreach>
  3388. </if>
  3389. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  3390. AND iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
  3391. </if>
  3392. </where>
  3393. group by ifon.first_level_user_id
  3394. ) a
  3395. left join (
  3396. select
  3397. sum(IFNULL(second_detail_premiums,0)) as "secondDetailPremiums",
  3398. ifon.two_level_user_id as "twoLevelUserId"
  3399. from ins_area_company iac
  3400. left join ins_orders io on io.orderno = iac.orderno
  3401. LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
  3402. <where>
  3403. <if test="vo.userId !=null and vo.userId !=''">
  3404. ifon.two_level_user_id =#{vo.userId}
  3405. </if>
  3406. <if test="vo.ids != null and vo.ids.size()>0 ">
  3407. AND io.userid IN
  3408. <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
  3409. #{item}
  3410. </foreach>
  3411. </if>
  3412. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  3413. AND iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
  3414. </if>
  3415. </where>
  3416. group by ifon.two_level_user_id
  3417. ) b on b.twoLevelUserId =a.firstLevelUserId
  3418. left join (
  3419. select
  3420. sum(IFNULL(third_detail_premiums,0)) as "thirdDetailPremiums",
  3421. ifon.three_level_user_id as "threeLevelUserId"
  3422. from ins_area_company iac
  3423. left join ins_orders io on io.orderno = iac.orderno
  3424. LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
  3425. <where>
  3426. <if test="vo.userId !=null and vo.userId !=''">
  3427. ifon.three_level_user_id =#{vo.userId}
  3428. </if>
  3429. <if test="vo.ids != null and vo.ids.size()>0 ">
  3430. AND io.userid IN
  3431. <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
  3432. #{item}
  3433. </foreach>
  3434. </if>
  3435. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  3436. AND iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
  3437. </if>
  3438. </where>
  3439. group by ifon.three_level_user_id
  3440. ) c on c.threeLevelUserId = a.firstLevelUserId
  3441. </select>
  3442. <select id="findListByDate" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
  3443. SELECT
  3444. iac.*
  3445. FROM ins_area_company as iac
  3446. <where>
  3447. iac.orderstatus = 3
  3448. <if test="benginDate != null and benginDate!='' and endDate != null and endDate!=''">
  3449. AND iac.createtime BETWEEN #{benginDate} AND #{endDate}
  3450. </if>
  3451. </where>
  3452. order by iac.createtime
  3453. </select>
  3454. <select id="getSumEntryStatus" resultType="java.lang.String">
  3455. select count(0)
  3456. from ins_area_company iac
  3457. left join ins_orders io on iac.orderno =io.orderno
  3458. <where>
  3459. iac.entry_status ='2'
  3460. <if test="taskStatisticsVo.userId !=null and taskStatisticsVo.userId != ''">
  3461. and io.userid =#{taskStatisticsVo.userId}
  3462. </if>
  3463. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  3464. AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
  3465. </if>
  3466. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  3467. 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')
  3468. </if>
  3469. </where>
  3470. </select>
  3471. </mapper>