|
|
@ -2,6 +2,7 @@ package com.zc.business.controller; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.ruoyi.common.annotation.Excel; |
|
|
|
import com.ruoyi.common.annotation.Log; |
|
|
|
import com.ruoyi.common.core.controller.BaseController; |
|
|
|
import com.ruoyi.common.core.domain.AjaxResult; |
|
|
@ -24,6 +25,8 @@ import org.apache.poi.ss.usermodel.*; |
|
|
|
import org.apache.poi.ss.util.CellRangeAddress; |
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.scheduling.annotation.Scheduled; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
import javax.servlet.ServletOutputStream; |
|
|
@ -31,6 +34,7 @@ import javax.servlet.http.HttpServletResponse; |
|
|
|
import java.io.IOException; |
|
|
|
import java.text.DecimalFormat; |
|
|
|
import java.time.LocalDate; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.util.*; |
|
|
|
import java.util.function.Function; |
|
|
@ -42,6 +46,7 @@ import java.util.stream.Collectors; |
|
|
|
* |
|
|
|
* @author xiepufeng |
|
|
|
*/ |
|
|
|
//@Component
|
|
|
|
@Api(tags = "交通数据统计") |
|
|
|
@RestController |
|
|
|
@RequestMapping("/business/traffic-statistics") |
|
|
@ -521,7 +526,27 @@ public AjaxResult realTimeTrafficFlow(String startDate, String direction,String |
|
|
|
endDate = String.valueOf(year); |
|
|
|
} |
|
|
|
List<Map<String, Object>> thisYearList = dcGantryMetricsStatisticsDataService.passIndicatorTimeDistribution(startDate,direction,periodType); |
|
|
|
Map<String,List<Map<String, Object>>> thisYearData = thisYearList.stream().collect(Collectors.groupingBy(item -> item.get("groupTime").toString())); |
|
|
|
Map<String,List<Map<String, Object>>> thisYearData = new HashMap<>(); |
|
|
|
DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm"); |
|
|
|
if (UniversalEnum.FOUR.getValue().equals(periodType)){ |
|
|
|
thisYearData = thisYearList.stream().collect(Collectors.groupingBy(item -> { |
|
|
|
LocalDateTime dateTime = LocalDateTime.parse(item.get("groupTime").toString(), inputFormatter); |
|
|
|
DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("HH时"); |
|
|
|
return outputFormatter.format(dateTime); |
|
|
|
})); |
|
|
|
} else if (UniversalEnum.THREE.getValue().equals(periodType)){ |
|
|
|
thisYearData = thisYearList.stream().collect(Collectors.groupingBy(item -> { |
|
|
|
LocalDateTime dateTime = LocalDateTime.parse(item.get("groupTime").toString(), inputFormatter); |
|
|
|
DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("M月d日"); |
|
|
|
return dateTime.format(outputFormatter); |
|
|
|
})); |
|
|
|
} else if (UniversalEnum.ONE.getValue().equals(periodType)){ |
|
|
|
thisYearData = thisYearList.stream().collect(Collectors.groupingBy(item -> { |
|
|
|
LocalDateTime dateTime = LocalDateTime.parse(item.get("groupTime").toString(), inputFormatter); |
|
|
|
DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("M月"); |
|
|
|
return dateTime.format(outputFormatter); |
|
|
|
})); |
|
|
|
} |
|
|
|
List<Map<String, Object>> lastYearList = dcGantryMetricsStatisticsDataService.passIndicatorTimeDistribution(endDate,direction,periodType); |
|
|
|
Map<String,List<Map<String, Object>>> lastYearData = lastYearList.stream().collect(Collectors.groupingBy(item -> item.get("groupTime").toString())); |
|
|
|
|
|
|
@ -533,20 +558,36 @@ public AjaxResult realTimeTrafficFlow(String startDate, String direction,String |
|
|
|
allKey.addAll(lastYearData.keySet()); |
|
|
|
} |
|
|
|
|
|
|
|
for (String key : allKey) { |
|
|
|
List<String> keyList = new ArrayList<>(allKey); |
|
|
|
Collections.sort(keyList); |
|
|
|
|
|
|
|
for (String key : keyList) { |
|
|
|
PassIndicatorTimeDistribution passIndicatorTimeDistribution = new PassIndicatorTimeDistribution(); |
|
|
|
passIndicatorTimeDistribution.setTime(key); |
|
|
|
if (thisYearData != null && thisYearData.containsKey(key)){ |
|
|
|
Map<String, Object> sectionData = thisYearData.get(key).get(UniversalEnum.ZERO.getNumber()); |
|
|
|
passIndicatorTimeDistribution.setCrowdingRate(sectionData.get("crowdingRate").toString()); |
|
|
|
passIndicatorTimeDistribution.setSaturationRate(sectionData.get("saturationRate").toString()); |
|
|
|
|
|
|
|
if (sectionData.get("saturationRate") instanceof Double){ |
|
|
|
double saturationRate = (Double)sectionData.get("saturationRate"); |
|
|
|
passIndicatorTimeDistribution.setSaturationRate(String.format("%.4f", saturationRate)); |
|
|
|
} else { |
|
|
|
passIndicatorTimeDistribution.setSaturationRate("0"); |
|
|
|
} |
|
|
|
// passIndicatorTimeDistribution.setSaturationRate(sectionData.get("saturationRate").toString());
|
|
|
|
passIndicatorTimeDistribution.setTrafficCompositionRate(sectionData.get("trafficCompositionRate").toString()); |
|
|
|
} |
|
|
|
|
|
|
|
if (lastYearData != null && lastYearData.containsKey(key)){ |
|
|
|
Map<String, Object> sectionData = lastYearData.get(key).get(UniversalEnum.ZERO.getNumber()); |
|
|
|
passIndicatorTimeDistribution.setCrowdingRateLastYear(sectionData.get("crowdingRate").toString()); |
|
|
|
passIndicatorTimeDistribution.setSaturationRateLastYear(sectionData.get("saturationRate").toString()); |
|
|
|
// passIndicatorTimeDistribution.setSaturationRateLastYear(sectionData.get("saturationRate").toString());
|
|
|
|
if (sectionData.get("saturationRate") instanceof Double){ |
|
|
|
double saturationRate = (Double)sectionData.get("saturationRate"); |
|
|
|
passIndicatorTimeDistribution.setSaturationRateLastYear(String.format("%.4f", saturationRate)); |
|
|
|
} else { |
|
|
|
passIndicatorTimeDistribution.setSaturationRateLastYear("0"); |
|
|
|
} |
|
|
|
passIndicatorTimeDistribution.setTrafficCompositionRateLastYear(sectionData.get("trafficCompositionRate").toString()); |
|
|
|
} |
|
|
|
list.add(passIndicatorTimeDistribution); |
|
|
@ -704,7 +745,7 @@ public AjaxResult realTimeTrafficFlow(String startDate, String direction,String |
|
|
|
// 将获取到的交通指标数据封装为成功的结果并返回
|
|
|
|
return AjaxResult.success(jsonArray); |
|
|
|
} |
|
|
|
|
|
|
|
// @Scheduled(cron = "0/30 * * * * ?")
|
|
|
|
@ApiOperation("获取当前拥堵路段") |
|
|
|
@GetMapping("/current/getTheCurrentCongestedSection") |
|
|
|
public AjaxResult getTheCurrentCongestedSection() throws HttpException, IOException { |
|
|
|