|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+<?xml version="1.0" encoding="UTF-8"?>
|
|
|
2
|
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
|
3
|
+<mapper namespace="com.chinaitop.depot.statisticalReport.mapper.StatisticalReportMapper">
|
|
|
4
|
+
|
|
|
5
|
+ <select id="getSummaryReportInfo" resultType="java.util.Map" parameterType="map">
|
|
|
6
|
+ <!-- SELECT bs.storehouse_code storeHouse, td.inTemp, td.inH, td.outTemp, td.outH, td.t_max maxTemp, td.t_min minTemp,
|
|
|
7
|
+ td.t_avg avgTemp, IFNULL(tq.co2avg,0) AS "co2avg", IFNULL(tq.ph3avg,0) AS "ph3avg", IFNULL(tq.o2avg,0) AS "o2avg",
|
|
|
8
|
+ ccmax.iValue maxvalues, ccmin.iValue minvalues, bs.dutyStoreman, bs.remark
|
|
|
9
|
+ FROM basic_storehouse bs
|
|
|
10
|
+ LEFT JOIN t_testdata td on td.storehouse = bs.storehouse_code and td.iLq_yq = '0' and td.org_id = bs.org_id
|
|
|
11
|
+ <if test="startDate != null and startDate != ''">
|
|
|
12
|
+ and td.t_time >= #{startDate,jdbcType=TIMESTAMP}
|
|
|
13
|
+ </if>
|
|
|
14
|
+ LEFT JOIN(
|
|
|
15
|
+ SELECT MAX(CASE tq.v_dev_kind_code WHEN "6964" THEN tq.cpo_avg ELSE 0 END ) AS "co2avg",
|
|
|
16
|
+ MAX(CASE tq.v_dev_kind_code WHEN "6965" THEN tq.cpo_avg ELSE 0 END ) AS "ph3avg",
|
|
|
17
|
+ MAX(CASE tq.v_dev_kind_code WHEN "6962" THEN tq.cpo_avg ELSE 0 END ) AS "o2avg",tq.v_cf_code
|
|
|
18
|
+ FROM t_qtdevinfo_value tq
|
|
|
19
|
+ <where>
|
|
|
20
|
+ <if test="orgId!=null">
|
|
|
21
|
+ and tq.org_id = ${orgId}
|
|
|
22
|
+ </if>
|
|
|
23
|
+ <if test="startDate != null and startDate != ''">
|
|
|
24
|
+ and tq.v_value_time >= #{startDate,jdbcType=TIMESTAMP}
|
|
|
25
|
+ </if>
|
|
|
26
|
+ </where>
|
|
|
27
|
+ GROUP BY tq.v_cf_code
|
|
|
28
|
+ ) tq on tq.v_cf_code = bs.storehouse_code
|
|
|
29
|
+ LEFT JOIN (
|
|
|
30
|
+ SELECT DISTINCT ti.vcfcode AS vCfCode, MAX(td.i_value) AS iValue, td.v_update_time AS vUpdateTime
|
|
|
31
|
+ FROM t_ccinfo ti
|
|
|
32
|
+ INNER JOIN t_ccdata td ON ti.vdevcode = td.v_cc_code AND td.org_id = ti.org_id
|
|
|
33
|
+ <where>
|
|
|
34
|
+ <if test="startDate != null and startDate != ''">
|
|
|
35
|
+ and td.v_update_time >= #{startDate,jdbcType=TIMESTAMP}
|
|
|
36
|
+ </if>
|
|
|
37
|
+ </where>
|
|
|
38
|
+ GROUP BY ti.vcfcode
|
|
|
39
|
+ ) ccmax ON td.storehouse = ccmax.vCfCode
|
|
|
40
|
+ LEFT JOIN (
|
|
|
41
|
+ SELECT DISTINCT ti.vcfcode AS vCfCode, min(td.i_value) AS iValue, td.v_update_time AS vUpdateTime
|
|
|
42
|
+ FROM t_ccinfo ti
|
|
|
43
|
+ INNER JOIN t_ccdata td ON ti.vdevcode = td.v_cc_code AND td.org_id = ti.org_id
|
|
|
44
|
+ <where>
|
|
|
45
|
+ <if test="startDate != null and startDate != ''">
|
|
|
46
|
+ and td.v_update_time >= #{startDate,jdbcType=TIMESTAMP}
|
|
|
47
|
+ </if>
|
|
|
48
|
+ <if test="endDate != null and endDate != ''">
|
|
|
49
|
+ and #{endDate,jdbcType=TIMESTAMP} >= td.v_update_time
|
|
|
50
|
+ </if>
|
|
|
51
|
+ </where>
|
|
|
52
|
+ GROUP BY ti.vcfcode
|
|
|
53
|
+ ) ccmin ON td.storehouse = ccmin.vCfCode
|
|
|
54
|
+ <where>
|
|
|
55
|
+ bs.del_flag = 1
|
|
|
56
|
+ <if test="orgId!=null">
|
|
|
57
|
+ and bs.org_id = ${orgId}
|
|
|
58
|
+ </if>
|
|
|
59
|
+ </where>
|
|
|
60
|
+ GROUP BY bs.storehouse_code -->
|
|
|
61
|
+
|
|
|
62
|
+ SELECT bs.storehouse_code storeHouse, td.inTemp, td.inH, td.outTemp, td.outH, td.t_max maxTemp,
|
|
|
63
|
+ td.t_min minTemp, td.t_avg avgTemp, bs.dutyStoreman, bs.remark
|
|
|
64
|
+ FROM basic_storehouse bs
|
|
|
65
|
+ LEFT JOIN (
|
|
|
66
|
+ select a.* from t_testdata a inner join (
|
|
|
67
|
+ select storehouse,max(t_time) t_time from t_testdata where org_id = 49 and iLq_yq = '0'
|
|
|
68
|
+ <if test="startDate != null and startDate != ''">
|
|
|
69
|
+ and to_date(t_time, 'yyyy-mm-dd') = #{startDate,jdbcType=TIMESTAMP}
|
|
|
70
|
+ </if>
|
|
|
71
|
+ GROUP BY storehouse
|
|
|
72
|
+ ) b on a.storehouse = b.storehouse and a.t_time = b.t_time
|
|
|
73
|
+ <if test="orgId!=null">
|
|
|
74
|
+ and a.org_id = ${orgId}
|
|
|
75
|
+ </if>
|
|
|
76
|
+ ) td on td.storehouse = bs.storehouse_code
|
|
|
77
|
+ and td.t_time >= #{startDate,jdbcType=TIMESTAMP}
|
|
|
78
|
+ where bs.del_flag = 1
|
|
|
79
|
+ <if test="orgId!=null">
|
|
|
80
|
+ and bs.org_id = ${orgId}
|
|
|
81
|
+ </if>
|
|
|
82
|
+
|
|
|
83
|
+ </select>
|
|
|
84
|
+
|
|
|
85
|
+ <select id="getDetailsReportInfo" resultType="java.util.Map" parameterType="map">
|
|
|
86
|
+ <!-- SELECT bs.storehouse_code storeHouse, bs.storehouse_type storehouseType, bs.keeping_way keepingWay,
|
|
|
87
|
+ bs.storehouse_name storehouseName, td.t_time, td.inTemp, td.inH, td.outTemp,
|
|
|
88
|
+ td.outH, td.t_max maxTemp, td.t_min minTemp, td.t_avg avgTemp, tq.v_value_time valueTime,
|
|
|
89
|
+ MAX(CASE v_dev_kind_code WHEN "6964" THEN cpo_avg ELSE 0 END ) AS "co2avg",
|
|
|
90
|
+ MAX(CASE v_dev_kind_code WHEN "6965" THEN cpo_avg ELSE 0 END ) AS "ph3avg",
|
|
|
91
|
+ MAX(CASE v_dev_kind_code WHEN "6962" THEN cpo_avg ELSE 0 END ) AS "o2avg",
|
|
|
92
|
+ ccmax.iValue maxvalues, ccmin.iValue minvalues, ccavg.iValue avgvalues, ccavg.vUpdateTime,
|
|
|
93
|
+ bs.dutyStoreman, bs.remark, sq.water, sq.location
|
|
|
94
|
+ FROM basic_storehouse bs
|
|
|
95
|
+ LEFT JOIN storage_qualitycheck sq on bs.storehouse_code = sq.house_id AND sq.org_id = bs.org_id and sq.type = 0
|
|
|
96
|
+ LEFT JOIN t_testdata td on bs.storehouse_code = td.storehouse and td.iLq_yq = '0' AND td.org_id = bs.org_id
|
|
|
97
|
+ <if test="startDate != null and startDate != ''">
|
|
|
98
|
+ and DATE_FORMAT(td.t_time, '%Y-%m-%d') = #{startDate}
|
|
|
99
|
+ </if>
|
|
|
100
|
+ LEFT JOIN t_qtdevinfo_value tq on bs.storehouse_code = tq.v_cf_code AND tq.org_id = bs.org_id
|
|
|
101
|
+ <if test="startDate != null and startDate != ''">
|
|
|
102
|
+ and DATE_FORMAT(tq.v_value_time, '%Y-%m-%d') = #{startDate}
|
|
|
103
|
+ </if>
|
|
|
104
|
+ LEFT JOIN (
|
|
|
105
|
+ SELECT DISTINCT ti.vcfcode AS vCfCode, MAX(td.i_value) AS iValue, td.v_update_time AS vUpdateTime
|
|
|
106
|
+ FROM t_ccinfo ti
|
|
|
107
|
+ INNER JOIN t_ccdata td ON ti.vdevcode = td.v_cc_code
|
|
|
108
|
+ <where>
|
|
|
109
|
+ <if test="startDate != null and startDate != ''">
|
|
|
110
|
+ and DATE_FORMAT(td.v_update_time, '%Y-%m-%d') = #{startDate}
|
|
|
111
|
+ </if>
|
|
|
112
|
+ </where>
|
|
|
113
|
+ GROUP BY ti.vcfcode
|
|
|
114
|
+ ) ccmax ON bs.storehouse_code = ccmax.vCfCode
|
|
|
115
|
+ LEFT JOIN (
|
|
|
116
|
+ SELECT DISTINCT ti.vcfcode AS vCfCode, min(td.i_value) AS iValue, td.v_update_time AS vUpdateTime
|
|
|
117
|
+ FROM t_ccinfo ti
|
|
|
118
|
+ INNER JOIN t_ccdata td ON ti.vdevcode = td.v_cc_code
|
|
|
119
|
+ <where>
|
|
|
120
|
+ <if test="startDate != null and startDate != ''">
|
|
|
121
|
+ and DATE_FORMAT(td.v_update_time, '%Y-%m-%d') = #{startDate}
|
|
|
122
|
+ </if>
|
|
|
123
|
+ </where>
|
|
|
124
|
+ GROUP BY ti.vcfcode
|
|
|
125
|
+ ) ccmin ON bs.storehouse_code = ccmin.vCfCode
|
|
|
126
|
+ LEFT JOIN (
|
|
|
127
|
+ SELECT DISTINCT ti.vcfcode AS vCfCode, avg(td.i_value) AS iValue,
|
|
|
128
|
+ td.v_update_time AS vUpdateTime
|
|
|
129
|
+ FROM t_ccinfo ti
|
|
|
130
|
+ INNER JOIN t_ccdata td ON ti.vdevcode = td.v_cc_code
|
|
|
131
|
+ <where>
|
|
|
132
|
+ <if test="startDate != null and startDate != ''">
|
|
|
133
|
+ and DATE_FORMAT(td.v_update_time, '%Y-%m-%d') = #{startDate}
|
|
|
134
|
+ </if>
|
|
|
135
|
+ </where>
|
|
|
136
|
+ GROUP BY ti.vcfcode
|
|
|
137
|
+ ) ccavg ON bs.storehouse_code = ccavg.vCfCode
|
|
|
138
|
+ <where>
|
|
|
139
|
+ <if test="orgId!=null">
|
|
|
140
|
+ and bs.org_id = ${orgId}
|
|
|
141
|
+ </if>
|
|
|
142
|
+ <if test="storehouseCode != null and storehouseCode != ''">
|
|
|
143
|
+ and bs.storehouse_code = #{storehouseCode}
|
|
|
144
|
+ </if>
|
|
|
145
|
+ </where>
|
|
|
146
|
+ GROUP BY bs.storehouse_code -->
|
|
|
147
|
+
|
|
|
148
|
+ SELECT bs.storehouse_code storehouse, bs.storehouse_type storehousetype, bs.keeping_way keepingway,
|
|
|
149
|
+ bs.storehouse_name storehousename, td.t_time, td.intemp, td.inh, td.outtemp,
|
|
|
150
|
+ td.outh, td.t_max maxtemp, td.t_min mintemp, td.t_avg avgtemp, bs.remark, sq.water, sq.location
|
|
|
151
|
+ FROM basic_storehouse bs
|
|
|
152
|
+ LEFT JOIN storage_qualitycheck sq on bs.storehouse_id = sq.house_id AND sq.org_id = bs.org_id and sq.type = 0
|
|
|
153
|
+ LEFT join(
|
|
|
154
|
+ select a.* from t_testdata a inner join (
|
|
|
155
|
+ select storehouse,max(t_time) t_time from t_testdata where iLq_yq = '0'
|
|
|
156
|
+ <if test="orgId!=null">
|
|
|
157
|
+ and org_id = ${orgId}
|
|
|
158
|
+ </if>
|
|
|
159
|
+ <if test="startDate != null and startDate != ''">
|
|
|
160
|
+ and to_date(t_time, 'yyyy-mm-dd') = #{startDate}
|
|
|
161
|
+ </if>
|
|
|
162
|
+ GROUP BY storehouse
|
|
|
163
|
+ ) b on a.storehouse = b.storehouse and a.t_time = b.t_time and a.org_id = 49
|
|
|
164
|
+ ) td on bs.storehouse_code = td.storehouse
|
|
|
165
|
+ <where>
|
|
|
166
|
+ <if test="orgId!=null">
|
|
|
167
|
+ and bs.org_id = ${orgId}
|
|
|
168
|
+ </if>
|
|
|
169
|
+ <if test="storehouseCode != null and storehouseCode != ''">
|
|
|
170
|
+ and bs.storehouse_code = #{storehouseCode}
|
|
|
171
|
+ </if>
|
|
|
172
|
+ </where>
|
|
|
173
|
+ </select>
|
|
|
174
|
+
|
|
|
175
|
+ <select id="getSubmitReportInfo" resultType="java.util.Map" parameterType="map">
|
|
|
176
|
+ SELECT bs.*, tdl1.lAvg firstfloor, tdl2.lAvg secondfloor, tdl3.lAvg threefloor, tdl4.lAvg fourfloor FROM (
|
|
|
177
|
+ SELECT bs.storehouse_code storehouse, bs.storehouse_type storehousetype, bs.keeping_way keepingway,
|
|
|
178
|
+ bs.storehouse_name storehousename, td.intemp, td.inh, td.t_max maxtemp, td.t_min mintemp,
|
|
|
179
|
+ td.t_avg avgtemp,sq.grain_annual harvesttime
|
|
|
180
|
+ <!-- , sq.water -->
|
|
|
181
|
+ FROM basic_storehouse bs
|
|
|
182
|
+ LEFT JOIN (
|
|
|
183
|
+ select grain_annual,house_id from business_store_ware_detail where id = (
|
|
|
184
|
+ select max(id) id from business_store_ware_detail
|
|
|
185
|
+ where type= 'notice'
|
|
|
186
|
+ <if test="orgId!=null">
|
|
|
187
|
+ and org_id = ${orgId}
|
|
|
188
|
+ </if>
|
|
|
189
|
+ group by house_id
|
|
|
190
|
+ )
|
|
|
191
|
+ ) sq on bs.storehouse_id = sq.house_id
|
|
|
192
|
+ LEFT JOIN (
|
|
|
193
|
+ select a.* from t_testdata a inner join (
|
|
|
194
|
+ select storehouse,max(t_time) t_time from t_testdata
|
|
|
195
|
+ where iLq_yq = '0'
|
|
|
196
|
+ <if test="orgId!=null">
|
|
|
197
|
+ and org_id = ${orgId}
|
|
|
198
|
+ </if>
|
|
|
199
|
+ <if test="startDate != null and startDate != ''">
|
|
|
200
|
+ and to_date(t_time, 'yyyy-mm-dd') = #{startDate}
|
|
|
201
|
+ </if>
|
|
|
202
|
+ GROUP BY storehouse
|
|
|
203
|
+ ) b on a.storehouse = b.storehouse and a.t_time = b.t_time
|
|
|
204
|
+ <if test="orgId!=null">
|
|
|
205
|
+ and a.org_id = ${orgId}
|
|
|
206
|
+ </if>
|
|
|
207
|
+ ) td on td.storehouse = bs.storehouse_code
|
|
|
208
|
+ where bs.del_flag = 1
|
|
|
209
|
+ <if test="orgId!=null">
|
|
|
210
|
+ and bs.org_id = ${orgId}
|
|
|
211
|
+ </if>
|
|
|
212
|
+ ) bs
|
|
|
213
|
+ LEFT join (
|
|
|
214
|
+ select a.* from t_testdata_layer a inner join (
|
|
|
215
|
+ select lHouse,max(ltime) ltime from t_testdata_layer
|
|
|
216
|
+ where
|
|
|
217
|
+ <if test="orgId!=null">
|
|
|
218
|
+ org_id = ${orgId}
|
|
|
219
|
+ </if>
|
|
|
220
|
+ <if test="startDate != null and startDate != ''">
|
|
|
221
|
+ and to_date(ltime, 'yyyy-mm-dd') = #{startDate}
|
|
|
222
|
+ </if>
|
|
|
223
|
+ GROUP BY lHouse
|
|
|
224
|
+ ) b on a.lHouse = b.lHouse and a.ltime = b.ltime and layerNumber = 1
|
|
|
225
|
+ <if test="orgId!=null">
|
|
|
226
|
+ and a.org_id = ${orgId}
|
|
|
227
|
+ </if>
|
|
|
228
|
+ ) tdl1 ON tdl1.lHouse = bs.storeHouse
|
|
|
229
|
+ LEFT join (
|
|
|
230
|
+ select a.* from t_testdata_layer a inner join (
|
|
|
231
|
+ select lHouse,max(ltime) ltime from t_testdata_layer
|
|
|
232
|
+ where
|
|
|
233
|
+ <if test="orgId!=null">
|
|
|
234
|
+ org_id = ${orgId}
|
|
|
235
|
+ </if>
|
|
|
236
|
+ <if test="startDate != null and startDate != ''">
|
|
|
237
|
+ and to_date(ltime, 'yyyy-mm-dd') = #{startDate}
|
|
|
238
|
+ </if>
|
|
|
239
|
+ GROUP BY lHouse
|
|
|
240
|
+ ) b on a.lHouse = b.lHouse and a.ltime = b.ltime and layerNumber = 2
|
|
|
241
|
+ <if test="orgId!=null">
|
|
|
242
|
+ and a.org_id = ${orgId}
|
|
|
243
|
+ </if>
|
|
|
244
|
+ ) tdl2 ON tdl2.lHouse = bs.storeHouse
|
|
|
245
|
+ LEFT join (
|
|
|
246
|
+ select a.* from t_testdata_layer a inner join (
|
|
|
247
|
+ select lHouse,max(ltime) ltime from t_testdata_layer
|
|
|
248
|
+ where
|
|
|
249
|
+ <if test="orgId!=null">
|
|
|
250
|
+ org_id = ${orgId}
|
|
|
251
|
+ </if>
|
|
|
252
|
+ <if test="startDate != null and startDate != ''">
|
|
|
253
|
+ and to_date(ltime, 'yyyy-mm-dd') = #{startDate}
|
|
|
254
|
+ </if>
|
|
|
255
|
+ GROUP BY lHouse
|
|
|
256
|
+ ) b on a.lHouse = b.lHouse and a.ltime = b.ltime and layerNumber = 3
|
|
|
257
|
+ <if test="orgId!=null">
|
|
|
258
|
+ and a.org_id = ${orgId}
|
|
|
259
|
+ </if>
|
|
|
260
|
+ ) tdl3 ON tdl3.lHouse = bs.storeHouse
|
|
|
261
|
+ LEFT join (
|
|
|
262
|
+ select a.* from t_testdata_layer a inner join (
|
|
|
263
|
+ select lHouse,max(ltime) ltime from t_testdata_layer
|
|
|
264
|
+ where
|
|
|
265
|
+ <if test="orgId!=null">
|
|
|
266
|
+ org_id = ${orgId}
|
|
|
267
|
+ </if>
|
|
|
268
|
+ <if test="startDate != null and startDate != ''">
|
|
|
269
|
+ and to_date(ltime, 'yyyy-mm-dd') = #{startDate}
|
|
|
270
|
+ </if>
|
|
|
271
|
+ GROUP BY lHouse
|
|
|
272
|
+ ) b on a.lHouse = b.lHouse and a.ltime = b.ltime and layerNumber = 4
|
|
|
273
|
+ <if test="orgId!=null">
|
|
|
274
|
+ and a.org_id = ${orgId}
|
|
|
275
|
+ </if>
|
|
|
276
|
+ ) tdl4 ON tdl4.lHouse = bs.storeHouse
|
|
|
277
|
+ </select>
|
|
|
278
|
+
|
|
|
279
|
+</mapper>
|