Commit fa587b833a85c8720a751aacc59d09da14f7280c

Authored by llw
1 parent 35970915

提交

src/main/java/com/zteits/irain/portal/web/parkinglotcloudplatform/datastatistic/BerthsStatisticController.java
... ... @@ -235,12 +235,21 @@ public class BerthsStatisticController extends BizController {
235 235 // 1个小时为一个时间戳
236 236 request.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER1HOUR);
237 237 int totaltimestampCount = endTime.get(Calendar.HOUR_OF_DAY);
238   - for (int i = 0; i <= totaltimestampCount; i++) {
239   - String hour = String.format("%02d", i);
240   - xAxisData.add(hour + ":" + "00");
  238 + String day = "";
  239 + String month = "";
  240 + for (int i = 0; i < dayDifference.intValue(); i++) {
  241 + beginTime.add(Calendar.DAY_OF_MONTH, 1);
  242 + int beginMonth = beginTime.get(Calendar.MONTH) + 1;
  243 + int beginDay = beginTime.get(Calendar.DAY_OF_MONTH);
  244 + month = String.format("%02d", (beginMonth));
  245 + day = String.format("%02d", (beginDay));
  246 + for (int j = 0; j < totaltimestampCount; j++) {
  247 + String hour = String.format("%02d", (j));
  248 + xAxisData.add(month + "-" + day + " " + hour);
  249 + }
241 250 }
242 251 request.setBaseRequest(new BaseInfo(1, 0));
243   - dateType="HH:mm";
  252 + dateType="MM-dd HH";
244 253 LineChartVO freeBerthRatios=getFreeBerthRatios(request, xAxisData, dateType,berthRatio);
245 254 return new BizResultVO<LineChartVO>().setData(freeBerthRatios);
246 255 } else if (dayDifference <= 3L) {
... ... @@ -300,6 +309,7 @@ public class BerthsStatisticController extends BizController {
300 309 throw new BizException(ErrorType.PARAMM_NULL, "开始时间和结束时间");
301 310 }
302 311 Calendar beginTime = Calendar.getInstance();
  312 + int year=beginTime.get(Calendar.YEAR);
303 313 beginTime.setTime(request.getBeginTime());
304 314  
305 315 Calendar endTime = Calendar.getInstance();
... ... @@ -309,18 +319,26 @@ public class BerthsStatisticController extends BizController {
309 319 new Timestamp(request.getBeginTime().getTime()));
310 320 List<String> xAxisData = Lists.newArrayList();
311 321 String dateType="";
  322 + request.setBaseRequest(new BaseInfo(1, 0));
312 323 int berthRatio=ParkConstant.ParkingLotUseStatistic.BerthRatioType.TURNOVER;
313 324 if (dayDifference == 0L) {
314 325 //1个小时为一个时间戳
315 326 request.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER1HOUR);
316 327 int totaltimestampCount = endTime.get(Calendar.HOUR_OF_DAY);
317   - for (int j = 0; j <= totaltimestampCount; j++) {
318   - String hour = String.format("%02d", (j));
319   - xAxisData.add(hour + ":" + "00");
  328 + String day = "";
  329 + String month = "";
  330 + for (int i = 0; i < dayDifference.intValue(); i++) {
  331 + beginTime.add(Calendar.DAY_OF_MONTH, 1);
  332 + int beginMonth = beginTime.get(Calendar.MONTH) + 1;
  333 + int beginDay = beginTime.get(Calendar.DAY_OF_MONTH);
  334 + month = String.format("%02d", (beginMonth));
  335 + day = String.format("%02d", (beginDay));
  336 + for (int j = 0; j < totaltimestampCount; j++) {
  337 + String hour = String.format("%02d", (j));
  338 + xAxisData.add(year+"-"+month + "-" + day + " " + hour);
  339 + }
320 340 }
321   -
322   - request.setBaseRequest(new BaseInfo(1, 0));
323   - dateType="HH:mm";
  341 + dateType="yyyy-MM-dd HH";
324 342 LineChartVO freeBerthRatios=getFreeBerthRatios(request, xAxisData, dateType,berthRatio);
325 343 return new BizResultVO<LineChartVO>().setData(freeBerthRatios);
326 344 } else if (dayDifference <= 3L) {
... ... @@ -337,11 +355,10 @@ public class BerthsStatisticController extends BizController {
337 355 day = String.format("%02d", (beginDay));
338 356 for (int j = 0; j < totaltimestampCount; j++) {
339 357 String hour = String.format("%02d", (j));
340   - xAxisData.add(month + "-" + day + " " + hour);
  358 + xAxisData.add(year+"-"+month + "-" + day + " " + hour);
341 359 }
342 360 }
343   - request.setBaseRequest(new BaseInfo(1, 0));
344   - dateType="MM-dd HH";
  361 + dateType="yyyy-MM-dd HH";
345 362 LineChartVO freeBerthRatios=getFreeBerthRatios(request, xAxisData, dateType,berthRatio);
346 363 return new BizResultVO<LineChartVO>().setData(freeBerthRatios);
347 364 } else {
... ... @@ -353,10 +370,9 @@ public class BerthsStatisticController extends BizController {
353 370 int beginDay = beginTime.get(Calendar.DAY_OF_MONTH);
354 371 String month = String.format("%02d", (beginMonth));
355 372 String day = String.format("%02d", (beginDay));
356   - xAxisData.add(month + "-" + day);
  373 + xAxisData.add(year+"-"+month + "-" + day);
357 374 }
358   - request.setBaseRequest(new BaseInfo(1, 0));
359   - dateType="MM-dd";
  375 + dateType="yyyy-MM-dd";
360 376 LineChartVO freeBerthRatios=getFreeBerthRatios(request, xAxisData, dateType,berthRatio);
361 377 return new BizResultVO<LineChartVO>().setData(freeBerthRatios);
362 378 }
... ...
src/main/java/com/zteits/irain/portal/web/parkinglotcloudplatform/datastatistic/VehicleFlowStatisticController.java
... ... @@ -95,9 +95,9 @@ public class VehicleFlowStatisticController extends BizController {
95 95 @ResponseBody
96 96 public BizResultVO<EasyUIDataGridVO<ParkingLotUseStatisticDTO>> queryParkingLotUseStatisticForPage(
97 97 @RequestBody ParkingLotUseStatisticForPageRequest request) throws Exception {
98   - if (null == request.getBeginTime() || null==request.getEndTime()) {
99   - throw new BizException(ErrorType.PARAMM_NULL, "开始时间和结束时间");
100   - }
  98 + if (null == request.getBeginTime() || null == request.getEndTime()) {
  99 + throw new BizException(ErrorType.PARAMM_NULL, "开始时间和结束时间");
  100 + }
101 101 Calendar beginc = Calendar.getInstance();
102 102 beginc.setTime(request.getBeginTime());
103 103 int beginYear = beginc.get(Calendar.YEAR);
... ... @@ -220,7 +220,7 @@ public class VehicleFlowStatisticController extends BizController {
220 220 *
221 221 * @param request
222 222 * @return
223   - * @throws Exception
  223 + * @throws Exception
224 224 */
225 225 @ApiOperation("根据时间获取车流量折线图")
226 226 @PostMapping("getVehicleFlowForLineChart")
... ... @@ -228,22 +228,22 @@ public class VehicleFlowStatisticController extends BizController {
228 228 public BizResultVO<LineChartVO> getVehicleFlowForLineChart(
229 229 @RequestBody ParkingLotUseStatisticForPageRequest request) throws Exception {
230 230  
231   - if (null == request.getBeginTime() || null==request.getEndTime()) {
232   - throw new BizException(ErrorType.PARAMM_NULL, "开始时间和结束时间");
233   - }
234   - //2.调用接口查询当前登录人管辖的停车场名称
  231 + if (null == request.getBeginTime() || null == request.getEndTime()) {
  232 + throw new BizException(ErrorType.PARAMM_NULL, "开始时间和结束时间");
  233 + }
  234 + // 2.调用接口查询当前登录人管辖的停车场名称
235 235 UserInfo userInfo = sessionCommUtil.getUserInfo();
236 236 List<String> plNos = new ArrayList<>();
237   - if(userInfo!=null){
  237 + if (userInfo != null) {
238 238 TdCompanyParkQueryRequest tdCompanyParkQueryRequest = new TdCompanyParkQueryRequest();
239 239 tdCompanyParkQueryRequest.setCustIdList(userInfo.getOrgIds());
240 240 tdCompanyParkQueryRequest.setSessionId(session.getId());
241 241 tdCompanyParkQueryRequest.setSysCode(sysCode);
242 242 BizResult<List<String>> bizResult = tdCustCompanyService.queryParkNoByCustIds(tdCompanyParkQueryRequest);
243   - //拥有的停车场编号
  243 + // 拥有的停车场编号
244 244 plNos = ResultUtils.getBizResultData(bizResult);
245 245 }
246   - if(CollectionUtils.isEmpty(plNos)){
  246 + if (CollectionUtils.isEmpty(plNos)) {
247 247 throw new BizException(ErrorType.PARK_LOT_NOT_EXISTS, "停车场plnos不存在");
248 248 }
249 249 request.setPlNos(plNos);
... ... @@ -251,7 +251,7 @@ public class VehicleFlowStatisticController extends BizController {
251 251 logger.info("根据停车场编号获取该停车场今日车流量和车位折线图");
252 252 Calendar beginTime = Calendar.getInstance();
253 253 beginTime.setTime(request.getBeginTime());
254   -
  254 + int year=beginTime.get(Calendar.YEAR);
255 255 Calendar endTime = Calendar.getInstance();
256 256 endTime.setTime(request.getEndTime());
257 257  
... ... @@ -259,19 +259,27 @@ public class VehicleFlowStatisticController extends BizController {
259 259 new Timestamp(request.getBeginTime().getTime()));
260 260 List<String> xAxisData = Lists.newArrayList();
261 261 request.setBaseRequest(new BaseInfo(1, 0));
262   - String dateType="";
263   -
  262 + String dateType = "";
  263 +
264 264 if (dayDifference == 0L) {
265   - // 20分钟为一个时间戳
266   - request.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER20MINUTE);
267   - int totaltimestampCount = endTime.get(Calendar.HOUR_OF_DAY) * 3;
268   - for (int i = 0; i < totaltimestampCount; i++) {
269   - String hour = String.format("%02d", (i / 3));
270   - String minute = String.format("%02d", (i % 3) * 20);
271   - xAxisData.add(hour + ":" + minute);
  265 + // 1小时为一个时间戳
  266 + request.setQueryKind(ParkConstant.ParkingLotUseStatistic.StatisticType.PER1HOUR);
  267 + int totaltimestampCount = endTime.get(Calendar.HOUR_OF_DAY);
  268 + String day = "";
  269 + String month = "";
  270 + for (int i = 0; i < dayDifference.intValue(); i++) {
  271 + beginTime.add(Calendar.DAY_OF_MONTH, 1);
  272 + int beginMonth = beginTime.get(Calendar.MONTH) + 1;
  273 + int beginDay = beginTime.get(Calendar.DAY_OF_MONTH);
  274 + month = String.format("%02d", (beginMonth));
  275 + day = String.format("%02d", (beginDay));
  276 + for (int j = 0; j < totaltimestampCount; j++) {
  277 + String hour = String.format("%02d", (j));
  278 + xAxisData.add(year+"-"+month + "-" + day + " " + hour);
  279 + }
272 280 }
273   - dateType="HH:mm";
274   - LineChartVO vehicleFlows=getVehicleFlows(request, xAxisData, dateType);
  281 + dateType = "yyyy-MM-dd HH";
  282 + LineChartVO vehicleFlows = getVehicleFlows(request, xAxisData, dateType);
275 283 return new BizResultVO<LineChartVO>().setData(vehicleFlows);
276 284  
277 285 } else if (dayDifference <= 3L) {
... ... @@ -288,11 +296,11 @@ public class VehicleFlowStatisticController extends BizController {
288 296 day = String.format("%02d", (beginDay));
289 297 for (int j = 0; j < totaltimestampCount; j++) {
290 298 String hour = String.format("%02d", (j));
291   - xAxisData.add(month + "-" + day + " " + hour);
  299 + xAxisData.add(year+"-"+month + "-" + day + " " + hour);
292 300 }
293 301 }
294   - dateType="MM-dd HH";
295   - LineChartVO vehicleFlows=getVehicleFlows(request, xAxisData, dateType);
  302 + dateType = "yyyy-MM-dd HH";
  303 + LineChartVO vehicleFlows = getVehicleFlows(request, xAxisData, dateType);
296 304 return new BizResultVO<LineChartVO>().setData(vehicleFlows);
297 305  
298 306 } else {
... ... @@ -304,20 +312,19 @@ public class VehicleFlowStatisticController extends BizController {
304 312 int beginDay = beginTime.get(Calendar.DAY_OF_MONTH);
305 313 String month = String.format("%02d", (beginMonth));
306 314 String day = String.format("%02d", (beginDay));
307   - xAxisData.add(month + "-" + day);
  315 + xAxisData.add(year+"-"+month + "-" + day);
308 316  
309 317 }
310   - dateType="MM-dd";
311   - LineChartVO vehicleFlows=getVehicleFlows(request, xAxisData, dateType);
  318 + dateType = "yyyy-MM-dd";
  319 + LineChartVO vehicleFlows = getVehicleFlows(request, xAxisData, dateType);
312 320 return new BizResultVO<LineChartVO>().setData(vehicleFlows);
313 321  
314 322 }
315 323  
316 324 }
317   -
318   -
319   - private LineChartVO getVehicleFlows(ParkingLotUseStatisticForPageRequest request,
320   - List<String> xAxisData,String dateType){
  325 +
  326 + private LineChartVO getVehicleFlows(ParkingLotUseStatisticForPageRequest request, List<String> xAxisData,
  327 + String dateType) {
321 328 // 调用后场服务
322 329 logger.info("调用DUBBO服务入参:" + JSON.toJSONString(request));
323 330 BizResult<PageBean<ParkingLotUseStatisticDTO>> bizResult = parkingLotStatisticService
... ... @@ -341,9 +348,13 @@ public class VehicleFlowStatisticController extends BizController {
341 348 String key = statisticDTO.getPlNo();
342 349 parkNameMap.put(key, statisticDTO.getPlName());
343 350 String statisBeginTime = DateUtil.getDateString(statisticDTO.getStatisticBeginTime(), dateType);
344   - //保存固定车流量和临时车流量
345   - fixVehicleFlowMap.put(statisBeginTime, (fixVehicleFlowMap.get(statisBeginTime)==null?0:fixVehicleFlowMap.get(statisBeginTime))+statisticDTO.getFixVehicleFlow());
346   - tmpVehicleFlowMap.put(statisBeginTime, (tmpVehicleFlowMap.get(statisBeginTime)==null?0:tmpVehicleFlowMap.get(statisBeginTime))+statisticDTO.getTmpVehicleFlow());
  351 + // 保存固定车流量和临时车流量
  352 + fixVehicleFlowMap.put(statisBeginTime,
  353 + (fixVehicleFlowMap.get(statisBeginTime) == null ? 0 : fixVehicleFlowMap.get(statisBeginTime))
  354 + + statisticDTO.getFixVehicleFlow());
  355 + tmpVehicleFlowMap.put(statisBeginTime,
  356 + (tmpVehicleFlowMap.get(statisBeginTime) == null ? 0 : tmpVehicleFlowMap.get(statisBeginTime))
  357 + + statisticDTO.getTmpVehicleFlow());
347 358 }
348 359 }
349 360  
... ... @@ -370,14 +381,14 @@ public class VehicleFlowStatisticController extends BizController {
370 381  
371 382 if (fixVehicleFlowMap.containsKey(timestamp)) {
372 383 lastfixFlow = fixVehicleFlowMap.get(timestamp).intValue();
373   - }else{
374   - lastfixFlow =0;
  384 + } else {
  385 + lastfixFlow = 0;
375 386 }
376 387 fixSerieVoData.add(lastfixFlow);
377 388  
378 389 if (tmpVehicleFlowMap.containsKey(timestamp)) {
379 390 lasttmpFlow = tmpVehicleFlowMap.get(timestamp).intValue();
380   - }else{
  391 + } else {
381 392 lasttmpFlow = 0;
382 393 }
383 394 tmpSerieVoData.add(lasttmpFlow);
... ... @@ -390,16 +401,15 @@ public class VehicleFlowStatisticController extends BizController {
390 401 vehicleFlows.setSeries(vehicleSeries);
391 402 return vehicleFlows;
392 403 }
393   -
  404 +
394 405 public static void main(String[] args) {
395   - String json="{\"id\":\"1\",\"platform\":\"android\",\"parameter\":{\"drid\":\"177277364\",\"sex\":\"1\",\"type\":\"2\",\"creatorname\":\"Mrw\",\"username\":\"jack\",\"pwd\":\"123456\",\"remark\":\"平板用户\",\"createtime\":\"2017-07-24 23:59:59\"}}";
396   - JSONObject object =(JSONObject)JSONObject.parse(json);
  406 + String json = "{\"id\":\"1\",\"platform\":\"android\",\"parameter\":{\"drid\":\"177277364\",\"sex\":\"1\",\"type\":\"2\",\"creatorname\":\"Mrw\",\"username\":\"jack\",\"pwd\":\"123456\",\"remark\":\"平板用户\",\"createtime\":\"2017-07-24 23:59:59\"}}";
  407 + JSONObject object = (JSONObject) JSONObject.parse(json);
397 408 System.out.println(object.get("id"));
398 409 System.out.println(object.get("platform"));
399   - JSONObject parameter =(JSONObject)object.get("parameter");
  410 + JSONObject parameter = (JSONObject) object.get("parameter");
400 411 System.out.println(parameter.get("drid"));
401 412 System.out.println(parameter.get("sex"));
402 413 }
403   -
404 414  
405 415 }
... ...