| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper
- PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
- "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.ydtech.modules.order.dao.InsAreaCompanyMapper">
- <resultMap id="BaseResultMap" type="com.ydtech.modules.order.entity.InsAreaCompany">
- <id property="id" column="id" jdbcType="VARCHAR"/>
- <result property="reqtxt" column="reqtxt" javaType="com.alibaba.fastjson.JSONObject"
- typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
- <result property="reptxt" column="reptxt" javaType="com.alibaba.fastjson.JSONObject"
- typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
- <result property="riskinfo" column="riskinfo" javaType="com.alibaba.fastjson.JSONArray"
- typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
- <result property="kindinfo" column="kindinfo" javaType="com.alibaba.fastjson.JSONArray"
- typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
- <result property="accidentInfo" column="accident_info" javaType="com.alibaba.fastjson.JSONArray"
- typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
- <result property="taxArrears" column="tax_arrears" javaType="com.alibaba.fastjson.JSONArray"
- typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
- <result property="crossInsurance" column="cross_insurance" javaType="com.alibaba.fastjson.JSONArray"
- typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
- <result property="orderno" column="orderno" jdbcType="VARCHAR"/>
- <result property="agreementId" column="agreement_id" jdbcType="BIGINT"/>
- <result property="apiType" column="api_type" jdbcType="TINYINT"/>
- <result property="orderstatus" column="orderstatus" jdbcType="VARCHAR"/>
- <result property="companyId" column="company_id" jdbcType="VARCHAR"/>
- <result property="inscompany" column="inscompany" jdbcType="VARCHAR"/>
- <result property="jqapplyno" column="jqapplyno" jdbcType="VARCHAR"/>
- <result property="jqpolicyno" column="jqpolicyno" jdbcType="VARCHAR"/>
- <result property="syapplyno" column="syapplyno" jdbcType="VARCHAR"/>
- <result property="sypolicyno" column="sypolicyno" jdbcType="VARCHAR"/>
- <result property="jqpremium" column="jqpremium" jdbcType="DECIMAL"/>
- <result property="sypremium" column="sypremium" jdbcType="DECIMAL"/>
- <result property="jypremium" column="jypremium" jdbcType="DECIMAL"/>
- <result property="sumpremium" column="sumpremium" jdbcType="DECIMAL"/>
- <result property="taxamount" column="taxamount" jdbcType="DECIMAL"/>
- <result property="jqdiscountrate" column="jqdiscountrate" jdbcType="DOUBLE"/>
- <result property="sydiscountrate" column="sydiscountrate" jdbcType="DOUBLE"/>
- <result property="feerate" column="feerate" jdbcType="DOUBLE"/>
- <result property="disrate" column="disrate" jdbcType="DOUBLE"/>
- <result property="auditid" column="auditid" jdbcType="VARCHAR"/>
- <result property="auditname" column="auditname" jdbcType="VARCHAR"/>
- <result property="audittime" column="audittime" jdbcType="TIMESTAMP"/>
- <result property="auditopinion" column="auditopinion" jdbcType="VARCHAR"/>
- <result property="jqappoint" column="jqappoint" jdbcType="VARCHAR"/>
- <result property="syappoint" column="syappoint" jdbcType="VARCHAR"/>
- <result property="createtime" column="createtime" jdbcType="TIMESTAMP"/>
- <result property="payDate" column="pay_date" jdbcType="TIMESTAMP"/>
- <result property="paymentLink" column="payment_link" jdbcType="VARCHAR"/>
- <result property="insOrderNo" column="ins_order_no" jdbcType="VARCHAR"/>
- <result property="attributionId" column="attribution_id" jdbcType="VARCHAR"/>
- <result property="jqStartDate" column="jq_start_date" jdbcType="VARCHAR"/>
- <result property="jqEndDate" column="jq_end_date" jdbcType="VARCHAR"/>
- <result property="syStartDate" column="sy_start_date" jdbcType="VARCHAR"/>
- <result property="syEndDate" column="sy_end_date" jdbcType="VARCHAR"/>
- <result property="accidentStrInfo" column="accident_str_info" jdbcType="VARCHAR"/>
- <result property="score" column="score" jdbcType="VARCHAR"/>
- <result property="jqScore" column="jq_score" jdbcType="VARCHAR"/>
- <result property="syScore" column="sy_score" jdbcType="VARCHAR"/>
- <result property="lossRation" column="loss_ration" jdbcType="DOUBLE"/>
- <result property="jqLossRation" column="jq_loss_ration" jdbcType="DOUBLE"/>
- <result property="syLossRation" column="sy_loss_ration" jdbcType="DOUBLE"/>
- <result property="totalAdjustRate" column="total_adjust_rate" jdbcType="DOUBLE"/>
- <result property="jqAdjustRate" column="jq_adjust_rate" jdbcType="DOUBLE"/>
- <result property="syAdjustRate" column="sy_adjust_rate" jdbcType="DOUBLE"/>
- <result property="insideOrderStatus" column="inside_order_status" jdbcType="TINYINT"/>
- <result property="insidePayTime" column="inside_pay_time" jdbcType="TIMESTAMP"/>
- <result property="signingTime" column="signing_time" jdbcType="TIMESTAMP"/>
- <result property="jqRenewal" column="jq_renewal" jdbcType="VARCHAR"/>
- <result property="syRenewal" column="sy_renewal" jdbcType="VARCHAR"/>
- <result property="jqClaims" column="jq_claims" jdbcType="VARCHAR"/>
- <result property="syClaims" column="sy_claims" jdbcType="VARCHAR"/>
- <result property="feeMatchErrMsg" column="fee_match_err_msg" jdbcType="VARCHAR"/>
- <result property="quoteErrMsg" column="quote_err_msg" jdbcType="VARCHAR"/>
- </resultMap>
- <resultMap id="InsAreaCompanyQueryDto" type="com.ydtech.modules.order.entity.dto.InsAreaCompanyQueryDto"
- extends="BaseResultMap">
- <result property="agreementName" column="agreement_name" jdbcType="VARCHAR"/>
- <result property="fileStatus" column="fileStatus" jdbcType="VARCHAR"/>
- </resultMap>
- <sql id="Base_Column_List">
- id,orderno,inscompany,
- reqtxt,reptxt,jqapplyno,
- jqpolicyno,syapplyno,sypolicyno,
- riskinfo,kindinfo,jqpremium,
- sypremium,taxamount,sumpremium,
- jqdiscountrate,sydiscountrate,feerate,
- disrate,auditid,auditname,
- audittime,auditopinion,jqappoint,
- syappoint,createtime,payment_link
- </sql>
- <select id="selectByOrderNo" resultMap="InsAreaCompanyQueryDto">
- SELECT iac.*, pa.agreement_name,
- (select IF(count(0)>0,'true','false') from pingan_sh_uploafile where sub_order_no=iac.id AND status=0) as fileStatus
- FROM ins_area_company as iac
- left join ptl_agreement as pa on pa.id = iac.agreement_id
- INNER JOIN (SELECT company_id, max(createtime) AS max_createtime
- FROM ins_area_company
- WHERE orderno = #{orderNo}
- GROUP BY company_id) t ON t.company_id = iac.company_id
- AND t.max_createtime = iac.createtime
- WHERE iac.orderno = #{orderNo}
- </select>
- <select id="selectAcceptInsurance" resultMap="InsAreaCompanyQueryDto">
- SELECT iac.*, pa.agreement_name,io.is_external,
- (select IF(count(0)>0,'true','false') from pingan_sh_uploafile where sub_order_no=iac.id AND status=0) as fileStatus
- FROM ins_area_company as iac
- left join ptl_agreement as pa on pa.id = iac.agreement_id
- left join ins_orders io on iac.orderno=io.orderno
- WHERE iac.orderstatus = 3
- and iac.orderno = #{orderNo};
- </select>
- <select id="queryLatestStatus" resultType="java.lang.String">
- SELECT iac.orderstatus
- FROM ins_area_company as iac
- INNER JOIN (SELECT company_id, max(createtime) AS max_createtime
- FROM ins_area_company
- WHERE orderno = #{orderNo}
- GROUP BY company_id) t ON t.company_id = iac.company_id
- AND t.max_createtime = iac.createtime
- WHERE iac.orderno = #{orderNo}
- ORDER BY orderstatus DESC
- LIMIT 1
- </select>
- <select id="getorDerIds" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
- SELECT a.id as "id",
- a.orderno as "orderno"
- FROM ins_area_company a
- LEFT JOIN ins_fee_order_new b ON a.id = b.ins_order_no
- WHERE a.orderstatus = '3'
- or a.orderstatus = '2'
- and b.id is not null
- </select>
- <select id="getAuditOrders" resultType="com.ydtech.modules.order.entity.InsOrders">
- SELECT
- iac.id as orderno,
- io.quoteno,
- io.orderstatus,
- io.company_id,
- io.ins_company,
- io.carinfo,
- io.userid,
- io.username,
- io.deptid,
- io.deptname,
- io.agreeid,
- iac.productid,
- iac.product,
- iac.createtime,
- io.frameno,
- io.licenseno,
- JSON_UNQUOTE(json_extract(io.insureinfo, '$.name')) as insuredname,
- io.is_external,
- iac.jq_start_date as jqstartdate,
- iac.jq_end_date as jqenddate,
- iac.sy_start_date as systartdate,
- iac.sy_end_date as syenddate,
- io.vehicle_and_vessel_tax,
- io.operatorid,
- iac.operator_name,
- sd.management_source,
- iac.problem_order,
- CASE ifa.audituser
- WHEN '自动审核' THEN ifa.audituser
- ELSE su2.name END
- AS auditUser,
- CASE ifa.audituser
- WHEN '自动审核' THEN '2'
- ELSE '1' END
- AS checkType,
- ifa.audittime as auditTime,
- ifa.auditstatus as auditStatus,
- eic.namesimple as partnerCompaniesName,
- iac.id as subOrderId,
- iac.signing_time as signingTime,
- iac.pay_date as payDate,
- pa.agreement_code as agreementCode,
- pa.agreement_name as agreementName,
- pa.business_description as businessDescription,
- pa.job_description as jobDescription,
- pa.agreement_title as agreementTitle,
- pa.docking_person as dockingPerson,
- io.entry_status
- FROM
- ins_fee_audit ifa
- LEFT JOIN ins_orders io ON io.orderno = ifa.orderno
- LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
- AND iac.orderstatus = 3
- LEFT JOIN sys_user su ON su.id = io.userid
- LEFT JOIN sys_dept sd ON sd.id = su.dept_id
- LEFT JOIN sys_user su2 ON ifa.audituser = su2.id
- LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
- LEFT JOIN esm_ins_company eic ON eic.id = pa.partner_companies_id
- WHERE
- iac.id = ifa.ins_order_no
- AND iac.orderstatus = 3
- <if test="params.auditStatus != null and params.auditStatus != ''">
- and ifa.auditstatus = #{params.auditStatus}
- </if>
- <if test="params.quoteStartDateStr != null and params.quoteStartDateStr != '' and params.quoteEndDateStr != null and params.quoteEndDateStr != ''">
- and DATE_FORMAT(iac.createtime, '%Y-%m-%d') between #{params.quoteStartDateStr} AND
- #{params.quoteEndDateStr}
- </if>
- <if test="params.orderNo != null and params.orderNo != ''">
- AND iac.id= #{params.orderNo}
- </if>
- <if test="params.licenseNo != null and params.licenseNo != ''">
- AND io.licenseno = #{params.licenseNo}
- </if>
- <if test="params.frameNo != null and params.frameNo != ''">
- AND io.frameno = #{params.frameNo}
- </if>
- <if test="params.insuredName != null and params.insuredName != ''">
- AND json_extract(io.insureinfo, '$.name') = #{params.insuredName}
- </if>
- <if test="params.companyId != null and params.companyId != ''">
- AND io.company_id = #{params.companyId}
- </if>
- <if test="params.engineNo != null and params.engineNo != ''">
- and JSON_EXTRACT( io.carinfo, '$.engineNo' ) = #{params.engineNo}
- </if>
- <if test="params.riskCode != null and params.riskCode != ''">
- and iac.product = #{params.riskCode}
- </if>
- <if test="params.attachStartDateStr != null and params.attachStartDateStr != '' and params.attachStartDateStr != null and params.attachStartDateStr != '' ">
- and ((
- DATE_FORMAT(iac.jq_start_date, '%Y-%m-%d') BETWEEN #{params.attachStartDateStr}
- AND #{params.attachEndDateStr}
- )
- OR ( DATE_FORMAT(iac.sy_start_date, '%Y-%m-%d') BETWEEN #{params.attachStartDateStr} AND
- #{params.attachEndDateStr} )
- )
- </if>
- <if test="params.provinceId != null and params.provinceId != ''">
- and io.deptid like "${params.provinceId}%"
- </if>
- <if test="params.problemOrder != null and params.problemOrder != ''">
- and iac.problem_order like "${params.problemOrder}%"
- </if>
- <if test="params.cityId != null and params.cityId != ''">
- and io.deptid like "${params.cityId}%"
- </if>
- <if test="params.countyId != null and params.countyId != ''">
- and io.deptid like "${params.countyId}%"
- </if>
- <if test="params.houseId != null and params.houseId != ''">
- and io.deptid like "${params.houseId}%"
- </if>
- <if test="params.operatorId != null and params.operatorId != ''">
- and io.userid = #{params.operatorId}
- </if>
- <if test="params.operatorName != null and params.operatorName != ''">
- and io.username = #{params.operatorName}
- </if>
- <if test="params.auditId != null and params.auditId != ''">
- and iac.new_operator_id = #{params.auditId}
- </if>
- <if test="params.agreeId != null and params.agreeId != ''">
- and iac.agreement_id = #{params.agreeId}
- </if>
- <if test="params.managementSource != null and params.managementSource != ''">
- and sd.management_source = #{params.managementSource}
- </if>
- <if test="params.signStartDateStr != null and params.signStartDateStr != '' and params.signEndDateStr != null and params.signEndDateStr != ''">
- and DATE_FORMAT(iac.signing_time, '%Y-%m-%d') between #{params.signStartDateStr} AND
- #{params.signEndDateStr}
- </if>
- <if test="params.payStartDateStr != null and params.payStartDateStr != '' and params.payEndDateStr != null and params.payEndDateStr != ''">
- and iac.pay_date between #{params.payStartDateStr} AND #{params.payEndDateStr}
- </if>
- <if test="params.isExternal != null and params.isExternal != ''">
- and io.is_external = #{params.isExternal}
- </if>
- <if test="params.jqPolicyNo != null and params.jqPolicyNo != ''">
- and iac.jqpolicyno = #{params.jqPolicyNo}
- </if>
- <if test="params.syPolicyNo != null and params.syPolicyNo != ''">
- and iac.sypolicyno = #{params.syPolicyNo}
- </if>
- <if test="params.noPolicyNo != null and params.noPolicyNo != ''">
- and iac.cross_insurance like concat('%', #{params.noPolicyNo}, '%')
- </if>
- <if test="params.checkUser != null and params.checkUser != ''">
- and CASE ifa.audituser WHEN '自动审核' THEN ifa.audituser
- ELSE su2.name END = #{params.checkUser}
- </if>
- <if test="params.checkType != null and params.checkType != ''">
- and CASE ifa.audituser
- WHEN '自动审核' THEN '2'
- ELSE '1' END = #{params.checkType}
- </if>
- order by iac.createtime desc
- </select>
- <select id="getByUserId" resultType="com.ydtech.modules.order.entity.InsOrders">
- SELECT
- io.*,
- sd.management_source
- FROM
- ins_orders io left join sys_user su on su.id = io.userid left join sys_dept sd on sd.id = su.dept_id
- WHERE
- orderno IN (
- SELECT
- orderno
- FROM
- ins_area_company
- WHERE
- id IN ( SELECT ins_order_no FROM ins_fee_order_new WHERE id NOT IN ( SELECT ins_order_no FROM ins_fee_audit ) )
- AND orderstatus = 3
- )
- AND
- io.orderstatus= 3
- <if test="orderNo != null and orderNo != ''">
- AND orderno = #{orderNo}
- </if>
- <if test="licenseNo != null and licenseNo != ''">
- AND licenseno = #{licenseNo}
- </if>
- <if test="frameNo != null and frameNo != ''">
- AND frameno = #{frameNo}
- </if>
- <if test="userId != null and userId != ''">
- AND userid = #{userId}
- </if>
- <if test="insuredname != null and insuredname != ''">
- AND insuredname = #{insuredname}
- </if>
- <if test="startDateStr != null and startDateStr != ''">
- AND createtime BETWEEN #{startDateStr} and #{endDateStr}
- </if>
- </select>
- <select id="selectFirstPromotionBy" resultType="com.ydtech.modules.order.entity.InsOrders">
- SELECT
- sum(a.first_detail_premiums) as "willFirstPremiums"
- FROM
- ins_fee_order_new a
- LEFT JOIN ins_area_company iac on iac.id=a.ins_order_no
- left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
- WHERE
- iff.auditstatus=0
- AND iac.orderstatus =3
- <if test="firstUserId != null and firstUserId != ''">
- AND a.first_level_user_id = #{firstUserId}
- </if>
- <if test="secondUserId != null and secondUserId != ''">
- AND a.two_level_user_id = #{secondUserId}
- </if>
- <if test="thirdUserId != null and thirdUserId != ''">
- AND a.three_level_user_id = #{thirdUserId}
- </if>
- <if test="id != null and id != ''">
- AND a.id = #{id}
- </if>
- </select>
- <select id="selectSecondPromotionBy" resultType="com.ydtech.modules.order.entity.InsOrders">
- SELECT
- sum( fee.p ) as "willFirstPremiums"
- FROM
- (
- SELECT
- sum( a.first_detail_premiums ) AS p
- FROM
- ins_fee_order_new a
- LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
- left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
- <where>
- iff.auditstatus=0
- and iac.orderstatus = '3'
- <if test="userId!=null and userId!= ''">
- AND a.first_level_user_id = #{userId}
- </if>
- <if test="id != null and id!=''">
- AND a.id =#{id}
- </if>
- </where>
- UNION
- SELECT
- sum( a.third_detail_premiums ) AS p
- FROM
- ins_fee_order_new a
- LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
- left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
- <where>
- iff.auditstatus=0
- and iac.orderstatus = '3'
- <if test="userId!=null and userId!= ''">
- AND a.three_level_user_id = #{userId}
- </if>
- <if test="id != null and id!=''">
- AND a.id =#{id}
- </if>
- </where>
- UNION
- SELECT
- sum( a.second_detail_premiums ) AS p
- FROM
- ins_fee_order_new a
- LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
- left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
- <where>
- iff.auditstatus=0
- and iac.orderstatus = '3'
- <if test="userId!=null and userId!= ''">
- AND a.two_level_user_id = #{userId}
- </if>
- <if test="id != null and id!=''">
- AND a.id =#{id}
- </if>
- </where>
- ) AS fee
- </select>
- <select id="selectThirdPromotionBy" resultType="com.ydtech.modules.order.entity.InsOrders">
- SELECT
- sum(a.third_detail_premiums) as "willThreePremiums"
- FROM
- ins_fee_order_new a
- LEFT JOIN ins_area_company iac on iac.id=a.ins_order_no
- left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
- WHERE
- iff.auditstatus=0
- AND iac.orderstatus =3
- <if test="firstUserId != null and firstUserId != ''">
- AND a.first_level_user_id = #{firstUserId}
- </if>
- <if test="secondUserId != null and secondUserId != ''">
- AND a.two_level_user_id = #{secondUserId}
- </if>
- <if test="thirdUserId != null and thirdUserId != ''">
- AND a.three_level_user_id = #{thirdUserId}
- </if>
- <if test="id != null and id != ''">
- AND a.id = #{id}
- </if>
- </select>
- <select id="getAlreadyAuditOrders" resultType="com.ydtech.modules.order.entity.InsOrders">
- SELECT
- io.*,
- sd.management_source,
- su2.name AS auditUser,
- ifa.audittime as auditTime
- FROM
- ins_orders io
- LEFT JOIN ins_fee_audit ifa ON ifa.orderno = io.orderno
- LEFT JOIN sys_user su ON su.id = io.userid
- LEFT JOIN sys_dept sd ON sd.id = su.dept_id
- LEFT JOIN sys_user su2 on ifa.audituser = su2.id
- WHERE
- io.orderno IN (
- SELECT
- orderno
- FROM
- ins_area_company
- WHERE
- id IN (
- SELECT
- ifon.ins_order_no
- FROM
- ins_fee_order_new ifon
- RIGHT JOIN ins_fee_audit ifa ON ifon.ins_order_no = ifa.ins_order_no
- WHERE
- ifa.auditstatus = #{params.auditStatus}
- )
- )
- AND orderstatus = 3
- <!-- <if test="params.orderNo != null and params.orderNo != ''">-->
- <!-- AND orderno = #{params.orderNo}-->
- <!-- </if>-->
- <if test="params.licenseNo != null and params.licenseNo != ''">
- AND licenseno = #{params.licenseNo}
- </if>
- <if test="params.frameNo != null and params.frameNo != ''">
- AND frameno = #{params.frameNo}
- </if>
- <if test="params.insuredName != null and params.insuredName != ''">
- AND insuredname = #{params.insuredName}
- </if>
- <if test="params.companyId != null and params.companyId != ''">
- AND company_id = #{params.companyId}
- </if>
- <if test="params.startDateStr != null and params.startDateStr != ''">
- AND createtime BETWEEN #{params.startDateStr} and #{params.endDateStr}
- </if>
- </select>
- <select id="selectListByDateStr" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
- -- 查询订单信息
- SELECT
- iac.*
- FROM
- ins_area_company iac
- left JOIN ins_orders AS io ON io.orderno = iac.orderno
- WHERE
- 1=1
- <if test="dateStr != null and dateStr != ''">
- AND DATE_FORMAT(io.createtime, '%Y-%m') =#{dateStr}
- </if>
- </select>
- <select id="selectListById" resultMap="BaseResultMap">
- SELECT
- iac.*
- FROM
- ins_area_company iac
- WHERE
- 1=1
- <if test="id != null and id != ''">
- AND iac.id =#{id}
- </if>
- </select>
- <select id="selectSecondPromotionByNew" resultType="com.ydtech.modules.order.entity.InsOrders">
- SELECT
- sum( fee.p ) as "willFirstPremiums"
- FROM
- (
- SELECT
- sum( a.first_detail_premiums ) AS p
- FROM
- ins_fee_order_new a
- LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
- left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
- <where>
- <choose>
- <when test='type == "1"'>
- iff.auditstatus=0
- </when>
- <otherwise>
- iff.auditstatus=1
- </otherwise>
- </choose>
- and iac.orderstatus = '3'
- <if test="userId!=null and userId!= ''">
- AND a.first_level_user_id = #{userId}
- </if>
- <if test="id != null and id!=''">
- AND a.id =#{id}
- </if>
- </where>
- UNION
- SELECT
- sum( a.third_detail_premiums ) AS p
- FROM
- ins_fee_order_new a
- LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
- left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
- <where>
- <choose>
- <when test='type == "1"'>
- iff.auditstatus=0
- </when>
- <otherwise>
- iff.auditstatus=1
- </otherwise>
- </choose>
- and iac.orderstatus = '3'
- <if test="userId!=null and userId!= ''">
- AND a.three_level_user_id = #{userId}
- </if>
- <if test="id != null and id!=''">
- AND a.id =#{id}
- </if>
- </where>
- UNION
- SELECT
- sum( a.second_detail_premiums ) AS p
- FROM
- ins_fee_order_new a
- LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
- left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
- <where>
- <choose>
- <when test='type == "1"'>
- iff.auditstatus=0
- </when>
- <otherwise>
- iff.auditstatus=1
- </otherwise>
- </choose>
- and iac.orderstatus = '3'
- <if test="userId!=null and userId!= ''">
- AND a.two_level_user_id = #{userId}
- </if>
- <if test="id != null and id!=''">
- AND a.id =#{id}
- </if>
- </where>
- ) AS fee
- </select>
- <select id="getSubOrderDetails" resultType="com.ydtech.modules.admin.model.vo.SubOrder">
- SELECT
- iac.id as subOrderId,
- iac.signing_time as signingTime,
- iac.jqpremium as jqpremium,
- iac.sypremium as sypremium,
- iac.jypremium as jypremium,
- io.licenseno as licenseno,
- io.userid as userId
- FROM
- ins_area_company iac
- LEFT JOIN ins_orders AS io ON io.orderno = iac.orderno
- WHERE
- iac.id=#{subOrderId}
- </select>
- <select id="premiumReportYear" resultType="com.ydtech.modules.admin.model.dto.PremiumReportDto">
- SELECT
- CONCAT(YEAR(iac.createtime),'-',LPAD(MONTH(iac.createtime), 2, '0')) reportDate,
- sum(jqpremium) jqpremium,
- sum(sypremium) sypremium,
- sum(sumpremium) sumpremium
- FROM
- ins_area_company iac left join ins_orders io on iac.orderno=io.orderno
- WHERE
- iac.orderstatus = 3 and
- iac.createtime >= #{beginTime} and iac.createtime <= #{endTime}
- and io.userid=#{userId}
- GROUP BY CONCAT(YEAR(iac.createtime),'-',LPAD(MONTH(iac.createtime), 2, '0'))
- </select>
- <select id="premiumReportMonth" resultType="com.ydtech.modules.admin.model.dto.PremiumReportDto">
- SELECT
- CONCAT(YEAR(iac.createtime),'-',LPAD(MONTH(iac.createtime), 2, '0'),'-',LPAD(Day(iac.createtime), 2, '0')) reportDate,
- sum(jqpremium) jqpremium,
- sum(sypremium) sypremium,
- sum(sumpremium) sumpremium
- FROM
- ins_area_company iac left join ins_orders io on iac.orderno=io.orderno
- WHERE
- iac.orderstatus = 3 and
- iac.createtime >= #{beginTime} and iac.createtime <= #{endTime}
- and io.userid=#{userId}
- GROUP BY CONCAT(YEAR(iac.createtime),'-',LPAD(MONTH(iac.createtime), 2, '0'),'-',LPAD(Day(iac.createtime), 2, '0'))
- </select>
- <select id="premiumReportDay" resultType="com.ydtech.modules.admin.model.dto.PremiumReportDto">
- SELECT
- CONCAT(YEAR ( iac.createtime ),'-',LPAD( MONTH ( iac.createtime ), 2, '0' ),'-',LPAD( DAY ( iac.createtime ), 2, '0' ),' ',LPAD( HOUR ( iac.createtime ), 2, '0' ))
- reportDate,
- sum( jqpremium ) jqpremium,
- sum( sypremium ) sypremium,
- sum( sumpremium ) sumpremium
- FROM
- ins_area_company iac left join ins_orders io on iac.orderno=io.orderno
- WHERE
- iac.orderstatus = 3 and
- iac.createtime >= #{beginTime} and iac.createtime <= #{endTime}
- and io.userid=#{userId}
- GROUP BY CONCAT(YEAR ( iac.createtime ),'-',LPAD( MONTH ( iac.createtime ), 2, '0' ),'-',LPAD( DAY ( iac.createtime ), 2, '0' ),' ',LPAD( HOUR ( iac.createtime ), 2, '0' ))
- </select>
- <select id="getAllpremium" resultType="com.ydtech.modules.admin.model.dto.AllpremiumDto">
- SELECT
- ifnull(sum( iac.jqpremium + iac.sypremium + iac.jypremium ),0) as sumPremium,
- count( 0 ) as sumCount
- FROM
- ins_area_company iac left join ins_orders io on iac.orderno=io.orderno
- WHERE
- iac.orderstatus = 3
- and io.userid=#{userId}
- AND YEAR (iac.createtime) = #{year}
- </select>
- <select id="getRejectOrder" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
- select
- iac.id,
- iac.orderno,
- iac.agreement_id,
- iac.jqpremium,
- iac.sypremium,
- iac.jypremium,
- iac.taxamount,
- iac.sumpremium,
- io.licenseno,
- ifa.audittime,
- ifa.audituser as auditname,
- ifa.rejectinfo,
- "1" as orderExternalStatus
- FROM
- ins_fee_audit ifa
- LEFT JOIN
- ins_area_company iac on iac.id = ifa.ins_order_no
- LEFT JOIN
- ins_orders io on iac.orderno = io.orderno
- left join
- sys_user su on su.id= ifa.audituser
- WHERE
- iac.operator_id = #{userId}
- AND
- ifa.auditstatus = 2 and IFNULL(iac.del_flag,'') != '0'
- <if test="vo.id != null and vo.id!=''">
- and iac.id = #{vo.id}
- </if>
- <if test="vo.licenseno != null and vo.licenseno!='' ">
- and io.licenseno like CONCAT('%', #{vo.licenseno}, '%')
- </if>
- <if test="vo.auditname != null and vo.auditname!='' ">
- and su.name like CONCAT('%', #{vo.auditname}, '%')
- </if>
- </select>
- <select id="queryBusinessDataPage"
- resultType="com.ydtech.modules.admin.model.report.opetationData.BusinessDataDto">
- SELECT
- <if test="flag != null and flag!='' and flag='1'">
- o.userid as userId,
- o.username as userName,
- </if>
- sum( iac.sumpremium ) as signeSumPremiumAmount,
- sum( iac.jqpremium ) as jqPremiumAmount,
- sum( iac.sypremium ) as syPremiumAmount,
- sum( iac.taxamount ) as taxAmount,
- sum( ion.no_premium ) as fcFeeAmount
- FROM
- ins_area_company iac
- LEFT JOIN ins_orders o ON iac.orderno = o.orderno
- LEFT JOIN ins_fee_order_new ion ON iac.id = ion.ins_order_no
- where iac.orderstatus = 3 and ion.id is not null
- <if test="userList != null and userList.size()>0 ">
- and o.userid IN
- <foreach item="item" collection="userList" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="flag != null and flag!='' and flag='1'">
- group by o.userid,o.username
- </if>
- </select>
- <select id="queryQuotationSubOrderCountDataPage"
- resultType="com.ydtech.modules.admin.model.report.opetationData.QuotationCountDataDto">
- SELECT
- <if test="flag != null and flag!='' and flag='1'">
- o.userid as userId,
- o.username as userName,
- </if>
- iac.orderstatus as orderStatus
- FROM
- ins_area_company iac
- LEFT JOIN ins_orders o ON iac.orderno = o.orderno
- where (iac.orderstatus = 0 or iac.orderstatus = 2 or iac.orderstatus = 3 )
- <if test="userList != null and userList.size()>0 ">
- and o.userid IN
- <foreach item="item" collection="userList" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="flag != null and flag!='' and flag='1'">
- group by o.userid,o.username,iac.orderstatus
- </if>
- </select>
- <select id="queryQuotationOrderCountDataPage"
- resultType="com.ydtech.modules.admin.model.report.opetationData.QuotationCountDataDto">
- SELECT
- a.userId as userId,
- a.userName as userName,
- b.qutationCount AS insOrderQutationCount,
- b.qutationInsureCount as insOrderQutationInsureCount,
- b.closeRate AS insOrderCloseRate as insOrderCloseRate,
- a.qutationCount as subOrderQutationCount,
- a.underwritingCount as subOrderUnderwritingCount,
- a.qutationInsureCount as subOrderQutationInsureCount,
- a.passRate as subOrderCloseRate,
- a.closeRate as subOrderPassRate,
- a.contributionRate as subOrderContributionRate
- FROM
- (
- SELECT
- inso.userid AS userId,
- inso.username AS userName,
- COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS qutationCount,
- COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
- COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
- COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END )/ count( iac.orderstatus ) AS passRate,
- COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )/ count( iac.orderstatus ) AS closeRate,
- COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )/ COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS contributionRate
- FROM
- ins_area_company iac
- LEFT JOIN ins_orders inso ON iac.orderno = inso.orderno
- <where>
- <if test="userList != null and userList.size()>0 ">
- and o.userid IN
- <foreach item="item" collection="userList" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- </where>
- GROUP BY
- inso.userid,
- inso.username
- ) a
- LEFT JOIN (
- SELECT
- inso.userid AS userId,
- inso.username AS userName,
- count( inso.orderstatus ) AS qutationCount,
- count( CASE WHEN inso.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
- COUNT( CASE WHEN inso.orderstatus = 3 THEN 1 END )/ count( inso.orderstatus ) AS closeRate
- FROM
- ins_orders inso
- <where>
- <if test="userList != null and userList.size()>0 ">
- and o.userid IN
- <foreach item="item" collection="userList" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- </where>
- GROUP BY
- inso.userid,
- inso.username
- ) b ON a.userId = b.userId
- </select>
- <select id="queryCompanyPremiumDataPage"
- resultType="com.ydtech.modules.admin.model.report.company.CompanyPremiumDataDto">
- SELECT
- agree.insurance_company_id AS companyId,
- agree.insurance_company AS companyName,
- agree.partner_companies_id AS parterCompanyId,
- ins.NAME AS parterCompanyName,
- sum( iac.sumpremium ) AS signeSumPremiumAmount
- FROM
- ins_area_company iac
- LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
- LEFT JOIN esm_ins_company ins ON agree.partner_companies_id = ins.id
- WHERE
- iac.orderstatus = 3
- and
- agree.id is not null
- <if test="vo.companyId != null and vo.companyId!='' ">
- agree.insurance_company_id = #{vo.companyId}
- </if>
- <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
- agree.insurance_company_id = #{vo.parterCompanyId}
- </if>
- GROUP BY
- agree.insurance_company_id,
- agree.insurance_company,
- agree.partner_companies_id,
- ins.NAME
- </select>
- <select id="queryCompanyQutationCountDataPage"
- resultType="com.ydtech.modules.admin.model.report.company.CompanyQutationCountDataDto">
- SELECT
- a.* ,
- (select ins.namesimple from esm_ins_company
- ins where a.parterCompanyId = ins.id) as "parterCompanyName"
- FROM
- (
- SELECT
- agree.insurance_company AS companyName,
- agree.partner_companies_id AS parterCompanyId,
- iac.company_id as "companyId",
- count( iac.orderstatus ) AS qutationCount,
- count( iac.id ) AS allNumber,
- count( CASE WHEN iac.orderstatus != '10' THEN 1 END ) AS orderSuccessNumber,
- count( CASE WHEN iac.orderstatus != '10' THEN 1 END ) / count( iac.id ) as "orderSuccessNumberRate",
- count( CASE WHEN iac.orderstatus = '10' THEN 1 END ) AS areaCompanyErrNumber,
- COUNT( CASE WHEN iac.orderstatus = '2' THEN 1 END ) + COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS underwritingCount,
- COUNT( CASE WHEN iac.orderstatus = '3' THEN 1 END ) AS qutationInsureCount,
- (COUNT( CASE WHEN iac.orderstatus = '2' THEN 1 END ) + COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )) / count( iac.orderstatus ) AS passRate,
- 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,
- COUNT( CASE WHEN iac.orderstatus = '3' THEN 1 END ) / count( iac.orderstatus ) AS contributionRate,
- COUNT(CASE WHEN agree.audit_type ='1' and ifa.auditstatus =1 and iac.orderstatus =3 THEN 1 END) as "numberManual"
- FROM
- ins_area_company iac
- LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
- LEFT JOIN ins_orders io ON iac.orderno = io.orderno
- LEFT JOIN sys_dept sd ON sd.id = io.deptid
- LEFT JOIN ins_fee_audit ifa on ifa.ins_order_no =iac.id
- WHERE
- agree.id IS NOT NULL
- <if test="vo.companyId != null and vo.companyId!='' ">
- AND agree.insurance_company_id = #{vo.companyId}
- </if>
- <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
- AND agree.partner_companies_id = #{vo.parterCompanyId}
- </if>
- <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
- AND iac.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
- </if>
- <if test="vo.managementSource != null and vo.managementSource!=''">
- AND sd.management_source =#{vo.managementSource}
- </if>
- <if test="vo.userId != null and vo.userId !=''">
- AND io.userid =#{vo.userId}
- </if>
- <if test="vo.deptId != null and vo.deptId !=''">
- AND io.deptId like concat('%',#{vo.deptId},'%')
- </if>
- <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
- AND sd.id in
- <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
- AND io.userid in
- <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- GROUP BY
- agree.insurance_company,
- iac.company_id,
- agree.partner_companies_id
- ) a
- order by a.parterCompanyId
- </select>
- <select id="getInsAreaCompanyError"
- resultType="com.ydtech.modules.admin.model.report.company.CompanyQutationCountDataDto">
- SELECT
- count(iace.id) as "areaCompanyErrNumber"
- FROM
- ins_area_company_error iace
- LEFT JOIN ptl_agreement agree ON iace.agreement_id = agree.id
- <where>
- 1=1
- <if test="vo.companyId != null and vo.companyId!='' ">
- AND agree.insurance_company_id = #{vo.companyId}
- </if>
- <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
- AND agree.partner_companies_id = #{vo.parterCompanyId}
- </if>
- <if test="vo.userId != null and vo.userId!=''">
- AND iace.user_id =#{vo.userId}
- </if>
- <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
- AND iace.create_time BETWEEN #{vo.beginDate} AND #{vo.endDate}
- </if>
- <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
- AND iace.dept_id in
- <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="vo.deptId != null and vo.deptId !=''">
- AND iace.dept_id like concat('%',#{vo.deptId},'%')
- </if>
- <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
- AND iace.user_id in
- <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- </where>
- </select>
- <select id="queryCompanyQutationCountDataPageTotal"
- resultType="java.lang.Long">
- SELECT
- count(0)
- FROM
- (
- SELECT
- agree.partner_companies_id
- FROM
- ins_area_company iac
- LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
- LEFT JOIN ins_orders io ON iac.orderno = io.orderno
- LEFT JOIN sys_dept sd ON sd.id = io.deptid
- WHERE
- agree.id IS NOT NULL
- <if test="vo.companyId != null and vo.companyId!='' ">
- AND agree.insurance_company_id = #{vo.companyId}
- </if>
- <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
- AND agree.partner_companies_id = #{vo.parterCompanyId}
- </if>
- <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
- AND iac.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
- </if>
- <if test="vo.managementSource != null and vo.managementSource!=''">
- AND sd.management_source =#{vo.managementSource}
- </if>
- <if test="vo.userId != null and vo.userId !=''">
- AND io.userid =#{vo.userId}
- </if>
- <if test="vo.deptId != null and vo.deptId !=''">
- AND io.deptId like concat('%',#{vo.deptId},'%')
- </if>
- <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
- AND sd.id in
- <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
- AND io.userid in
- <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- GROUP BY
- agree.partner_companies_id
- ) a
- </select>
- <select id="getStageOrder" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
- select
- iac.id,
- iac.orderno,
- iac.agreement_id,
- iac.jqpremium,
- iac.sypremium,
- iac.jypremium,
- iac.taxamount,
- iac.sumpremium,
- io.licenseno,
- iac.createtime,
- "0" as orderExternalStatus
- FROM
- ins_area_company iac
- LEFT JOIN
- ins_orders io on iac.orderno = io.orderno
- left join ptl_agreement agree on iac.agreement_id =agree.id
- WHERE
- iac.operator_id = #{userId}
- AND
- iac.orderstatus = 0
- and agree.is_external =1
- <if test="vo.id != null and vo.id!='' ">
- and iac.id = #{vo.id}
- </if>
- <if test="vo.licenseno != null and vo.licenseno!='' ">
- and io.licenseno like CONCAT('%', #{vo.licenseno}, '%')
- </if>
- </select>
- <select id="queryPageTaskStatistics" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
- select a.*, su.name as "userName",
- inf.url as "logo",
- sui.sex as "sex",
- su.leader_name as "leaderName",
- su2.mobile as "leaderMobile"
- from (
- SELECT
- sd.NAME AS "deptName",
- io.userid AS "userId",
- sd.parent_id as "deptId",
- sd.management_source as "managementSource",
- COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS qutationCount,
- COUNT( CASE WHEN iot.order_status ='2' THEN 1 END ) AS underwritingCount,
- COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) AS qutationInsureCount,
- COUNT( CASE WHEN iot.order_status = '4' THEN 1 END ) AS underwritingReturn,
- COUNT( CASE WHEN iot.order_status ='2' THEN 1 END ) / COUNT( CASE WHEN iot.order_status ='0' THEN 1 END ) AS "passingRate",
- 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",
- (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",
- 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",
- COUNT(CASE WHEN io.order_source = 0 and iot.order_status ='0' THEN 1 END) as "pcOrderSource",
- COUNT(CASE WHEN io.order_source = 1 and iot.order_status ='0' THEN 1 END) as "appOrderSource",
- COUNT(CASE WHEN iac.entry_status = '2' THEN 1 END) as "sumEntryStatus",
- COUNT( CASE WHEN iot.order_status = '1' THEN 1 END ) AS "auditOrder"
- FROM
- (
- select iot.suborder,iot.order_status from `ins_orders_track` iot
- GROUP BY iot.suborder ,iot.order_status
- ) iot
- left join ins_area_company iac ON iac.id = iot.suborder
- LEFT JOIN ins_orders io ON io.orderno = iac.orderno
- LEFT JOIN sys_dept sd ON sd.id = io.deptid
- <where>
- sd.management_source = '1'
- <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
- and io.deptid like "${taskStatisticsVo.provinceId}%"
- </if>
- <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
- and io.deptid like "${taskStatisticsVo.cityId}%"
- </if>
- <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
- and io.deptid like "${taskStatisticsVo.countyId}%"
- </if>
- <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
- and io.deptid like "${taskStatisticsVo.houseId}%"
- </if>
- <if test="taskStatisticsVo.userId != null and taskStatisticsVo.userId != ''">
- and io.userid =#{taskStatisticsVo.userId}
- </if>
- <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
- AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
- </if>
- <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
- 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')
- </if>
- <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
- AND sd.id in
- <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
- AND io.userid in
- <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- </where>
- GROUP BY
- io.userid,
- sd.NAME,
- sd.id,
- sd.management_source
- ) a
- left join sys_user su on su.id =a.userId
- LEFT JOIN ins_upload_files inf on su.head_sculpture =inf.id
- LEFT JOIN sys_user_info sui on sui .id =su.id
- LEFT JOIN sys_user su2 on su2.id =su.leader_id
- <where>
- <if test='taskStatisticsVo.userName !=null and taskStatisticsVo.userName!="" '>
- and su.name like concat('%',#{taskStatisticsVo.userName},'%')
- </if>
- <!-- <if test='taskStatisticsVo.leaderId !=null and taskStatisticsVo.leaderId!="" '>-->
- <!-- and su.leader_id =#{taskStatisticsVo.leaderId}-->
- <!-- </if>-->
- <if test="taskStatisticsVo.leaderIds != null and taskStatisticsVo.leaderIds != '' and taskStatisticsVo.leaderIds.size() > 0">
- AND su.leader_id in
- <foreach collection="taskStatisticsVo.leaderIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test='taskStatisticsVo.userId !=null and taskStatisticsVo.userId!="" '>
- and su.id =#{taskStatisticsVo.userId}
- </if>
- </where>
- </select>
- <select id="queryPageElectric" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
- select a.*, su.name as "userName",
- inf.url as "logo",
- sui.sex as "sex",
- su.leader_name as "leaderName",
- su2.mobile as "leaderMobile"
- from (
- SELECT
- sd.NAME AS "deptName",
- io.userid AS "userId",
- sd.parent_id as "deptId",
- sd.management_source as "managementSource",
- COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS qutationCount,
- COUNT( CASE WHEN iot.order_status ='2' THEN 1 END ) AS underwritingCount,
- COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) AS qutationInsureCount,
- COUNT( CASE WHEN iot.order_status = '4' THEN 1 END ) AS underwritingReturn,
- COUNT( CASE WHEN iot.order_status = '2' THEN 1 END ) / COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS "passingRate",
- 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",
- (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",
- 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",
- COUNT(CASE WHEN io.order_source = 0 and iot.order_status = '0' THEN 1 END) as "pcOrderSource",
- COUNT(CASE WHEN io.order_source = 1 and iot.order_status = '0' THEN 1 END) as "appOrderSource",
- COUNT( CASE WHEN iot.order_status ='1' THEN 1 END ) AS "auditOrder"
- FROM
- (
- select iot.suborder,iot.order_status from `ins_orders_track` iot
- GROUP BY iot.suborder ,iot.order_status
- ) iot
- left join ins_area_company iac ON iac.id = iot.suborder
- LEFT JOIN ins_orders io ON io.orderno = iac.orderno
- LEFT JOIN sys_dept sd ON sd.id = io.deptid
- <where>
- sd.management_source = '3'
- <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
- and io.deptid like "${taskStatisticsVo.provinceId}%"
- </if>
- <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
- and io.deptid like "${taskStatisticsVo.cityId}%"
- </if>
- <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
- and io.deptid like "${taskStatisticsVo.countyId}%"
- </if>
- <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
- and io.deptid like "${taskStatisticsVo.houseId}%"
- </if>
- <if test="taskStatisticsVo.userId != null and taskStatisticsVo.userId != ''">
- and io.userid =#{taskStatisticsVo.userId}
- </if>
- <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
- AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
- </if>
- <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
- 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')
- </if>
- <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
- and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
- </if>
- <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
- AND sd.id in
- <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
- AND io.userid in
- <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
- <choose>
- <when test="taskStatisticsVo.days =='1'">
- and io.createtime >= DATE_SUB(NOW(), INTERVAL 1 DAY)
- </when>
- <when test="taskStatisticsVo.days =='7'">
- and io.createtime >= DATE_SUB(NOW(), INTERVAL 7 DAY)
- </when>
- <when test="taskStatisticsVo.days =='30'">
- and io.createtime >= DATE_SUB(NOW(), INTERVAL 30 DAY)
- </when>
- </choose>
- </if>
- </where>
- GROUP BY
- io.userid,
- sd.NAME,
- sd.id,
- sd.management_source
- ) a
- left join sys_user su on su.id =a.userId
- LEFT JOIN ins_upload_files inf on su.head_sculpture =inf.id
- LEFT JOIN sys_user_info sui on sui .id =su.id
- LEFT JOIN sys_user su2 on su2.id =su.leader_id
- <where>
- <if test='taskStatisticsVo.userName !=null and taskStatisticsVo.userName!="" '>
- and su.name like concat('%',#{taskStatisticsVo.userName},'%')
- </if>
- <!-- <if test='taskStatisticsVo.leaderId !=null and taskStatisticsVo.leaderId!="" '>-->
- <!-- and su.leader_id =#{taskStatisticsVo.leaderId}-->
- <!-- </if>-->
- <if test="taskStatisticsVo.leaderIds != null and taskStatisticsVo.leaderIds != '' and taskStatisticsVo.leaderIds.size() > 0">
- AND su.leader_id in
- <foreach collection="taskStatisticsVo.leaderIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test='taskStatisticsVo.userId !=null and taskStatisticsVo.userId!="" '>
- and su.id =#{taskStatisticsVo.userId}
- </if>
- </where>
- </select>
- <select id="queryPageElectricTotal" resultType="java.lang.Long">
- select count(0) from (
- SELECT
- io.userid
- FROM
- ins_area_company iac
- LEFT JOIN ins_orders io ON io.orderno = iac.orderno
- LEFT JOIN sys_dept sd ON sd.id = io.deptid
- <where>
- sd.management_source = '3'
- <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
- and io.deptid like "${taskStatisticsVo.provinceId}%"
- </if>
- <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
- and io.deptid like "${taskStatisticsVo.cityId}%"
- </if>
- <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
- and io.deptid like "${taskStatisticsVo.countyId}%"
- </if>
- <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
- and io.deptid like "${taskStatisticsVo.houseId}%"
- </if>
- <if test="taskStatisticsVo.leaderIds != null and taskStatisticsVo.leaderIds != '' and taskStatisticsVo.leaderIds.size() > 0">
- AND su.leader_id in
- <foreach collection="taskStatisticsVo.leaderIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
- AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
- </if>
- <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
- 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')
- </if>
- <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
- and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
- </if>
- <if test="taskStatisticsVo.userId != null and taskStatisticsVo.userId != ''">
- and io.userid =#{taskStatisticsVo.userId}
- </if>
- <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
- AND sd.id in
- <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
- AND io.userid in
- <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
- <choose>
- <when test="taskStatisticsVo.days =='1'">
- and io.createtime >= DATE_SUB(NOW(), INTERVAL 1 DAY)
- </when>
- <when test="taskStatisticsVo.days =='7'">
- and io.createtime >= DATE_SUB(NOW(), INTERVAL 7 DAY)
- </when>
- <when test="taskStatisticsVo.days =='30'">
- and io.createtime >= DATE_SUB(NOW(), INTERVAL 30 DAY)
- </when>
- </choose>
- </if>
- </where>
- GROUP BY
- io.userid
- ) a
- </select>
- <select id="queryPageTaskStatisticsTotal" resultType="java.lang.Long">
- select count(0) from (
- SELECT
- io.userid
- FROM
- ins_area_company iac
- LEFT JOIN ins_orders io ON io.orderno = iac.orderno
- LEFT JOIN sys_dept sd ON sd.id = io.deptid
- left join sys_user su on su.id = io.userid
- <where>
- sd.management_source = '1'
- <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
- and io.deptid like "${taskStatisticsVo.provinceId}%"
- </if>
- <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
- and io.deptid like "${taskStatisticsVo.cityId}%"
- </if>
- <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
- and io.deptid like "${taskStatisticsVo.countyId}%"
- </if>
- <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
- and io.deptid like "${taskStatisticsVo.houseId}%"
- </if>
- <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
- AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
- </if>
- <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
- 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')
- </if>
- <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
- and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
- </if>
- <if test="taskStatisticsVo.userId != null and taskStatisticsVo.userId != ''">
- and io.userid =#{taskStatisticsVo.userId}
- </if>
- <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
- AND sd.id in
- <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="taskStatisticsVo.leaderIds != null and taskStatisticsVo.leaderIds != '' and taskStatisticsVo.leaderIds.size() > 0">
- AND su.leader_id in
- <foreach collection="taskStatisticsVo.leaderIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
- AND io.userid in
- <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
- <choose>
- <when test="taskStatisticsVo.days =='1'">
- and io.createtime >= DATE_SUB(NOW(), INTERVAL 1 DAY)
- </when>
- <when test="taskStatisticsVo.days =='7'">
- and io.createtime >= DATE_SUB(NOW(), INTERVAL 7 DAY)
- </when>
- <when test="taskStatisticsVo.days =='30'">
- and io.createtime >= DATE_SUB(NOW(), INTERVAL 30 DAY)
- </when>
- </choose>
- </if>
- </where>
- GROUP BY
- io.userid
- ) a
- </select>
- <select id="insuranceCompanyQueryPage" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
- select
- a.*,
- ( SELECT eic.namesimple FROM esm_ins_company eic WHERE eic.id = a.partner_companies_id ) AS "partnerCompaniesName"
- FROM
- (
- SELECT
- pa.insurance_company_id,
- pa.partner_companies_id,
- pa.insurance_company AS "insuranceCompanyName",
- COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS qutationCount,
- COUNT( CASE WHEN iot.order_status = '1' THEN 1 END ) AS "auditOrder",
- COUNT( CASE WHEN iot.order_status = '2' THEN 1 END ) AS underwritingCount,
- COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) AS qutationInsureCount,
- COUNT( CASE WHEN iot.order_status = '4' THEN 1 END ) AS underwritingReturn,
- COUNT( CASE WHEN iot.order_status ='2' THEN 1 END ) / COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS "passingRate",
- COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) / COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS "closeRate",
- (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",
- COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) / COUNT( iot.order_status ) AS "quotationRate"
- FROM
- (
- select iot.suborder,iot.order_status from `ins_orders_track` iot
- GROUP BY iot.suborder ,iot.order_status
- ) iot
- LEFT JOIN ins_area_company iac ON iac.id = iot.suborder
- LEFT JOIN ins_fee_audit ifa ON ifa.ins_order_no = iac.id
- LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
- LEFT JOIN ins_orders io ON io.orderno = iac.orderno
- <where>
- pa.insurance_company_id IS NOT NULL
- <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
- and io.deptid like concat('%', #{taskStatisticsVo.provinceId}, '%')
- </if>
- <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
- and io.deptid like concat('%', #{taskStatisticsVo.cityId}, '%')
- </if>
- <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
- and io.deptid like concat('%', #{taskStatisticsVo.countyId}, '%')
- </if>
- <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
- and io.deptid like concat('%', #{taskStatisticsVo.houseId}, '%')
- </if>
- <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
- AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT(#{taskStatisticsVo.createtimeStart},'%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.createtimeEnd}, '%Y-%m-%d')
- </if>
- <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
- AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
- </if>
- <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId != ''">
- AND iac.company_id =#{taskStatisticsVo.companyId}
- </if>
- <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
- AND io.deptid in
- <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
- AND io.userid in
- <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- </where>
- GROUP BY
- pa.insurance_company_id,
- pa.partner_companies_id,
- pa.insurance_company
- ) a
- </select>
- <select id="insuranceCompanyQueryTotal" resultType="java.lang.Long">
- SELECT
- COUNT(0)
- FROM
- (
- SELECT
- pa.insurance_company_id,
- pa.partner_companies_id
- FROM
- ins_area_company iac
- LEFT JOIN ins_fee_audit ifa ON ifa.ins_order_no = iac.id
- LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
- LEFT JOIN ins_orders io ON io.orderno = iac.orderno
- <where>
- pa.insurance_company_id IS NOT NULL
- <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
- and io.deptid like concat('%', #{taskStatisticsVo.provinceId}, '%')
- </if>
- <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
- and io.deptid like concat('%', #{taskStatisticsVo.cityId}, '%')
- </if>
- <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
- and io.deptid like concat('%', #{taskStatisticsVo.countyId}, '%')
- </if>
- <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId != ''">
- AND iac.company_id =#{taskStatisticsVo.companyId}
- </if>
- <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
- and io.deptid like concat('%', #{taskStatisticsVo.houseId}, '%')
- </if>
- <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
- AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT(#{taskStatisticsVo.createtimeStart},'%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.createtimeEnd}, '%Y-%m-%d')
- </if>
- <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
- AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
- </if>
- <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
- AND io.deptid in
- <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
- AND io.userid in
- <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- </where>
- GROUP BY
- pa.insurance_company_id,
- pa.partner_companies_id
- ) total
- </select>
- <select id="agentStatisticsQueryPage" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
- SELECT
- sd.name as "deptName",
- su.name as "userName",
- io.userid as "userId",
- sd.id as "deptId",
- suLeader.name as "leaderName",
- suLeader.mobile as "leaderMobile",
- sd.management_source as "managementSource",
- COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS qutationCount,
- COUNT( CASE WHEN iot.order_status = '2' THEN 1 END ) AS underwritingCount,
- COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) AS qutationInsureCount,
- COUNT( CASE WHEN iot.order_status = '4' THEN 1 END ) AS underwritingReturn,
- 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",
- COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) / COUNT( CASE WHEN iot.order_status ='0' THEN 1 END ) as "closeRate",
- 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",
- 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",
- COUNT( CASE WHEN iot.order_status = '1' THEN 1 END ) as "auditOrder"
- FROM
- (
- select iot.suborder,iot.order_status from `ins_orders_track` iot
- GROUP BY iot.suborder ,iot.order_status
- ) iot
- LEFT JOIN ins_area_company iac ON iac.id = iot.suborder
- left join ins_orders io on io.orderno = iac.orderno
- left join sys_dept sd on sd.id=io.deptid
- left join sys_user su on su.id=io.userid
- left join sys_user suLeader on suLeader.id =su.leader_id
- <where>
- sd.management_source = '2'
- <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
- and io.deptid like "${taskStatisticsVo.provinceId}%"
- </if>
- <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
- and io.deptid like "${taskStatisticsVo.cityId}%"
- </if>
- <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
- and io.deptid like "${taskStatisticsVo.countyId}%"
- </if>
- <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
- and io.deptid like "${taskStatisticsVo.houseId}%"
- </if>
- <if test="taskStatisticsVo.userId !=null and taskStatisticsVo.userId!='' ">
- and io.userid =#{taskStatisticsVo.userId}
- </if>
- <if test='taskStatisticsVo.userName !=null and taskStatisticsVo.userName!="" '>
- and su.name like concat('%',#{taskStatisticsVo.userName},'%')
- </if>
- <if test='taskStatisticsVo.leaderId !=null and taskStatisticsVo.leaderId!="" '>
- and su.leader_id =#{taskStatisticsVo.leaderId}
- </if>
- <!-- -->
- <!-- <if test='taskStatisticsVo.userId !=null and taskStatisticsVo.userId!="" '>-->
- <!-- and su.id =#{taskStatisticsVo.userId}-->
- <!-- </if>-->
- <if test="taskStatisticsVo.leaderIds != null and taskStatisticsVo.leaderIds != '' and taskStatisticsVo.leaderIds.size() > 0">
- AND su.leader_id in
- <foreach collection="taskStatisticsVo.leaderIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
- AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
- </if>
- <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
- 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')
- </if>
- <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
- and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
- </if>
- <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
- AND sd.id in
- <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
- AND io.userid in
- <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
- <choose>
- <when test="taskStatisticsVo.days =='1'">
- and io.createtime >= DATE_SUB(NOW(), INTERVAL 1 DAY)
- </when>
- <when test="taskStatisticsVo.days =='7'">
- and io.createtime >= DATE_SUB(NOW(), INTERVAL 7 DAY)
- </when>
- <when test="taskStatisticsVo.days =='30'">
- and io.createtime >= DATE_SUB(NOW(), INTERVAL 30 DAY)
- </when>
- </choose>
- </if>
- </where>
- GROUP BY io.userid , su.name, sd.id , sd.name,suLeader.name,suLeader.mobile,sd.management_source
- </select>
- <select id="agentStatisticsQueryPageTotal" resultType="java.lang.Long">
- select count(0) from (
- SELECT
- io.userid as "userId"
- FROM
- ins_area_company iac
- left join ins_orders io on io.orderno = iac.orderno
- left join sys_dept sd on sd.id=io.deptid
- left join sys_user su on su.id=io.userid
- <where>
- sd.management_source = '2'
- <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
- and io.deptid like "${taskStatisticsVo.provinceId}%"
- </if>
- <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
- and io.deptid like "${taskStatisticsVo.cityId}%"
- </if>
- <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
- and io.deptid like "${taskStatisticsVo.countyId}%"
- </if>
- <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
- and io.deptid like "${taskStatisticsVo.houseId}%"
- </if>
- <if test='taskStatisticsVo.userName !=null and taskStatisticsVo.userName!="" '>
- and su.name like concat('%',#{taskStatisticsVo.userName},'%')
- </if>
- <!-- <if test='taskStatisticsVo.leaderId !=null and taskStatisticsVo.leaderId!="" '>-->
- <!-- and su.leader_id =#{taskStatisticsVo.leaderId}-->
- <!-- </if>-->
- <if test="taskStatisticsVo.leaderIds != null and taskStatisticsVo.leaderIds != '' and taskStatisticsVo.leaderIds.size() > 0">
- AND su.leader_id in
- <foreach collection="taskStatisticsVo.leaderIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test='taskStatisticsVo.userId !=null and taskStatisticsVo.userId!="" '>
- and su.id =#{taskStatisticsVo.userId}
- </if>
- <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
- AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
- </if>
- <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
- 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')
- </if>
- <if test="taskStatisticsVo.userId !=null and taskStatisticsVo.userId!='' ">
- and io.userid =#{taskStatisticsVo.userId}
- </if>
- <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
- and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
- </if>
- <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
- <choose>
- <when test="taskStatisticsVo.days =='1'">
- and io.createtime >= DATE_SUB(NOW(), INTERVAL 1 DAY)
- </when>
- <when test="taskStatisticsVo.days =='7'">
- and io.createtime >= DATE_SUB(NOW(), INTERVAL 7 DAY)
- </when>
- <when test="taskStatisticsVo.days =='30'">
- and io.createtime >= DATE_SUB(NOW(), INTERVAL 30 DAY)
- </when>
- </choose>
- </if>
- </where>
- GROUP BY io.userid
- ) a
- </select>
- <select id="costCenter" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
- SELECT
- iac.company_id,
- iac.inscompany as "insuranceCompanyName",
- COUNT( CASE WHEN ifa.auditstatus = 1 THEN 1 END ) AS "auditstatusOrders",
- COUNT( CASE WHEN ifa.auditstatus = 0 THEN 1 END ) AS "auditOrder",
- COUNT( CASE WHEN ifa.auditstatus = 1 and ifa.audituser != '自动审核' THEN 1 END ) AS "persionAudit",
- COUNT( CASE WHEN ifa.audituser = '自动审核' THEN 1 END ) AS "automaticAudit"
- FROM
- ins_fee_audit ifa
- LEFT JOIN ins_orders io ON io.orderno = ifa.orderno
- LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
- AND iac.orderstatus = 3
- LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
- LEFT JOIN esm_ins_company eic ON eic.id = pa.partner_companies_id
- left join sys_user su on su.id =ifa.audituser
- <where>
- 1=1
- and iac.id = ifa.ins_order_no
- AND iac.orderstatus = 3
- <if test="taskStatisticsVo.reviewer !=null and taskStatisticsVo.reviewer !=''">
- and su.name =#{taskStatisticsVo.reviewer}
- </if>
- <if test="taskStatisticsVo.audittime !=null and taskStatisticsVo.audittime !=''">
- and ifa.audittime =#{taskStatisticsVo.audittime}
- </if>
- <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId !=''">
- and iac.company_id =#{taskStatisticsVo.companyId}
- </if>
- <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
- 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')
- </if>
- <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
- 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')
- </if>
- <if test="taskStatisticsVo.auditTimeStart !=null and taskStatisticsVo.auditTimeEnd != '' and taskStatisticsVo.auditTimeStart !=null and taskStatisticsVo.auditTimeEnd != ''">
- AND DATE_FORMAT( ifa.audittime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.auditTimeStart}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.auditTimeEnd}, '%Y-%m-%d')
- </if>
- <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
- AND io.deptid in
- <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
- AND su.id in
- <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <choose>
- <when test="taskStatisticsVo.riskCode != null and taskStatisticsVo.riskCode != '' and taskStatisticsVo.riskCode != 'all' ">
- and iac.product = #{taskStatisticsVo.riskCode}
- </when>
- </choose>
- </where>
- GROUP BY
- iac.company_id,
- iac.inscompany
- </select>
- <select id="costCenterDetails" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
- SELECT
- ifa.audituser as "audituser",
- su.name as "audituserName",
- su.mobile as "audituserMobile",
- iac.inscompany as "insuranceCompanyName",
- COUNT( CASE WHEN ifa.auditstatus = 1 THEN 1 END ) AS "auditstatusOrders",
- COUNT( CASE WHEN ifa.auditstatus = 0 THEN 1 END ) AS "auditOrder"
- FROM
- ins_fee_audit ifa
- LEFT JOIN ins_orders io ON io.orderno = ifa.orderno
- LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
- LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
- LEFT JOIN esm_ins_company eic ON eic.id = pa.partner_companies_id
- left join sys_user su on su.id =ifa.audituser
- <where>
- 1=1
- and iac.id = ifa.ins_order_no
- AND iac.orderstatus = 3
- AND ifa.audituser != '自动审核'
- AND (ifa.auditstatus ='1' or ifa.auditstatus ='0')
- <if test="taskStatisticsVo.reviewer !=null and taskStatisticsVo.reviewer !=''">
- and su.name =#{taskStatisticsVo.reviewer}
- </if>
- <if test="taskStatisticsVo.auditTimeStart !=null and taskStatisticsVo.auditTimeEnd != '' and taskStatisticsVo.auditTimeStart !=null and taskStatisticsVo.auditTimeEnd != ''">
- AND DATE_FORMAT( ifa.audittime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.auditTimeStart}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.auditTimeEnd}, '%Y-%m-%d')
- </if>
- <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId !=''">
- and iac.company_id =#{taskStatisticsVo.companyId}
- </if>
- <if test="taskStatisticsVo.audittime !=null and taskStatisticsVo.audittime !=''">
- and ifa.audittime =#{taskStatisticsVo.audittime}
- </if>
- <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
- AND DATE_FORMAT( ifa.audittime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.createtimeStart}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.createtimeEnd}, '%Y-%m-%d')
- </if>
- <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
- 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')
- </if>
- <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
- AND io.deptid in
- <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
- AND su.id in
- <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <choose>
- <when test="taskStatisticsVo.riskCode != null and taskStatisticsVo.riskCode != '' and taskStatisticsVo.riskCode != 'all' ">
- and iac.product = #{taskStatisticsVo.riskCode}
- </when>
- </choose>
- </where>
- GROUP BY
- ifa.audituser,su.name,su.mobile,iac.inscompany
- </select>
- <select id="costCenterDetailsExcel" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDtoExcel">
- SELECT
- ifa.audituser as "audituser",
- su.name as "audituserName",
- su.mobile as "audituserMobile",
- iac.inscompany as "insuranceCompanyName",
- COUNT( CASE WHEN ifa.auditstatus = 1 THEN 1 END ) AS "auditstatusOrders",
- COUNT( CASE WHEN ifa.auditstatus = 0 THEN 1 END ) AS "auditOrder"
- FROM
- ins_fee_audit ifa
- LEFT JOIN ins_orders io ON io.orderno = ifa.orderno
- LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
- LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
- LEFT JOIN esm_ins_company eic ON eic.id = pa.partner_companies_id
- left join sys_user su on su.id =ifa.audituser
- <where>
- 1=1
- and iac.id = ifa.ins_order_no
- AND iac.orderstatus = 3
- AND ifa.audituser != '自动审核'
- AND (ifa.auditstatus ='1' or ifa.auditstatus ='0')
- <if test="taskStatisticsVo.reviewer !=null and taskStatisticsVo.reviewer !=''">
- and su.name =#{taskStatisticsVo.reviewer}
- </if>
- <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId !=''">
- and iac.company_id =#{taskStatisticsVo.companyId}
- </if>
- <if test="taskStatisticsVo.audittime !=null and taskStatisticsVo.audittime !=''">
- and ifa.audittime =#{taskStatisticsVo.audittime}
- </if>
- <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId !=''">
- and iac.company_id =#{taskStatisticsVo.companyId}
- </if>
- <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
- AND DATE_FORMAT( ifa.audittime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.createtimeStart}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.createtimeEnd}, '%Y-%m-%d')
- </if>
- <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
- 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')
- </if>
- <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
- AND io.deptid in
- <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
- AND su.id in
- <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <choose>
- <when test="taskStatisticsVo.riskCode != null and taskStatisticsVo.riskCode != '' and taskStatisticsVo.riskCode != 'all' ">
- and iac.product = #{taskStatisticsVo.riskCode}
- </when>
- </choose>
- </where>
- GROUP BY
- ifa.audituser,su.name,su.mobile,iac.inscompany
- </select>
- <select id="costCenterDetailsLicense" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
- SELECT
- io.licenseno as "licenseno",
- iot.createTime as "createTime",
- ifa.audittime as "auditTime",
- IFNULL(TIMESTAMPDIFF(SECOND, iot.createTime, ifa.audittime),0) as "timeDifference"
- FROM
- ins_fee_audit ifa
- LEFT JOIN ins_orders io ON io.orderno = ifa.orderno
- LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
- LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
- LEFT JOIN esm_ins_company eic ON eic.id = pa.partner_companies_id
- left join (
- select distinct suborder as "suborder" , order_status as "orderStatus",create_time as "createTime" from ins_orders_track
- ) iot on iot.suborder = iac.id
- left join sys_user su on su.id =ifa.audituser
- <where>
- 1=1
- and iac.id = ifa.ins_order_no
- AND iac.orderstatus = 3
- AND io.orderstatus = 3
- AND iot.orderStatus ='3'
- AND ifa.audituser != '自动审核'
- AND (ifa.auditstatus ='1' or ifa.auditstatus ='0')
- <if test="taskStatisticsVo.reviewer !=null and taskStatisticsVo.reviewer !=''">
- and su.name =#{taskStatisticsVo.reviewer}
- </if>
- <if test="taskStatisticsVo.audituser !=null and taskStatisticsVo.audituser !=''">
- and ifa.audituser =#{taskStatisticsVo.audituser}
- </if>
- <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId !=''">
- and iac.company_id =#{taskStatisticsVo.companyId}
- </if>
- <if test="taskStatisticsVo.audittime !=null and taskStatisticsVo.audittime !=''">
- and ifa.audittime =#{taskStatisticsVo.audittime}
- </if>
- <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId !=''">
- and iac.company_id =#{taskStatisticsVo.companyId}
- </if>
- <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
- AND DATE_FORMAT( ifa.audittime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.createtimeStart}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.createtimeEnd}, '%Y-%m-%d')
- </if>
- <if test="taskStatisticsVo.auditTimeStart !=null and taskStatisticsVo.auditTimeEnd != '' and taskStatisticsVo.auditTimeStart !=null and taskStatisticsVo.auditTimeEnd != ''">
- AND DATE_FORMAT( ifa.audittime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.auditTimeStart}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.auditTimeEnd}, '%Y-%m-%d')
- </if>
- <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
- 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')
- </if>
- <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
- AND io.deptid in
- <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
- AND su.id in
- <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <choose>
- <when test="taskStatisticsVo.riskCode != null and taskStatisticsVo.riskCode != '' and taskStatisticsVo.riskCode != 'all' ">
- and iac.product = #{taskStatisticsVo.riskCode}
- </when>
- </choose>
- </where>
- </select>
- <select id="costCenterSecond" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDtoNew">
- SELECT
- IFNULL(count(io.licenseno),0) as "orderNumber",
- IFNULL(sum(TIMESTAMPDIFF(SECOND, iot.createTime, ifa.audittime)),0) as "sumSecond",
- ROUND(IFNULL(sum(TIMESTAMPDIFF(SECOND, iot.createTime, ifa.audittime)),0) / count(io.licenseno),2) as "averageSecond"
- FROM
- ins_fee_audit ifa
- LEFT JOIN ins_orders io ON io.orderno = ifa.orderno
- LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
- LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
- LEFT JOIN esm_ins_company eic ON eic.id = pa.partner_companies_id
- left join sys_user su on su.id =ifa.audituser
- left join (
- select distinct suborder as "suborder" , order_status as "orderStatus",create_time as "createTime" from ins_orders_track
- ) iot on iot.suborder = iac.id
- <where>
- 1=1
- and iac.id = ifa.ins_order_no
- AND iac.orderstatus = 3
- AND io.orderstatus = 3
- AND ifa.audituser != '自动审核'
- AND iot.orderStatus ='3'
- AND (ifa.auditstatus ='1' or ifa.auditstatus ='0')
- <if test="taskStatisticsVo.reviewer !=null and taskStatisticsVo.reviewer !=''">
- and su.name =#{taskStatisticsVo.reviewer}
- </if>
- <if test="taskStatisticsVo.audituser !=null and taskStatisticsVo.audituser !=''">
- and ifa.audituser =#{taskStatisticsVo.audituser}
- </if>
- <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId !=''">
- and iac.company_id =#{taskStatisticsVo.companyId}
- </if>
- <if test="taskStatisticsVo.audittime !=null and taskStatisticsVo.audittime !=''">
- and ifa.audittime =#{taskStatisticsVo.audittime}
- </if>
- <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
- AND DATE_FORMAT( ifa.audittime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.createtimeStart}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.createtimeEnd}, '%Y-%m-%d')
- </if>
- <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
- 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')
- </if>
- <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
- AND io.deptid in
- <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
- AND su.id in
- <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <choose>
- <when test="taskStatisticsVo.riskCode != null and taskStatisticsVo.riskCode != '' and taskStatisticsVo.riskCode != 'all' ">
- and iac.product = #{taskStatisticsVo.riskCode}
- </when>
- </choose>
- </where>
- </select>
- <select id="getOrderManpower" resultType="com.ydtech.modules.admin.model.dto.QxFrontlineAgentDto">
- SELECT
- count( a.numberUserId ) as "orderManpower",
- sum( a.orderAmount ) as "totalPremium",
- sum( a.orderAmount )/ count( a.numberUserId ) as "averagePremium"
- FROM
- (
- SELECT
- count( io.userid ) AS "numberUserId",
- SUM(IFNULL(iac.jqpremium, 0)) +
- SUM(IFNULL(iac.sypremium, 0)) +
- SUM(IFNULL(iac.jypremium, 0)) AS "orderAmount"
- FROM
- `ins_area_company` iac
- LEFT JOIN ins_orders io ON io.orderno = iac.orderno
- <where>
- iac.orderstatus = '3'
- <if test="ids != null and ids.size()>0 ">
- AND io.userid IN
- <foreach item="item" collection="ids" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- </where>
- GROUP BY
- io.userid
- ) a
- </select>
- <select id="getOrderManpowerNew" resultType="com.ydtech.modules.admin.model.dto.QxFrontlineAgentDto">
- SELECT
- count( a.numberUserId ) as "orderManpower",
- IFNULL(sum( a.orderAmount ),0) as "totalPremium",
- ROUND(sum( a.orderAmount )/ sum(a.ordernoNumber),2) AS "averagePremium"
- FROM
- (
- SELECT
- count( io.userid ) AS "numberUserId",
- count( iac.orderno ) AS "ordernoNumber",
- SUM(IFNULL(iac.jqpremium, 0)
- +IFNULL(iac.sypremium, 0)
- +IFNULL(iac.jypremium, 0)
- ) AS "orderAmount"
- FROM
- `ins_area_company` iac
- LEFT JOIN ins_orders io ON io.orderno = iac.orderno
- <where>
- iac.orderstatus = '3'
- <if test="vo.ids != null and vo.ids.size()>0 ">
- AND io.userid IN
- <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
- AND iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
- </if>
- </where>
- GROUP BY
- io.userid
- ) a
- <where>
- <if test="vo.outThere != null and vo.outThere!=''">
- <choose>
- <when test=" vo.outThere == 0">
- AND IFNULL(a.orderAmount,0) = 0
- </when>
- <when test="vo.outThere == 1">
- AND IFNULL(a.orderAmount,0) > 0
- </when>
- </choose>
- </if>
- </where>
- order by sum( a.orderAmount ) desc
- </select>
- <select id="getChannelOrderManpowerNew" resultType="com.ydtech.modules.admin.model.dto.QxFrontlineAgentDto">
- SELECT
- a.userId as "userId",
- a.userName as "name",
- a.orderNumber as "orderNumber",
- a.underwritingCount as "underwritingCount",
- a.qutationInsureCount as "qutationInsureCount",
- IFNULL(a.jqpremium,0) + IFNULL(a.sypremium,0) + IFNULL(a.jypremium,0) as "totalPremium",
- a.isFactorVerify as "isFactorVerify",
- a.isNotFactorVerify as "isNotFactorVerify"
- FROM
- (
- SELECT
- io.userid as "userId",
- io.username as "userName",
- count( iac.orderno ) AS "orderNumber",
- sum(CASE WHEN iac.orderstatus = 3 THEN iac.jqpremium END ) AS jqpremium,
- sum(CASE WHEN iac.orderstatus = 3 THEN iac.sypremium END ) AS sypremium,
- sum(CASE WHEN iac.orderstatus = 3 THEN iac.jypremium END ) AS jypremium,
- COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
- COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
- COUNT( CASE WHEN su.factor_verify = 1 THEN 1 END ) AS isFactorVerify,
- COUNT( CASE WHEN su.factor_verify = 0 THEN 1 END ) AS isNotFactorVerify
- FROM
- `ins_area_company` iac
- LEFT JOIN ins_orders io ON io.orderno = iac.orderno
- left join sys_user su on su.id=io.userid
- <where>
- <if test="vo.ids != null and vo.ids.size()>0 ">
- AND io.userid IN
- <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
- AND iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
- </if>
- <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
- AND iac.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
- </if>
- <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
- AND io.deptid in
- <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
- AND io.userid in
- <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- </where>
- GROUP BY
- io.userid,
- io.username
- ) a
- left join sys_user su on su.id=a.userId
- </select>
- <select id="NumberQuotations" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
- SELECT
- count(iac.id) as "orderNumber",
- COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
- COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
- sum( CASE WHEN iac.orderstatus = 3 THEN IFNULL(iac.jqpremium, 0) + IFNULL(iac.sypremium, 0) + IFNULL(iac.jypremium, 0) END ) AS totalPremium
- FROM
- ins_area_company iac
- left join ins_orders io on io.orderno = iac.orderno
- left join sys_dept sd on sd.id=io.deptid
- left join sys_user su on su.id=io.userid
- left join ins_fee_audit ifa on ifa .ins_order_no =iac.id
- <where>
- sd.management_source = '2'
- <if test="userId !=null and userId !=''">
- and io.userId =#{userId}
- </if>
- </where>
- </select>
- <select id="totalQuotation" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
- SELECT
- agree.insurance_company_id AS companyId,
- agree.insurance_company AS companyName,
- agree.partner_companies_id AS parterCompanyId,
- ins.namesimple AS parterCompanyName,
- count(iac.orderstatus) AS orderNumber,
- '-' as bigQutationCount,
- '-' as bigUnderwritingCount,
- '-' as bigCloseRate,
- COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
- COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
- COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END )/ count(iac.orderstatus) AS passRate,
- COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END )/ count(iac.orderstatus) AS underwritingCountRate,
- COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )/ count(iac.orderstatus) AS closeRate,
- COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )/ COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS
- contributionRate
- FROM
- ins_area_company iac
- LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
- LEFT JOIN ins_orders io on io.orderno = iac.orderno
- LEFT JOIN esm_ins_company ins ON agree.partner_companies_id = ins.id
- WHERE
- agree.id IS NOT NULL
- <if test="vo.companyId != null and vo.companyId!='' ">
- agree.insurance_company_id = #{vo.companyId}
- </if>
- <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
- agree.partner_companies_id = #{vo.parterCompanyId}
- </if>
- <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
- AND iac.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
- </if>
- <if test="vo.provinceId != null and vo.provinceId != ''">
- and io.deptid like "${vo.provinceId}%"
- </if>
- <if test="vo.cityId != null and vo.cityId != ''">
- and io.deptid like "${vo.cityId}%"
- </if>
- <if test="vo.countyId != null and vo.countyId != ''">
- and io.deptid like "${vo.countyId}%"
- </if>
- <if test="taskStatisticsVo.houseId != null and vo.houseId != ''">
- and io.deptid like "${vo.houseId}%"
- </if>
- GROUP BY
- agree.insurance_company_id,
- agree.insurance_company,
- agree.partner_companies_id,
- ins.NAME
- </select>
- <select id="getBusinessData" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
- select
- a.dockingPerson as "dockingPerson",
- a.dockingPhone as "dockingPhone",
- a.agreementType as "agreementType",
- a.logo as "logo",
- a.companyId as "companyId",
- a.insuranceCompanyName as "insuranceCompanyName",
- a.parterCompanyId as "parterCompanyId",
- a.partnerCompaniesName as "partnerCompaniesName",
- sum(a.totalPremium) as "totalPremium",
- sum(a.qutationInsureCount) as "qutationInsureCount",
- sum(a.totalPremium) / sum(a.qutationInsureCount) AS "averagePremium",
- sum(a.totalPremium) / sum(a.userNumber) as "perCapitaAmount",
- sum(a.userNumber) as "userNumber"
- from (
- select
- a.companyId as "companyId",
- a.insuranceCompanyName as "insuranceCompanyName",
- a.parterCompanyId as "parterCompanyId",
- a.partnerCompaniesName as "partnerCompaniesName",
- a.totalPremium as "totalPremium",
- a.qutationInsureCount as "qutationInsureCount",
- a.userNumber as "userNumber",
- c.docking_person as "dockingPerson",
- c.docking_phone as "dockingPhone",
- c.agreement_type as "agreementType",
- b.logo as "logo"
- from (
- SELECT
- agree.insurance_company_id AS "companyId",
- agree.insurance_company AS "insuranceCompanyName",
- agree.partner_companies_id AS "parterCompanyId",
- ins.namesimple AS "partnerCompaniesName",
- agree.id as "agreeId",
- IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0) as "totalPremium",
- COUNT(0 ) AS "qutationInsureCount",
- (IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0)) / COUNT(0 ) AS "averagePremium",
- COUNT(DISTINCT io.userId) AS "userNumber",
- (IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0)) / COUNT(DISTINCT io.userId) as "perCapitaAmount"
- FROM
- ins_area_company iac
- LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
- LEFT JOIN ins_orders io on io.orderno = iac.orderno
- LEFT JOIN ins_fee_audit ifa on ifa.ins_order_no =iac.id
- LEFT JOIN esm_ins_company ins ON agree.partner_companies_id = ins.id
- WHERE
- agree.id IS NOT NULL
- and iac.orderstatus = '3'
- and ifa.auditstatus != '2'
- <if test="vo.companyId != null and vo.companyId!='' ">
- and agree.insurance_company_id = #{vo.companyId}
- </if>
- <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
- and agree.partner_companies_id = #{vo.parterCompanyId}
- </if>
- <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
- 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')
- </if>
- <if test="vo.provinceId != null and vo.provinceId != '' and vo.cityId == null and vo.countyId == null and vo.houseId == null ">
- and io.deptid like concat('%',#{vo.provinceId},'%')
- </if>
- <if test="vo.cityId != null and vo.cityId != '' and vo.countyId ==null and vo.houseId ==null">
- and io.deptid like concat('%',#{vo.cityId},'%')
- </if>
- <if test="vo.countyId != null and vo.countyId != '' and vo.houseId ==null">
- and io.deptid like concat('%',#{vo.countyId},'%')
- </if>
- <if test="vo.houseId != null and vo.houseId != ''">
- and io.deptid like concat('%',#{vo.houseId},'%')
- </if>
- <if test="vo.parterProvinceId != null and vo.parterProvinceId != '' and vo.parterCityId == null and vo.parterCountyId == null ">
- and agree.partner_companies_id like concat('%',#{vo.parterProvinceId},'%')
- </if>
- <if test="vo.parterCityId != null and vo.parterCityId != '' and vo.parterCountyId ==null ">
- and agree.partner_companies_id like concat('%',#{vo.parterCityId},'%')
- </if>
- <if test="vo.parterCountyId != null and vo.parterCountyId != '' ">
- and agree.partner_companies_id like concat('%',#{vo.parterCountyId},'%')
- </if>
- <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
- AND io.deptid in
- <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
- AND io.userid in
- <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- GROUP BY
- agree.insurance_company_id,
- agree.insurance_company,
- agree.partner_companies_id,
- agree.id
- <choose>
- <when test="vo.orderSort != null and vo.orderSort != '' and vo.userNumberSort == null ">
- order by
- sum(sumpremium) ${vo.orderSort == 'asc' ? 'asc' : 'desc'}
- </when>
- <when test="vo.userNumberSort != null and vo.userNumberSort != '' and vo.orderSort == null ">
- order by
- COUNT(DISTINCT io.userId) ${vo.userNumberSort == 'asc' ? 'asc' : 'desc'}
- </when>
- <when test="vo.userNumberSort != null and vo.userNumberSort != '' and vo.orderSort != null and vo.orderSort != '' ">
- order by
- COUNT(DISTINCT io.userId) ${vo.userNumberSort == 'asc' ? 'asc' : 'desc'}, sum(sumpremium) ${vo.orderSort == 'asc' ? 'asc' : 'desc'}
- </when>
- </choose>
- ) a
- left join esm_ins_company b on b.id =a.companyId
- left join ptl_agreement c on c.id =a.agreeId
- ) a
- group by a.companyId,a.insuranceCompanyName,a.parterCompanyId,a.partnerCompaniesName,a.logo,a.dockingPerson,a.dockingPhone,a.agreementType
- </select>
- <select id="getCountBusinessData" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
- select
- sum(a.totalPremium) as "totalPremium",
- sum(a.qutationInsureCount) as "qutationInsureCount",
- ROUND(sum( a.totalPremium ) / sum( a.qutationInsureCount ),2) AS "averagePremium",
- sum(a.userNumber) as "userNumber",
- count(DISTINCT a.insuranceCompanyName) as "insuranceCompanyNumber",
- ROUND(sum(a.totalPremium)/sum(a.userNumber),0) as "perCapitaAmount"
- from (
- SELECT
- agree.insurance_company AS "insuranceCompanyName",
- IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0) as "totalPremium",
- COUNT(0 ) AS "qutationInsureCount",
- COUNT(DISTINCT io.userId) AS "userNumber"
- FROM
- ins_area_company iac
- LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
- LEFT JOIN ins_orders io on io.orderno = iac.orderno
- LEFT JOIN ins_fee_audit ifa on ifa.ins_order_no =iac.id
- WHERE
- agree.id IS NOT NULL
- and iac.orderstatus = '3'
- and ifa.auditstatus != '2'
- <if test="vo.companyId != null and vo.companyId!='' ">
- and agree.insurance_company_id = #{vo.companyId}
- </if>
- <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
- and agree.partner_companies_id = #{vo.parterCompanyId}
- </if>
- <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
- 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')
- </if>
- <if test="vo.provinceId != null and vo.provinceId != '' and vo.cityId == null and vo.countyId == null and vo.houseId == null ">
- and io.deptid like concat('%',#{vo.provinceId},'%')
- </if>
- <if test="vo.cityId != null and vo.cityId != '' and vo.countyId ==null and vo.houseId ==null">
- and io.deptid like concat('%',#{vo.cityId},'%')
- </if>
- <if test="vo.countyId != null and vo.countyId != '' and vo.houseId ==null">
- and io.deptid like concat('%',#{vo.countyId},'%')
- </if>
- <if test="vo.houseId != null and vo.houseId != ''">
- and io.deptid like concat('%',#{vo.houseId},'%')
- </if>
- <if test="vo.parterProvinceId != null and vo.parterProvinceId != '' and vo.parterCityId == null and vo.parterCountyId == null ">
- and agree.partner_companies_id like concat('%',#{vo.parterProvinceId},'%')
- </if>
- <if test="vo.parterCityId != null and vo.parterCityId != '' and vo.parterCountyId ==null ">
- and agree.partner_companies_id like concat('%',#{vo.parterCityId},'%')
- </if>
- <if test="vo.parterCountyId != null and vo.parterCountyId != '' ">
- and agree.partner_companies_id like concat('%',#{vo.parterCountyId},'%')
- </if>
- <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
- AND io.deptid in
- <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
- AND io.userid in
- <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- group by
- agree.insurance_company,
- agree.partner_companies_id
- ) a
- </select>
- <select id="getUserNumber" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
- SELECT
- COUNT(DISTINCT io.userId) AS "userNumber"
- FROM
- ins_area_company iac
- LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
- LEFT JOIN ins_orders io on io.orderno = iac.orderno
- LEFT JOIN ins_fee_audit ifa on ifa.ins_order_no =iac.id
- WHERE
- agree.id IS NOT NULL
- and iac.orderstatus = '3'
- and ifa.auditstatus != '2'
- <if test="vo.companyId != null and vo.companyId!='' ">
- and agree.insurance_company_id = #{vo.companyId}
- </if>
- <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
- and agree.partner_companies_id = #{vo.parterCompanyId}
- </if>
- <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
- 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')
- </if>
- <if test="vo.provinceId != null and vo.provinceId != '' and vo.cityId == null and vo.countyId == null and vo.houseId == null ">
- and io.deptid like concat('%',#{vo.provinceId},'%')
- </if>
- <if test="vo.cityId != null and vo.cityId != '' and vo.countyId ==null and vo.houseId ==null">
- and io.deptid like concat('%',#{vo.cityId},'%')
- </if>
- <if test="vo.countyId != null and vo.countyId != '' and vo.houseId ==null">
- and io.deptid like concat('%',#{vo.countyId},'%')
- </if>
- <if test="vo.houseId != null and vo.houseId != ''">
- and io.deptid like concat('%',#{vo.houseId},'%')
- </if>
- <if test="vo.parterProvinceId != null and vo.parterProvinceId != '' and vo.parterCityId == null and vo.parterCountyId == null ">
- and agree.partner_companies_id like concat('%',#{vo.parterProvinceId},'%')
- </if>
- <if test="vo.parterCityId != null and vo.parterCityId != '' and vo.parterCountyId ==null ">
- and agree.partner_companies_id like concat('%',#{vo.parterCityId},'%')
- </if>
- <if test="vo.parterCountyId != null and vo.parterCountyId != '' ">
- and agree.partner_companies_id like concat('%',#{vo.parterCountyId},'%')
- </if>
- <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
- AND io.deptid in
- <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
- AND io.userid in
- <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- </select>
- <select id="getDistribution" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
- SELECT
- agree.insurance_company_id AS "companyId",
- agree.insurance_company AS "insuranceCompanyName",
- agree.partner_companies_id AS "parterCompanyId",
- ins.namesimple AS "partnerCompaniesName",
- IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0) as "totalPremium",
- COUNT(0) AS "qutationInsureCount",
- ROUND((IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0)) / COUNT(0), 2) AS "averagePremium",
- COUNT(DISTINCT io.userId) AS "userNumber",
- ROUND((IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0)) / COUNT(DISTINCT io.userId) ,2) as "perCapitaAmount"
- FROM
- ins_area_company iac
- LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
- LEFT JOIN ins_orders io on io.orderno = iac.orderno
- LEFT JOIN esm_ins_company ins ON agree.partner_companies_id = ins.id
- LEFT JOIN ins_fee_audit ifa on ifa.ins_order_no =iac.id
- WHERE
- agree.id IS NOT NULL
- and ifa.auditstatus != '2'
- <if test="vo.companyId != null and vo.companyId!='' ">
- and agree.insurance_company_id = #{vo.companyId}
- </if>
- <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
- and agree.partner_companies_id = #{vo.parterCompanyId}
- </if>
- <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
- 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')
- </if>
- <if test="vo.days !=null and vo.days !='' and vo.days != 0 ">
- and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{vo.days} DAY)
- </if>
- <if test="vo.provinceId != null and vo.provinceId != ''">
- and io.deptid like "${vo.provinceId}%"
- </if>
- <if test="vo.cityId != null and vo.cityId != ''">
- and io.deptid like "${vo.cityId}%"
- </if>
- <if test="vo.countyId != null and vo.countyId != ''">
- and io.deptid like "${vo.countyId}%"
- </if>
- <if test="vo.houseId != null and vo.houseId != ''">
- and io.deptid like "${vo.houseId}%"
- </if>
- <if test="vo.quotationStatus != null and vo.quotationStatus != ''">
- and iac.orderstatus =#{vo.quotationStatus}
- </if>
- <if test="vo.dockingPerson != null and vo.dockingPerson != ''">
- and agree.docking_person =#{vo.dockingPerson}
- </if>
- <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
- AND io.deptid in
- <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
- AND io.userid in
- <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="vo.riskCode != null and vo.riskCode != '' and vo.riskCode != 'all'">
- and iac.product = #{vo.riskCode}
- </if>
- GROUP BY
- agree.insurance_company_id,
- agree.insurance_company,
- agree.partner_companies_id,
- ins.namesimple
- </select>
- <select id="getOrderPremiumByUserIds" resultType="Double">
- SELECT
- IFNULL(
- SUM( IFNULL( iac.jqpremium, 0 ) + IFNULL( iac.sypremium, 0 ) + IFNULL( iac.jypremium, 0 ) ),
- 0
- ) AS "totalPremium"
- FROM
- `ins_area_company` iac
- LEFT JOIN ins_orders io ON io.orderno = iac.orderno
- <where>
- iac.orderstatus = '3'
- <if test="vo.ids != null and vo.ids.size()>0 ">
- AND io.userid IN
- <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
- AND iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
- </if>
- </where>
- </select>
- <select id="querOrdersDataPage" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
- SELECT
- count( 0 ) AS "orderNumber",
- b.licenseno as "licenseno",
- b.frameno as "frameno",
- b.modelCode as "modelCode",
- b.modelcname as "modelcname"
- FROM
- (
- SELECT
- io.orderstatus AS orderstatus,
- io.frameno AS frameno,
- REPLACE(JSON_EXTRACT(io.carinfo, '$.engineNo'), '"', '') as "modelCode",
- REPLACE(JSON_EXTRACT(io.carinfo, '$.modelcname'), '"', '') as "modelcname",
- ifnull(io.licenseno, '') AS licenseno
- FROM
- ins_orders io
- LEFT JOIN sys_user su on io.userid=su.id
- <where>
- 1=1
- <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
- AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
- </if>
- <if test="vo.licenseno != null and vo.licenseno!='' ">
- AND io.licenseno =#{vo.licenseno}
- </if>
- <if test="vo.userId != null and vo.userId!='' ">
- AND io.userid =#{vo.userId}
- </if>
- <if test="vo.userName != null and vo.userName!='' ">
- AND su.name =#{vo.userName}
- </if>
- <if test="vo.mobile != null and vo.mobile!='' ">
- AND su.mobile =#{vo.mobile}
- </if>
- <if test="vo.frameno != null and vo.frameno!='' ">
- AND io.frameno =#{vo.frameno}
- </if>
- <if test="vo.deptId != null and vo.deptId!='' ">
- and io.deptid like concat('%', #{vo.deptId}, '%')
- </if>
- <if test="vo.year != null and vo.year!='' ">
- AND DATE_FORMAT( io.createtime, '%Y') =#{vo.year}
- </if>
- <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
- AND io.deptid in
- <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
- AND io.userid in
- <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- </where>
- ) b
- GROUP BY
- b.licenseno,
- b.frameno,
- b.modelCode,
- b.modelcname
- </select>
- <select id="getOrdersGroupByLicenseno" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
- SELECT
- io.licenseno AS "licenseno",
- io.frameno AS "frameno",
- io.orderstatus as "orderstatus",
- io.orderno as "orderno"
- FROM
- ins_orders io
- LEFT JOIN sys_user su on io.userid=su.id
- <where>
- io.licenseno is not null
- <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
- AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
- </if>
- <if test="vo.licenseno != null and vo.licenseno!='' ">
- AND io.licenseno =#{vo.licenseno}
- </if>
- <if test="vo.userId != null and vo.userId!='' ">
- AND io.userId =#{vo.userId}
- </if>
- <if test="vo.userName != null and vo.userName!='' ">
- AND su.name =#{vo.userName}
- </if>
- <if test="vo.mobile != null and vo.mobile!='' ">
- AND su.mobile =#{vo.mobile}
- </if>
- <if test="vo.frameno != null and vo.frameno!='' ">
- AND su.frameno =#{vo.frameno}
- </if>
- <if test="vo.deptId != null and vo.deptId!='' ">
- and io.deptid like concat('%', #{vo.deptId}, '%')
- </if>
- </where>
- </select>
- <select id="querOrdersamountTo" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
- select sum(a.orderNumber) as "orderNumber",
- count(a.licenseno) as "b.frameno"
- from (
- SELECT
- count( 0 ) AS "orderNumber",
- b.licenseno as "licenseno",
- b.frameno as "frameno"
- FROM
- (
- SELECT
- io.orderstatus AS orderstatus,
- io.frameno AS frameno,
- ifnull(io.licenseno, '') AS licenseno
- FROM
- ins_orders io
- LEFT JOIN sys_user su on io.userid=su.id
- <where>
- 1=1
- <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
- AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
- </if>
- <if test="vo.licenseno != null and vo.licenseno!='' ">
- AND io.licenseno =#{vo.licenseno}
- </if>
- <if test="vo.userId != null and vo.userId!='' ">
- AND io.userid =#{vo.userId}
- </if>
- <if test="vo.userName != null and vo.userName!='' ">
- AND su.name =#{vo.userName}
- </if>
- <if test="vo.mobile != null and vo.mobile!='' ">
- AND su.mobile =#{vo.mobile}
- </if>
- <if test="vo.frameno != null and vo.frameno!='' ">
- AND io.frameno =#{vo.frameno}
- </if>
- <if test="vo.deptId != null and vo.deptId!='' ">
- and io.deptid like concat('%', #{vo.deptId}, '%')
- </if>
- </where>
- ) b
- GROUP BY
- b.licenseno,
- b.frameno
- ) a
- </select>
- <select id="querResultOrderNumber" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
- SELECT
- count( io.orderno ) AS "orderNumber",
- 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"
- FROM
- ins_orders io
- LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
- LEFT JOIN sys_user su ON io.userid = su.id
- <where>
- 1=1
- <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
- AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
- </if>
- <if test="vo.licenseno != null and vo.licenseno!='' ">
- AND io.licenseno =#{vo.licenseno}
- </if>
- <if test="vo.userId != null and vo.userId!='' ">
- AND io.userid =#{vo.userId}
- </if>
- <if test="vo.userName != null and vo.userName!='' ">
- AND su.name =#{vo.userName}
- </if>
- <if test="vo.mobile != null and vo.mobile!='' ">
- AND su.mobile =#{vo.mobile}
- </if>
- <if test="vo.frameno != null and vo.frameno!='' ">
- AND su.frameno =#{vo.frameno}
- </if>
- <if test="vo.deptId != null and vo.deptId!='' ">
- and io.deptid like concat('%', #{vo.deptId}, '%')
- </if>
- </where>
- </select>
- <select id="numberQuotationsByUserIds" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
- SELECT
- count(iac.id) as "orderNumber",
- COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
- COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
- sum( CASE WHEN iac.orderstatus = 3 THEN IFNULL(iac.jqpremium, 0) + IFNULL(iac.sypremium, 0) + IFNULL(iac.jypremium, 0) END ) AS totalPremium
- FROM
- ins_area_company iac
- left join ins_orders io on io.orderno = iac.orderno
- <where>
- <if test="ids != null and ids.size()>0 ">
- AND io.userid IN
- <foreach item="item" collection="ids" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="month != null and month!='' ">
- AND DATE_FORMAT(iac.createtime, '%Y-%m') =#{month}
- </if>
- </where>
- </select>
- <select id="selectByOrdersDataVo" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
- select
- iac.inscompany as "namesimple"
- from
- ins_area_company iac
- <where>
- 1=1
- <if test="vo.orderstatus != null and vo.orderstatus != '' ">
- AND iac.orderstatus =#{vo.orderstatus}
- </if>
- <if test="vo.orderno !=null and vo.orderno !='' ">
- AND iac.orderno =#{vo.orderno}
- </if>
- </where>
- </select>
- <select id="channelExcel" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsExcel">
- select a.*,(select name from sys_user where id =a.userId) as "userName"
- from (
- SELECT
- sd.NAME AS "deptName",
- io.userid AS "userId",
- sd.parent_id as "deptId",
- sd.management_source as "managementSource",
- COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS qutationCount,
- COUNT( CASE WHEN iot.order_status ='2' THEN 1 END ) AS underwritingCount,
- COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) AS qutationInsureCount,
- COUNT( CASE WHEN iot.order_status = '4' THEN 1 END ) AS underwritingReturn,
- COUNT( CASE WHEN iot.order_status ='2' THEN 1 END ) / COUNT( CASE WHEN iot.order_status ='0' THEN 1 END ) AS "passingRate",
- 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",
- (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",
- 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",
- COUNT(CASE WHEN io.order_source = 0 and iot.order_status ='0' THEN 1 END) as "pcOrderSource",
- COUNT(CASE WHEN io.order_source = 1 and iot.order_status ='0' THEN 1 END) as "appOrderSource",
- COUNT( CASE WHEN iot.order_status = '1' THEN 1 END ) AS "auditOrder"
- FROM
- (
- select iot.suborder,iot.order_status from `ins_orders_track` iot
- GROUP BY iot.suborder ,iot.order_status
- ) iot
- left join ins_area_company iac ON iac.id = iot.suborder
- LEFT JOIN ins_orders io ON io.orderno = iac.orderno
- LEFT JOIN sys_dept sd ON sd.id = io.deptid
- <where>
- <if test="taskStatisticsVo.managementSource != null and taskStatisticsVo.managementSource!=''">
- AND sd.management_source =#{taskStatisticsVo.managementSource}
- </if>
- <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
- and io.deptid like "${taskStatisticsVo.provinceId}%"
- </if>
- <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
- and io.deptid like "${taskStatisticsVo.cityId}%"
- </if>
- <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
- and io.deptid like "${taskStatisticsVo.countyId}%"
- </if>
- <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
- and io.deptid like "${taskStatisticsVo.houseId}%"
- </if>
- <if test="taskStatisticsVo.userId != null and taskStatisticsVo.userId != ''">
- and io.userid =#{taskStatisticsVo.userId}
- </if>
- <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
- AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
- </if>
- <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
- 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')
- </if>
- <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
- AND sd.id in
- <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
- AND io.userid in
- <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
- <choose>
- <when test="taskStatisticsVo.days =='1'">
- and io.createtime >= DATE_SUB(NOW(), INTERVAL 1 DAY)
- </when>
- <when test="taskStatisticsVo.days =='7'">
- and io.createtime >= DATE_SUB(NOW(), INTERVAL 7 DAY)
- </when>
- <when test="taskStatisticsVo.days =='30'">
- and io.createtime >= DATE_SUB(NOW(), INTERVAL 30 DAY)
- </when>
- </choose>
- </if>
- </where>
- GROUP BY
- io.userid,
- sd.NAME,
- sd.id,
- sd.management_source
- ) a
- left join sys_user su on su.id =a.userId
- LEFT JOIN ins_upload_files inf on su.head_sculpture =inf.id
- LEFT JOIN sys_user_info sui on sui .id =su.id
- LEFT JOIN sys_user su2 on su2.id =su.leader_id
- <where>
- <if test='taskStatisticsVo.userName !=null and taskStatisticsVo.userName!="" '>
- and su.name like concat('%',#{taskStatisticsVo.userName},'%')
- </if>
- <if test='taskStatisticsVo.leaderId !=null and taskStatisticsVo.leaderId!="" '>
- and su.leader_id =#{taskStatisticsVo.leaderId}
- </if>
- <if test='taskStatisticsVo.userId !=null and taskStatisticsVo.userId!="" '>
- and su.id =#{taskStatisticsVo.userId}
- </if>
- </where>
- </select>
- <select id="insuranceCompanyExcel" resultType="com.ydtech.modules.admin.model.dto.InsuranceCompanyExcel">
- SELECT
- a.*,
- ( SELECT eic.namesimple FROM esm_ins_company eic WHERE eic.id = a.partner_companies_id ) AS "partnerCompaniesName"
- FROM
- (
- SELECT
- pa.insurance_company_id,
- pa.partner_companies_id,
- pa.insurance_company AS "insuranceCompanyName",
- COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS qutationCount,
- COUNT( CASE WHEN iot.order_status = '1' THEN 1 END ) AS "auditOrder",
- COUNT( CASE WHEN iot.order_status = '2' THEN 1 END ) AS underwritingCount,
- COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) AS qutationInsureCount,
- COUNT( CASE WHEN iot.order_status = '4' THEN 1 END ) AS underwritingReturn,
- COUNT( CASE WHEN iot.order_status ='2' THEN 1 END ) / COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS "passingRate",
- COUNT( CASE WHEN iot.order_status = '3' THEN 1 END ) / COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) AS "closeRate",
- (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",
- COUNT( CASE WHEN iot.order_status = '0' THEN 1 END ) / COUNT( iot.order_status ) AS "quotationRate"
- FROM
- (
- select iot.suborder,iot.order_status from `ins_orders_track` iot
- GROUP BY iot.suborder ,iot.order_status
- ) iot
- LEFT JOIN ins_area_company iac ON iac.id = iot.suborder
- LEFT JOIN ins_fee_audit ifa ON ifa.ins_order_no = iac.id
- LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
- LEFT JOIN ins_orders io ON io.orderno = iac.orderno
- <where>
- pa.insurance_company_id IS NOT NULL
- <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
- and io.deptid like concat('%', #{taskStatisticsVo.provinceId}, '%')
- </if>
- <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
- and io.deptid like concat('%', #{taskStatisticsVo.cityId}, '%')
- </if>
- <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
- and io.deptid like concat('%', #{taskStatisticsVo.countyId}, '%')
- </if>
- <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
- and io.deptid like concat('%', #{taskStatisticsVo.houseId}, '%')
- </if>
- <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
- AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT(#{taskStatisticsVo.createtimeStart},'%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.createtimeEnd}, '%Y-%m-%d')
- </if>
- <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
- AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
- </if>
- <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId != ''">
- AND iac.company_id =#{taskStatisticsVo.companyId}
- </if>
- <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
- AND io.deptid in
- <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
- AND io.userid in
- <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- </where>
- GROUP BY
- pa.insurance_company_id,
- pa.partner_companies_id,
- pa.insurance_company
- ) a
- </select>
- <select id="getSumBigOrderCount" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
- select count(0) as "orderNumber",
- GROUP_CONCAT(inscompany ORDER BY inscompany SEPARATOR ',') as "namesimple"
- from ins_area_company iac
- left join ins_orders io on io.orderno = iac.orderno
- <where>
- 1=1
- and iac.orderstatus ='3'
- and io.orderstatus ='3'
- <if test="vo.licenseno !=null and vo.licenseno!=''">
- AND io.licenseno =#{vo.licenseno}
- </if>
- <if test="vo.frameno !=null and vo.frameno!=''">
- AND io.frameno =#{vo.frameno}
- </if>
- <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
- AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
- </if>
- <if test="vo.year != null and vo.year!='' ">
- AND DATE_FORMAT( io.createtime, '%Y') =#{vo.year}
- </if>
- </where>
- limit 10
- </select>
- <select id="queryAgencyUserInsAreaPage" resultType="com.ydtech.modules.admin.model.vo.AgencyUserInsAreaVo">
- select
- io.userid as userId,
- io.username as userName,
- io.licenseno as licenseno,
- iac.id as companyId,
- iac.jqpremium as jqpremium,
- iac.sypremium as sypremium,
- iac.jypremium as jypremium,
- iac.createtime as createtime,
- iac.orderstatus as orderstatus
- from ins_area_company iac
- left join ins_orders io on io.orderno = iac.orderno
- <where>
- iac.orderstatus=3
- <if test="dto.userId !=null and dto.userId !=''">
- and io.userid = #{dto.userId}
- </if>
- <if test="dto.deptId !=null and dto.deptId !=''">
- and io.deptid like concat( #{dto.deptId}, '%')
- </if>
- <if test="dto.startTime !=null and dto.startTime !=''">
- and io.createtime >= #{dto.startTime}
- </if>
- </where>
- ORDER BY iac.createtime
- </select>
- <select id="querOrdersDataListExcel" resultType="com.ydtech.modules.admin.model.dto.OrdersDataExcel">
- SELECT
- count( 0 ) AS "orderNumber",
- b.licenseno as "licenseno",
- b.frameno as "frameno",
- b.modelCode as "modelCode",
- b.modelcname as "modelcname"
- FROM
- (
- SELECT
- io.orderstatus AS orderstatus,
- io.frameno AS frameno,
- REPLACE(JSON_EXTRACT(io.carinfo, '$.engineNo'), '"', '') as "modelCode",
- REPLACE(JSON_EXTRACT(io.carinfo, '$.modelcname'), '"', '') as "modelcname",
- ifnull(io.licenseno, '') AS licenseno
- FROM
- ins_orders io
- LEFT JOIN sys_user su on io.userid=su.id
- <where>
- 1=1
- <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
- AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
- </if>
- <if test="vo.licenseno != null and vo.licenseno!='' ">
- AND io.licenseno =#{vo.licenseno}
- </if>
- <if test="vo.userId != null and vo.userId!='' ">
- AND io.userid =#{vo.userId}
- </if>
- <if test="vo.userName != null and vo.userName!='' ">
- AND su.name =#{vo.userName}
- </if>
- <if test="vo.mobile != null and vo.mobile!='' ">
- AND su.mobile =#{vo.mobile}
- </if>
- <if test="vo.frameno != null and vo.frameno!='' ">
- AND io.frameno =#{vo.frameno}
- </if>
- <if test="vo.deptId != null and vo.deptId!='' ">
- and io.deptid like concat('%', #{vo.deptId}, '%')
- </if>
- <if test="vo.year != null and vo.year!='' ">
- AND DATE_FORMAT( io.createtime, '%Y') =#{vo.year}
- </if>
- <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
- AND io.deptid in
- <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
- AND io.userid in
- <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- </where>
- ) b
- GROUP BY
- b.licenseno,
- b.frameno,
- b.modelCode,
- b.modelcname
- </select>
- <select id="orderCheckPage" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
- select
- iac.id,
- iac.orderno,
- iac.agreement_id,
- iac.jqpremium,
- iac.sypremium,
- iac.jypremium,
- iac.taxamount,
- iac.sumpremium,
- io.licenseno,
- iac.createtime,
- su.name as auditname
- FROM
- ins_area_company iac
- LEFT JOIN
- ins_orders io on iac.orderno = io.orderno
- left join ptl_agreement agree on iac.agreement_id =agree.id
- left join ins_fee_audit ifa on iac.id = ifa.ins_order_no
- left join sys_user su on su.id= ifa.audituser
- WHERE
- iac.operator_id = #{userId}
- AND
- iac.orderstatus = 3
- and agree.is_external =1
- and auditstatus =1
- <if test="vo.id != null and vo.id!='' ">
- and iac.id = #{vo.id}
- </if>
- <if test="vo.licenseno != null and vo.licenseno!='' ">
- and io.licenseno like CONCAT('%', #{vo.licenseno}, '%')
- </if>
- </select>
- <select id="costCenterTotal" resultType="java.util.HashMap">
- SELECT
- COUNT( CASE WHEN ifa.auditstatus = 1 THEN 1 END ) AS "allAuditstatusOrders",
- COUNT( CASE WHEN ifa.auditstatus = 0 THEN 1 END ) AS "allAuditOrder",
- COUNT( CASE WHEN ifa.auditstatus = 1 and ifa.audituser != '自动审核' THEN 1 END ) AS "allPersionAudit",
- COUNT( CASE WHEN ifa.audituser = '自动审核' THEN 1 END ) AS "allAutomaticAudit"
- FROM
- ins_fee_audit ifa
- LEFT JOIN ins_orders io ON io.orderno = ifa.orderno
- LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
- AND iac.orderstatus = 3
- LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
- LEFT JOIN esm_ins_company eic ON eic.id = pa.partner_companies_id
- left join sys_user su on su.id =ifa.audituser
- <where>
- 1=1
- and iac.id = ifa.ins_order_no
- AND iac.orderstatus = 3
- <if test="taskStatisticsVo.reviewer !=null and taskStatisticsVo.reviewer !=''">
- and su.name =#{taskStatisticsVo.reviewer}
- </if>
- <if test="taskStatisticsVo.audittime !=null and taskStatisticsVo.audittime !=''">
- and ifa.audittime =#{taskStatisticsVo.audittime}
- </if>
- <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId !=''">
- and iac.company_id =#{taskStatisticsVo.companyId}
- </if>
- <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
- 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')
- </if>
- <if test="taskStatisticsVo.auditTimeStart !=null and taskStatisticsVo.auditTimeEnd != '' and taskStatisticsVo.auditTimeStart !=null and taskStatisticsVo.auditTimeEnd != ''">
- AND DATE_FORMAT( ifa.audittime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.auditTimeStart}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.auditTimeEnd}, '%Y-%m-%d')
- </if>
- <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
- 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')
- </if>
- <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
- AND io.deptid in
- <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
- AND su.id in
- <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <choose>
- <when test="taskStatisticsVo.riskCode != null and taskStatisticsVo.riskCode != '' and taskStatisticsVo.riskCode != 'all' ">
- and iac.product = #{taskStatisticsVo.riskCode}
- </when>
- </choose>
- </where>
- </select>
- <select id="getSubOrderCountDTO" resultType="com.ydtech.modules.order.entity.dto.SubOrderCountDTO">
- select orderno, orderstatus, count(*)as count
- from (select orderno, company_id, orderstatus
- from ins_area_company
- where orderno in
- <foreach collection="orderNo" open="(" separator="," close=")" item="item" index="index">
- #{item,jdbcType=VARCHAR}
- </foreach>
- and del_flag = '1'
- group by orderno, company_id, orderstatus) as iac
- group by orderno, orderstatus
- </select>
- <select id="getAllRejectOrders" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
- select
- iac.id,
- iac.orderno,
- iac.agreement_id,
- iac.jqpremium,
- iac.sypremium,
- iac.jypremium,
- iac.taxamount,
- iac.sumpremium,
- io.licenseno,
- ifa.audittime,
- ifa.audituser as auditname,
- ifa.rejectinfo,
- "1" as orderExternalStatus
- FROM
- ins_fee_audit ifa
- LEFT JOIN
- ins_area_company iac on iac.id = ifa.ins_order_no
- LEFT JOIN
- ins_orders io on iac.orderno = io.orderno
- left join
- sys_user su on su.id= ifa.audituser
- WHERE
- ifa.auditstatus = 2 and IFNULL(iac.del_flag,'') != '0'
- <if test="vo.id != null and vo.id!=''">
- and iac.id = #{vo.id}
- </if>
- <if test="vo.licenseno != null and vo.licenseno!='' ">
- and io.licenseno like CONCAT('%', #{vo.licenseno}, '%')
- </if>
- <if test="vo.auditname != null and vo.auditname!='' ">
- and su.name like CONCAT('%', #{vo.auditname}, '%')
- </if>
- order by io.createtime
- </select>
- <select id="queryPageOrderCB" resultType="com.ydtech.modules.order.entity.InsOrders">
- SELECT
- iac.id as orderno,
- io.quoteno,
- iac.orderstatus,
- iac.company_id,
- iac.inscompany,
- io.carinfo,
- io.userid,
- io.username,
- io.deptid,
- io.deptname,
- io.agreeid,
- iac.productid,
- iac.product,
- iac.createtime,
- io.frameno,
- io.licenseno,
- JSON_UNQUOTE(json_extract(io.insureinfo, '$.name')) as insuredname,
- io.is_external,
- iac.jq_start_date as jqstartdate,
- iac.jq_end_date as jqenddate,
- iac.sy_start_date as systartdate,
- iac.sy_end_date as syenddate,
- io.vehicle_and_vessel_tax,
- io.operatorid,
- iac.operator_name,
- sd.management_source,
- iac.problem_order,
- eic.namesimple as partnerCompaniesName,
- iac.id as subOrderId,
- iac.signing_time as signingTime,
- iac.pay_date as payDate,
- pa.agreement_code as agreementCode,
- pa.agreement_name as agreementName,
- pa.business_description as businessDescription,
- pa.job_description as jobDescription,
- pa.agreement_title as agreementTitle,
- pa.docking_person as dockingPerson,
- io.entry_status
- FROM
- ins_area_company iac
- LEFT JOIN ins_orders io ON iac.orderno = io.orderno
- LEFT JOIN sys_user su ON su.id = io.userid
- LEFT JOIN sys_dept sd ON sd.id = su.dept_id
- LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
- LEFT JOIN esm_ins_company eic ON eic.id = pa.partner_companies_id
- WHERE
- iac.orderstatus = 3
- <if test="params.quoteStartDateStr != null and params.quoteStartDateStr != '' and params.quoteEndDateStr != null and params.quoteEndDateStr != ''">
- and DATE_FORMAT(iac.createtime, '%Y-%m-%d') between #{params.quoteStartDateStr} AND
- #{params.quoteEndDateStr}
- </if>
- <if test="params.orderNo != null and params.orderNo != ''">
- AND iac.id= #{params.orderNo}
- </if>
- <if test="params.licenseNo != null and params.licenseNo != ''">
- AND io.licenseno = #{params.licenseNo}
- </if>
- <if test="params.frameNo != null and params.frameNo != ''">
- AND io.frameno = #{params.frameNo}
- </if>
- <if test="params.insuredName != null and params.insuredName != ''">
- AND json_extract(io.insureinfo, '$.name') = #{params.insuredName}
- </if>
- <if test="params.companyId != null and params.companyId != ''">
- AND iac.company_id = #{params.companyId}
- </if>
- <if test="params.engineNo != null and params.engineNo != ''">
- and JSON_EXTRACT( io.carinfo, '$.engineNo' ) = #{params.engineNo}
- </if>
- <if test="params.riskCode != null and params.riskCode != ''">
- and iac.product = #{params.riskCode}
- </if>
- <if test="params.attachStartDateStr != null and params.attachStartDateStr != '' and params.attachStartDateStr != null and params.attachStartDateStr != '' ">
- and ((
- DATE_FORMAT(iac.jq_start_date, '%Y-%m-%d') BETWEEN #{params.attachStartDateStr}
- AND #{params.attachEndDateStr}
- )
- OR ( DATE_FORMAT(iac.sy_start_date, '%Y-%m-%d') BETWEEN #{params.attachStartDateStr} AND
- #{params.attachEndDateStr} )
- )
- </if>
- <if test="params.provinceId != null and params.provinceId != ''">
- and io.deptid like "${params.provinceId}%"
- </if>
- <if test="params.problemOrder != null and params.problemOrder != ''">
- and iac.problem_order like "${params.problemOrder}%"
- </if>
- <if test="params.cityId != null and params.cityId != ''">
- and io.deptid like "${params.cityId}%"
- </if>
- <if test="params.countyId != null and params.countyId != ''">
- and io.deptid like "${params.countyId}%"
- </if>
- <if test="params.houseId != null and params.houseId != ''">
- and io.deptid like "${params.houseId}%"
- </if>
- <if test="params.operatorId != null and params.operatorId != ''">
- and io.userid = #{params.operatorId}
- </if>
- <if test="params.operatorName != null and params.operatorName != ''">
- and io.username = #{params.operatorName}
- </if>
- <if test="params.auditId != null and params.auditId != ''">
- and iac.new_operator_id = #{params.auditId}
- </if>
- <if test="params.agreeId != null and params.agreeId != ''">
- and iac.agreement_id = #{params.agreeId}
- </if>
- <if test="params.managementSource != null and params.managementSource != ''">
- and sd.management_source = #{params.managementSource}
- </if>
- <if test="params.signStartDateStr != null and params.signStartDateStr != '' and params.signEndDateStr != null and params.signEndDateStr != ''">
- and DATE_FORMAT(iac.signing_time, '%Y-%m-%d') between #{params.signStartDateStr} AND
- #{params.signEndDateStr}
- </if>
- <if test="params.payStartDateStr != null and params.payStartDateStr != '' and params.payEndDateStr != null and params.payEndDateStr != ''">
- and iac.pay_date between #{params.payStartDateStr} AND #{params.payEndDateStr}
- </if>
- <if test="params.isExternal != null and params.isExternal != ''">
- and io.is_external = #{params.isExternal}
- </if>
- <if test="params.jqPolicyNo != null and params.jqPolicyNo != ''">
- and iac.jqpolicyno = #{params.jqPolicyNo}
- </if>
- <if test="params.syPolicyNo != null and params.syPolicyNo != ''">
- and iac.sypolicyno = #{params.syPolicyNo}
- </if>
- <if test="params.noPolicyNo != null and params.noPolicyNo != ''">
- and iac.cross_insurance like concat('%', #{params.noPolicyNo}, '%')
- </if>
- order by iac.createtime desc
- </select>
- <select id="getExpectNetProfit" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
- select
- ROUND(sum(IFNULL(ifon.jq_costs_premiums,0) + IFNULL(ifon.sy_costs_premiums,0) + IFNULL (ifon.no_costs_premiums,0)),2) as "entranceAllFee",
- ROUND(sum(IFNULL(jq_export_other_costs_premiums,0) + IFNULL(jq_export_supervise_costs_premiums,0)
- +IFNULL(sy_export_other_costs_premiums,0) +IFNULL(sy_export_supervise_costs_premiums,0)
- +IFNULL(no_export_other_costs_premiums,0)+IFNULL(no_export_supervise_costs_premiums,0) ),2) as
- "exportAllFee",
- ROUND(sum(IFNULL(b.distributionAmount,0)),2) as "distributionAmount"
- from ins_area_company iac
- left join ins_orders io on io.orderno = iac.orderno
- LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
- LEFT JOIN (
- select IFNULL(a.firstDetailPremiums,0) + IFNULL(b.secondDetailPremiums,0) +IFNULL(c.thirdDetailPremiums,0) as "distributionAmount",
- a.firstLevelUserId
- from (
- select
- sum(ifon.first_detail_premiums) as "firstDetailPremiums",
- ifon.first_level_user_id as "firstLevelUserId"
- from ins_area_company iac
- left join ins_orders io on io.orderno = iac.orderno
- LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
- <where>
- iac.orderstatus = 3
- <if test="vo.userId !=null and vo.userId !=''">
- AND ifon.first_level_user_id =#{vo.userId}
- </if>
- <if test="vo.ids != null and vo.ids.size()>0 ">
- AND ifon.first_level_user_id IN
- <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
- AND iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
- </if>
- </where>
- group by ifon.first_level_user_id
- ) a
- left join (
- select
- sum(IFNULL(second_detail_premiums,0)) as "secondDetailPremiums",
- ifon.two_level_user_id as "twoLevelUserId"
- from ins_area_company iac
- left join ins_orders io on io.orderno = iac.orderno
- LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
- <where>
- iac.orderstatus = 3
- <if test="vo.userId !=null and vo.userId !=''">
- AND ifon.two_level_user_id =#{vo.userId}
- </if>
- <if test="vo.ids != null and vo.ids.size()>0 ">
- AND ifon.two_level_user_id IN
- <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
- AND iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
- </if>
- </where>
- group by ifon.two_level_user_id
- ) b on b.twoLevelUserId =a.firstLevelUserId
- left join (
- select
- sum(IFNULL(third_detail_premiums,0)) as "thirdDetailPremiums",
- ifon.three_level_user_id as "threeLevelUserId"
- from ins_area_company iac
- left join ins_orders io on io.orderno = iac.orderno
- LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
- <where>
- iac.orderstatus = 3
- <if test="vo.userId !=null and vo.userId !=''">
- AND ifon.three_level_user_id =#{vo.userId}
- </if>
- <if test="vo.ids != null and vo.ids.size()>0 ">
- AND ifon.three_level_user_id IN
- <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
- AND iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
- </if>
- </where>
- group by ifon.three_level_user_id
- ) c on c.threeLevelUserId = a.firstLevelUserId
- ) b on b.firstLevelUserId =iac.leader_id
- <where>
- iac.orderstatus = 3
- <if test="vo.userId !=null and vo.userId !=''">
- AND io.userid =#{vo.userId}
- </if>
- <if test="vo.ids != null and vo.ids.size()>0 ">
- AND io.userid IN
- <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
- AND iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
- </if>
- </where>
- </select>
- <select id="getDistributionAllAmount" resultType="java.util.HashMap">
- select IFNULL(a.firstDetailPremiums,0) + IFNULL(b.secondDetailPremiums,0) +IFNULL(c.thirdDetailPremiums,0) as "distributionAmount",
- a.firstLevelUserId
- from (
- select
- sum(ifon.first_detail_premiums) as "firstDetailPremiums",
- ifon.first_level_user_id as "firstLevelUserId"
- from ins_area_company iac
- left join ins_orders io on io.orderno = iac.orderno
- LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
- <where>
- <if test="vo.userId !=null and vo.userId !=''">
- ifon.first_level_user_id =#{vo.userId}
- </if>
- <if test="vo.ids != null and vo.ids.size()>0 ">
- AND io.userid IN
- <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
- AND iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
- </if>
- </where>
- group by ifon.first_level_user_id
- ) a
- left join (
- select
- sum(IFNULL(second_detail_premiums,0)) as "secondDetailPremiums",
- ifon.two_level_user_id as "twoLevelUserId"
- from ins_area_company iac
- left join ins_orders io on io.orderno = iac.orderno
- LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
- <where>
- <if test="vo.userId !=null and vo.userId !=''">
- ifon.two_level_user_id =#{vo.userId}
- </if>
- <if test="vo.ids != null and vo.ids.size()>0 ">
- AND io.userid IN
- <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
- AND iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
- </if>
- </where>
- group by ifon.two_level_user_id
- ) b on b.twoLevelUserId =a.firstLevelUserId
- left join (
- select
- sum(IFNULL(third_detail_premiums,0)) as "thirdDetailPremiums",
- ifon.three_level_user_id as "threeLevelUserId"
- from ins_area_company iac
- left join ins_orders io on io.orderno = iac.orderno
- LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
- <where>
- <if test="vo.userId !=null and vo.userId !=''">
- ifon.three_level_user_id =#{vo.userId}
- </if>
- <if test="vo.ids != null and vo.ids.size()>0 ">
- AND io.userid IN
- <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
- AND iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
- </if>
- </where>
- group by ifon.three_level_user_id
- ) c on c.threeLevelUserId = a.firstLevelUserId
- </select>
- <select id="findListByDate" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
- SELECT
- iac.*
- FROM ins_area_company as iac
- <where>
- iac.orderstatus = 3
- <if test="benginDate != null and benginDate!='' and endDate != null and endDate!=''">
- AND iac.createtime BETWEEN #{benginDate} AND #{endDate}
- </if>
- </where>
- order by iac.createtime
- </select>
- <select id="getSumEntryStatus" resultType="java.lang.String">
- select count(0)
- from ins_area_company iac
- left join ins_orders io on iac.orderno =io.orderno
- <where>
- iac.entry_status ='2'
- <if test="taskStatisticsVo.userId !=null and taskStatisticsVo.userId != ''">
- and io.userid =#{taskStatisticsVo.userId}
- </if>
- <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
- AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
- </if>
- <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
- 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')
- </if>
- </where>
- </select>
- </mapper>
|