|
|
@@ -9,6 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
9
|
9
|
import org.springframework.stereotype.Service;
|
|
10
|
10
|
import org.springframework.transaction.annotation.Transactional;
|
|
11
|
11
|
|
|
|
12
|
+import java.text.ParseException;
|
|
12
|
13
|
import java.text.SimpleDateFormat;
|
|
13
|
14
|
import java.util.*;
|
|
14
|
15
|
|
|
|
@@ -145,6 +146,79 @@ public class ReportBaseServiceImpl implements IReportBaseService {
|
|
145
|
146
|
}
|
|
146
|
147
|
return Report;
|
|
147
|
148
|
}
|
|
|
149
|
+
|
|
|
150
|
+ //话务量统计
|
|
|
151
|
+ @Override
|
|
|
152
|
+ public List<HourReport> selectConnection(ScreenConnection connection) throws ParseException {
|
|
|
153
|
+ // 定义时间格式
|
|
|
154
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
155
|
+ SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
156
|
+ // 将字符串解析为 Date 对象
|
|
|
157
|
+ Date time1 = sdf.parse(connection.getStartTime());
|
|
|
158
|
+ Date time2 = sdf.parse(connection.getEndTime());
|
|
|
159
|
+ // 计算时间差(单位:毫秒)
|
|
|
160
|
+ long difference =time2.getTime()- time1.getTime() ;
|
|
|
161
|
+ // 将毫秒转换为小时
|
|
|
162
|
+ long hours = difference / (1000 * 60 * 60);
|
|
|
163
|
+ String Format="HH";int field=11;
|
|
|
164
|
+ if (hours>24)
|
|
|
165
|
+ {
|
|
|
166
|
+ long day=hours/24;
|
|
|
167
|
+ if (day>31)
|
|
|
168
|
+ {
|
|
|
169
|
+ Format="yyyy-MM";field=2;
|
|
|
170
|
+ connection.setGrouping("%Y-%m");
|
|
|
171
|
+ }
|
|
|
172
|
+ else
|
|
|
173
|
+ {
|
|
|
174
|
+ Format="yyyy-MM-dd";field=6;
|
|
|
175
|
+ connection.setGrouping("%Y-%m-%d");
|
|
|
176
|
+ }
|
|
|
177
|
+ }
|
|
|
178
|
+ else
|
|
|
179
|
+ {
|
|
|
180
|
+ connection.setGrouping("%H");
|
|
|
181
|
+ }
|
|
|
182
|
+ Date date=new Date();
|
|
|
183
|
+ if (!sdf.format(time2).equals(sdf.format(date)))
|
|
|
184
|
+ {
|
|
|
185
|
+ Calendar calendar3 = Calendar.getInstance();
|
|
|
186
|
+ calendar3.setTime(time2);
|
|
|
187
|
+ calendar3.set(Calendar.HOUR_OF_DAY, 23);
|
|
|
188
|
+ calendar3.set(Calendar.MINUTE, 59);
|
|
|
189
|
+ calendar3.set(Calendar.SECOND, 59);
|
|
|
190
|
+ date=calendar3.getTime();
|
|
|
191
|
+ }
|
|
|
192
|
+ connection.setEndTime(sdf1.format(date));
|
|
|
193
|
+
|
|
|
194
|
+
|
|
|
195
|
+ List<HourReport> Traffic= reportMapper.selectConnection( connection);
|
|
|
196
|
+ List<HourReport> Report=new ArrayList<>();
|
|
|
197
|
+ Date temp=time1;
|
|
|
198
|
+ SimpleDateFormat formatter = new SimpleDateFormat(Format);
|
|
|
199
|
+ while (temp.getTime()<=date.getTime())
|
|
|
200
|
+ {
|
|
|
201
|
+ Calendar calendar2 = Calendar.getInstance();
|
|
|
202
|
+ calendar2.setTime(temp);
|
|
|
203
|
+ Date finalTemp =calendar2.getTime();
|
|
|
204
|
+ HourReport view=new HourReport();
|
|
|
205
|
+ view.setDATE(formatter.format(finalTemp));
|
|
|
206
|
+ if (Traffic!=null &&Traffic.size()>0)
|
|
|
207
|
+ {
|
|
|
208
|
+ if (Traffic.stream().anyMatch(x -> x.getDATE().equals(formatter.format(finalTemp)) ))
|
|
|
209
|
+ {
|
|
|
210
|
+ var traffaic=Traffic.stream().filter(x->x.getDATE().equals(formatter.format(finalTemp))).
|
|
|
211
|
+ findFirst().get();
|
|
|
212
|
+ view.setNumber(traffaic.getNumber());
|
|
|
213
|
+ }
|
|
|
214
|
+ }
|
|
|
215
|
+ Report.add(view);
|
|
|
216
|
+
|
|
|
217
|
+ calendar2.add(field,1);
|
|
|
218
|
+ temp=calendar2.getTime();
|
|
|
219
|
+ }
|
|
|
220
|
+ return Report;
|
|
|
221
|
+ }
|
|
148
|
222
|
//话务量统计
|
|
149
|
223
|
@Override
|
|
150
|
224
|
public List<TrafficView> selectTraffic() {
|
|
|
@@ -179,7 +253,7 @@ public class ReportBaseServiceImpl implements IReportBaseService {
|
|
179
|
253
|
}
|
|
180
|
254
|
}
|
|
181
|
255
|
Report.add(view);
|
|
182
|
|
- calendar2.add(Calendar.HOUR_OF_DAY,1);
|
|
|
256
|
+ calendar2.add(Calendar.MONTH,1);
|
|
183
|
257
|
temp=calendar2.getTime();
|
|
184
|
258
|
}
|
|
185
|
259
|
return Report;
|