InsAreaCompanyMapper.xml 111 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.ydtech.modules.order.dao.InsAreaCompanyMapper">
  6. <resultMap id="BaseResultMap" type="com.ydtech.modules.order.entity.InsAreaCompany">
  7. <id property="id" column="id" jdbcType="VARCHAR"/>
  8. <result property="reqtxt" column="reqtxt" javaType="com.alibaba.fastjson.JSONObject"
  9. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  10. <result property="reptxt" column="reptxt" javaType="com.alibaba.fastjson.JSONObject"
  11. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  12. <result property="riskinfo" column="riskinfo" javaType="com.alibaba.fastjson.JSONArray"
  13. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  14. <result property="kindinfo" column="kindinfo" javaType="com.alibaba.fastjson.JSONArray"
  15. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  16. <result property="accidentInfo" column="accident_info" javaType="com.alibaba.fastjson.JSONArray"
  17. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  18. <result property="taxArrears" column="tax_arrears" javaType="com.alibaba.fastjson.JSONArray"
  19. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  20. <result property="crossInsurance" column="cross_insurance" javaType="com.alibaba.fastjson.JSONArray"
  21. typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" jdbcType="VARCHAR"/>
  22. <result property="orderno" column="orderno" jdbcType="VARCHAR"/>
  23. <result property="agreementId" column="agreement_id" jdbcType="BIGINT"/>
  24. <result property="apiType" column="api_type" jdbcType="TINYINT"/>
  25. <result property="orderstatus" column="orderstatus" jdbcType="VARCHAR"/>
  26. <result property="companyId" column="company_id" jdbcType="VARCHAR"/>
  27. <result property="inscompany" column="inscompany" jdbcType="VARCHAR"/>
  28. <result property="jqapplyno" column="jqapplyno" jdbcType="VARCHAR"/>
  29. <result property="jqpolicyno" column="jqpolicyno" jdbcType="VARCHAR"/>
  30. <result property="syapplyno" column="syapplyno" jdbcType="VARCHAR"/>
  31. <result property="sypolicyno" column="sypolicyno" jdbcType="VARCHAR"/>
  32. <result property="jqpremium" column="jqpremium" jdbcType="DECIMAL"/>
  33. <result property="sypremium" column="sypremium" jdbcType="DECIMAL"/>
  34. <result property="jypremium" column="jypremium" jdbcType="DECIMAL"/>
  35. <result property="sumpremium" column="sumpremium" jdbcType="DECIMAL"/>
  36. <result property="taxamount" column="taxamount" jdbcType="DECIMAL"/>
  37. <result property="jqdiscountrate" column="jqdiscountrate" jdbcType="DOUBLE"/>
  38. <result property="sydiscountrate" column="sydiscountrate" jdbcType="DOUBLE"/>
  39. <result property="feerate" column="feerate" jdbcType="DOUBLE"/>
  40. <result property="disrate" column="disrate" jdbcType="DOUBLE"/>
  41. <result property="auditid" column="auditid" jdbcType="VARCHAR"/>
  42. <result property="auditname" column="auditname" jdbcType="VARCHAR"/>
  43. <result property="audittime" column="audittime" jdbcType="TIMESTAMP"/>
  44. <result property="auditopinion" column="auditopinion" jdbcType="VARCHAR"/>
  45. <result property="jqappoint" column="jqappoint" jdbcType="VARCHAR"/>
  46. <result property="syappoint" column="syappoint" jdbcType="VARCHAR"/>
  47. <result property="createtime" column="createtime" jdbcType="TIMESTAMP"/>
  48. <result property="payDate" column="pay_date" jdbcType="TIMESTAMP"/>
  49. <result property="paymentLink" column="payment_link" jdbcType="VARCHAR"/>
  50. <result property="insOrderNo" column="ins_order_no" jdbcType="VARCHAR"/>
  51. <result property="attributionId" column="attribution_id" jdbcType="VARCHAR"/>
  52. <result property="jqStartDate" column="jq_start_date" jdbcType="VARCHAR"/>
  53. <result property="jqEndDate" column="jq_end_date" jdbcType="VARCHAR"/>
  54. <result property="syStartDate" column="sy_start_date" jdbcType="VARCHAR"/>
  55. <result property="syEndDate" column="sy_end_date" jdbcType="VARCHAR"/>
  56. <result property="accidentStrInfo" column="accident_str_info" jdbcType="VARCHAR"/>
  57. <result property="score" column="score" jdbcType="VARCHAR"/>
  58. <result property="jqScore" column="jq_score" jdbcType="VARCHAR"/>
  59. <result property="syScore" column="sy_score" jdbcType="VARCHAR"/>
  60. <result property="lossRation" column="loss_ration" jdbcType="DOUBLE"/>
  61. <result property="jqLossRation" column="jq_loss_ration" jdbcType="DOUBLE"/>
  62. <result property="syLossRation" column="sy_loss_ration" jdbcType="DOUBLE"/>
  63. <result property="totalAdjustRate" column="total_adjust_rate" jdbcType="DOUBLE"/>
  64. <result property="jqAdjustRate" column="jq_adjust_rate" jdbcType="DOUBLE"/>
  65. <result property="syAdjustRate" column="sy_adjust_rate" jdbcType="DOUBLE"/>
  66. <result property="insideOrderStatus" column="inside_order_status" jdbcType="TINYINT"/>
  67. <result property="insidePayTime" column="inside_pay_time" jdbcType="TIMESTAMP"/>
  68. <result property="signingTime" column="signing_time" jdbcType="TIMESTAMP"/>
  69. <result property="jqRenewal" column="jq_renewal" jdbcType="VARCHAR"/>
  70. <result property="syRenewal" column="sy_renewal" jdbcType="VARCHAR"/>
  71. <result property="jqClaims" column="jq_claims" jdbcType="VARCHAR"/>
  72. <result property="syClaims" column="sy_claims" jdbcType="VARCHAR"/>
  73. </resultMap>
  74. <resultMap id="InsAreaCompanyQueryDto" type="com.ydtech.modules.order.entity.dto.InsAreaCompanyQueryDto"
  75. extends="BaseResultMap">
  76. <result property="agreementName" column="agreement_name" jdbcType="VARCHAR"/>
  77. <result property="fileStatus" column="fileStatus" jdbcType="VARCHAR"/>
  78. </resultMap>
  79. <sql id="Base_Column_List">
  80. id,orderno,inscompany,
  81. reqtxt,reptxt,jqapplyno,
  82. jqpolicyno,syapplyno,sypolicyno,
  83. riskinfo,kindinfo,jqpremium,
  84. sypremium,taxamount,sumpremium,
  85. jqdiscountrate,sydiscountrate,feerate,
  86. disrate,auditid,auditname,
  87. audittime,auditopinion,jqappoint,
  88. syappoint,createtime,payment_link
  89. </sql>
  90. <select id="selectByOrderNo" resultMap="InsAreaCompanyQueryDto">
  91. SELECT iac.*, pa.agreement_name,
  92. (select IF(count(0)>0,'true','false') from pingan_sh_uploafile where sub_order_no=iac.id AND status=0) as fileStatus
  93. FROM ins_area_company as iac
  94. left join ptl_agreement as pa on pa.id = iac.agreement_id
  95. INNER JOIN (SELECT company_id, max(createtime) AS max_createtime
  96. FROM ins_area_company
  97. WHERE orderno = #{orderNo}
  98. GROUP BY company_id) t ON t.company_id = iac.company_id
  99. AND t.max_createtime = iac.createtime
  100. WHERE iac.orderno = #{orderNo}
  101. </select>
  102. <select id="selectAcceptInsurance" resultMap="InsAreaCompanyQueryDto">
  103. SELECT iac.*, pa.agreement_name,io.is_external,
  104. (select IF(count(0)>0,'true','false') from pingan_sh_uploafile where sub_order_no=iac.id AND status=0) as fileStatus
  105. FROM ins_area_company as iac
  106. left join ptl_agreement as pa on pa.id = iac.agreement_id
  107. left join ins_orders io on iac.orderno=io.orderno
  108. WHERE iac.orderstatus = 3
  109. and iac.orderno = #{orderNo};
  110. </select>
  111. <select id="queryLatestStatus" resultType="java.lang.String">
  112. SELECT iac.orderstatus
  113. FROM ins_area_company as iac
  114. INNER JOIN (SELECT company_id, max(createtime) AS max_createtime
  115. FROM ins_area_company
  116. WHERE orderno = #{orderNo}
  117. GROUP BY company_id) t ON t.company_id = iac.company_id
  118. AND t.max_createtime = iac.createtime
  119. WHERE iac.orderno = #{orderNo}
  120. ORDER BY orderstatus DESC
  121. LIMIT 1
  122. </select>
  123. <select id="getorDerIds" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
  124. SELECT a.id as "id",
  125. a.orderno as "orderno"
  126. FROM ins_area_company a
  127. LEFT JOIN ins_fee_order_new b ON a.id = b.ins_order_no
  128. WHERE a.orderstatus = '3'
  129. or a.orderstatus = '2'
  130. and b.id is not null
  131. </select>
  132. <select id="getAuditOrders" resultType="com.ydtech.modules.order.entity.InsOrders">
  133. SELECT
  134. iac.id as orderno,
  135. io.quoteno,
  136. io.orderstatus,
  137. io.company_id,
  138. io.ins_company,
  139. io.carinfo,
  140. io.userid,
  141. io.username,
  142. io.deptid,
  143. io.deptname,
  144. io.agreeid,
  145. iac.productid,
  146. iac.product,
  147. iac.createtime,
  148. io.frameno,
  149. io.licenseno,
  150. JSON_UNQUOTE(json_extract(io.insureinfo, '$.name')) as insuredname,
  151. io.is_external,
  152. iac.jq_start_date as jqstartdate,
  153. iac.jq_end_date as jqenddate,
  154. iac.sy_start_date as systartdate,
  155. iac.sy_end_date as syenddate,
  156. io.vehicle_and_vessel_tax,
  157. io.operatorid,
  158. iac.operator_name,
  159. sd.management_source,
  160. iac.problem_order,
  161. CASE ifa.audituser
  162. WHEN '自动审核' THEN ifa.audituser
  163. ELSE su2.name END
  164. AS auditUser,
  165. CASE ifa.audituser
  166. WHEN '自动审核' THEN '2'
  167. ELSE '1' END
  168. AS checkType,
  169. ifa.audittime as auditTime,
  170. ifa.auditstatus as auditStatus,
  171. eic.namesimple as partnerCompaniesName,
  172. iac.id as subOrderId,
  173. iac.signing_time as signingTime,
  174. iac.pay_date as payDate,
  175. pa.agreement_code as agreementCode,
  176. pa.agreement_name as agreementName,
  177. pa.business_description as businessDescription,
  178. pa.job_description as jobDescription,
  179. pa.agreement_title as agreementTitle,
  180. pa.docking_person as dockingPerson,
  181. io.entry_status
  182. FROM
  183. ins_fee_audit ifa
  184. LEFT JOIN ins_orders io ON io.orderno = ifa.orderno
  185. LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
  186. AND iac.orderstatus = 3
  187. LEFT JOIN sys_user su ON su.id = io.userid
  188. LEFT JOIN sys_dept sd ON sd.id = su.dept_id
  189. LEFT JOIN sys_user su2 ON ifa.audituser = su2.id
  190. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  191. LEFT JOIN esm_ins_company eic ON eic.id = pa.partner_companies_id
  192. WHERE
  193. iac.id = ifa.ins_order_no
  194. AND iac.orderstatus = 3
  195. <if test="params.auditStatus != null and params.auditStatus != ''">
  196. and ifa.auditstatus = #{params.auditStatus}
  197. </if>
  198. <if test="params.quoteStartDateStr != null and params.quoteStartDateStr != '' and params.quoteEndDateStr != null and params.quoteEndDateStr != ''">
  199. and DATE_FORMAT(iac.createtime, '%Y-%m-%d') between #{params.quoteStartDateStr} AND
  200. #{params.quoteEndDateStr}
  201. </if>
  202. <if test="params.orderNo != null and params.orderNo != ''">
  203. AND iac.id= #{params.orderNo}
  204. </if>
  205. <if test="params.licenseNo != null and params.licenseNo != ''">
  206. AND io.licenseno = #{params.licenseNo}
  207. </if>
  208. <if test="params.frameNo != null and params.frameNo != ''">
  209. AND io.frameno = #{params.frameNo}
  210. </if>
  211. <if test="params.insuredName != null and params.insuredName != ''">
  212. AND json_extract(io.insureinfo, '$.name') = #{params.insuredName}
  213. </if>
  214. <if test="params.companyId != null and params.companyId != ''">
  215. AND io.company_id = #{params.companyId}
  216. </if>
  217. <if test="params.engineNo != null and params.engineNo != ''">
  218. and JSON_EXTRACT( io.carinfo, '$.engineNo' ) = #{params.engineNo}
  219. </if>
  220. <if test="params.riskCode != null and params.riskCode != ''">
  221. and iac.product = #{params.riskCode}
  222. </if>
  223. <if test="params.attachStartDateStr != null and params.attachStartDateStr != '' and params.attachStartDateStr != null and params.attachStartDateStr != '' ">
  224. and ((
  225. DATE_FORMAT(iac.jq_start_date, '%Y-%m-%d') BETWEEN #{params.attachStartDateStr}
  226. AND #{params.attachEndDateStr}
  227. )
  228. OR ( DATE_FORMAT(iac.sy_start_date, '%Y-%m-%d') BETWEEN #{params.attachStartDateStr} AND
  229. #{params.attachEndDateStr} )
  230. )
  231. </if>
  232. <if test="params.provinceId != null and params.provinceId != ''">
  233. and io.deptid like "${params.provinceId}%"
  234. </if>
  235. <if test="params.problemOrder != null and params.problemOrder != ''">
  236. and iac.problem_order like "${params.problemOrder}%"
  237. </if>
  238. <if test="params.cityId != null and params.cityId != ''">
  239. and io.deptid like "${params.cityId}%"
  240. </if>
  241. <if test="params.countyId != null and params.countyId != ''">
  242. and io.deptid like "${params.countyId}%"
  243. </if>
  244. <if test="params.houseId != null and params.houseId != ''">
  245. and io.deptid like "${params.houseId}%"
  246. </if>
  247. <if test="params.operatorId != null and params.operatorId != ''">
  248. and io.userid = #{params.operatorId}
  249. </if>
  250. <if test="params.operatorName != null and params.operatorName != ''">
  251. and io.username = #{params.operatorName}
  252. </if>
  253. <if test="params.auditId != null and params.auditId != ''">
  254. and iac.new_operator_id = #{params.auditId}
  255. </if>
  256. <if test="params.agreeId != null and params.agreeId != ''">
  257. and iac.agreement_id = #{params.agreeId}
  258. </if>
  259. <if test="params.managementSource != null and params.managementSource != ''">
  260. and sd.management_source = #{params.managementSource}
  261. </if>
  262. <if test="params.signStartDateStr != null and params.signStartDateStr != '' and params.signEndDateStr != null and params.signEndDateStr != ''">
  263. and DATE_FORMAT(iac.signing_time, '%Y-%m-%d') between #{params.signStartDateStr} AND
  264. #{params.signEndDateStr}
  265. </if>
  266. <if test="params.payStartDateStr != null and params.payStartDateStr != '' and params.payEndDateStr != null and params.payEndDateStr != ''">
  267. and DATE_FORMAT(iac.pay_date, '%Y-%m-%d') between #{params.payStartDateStr} AND #{params.payEndDateStr}
  268. </if>
  269. <if test="params.isExternal != null and params.isExternal != ''">
  270. and io.is_external = #{params.isExternal}
  271. </if>
  272. <if test="params.jqPolicyNo != null and params.jqPolicyNo != ''">
  273. and iac.jqpolicyno = #{params.jqPolicyNo}
  274. </if>
  275. <if test="params.syPolicyNo != null and params.syPolicyNo != ''">
  276. and iac.sypolicyno = #{params.syPolicyNo}
  277. </if>
  278. <if test="params.noPolicyNo != null and params.noPolicyNo != ''">
  279. and iac.cross_insurance like concat('%', #{params.noPolicyNo}, '%')
  280. </if>
  281. <if test="params.checkUser != null and params.checkUser != ''">
  282. and CASE ifa.audituser WHEN '自动审核' THEN ifa.audituser
  283. ELSE su2.name END = #{params.checkUser}
  284. </if>
  285. <if test="params.checkType != null and params.checkType != ''">
  286. and CASE ifa.audituser
  287. WHEN '自动审核' THEN '2'
  288. ELSE '1' END = #{params.checkType}
  289. </if>
  290. order by iac.createtime desc
  291. </select>
  292. <select id="getByUserId" resultType="com.ydtech.modules.order.entity.InsOrders">
  293. SELECT
  294. io.*,
  295. sd.management_source
  296. FROM
  297. ins_orders io left join sys_user su on su.id = io.userid left join sys_dept sd on sd.id = su.dept_id
  298. WHERE
  299. orderno IN (
  300. SELECT
  301. orderno
  302. FROM
  303. ins_area_company
  304. WHERE
  305. id IN ( SELECT ins_order_no FROM ins_fee_order_new WHERE id NOT IN ( SELECT ins_order_no FROM ins_fee_audit ) )
  306. AND orderstatus = 3
  307. )
  308. AND
  309. io.orderstatus= 3
  310. <if test="orderNo != null and orderNo != ''">
  311. AND orderno = #{orderNo}
  312. </if>
  313. <if test="licenseNo != null and licenseNo != ''">
  314. AND licenseno = #{licenseNo}
  315. </if>
  316. <if test="frameNo != null and frameNo != ''">
  317. AND frameno = #{frameNo}
  318. </if>
  319. <if test="userId != null and userId != ''">
  320. AND userid = #{userId}
  321. </if>
  322. <if test="insuredname != null and insuredname != ''">
  323. AND insuredname = #{insuredname}
  324. </if>
  325. <if test="startDateStr != null and startDateStr != ''">
  326. AND createtime BETWEEN #{startDateStr} and #{endDateStr}
  327. </if>
  328. </select>
  329. <select id="selectFirstPromotionBy" resultType="com.ydtech.modules.order.entity.InsOrders">
  330. SELECT
  331. sum(a.first_detail_premiums) as "willFirstPremiums"
  332. FROM
  333. ins_fee_order_new a
  334. LEFT JOIN ins_area_company iac on iac.id=a.ins_order_no
  335. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  336. WHERE
  337. iff.auditstatus=0
  338. AND iac.orderstatus =3
  339. <if test="firstUserId != null and firstUserId != ''">
  340. AND a.first_level_user_id = #{firstUserId}
  341. </if>
  342. <if test="secondUserId != null and secondUserId != ''">
  343. AND a.two_level_user_id = #{secondUserId}
  344. </if>
  345. <if test="thirdUserId != null and thirdUserId != ''">
  346. AND a.three_level_user_id = #{thirdUserId}
  347. </if>
  348. <if test="id != null and id != ''">
  349. AND a.id = #{id}
  350. </if>
  351. </select>
  352. <select id="selectSecondPromotionBy" resultType="com.ydtech.modules.order.entity.InsOrders">
  353. SELECT
  354. sum( fee.p ) as "willFirstPremiums"
  355. FROM
  356. (
  357. SELECT
  358. sum( a.first_detail_premiums ) AS p
  359. FROM
  360. ins_fee_order_new a
  361. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  362. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  363. <where>
  364. iff.auditstatus=0
  365. and iac.orderstatus = '3'
  366. <if test="userId!=null and userId!= ''">
  367. AND a.first_level_user_id = #{userId}
  368. </if>
  369. <if test="id != null and id!=''">
  370. AND a.id =#{id}
  371. </if>
  372. </where>
  373. UNION
  374. SELECT
  375. sum( a.third_detail_premiums ) AS p
  376. FROM
  377. ins_fee_order_new a
  378. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  379. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  380. <where>
  381. iff.auditstatus=0
  382. and iac.orderstatus = '3'
  383. <if test="userId!=null and userId!= ''">
  384. AND a.three_level_user_id = #{userId}
  385. </if>
  386. <if test="id != null and id!=''">
  387. AND a.id =#{id}
  388. </if>
  389. </where>
  390. UNION
  391. SELECT
  392. sum( a.second_detail_premiums ) AS p
  393. FROM
  394. ins_fee_order_new a
  395. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  396. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  397. <where>
  398. iff.auditstatus=0
  399. and iac.orderstatus = '3'
  400. <if test="userId!=null and userId!= ''">
  401. AND a.two_level_user_id = #{userId}
  402. </if>
  403. <if test="id != null and id!=''">
  404. AND a.id =#{id}
  405. </if>
  406. </where>
  407. ) AS fee
  408. </select>
  409. <select id="selectThirdPromotionBy" resultType="com.ydtech.modules.order.entity.InsOrders">
  410. SELECT
  411. sum(a.third_detail_premiums) as "willThreePremiums"
  412. FROM
  413. ins_fee_order_new a
  414. LEFT JOIN ins_area_company iac on iac.id=a.ins_order_no
  415. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  416. WHERE
  417. iff.auditstatus=0
  418. AND iac.orderstatus =3
  419. <if test="firstUserId != null and firstUserId != ''">
  420. AND a.first_level_user_id = #{firstUserId}
  421. </if>
  422. <if test="secondUserId != null and secondUserId != ''">
  423. AND a.two_level_user_id = #{secondUserId}
  424. </if>
  425. <if test="thirdUserId != null and thirdUserId != ''">
  426. AND a.three_level_user_id = #{thirdUserId}
  427. </if>
  428. <if test="id != null and id != ''">
  429. AND a.id = #{id}
  430. </if>
  431. </select>
  432. <select id="getAlreadyAuditOrders" resultType="com.ydtech.modules.order.entity.InsOrders">
  433. SELECT
  434. io.*,
  435. sd.management_source,
  436. su2.name AS auditUser,
  437. ifa.audittime as auditTime
  438. FROM
  439. ins_orders io
  440. LEFT JOIN ins_fee_audit ifa ON ifa.orderno = io.orderno
  441. LEFT JOIN sys_user su ON su.id = io.userid
  442. LEFT JOIN sys_dept sd ON sd.id = su.dept_id
  443. LEFT JOIN sys_user su2 on ifa.audituser = su2.id
  444. WHERE
  445. io.orderno IN (
  446. SELECT
  447. orderno
  448. FROM
  449. ins_area_company
  450. WHERE
  451. id IN (
  452. SELECT
  453. ifon.ins_order_no
  454. FROM
  455. ins_fee_order_new ifon
  456. RIGHT JOIN ins_fee_audit ifa ON ifon.ins_order_no = ifa.ins_order_no
  457. WHERE
  458. ifa.auditstatus = #{params.auditStatus}
  459. )
  460. )
  461. AND orderstatus = 3
  462. <!-- <if test="params.orderNo != null and params.orderNo != ''">-->
  463. <!-- AND orderno = #{params.orderNo}-->
  464. <!-- </if>-->
  465. <if test="params.licenseNo != null and params.licenseNo != ''">
  466. AND licenseno = #{params.licenseNo}
  467. </if>
  468. <if test="params.frameNo != null and params.frameNo != ''">
  469. AND frameno = #{params.frameNo}
  470. </if>
  471. <if test="params.insuredName != null and params.insuredName != ''">
  472. AND insuredname = #{params.insuredName}
  473. </if>
  474. <if test="params.companyId != null and params.companyId != ''">
  475. AND company_id = #{params.companyId}
  476. </if>
  477. <if test="params.startDateStr != null and params.startDateStr != ''">
  478. AND createtime BETWEEN #{params.startDateStr} and #{params.endDateStr}
  479. </if>
  480. </select>
  481. <select id="selectListByDateStr" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
  482. -- 查询订单信息
  483. SELECT
  484. iac.*
  485. FROM
  486. ins_area_company iac
  487. left JOIN ins_orders AS io ON io.orderno = iac.orderno
  488. WHERE
  489. 1=1
  490. <if test="dateStr != null and dateStr != ''">
  491. AND DATE_FORMAT(io.createtime, '%Y-%m') =#{dateStr}
  492. </if>
  493. </select>
  494. <select id="selectListById" resultMap="BaseResultMap">
  495. SELECT
  496. iac.*
  497. FROM
  498. ins_area_company iac
  499. WHERE
  500. 1=1
  501. <if test="id != null and id != ''">
  502. AND iac.id =#{id}
  503. </if>
  504. </select>
  505. <select id="selectSecondPromotionByNew" resultType="com.ydtech.modules.order.entity.InsOrders">
  506. SELECT
  507. sum( fee.p ) as "willFirstPremiums"
  508. FROM
  509. (
  510. SELECT
  511. sum( a.first_detail_premiums ) AS p
  512. FROM
  513. ins_fee_order_new a
  514. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  515. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  516. <where>
  517. <choose>
  518. <when test='type == "1"'>
  519. iff.auditstatus=0
  520. </when>
  521. <otherwise>
  522. iff.auditstatus=1
  523. </otherwise>
  524. </choose>
  525. and iac.orderstatus = '3'
  526. <if test="userId!=null and userId!= ''">
  527. AND a.first_level_user_id = #{userId}
  528. </if>
  529. <if test="id != null and id!=''">
  530. AND a.id =#{id}
  531. </if>
  532. </where>
  533. UNION
  534. SELECT
  535. sum( a.third_detail_premiums ) AS p
  536. FROM
  537. ins_fee_order_new a
  538. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  539. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  540. <where>
  541. <choose>
  542. <when test='type == "1"'>
  543. iff.auditstatus=0
  544. </when>
  545. <otherwise>
  546. iff.auditstatus=1
  547. </otherwise>
  548. </choose>
  549. and iac.orderstatus = '3'
  550. <if test="userId!=null and userId!= ''">
  551. AND a.three_level_user_id = #{userId}
  552. </if>
  553. <if test="id != null and id!=''">
  554. AND a.id =#{id}
  555. </if>
  556. </where>
  557. UNION
  558. SELECT
  559. sum( a.second_detail_premiums ) AS p
  560. FROM
  561. ins_fee_order_new a
  562. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  563. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  564. <where>
  565. <choose>
  566. <when test='type == "1"'>
  567. iff.auditstatus=0
  568. </when>
  569. <otherwise>
  570. iff.auditstatus=1
  571. </otherwise>
  572. </choose>
  573. and iac.orderstatus = '3'
  574. <if test="userId!=null and userId!= ''">
  575. AND a.two_level_user_id = #{userId}
  576. </if>
  577. <if test="id != null and id!=''">
  578. AND a.id =#{id}
  579. </if>
  580. </where>
  581. ) AS fee
  582. </select>
  583. <select id="getSubOrderDetails" resultType="com.ydtech.modules.admin.model.vo.SubOrder">
  584. SELECT
  585. iac.id as subOrderId,
  586. iac.signing_time as signingTime,
  587. iac.jqpremium as jqpremium,
  588. iac.sypremium as sypremium,
  589. iac.jypremium as jypremium,
  590. io.licenseno as licenseno,
  591. io.userid as userId
  592. FROM
  593. ins_area_company iac
  594. LEFT JOIN ins_orders AS io ON io.orderno = iac.orderno
  595. WHERE
  596. iac.id=#{subOrderId}
  597. </select>
  598. <select id="premiumReportYear" resultType="com.ydtech.modules.admin.model.dto.PremiumReportDto">
  599. SELECT
  600. CONCAT(YEAR(iac.createtime),'-',LPAD(MONTH(iac.createtime), 2, '0')) reportDate,
  601. sum(jqpremium) jqpremium,
  602. sum(sypremium) sypremium,
  603. sum(sumpremium) sumpremium
  604. FROM
  605. ins_area_company iac left join ins_orders io on iac.orderno=io.orderno
  606. WHERE
  607. iac.orderstatus = 3 and
  608. iac.createtime &gt;= #{beginTime} and iac.createtime &lt;= #{endTime}
  609. and io.userid=#{userId}
  610. GROUP BY CONCAT(YEAR(iac.createtime),'-',LPAD(MONTH(iac.createtime), 2, '0'))
  611. </select>
  612. <select id="premiumReportMonth" resultType="com.ydtech.modules.admin.model.dto.PremiumReportDto">
  613. SELECT
  614. CONCAT(YEAR(iac.createtime),'-',LPAD(MONTH(iac.createtime), 2, '0'),'-',LPAD(Day(iac.createtime), 2, '0')) reportDate,
  615. sum(jqpremium) jqpremium,
  616. sum(sypremium) sypremium,
  617. sum(sumpremium) sumpremium
  618. FROM
  619. ins_area_company iac left join ins_orders io on iac.orderno=io.orderno
  620. WHERE
  621. iac.orderstatus = 3 and
  622. iac.createtime &gt;= #{beginTime} and iac.createtime &lt;= #{endTime}
  623. and io.userid=#{userId}
  624. GROUP BY CONCAT(YEAR(iac.createtime),'-',LPAD(MONTH(iac.createtime), 2, '0'),'-',LPAD(Day(iac.createtime), 2, '0'))
  625. </select>
  626. <select id="premiumReportDay" resultType="com.ydtech.modules.admin.model.dto.PremiumReportDto">
  627. SELECT
  628. CONCAT(YEAR ( iac.createtime ),'-',LPAD( MONTH ( iac.createtime ), 2, '0' ),'-',LPAD( DAY ( iac.createtime ), 2, '0' ),' ',LPAD( HOUR ( iac.createtime ), 2, '0' ))
  629. reportDate,
  630. sum( jqpremium ) jqpremium,
  631. sum( sypremium ) sypremium,
  632. sum( sumpremium ) sumpremium
  633. FROM
  634. ins_area_company iac left join ins_orders io on iac.orderno=io.orderno
  635. WHERE
  636. iac.orderstatus = 3 and
  637. iac.createtime &gt;= #{beginTime} and iac.createtime &lt;= #{endTime}
  638. and io.userid=#{userId}
  639. GROUP BY CONCAT(YEAR ( iac.createtime ),'-',LPAD( MONTH ( iac.createtime ), 2, '0' ),'-',LPAD( DAY ( iac.createtime ), 2, '0' ),' ',LPAD( HOUR ( iac.createtime ), 2, '0' ))
  640. </select>
  641. <select id="getAllpremium" resultType="com.ydtech.modules.admin.model.dto.AllpremiumDto">
  642. SELECT
  643. ifnull(sum( iac.jqpremium + iac.sypremium + iac.jypremium ),0) as sumPremium,
  644. count( 0 ) as sumCount
  645. FROM
  646. ins_area_company iac left join ins_orders io on iac.orderno=io.orderno
  647. WHERE
  648. iac.orderstatus = 3
  649. and io.userid=#{userId}
  650. AND YEAR (iac.createtime) = #{year}
  651. </select>
  652. <select id="getRejectOrder" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
  653. select
  654. iac.id,
  655. iac.orderno,
  656. iac.agreement_id,
  657. iac.jqpremium,
  658. iac.sypremium,
  659. iac.jypremium,
  660. iac.taxamount,
  661. iac.sumpremium,
  662. io.licenseno,
  663. ifa.audittime,
  664. ifa.audituser as auditname,
  665. ifa.rejectinfo,
  666. "1" as orderExternalStatus
  667. FROM
  668. ins_fee_audit ifa
  669. LEFT JOIN
  670. ins_area_company iac on iac.id = ifa.ins_order_no
  671. LEFT JOIN
  672. ins_orders io on iac.orderno = io.orderno
  673. left join
  674. sys_user su on su.id= ifa.audituser
  675. WHERE
  676. iac.operator_id = #{userId}
  677. AND
  678. ifa.auditstatus = 2 and IFNULL(iac.del_flag,'') != '0'
  679. <if test="vo.id != null and vo.id!=''">
  680. and iac.id = #{vo.id}
  681. </if>
  682. <if test="vo.licenseno != null and vo.licenseno!='' ">
  683. and io.licenseno like CONCAT('%', #{vo.licenseno}, '%')
  684. </if>
  685. <if test="vo.auditname != null and vo.auditname!='' ">
  686. and su.name like CONCAT('%', #{vo.auditname}, '%')
  687. </if>
  688. </select>
  689. <select id="queryBusinessDataPage"
  690. resultType="com.ydtech.modules.admin.model.report.opetationData.BusinessDataDto">
  691. SELECT
  692. <if test="flag != null and flag!='' and flag='1'">
  693. o.userid as userId,
  694. o.username as userName,
  695. </if>
  696. sum( iac.sumpremium ) as signeSumPremiumAmount,
  697. sum( iac.jqpremium ) as jqPremiumAmount,
  698. sum( iac.sypremium ) as syPremiumAmount,
  699. sum( iac.taxamount ) as taxAmount,
  700. sum( ion.no_premium ) as fcFeeAmount
  701. FROM
  702. ins_area_company iac
  703. LEFT JOIN ins_orders o ON iac.orderno = o.orderno
  704. LEFT JOIN ins_fee_order_new ion ON iac.id = ion.ins_order_no
  705. where iac.orderstatus = 3 and ion.id is not null
  706. <if test="userList != null and userList.size()>0 ">
  707. and o.userid IN
  708. <foreach item="item" collection="userList" open="(" separator="," close=")">
  709. #{item}
  710. </foreach>
  711. </if>
  712. <if test="flag != null and flag!='' and flag='1'">
  713. group by o.userid,o.username
  714. </if>
  715. </select>
  716. <select id="queryQuotationSubOrderCountDataPage"
  717. resultType="com.ydtech.modules.admin.model.report.opetationData.QuotationCountDataDto">
  718. SELECT
  719. <if test="flag != null and flag!='' and flag='1'">
  720. o.userid as userId,
  721. o.username as userName,
  722. </if>
  723. iac.orderstatus as orderStatus
  724. FROM
  725. ins_area_company iac
  726. LEFT JOIN ins_orders o ON iac.orderno = o.orderno
  727. where (iac.orderstatus = 0 or iac.orderstatus = 2 or iac.orderstatus = 3 )
  728. <if test="userList != null and userList.size()>0 ">
  729. and o.userid IN
  730. <foreach item="item" collection="userList" open="(" separator="," close=")">
  731. #{item}
  732. </foreach>
  733. </if>
  734. <if test="flag != null and flag!='' and flag='1'">
  735. group by o.userid,o.username,iac.orderstatus
  736. </if>
  737. </select>
  738. <select id="queryQuotationOrderCountDataPage"
  739. resultType="com.ydtech.modules.admin.model.report.opetationData.QuotationCountDataDto">
  740. SELECT
  741. a.userId as userId,
  742. a.userName as userName,
  743. b.qutationCount AS insOrderQutationCount,
  744. b.qutationInsureCount as insOrderQutationInsureCount,
  745. b.closeRate AS insOrderCloseRate as insOrderCloseRate,
  746. a.qutationCount as subOrderQutationCount,
  747. a.underwritingCount as subOrderUnderwritingCount,
  748. a.qutationInsureCount as subOrderQutationInsureCount,
  749. a.passRate as subOrderCloseRate,
  750. a.closeRate as subOrderPassRate,
  751. a.contributionRate as subOrderContributionRate
  752. FROM
  753. (
  754. SELECT
  755. inso.userid AS userId,
  756. inso.username AS userName,
  757. COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS qutationCount,
  758. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
  759. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  760. COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END )/ count( iac.orderstatus ) AS passRate,
  761. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )/ count( iac.orderstatus ) AS closeRate,
  762. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )/ COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS contributionRate
  763. FROM
  764. ins_area_company iac
  765. LEFT JOIN ins_orders inso ON iac.orderno = inso.orderno
  766. <where>
  767. <if test="userList != null and userList.size()>0 ">
  768. and o.userid IN
  769. <foreach item="item" collection="userList" open="(" separator="," close=")">
  770. #{item}
  771. </foreach>
  772. </if>
  773. </where>
  774. GROUP BY
  775. inso.userid,
  776. inso.username
  777. ) a
  778. LEFT JOIN (
  779. SELECT
  780. inso.userid AS userId,
  781. inso.username AS userName,
  782. count( inso.orderstatus ) AS qutationCount,
  783. count( CASE WHEN inso.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  784. COUNT( CASE WHEN inso.orderstatus = 3 THEN 1 END )/ count( inso.orderstatus ) AS closeRate
  785. FROM
  786. ins_orders inso
  787. <where>
  788. <if test="userList != null and userList.size()>0 ">
  789. and o.userid IN
  790. <foreach item="item" collection="userList" open="(" separator="," close=")">
  791. #{item}
  792. </foreach>
  793. </if>
  794. </where>
  795. GROUP BY
  796. inso.userid,
  797. inso.username
  798. ) b ON a.userId = b.userId
  799. </select>
  800. <select id="queryCompanyPremiumDataPage"
  801. resultType="com.ydtech.modules.admin.model.report.company.CompanyPremiumDataDto">
  802. SELECT
  803. agree.insurance_company_id AS companyId,
  804. agree.insurance_company AS companyName,
  805. agree.partner_companies_id AS parterCompanyId,
  806. ins.NAME AS parterCompanyName,
  807. sum( iac.sumpremium ) AS signeSumPremiumAmount
  808. FROM
  809. ins_area_company iac
  810. LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
  811. LEFT JOIN esm_ins_company ins ON agree.partner_companies_id = ins.id
  812. WHERE
  813. iac.orderstatus = 3
  814. and
  815. agree.id is not null
  816. <if test="vo.companyId != null and vo.companyId!='' ">
  817. agree.insurance_company_id = #{vo.companyId}
  818. </if>
  819. <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
  820. agree.insurance_company_id = #{vo.parterCompanyId}
  821. </if>
  822. GROUP BY
  823. agree.insurance_company_id,
  824. agree.insurance_company,
  825. agree.partner_companies_id,
  826. ins.NAME
  827. </select>
  828. <select id="queryCompanyQutationCountDataPage"
  829. resultType="com.ydtech.modules.admin.model.report.company.CompanyQutationCountDataDto">
  830. SELECT
  831. a.* ,
  832. (select ins.namesimple from esm_ins_company
  833. ins where a.parterCompanyId = ins.id) as "parterCompanyName"
  834. FROM
  835. (
  836. SELECT
  837. count(agree.partner_companies_id) as "orderSuccessNumber",
  838. agree.insurance_company AS companyName,
  839. agree.partner_companies_id AS parterCompanyId,
  840. iac.company_id as "companyId",
  841. count( iac.orderstatus ) AS qutationCount,
  842. count( iac.id ) AS orderSuccessNumberRate,
  843. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) + COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS underwritingCount,
  844. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  845. (COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) + COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )) / count( iac.orderstatus ) AS passRate,
  846. 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,
  847. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )/ count( iac.orderstatus ) AS contributionRate,
  848. COUNT(CASE WHEN agree.audit_type =1 and ifa.auditstatus =1 and iac.orderstatus =3 THEN 1 END) as "numberManual"
  849. FROM
  850. ins_area_company iac
  851. LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
  852. LEFT JOIN ins_orders io ON iac.orderno = io.orderno
  853. LEFT JOIN sys_dept sd ON sd.id = io.deptid
  854. LEFT JOIN ins_fee_audit ifa on ifa.ins_order_no =iac.id
  855. WHERE
  856. agree.id IS NOT NULL
  857. <if test="vo.companyId != null and vo.companyId!='' ">
  858. AND agree.insurance_company_id = #{vo.companyId}
  859. </if>
  860. <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
  861. AND agree.partner_companies_id = #{vo.parterCompanyId}
  862. </if>
  863. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  864. AND iac.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  865. </if>
  866. <if test="vo.managementSource != null and vo.managementSource!=''">
  867. AND sd.management_source =#{vo.managementSource}
  868. </if>
  869. <if test="vo.userId != null and vo.userId !=''">
  870. AND io.userid =#{vo.userId}
  871. </if>
  872. <if test="vo.deptId != null and vo.deptId !=''">
  873. AND io.deptId like concat('%',#{vo.leaderName},'%')
  874. </if>
  875. <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
  876. AND sd.id in
  877. <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
  878. #{item}
  879. </foreach>
  880. </if>
  881. <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
  882. AND io.userid in
  883. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  884. #{item}
  885. </foreach>
  886. </if>
  887. GROUP BY
  888. agree.insurance_company,
  889. iac.company_id,
  890. agree.partner_companies_id
  891. ) a
  892. order by a.parterCompanyId
  893. </select>
  894. <select id="getInsAreaCompanyError"
  895. resultType="com.ydtech.modules.admin.model.report.company.CompanyQutationCountDataDto">
  896. SELECT
  897. count(iace.id) as "areaCompanyErrNumber"
  898. FROM
  899. ins_area_company_error iace
  900. LEFT JOIN ptl_agreement agree ON iace.agreement_id = agree.id
  901. <where>
  902. 1=1
  903. <if test="vo.companyId != null and vo.companyId!='' ">
  904. AND agree.insurance_company_id = #{vo.companyId}
  905. </if>
  906. <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
  907. AND agree.partner_companies_id = #{vo.parterCompanyId}
  908. </if>
  909. <if test="vo.userId != null and vo.userId!=''">
  910. AND iace.user_id =#{vo.userId}
  911. </if>
  912. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  913. AND iace.create_time BETWEEN #{vo.beginDate} AND #{vo.endDate}
  914. </if>
  915. <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
  916. AND iace.dept_id in
  917. <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
  918. #{item}
  919. </foreach>
  920. </if>
  921. <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
  922. AND iace.user_id in
  923. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  924. #{item}
  925. </foreach>
  926. </if>
  927. </where>
  928. </select>
  929. <select id="queryCompanyQutationCountDataPageTotal"
  930. resultType="java.lang.Long">
  931. SELECT
  932. count(0)
  933. FROM
  934. (
  935. SELECT
  936. agree.partner_companies_id
  937. FROM
  938. ins_area_company iac
  939. LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
  940. LEFT JOIN ins_orders io ON iac.orderno = io.orderno
  941. LEFT JOIN sys_dept sd ON sd.id = io.deptid
  942. WHERE
  943. agree.id IS NOT NULL
  944. <if test="vo.companyId != null and vo.companyId!='' ">
  945. AND agree.insurance_company_id = #{vo.companyId}
  946. </if>
  947. <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
  948. AND agree.partner_companies_id = #{vo.parterCompanyId}
  949. </if>
  950. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  951. AND iac.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  952. </if>
  953. <if test="vo.managementSource != null and vo.managementSource!=''">
  954. AND sd.management_source =#{vo.managementSource}
  955. </if>
  956. <if test="vo.userId != null and vo.userId !=''">
  957. AND io.userid =#{vo.userId}
  958. </if>
  959. <if test="vo.deptId != null and vo.deptId !=''">
  960. AND io.deptId like concat('%',#{vo.leaderName},'%')
  961. </if>
  962. <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
  963. AND sd.id in
  964. <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
  965. #{item}
  966. </foreach>
  967. </if>
  968. <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
  969. AND io.userid in
  970. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  971. #{item}
  972. </foreach>
  973. </if>
  974. GROUP BY
  975. agree.partner_companies_id
  976. ) a
  977. </select>
  978. <select id="getStageOrder" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
  979. select
  980. iac.id,
  981. iac.orderno,
  982. iac.agreement_id,
  983. iac.jqpremium,
  984. iac.sypremium,
  985. iac.jypremium,
  986. iac.taxamount,
  987. iac.sumpremium,
  988. io.licenseno,
  989. iac.createtime,
  990. "0" as orderExternalStatus
  991. FROM
  992. ins_area_company iac
  993. LEFT JOIN
  994. ins_orders io on iac.orderno = io.orderno
  995. left join ptl_agreement agree on iac.agreement_id =agree.id
  996. WHERE
  997. iac.operator_id = #{userId}
  998. AND
  999. iac.orderstatus = 0
  1000. and agree.is_external =1
  1001. <if test="vo.id != null and vo.id!='' ">
  1002. and iac.id = #{vo.id}
  1003. </if>
  1004. <if test="vo.licenseno != null and vo.licenseno!='' ">
  1005. and io.licenseno like CONCAT('%', #{vo.licenseno}, '%')
  1006. </if>
  1007. </select>
  1008. <select id="queryPageTaskStatistics" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  1009. select a.*, su.name as "userName",
  1010. inf.url as "logo",
  1011. sui.sex as "sex",
  1012. su.leader_name as "leaderName"
  1013. from (
  1014. SELECT
  1015. sd.NAME AS "deptName",
  1016. io.userid AS "userId",
  1017. sd.parent_id as "deptId",
  1018. COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS qutationCount,
  1019. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
  1020. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  1021. COUNT( CASE WHEN iac.orderstatus = 4 THEN 1 END ) AS underwritingReturn,
  1022. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) / COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS "passingRate",
  1023. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) / COUNT( iac.orderstatus ) AS "closeRate",
  1024. (COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) + COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ))/ COUNT( iac.orderstatus ) AS "contributionRate",
  1025. COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) / COUNT( iac.orderstatus ) AS "quotationRate",
  1026. COUNT(CASE WHEN io.order_source = 0 and iac.orderstatus = 0 THEN 1 END) as "pcOrderSource",
  1027. COUNT(CASE WHEN io.order_source = 1 and iac.orderstatus = 0 THEN 1 END) as "appOrderSource",
  1028. COUNT( CASE WHEN iac.orderstatus = 1 THEN 1 END ) AS "auditOrder"
  1029. FROM
  1030. ins_area_company iac
  1031. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  1032. LEFT JOIN sys_dept sd ON sd.id = io.deptid
  1033. <where>
  1034. sd.management_source = '1'
  1035. <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
  1036. and io.deptid like "${taskStatisticsVo.provinceId}%"
  1037. </if>
  1038. <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
  1039. and io.deptid like "${taskStatisticsVo.cityId}%"
  1040. </if>
  1041. <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
  1042. and io.deptid like "${taskStatisticsVo.countyId}%"
  1043. </if>
  1044. <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
  1045. and io.deptid like "${taskStatisticsVo.houseId}%"
  1046. </if>
  1047. <if test="taskStatisticsVo.userId != null and taskStatisticsVo.userId != ''">
  1048. and io.userid =#{taskStatisticsVo.userId}
  1049. </if>
  1050. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1051. AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
  1052. </if>
  1053. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1054. AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
  1055. </if>
  1056. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1057. and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
  1058. </if>
  1059. <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
  1060. AND sd.id in
  1061. <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
  1062. #{item}
  1063. </foreach>
  1064. </if>
  1065. <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
  1066. AND io.userid in
  1067. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  1068. #{item}
  1069. </foreach>
  1070. </if>
  1071. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1072. <choose>
  1073. <when test="taskStatisticsVo.days =='1'">
  1074. and io.createtime >= DATE_SUB(NOW(), INTERVAL 1 DAY)
  1075. </when>
  1076. <when test="taskStatisticsVo.days =='7'">
  1077. and io.createtime >= DATE_SUB(NOW(), INTERVAL 7 DAY)
  1078. </when>
  1079. <when test="taskStatisticsVo.days =='30'">
  1080. and io.createtime >= DATE_SUB(NOW(), INTERVAL 30 DAY)
  1081. </when>
  1082. </choose>
  1083. </if>
  1084. </where>
  1085. GROUP BY
  1086. io.userid,
  1087. sd.NAME,
  1088. sd.id
  1089. ) a
  1090. left join sys_user su on su.id =a.userId
  1091. LEFT JOIN ins_upload_files inf on su.head_sculpture =inf.id
  1092. LEFT JOIN sys_user_info sui on sui .id =su.id
  1093. <where>
  1094. <if test='taskStatisticsVo.userName !=null and taskStatisticsVo.userName!="" '>
  1095. and su.name like concat('%',#{taskStatisticsVo.userName},'%')
  1096. </if>
  1097. <if test='taskStatisticsVo.leaderId !=null and taskStatisticsVo.leaderId!="" '>
  1098. and su.leader_id =#{taskStatisticsVo.leaderId}
  1099. </if>
  1100. <if test='taskStatisticsVo.userId !=null and taskStatisticsVo.userId!="" '>
  1101. and su.id =#{taskStatisticsVo.userId}
  1102. </if>
  1103. </where>
  1104. </select>
  1105. <select id="queryPageTaskStatisticsTotal" resultType="java.lang.Long">
  1106. select count(0) from (
  1107. SELECT
  1108. io.userid
  1109. FROM
  1110. ins_area_company iac
  1111. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  1112. LEFT JOIN sys_dept sd ON sd.id = io.deptid
  1113. <where>
  1114. sd.management_source = '1'
  1115. <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
  1116. and io.deptid like "${taskStatisticsVo.provinceId}%"
  1117. </if>
  1118. <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
  1119. and io.deptid like "${taskStatisticsVo.cityId}%"
  1120. </if>
  1121. <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
  1122. and io.deptid like "${taskStatisticsVo.countyId}%"
  1123. </if>
  1124. <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
  1125. and io.deptid like "${taskStatisticsVo.houseId}%"
  1126. </if>
  1127. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1128. AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
  1129. </if>
  1130. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1131. AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
  1132. </if>
  1133. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1134. and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
  1135. </if>
  1136. <if test="taskStatisticsVo.userId != null and taskStatisticsVo.userId != ''">
  1137. and io.userid =#{taskStatisticsVo.userId}
  1138. </if>
  1139. <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
  1140. AND sd.id in
  1141. <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
  1142. #{item}
  1143. </foreach>
  1144. </if>
  1145. <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
  1146. AND io.userid in
  1147. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  1148. #{item}
  1149. </foreach>
  1150. </if>
  1151. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1152. <choose>
  1153. <when test="taskStatisticsVo.days =='1'">
  1154. and io.createtime >= DATE_SUB(NOW(), INTERVAL 1 DAY)
  1155. </when>
  1156. <when test="taskStatisticsVo.days =='7'">
  1157. and io.createtime >= DATE_SUB(NOW(), INTERVAL 7 DAY)
  1158. </when>
  1159. <when test="taskStatisticsVo.days =='30'">
  1160. and io.createtime >= DATE_SUB(NOW(), INTERVAL 30 DAY)
  1161. </when>
  1162. </choose>
  1163. </if>
  1164. </where>
  1165. GROUP BY
  1166. io.userid
  1167. ) a
  1168. </select>
  1169. <select id="insuranceCompanyQueryPage" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  1170. SELECT
  1171. a.*,
  1172. ( SELECT eic.namesimple FROM esm_ins_company eic WHERE eic.id = a.partner_companies_id ) AS "partnerCompaniesName"
  1173. FROM
  1174. (
  1175. SELECT
  1176. pa.insurance_company_id,
  1177. pa.partner_companies_id,
  1178. pa.insurance_company AS "insuranceCompanyName",
  1179. COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS qutationCount,
  1180. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
  1181. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  1182. COUNT( CASE WHEN iac.orderstatus = 4 THEN 1 END ) AS underwritingReturn,
  1183. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) / COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS "passingRate",
  1184. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) / COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS "closeRate",
  1185. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) / COUNT( iac.orderstatus ) AS "contributionRate",
  1186. COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) / COUNT( iac.orderstatus ) AS "quotationRate",
  1187. COUNT( CASE WHEN ifa.auditstatus = 1 THEN 1 END ) AS "auditOrder"
  1188. FROM
  1189. ins_area_company iac
  1190. LEFT JOIN ins_fee_audit ifa ON ifa.ins_order_no = iac.id
  1191. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  1192. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  1193. <where>
  1194. pa.insurance_company_id IS NOT NULL
  1195. <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
  1196. and io.deptid like concat('%', #{taskStatisticsVo.provinceId}, '%')
  1197. </if>
  1198. <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
  1199. and io.deptid like concat('%', #{taskStatisticsVo.cityId}, '%')
  1200. </if>
  1201. <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
  1202. and io.deptid like concat('%', #{taskStatisticsVo.countyId}, '%')
  1203. </if>
  1204. <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
  1205. and io.deptid like concat('%', #{taskStatisticsVo.houseId}, '%')
  1206. </if>
  1207. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1208. AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
  1209. </if>
  1210. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1211. AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
  1212. </if>
  1213. <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId != ''">
  1214. AND iac.company_id =#{taskStatisticsVo.companyId}
  1215. </if>
  1216. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1217. and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
  1218. </if>
  1219. <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
  1220. AND io.deptid in
  1221. <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
  1222. #{item}
  1223. </foreach>
  1224. </if>
  1225. <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
  1226. AND io.userid in
  1227. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  1228. #{item}
  1229. </foreach>
  1230. </if>
  1231. </where>
  1232. GROUP BY
  1233. pa.insurance_company_id,
  1234. pa.partner_companies_id,
  1235. pa.insurance_company
  1236. ) a
  1237. </select>
  1238. <select id="insuranceCompanyQueryTotal" resultType="java.lang.Long">
  1239. SELECT
  1240. COUNT(0)
  1241. FROM
  1242. (
  1243. SELECT
  1244. pa.insurance_company_id,
  1245. pa.partner_companies_id
  1246. FROM
  1247. ins_area_company iac
  1248. LEFT JOIN ins_fee_audit ifa ON ifa.ins_order_no = iac.id
  1249. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  1250. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  1251. <where>
  1252. pa.insurance_company_id IS NOT NULL
  1253. <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
  1254. and io.deptid like concat('%', #{taskStatisticsVo.provinceId}, '%')
  1255. </if>
  1256. <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
  1257. and io.deptid like concat('%', #{taskStatisticsVo.cityId}, '%')
  1258. </if>
  1259. <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
  1260. and io.deptid like concat('%', #{taskStatisticsVo.countyId}, '%')
  1261. </if>
  1262. <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
  1263. and io.deptid like concat('%', #{taskStatisticsVo.houseId}, '%')
  1264. </if>
  1265. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1266. AND io.createtime BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
  1267. </if>
  1268. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1269. AND iac.createtime BETWEEN #{taskStatisticsVo.beginDate} AND #{taskStatisticsVo.endDate}
  1270. </if>
  1271. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1272. and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
  1273. </if>
  1274. <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
  1275. AND io.deptid in
  1276. <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
  1277. #{item}
  1278. </foreach>
  1279. </if>
  1280. <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
  1281. AND io.userid in
  1282. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  1283. #{item}
  1284. </foreach>
  1285. </if>
  1286. </where>
  1287. GROUP BY
  1288. pa.insurance_company_id,
  1289. pa.partner_companies_id
  1290. ) total
  1291. </select>
  1292. <select id="agentStatisticsQueryPage" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  1293. SELECT
  1294. sd.name as "deptName",
  1295. su.name as "userName",
  1296. io.userid as "userId",
  1297. sd.id as "deptId",
  1298. COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS qutationCount,
  1299. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
  1300. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  1301. COUNT( CASE WHEN iac.orderstatus = 4 THEN 1 END ) AS underwritingReturn,
  1302. (COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) +COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )) / COUNT(iac.orderstatus) as "passingRate",
  1303. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) / COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) as "closeRate",
  1304. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) / COUNT(iac.orderstatus) as "contributionRate",
  1305. COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) / COUNT(iac.orderstatus) as "quotationRate",
  1306. COUNT( CASE WHEN iac.orderstatus = 1 THEN 1 END ) as "auditOrder"
  1307. FROM
  1308. ins_area_company iac
  1309. left join ins_orders io on io.orderno = iac.orderno
  1310. left join sys_dept sd on sd.id=io.deptid
  1311. left join sys_user su on su.id=io.userid
  1312. <where>
  1313. sd.management_source = '2'
  1314. <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
  1315. and io.deptid like "${taskStatisticsVo.provinceId}%"
  1316. </if>
  1317. <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
  1318. and io.deptid like "${taskStatisticsVo.cityId}%"
  1319. </if>
  1320. <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
  1321. and io.deptid like "${taskStatisticsVo.countyId}%"
  1322. </if>
  1323. <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
  1324. and io.deptid like "${taskStatisticsVo.houseId}%"
  1325. </if>
  1326. <if test="taskStatisticsVo.userId !=null and taskStatisticsVo.userId!='' ">
  1327. and io.userid =#{taskStatisticsVo.userId}
  1328. </if>
  1329. <if test='taskStatisticsVo.userName !=null and taskStatisticsVo.userName!="" '>
  1330. and su.name like concat('%',#{taskStatisticsVo.userName},'%')
  1331. </if>
  1332. <if test='taskStatisticsVo.leaderId !=null and taskStatisticsVo.leaderId!="" '>
  1333. and su.leader_id =#{taskStatisticsVo.leaderId}
  1334. </if>
  1335. <if test='taskStatisticsVo.userId !=null and taskStatisticsVo.userId!="" '>
  1336. and su.id =#{taskStatisticsVo.userId}
  1337. </if>
  1338. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1339. AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
  1340. </if>
  1341. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1342. AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
  1343. </if>
  1344. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1345. and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
  1346. </if>
  1347. <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
  1348. AND sd.id in
  1349. <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
  1350. #{item}
  1351. </foreach>
  1352. </if>
  1353. <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
  1354. AND io.userid in
  1355. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  1356. #{item}
  1357. </foreach>
  1358. </if>
  1359. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1360. <choose>
  1361. <when test="taskStatisticsVo.days =='1'">
  1362. and io.createtime >= DATE_SUB(NOW(), INTERVAL 1 DAY)
  1363. </when>
  1364. <when test="taskStatisticsVo.days =='7'">
  1365. and io.createtime >= DATE_SUB(NOW(), INTERVAL 7 DAY)
  1366. </when>
  1367. <when test="taskStatisticsVo.days =='30'">
  1368. and io.createtime >= DATE_SUB(NOW(), INTERVAL 30 DAY)
  1369. </when>
  1370. </choose>
  1371. </if>
  1372. </where>
  1373. GROUP BY io.userid , su.name, sd.id , sd.name
  1374. </select>
  1375. <select id="agentStatisticsQueryPageTotal" resultType="java.lang.Long">
  1376. select count(0) from (
  1377. SELECT
  1378. io.userid as "userId"
  1379. FROM
  1380. ins_area_company iac
  1381. left join ins_orders io on io.orderno = iac.orderno
  1382. left join sys_dept sd on sd.id=io.deptid
  1383. left join sys_user su on su.id=io.userid
  1384. <where>
  1385. sd.management_source = '2'
  1386. <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
  1387. and io.deptid like "${taskStatisticsVo.provinceId}%"
  1388. </if>
  1389. <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
  1390. and io.deptid like "${taskStatisticsVo.cityId}%"
  1391. </if>
  1392. <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
  1393. and io.deptid like "${taskStatisticsVo.countyId}%"
  1394. </if>
  1395. <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
  1396. and io.deptid like "${taskStatisticsVo.houseId}%"
  1397. </if>
  1398. <if test='taskStatisticsVo.userName !=null and taskStatisticsVo.userName!="" '>
  1399. and su.name like concat('%',#{taskStatisticsVo.userName},'%')
  1400. </if>
  1401. <if test='taskStatisticsVo.leaderId !=null and taskStatisticsVo.leaderId!="" '>
  1402. and su.leader_id =#{taskStatisticsVo.leaderId}
  1403. </if>
  1404. <if test='taskStatisticsVo.userId !=null and taskStatisticsVo.userId!="" '>
  1405. and su.id =#{taskStatisticsVo.userId}
  1406. </if>
  1407. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1408. AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
  1409. </if>
  1410. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1411. AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
  1412. </if>
  1413. <if test="taskStatisticsVo.userId !=null and taskStatisticsVo.userId!='' ">
  1414. and io.userid =#{taskStatisticsVo.userId}
  1415. </if>
  1416. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1417. and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
  1418. </if>
  1419. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1420. <choose>
  1421. <when test="taskStatisticsVo.days =='1'">
  1422. and io.createtime >= DATE_SUB(NOW(), INTERVAL 1 DAY)
  1423. </when>
  1424. <when test="taskStatisticsVo.days =='7'">
  1425. and io.createtime >= DATE_SUB(NOW(), INTERVAL 7 DAY)
  1426. </when>
  1427. <when test="taskStatisticsVo.days =='30'">
  1428. and io.createtime >= DATE_SUB(NOW(), INTERVAL 30 DAY)
  1429. </when>
  1430. </choose>
  1431. </if>
  1432. </where>
  1433. GROUP BY io.userid
  1434. ) a
  1435. </select>
  1436. <select id="costCenter" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  1437. SELECT
  1438. iac.company_id,
  1439. iac.inscompany as "insuranceCompanyName",
  1440. COUNT( CASE WHEN ifa.auditstatus = 1 THEN 1 END ) AS "auditstatusOrders",
  1441. COUNT( CASE WHEN ifa.auditstatus = 0 THEN 1 END ) AS "auditOrder",
  1442. COUNT( CASE WHEN ifa.auditstatus = 1 and ifa.audituser != '自动审核' THEN 1 END ) AS "persionAudit",
  1443. COUNT( CASE WHEN ifa.audituser = '自动审核' THEN 1 END ) AS "automaticAudit"
  1444. FROM
  1445. ins_fee_audit ifa
  1446. LEFT JOIN ins_orders io ON io.orderno = ifa.orderno
  1447. LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
  1448. AND iac.orderstatus = 3
  1449. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  1450. LEFT JOIN esm_ins_company eic ON eic.id = pa.partner_companies_id
  1451. <where>
  1452. 1=1
  1453. and iac.id = ifa.ins_order_no
  1454. AND iac.orderstatus = 3
  1455. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1456. AND DATE_FORMAT( ifa.audittime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.createtimeStart}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.createtimeEnd}, '%Y-%m-%d')
  1457. </if>
  1458. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1459. AND DATE_FORMAT( ifa.audittime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
  1460. </if>
  1461. <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
  1462. AND io.deptid in
  1463. <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
  1464. #{item}
  1465. </foreach>
  1466. </if>
  1467. <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
  1468. AND su.id in
  1469. <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
  1470. #{item}
  1471. </foreach>
  1472. </if>
  1473. <choose>
  1474. <when test="taskStatisticsVo.riskCode != null and taskStatisticsVo.riskCode != '' and taskStatisticsVo.riskCode != 'all' ">
  1475. and iac.product = #{taskStatisticsVo.riskCode}
  1476. </when>
  1477. </choose>
  1478. </where>
  1479. GROUP BY
  1480. iac.company_id,
  1481. iac.inscompany
  1482. </select>
  1483. <select id="getOrderManpower" resultType="com.ydtech.modules.admin.model.dto.QxFrontlineAgentDto">
  1484. SELECT
  1485. count( a.numberUserId ) as "orderManpower",
  1486. sum( a.orderAmount ) as "totalPremium",
  1487. sum( a.orderAmount )/ count( a.numberUserId ) as "averagePremium"
  1488. FROM
  1489. (
  1490. SELECT
  1491. count( io.userid ) AS "numberUserId",
  1492. SUM(IFNULL(iac.jqpremium, 0)) +
  1493. SUM(IFNULL(iac.sypremium, 0)) +
  1494. SUM(IFNULL(iac.jypremium, 0)) AS "orderAmount"
  1495. FROM
  1496. `ins_area_company` iac
  1497. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  1498. <where>
  1499. iac.orderstatus = '3'
  1500. <if test="ids != null and ids.size()>0 ">
  1501. AND io.userid IN
  1502. <foreach item="item" collection="ids" open="(" separator="," close=")">
  1503. #{item}
  1504. </foreach>
  1505. </if>
  1506. </where>
  1507. GROUP BY
  1508. io.userid
  1509. ) a
  1510. </select>
  1511. <select id="getOrderManpowerNew" resultType="com.ydtech.modules.admin.model.dto.QxFrontlineAgentDto">
  1512. SELECT
  1513. count( a.numberUserId ) as "orderManpower",
  1514. IFNULL(sum( a.orderAmount ),0) as "totalPremium",
  1515. ROUND(sum( a.orderAmount )/ sum(a.ordernoNumber),2) AS "averagePremium"
  1516. FROM
  1517. (
  1518. SELECT
  1519. count( io.userid ) AS "numberUserId",
  1520. count( iac.orderno ) AS "ordernoNumber",
  1521. SUM(IFNULL(iac.jqpremium, 0)
  1522. +IFNULL(iac.sypremium, 0)
  1523. +IFNULL(iac.jypremium, 0)
  1524. ) AS "orderAmount"
  1525. FROM
  1526. `ins_area_company` iac
  1527. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  1528. <where>
  1529. iac.orderstatus = '3'
  1530. <if test="vo.ids != null and vo.ids.size()>0 ">
  1531. AND io.userid IN
  1532. <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
  1533. #{item}
  1534. </foreach>
  1535. </if>
  1536. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  1537. AND iac.createtime BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
  1538. </if>
  1539. </where>
  1540. GROUP BY
  1541. io.userid
  1542. ) a
  1543. order by sum( a.orderAmount ) desc
  1544. </select>
  1545. <select id="getChannelOrderManpowerNew" resultType="com.ydtech.modules.admin.model.dto.QxFrontlineAgentDto">
  1546. SELECT
  1547. a.userId as "userId",
  1548. a.userName as "name",
  1549. a.orderNumber as "orderNumber",
  1550. a.underwritingCount as "underwritingCount",
  1551. a.qutationInsureCount as "qutationInsureCount",
  1552. IFNULL(a.jqpremium,0) + IFNULL(a.sypremium,0) + IFNULL(a.jypremium,0) as "totalPremium",
  1553. a.isFactorVerify as "isFactorVerify",
  1554. a.isNotFactorVerify as "isNotFactorVerify"
  1555. FROM
  1556. (
  1557. SELECT
  1558. io.userid as "userId",
  1559. io.username as "userName",
  1560. count( iac.orderno ) AS "orderNumber",
  1561. sum(CASE WHEN iac.orderstatus = 3 THEN iac.jqpremium END ) AS jqpremium,
  1562. sum(CASE WHEN iac.orderstatus = 3 THEN iac.sypremium END ) AS sypremium,
  1563. sum(CASE WHEN iac.orderstatus = 3 THEN iac.jypremium END ) AS jypremium,
  1564. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
  1565. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  1566. COUNT( CASE WHEN su.factor_verify = 1 THEN 1 END ) AS isFactorVerify,
  1567. COUNT( CASE WHEN su.factor_verify = 0 THEN 1 END ) AS isNotFactorVerify
  1568. FROM
  1569. `ins_area_company` iac
  1570. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  1571. left join sys_user su on su.id=io.userid
  1572. <where>
  1573. <if test="vo.ids != null and vo.ids.size()>0 ">
  1574. AND io.userid IN
  1575. <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
  1576. #{item}
  1577. </foreach>
  1578. </if>
  1579. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  1580. AND iac.createtime BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
  1581. </if>
  1582. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  1583. AND iac.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  1584. </if>
  1585. <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
  1586. AND io.deptid in
  1587. <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
  1588. #{item}
  1589. </foreach>
  1590. </if>
  1591. <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
  1592. AND io.userid in
  1593. <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
  1594. #{item}
  1595. </foreach>
  1596. </if>
  1597. </where>
  1598. GROUP BY
  1599. io.userid,
  1600. io.username
  1601. ) a
  1602. left join sys_user su on su.id=a.userId
  1603. </select>
  1604. <select id="NumberQuotations" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  1605. SELECT
  1606. count(iac.id) as "orderNumber",
  1607. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
  1608. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  1609. sum( CASE WHEN iac.orderstatus = 3 THEN IFNULL(iac.jqpremium, 0) + IFNULL(iac.sypremium, 0) + IFNULL(iac.jypremium, 0) END ) AS totalPremium
  1610. FROM
  1611. ins_area_company iac
  1612. left join ins_orders io on io.orderno = iac.orderno
  1613. left join sys_dept sd on sd.id=io.deptid
  1614. left join sys_user su on su.id=io.userid
  1615. left join ins_fee_audit ifa on ifa .ins_order_no =iac.id
  1616. <where>
  1617. sd.management_source = '2'
  1618. <if test="userId !=null and userId !=''">
  1619. and io.userId =#{userId}
  1620. </if>
  1621. </where>
  1622. </select>
  1623. <select id="totalQuotation" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  1624. SELECT
  1625. agree.insurance_company_id AS companyId,
  1626. agree.insurance_company AS companyName,
  1627. agree.partner_companies_id AS parterCompanyId,
  1628. ins.namesimple AS parterCompanyName,
  1629. count(iac.orderstatus) AS orderNumber,
  1630. '-' as bigQutationCount,
  1631. '-' as bigUnderwritingCount,
  1632. '-' as bigCloseRate,
  1633. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
  1634. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  1635. COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END )/ count(iac.orderstatus) AS passRate,
  1636. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END )/ count(iac.orderstatus) AS underwritingCountRate,
  1637. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )/ count(iac.orderstatus) AS closeRate,
  1638. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )/ COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS
  1639. contributionRate
  1640. FROM
  1641. ins_area_company iac
  1642. LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
  1643. LEFT JOIN ins_orders io on io.orderno = iac.orderno
  1644. LEFT JOIN esm_ins_company ins ON agree.partner_companies_id = ins.id
  1645. WHERE
  1646. agree.id IS NOT NULL
  1647. <if test="vo.companyId != null and vo.companyId!='' ">
  1648. agree.insurance_company_id = #{vo.companyId}
  1649. </if>
  1650. <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
  1651. agree.partner_companies_id = #{vo.parterCompanyId}
  1652. </if>
  1653. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  1654. AND iac.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  1655. </if>
  1656. <if test="vo.provinceId != null and vo.provinceId != ''">
  1657. and io.deptid like "${vo.provinceId}%"
  1658. </if>
  1659. <if test="vo.cityId != null and vo.cityId != ''">
  1660. and io.deptid like "${vo.cityId}%"
  1661. </if>
  1662. <if test="vo.countyId != null and vo.countyId != ''">
  1663. and io.deptid like "${vo.countyId}%"
  1664. </if>
  1665. <if test="taskStatisticsVo.houseId != null and vo.houseId != ''">
  1666. and io.deptid like "${vo.houseId}%"
  1667. </if>
  1668. GROUP BY
  1669. agree.insurance_company_id,
  1670. agree.insurance_company,
  1671. agree.partner_companies_id,
  1672. ins.NAME
  1673. </select>
  1674. <select id="getBusinessData" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  1675. select
  1676. a.companyId as "companyId",
  1677. a.insuranceCompanyName as "insuranceCompanyName",
  1678. a.parterCompanyId as "parterCompanyId",
  1679. a.partnerCompaniesName as "partnerCompaniesName",
  1680. a.totalPremium as "totalPremium",
  1681. a.qutationInsureCount as "qutationInsureCount",
  1682. a.averagePremium as "averagePremium",
  1683. a.userNumber as "userNumber",
  1684. a.perCapitaAmount as "perCapitaAmount",
  1685. c.docking_person as "dockingPerson",
  1686. c.docking_phone as "dockingPhone",
  1687. c.agreement_type as "agreementType",
  1688. b.logo as "logo"
  1689. from (
  1690. SELECT
  1691. agree.insurance_company_id AS "companyId",
  1692. agree.insurance_company AS "insuranceCompanyName",
  1693. agree.partner_companies_id AS "parterCompanyId",
  1694. ins.namesimple AS "partnerCompaniesName",
  1695. agree.id as "agreeId",
  1696. IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0) as "totalPremium",
  1697. COUNT(0 ) AS "qutationInsureCount",
  1698. (IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0)) / COUNT(0 ) AS "averagePremium",
  1699. COUNT(DISTINCT io.userId) AS "userNumber",
  1700. (IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0)) / COUNT(DISTINCT io.userId) as "perCapitaAmount"
  1701. FROM
  1702. ins_area_company iac
  1703. LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
  1704. LEFT JOIN ins_orders io on io.orderno = iac.orderno
  1705. LEFT JOIN esm_ins_company ins ON agree.partner_companies_id = ins.id
  1706. WHERE
  1707. agree.id IS NOT NULL
  1708. and iac.orderstatus = '3'
  1709. <if test="vo.companyId != null and vo.companyId!='' ">
  1710. and agree.insurance_company_id = #{vo.companyId}
  1711. </if>
  1712. <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
  1713. and agree.partner_companies_id = #{vo.parterCompanyId}
  1714. </if>
  1715. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  1716. AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{vo.createtimeStart}, '%Y-%m-%d') AND DATE_FORMAT( #{vo.createtimeEnd}, '%Y-%m-%d')
  1717. </if>
  1718. <if test="vo.provinceId != null and vo.provinceId != '' and vo.cityId == null and vo.countyId == null and vo.houseId == null ">
  1719. and io.deptid like "${vo.provinceId}%"
  1720. </if>
  1721. <if test="vo.cityId != null and vo.cityId != '' and vo.countyId ==null and vo.houseId ==null">
  1722. and io.deptid like "${vo.cityId}%"
  1723. </if>
  1724. <if test="vo.countyId != null and vo.countyId != '' and vo.houseId ==null">
  1725. and io.deptid like "${vo.countyId}%"
  1726. </if>
  1727. <if test="vo.houseId != null and vo.houseId != ''">
  1728. and io.deptid like "${vo.houseId}%"
  1729. </if>
  1730. <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
  1731. AND io.deptid in
  1732. <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
  1733. #{item}
  1734. </foreach>
  1735. </if>
  1736. <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
  1737. AND io.userid in
  1738. <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
  1739. #{item}
  1740. </foreach>
  1741. </if>
  1742. GROUP BY
  1743. agree.insurance_company_id,
  1744. agree.insurance_company,
  1745. agree.partner_companies_id,
  1746. agree.id
  1747. <choose>
  1748. <when test="vo.orderSort != null and vo.orderSort != '' and vo.userNumberSort == null ">
  1749. order by
  1750. sum(sumpremium) ${vo.orderSort == 'asc' ? 'asc' : 'desc'}
  1751. </when>
  1752. <when test="vo.userNumberSort != null and vo.userNumberSort != '' and vo.orderSort == null ">
  1753. order by
  1754. COUNT(DISTINCT io.userId) ${vo.userNumberSort == 'asc' ? 'asc' : 'desc'}
  1755. </when>
  1756. <when test="vo.userNumberSort != null and vo.userNumberSort != '' and vo.orderSort != null and vo.orderSort != '' ">
  1757. order by
  1758. COUNT(DISTINCT io.userId) ${vo.userNumberSort == 'asc' ? 'asc' : 'desc'}, sum(sumpremium) ${vo.orderSort == 'asc' ? 'asc' : 'desc'}
  1759. </when>
  1760. </choose>
  1761. ) a
  1762. left join esm_ins_company b on b.id =a.companyId
  1763. left join ptl_agreement c on c.id =a.agreeId
  1764. </select>
  1765. <select id="getDistribution" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  1766. SELECT
  1767. agree.insurance_company_id AS "companyId",
  1768. agree.insurance_company AS "insuranceCompanyName",
  1769. agree.partner_companies_id AS "parterCompanyId",
  1770. ins.namesimple AS "partnerCompaniesName",
  1771. IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0) as "totalPremium",
  1772. COUNT(0) AS "qutationInsureCount",
  1773. (IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0)) / COUNT(0) AS "averagePremium",
  1774. COUNT(DISTINCT io.userId) AS "userNumber",
  1775. (IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0)) / COUNT(DISTINCT io.userId) as "perCapitaAmount"
  1776. FROM
  1777. ins_area_company iac
  1778. LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
  1779. LEFT JOIN ins_orders io on io.orderno = iac.orderno
  1780. LEFT JOIN esm_ins_company ins ON agree.partner_companies_id = ins.id
  1781. WHERE
  1782. agree.id IS NOT NULL
  1783. <if test="vo.companyId != null and vo.companyId!='' ">
  1784. and agree.insurance_company_id = #{vo.companyId}
  1785. </if>
  1786. <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
  1787. and agree.partner_companies_id = #{vo.parterCompanyId}
  1788. </if>
  1789. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  1790. AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{vo.createtimeStart}, '%Y-%m-%d') AND DATE_FORMAT( #{vo.createtimeEnd}, '%Y-%m-%d')
  1791. </if>
  1792. <if test="vo.days !=null and vo.days !='' and vo.days != 0 ">
  1793. and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{vo.days} DAY)
  1794. </if>
  1795. <if test="vo.provinceId != null and vo.provinceId != ''">
  1796. and io.deptid like "${vo.provinceId}%"
  1797. </if>
  1798. <if test="vo.cityId != null and vo.cityId != ''">
  1799. and io.deptid like "${vo.cityId}%"
  1800. </if>
  1801. <if test="vo.countyId != null and vo.countyId != ''">
  1802. and io.deptid like "${vo.countyId}%"
  1803. </if>
  1804. <if test="vo.houseId != null and vo.houseId != ''">
  1805. and io.deptid like "${vo.houseId}%"
  1806. </if>
  1807. <if test="vo.quotationStatus != null and vo.quotationStatus != ''">
  1808. and iac.orderstatus =#{vo.quotationStatus}
  1809. </if>
  1810. <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
  1811. AND io.deptid in
  1812. <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
  1813. #{item}
  1814. </foreach>
  1815. </if>
  1816. <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
  1817. AND io.userid in
  1818. <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
  1819. #{item}
  1820. </foreach>
  1821. </if>
  1822. GROUP BY
  1823. agree.insurance_company_id,
  1824. agree.insurance_company,
  1825. agree.partner_companies_id,
  1826. ins.namesimple
  1827. </select>
  1828. <select id="getOrderPremiumByUserIds" resultType="Double">
  1829. SELECT
  1830. IFNULL(
  1831. SUM( IFNULL( iac.jqpremium, 0 ) + IFNULL( iac.sypremium, 0 ) + IFNULL( iac.jypremium, 0 ) ),
  1832. 0
  1833. ) AS "totalPremium"
  1834. FROM
  1835. `ins_area_company` iac
  1836. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  1837. <where>
  1838. iac.orderstatus = '3'
  1839. <if test="ids != null and ids.size()>0 ">
  1840. AND io.userid IN
  1841. <foreach item="item" collection="ids" open="(" separator="," close=")">
  1842. #{item}
  1843. </foreach>
  1844. </if>
  1845. </where>
  1846. </select>
  1847. <select id="querOrdersDataPage" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
  1848. SELECT
  1849. count( 0 ) AS "orderNumber",
  1850. b.licenseno as "licenseno",
  1851. b.frameno as "frameno",
  1852. b.modelCode as "modelCode",
  1853. b.modelcname as "modelcname"
  1854. FROM
  1855. (
  1856. SELECT
  1857. io.orderstatus AS orderstatus,
  1858. io.frameno AS frameno,
  1859. REPLACE(JSON_EXTRACT(io.carinfo, '$.engineNo'), '"', '') as "modelCode",
  1860. REPLACE(JSON_EXTRACT(io.carinfo, '$.modelcname'), '"', '') as "modelcname",
  1861. ifnull(io.licenseno, '') AS licenseno
  1862. FROM
  1863. ins_orders io
  1864. LEFT JOIN sys_user su on io.userid=su.id
  1865. <where>
  1866. 1=1
  1867. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  1868. AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  1869. </if>
  1870. <if test="vo.licenseno != null and vo.licenseno!='' ">
  1871. AND io.licenseno =#{vo.licenseno}
  1872. </if>
  1873. <if test="vo.userId != null and vo.userId!='' ">
  1874. AND io.userid =#{vo.userId}
  1875. </if>
  1876. <if test="vo.userName != null and vo.userName!='' ">
  1877. AND su.name =#{vo.userName}
  1878. </if>
  1879. <if test="vo.mobile != null and vo.mobile!='' ">
  1880. AND su.mobile =#{vo.mobile}
  1881. </if>
  1882. <if test="vo.frameno != null and vo.frameno!='' ">
  1883. AND io.frameno =#{vo.frameno}
  1884. </if>
  1885. <if test="vo.deptId != null and vo.deptId!='' ">
  1886. and io.deptid like concat('%', #{vo.deptId}, '%')
  1887. </if>
  1888. <if test="vo.year != null and vo.year!='' ">
  1889. AND DATE_FORMAT( io.createtime, '%Y') =#{vo.year}
  1890. </if>
  1891. <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
  1892. AND io.deptid in
  1893. <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
  1894. #{item}
  1895. </foreach>
  1896. </if>
  1897. <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
  1898. AND io.userid in
  1899. <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
  1900. #{item}
  1901. </foreach>
  1902. </if>
  1903. </where>
  1904. ) b
  1905. GROUP BY
  1906. b.licenseno,
  1907. b.frameno,
  1908. b.modelCode,
  1909. b.modelcname
  1910. </select>
  1911. <select id="getOrdersGroupByLicenseno" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
  1912. SELECT
  1913. io.licenseno AS "licenseno",
  1914. io.frameno AS "frameno",
  1915. io.orderstatus as "orderstatus",
  1916. io.orderno as "orderno"
  1917. FROM
  1918. ins_orders io
  1919. LEFT JOIN sys_user su on io.userid=su.id
  1920. <where>
  1921. io.licenseno is not null
  1922. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  1923. AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  1924. </if>
  1925. <if test="vo.licenseno != null and vo.licenseno!='' ">
  1926. AND io.licenseno =#{vo.licenseno}
  1927. </if>
  1928. <if test="vo.userId != null and vo.userId!='' ">
  1929. AND io.userId =#{vo.userId}
  1930. </if>
  1931. <if test="vo.userName != null and vo.userName!='' ">
  1932. AND su.name =#{vo.userName}
  1933. </if>
  1934. <if test="vo.mobile != null and vo.mobile!='' ">
  1935. AND su.mobile =#{vo.mobile}
  1936. </if>
  1937. <if test="vo.frameno != null and vo.frameno!='' ">
  1938. AND su.frameno =#{vo.frameno}
  1939. </if>
  1940. <if test="vo.deptId != null and vo.deptId!='' ">
  1941. and io.deptid like concat('%', #{vo.deptId}, '%')
  1942. </if>
  1943. </where>
  1944. </select>
  1945. <select id="querOrdersamountTo" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
  1946. select sum(a.orderNumber) as "orderNumber",
  1947. count(a.licenseno) as "b.frameno"
  1948. from (
  1949. SELECT
  1950. count( 0 ) AS "orderNumber",
  1951. b.licenseno as "licenseno",
  1952. b.frameno as "frameno"
  1953. FROM
  1954. (
  1955. SELECT
  1956. io.orderstatus AS orderstatus,
  1957. io.frameno AS frameno,
  1958. ifnull(io.licenseno, '') AS licenseno
  1959. FROM
  1960. ins_orders io
  1961. LEFT JOIN sys_user su on io.userid=su.id
  1962. <where>
  1963. 1=1
  1964. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  1965. AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  1966. </if>
  1967. <if test="vo.licenseno != null and vo.licenseno!='' ">
  1968. AND io.licenseno =#{vo.licenseno}
  1969. </if>
  1970. <if test="vo.userId != null and vo.userId!='' ">
  1971. AND io.userid =#{vo.userId}
  1972. </if>
  1973. <if test="vo.userName != null and vo.userName!='' ">
  1974. AND su.name =#{vo.userName}
  1975. </if>
  1976. <if test="vo.mobile != null and vo.mobile!='' ">
  1977. AND su.mobile =#{vo.mobile}
  1978. </if>
  1979. <if test="vo.frameno != null and vo.frameno!='' ">
  1980. AND io.frameno =#{vo.frameno}
  1981. </if>
  1982. <if test="vo.deptId != null and vo.deptId!='' ">
  1983. and io.deptid like concat('%', #{vo.deptId}, '%')
  1984. </if>
  1985. </where>
  1986. ) b
  1987. GROUP BY
  1988. b.licenseno,
  1989. b.frameno
  1990. ) a
  1991. </select>
  1992. <select id="querResultOrderNumber" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
  1993. SELECT
  1994. count( io.orderno ) AS "orderNumber",
  1995. 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"
  1996. FROM
  1997. ins_orders io
  1998. LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
  1999. LEFT JOIN sys_user su ON io.userid = su.id
  2000. <where>
  2001. 1=1
  2002. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  2003. AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  2004. </if>
  2005. <if test="vo.licenseno != null and vo.licenseno!='' ">
  2006. AND io.licenseno =#{vo.licenseno}
  2007. </if>
  2008. <if test="vo.userId != null and vo.userId!='' ">
  2009. AND io.userid =#{vo.userId}
  2010. </if>
  2011. <if test="vo.userName != null and vo.userName!='' ">
  2012. AND su.name =#{vo.userName}
  2013. </if>
  2014. <if test="vo.mobile != null and vo.mobile!='' ">
  2015. AND su.mobile =#{vo.mobile}
  2016. </if>
  2017. <if test="vo.frameno != null and vo.frameno!='' ">
  2018. AND su.frameno =#{vo.frameno}
  2019. </if>
  2020. <if test="vo.deptId != null and vo.deptId!='' ">
  2021. and io.deptid like concat('%', #{vo.deptId}, '%')
  2022. </if>
  2023. </where>
  2024. </select>
  2025. <select id="numberQuotationsByUserIds" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  2026. SELECT
  2027. count(iac.id) as "orderNumber",
  2028. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
  2029. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  2030. sum( CASE WHEN iac.orderstatus = 3 THEN IFNULL(iac.jqpremium, 0) + IFNULL(iac.sypremium, 0) + IFNULL(iac.jypremium, 0) END ) AS totalPremium
  2031. FROM
  2032. ins_area_company iac
  2033. left join ins_orders io on io.orderno = iac.orderno
  2034. <where>
  2035. <if test="ids != null and ids.size()>0 ">
  2036. AND io.userid IN
  2037. <foreach item="item" collection="ids" open="(" separator="," close=")">
  2038. #{item}
  2039. </foreach>
  2040. </if>
  2041. <if test="month != null and month!='' ">
  2042. AND DATE_FORMAT(iac.createtime, '%Y-%m') =#{month}
  2043. </if>
  2044. </where>
  2045. </select>
  2046. <select id="selectByOrdersDataVo" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
  2047. select
  2048. iac.inscompany as "namesimple"
  2049. from
  2050. ins_area_company iac
  2051. <where>
  2052. 1=1
  2053. <if test="vo.orderstatus != null and vo.orderstatus != '' ">
  2054. AND iac.orderstatus =#{vo.orderstatus}
  2055. </if>
  2056. <if test="vo.orderno !=null and vo.orderno !='' ">
  2057. AND iac.orderno =#{vo.orderno}
  2058. </if>
  2059. </where>
  2060. </select>
  2061. <select id="channelExcel" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsExcel">
  2062. select a.*,(select name from sys_user where id =a.userId) as "userName"
  2063. from (
  2064. SELECT
  2065. sd.NAME AS "deptName",
  2066. io.userid AS "userId",
  2067. sd.parent_id as "deptId",
  2068. COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS qutationCount,
  2069. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
  2070. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  2071. COUNT( CASE WHEN iac.orderstatus = 4 THEN 1 END ) AS underwritingReturn,
  2072. (COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) / COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END )) * 100 AS "passingRate",
  2073. (COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) / COUNT( iac.orderstatus )) * 100 AS "closeRate",
  2074. ((COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) + COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ))/ COUNT( iac.orderstatus )) * 100 AS "contributionRate",
  2075. (COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) / COUNT( iac.orderstatus )) * 100 AS "quotationRate",
  2076. COUNT( CASE WHEN iac.orderstatus = 1 THEN 1 END ) AS "auditOrder"
  2077. FROM
  2078. ins_area_company iac
  2079. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  2080. LEFT JOIN sys_dept sd ON sd.id = io.deptid
  2081. <where>
  2082. 1=1
  2083. <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
  2084. and io.deptid like "${taskStatisticsVo.provinceId}%"
  2085. </if>
  2086. <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
  2087. and io.deptid like "${taskStatisticsVo.cityId}%"
  2088. </if>
  2089. <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
  2090. and io.deptid like "${taskStatisticsVo.countyId}%"
  2091. </if>
  2092. <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
  2093. and io.deptid like "${taskStatisticsVo.houseId}%"
  2094. </if>
  2095. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  2096. AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
  2097. </if>
  2098. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  2099. AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
  2100. </if>
  2101. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  2102. and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
  2103. </if>
  2104. <if test="taskStatisticsVo.managementSource!=null and taskStatisticsVo.managementSource!=''">
  2105. and sd.management_source=#{taskStatisticsVo.managementSource}
  2106. </if>
  2107. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  2108. <choose>
  2109. <when test="taskStatisticsVo.days =='1'">
  2110. and io.createtime >= DATE_SUB(NOW(), INTERVAL 1 DAY)
  2111. </when>
  2112. <when test="taskStatisticsVo.days =='7'">
  2113. and io.createtime >= DATE_SUB(NOW(), INTERVAL 7 DAY)
  2114. </when>
  2115. <when test="taskStatisticsVo.days =='30'">
  2116. and io.createtime >= DATE_SUB(NOW(), INTERVAL 30 DAY)
  2117. </when>
  2118. </choose>
  2119. </if>
  2120. </where>
  2121. GROUP BY
  2122. io.userid,
  2123. sd.NAME,
  2124. sd.id
  2125. ) a
  2126. </select>
  2127. <select id="insuranceCompanyExcel" resultType="com.ydtech.modules.admin.model.dto.InsuranceCompanyExcel">
  2128. SELECT
  2129. a.*,
  2130. ( SELECT eic.namesimple FROM esm_ins_company eic WHERE eic.id = a.partner_companies_id ) AS "partnerCompaniesName"
  2131. FROM
  2132. (
  2133. SELECT
  2134. pa.insurance_company_id,
  2135. pa.partner_companies_id,
  2136. pa.insurance_company AS "insuranceCompanyName",
  2137. COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS qutationCount,
  2138. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCountRate,
  2139. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  2140. COUNT( CASE WHEN iac.orderstatus = 4 THEN 1 END ) AS underwritingReturn,
  2141. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) / COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS "passingRate",
  2142. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) / COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS "closeRate",
  2143. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) / COUNT( iac.orderstatus ) AS "contributionRate",
  2144. COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) / COUNT( iac.orderstatus ) AS "quotationRate",
  2145. COUNT( CASE WHEN ifa.auditstatus = 1 THEN 1 END ) AS "auditOrder"
  2146. FROM
  2147. ins_area_company iac
  2148. LEFT JOIN ins_fee_audit ifa ON ifa.ins_order_no = iac.id
  2149. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  2150. <where>
  2151. pa.insurance_company_id IS NOT NULL
  2152. <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
  2153. and io.deptid like "${taskStatisticsVo.provinceId}%"
  2154. </if>
  2155. <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
  2156. and io.deptid like "${taskStatisticsVo.cityId}%"
  2157. </if>
  2158. <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
  2159. and io.deptid like "${taskStatisticsVo.countyId}%"
  2160. </if>
  2161. <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
  2162. and io.deptid like "${taskStatisticsVo.houseId}%"
  2163. </if>
  2164. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  2165. AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
  2166. </if>
  2167. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  2168. AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
  2169. </if>
  2170. <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId != ''">
  2171. AND iac.company_id =#{taskStatisticsVo.companyId}
  2172. </if>
  2173. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  2174. and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
  2175. </if>
  2176. </where>
  2177. GROUP BY
  2178. pa.insurance_company_id,
  2179. pa.partner_companies_id,
  2180. pa.insurance_company
  2181. ) a
  2182. </select>
  2183. <select id="getSumBigOrderCount" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
  2184. select count(0) as "orderNumber",
  2185. GROUP_CONCAT(inscompany ORDER BY inscompany SEPARATOR ',') as "namesimple"
  2186. from ins_area_company iac
  2187. left join ins_orders io on io.orderno = iac.orderno
  2188. <where>
  2189. 1=1
  2190. and iac.orderstatus ='3'
  2191. and io.orderstatus ='3'
  2192. <if test="vo.licenseno !=null and vo.licenseno!=''">
  2193. AND io.licenseno =#{vo.licenseno}
  2194. </if>
  2195. <if test="vo.frameno !=null and vo.frameno!=''">
  2196. AND io.frameno =#{vo.frameno}
  2197. </if>
  2198. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  2199. AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  2200. </if>
  2201. <if test="vo.year != null and vo.year!='' ">
  2202. AND DATE_FORMAT( io.createtime, '%Y') =#{vo.year}
  2203. </if>
  2204. </where>
  2205. </select>
  2206. <select id="queryAgencyUserInsAreaPage" resultType="com.ydtech.modules.admin.model.vo.AgencyUserInsAreaVo">
  2207. select
  2208. io.userid as userId,
  2209. io.username as userName,
  2210. io.licenseno as licenseno,
  2211. iac.id as companyId,
  2212. iac.jqpremium as jqpremium,
  2213. iac.sypremium as sypremium,
  2214. iac.jypremium as jypremium,
  2215. iac.createtime as createtime,
  2216. iac.orderstatus as orderstatus
  2217. from ins_area_company iac
  2218. left join ins_orders io on io.orderno = iac.orderno
  2219. <where>
  2220. iac.orderstatus=3
  2221. <if test="dto.userId !=null and dto.userId !=''">
  2222. and io.userid = #{dto.userId}
  2223. </if>
  2224. <if test="dto.deptId !=null and dto.deptId !=''">
  2225. and io.deptid like concat( #{dto.deptId}, '%')
  2226. </if>
  2227. <if test="dto.startTime !=null and dto.startTime !=''">
  2228. and io.createtime >= #{dto.startTime}
  2229. </if>
  2230. </where>
  2231. ORDER BY iac.createtime
  2232. </select>
  2233. <select id="querOrdersDataListExcel" resultType="com.ydtech.modules.admin.model.dto.OrdersDataExcel">
  2234. select a.*,
  2235. IFNULL(b.orderNumber,0)/IFNULL(a.orderNumber ,0)
  2236. from (
  2237. SELECT
  2238. count( 0 ) AS "orderNumber",
  2239. b.licenseno as "licenseno",
  2240. b.modelCode as "modelCode",
  2241. b.modelcname as "modelcname",
  2242. b.frameno as "frameno"
  2243. FROM
  2244. (
  2245. SELECT
  2246. io.orderstatus AS orderstatus,
  2247. io.frameno AS frameno,
  2248. REPLACE(JSON_EXTRACT(io.carinfo, '$.engineNo'), '"', '') as "modelCode",
  2249. REPLACE(JSON_EXTRACT(io.carinfo, '$.modelcname'), '"', '') as "modelcname",
  2250. ifnull(io.licenseno, '') AS licenseno
  2251. FROM
  2252. ins_orders io
  2253. LEFT JOIN sys_user su on io.userid=su.id
  2254. <where>
  2255. 1=1
  2256. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  2257. AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  2258. </if>
  2259. <if test="vo.licenseno != null and vo.licenseno!='' ">
  2260. AND io.licenseno =#{vo.licenseno}
  2261. </if>
  2262. <if test="vo.userId != null and vo.userId!='' ">
  2263. AND io.userid =#{vo.userId}
  2264. </if>
  2265. <if test="vo.userName != null and vo.userName!='' ">
  2266. AND su.name =#{vo.userName}
  2267. </if>
  2268. <if test="vo.mobile != null and vo.mobile!='' ">
  2269. AND su.mobile =#{vo.mobile}
  2270. </if>
  2271. <if test="vo.frameno != null and vo.frameno!='' ">
  2272. AND io.frameno =#{vo.frameno}
  2273. </if>
  2274. <if test="vo.deptId != null and vo.deptId!='' ">
  2275. and io.deptid like concat('%', #{vo.deptId}, '%')
  2276. </if>
  2277. <if test="vo.year != null and vo.year!='' ">
  2278. AND DATE_FORMAT( io.createtime, '%Y') =#{vo.year}
  2279. </if>
  2280. </where>
  2281. ) b
  2282. GROUP BY
  2283. b.licenseno,
  2284. b.frameno,
  2285. b.modelCode,
  2286. b.modelcname
  2287. ) a
  2288. left join (
  2289. select count(0) as "orderNumber",
  2290. GROUP_CONCAT(inscompany ORDER BY inscompany SEPARATOR ',') as "namesimple",
  2291. io.licenseno as "licenseno"
  2292. from ins_area_company iac
  2293. left join ins_orders io on io.orderno = iac.orderno
  2294. <where>
  2295. 1=1
  2296. and iac.orderstatus ='3'
  2297. and io.orderstatus ='3'
  2298. <if test="vo.licenseno !=null and vo.licenseno!=''">
  2299. AND io.licenseno =#{vo.licenseno}
  2300. </if>
  2301. <if test="vo.frameno !=null and vo.frameno!=''">
  2302. AND io.frameno =#{vo.frameno}
  2303. </if>
  2304. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  2305. AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  2306. </if>
  2307. <if test="vo.year != null and vo.year!='' ">
  2308. AND DATE_FORMAT( io.createtime, '%Y') =#{vo.year}
  2309. </if>
  2310. </where>
  2311. group by
  2312. io.licenseno
  2313. ) b on b.licenseno =a.licenseno
  2314. </select>
  2315. <select id="orderCheckPage" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
  2316. select
  2317. iac.id,
  2318. iac.orderno,
  2319. iac.agreement_id,
  2320. iac.jqpremium,
  2321. iac.sypremium,
  2322. iac.jypremium,
  2323. iac.taxamount,
  2324. iac.sumpremium,
  2325. io.licenseno,
  2326. iac.createtime,
  2327. su.name as auditname
  2328. FROM
  2329. ins_area_company iac
  2330. LEFT JOIN
  2331. ins_orders io on iac.orderno = io.orderno
  2332. left join ptl_agreement agree on iac.agreement_id =agree.id
  2333. left join ins_fee_audit ifa on iac.id = ifa.ins_order_no
  2334. left join sys_user su on su.id= ifa.audituser
  2335. WHERE
  2336. iac.operator_id = #{userId}
  2337. AND
  2338. iac.orderstatus = 3
  2339. and agree.is_external =1
  2340. and auditstatus =1
  2341. <if test="vo.id != null and vo.id!='' ">
  2342. and iac.id = #{vo.id}
  2343. </if>
  2344. <if test="vo.licenseno != null and vo.licenseno!='' ">
  2345. and io.licenseno like CONCAT('%', #{vo.licenseno}, '%')
  2346. </if>
  2347. </select>
  2348. </mapper>