InsAreaCompanyMapper.xml 99 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257
  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. io.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. ifa.audittime as auditTime,
  166. ifa.auditstatus as auditStatus,
  167. eic.namesimple as partnerCompaniesName,
  168. iac.id as subOrderId,
  169. iac.signing_time as signingTime,
  170. iac.pay_date as payDate,
  171. pa.agreement_code as agreementCode,
  172. pa.agreement_name as agreementName,
  173. io.entry_status
  174. FROM
  175. ins_fee_audit ifa
  176. LEFT JOIN ins_orders io ON io.orderno = ifa.orderno
  177. LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
  178. AND iac.orderstatus = 3
  179. LEFT JOIN sys_user su ON su.id = io.userid
  180. LEFT JOIN sys_dept sd ON sd.id = su.dept_id
  181. LEFT JOIN sys_user su2 ON ifa.audituser = su2.id
  182. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  183. LEFT JOIN esm_ins_company eic ON eic.id = pa.partner_companies_id
  184. WHERE
  185. iac.id = ifa.ins_order_no
  186. AND iac.orderstatus = 3
  187. <if test="params.auditStatus != null and params.auditStatus != ''">
  188. and ifa.auditstatus = #{params.auditStatus}
  189. </if>
  190. <if test="params.quoteStartDateStr != null and params.quoteStartDateStr != '' and params.quoteEndDateStr != null and params.quoteEndDateStr != ''">
  191. and DATE_FORMAT(iac.createtime, '%Y-%m-%d') between #{params.quoteStartDateStr} AND
  192. #{params.quoteEndDateStr}
  193. </if>
  194. <if test="params.orderNo != null and params.orderNo != ''">
  195. AND iac.id= #{params.orderNo}
  196. </if>
  197. <if test="params.licenseNo != null and params.licenseNo != ''">
  198. AND io.licenseno = #{params.licenseNo}
  199. </if>
  200. <if test="params.frameNo != null and params.frameNo != ''">
  201. AND io.frameno = #{params.frameNo}
  202. </if>
  203. <if test="params.insuredName != null and params.insuredName != ''">
  204. AND io.insuredname = #{params.insuredName}
  205. </if>
  206. <if test="params.companyId != null and params.companyId != ''">
  207. AND io.company_id = #{params.companyId}
  208. </if>
  209. <if test="params.engineNo != null and params.engineNo != ''">
  210. and JSON_EXTRACT( io.carinfo, '$.engineNo' ) = #{params.engineNo}
  211. </if>
  212. <if test="params.riskCode != null and params.riskCode != ''">
  213. and iac.product = #{params.riskCode}
  214. </if>
  215. <if test="params.attachStartDateStr != null and params.attachStartDateStr != '' and params.attachStartDateStr != null and params.attachStartDateStr != '' ">
  216. and ((
  217. DATE_FORMAT(iac.jq_start_date, '%Y-%m-%d') BETWEEN #{params.attachStartDateStr}
  218. AND #{params.attachEndDateStr}
  219. )
  220. OR ( DATE_FORMAT(iac.sy_start_date, '%Y-%m-%d') BETWEEN #{params.attachStartDateStr} AND
  221. #{params.attachEndDateStr} )
  222. )
  223. </if>
  224. <if test="params.provinceId != null and params.provinceId != ''">
  225. and io.deptid like "${params.provinceId}%"
  226. </if>
  227. <if test="params.problemOrder != null and params.problemOrder != ''">
  228. and iac.problem_order like "${params.problemOrder}%"
  229. </if>
  230. <if test="params.cityId != null and params.cityId != ''">
  231. and io.deptid like "${params.cityId}%"
  232. </if>
  233. <if test="params.countyId != null and params.countyId != ''">
  234. and io.deptid like "${params.countyId}%"
  235. </if>
  236. <if test="params.houseId != null and params.houseId != ''">
  237. and io.deptid like "${params.houseId}%"
  238. </if>
  239. <if test="params.operatorId != null and params.operatorId != ''">
  240. and io.userid = #{params.operatorId}
  241. </if>
  242. <if test="params.operatorName != null and params.operatorName != ''">
  243. and io.username = #{params.operatorName}
  244. </if>
  245. <if test="params.auditId != null and params.auditId != ''">
  246. and iac.new_operator_id = #{params.auditId}
  247. </if>
  248. <if test="params.agreeId != null and params.agreeId != ''">
  249. and iac.agreement_id = #{params.agreeId}
  250. </if>
  251. <if test="params.managementSource != null and params.managementSource != ''">
  252. and sd.management_source = #{params.managementSource}
  253. </if>
  254. <if test="params.signStartDateStr != null and params.signStartDateStr != '' and params.signEndDateStr != null and params.signEndDateStr != ''">
  255. and DATE_FORMAT(iac.signing_time, '%Y-%m-%d') between #{params.signStartDateStr} AND
  256. #{params.signEndDateStr}
  257. </if>
  258. <if test="params.payStartDateStr != null and params.payStartDateStr != '' and params.payEndDateStr != null and params.payEndDateStr != ''">
  259. and DATE_FORMAT(iac.pay_date, '%Y-%m-%d') between #{params.payStartDateStr} AND #{params.payEndDateStr}
  260. </if>
  261. <if test="params.isExternal != null and params.isExternal != ''">
  262. and io.is_external = #{params.isExternal}
  263. </if>
  264. <if test="params.jqPolicyNo != null and params.jqPolicyNo != ''">
  265. and iac.jqpolicyno = #{params.jqPolicyNo}
  266. </if>
  267. <if test="params.syPolicyNo != null and params.syPolicyNo != ''">
  268. and iac.sypolicyno = #{params.syPolicyNo}
  269. </if>
  270. <if test="params.noPolicyNo != null and params.noPolicyNo != ''">
  271. and iac.cross_insurance like concat('%', #{params.noPolicyNo}, '%')
  272. </if>
  273. order by iac.createtime desc
  274. </select>
  275. <select id="getByUserId" resultType="com.ydtech.modules.order.entity.InsOrders">
  276. SELECT
  277. io.*,
  278. sd.management_source
  279. FROM
  280. ins_orders io left join sys_user su on su.id = io.userid left join sys_dept sd on sd.id = su.dept_id
  281. WHERE
  282. orderno IN (
  283. SELECT
  284. orderno
  285. FROM
  286. ins_area_company
  287. WHERE
  288. id IN ( SELECT ins_order_no FROM ins_fee_order_new WHERE id NOT IN ( SELECT ins_order_no FROM ins_fee_audit ) )
  289. AND orderstatus = 3
  290. )
  291. AND
  292. io.orderstatus= 3
  293. <if test="orderNo != null and orderNo != ''">
  294. AND orderno = #{orderNo}
  295. </if>
  296. <if test="licenseNo != null and licenseNo != ''">
  297. AND licenseno = #{licenseNo}
  298. </if>
  299. <if test="frameNo != null and frameNo != ''">
  300. AND frameno = #{frameNo}
  301. </if>
  302. <if test="userId != null and userId != ''">
  303. AND userid = #{userId}
  304. </if>
  305. <if test="insuredname != null and insuredname != ''">
  306. AND insuredname = #{insuredname}
  307. </if>
  308. <if test="startDateStr != null and startDateStr != ''">
  309. AND createtime BETWEEN #{startDateStr} and #{endDateStr}
  310. </if>
  311. </select>
  312. <select id="selectFirstPromotionBy" resultType="com.ydtech.modules.order.entity.InsOrders">
  313. SELECT
  314. sum(a.first_detail_premiums) as "willFirstPremiums"
  315. FROM
  316. ins_fee_order_new a
  317. LEFT JOIN ins_area_company iac on iac.id=a.ins_order_no
  318. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  319. WHERE
  320. iff.auditstatus=0
  321. AND iac.orderstatus =3
  322. <if test="firstUserId != null and firstUserId != ''">
  323. AND a.first_level_user_id = #{firstUserId}
  324. </if>
  325. <if test="secondUserId != null and secondUserId != ''">
  326. AND a.two_level_user_id = #{secondUserId}
  327. </if>
  328. <if test="thirdUserId != null and thirdUserId != ''">
  329. AND a.three_level_user_id = #{thirdUserId}
  330. </if>
  331. <if test="id != null and id != ''">
  332. AND a.id = #{id}
  333. </if>
  334. </select>
  335. <select id="selectSecondPromotionBy" resultType="com.ydtech.modules.order.entity.InsOrders">
  336. SELECT
  337. sum( fee.p ) as "willFirstPremiums"
  338. FROM
  339. (
  340. SELECT
  341. sum( a.first_detail_premiums ) AS p
  342. FROM
  343. ins_fee_order_new a
  344. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  345. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  346. <where>
  347. iff.auditstatus=0
  348. and iac.orderstatus = '3'
  349. <if test="userId!=null and userId!= ''">
  350. AND a.first_level_user_id = #{userId}
  351. </if>
  352. <if test="id != null and id!=''">
  353. AND a.id =#{id}
  354. </if>
  355. </where>
  356. UNION
  357. SELECT
  358. sum( a.third_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.three_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.second_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.two_level_user_id = #{userId}
  385. </if>
  386. <if test="id != null and id!=''">
  387. AND a.id =#{id}
  388. </if>
  389. </where>
  390. ) AS fee
  391. </select>
  392. <select id="selectThirdPromotionBy" resultType="com.ydtech.modules.order.entity.InsOrders">
  393. SELECT
  394. sum(a.third_detail_premiums) as "willThreePremiums"
  395. FROM
  396. ins_fee_order_new a
  397. LEFT JOIN ins_area_company iac on iac.id=a.ins_order_no
  398. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  399. WHERE
  400. iff.auditstatus=0
  401. AND iac.orderstatus =3
  402. <if test="firstUserId != null and firstUserId != ''">
  403. AND a.first_level_user_id = #{firstUserId}
  404. </if>
  405. <if test="secondUserId != null and secondUserId != ''">
  406. AND a.two_level_user_id = #{secondUserId}
  407. </if>
  408. <if test="thirdUserId != null and thirdUserId != ''">
  409. AND a.three_level_user_id = #{thirdUserId}
  410. </if>
  411. <if test="id != null and id != ''">
  412. AND a.id = #{id}
  413. </if>
  414. </select>
  415. <select id="getAlreadyAuditOrders" resultType="com.ydtech.modules.order.entity.InsOrders">
  416. SELECT
  417. io.*,
  418. sd.management_source,
  419. su2.name AS auditUser,
  420. ifa.audittime as auditTime
  421. FROM
  422. ins_orders io
  423. LEFT JOIN ins_fee_audit ifa ON ifa.orderno = io.orderno
  424. LEFT JOIN sys_user su ON su.id = io.userid
  425. LEFT JOIN sys_dept sd ON sd.id = su.dept_id
  426. LEFT JOIN sys_user su2 on ifa.audituser = su2.id
  427. WHERE
  428. io.orderno IN (
  429. SELECT
  430. orderno
  431. FROM
  432. ins_area_company
  433. WHERE
  434. id IN (
  435. SELECT
  436. ifon.ins_order_no
  437. FROM
  438. ins_fee_order_new ifon
  439. RIGHT JOIN ins_fee_audit ifa ON ifon.ins_order_no = ifa.ins_order_no
  440. WHERE
  441. ifa.auditstatus = #{params.auditStatus}
  442. )
  443. )
  444. AND orderstatus = 3
  445. <!-- <if test="params.orderNo != null and params.orderNo != ''">-->
  446. <!-- AND orderno = #{params.orderNo}-->
  447. <!-- </if>-->
  448. <if test="params.licenseNo != null and params.licenseNo != ''">
  449. AND licenseno = #{params.licenseNo}
  450. </if>
  451. <if test="params.frameNo != null and params.frameNo != ''">
  452. AND frameno = #{params.frameNo}
  453. </if>
  454. <if test="params.insuredName != null and params.insuredName != ''">
  455. AND insuredname = #{params.insuredName}
  456. </if>
  457. <if test="params.companyId != null and params.companyId != ''">
  458. AND company_id = #{params.companyId}
  459. </if>
  460. <if test="params.startDateStr != null and params.startDateStr != ''">
  461. AND createtime BETWEEN #{params.startDateStr} and #{params.endDateStr}
  462. </if>
  463. </select>
  464. <select id="selectListByDateStr" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
  465. -- 查询订单信息
  466. SELECT
  467. iac.*
  468. FROM
  469. ins_area_company iac
  470. left JOIN ins_orders AS io ON io.orderno = iac.orderno
  471. WHERE
  472. 1=1
  473. <if test="dateStr != null and dateStr != ''">
  474. AND DATE_FORMAT(io.createtime, '%Y-%m') =#{dateStr}
  475. </if>
  476. </select>
  477. <select id="selectListById" resultMap="BaseResultMap">
  478. SELECT
  479. iac.*
  480. FROM
  481. ins_area_company iac
  482. WHERE
  483. 1=1
  484. <if test="id != null and id != ''">
  485. AND iac.id =#{id}
  486. </if>
  487. </select>
  488. <select id="selectSecondPromotionByNew" resultType="com.ydtech.modules.order.entity.InsOrders">
  489. SELECT
  490. sum( fee.p ) as "willFirstPremiums"
  491. FROM
  492. (
  493. SELECT
  494. sum( a.first_detail_premiums ) AS p
  495. FROM
  496. ins_fee_order_new a
  497. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  498. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  499. <where>
  500. <choose>
  501. <when test='type == "1"'>
  502. iff.auditstatus=0
  503. </when>
  504. <otherwise>
  505. iff.auditstatus=1
  506. </otherwise>
  507. </choose>
  508. and iac.orderstatus = '3'
  509. <if test="userId!=null and userId!= ''">
  510. AND a.first_level_user_id = #{userId}
  511. </if>
  512. <if test="id != null and id!=''">
  513. AND a.id =#{id}
  514. </if>
  515. </where>
  516. UNION
  517. SELECT
  518. sum( a.third_detail_premiums ) AS p
  519. FROM
  520. ins_fee_order_new a
  521. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  522. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  523. <where>
  524. <choose>
  525. <when test='type == "1"'>
  526. iff.auditstatus=0
  527. </when>
  528. <otherwise>
  529. iff.auditstatus=1
  530. </otherwise>
  531. </choose>
  532. and iac.orderstatus = '3'
  533. <if test="userId!=null and userId!= ''">
  534. AND a.three_level_user_id = #{userId}
  535. </if>
  536. <if test="id != null and id!=''">
  537. AND a.id =#{id}
  538. </if>
  539. </where>
  540. UNION
  541. SELECT
  542. sum( a.second_detail_premiums ) AS p
  543. FROM
  544. ins_fee_order_new a
  545. LEFT JOIN ins_area_company iac ON iac.id = a.ins_order_no
  546. left join ins_fee_audit iff on a.ins_order_no=iff.ins_order_no
  547. <where>
  548. <choose>
  549. <when test='type == "1"'>
  550. iff.auditstatus=0
  551. </when>
  552. <otherwise>
  553. iff.auditstatus=1
  554. </otherwise>
  555. </choose>
  556. and iac.orderstatus = '3'
  557. <if test="userId!=null and userId!= ''">
  558. AND a.two_level_user_id = #{userId}
  559. </if>
  560. <if test="id != null and id!=''">
  561. AND a.id =#{id}
  562. </if>
  563. </where>
  564. ) AS fee
  565. </select>
  566. <select id="getSubOrderDetails" resultType="com.ydtech.modules.admin.model.vo.SubOrder">
  567. SELECT
  568. iac.id as subOrderId,
  569. iac.signing_time as signingTime,
  570. iac.jqpremium as jqpremium,
  571. iac.sypremium as sypremium,
  572. iac.jypremium as jypremium,
  573. io.licenseno as licenseno,
  574. io.userid as userId
  575. FROM
  576. ins_area_company iac
  577. LEFT JOIN ins_orders AS io ON io.orderno = iac.orderno
  578. WHERE
  579. iac.id=#{subOrderId}
  580. </select>
  581. <select id="premiumReportYear" resultType="com.ydtech.modules.admin.model.dto.PremiumReportDto">
  582. SELECT
  583. CONCAT(YEAR(iac.createtime),'-',LPAD(MONTH(iac.createtime), 2, '0')) reportDate,
  584. sum(jqpremium) jqpremium,
  585. sum(sypremium) sypremium,
  586. sum(sumpremium) sumpremium
  587. FROM
  588. ins_area_company iac left join ins_orders io on iac.orderno=io.orderno
  589. WHERE
  590. iac.orderstatus = 3 and
  591. iac.createtime &gt;= #{beginTime} and iac.createtime &lt;= #{endTime}
  592. and io.userid=#{userId}
  593. GROUP BY CONCAT(YEAR(iac.createtime),'-',LPAD(MONTH(iac.createtime), 2, '0'))
  594. </select>
  595. <select id="premiumReportMonth" resultType="com.ydtech.modules.admin.model.dto.PremiumReportDto">
  596. SELECT
  597. CONCAT(YEAR(iac.createtime),'-',LPAD(MONTH(iac.createtime), 2, '0'),'-',LPAD(Day(iac.createtime), 2, '0')) reportDate,
  598. sum(jqpremium) jqpremium,
  599. sum(sypremium) sypremium,
  600. sum(sumpremium) sumpremium
  601. FROM
  602. ins_area_company iac left join ins_orders io on iac.orderno=io.orderno
  603. WHERE
  604. iac.orderstatus = 3 and
  605. iac.createtime &gt;= #{beginTime} and iac.createtime &lt;= #{endTime}
  606. and io.userid=#{userId}
  607. GROUP BY CONCAT(YEAR(iac.createtime),'-',LPAD(MONTH(iac.createtime), 2, '0'),'-',LPAD(Day(iac.createtime), 2, '0'))
  608. </select>
  609. <select id="premiumReportDay" resultType="com.ydtech.modules.admin.model.dto.PremiumReportDto">
  610. SELECT
  611. CONCAT(YEAR ( iac.createtime ),'-',LPAD( MONTH ( iac.createtime ), 2, '0' ),'-',LPAD( DAY ( iac.createtime ), 2, '0' ),' ',LPAD( HOUR ( iac.createtime ), 2, '0' ))
  612. reportDate,
  613. sum( jqpremium ) jqpremium,
  614. sum( sypremium ) sypremium,
  615. sum( sumpremium ) sumpremium
  616. FROM
  617. ins_area_company iac left join ins_orders io on iac.orderno=io.orderno
  618. WHERE
  619. iac.orderstatus = 3 and
  620. iac.createtime &gt;= #{beginTime} and iac.createtime &lt;= #{endTime}
  621. and io.userid=#{userId}
  622. GROUP BY CONCAT(YEAR ( iac.createtime ),'-',LPAD( MONTH ( iac.createtime ), 2, '0' ),'-',LPAD( DAY ( iac.createtime ), 2, '0' ),' ',LPAD( HOUR ( iac.createtime ), 2, '0' ))
  623. </select>
  624. <select id="getAllpremium" resultType="com.ydtech.modules.admin.model.dto.AllpremiumDto">
  625. SELECT
  626. ifnull(sum( iac.jqpremium + iac.sypremium + iac.jypremium ),0) as sumPremium,
  627. count( 0 ) as sumCount
  628. FROM
  629. ins_area_company iac left join ins_orders io on iac.orderno=io.orderno
  630. WHERE
  631. iac.orderstatus = 3
  632. and io.userid=#{userId}
  633. AND YEAR (iac.createtime) = #{year}
  634. </select>
  635. <select id="getRejectOrder" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
  636. select
  637. iac.id,
  638. iac.orderno,
  639. iac.agreement_id,
  640. iac.jqpremium,
  641. iac.sypremium,
  642. iac.jypremium,
  643. iac.taxamount,
  644. iac.sumpremium,
  645. io.licenseno,
  646. ifa.audittime,
  647. ifa.audituser as auditname,
  648. ifa.rejectinfo,
  649. "1" as orderExternalStatus
  650. FROM
  651. ins_fee_audit ifa
  652. LEFT JOIN
  653. ins_area_company iac on iac.id = ifa.ins_order_no
  654. LEFT JOIN
  655. ins_orders io on iac.orderno = io.orderno
  656. left join
  657. sys_user su on su.id= ifa.audituser
  658. WHERE
  659. iac.operator_id = #{userId}
  660. AND
  661. ifa.auditstatus = 2
  662. <if test="vo.id != null and vo.id!=''">
  663. and iac.id = #{vo.id}
  664. </if>
  665. <if test="vo.licenseno != null and vo.licenseno!='' ">
  666. and io.licenseno like CONCAT('%', #{vo.licenseno}, '%')
  667. </if>
  668. <if test="vo.auditname != null and vo.auditname!='' ">
  669. and su.name like CONCAT('%', #{vo.auditname}, '%')
  670. </if>
  671. </select>
  672. <select id="queryBusinessDataPage"
  673. resultType="com.ydtech.modules.admin.model.report.opetationData.BusinessDataDto">
  674. SELECT
  675. <if test="flag != null and flag!='' and flag='1'">
  676. o.userid as userId,
  677. o.username as userName,
  678. </if>
  679. sum( iac.sumpremium ) as signeSumPremiumAmount,
  680. sum( iac.jqpremium ) as jqPremiumAmount,
  681. sum( iac.sypremium ) as syPremiumAmount,
  682. sum( iac.taxamount ) as taxAmount,
  683. sum( ion.no_premium ) as fcFeeAmount
  684. FROM
  685. ins_area_company iac
  686. LEFT JOIN ins_orders o ON iac.orderno = o.orderno
  687. LEFT JOIN ins_fee_order_new ion ON iac.id = ion.ins_order_no
  688. where iac.orderstatus = 3 and ion.id is not null
  689. <if test="userList != null and userList.size()>0 ">
  690. and o.userid IN
  691. <foreach item="item" collection="userList" open="(" separator="," close=")">
  692. #{item}
  693. </foreach>
  694. </if>
  695. <if test="flag != null and flag!='' and flag='1'">
  696. group by o.userid,o.username
  697. </if>
  698. </select>
  699. <select id="queryQuotationSubOrderCountDataPage"
  700. resultType="com.ydtech.modules.admin.model.report.opetationData.QuotationCountDataDto">
  701. SELECT
  702. <if test="flag != null and flag!='' and flag='1'">
  703. o.userid as userId,
  704. o.username as userName,
  705. </if>
  706. iac.orderstatus as orderStatus
  707. FROM
  708. ins_area_company iac
  709. LEFT JOIN ins_orders o ON iac.orderno = o.orderno
  710. where (iac.orderstatus = 0 or iac.orderstatus = 2 or iac.orderstatus = 3 )
  711. <if test="userList != null and userList.size()>0 ">
  712. and o.userid IN
  713. <foreach item="item" collection="userList" open="(" separator="," close=")">
  714. #{item}
  715. </foreach>
  716. </if>
  717. <if test="flag != null and flag!='' and flag='1'">
  718. group by o.userid,o.username,iac.orderstatus
  719. </if>
  720. </select>
  721. <select id="queryQuotationOrderCountDataPage"
  722. resultType="com.ydtech.modules.admin.model.report.opetationData.QuotationCountDataDto">
  723. SELECT
  724. a.userId as userId,
  725. a.userName as userName,
  726. b.qutationCount AS insOrderQutationCount,
  727. b.qutationInsureCount as insOrderQutationInsureCount,
  728. b.closeRate AS insOrderCloseRate as insOrderCloseRate,
  729. a.qutationCount as subOrderQutationCount,
  730. a.underwritingCount as subOrderUnderwritingCount,
  731. a.qutationInsureCount as subOrderQutationInsureCount,
  732. a.passRate as subOrderCloseRate,
  733. a.closeRate as subOrderPassRate,
  734. a.contributionRate as subOrderContributionRate
  735. FROM
  736. (
  737. SELECT
  738. inso.userid AS userId,
  739. inso.username AS userName,
  740. COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS qutationCount,
  741. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
  742. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  743. COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END )/ count( iac.orderstatus ) AS passRate,
  744. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )/ count( iac.orderstatus ) AS closeRate,
  745. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )/ COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS contributionRate
  746. FROM
  747. ins_area_company iac
  748. LEFT JOIN ins_orders inso ON iac.orderno = inso.orderno
  749. <where>
  750. <if test="userList != null and userList.size()>0 ">
  751. and o.userid IN
  752. <foreach item="item" collection="userList" open="(" separator="," close=")">
  753. #{item}
  754. </foreach>
  755. </if>
  756. </where>
  757. GROUP BY
  758. inso.userid,
  759. inso.username
  760. ) a
  761. LEFT JOIN (
  762. SELECT
  763. inso.userid AS userId,
  764. inso.username AS userName,
  765. count( inso.orderstatus ) AS qutationCount,
  766. count( CASE WHEN inso.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  767. COUNT( CASE WHEN inso.orderstatus = 3 THEN 1 END )/ count( inso.orderstatus ) AS closeRate
  768. FROM
  769. ins_orders inso
  770. <where>
  771. <if test="userList != null and userList.size()>0 ">
  772. and o.userid IN
  773. <foreach item="item" collection="userList" open="(" separator="," close=")">
  774. #{item}
  775. </foreach>
  776. </if>
  777. </where>
  778. GROUP BY
  779. inso.userid,
  780. inso.username
  781. ) b ON a.userId = b.userId
  782. </select>
  783. <select id="queryCompanyPremiumDataPage"
  784. resultType="com.ydtech.modules.admin.model.report.company.CompanyPremiumDataDto">
  785. SELECT
  786. agree.insurance_company_id AS companyId,
  787. agree.insurance_company AS companyName,
  788. agree.partner_companies_id AS parterCompanyId,
  789. ins.NAME AS parterCompanyName,
  790. sum( iac.sumpremium ) AS signeSumPremiumAmount
  791. FROM
  792. ins_area_company iac
  793. LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
  794. LEFT JOIN esm_ins_company ins ON agree.partner_companies_id = ins.id
  795. WHERE
  796. iac.orderstatus = 3
  797. and
  798. agree.id is not null
  799. <if test="vo.companyId != null and vo.companyId!='' ">
  800. agree.insurance_company_id = #{vo.companyId}
  801. </if>
  802. <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
  803. agree.insurance_company_id = #{vo.parterCompanyId}
  804. </if>
  805. GROUP BY
  806. agree.insurance_company_id,
  807. agree.insurance_company,
  808. agree.partner_companies_id,
  809. ins.NAME
  810. </select>
  811. <select id="queryCompanyQutationCountDataPage"
  812. resultType="com.ydtech.modules.admin.model.report.company.CompanyQutationCountDataDto">
  813. SELECT
  814. a.* ,
  815. (select ins.namesimple from esm_ins_company
  816. ins where a.parterCompanyId = ins.id) as "parterCompanyName"
  817. FROM
  818. (
  819. SELECT
  820. count(agree.partner_companies_id) as "orderSuccessNumber",
  821. agree.insurance_company AS companyName,
  822. agree.partner_companies_id AS parterCompanyId,
  823. iac.company_id as "companyId",
  824. count( iac.orderstatus ) AS qutationCount,
  825. count( iac.id ) AS orderSuccessNumberRate,
  826. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) + COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS underwritingCount,
  827. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  828. (COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) + COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )) / count( iac.orderstatus ) AS passRate,
  829. 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,
  830. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )/ count( iac.orderstatus ) AS contributionRate,
  831. COUNT(CASE WHEN agree.audit_type =1 and ifa.auditstatus =1 and iac.orderstatus =3 THEN 1 END) as "numberManual"
  832. FROM
  833. ins_area_company iac
  834. LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
  835. LEFT JOIN ins_orders io ON iac.orderno = io.orderno
  836. LEFT JOIN sys_dept sd ON sd.id = io.deptid
  837. LEFT JOIN ins_fee_audit ifa on ifa.ins_order_no =iac.id
  838. WHERE
  839. agree.id IS NOT NULL
  840. <if test="vo.companyId != null and vo.companyId!='' ">
  841. AND agree.insurance_company_id = #{vo.companyId}
  842. </if>
  843. <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
  844. AND agree.partner_companies_id = #{vo.parterCompanyId}
  845. </if>
  846. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  847. AND iac.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  848. </if>
  849. <if test="vo.managementSource != null and vo.managementSource!=''">
  850. AND sd.management_source =#{vo.managementSource}
  851. </if>
  852. <if test="vo.userId != null and vo.userId !=''">
  853. AND io.userid =#{vo.userId}
  854. </if>
  855. <if test="vo.deptId != null and vo.deptId !=''">
  856. AND io.deptId like concat('%',#{vo.leaderName},'%')
  857. </if>
  858. GROUP BY
  859. agree.insurance_company,
  860. iac.company_id,
  861. agree.partner_companies_id
  862. ) a
  863. </select>
  864. <select id="getInsAreaCompanyError"
  865. resultType="com.ydtech.modules.admin.model.report.company.CompanyQutationCountDataDto">
  866. SELECT
  867. count(iace.id) as "areaCompanyErrNumber"
  868. FROM
  869. ins_area_company_error iace
  870. LEFT JOIN ptl_agreement agree ON iace.agreement_id = agree.id
  871. <where>
  872. 1=1
  873. <if test="vo.companyId != null and vo.companyId!='' ">
  874. AND agree.insurance_company_id = #{vo.companyId}
  875. </if>
  876. <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
  877. AND agree.partner_companies_id = #{vo.parterCompanyId}
  878. </if>
  879. <if test="vo.userId != null and vo.userId!=''">
  880. AND iace.user_id =#{vo.userId}
  881. </if>
  882. </where>
  883. </select>
  884. <select id="queryCompanyQutationCountDataPageTotal"
  885. resultType="java.lang.Long">
  886. SELECT
  887. count(0)
  888. FROM
  889. (
  890. SELECT
  891. agree.partner_companies_id
  892. FROM
  893. ins_area_company iac
  894. LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
  895. LEFT JOIN ins_orders io ON iac.orderno = io.orderno
  896. LEFT JOIN sys_dept sd ON sd.id = io.deptid
  897. WHERE
  898. agree.id IS NOT NULL
  899. <if test="vo.companyId != null and vo.companyId!='' ">
  900. AND agree.insurance_company_id = #{vo.companyId}
  901. </if>
  902. <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
  903. AND agree.partner_companies_id = #{vo.parterCompanyId}
  904. </if>
  905. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  906. AND iac.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  907. </if>
  908. <if test="vo.managementSource != null and vo.managementSource!=''">
  909. AND sd.management_source =#{vo.managementSource}
  910. </if>
  911. <if test="vo.userId != null and vo.userId !=''">
  912. AND io.userid =#{vo.userId}
  913. </if>
  914. <if test="vo.deptId != null and vo.deptId !=''">
  915. AND io.deptId like concat('%',#{vo.leaderName},'%')
  916. </if>
  917. GROUP BY
  918. agree.partner_companies_id
  919. ) a
  920. </select>
  921. <select id="getStageOrder" resultType="com.ydtech.modules.order.entity.InsAreaCompany">
  922. select
  923. iac.id,
  924. iac.orderno,
  925. iac.agreement_id,
  926. iac.jqpremium,
  927. iac.sypremium,
  928. iac.jypremium,
  929. iac.taxamount,
  930. iac.sumpremium,
  931. io.licenseno,
  932. iac.createtime,
  933. "0" as orderExternalStatus
  934. FROM
  935. ins_area_company iac
  936. LEFT JOIN
  937. ins_orders io on iac.orderno = io.orderno
  938. left join ptl_agreement agree on iac.agreement_id =agree.id
  939. WHERE
  940. iac.operator_id = #{userId}
  941. AND
  942. iac.orderstatus = 0
  943. and agree.is_external =1
  944. <if test="vo.id != null and vo.id!='' ">
  945. and iac.id = #{vo.id}
  946. </if>
  947. <if test="vo.licenseno != null and vo.licenseno!='' ">
  948. and io.licenseno like CONCAT('%', #{vo.licenseno}, '%')
  949. </if>
  950. </select>
  951. <select id="queryPageTaskStatistics" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  952. select a.*, su.name as "userName",
  953. inf.url as "logo",
  954. sui.sex as "sex",
  955. su.leader_name as "leaderName"
  956. from (
  957. SELECT
  958. sd.NAME AS "deptName",
  959. io.userid AS "userId",
  960. sd.parent_id as "deptId",
  961. COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS qutationCount,
  962. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
  963. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  964. COUNT( CASE WHEN iac.orderstatus = 4 THEN 1 END ) AS underwritingReturn,
  965. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) / COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS "passingRate",
  966. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) / COUNT( iac.orderstatus ) AS "closeRate",
  967. (COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) + COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ))/ COUNT( iac.orderstatus ) AS "contributionRate",
  968. COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) / COUNT( iac.orderstatus ) AS "quotationRate",
  969. COUNT(CASE WHEN io.order_source = 0 and iac.orderstatus = 0 THEN 1 END) as "pcOrderSource",
  970. COUNT(CASE WHEN io.order_source = 1 and iac.orderstatus = 0 THEN 1 END) as "appOrderSource",
  971. COUNT( CASE WHEN iac.orderstatus = 1 THEN 1 END ) AS "auditOrder"
  972. FROM
  973. ins_area_company iac
  974. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  975. LEFT JOIN sys_dept sd ON sd.id = io.deptid
  976. <where>
  977. sd.management_source = '1'
  978. <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
  979. and io.deptid like "${taskStatisticsVo.provinceId}%"
  980. </if>
  981. <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
  982. and io.deptid like "${taskStatisticsVo.cityId}%"
  983. </if>
  984. <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
  985. and io.deptid like "${taskStatisticsVo.countyId}%"
  986. </if>
  987. <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
  988. and io.deptid like "${taskStatisticsVo.houseId}%"
  989. </if>
  990. <if test="taskStatisticsVo.userId != null and taskStatisticsVo.userId != ''">
  991. and io.userid =#{taskStatisticsVo.userId}
  992. </if>
  993. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  994. AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
  995. </if>
  996. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  997. AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
  998. </if>
  999. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1000. and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
  1001. </if>
  1002. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1003. <choose>
  1004. <when test="taskStatisticsVo.days =='1'">
  1005. and io.createtime >= DATE_SUB(NOW(), INTERVAL 1 DAY)
  1006. </when>
  1007. <when test="taskStatisticsVo.days =='7'">
  1008. and io.createtime >= DATE_SUB(NOW(), INTERVAL 7 DAY)
  1009. </when>
  1010. <when test="taskStatisticsVo.days =='30'">
  1011. and io.createtime >= DATE_SUB(NOW(), INTERVAL 30 DAY)
  1012. </when>
  1013. </choose>
  1014. </if>
  1015. </where>
  1016. GROUP BY
  1017. io.userid,
  1018. sd.NAME,
  1019. sd.id
  1020. ) a
  1021. left join sys_user su on su.id =a.userId
  1022. LEFT JOIN ins_upload_files inf on su.head_sculpture =inf.id
  1023. LEFT JOIN sys_user_info sui on sui .id =su.id
  1024. </select>
  1025. <select id="queryPageTaskStatisticsTotal" resultType="java.lang.Long">
  1026. select count(0) from (
  1027. SELECT
  1028. io.userid
  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.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1048. AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
  1049. </if>
  1050. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1051. AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
  1052. </if>
  1053. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1054. and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
  1055. </if>
  1056. <if test="taskStatisticsVo.userId != null and taskStatisticsVo.userId != ''">
  1057. and io.userid =#{taskStatisticsVo.userId}
  1058. </if>
  1059. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1060. <choose>
  1061. <when test="taskStatisticsVo.days =='1'">
  1062. and io.createtime >= DATE_SUB(NOW(), INTERVAL 1 DAY)
  1063. </when>
  1064. <when test="taskStatisticsVo.days =='7'">
  1065. and io.createtime >= DATE_SUB(NOW(), INTERVAL 7 DAY)
  1066. </when>
  1067. <when test="taskStatisticsVo.days =='30'">
  1068. and io.createtime >= DATE_SUB(NOW(), INTERVAL 30 DAY)
  1069. </when>
  1070. </choose>
  1071. </if>
  1072. </where>
  1073. GROUP BY
  1074. io.userid
  1075. ) a
  1076. </select>
  1077. <select id="insuranceCompanyQueryPage" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  1078. SELECT
  1079. a.*,
  1080. ( SELECT eic.namesimple FROM esm_ins_company eic WHERE eic.id = a.partner_companies_id ) AS "partnerCompaniesName"
  1081. FROM
  1082. (
  1083. SELECT
  1084. pa.insurance_company_id,
  1085. pa.partner_companies_id,
  1086. pa.insurance_company AS "insuranceCompanyName",
  1087. COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS qutationCount,
  1088. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
  1089. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  1090. COUNT( CASE WHEN iac.orderstatus = 4 THEN 1 END ) AS underwritingReturn,
  1091. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) / COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS "passingRate",
  1092. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) / COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS "closeRate",
  1093. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) / COUNT( iac.orderstatus ) AS "contributionRate",
  1094. COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) / COUNT( iac.orderstatus ) AS "quotationRate",
  1095. COUNT( CASE WHEN ifa.auditstatus = 0 THEN 1 END ) AS "auditOrder"
  1096. FROM
  1097. ins_area_company iac
  1098. LEFT JOIN ins_fee_audit ifa ON ifa.ins_order_no = iac.id
  1099. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  1100. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  1101. <where>
  1102. pa.insurance_company_id IS NOT NULL
  1103. <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
  1104. and io.deptid like concat('%', #{taskStatisticsVo.provinceId}, '%')
  1105. </if>
  1106. <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
  1107. and io.deptid like concat('%', #{taskStatisticsVo.cityId}, '%')
  1108. </if>
  1109. <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
  1110. and io.deptid like concat('%', #{taskStatisticsVo.countyId}, '%')
  1111. </if>
  1112. <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
  1113. and io.deptid like concat('%', #{taskStatisticsVo.houseId}, '%')
  1114. </if>
  1115. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1116. AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
  1117. </if>
  1118. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1119. AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
  1120. </if>
  1121. <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId != ''">
  1122. AND iac.company_id =#{taskStatisticsVo.companyId}
  1123. </if>
  1124. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1125. and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
  1126. </if>
  1127. </where>
  1128. GROUP BY
  1129. pa.insurance_company_id,
  1130. pa.partner_companies_id,
  1131. pa.insurance_company
  1132. ) a
  1133. </select>
  1134. <select id="insuranceCompanyQueryTotal" resultType="java.lang.Long">
  1135. SELECT
  1136. COUNT(0)
  1137. FROM
  1138. (
  1139. SELECT
  1140. pa.insurance_company_id,
  1141. pa.partner_companies_id
  1142. FROM
  1143. ins_area_company iac
  1144. LEFT JOIN ins_fee_audit ifa ON ifa.ins_order_no = iac.id
  1145. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  1146. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  1147. <where>
  1148. pa.insurance_company_id IS NOT NULL
  1149. <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
  1150. and io.deptid like concat('%', #{taskStatisticsVo.provinceId}, '%')
  1151. </if>
  1152. <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
  1153. and io.deptid like concat('%', #{taskStatisticsVo.cityId}, '%')
  1154. </if>
  1155. <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
  1156. and io.deptid like concat('%', #{taskStatisticsVo.countyId}, '%')
  1157. </if>
  1158. <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
  1159. and io.deptid like concat('%', #{taskStatisticsVo.houseId}, '%')
  1160. </if>
  1161. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1162. AND io.createtime BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
  1163. </if>
  1164. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1165. AND iac.createtime BETWEEN #{taskStatisticsVo.beginDate} AND #{taskStatisticsVo.endDate}
  1166. </if>
  1167. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1168. and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
  1169. </if>
  1170. </where>
  1171. GROUP BY
  1172. pa.insurance_company_id,
  1173. pa.partner_companies_id
  1174. ) total
  1175. </select>
  1176. <select id="agentStatisticsQueryPage" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  1177. SELECT
  1178. sd.name as "deptName",
  1179. su.name as "userName",
  1180. io.userid as "userId",
  1181. sd.id as "deptId",
  1182. COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS qutationCount,
  1183. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
  1184. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  1185. COUNT( CASE WHEN iac.orderstatus = 4 THEN 1 END ) AS underwritingReturn,
  1186. (COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) +COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )) / COUNT(iac.orderstatus) as "passingRate",
  1187. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) / COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) as "closeRate",
  1188. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) / COUNT(iac.orderstatus) as "contributionRate",
  1189. COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) / COUNT(iac.orderstatus) as "quotationRate",
  1190. COUNT( CASE WHEN iac.orderstatus = 1 THEN 1 END ) as "auditOrder"
  1191. FROM
  1192. ins_area_company iac
  1193. left join ins_orders io on io.orderno = iac.orderno
  1194. left join sys_dept sd on sd.id=io.deptid
  1195. left join sys_user su on su.id=io.userid
  1196. <where>
  1197. sd.management_source = '2'
  1198. <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
  1199. and io.deptid like "${taskStatisticsVo.provinceId}%"
  1200. </if>
  1201. <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
  1202. and io.deptid like "${taskStatisticsVo.cityId}%"
  1203. </if>
  1204. <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
  1205. and io.deptid like "${taskStatisticsVo.countyId}%"
  1206. </if>
  1207. <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
  1208. and io.deptid like "${taskStatisticsVo.houseId}%"
  1209. </if>
  1210. <if test="taskStatisticsVo.userId !=null and taskStatisticsVo.userId!='' ">
  1211. and io.userid =#{taskStatisticsVo.userId}
  1212. </if>
  1213. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1214. AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
  1215. </if>
  1216. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1217. AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
  1218. </if>
  1219. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1220. and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
  1221. </if>
  1222. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1223. <choose>
  1224. <when test="taskStatisticsVo.days =='1'">
  1225. and io.createtime >= DATE_SUB(NOW(), INTERVAL 1 DAY)
  1226. </when>
  1227. <when test="taskStatisticsVo.days =='7'">
  1228. and io.createtime >= DATE_SUB(NOW(), INTERVAL 7 DAY)
  1229. </when>
  1230. <when test="taskStatisticsVo.days =='30'">
  1231. and io.createtime >= DATE_SUB(NOW(), INTERVAL 30 DAY)
  1232. </when>
  1233. </choose>
  1234. </if>
  1235. </where>
  1236. GROUP BY io.userid , su.name, sd.id , sd.name
  1237. </select>
  1238. <select id="agentStatisticsQueryPageTotal" resultType="java.lang.Long">
  1239. select count(0) from (
  1240. SELECT
  1241. io.userid as "userId"
  1242. FROM
  1243. ins_area_company iac
  1244. left join ins_orders io on io.orderno = iac.orderno
  1245. left join sys_dept sd on sd.id=io.deptid
  1246. <where>
  1247. sd.management_source = '2'
  1248. <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
  1249. and io.deptid like "${taskStatisticsVo.provinceId}%"
  1250. </if>
  1251. <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
  1252. and io.deptid like "${taskStatisticsVo.cityId}%"
  1253. </if>
  1254. <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
  1255. and io.deptid like "${taskStatisticsVo.countyId}%"
  1256. </if>
  1257. <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
  1258. and io.deptid like "${taskStatisticsVo.houseId}%"
  1259. </if>
  1260. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1261. AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
  1262. </if>
  1263. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1264. AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
  1265. </if>
  1266. <if test="taskStatisticsVo.userId !=null and taskStatisticsVo.userId!='' ">
  1267. and io.userid =#{taskStatisticsVo.userId}
  1268. </if>
  1269. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1270. and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
  1271. </if>
  1272. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1273. <choose>
  1274. <when test="taskStatisticsVo.days =='1'">
  1275. and io.createtime >= DATE_SUB(NOW(), INTERVAL 1 DAY)
  1276. </when>
  1277. <when test="taskStatisticsVo.days =='7'">
  1278. and io.createtime >= DATE_SUB(NOW(), INTERVAL 7 DAY)
  1279. </when>
  1280. <when test="taskStatisticsVo.days =='30'">
  1281. and io.createtime >= DATE_SUB(NOW(), INTERVAL 30 DAY)
  1282. </when>
  1283. </choose>
  1284. </if>
  1285. </where>
  1286. GROUP BY io.userid
  1287. ) a
  1288. </select>
  1289. <select id="costCenter" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  1290. SELECT
  1291. iac.company_id,
  1292. iac.inscompany as "insuranceCompanyName",
  1293. COUNT( CASE WHEN ifa.auditstatus = 1 THEN 1 END ) AS "auditstatusOrders",
  1294. COUNT( CASE WHEN ifa.auditstatus = 0 THEN 1 END ) AS "auditOrder",
  1295. COUNT( CASE WHEN ifa.auditstatus = 1 and ifa.audituser != '自动审核' THEN 1 END ) AS "persionAudit",
  1296. COUNT( CASE WHEN ifa.audituser = '自动审核' THEN 1 END ) AS "automaticAudit"
  1297. FROM
  1298. ins_fee_audit ifa
  1299. LEFT JOIN ins_orders io ON io.orderno = ifa.orderno
  1300. LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
  1301. AND iac.orderstatus = 3
  1302. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  1303. LEFT JOIN esm_ins_company eic ON eic.id = pa.partner_companies_id
  1304. <where>
  1305. 1=1
  1306. and iac.id = ifa.ins_order_no
  1307. AND iac.orderstatus = 3
  1308. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1309. AND DATE_FORMAT( ifa.audittime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.createtimeStart}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.createtimeEnd}, '%Y-%m-%d')
  1310. </if>
  1311. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1312. AND DATE_FORMAT( ifa.audittime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
  1313. </if>
  1314. <choose>
  1315. <when test="taskStatisticsVo.riskCode != null and taskStatisticsVo.riskCode != '' and taskStatisticsVo.riskCode != 'all' ">
  1316. and iac.product = #{taskStatisticsVo.riskCode}
  1317. </when>
  1318. </choose>
  1319. </where>
  1320. GROUP BY
  1321. iac.company_id,
  1322. iac.inscompany
  1323. </select>
  1324. <select id="getOrderManpower" resultType="com.ydtech.modules.admin.model.dto.QxFrontlineAgentDto">
  1325. SELECT
  1326. count( a.numberUserId ) as "orderManpower",
  1327. sum( a.orderAmount ) as "totalPremium",
  1328. sum( a.orderAmount )/ count( a.numberUserId ) as "averagePremium"
  1329. FROM
  1330. (
  1331. SELECT
  1332. count( io.userid ) AS "numberUserId",
  1333. SUM(IFNULL(iac.jqpremium, 0)) +
  1334. SUM(IFNULL(iac.sypremium, 0)) +
  1335. SUM(IFNULL(iac.jypremium, 0)) AS "orderAmount"
  1336. FROM
  1337. `ins_area_company` iac
  1338. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  1339. <where>
  1340. iac.orderstatus = '3'
  1341. <if test="ids != null and ids.size()>0 ">
  1342. AND io.userid IN
  1343. <foreach item="item" collection="ids" open="(" separator="," close=")">
  1344. #{item}
  1345. </foreach>
  1346. </if>
  1347. </where>
  1348. GROUP BY
  1349. io.userid
  1350. ) a
  1351. </select>
  1352. <select id="getOrderManpowerNew" resultType="com.ydtech.modules.admin.model.dto.QxFrontlineAgentDto">
  1353. SELECT
  1354. count( a.numberUserId ) as "orderManpower",
  1355. IFNULL(sum( a.orderAmount ),0) as "totalPremium",
  1356. ROUND(sum( a.orderAmount )/ sum(a.ordernoNumber),2) AS "averagePremium"
  1357. FROM
  1358. (
  1359. SELECT
  1360. count( io.userid ) AS "numberUserId",
  1361. count( iac.orderno ) AS "ordernoNumber",
  1362. SUM(IFNULL(iac.jqpremium, 0)
  1363. +IFNULL(iac.sypremium, 0)
  1364. +IFNULL(iac.jypremium, 0)
  1365. ) AS "orderAmount"
  1366. FROM
  1367. `ins_area_company` iac
  1368. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  1369. <where>
  1370. iac.orderstatus = '3'
  1371. <if test="vo.ids != null and vo.ids.size()>0 ">
  1372. AND io.userid IN
  1373. <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
  1374. #{item}
  1375. </foreach>
  1376. </if>
  1377. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  1378. AND iac.createtime BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
  1379. </if>
  1380. </where>
  1381. GROUP BY
  1382. io.userid
  1383. ) a
  1384. order by sum( a.orderAmount ) desc
  1385. </select>
  1386. <select id="getChannelOrderManpowerNew" resultType="com.ydtech.modules.admin.model.dto.QxFrontlineAgentDto">
  1387. SELECT
  1388. a.userId as "userId",
  1389. a.userName as "name",
  1390. a.orderNumber as "orderNumber",
  1391. a.underwritingCount as "underwritingCount",
  1392. a.qutationInsureCount as "qutationInsureCount",
  1393. IFNULL(a.jqpremium,0) + IFNULL(a.sypremium,0) + IFNULL(a.jypremium,0) as "totalPremium",
  1394. a.isFactorVerify as "isFactorVerify",
  1395. a.isNotFactorVerify as "isNotFactorVerify"
  1396. FROM
  1397. (
  1398. SELECT
  1399. io.userid as "userId",
  1400. io.username as "userName",
  1401. count( iac.orderno ) AS "orderNumber",
  1402. sum(CASE WHEN iac.orderstatus = 3 THEN iac.jqpremium END ) AS jqpremium,
  1403. sum(CASE WHEN iac.orderstatus = 3 THEN iac.sypremium END ) AS sypremium,
  1404. sum(CASE WHEN iac.orderstatus = 3 THEN iac.jypremium END ) AS jypremium,
  1405. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
  1406. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  1407. COUNT( CASE WHEN su.factor_verify = 1 THEN 1 END ) AS isFactorVerify,
  1408. COUNT( CASE WHEN su.factor_verify = 0 THEN 1 END ) AS isNotFactorVerify
  1409. FROM
  1410. `ins_area_company` iac
  1411. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  1412. left join sys_user su on su.id=io.userid
  1413. <where>
  1414. <if test="vo.ids != null and vo.ids.size()>0 ">
  1415. AND io.userid IN
  1416. <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
  1417. #{item}
  1418. </foreach>
  1419. </if>
  1420. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  1421. AND iac.createtime BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
  1422. </if>
  1423. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  1424. AND iac.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  1425. </if>
  1426. </where>
  1427. GROUP BY
  1428. io.userid,
  1429. io.username
  1430. ) a
  1431. left join sys_user su on su.id=a.userId
  1432. </select>
  1433. <select id="NumberQuotations" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  1434. SELECT
  1435. count(iac.id) as "orderNumber",
  1436. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
  1437. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  1438. sum( CASE WHEN iac.orderstatus = 3 THEN IFNULL(iac.jqpremium, 0) + IFNULL(iac.sypremium, 0) + IFNULL(iac.jypremium, 0) END ) AS totalPremium
  1439. FROM
  1440. ins_area_company iac
  1441. left join ins_orders io on io.orderno = iac.orderno
  1442. left join sys_dept sd on sd.id=io.deptid
  1443. left join sys_user su on su.id=io.userid
  1444. left join ins_fee_audit ifa on ifa .ins_order_no =iac.id
  1445. <where>
  1446. sd.management_source = '2'
  1447. <if test="userId !=null and userId !=''">
  1448. and io.userId =#{userId}
  1449. </if>
  1450. </where>
  1451. </select>
  1452. <select id="totalQuotation" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  1453. SELECT
  1454. agree.insurance_company_id AS companyId,
  1455. agree.insurance_company AS companyName,
  1456. agree.partner_companies_id AS parterCompanyId,
  1457. ins.namesimple AS parterCompanyName,
  1458. count(iac.orderstatus) AS orderNumber,
  1459. '-' as bigQutationCount,
  1460. '-' as bigUnderwritingCount,
  1461. '-' as bigCloseRate,
  1462. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
  1463. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  1464. COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END )/ count(iac.orderstatus) AS passRate,
  1465. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END )/ count(iac.orderstatus) AS underwritingCountRate,
  1466. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )/ count(iac.orderstatus) AS closeRate,
  1467. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END )/ COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS
  1468. contributionRate
  1469. FROM
  1470. ins_area_company iac
  1471. LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
  1472. LEFT JOIN ins_orders io on io.orderno = iac.orderno
  1473. LEFT JOIN esm_ins_company ins ON agree.partner_companies_id = ins.id
  1474. WHERE
  1475. agree.id IS NOT NULL
  1476. <if test="vo.companyId != null and vo.companyId!='' ">
  1477. agree.insurance_company_id = #{vo.companyId}
  1478. </if>
  1479. <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
  1480. agree.partner_companies_id = #{vo.parterCompanyId}
  1481. </if>
  1482. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  1483. AND iac.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  1484. </if>
  1485. <if test="vo.provinceId != null and vo.provinceId != ''">
  1486. and io.deptid like "${vo.provinceId}%"
  1487. </if>
  1488. <if test="vo.cityId != null and vo.cityId != ''">
  1489. and io.deptid like "${vo.cityId}%"
  1490. </if>
  1491. <if test="vo.countyId != null and vo.countyId != ''">
  1492. and io.deptid like "${vo.countyId}%"
  1493. </if>
  1494. <if test="taskStatisticsVo.houseId != null and vo.houseId != ''">
  1495. and io.deptid like "${vo.houseId}%"
  1496. </if>
  1497. GROUP BY
  1498. agree.insurance_company_id,
  1499. agree.insurance_company,
  1500. agree.partner_companies_id,
  1501. ins.NAME
  1502. </select>
  1503. <select id="getBusinessData" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  1504. select
  1505. a.companyId as "companyId",
  1506. a.insuranceCompanyName as "insuranceCompanyName",
  1507. a.parterCompanyId as "parterCompanyId",
  1508. a.partnerCompaniesName as "partnerCompaniesName",
  1509. a.totalPremium as "totalPremium",
  1510. a.qutationInsureCount as "qutationInsureCount",
  1511. a.averagePremium as "averagePremium",
  1512. a.userNumber as "userNumber",
  1513. a.perCapitaAmount as "perCapitaAmount",
  1514. c.docking_person as "dockingPerson",
  1515. c.docking_phone as "dockingPhone",
  1516. c.agreement_type as "agreementType",
  1517. b.logo as "logo"
  1518. from (
  1519. SELECT
  1520. agree.insurance_company_id AS "companyId",
  1521. agree.insurance_company AS "insuranceCompanyName",
  1522. agree.partner_companies_id AS "parterCompanyId",
  1523. ins.namesimple AS "partnerCompaniesName",
  1524. agree.id as "agreeId",
  1525. IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0) as "totalPremium",
  1526. COUNT(0 ) AS "qutationInsureCount",
  1527. IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0) / COUNT(0 ) AS "averagePremium",
  1528. COUNT(DISTINCT io.userId) AS "userNumber",
  1529. IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0) / COUNT(DISTINCT io.userId) as "perCapitaAmount"
  1530. FROM
  1531. ins_area_company iac
  1532. LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
  1533. LEFT JOIN ins_orders io on io.orderno = iac.orderno
  1534. LEFT JOIN esm_ins_company ins ON agree.partner_companies_id = ins.id
  1535. WHERE
  1536. agree.id IS NOT NULL
  1537. and iac.orderstatus = '3'
  1538. <if test="vo.companyId != null and vo.companyId!='' ">
  1539. and agree.insurance_company_id = #{vo.companyId}
  1540. </if>
  1541. <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
  1542. and agree.partner_companies_id = #{vo.parterCompanyId}
  1543. </if>
  1544. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  1545. AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{vo.createtimeStart}, '%Y-%m-%d') AND DATE_FORMAT( #{vo.createtimeEnd}, '%Y-%m-%d')
  1546. </if>
  1547. <if test="vo.provinceId != null and vo.provinceId != '' and vo.cityId == null and vo.countyId == null and vo.houseId == null ">
  1548. and io.deptid like "${vo.provinceId}%"
  1549. </if>
  1550. <if test="vo.cityId != null and vo.cityId != '' and vo.countyId ==null and vo.houseId ==null">
  1551. and io.deptid like "${vo.cityId}%"
  1552. </if>
  1553. <if test="vo.countyId != null and vo.countyId != '' and vo.houseId ==null">
  1554. and io.deptid like "${vo.countyId}%"
  1555. </if>
  1556. <if test="vo.houseId != null and vo.houseId != ''">
  1557. and io.deptid like "${vo.houseId}%"
  1558. </if>
  1559. GROUP BY
  1560. agree.insurance_company_id,
  1561. agree.insurance_company,
  1562. agree.partner_companies_id,
  1563. agree.id
  1564. <choose>
  1565. <when test="vo.orderSort != null and vo.orderSort != '' and vo.userNumberSort == null ">
  1566. order by
  1567. sum(sumpremium) ${vo.orderSort == 'asc' ? 'asc' : 'desc'}
  1568. </when>
  1569. <when test="vo.userNumberSort != null and vo.userNumberSort != '' and vo.orderSort == null ">
  1570. order by
  1571. COUNT(DISTINCT io.userId) ${vo.userNumberSort == 'asc' ? 'asc' : 'desc'}
  1572. </when>
  1573. <when test="vo.userNumberSort != null and vo.userNumberSort != '' and vo.orderSort != null and vo.orderSort != '' ">
  1574. order by
  1575. COUNT(DISTINCT io.userId) ${vo.userNumberSort == 'asc' ? 'asc' : 'desc'}, sum(sumpremium) ${vo.orderSort == 'asc' ? 'asc' : 'desc'}
  1576. </when>
  1577. </choose>
  1578. ) a
  1579. left join esm_ins_company b on b.id =a.companyId
  1580. left join ptl_agreement c on c.id =a.agreeId
  1581. </select>
  1582. <select id="getDistribution" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  1583. SELECT
  1584. agree.insurance_company_id AS "companyId",
  1585. agree.insurance_company AS "insuranceCompanyName",
  1586. agree.partner_companies_id AS "parterCompanyId",
  1587. ins.namesimple AS "partnerCompaniesName",
  1588. IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0) as "totalPremium",
  1589. COUNT(0) AS "qutationInsureCount",
  1590. (IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0)) / COUNT(0) AS "averagePremium",
  1591. COUNT(DISTINCT io.userId) AS "userNumber",
  1592. (IFNULL(sum(iac.jqpremium),0) + IFNULL(sum(iac.sypremium),0) +IFNULL(sum(iac.jypremium),0)) / COUNT(DISTINCT io.userId) as "perCapitaAmount"
  1593. FROM
  1594. ins_area_company iac
  1595. LEFT JOIN ptl_agreement agree ON iac.agreement_id = agree.id
  1596. LEFT JOIN ins_orders io on io.orderno = iac.orderno
  1597. LEFT JOIN esm_ins_company ins ON agree.partner_companies_id = ins.id
  1598. WHERE
  1599. agree.id IS NOT NULL
  1600. <if test="vo.companyId != null and vo.companyId!='' ">
  1601. and agree.insurance_company_id = #{vo.companyId}
  1602. </if>
  1603. <if test="vo.parterCompanyId != null and vo.parterCompanyId!='' ">
  1604. and agree.partner_companies_id = #{vo.parterCompanyId}
  1605. </if>
  1606. <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
  1607. AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{vo.createtimeStart}, '%Y-%m-%d') AND DATE_FORMAT( #{vo.createtimeEnd}, '%Y-%m-%d')
  1608. </if>
  1609. <if test="vo.days !=null and vo.days !='' and vo.days != 0 ">
  1610. and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{vo.days} DAY)
  1611. </if>
  1612. <if test="vo.provinceId != null and vo.provinceId != ''">
  1613. and io.deptid like "${vo.provinceId}%"
  1614. </if>
  1615. <if test="vo.cityId != null and vo.cityId != ''">
  1616. and io.deptid like "${vo.cityId}%"
  1617. </if>
  1618. <if test="vo.countyId != null and vo.countyId != ''">
  1619. and io.deptid like "${vo.countyId}%"
  1620. </if>
  1621. <if test="vo.houseId != null and vo.houseId != ''">
  1622. and io.deptid like "${vo.houseId}%"
  1623. </if>
  1624. <if test="vo.quotationStatus != null and vo.quotationStatus != ''">
  1625. and iac.orderstatus =#{vo.quotationStatus}
  1626. </if>
  1627. GROUP BY
  1628. agree.insurance_company_id,
  1629. agree.insurance_company,
  1630. agree.partner_companies_id,
  1631. ins.namesimple
  1632. </select>
  1633. <select id="getOrderPremiumByUserIds" resultType="Double">
  1634. SELECT
  1635. IFNULL(
  1636. SUM( IFNULL( iac.jqpremium, 0 ) + IFNULL( iac.sypremium, 0 ) + IFNULL( iac.jypremium, 0 ) ),
  1637. 0
  1638. ) AS "totalPremium"
  1639. FROM
  1640. `ins_area_company` iac
  1641. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  1642. <where>
  1643. iac.orderstatus = '3'
  1644. <if test="ids != null and ids.size()>0 ">
  1645. AND io.userid IN
  1646. <foreach item="item" collection="ids" open="(" separator="," close=")">
  1647. #{item}
  1648. </foreach>
  1649. </if>
  1650. </where>
  1651. </select>
  1652. <select id="querOrdersDataPage" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
  1653. SELECT
  1654. count( 0 ) AS "orderNumber",
  1655. b.licenseno as "licenseno",
  1656. b.frameno as "frameno",
  1657. b.modelCode as "modelCode",
  1658. b.modelcname as "modelcname"
  1659. FROM
  1660. (
  1661. SELECT
  1662. io.orderstatus AS orderstatus,
  1663. io.frameno AS frameno,
  1664. REPLACE(JSON_EXTRACT(io.carinfo, '$.engineNo'), '"', '') as "modelCode",
  1665. REPLACE(JSON_EXTRACT(io.carinfo, '$.modelcname'), '"', '') as "modelcname",
  1666. ifnull(io.licenseno, '') AS licenseno
  1667. FROM
  1668. ins_orders io
  1669. LEFT JOIN sys_user su on io.userid=su.id
  1670. <where>
  1671. 1=1
  1672. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  1673. AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  1674. </if>
  1675. <if test="vo.licenseno != null and vo.licenseno!='' ">
  1676. AND io.licenseno =#{vo.licenseno}
  1677. </if>
  1678. <if test="vo.userId != null and vo.userId!='' ">
  1679. AND io.userid =#{vo.userId}
  1680. </if>
  1681. <if test="vo.userName != null and vo.userName!='' ">
  1682. AND su.name =#{vo.userName}
  1683. </if>
  1684. <if test="vo.mobile != null and vo.mobile!='' ">
  1685. AND su.mobile =#{vo.mobile}
  1686. </if>
  1687. <if test="vo.frameno != null and vo.frameno!='' ">
  1688. AND io.frameno =#{vo.frameno}
  1689. </if>
  1690. <if test="vo.deptId != null and vo.deptId!='' ">
  1691. and io.deptid like concat('%', #{vo.deptId}, '%')
  1692. </if>
  1693. <if test="vo.year != null and vo.year!='' ">
  1694. AND DATE_FORMAT( io.createtime, '%Y') =#{vo.year}
  1695. </if>
  1696. </where>
  1697. ) b
  1698. GROUP BY
  1699. b.licenseno,
  1700. b.frameno,
  1701. b.modelCode,
  1702. b.modelcname
  1703. </select>
  1704. <select id="getOrdersGroupByLicenseno" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
  1705. SELECT
  1706. io.licenseno AS "licenseno",
  1707. io.frameno AS "frameno",
  1708. io.orderstatus as "orderstatus",
  1709. io.orderno as "orderno"
  1710. FROM
  1711. ins_orders io
  1712. LEFT JOIN sys_user su on io.userid=su.id
  1713. <where>
  1714. io.licenseno is not null
  1715. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  1716. AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  1717. </if>
  1718. <if test="vo.licenseno != null and vo.licenseno!='' ">
  1719. AND io.licenseno =#{vo.licenseno}
  1720. </if>
  1721. <if test="vo.userId != null and vo.userId!='' ">
  1722. AND io.userId =#{vo.userId}
  1723. </if>
  1724. <if test="vo.userName != null and vo.userName!='' ">
  1725. AND su.name =#{vo.userName}
  1726. </if>
  1727. <if test="vo.mobile != null and vo.mobile!='' ">
  1728. AND su.mobile =#{vo.mobile}
  1729. </if>
  1730. <if test="vo.frameno != null and vo.frameno!='' ">
  1731. AND su.frameno =#{vo.frameno}
  1732. </if>
  1733. <if test="vo.deptId != null and vo.deptId!='' ">
  1734. and io.deptid like concat('%', #{vo.deptId}, '%')
  1735. </if>
  1736. </where>
  1737. </select>
  1738. <select id="querOrdersamountTo" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
  1739. select sum(a.orderNumber) as "orderNumber",
  1740. count(a.licenseno) as "b.frameno"
  1741. from (
  1742. SELECT
  1743. count( 0 ) AS "orderNumber",
  1744. b.licenseno as "licenseno",
  1745. b.frameno as "frameno"
  1746. FROM
  1747. (
  1748. SELECT
  1749. io.orderstatus AS orderstatus,
  1750. io.frameno AS frameno,
  1751. ifnull(io.licenseno, '') AS licenseno
  1752. FROM
  1753. ins_orders io
  1754. LEFT JOIN sys_user su on io.userid=su.id
  1755. <where>
  1756. 1=1
  1757. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  1758. AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  1759. </if>
  1760. <if test="vo.licenseno != null and vo.licenseno!='' ">
  1761. AND io.licenseno =#{vo.licenseno}
  1762. </if>
  1763. <if test="vo.userId != null and vo.userId!='' ">
  1764. AND io.userid =#{vo.userId}
  1765. </if>
  1766. <if test="vo.userName != null and vo.userName!='' ">
  1767. AND su.name =#{vo.userName}
  1768. </if>
  1769. <if test="vo.mobile != null and vo.mobile!='' ">
  1770. AND su.mobile =#{vo.mobile}
  1771. </if>
  1772. <if test="vo.frameno != null and vo.frameno!='' ">
  1773. AND io.frameno =#{vo.frameno}
  1774. </if>
  1775. <if test="vo.deptId != null and vo.deptId!='' ">
  1776. and io.deptid like concat('%', #{vo.deptId}, '%')
  1777. </if>
  1778. </where>
  1779. ) b
  1780. GROUP BY
  1781. b.licenseno,
  1782. b.frameno
  1783. ) a
  1784. </select>
  1785. <select id="querResultOrderNumber" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
  1786. SELECT
  1787. count( io.orderno ) AS "orderNumber",
  1788. 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"
  1789. FROM
  1790. ins_orders io
  1791. LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
  1792. LEFT JOIN sys_user su ON io.userid = su.id
  1793. <where>
  1794. 1=1
  1795. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  1796. AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  1797. </if>
  1798. <if test="vo.licenseno != null and vo.licenseno!='' ">
  1799. AND io.licenseno =#{vo.licenseno}
  1800. </if>
  1801. <if test="vo.userId != null and vo.userId!='' ">
  1802. AND io.userid =#{vo.userId}
  1803. </if>
  1804. <if test="vo.userName != null and vo.userName!='' ">
  1805. AND su.name =#{vo.userName}
  1806. </if>
  1807. <if test="vo.mobile != null and vo.mobile!='' ">
  1808. AND su.mobile =#{vo.mobile}
  1809. </if>
  1810. <if test="vo.frameno != null and vo.frameno!='' ">
  1811. AND su.frameno =#{vo.frameno}
  1812. </if>
  1813. <if test="vo.deptId != null and vo.deptId!='' ">
  1814. and io.deptid like concat('%', #{vo.deptId}, '%')
  1815. </if>
  1816. </where>
  1817. </select>
  1818. <select id="numberQuotationsByUserIds" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
  1819. SELECT
  1820. count(iac.id) as "orderNumber",
  1821. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
  1822. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  1823. sum( CASE WHEN iac.orderstatus = 3 THEN IFNULL(iac.jqpremium, 0) + IFNULL(iac.sypremium, 0) + IFNULL(iac.jypremium, 0) END ) AS totalPremium
  1824. FROM
  1825. ins_area_company iac
  1826. left join ins_orders io on io.orderno = iac.orderno
  1827. <where>
  1828. <if test="ids != null and ids.size()>0 ">
  1829. AND io.userid IN
  1830. <foreach item="item" collection="ids" open="(" separator="," close=")">
  1831. #{item}
  1832. </foreach>
  1833. </if>
  1834. <if test="month != null and month!='' ">
  1835. AND DATE_FORMAT(iac.createtime, '%Y-%m') =#{month}
  1836. </if>
  1837. </where>
  1838. </select>
  1839. <select id="selectByOrdersDataVo" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
  1840. select
  1841. iac.inscompany as "namesimple"
  1842. from
  1843. ins_area_company iac
  1844. <where>
  1845. 1=1
  1846. <if test="vo.orderstatus != null and vo.orderstatus != '' ">
  1847. AND iac.orderstatus =#{vo.orderstatus}
  1848. </if>
  1849. <if test="vo.orderno !=null and vo.orderno !='' ">
  1850. AND iac.orderno =#{vo.orderno}
  1851. </if>
  1852. </where>
  1853. </select>
  1854. <select id="channelExcel" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsExcel">
  1855. select a.*,(select name from sys_user where id =a.userId) as "userName"
  1856. from (
  1857. SELECT
  1858. sd.NAME AS "deptName",
  1859. io.userid AS "userId",
  1860. sd.parent_id as "deptId",
  1861. COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS qutationCount,
  1862. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
  1863. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  1864. COUNT( CASE WHEN iac.orderstatus = 4 THEN 1 END ) AS underwritingReturn,
  1865. (COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) / COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END )) * 100 AS "passingRate",
  1866. (COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) / COUNT( iac.orderstatus )) * 100 AS "closeRate",
  1867. ((COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) + COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ))/ COUNT( iac.orderstatus )) * 100 AS "contributionRate",
  1868. (COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) / COUNT( iac.orderstatus )) * 100 AS "quotationRate",
  1869. COUNT( CASE WHEN iac.orderstatus = 1 THEN 1 END ) AS "auditOrder"
  1870. FROM
  1871. ins_area_company iac
  1872. LEFT JOIN ins_orders io ON io.orderno = iac.orderno
  1873. LEFT JOIN sys_dept sd ON sd.id = io.deptid
  1874. <where>
  1875. 1=1
  1876. <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
  1877. and io.deptid like "${taskStatisticsVo.provinceId}%"
  1878. </if>
  1879. <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
  1880. and io.deptid like "${taskStatisticsVo.cityId}%"
  1881. </if>
  1882. <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
  1883. and io.deptid like "${taskStatisticsVo.countyId}%"
  1884. </if>
  1885. <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
  1886. and io.deptid like "${taskStatisticsVo.houseId}%"
  1887. </if>
  1888. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1889. AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
  1890. </if>
  1891. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1892. AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
  1893. </if>
  1894. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1895. and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
  1896. </if>
  1897. <if test="taskStatisticsVo.managementSource!=null and taskStatisticsVo.managementSource!=''">
  1898. and sd.management_source=#{taskStatisticsVo.managementSource}
  1899. </if>
  1900. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1901. <choose>
  1902. <when test="taskStatisticsVo.days =='1'">
  1903. and io.createtime >= DATE_SUB(NOW(), INTERVAL 1 DAY)
  1904. </when>
  1905. <when test="taskStatisticsVo.days =='7'">
  1906. and io.createtime >= DATE_SUB(NOW(), INTERVAL 7 DAY)
  1907. </when>
  1908. <when test="taskStatisticsVo.days =='30'">
  1909. and io.createtime >= DATE_SUB(NOW(), INTERVAL 30 DAY)
  1910. </when>
  1911. </choose>
  1912. </if>
  1913. </where>
  1914. GROUP BY
  1915. io.userid,
  1916. sd.NAME,
  1917. sd.id
  1918. ) a
  1919. </select>
  1920. <select id="insuranceCompanyExcel" resultType="com.ydtech.modules.admin.model.dto.InsuranceCompanyExcel">
  1921. SELECT
  1922. a.*,
  1923. ( SELECT eic.namesimple FROM esm_ins_company eic WHERE eic.id = a.partner_companies_id ) AS "partnerCompaniesName"
  1924. FROM
  1925. (
  1926. SELECT
  1927. pa.insurance_company_id,
  1928. pa.partner_companies_id,
  1929. pa.insurance_company AS "insuranceCompanyName",
  1930. COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS qutationCount,
  1931. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) AS underwritingCount,
  1932. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) AS qutationInsureCount,
  1933. COUNT( CASE WHEN iac.orderstatus = 4 THEN 1 END ) AS underwritingReturn,
  1934. COUNT( CASE WHEN iac.orderstatus = 2 THEN 1 END ) / COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS "passingRate",
  1935. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) / COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) AS "closeRate",
  1936. COUNT( CASE WHEN iac.orderstatus = 3 THEN 1 END ) / COUNT( iac.orderstatus ) AS "contributionRate",
  1937. COUNT( CASE WHEN iac.orderstatus = 0 THEN 1 END ) / COUNT( iac.orderstatus ) AS "quotationRate",
  1938. COUNT( CASE WHEN ifa.auditstatus = 0 THEN 1 END ) AS "auditOrder"
  1939. FROM
  1940. ins_area_company iac
  1941. LEFT JOIN ins_fee_audit ifa ON ifa.ins_order_no = iac.id
  1942. LEFT JOIN ptl_agreement pa ON pa.id = iac.agreement_id
  1943. <where>
  1944. pa.insurance_company_id IS NOT NULL
  1945. <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
  1946. and io.deptid like "${taskStatisticsVo.provinceId}%"
  1947. </if>
  1948. <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
  1949. and io.deptid like "${taskStatisticsVo.cityId}%"
  1950. </if>
  1951. <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
  1952. and io.deptid like "${taskStatisticsVo.countyId}%"
  1953. </if>
  1954. <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
  1955. and io.deptid like "${taskStatisticsVo.houseId}%"
  1956. </if>
  1957. <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
  1958. AND DATE_FORMAT( io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
  1959. </if>
  1960. <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
  1961. AND DATE_FORMAT( iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
  1962. </if>
  1963. <if test="taskStatisticsVo.companyId !=null and taskStatisticsVo.companyId != ''">
  1964. AND iac.company_id =#{taskStatisticsVo.companyId}
  1965. </if>
  1966. <if test="taskStatisticsVo.days !=null and taskStatisticsVo.days !='' ">
  1967. and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{taskStatisticsVo.days} DAY)
  1968. </if>
  1969. </where>
  1970. GROUP BY
  1971. pa.insurance_company_id,
  1972. pa.partner_companies_id,
  1973. pa.insurance_company
  1974. ) a
  1975. </select>
  1976. <select id="getSumBigOrderCount" resultType="com.ydtech.modules.admin.model.report.company.OrdersDataDto">
  1977. select count(0) as "orderNumber",
  1978. GROUP_CONCAT(inscompany ORDER BY inscompany SEPARATOR ',') as "namesimple"
  1979. from ins_area_company iac
  1980. left join ins_orders io on io.orderno = iac.orderno
  1981. <where>
  1982. 1=1
  1983. and iac.orderstatus ='3'
  1984. and io.orderstatus ='3'
  1985. <if test="vo.licenseno !=null and vo.licenseno!=''">
  1986. AND io.licenseno =#{vo.licenseno}
  1987. </if>
  1988. <if test="vo.frameno !=null and vo.frameno!=''">
  1989. AND io.frameno =#{vo.frameno}
  1990. </if>
  1991. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  1992. AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  1993. </if>
  1994. <if test="vo.year != null and vo.year!='' ">
  1995. AND DATE_FORMAT( io.createtime, '%Y') =#{vo.year}
  1996. </if>
  1997. </where>
  1998. </select>
  1999. <select id="queryAgencyUserInsAreaPage" resultType="com.ydtech.modules.admin.model.vo.AgencyUserInsAreaVo">
  2000. select
  2001. io.userid as userId,
  2002. io.username as userName,
  2003. io.licenseno as licenseno,
  2004. iac.id as companyId,
  2005. iac.jqpremium as jqpremium,
  2006. iac.sypremium as sypremium,
  2007. iac.jypremium as jypremium,
  2008. iac.createtime as createtime,
  2009. iac.orderstatus as orderstatus
  2010. from ins_area_company iac
  2011. left join ins_orders io on io.orderno = iac.orderno
  2012. <where>
  2013. iac.orderstatus=3
  2014. <if test="dto.userId !=null and dto.userId !=''">
  2015. and io.userid = #{dto.userId}
  2016. </if>
  2017. <if test="dto.deptId !=null and dto.deptId !=''">
  2018. and io.deptid = #{dto.deptId}
  2019. </if>
  2020. <if test="dto.startTime !=null and dto.startTime !=''">
  2021. and io.createtime >= #{dto.startTime}
  2022. </if>
  2023. </where>
  2024. ORDER BY iac.createtime
  2025. </select>
  2026. <select id="querOrdersDataListExcel" resultType="com.ydtech.modules.admin.model.dto.OrdersDataExcel">
  2027. select a.*,
  2028. IFNULL(b.orderNumber,0)/IFNULL(a.orderNumber ,0)
  2029. from (
  2030. SELECT
  2031. count( 0 ) AS "orderNumber",
  2032. b.licenseno as "licenseno",
  2033. b.modelCode as "modelCode",
  2034. b.modelcname as "modelcname",
  2035. b.frameno as "frameno"
  2036. FROM
  2037. (
  2038. SELECT
  2039. io.orderstatus AS orderstatus,
  2040. io.frameno AS frameno,
  2041. REPLACE(JSON_EXTRACT(io.carinfo, '$.engineNo'), '"', '') as "modelCode",
  2042. REPLACE(JSON_EXTRACT(io.carinfo, '$.modelcname'), '"', '') as "modelcname",
  2043. ifnull(io.licenseno, '') AS licenseno
  2044. FROM
  2045. ins_orders io
  2046. LEFT JOIN sys_user su on io.userid=su.id
  2047. <where>
  2048. 1=1
  2049. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  2050. AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  2051. </if>
  2052. <if test="vo.licenseno != null and vo.licenseno!='' ">
  2053. AND io.licenseno =#{vo.licenseno}
  2054. </if>
  2055. <if test="vo.userId != null and vo.userId!='' ">
  2056. AND io.userid =#{vo.userId}
  2057. </if>
  2058. <if test="vo.userName != null and vo.userName!='' ">
  2059. AND su.name =#{vo.userName}
  2060. </if>
  2061. <if test="vo.mobile != null and vo.mobile!='' ">
  2062. AND su.mobile =#{vo.mobile}
  2063. </if>
  2064. <if test="vo.frameno != null and vo.frameno!='' ">
  2065. AND io.frameno =#{vo.frameno}
  2066. </if>
  2067. <if test="vo.deptId != null and vo.deptId!='' ">
  2068. and io.deptid like concat('%', #{vo.deptId}, '%')
  2069. </if>
  2070. <if test="vo.year != null and vo.year!='' ">
  2071. AND DATE_FORMAT( io.createtime, '%Y') =#{vo.year}
  2072. </if>
  2073. </where>
  2074. ) b
  2075. GROUP BY
  2076. b.licenseno,
  2077. b.frameno,
  2078. b.modelCode,
  2079. b.modelcname
  2080. ) a
  2081. left join (
  2082. select count(0) as "orderNumber",
  2083. GROUP_CONCAT(inscompany ORDER BY inscompany SEPARATOR ',') as "namesimple",
  2084. io.licenseno as "licenseno"
  2085. from ins_area_company iac
  2086. left join ins_orders io on io.orderno = iac.orderno
  2087. <where>
  2088. 1=1
  2089. and iac.orderstatus ='3'
  2090. and io.orderstatus ='3'
  2091. <if test="vo.licenseno !=null and vo.licenseno!=''">
  2092. AND io.licenseno =#{vo.licenseno}
  2093. </if>
  2094. <if test="vo.frameno !=null and vo.frameno!=''">
  2095. AND io.frameno =#{vo.frameno}
  2096. </if>
  2097. <if test="vo.beginDate != null and vo.beginDate!='' and vo.endDate != null and vo.endDate!=''">
  2098. AND io.createtime BETWEEN #{vo.beginDate} AND #{vo.endDate}
  2099. </if>
  2100. <if test="vo.year != null and vo.year!='' ">
  2101. AND DATE_FORMAT( io.createtime, '%Y') =#{vo.year}
  2102. </if>
  2103. </where>
  2104. group by
  2105. io.licenseno
  2106. ) b on b.licenseno =a.licenseno
  2107. </select>
  2108. </mapper>