<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "http://mybatis.org/dtd/mybatis-3-mapper.dtd" "mybatis-3-mapper.dtd" > <mapper namespace="com.reyun.saas.report.data.dao.DataInfoDayMapper"> <select id="statisticAnalysis" resultType="Map"> select ${params.idColumn} <include refid="commonStatisticAnalysisSumSQL"/> from ( <if test="data.dateType==1 or data.dateType==3 "> select ${params.idColumn} <include refid="commonStatisticAnalysisDataSQL"/> from `yy-flink`.data_info_day where ds >= #{data.startDateStream} and ds <= #{data.endDateStream} and os = #{data.os} and <if test="data.os==2"> <foreach collection="data.appkeyAndCidsList" item="appkeyAndCids" open="(" close=")" separator="or"> ( appkey = #{appkeyAndCids.appkey} and cid in <foreach collection="appkeyAndCids.cids" item="cid" open="(" close=")" separator=","> #{cid} </foreach> ) </foreach> </if> <if test="data.os==1"> appkey in <foreach collection="data.appkeyAndCidsList" item="appkeyAndCids" open="(" close=")" separator=","> #{appkeyAndCids.appkey} </foreach> </if> <if test="data.sdkVersions!=null"> and sdk_version in (${data.sdkVersions}) </if> <if test="data.appVersions!=null"> and app_version in (${data.appVersions}) </if> <if test="data.sysVersions!=null"> and system_version in (${data.sysVersions}) </if> <if test="data.models!=null"> and model_equip in (${data.models}) </if> <if test="data.brands!=null"> and brand_equip in (${data.brands}) </if> </if> <if test="data.dateType==3 "> union all </if> <if test="data.dateType==2 or data.dateType==3 "> select ${params.idColumn} <include refid="commonStatisticAnalysisDataSQL"/> from `yy_etl`.data_info_day where ds >= #{data.startDateOffLine} and ds <= #{data.endDateOffLine} and os = #{data.os} and <if test="data.os==2"> <foreach collection="data.appkeyAndCidsList" item="appkeyAndCids" open="(" close=")" separator="or"> ( appkey = #{appkeyAndCids.appkey} and cid in <foreach collection="appkeyAndCids.cids" item="cid" open="(" close=")" separator=","> #{cid} </foreach> ) </foreach> </if> <if test="data.os==1"> appkey in <foreach collection="data.appkeyAndCidsList" item="appkeyAndCids" open="(" close=")" separator=","> #{appkeyAndCids.appkey} </foreach> </if> <if test="data.sdkVersions!=null"> and sdk_version in (${data.sdkVersions}) </if> <if test="data.appVersions!=null"> and app_version in (${data.appVersions}) </if> <if test="data.sysVersions!=null"> and system_version in (${data.sysVersions}) </if> <if test="data.models!=null"> and model_equip in (${data.models}) </if> <if test="data.brands!=null"> and brand_equip in (${data.brands}) </if> </if> ) a GROUP BY ${params.idColumn} <if test="params.orderByColumn!=null"> order by ${params.orderByColumn} </if> </select> <select id="statisticAnalysisTotal" resultType="Map"> select '汇总' as ${params.idColumn} <include refid="commonStatisticAnalysisSumSQL"/> from ( <if test="data.dateType==1 or data.dateType==3 "> select ${params.idColumn} <include refid="commonStatisticAnalysisDataSQL"/> from `yy-flink`.data_info_day where ds >= #{data.startDateStream} and ds <= #{data.endDateStream} and os = #{data.os} and <if test="data.os==2"> <foreach collection="data.appkeyAndCidsList" item="appkeyAndCids" open="(" close=")" separator="or"> ( appkey = #{appkeyAndCids.appkey} and cid in <foreach collection="appkeyAndCids.cids" item="cid" open="(" close=")" separator=","> #{cid} </foreach> ) </foreach> </if> <if test="data.os==1"> appkey in <foreach collection="data.appkeyAndCidsList" item="appkeyAndCids" open="(" close=")" separator=","> #{appkeyAndCids.appkey} </foreach> </if> <if test="data.sdkVersions!=null"> and sdk_version in (${data.sdkVersions}) </if> <if test="data.appVersions!=null"> and app_version in (${data.appVersions}) </if> <if test="data.sysVersions!=null"> and system_version in (${data.sysVersions}) </if> <if test="data.models!=null"> and model_equip in (${data.models}) </if> <if test="data.brands!=null"> and brand_equip in (${data.brands}) </if> </if> <if test="data.dateType==3 "> union all </if> <if test="data.dateType==2 or data.dateType==3 "> select ${params.idColumn} <include refid="commonStatisticAnalysisDataSQL"/> from `yy_etl`.data_info_day where ds >= #{data.startDateOffLine} and ds <= #{data.endDateOffLine} and os = #{data.os} and <if test="data.os==2"> <foreach collection="data.appkeyAndCidsList" item="appkeyAndCids" open="(" close=")" separator="or"> ( appkey = #{appkeyAndCids.appkey} and cid in <foreach collection="appkeyAndCids.cids" item="cid" open="(" close=")" separator=","> #{cid} </foreach> ) </foreach> </if> <if test="data.os==1"> appkey in <foreach collection="data.appkeyAndCidsList" item="appkeyAndCids" open="(" close=")" separator=","> #{appkeyAndCids.appkey} </foreach> </if> <if test="data.sdkVersions!=null"> and sdk_version in (${data.sdkVersions}) </if> <if test="data.appVersions!=null"> and app_version in (${data.appVersions}) </if> <if test="data.sysVersions!=null"> and system_version in (${data.sysVersions}) </if> <if test="data.models!=null"> and model_equip in (${data.models}) </if> <if test="data.brands!=null"> and brand_equip in (${data.brands}) </if> </if> ) a </select> </mapper>