ChannelRiskDataMapper.xml 6.25 KB
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.com.glsx.datariskcon.modules.mapper.ChannelRiskDataMapper">
    <resultMap id="BaseResultMap" type="cn.com.glsx.datariskcon.modules.entity.ChannelRiskData">
        <id column="id" jdbcType="INTEGER" property="id"/>
        <result column="workorder_no" jdbcType="VARCHAR" property="workorder_no"/>
        <result column="owner_name" jdbcType="VARCHAR" property="owner_name"/>
        <result column="vin" jdbcType="VARCHAR" property="vin"/>
        <result column="sn" jdbcType="VARCHAR" property="sn"/>
        <result column="active_date" jdbcType="TIMESTAMP" property="active_date"/>
        <result column="dev_type" jdbcType="INTEGER" property="dev_type"/>
        <result column="gps_time" jdbcType="TIMESTAMP" property="gps_time"/>
        <result column="lng" jdbcType="DOUBLE" property="lng"/>
        <result column="lat" jdbcType="DOUBLE" property="lat"/>
        <result column="prov" jdbcType="VARCHAR" property="prov"/>
        <result column="city" jdbcType="VARCHAR" property="city"/>
        <result column="zone" jdbcType="VARCHAR" property="zone"/>
        <result column="address" jdbcType="VARCHAR" property="address"/>
        <result column="shop_name" jdbcType="VARCHAR" property="shop_name"/>
        <result column="labels" jdbcType="VARCHAR" property="labels"/>
        <result column="type" jdbcType="INTEGER" property="type"/>
    </resultMap>
    <sql id="Base_Column_List">
        id, workorder_no, owner_name,vin, sn, active_date, dev_type,gps_time, lng,
        lat, prov,city,zone,address,shop_name,labels,type
    </sql>

    <select id="findChannelAllRiskData" resultMap="BaseResultMap">
        select
        active_date,owner_name,vin,sn,address,lng,lat,zone
        FROM t_channel_risk_data
        <if test="isExcep == 'true'">
            where type=1
        </if>
        <if test="isExcep == 'false'">
            where type=0
        </if>
        <if test="channelName !=null and channelName !=''">
            and shop_name=#{channelName}
        </if>
    </select>

    <select id="findProInstallSheet" resultType="java.util.Map">
        select
        prov as xAxis,count(prov) as value
        from t_channel_risk_data
        where type=0
        <if test="channelName !=null and channelName !=''">
            and shop_name=#{channelName}
        </if>
        <if test="monthNum !=null and monthNum !=''">
            and gps_time>=DATE_SUB(last_day(curdate()), INTERVAL #{monthNum} MONTH)+1
        </if>
        group by prov
    </select>

    <select id="findCityInstallSheet" resultType="java.util.Map">
        select
        city as xAxis,count(city) as value
        from t_channel_risk_data
        where prov=#{proviceName}
        and type=0
        <if test="monthNum !=null and monthNum !=''">
            and gps_time>=DATE_SUB(last_day(curdate()), INTERVAL #{monthNum} MONTH)+1
        </if>
        <if test="channelName !=null and channelName !=''">
            and shop_name=#{channelName}
        </if>
        group by city
    </select>

    <select id="findZoneInstallSheet" resultType="java.util.Map">
        select
        zone as xAxis,count(zone) as value
        from t_channel_risk_data
        where city=#{cityName}
        and type=0
        <if test="monthNum !=null and monthNum !=''">
            and gps_time>=DATE_SUB(last_day(curdate()), INTERVAL #{monthNum} MONTH)+1
        </if>
        <if test="channelName !=null and channelName !=''">
            and shop_name=#{channelName}
        </if>
        group by zone
    </select>

    <select id="findTimeInstallSheet" resultType="java.util.Map">
        select
        concat(DATE_FORMAT(gps_time,'%m'),'月份') as xAxis,
        count(id) as value
        from t_channel_risk_data
        where type=0
        <if test="monthNum !=null and monthNum !=''">
            and gps_time>=DATE_SUB(last_day(curdate()), INTERVAL #{monthNum} MONTH)+1
        </if>
        <if test="channelName !=null and channelName !=''">
            and shop_name=#{channelName}
        </if>
        group by xAxis
    </select>

    <select id="findProTimeInstallSheet" resultType="java.util.Map">
        select
        concat(DATE_FORMAT(gps_time,'%m'),'月份') as xAxis,
        count(id) as value
        from t_channel_risk_data
        where type=0
        <if test="monthNum !=null and monthNum !=''">
            and gps_time>=DATE_SUB(last_day(curdate()), INTERVAL #{monthNum} MONTH)+1
        </if>
        <if test="channelName !=null and channelName !=''">
            and shop_name=#{channelName}
        </if>
        and prov=#{proviceName}
        group by xAxis
    </select>

    <select id="findCityTimeInstallSheet" resultType="java.util.Map">
        select
        concat(DATE_FORMAT(gps_time,'%m'),'月份') as xAxis,
        count(id) as value
        from t_channel_risk_data
        where type=0
        <if test="monthNum !=null and monthNum !=''">
            and gps_time>=DATE_SUB(last_day(curdate()), INTERVAL #{monthNum} MONTH)+1
        </if>
        <if test="channelName !=null and channelName !=''">
            and shop_name=#{channelName}
        </if>
        and city=#{cityName}
        group by xAxis
    </select>

    <select id="findOutletsData" resultType="java.util.Map">
        select
        shop_name,address,count(shop_name) as orderCount
        FROM  t_channel_risk_data
        where type=1
        <if test="shopName !=null and shopName !=''">
            and shop_name like CONCAT('%',#{shopName},'%')
        </if>
        group by shop_name
    </select>

    <select id="findOutletsDataDetail" resultMap="BaseResultMap">
        select active_date,owner_name,vin,sn,address
        from t_channel_risk_data
        where type=1
        <if test="proviceName !=null and proviceName !=''">
            and prov=#{proviceName}
        </if>
        <if test="cityName !=null and cityName !=''">
            and city=#{cityName}
        </if>
        <if test="regionName !=null and regionName !=''">
            and zone=#{regionName}
        </if>
    </select>

    <select id="findAllChannel" resultType="java.lang.String">
        select
        distinct shop_name as shop_name
        FROM  t_channel_risk_data
    </select>

</mapper>