ChannelRiskDataMapper.xml
5.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<?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.report.modules.mapper.ChannelRiskDataMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.report.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"/>
<result column="center_lat" jdbcType="DOUBLE" property="center_lat"/>
<result column="center_lng" jdbcType="DOUBLE" property="center_lng"/>
<result column="adcode" jdbcType="VARCHAR" property="adcode"/>
</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 and labels=-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
DATE_FORMAT(gps_time,'%Y年%c月') 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>
<if test="proviceName !=null and proviceName !=''">
and prov=#{proviceName}
</if>
<if test="cityName !=null and cityName !=''">
and city=#{cityName}
</if>
group by xAxis ORDER BY gps_time
</select>
<select id="findOutletsData" resultType="java.util.Map">
select
labels as shop_name,address,count(labels) as orderCount,center_lat,center_lng,t2.adcode
FROM t_channel_risk_data t1 left join base_provinces t2 on t1.prov=t2.name
where labels!=-1
<if test="shopName !=null and shopName !=''">
and labels like CONCAT('%',#{shopName},'%')
</if>
group by labels order by orderCount desc
</select>
<select id="findOutletsDataDetail" resultMap="BaseResultMap">
select active_date,owner_name,vin,sn,address,lng,t2.adcode,
lat
from t_channel_risk_data t1 left join base_provinces t2 on t1.prov=t2.name
where type=1 and labels=-1
<if test="item.provinceName !=null and item.provinceName !=''">
and prov=#{item.provinceName}
</if>
<if test="item.cityName !=null and item.cityName !=''">
and city=#{item.cityName}
</if>
<if test="item.regionName !=null and item.regionName !=''">
and zone=#{item.regionName}
</if>
<if test="item.shopName !=null and item.shopName !=''">
and shop_name like CONCAT('%',#{item.shopName},'%')
</if>
</select>
<select id="findAllChannel" resultType="java.lang.String">
select
distinct shop_name as shop_name
FROM t_channel_risk_data
</select>
</mapper>