|
|
@ -3,19 +3,20 @@ package com.zc.business.controller; |
|
|
|
import com.ruoyi.common.core.controller.BaseController; |
|
|
|
import com.ruoyi.common.core.domain.AjaxResult; |
|
|
|
import com.ruoyi.common.core.page.TableDataInfo; |
|
|
|
import com.ruoyi.common.utils.poi.ExcelUtil; |
|
|
|
import com.zc.business.domain.DcDispatch; |
|
|
|
import com.zc.business.domain.DcWarning; |
|
|
|
import com.zc.business.domain.export.*; |
|
|
|
import com.zc.business.service.IDCPerceivedEventsWarningService; |
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.web.bind.annotation.PostMapping; |
|
|
|
import org.springframework.web.bind.annotation.RequestBody; |
|
|
|
import org.springframework.web.bind.annotation.RequestMapping; |
|
|
|
import org.springframework.web.bind.annotation.RestController; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
import java.util.Date; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
|
* @author 王思祥 |
|
|
@ -253,6 +254,44 @@ public class DCPerceivedEventsWarningController extends BaseController { |
|
|
|
} |
|
|
|
return AjaxResult.success(perceivedEventsWarningService.selectManyTimesInterval(dcWarning)); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 导出感知事件多发时段 |
|
|
|
* |
|
|
|
* @author liuwenge |
|
|
|
* @date 2024/6/25 10:34 |
|
|
|
* @param response |
|
|
|
* @param dcWarning |
|
|
|
* @return com.ruoyi.common.core.domain.AjaxResult |
|
|
|
*/ |
|
|
|
@ApiOperation(value = "导出感知事件多发时段",tags = {"ECharts导出"}) |
|
|
|
@GetMapping("/exportManyTimesInterval") |
|
|
|
public AjaxResult exportManyTimesInterval(HttpServletResponse response,DcWarning dcWarning){ |
|
|
|
if (dcWarning==null||StringUtils.isBlank(dcWarning.getType())||dcWarning.getCurrently()==null||dcWarning.getLastYear()==null |
|
|
|
||StringUtils.isBlank(dcWarning.getStartStakeMark())||StringUtils.isBlank(dcWarning.getEndStakeMark()) |
|
|
|
||StringUtils.isBlank(dcWarning.getDirection())){ |
|
|
|
return AjaxResult.error("参数错误"); |
|
|
|
} |
|
|
|
HashMap<String,Object> map = perceivedEventsWarningService.selectManyTimesInterval(dcWarning); |
|
|
|
List<ManyTimesInterval> list = new ArrayList<>(); |
|
|
|
if (map != null){ |
|
|
|
List<HashMap<String,Object>> currentlyMap = (List<HashMap<String, Object>>) map.get("currentlyMap"); |
|
|
|
List<HashMap<String,Object>> lastYearMap = (List<HashMap<String, Object>>) map.get("lastYearMap"); |
|
|
|
for (int i = 0; i < currentlyMap.size(); i++) { |
|
|
|
ManyTimesInterval manyTimesInterval = new ManyTimesInterval(); |
|
|
|
int time = Integer.parseInt(currentlyMap.get(i).get("time").toString()); |
|
|
|
manyTimesInterval.setTime(time + "点至" + (time +1) + "点"); |
|
|
|
manyTimesInterval.setCurrentData(currentlyMap.get(i).get("number").toString()); |
|
|
|
manyTimesInterval.setContemporaneousData(lastYearMap.get(i).get("number").toString()); |
|
|
|
list.add(manyTimesInterval); |
|
|
|
} |
|
|
|
} |
|
|
|
ExcelUtil<ManyTimesInterval> util = new ExcelUtil<>(ManyTimesInterval.class); |
|
|
|
util.exportExcel(response, list, "感知事件多发时段"); |
|
|
|
|
|
|
|
return AjaxResult.success("导出感知事件多发时段成功"); |
|
|
|
} |
|
|
|
|
|
|
|
//新-感知事件类型分析
|
|
|
|
@PostMapping("/selectWarningType") |
|
|
|
public AjaxResult selectWarningType(@RequestBody DcWarning dcWarning){ |
|
|
@ -263,6 +302,36 @@ public class DCPerceivedEventsWarningController extends BaseController { |
|
|
|
} |
|
|
|
return AjaxResult.success(perceivedEventsWarningService.newSelectWarningType(dcWarning)); |
|
|
|
} |
|
|
|
@ApiOperation(value = "导出感知事件类型分析",tags = {"ECharts导出"}) |
|
|
|
@GetMapping("/exportSelectWarningType") |
|
|
|
public AjaxResult exportSelectWarningType(HttpServletResponse response,DcWarning dcWarning){ |
|
|
|
if (dcWarning==null||StringUtils.isBlank(dcWarning.getType())||dcWarning.getCurrently()==null||dcWarning.getLastYear()==null |
|
|
|
||StringUtils.isBlank(dcWarning.getStartStakeMark())||StringUtils.isBlank(dcWarning.getEndStakeMark()) |
|
|
|
||StringUtils.isBlank(dcWarning.getDirection())){ |
|
|
|
return AjaxResult.error("参数错误"); |
|
|
|
} |
|
|
|
HashMap<String,Object> map = perceivedEventsWarningService.newSelectWarningType(dcWarning); |
|
|
|
List<SelectWarningType> list = new ArrayList<>(); |
|
|
|
if (map != null){ |
|
|
|
List<HashMap<String,Object>> currentlyMap = (List<HashMap<String, Object>>) map.get("currentlyMap"); |
|
|
|
Integer total = 0; |
|
|
|
for (HashMap<String, Object> stringObjectHashMap : currentlyMap) { |
|
|
|
total += Integer.parseInt(stringObjectHashMap.get("number").toString()); |
|
|
|
} |
|
|
|
for (int i = 0; i < currentlyMap.size(); i++) { |
|
|
|
SelectWarningType selectWarningType = new SelectWarningType(); |
|
|
|
selectWarningType.setWarningType(currentlyMap.get(i).get("warningType").toString()); |
|
|
|
selectWarningType.setNumber(currentlyMap.get(i).get("number").toString()); |
|
|
|
double ratio = Double.parseDouble(currentlyMap.get(i).get("number").toString()) / total * 100; |
|
|
|
selectWarningType.setRatio(String.format("%.2f", ratio) + "%"); |
|
|
|
list.add(selectWarningType); |
|
|
|
} |
|
|
|
} |
|
|
|
ExcelUtil<SelectWarningType> util = new ExcelUtil<>(SelectWarningType.class); |
|
|
|
util.exportExcel(response, list, "感知事件类型分析"); |
|
|
|
|
|
|
|
return AjaxResult.success("导出感知事件类型分析成功"); |
|
|
|
} |
|
|
|
//新-感知事件桩号范围内事件分析
|
|
|
|
@PostMapping("/selectSection") |
|
|
|
public AjaxResult selectSection(@RequestBody DcWarning dcWarning){ |
|
|
@ -273,6 +342,42 @@ public class DCPerceivedEventsWarningController extends BaseController { |
|
|
|
} |
|
|
|
return AjaxResult.success(perceivedEventsWarningService.newSelectSection(dcWarning)); |
|
|
|
} |
|
|
|
|
|
|
|
@ApiOperation(value = "导出桩号范围内事件分析",tags = {"ECharts导出"}) |
|
|
|
@GetMapping("/exportSelectSection") |
|
|
|
public AjaxResult exportSelectSection(HttpServletResponse response,DcWarning dcWarning){ |
|
|
|
if (dcWarning==null||StringUtils.isBlank(dcWarning.getType())||dcWarning.getCurrently()==null||dcWarning.getLastYear()==null |
|
|
|
||StringUtils.isBlank(dcWarning.getStartStakeMark())||StringUtils.isBlank(dcWarning.getEndStakeMark()) |
|
|
|
||StringUtils.isBlank(dcWarning.getDirection())){ |
|
|
|
return AjaxResult.error("参数错误"); |
|
|
|
} |
|
|
|
HashMap<String,Object> map = perceivedEventsWarningService.newSelectSection(dcWarning); |
|
|
|
List<SelectSection> list = new ArrayList<>(); |
|
|
|
if (map != null){ |
|
|
|
HashMap<String,Object> currentlyMap = (HashMap<String, Object>) map.get("currentlyMap"); |
|
|
|
HashMap<String,Object> lastYearMap = (HashMap<String, Object>) map.get("lastYearMap"); |
|
|
|
|
|
|
|
Set<String> allKeys = new HashSet<>(currentlyMap.keySet()); |
|
|
|
allKeys.addAll(lastYearMap.keySet()); |
|
|
|
for (String key : allKeys) { |
|
|
|
SelectSection selectSection = new SelectSection(); |
|
|
|
selectSection.setStakeMark(key); |
|
|
|
if (currentlyMap.containsKey(key)){ |
|
|
|
selectSection.setCurrentData(currentlyMap.get(key).toString()); |
|
|
|
} |
|
|
|
if (lastYearMap.containsKey(key)){ |
|
|
|
selectSection.setContemporaneousData(lastYearMap.get(key).toString()); |
|
|
|
} |
|
|
|
|
|
|
|
list.add(selectSection); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
ExcelUtil<SelectSection> util = new ExcelUtil<>(SelectSection.class); |
|
|
|
util.exportExcel(response, list, "桩号范围内事件分析"); |
|
|
|
|
|
|
|
return AjaxResult.success("导出桩号范围内事件分析成功"); |
|
|
|
} |
|
|
|
//新-感知事件路段处置类型分析
|
|
|
|
@PostMapping("/selectStateType") |
|
|
|
public AjaxResult selectStateType(@RequestBody DcWarning dcWarning){ |
|
|
@ -281,9 +386,88 @@ public class DCPerceivedEventsWarningController extends BaseController { |
|
|
|
} |
|
|
|
return AjaxResult.success(perceivedEventsWarningService.newSelectStateType(dcWarning)); |
|
|
|
} |
|
|
|
@ApiOperation(value = "导出感知事件路段分析",tags = {"ECharts导出"}) |
|
|
|
@GetMapping("/exportSelectStateType") |
|
|
|
public AjaxResult exportSelectStateType(HttpServletResponse response, DcWarning dcWarning){ |
|
|
|
if (dcWarning==null||dcWarning.getCurrently()==null||dcWarning.getLastYear()==null){ |
|
|
|
return AjaxResult.error("参数错误"); |
|
|
|
} |
|
|
|
List<SelectStateType> list = new ArrayList<>(); |
|
|
|
|
|
|
|
HashMap<String,Object> map = perceivedEventsWarningService.newSelectStateType(dcWarning); |
|
|
|
List<Map<String,Object>> currentlyMap = (List<Map<String, Object>>) map.get("currentlyMap"); |
|
|
|
List<HashMap<String,Object>> lastYearMap = (List<HashMap<String, Object>>) map.get("lastYearMap"); |
|
|
|
List<HashMap<String,Object>> stateDuration = (List<HashMap<String, Object>>) map.get("stateDuration"); |
|
|
|
|
|
|
|
Map<String,List<Map<String,Object>>> currentlyData = currentlyMap.stream().collect(Collectors.groupingBy(item -> item.get("sectionName").toString())); |
|
|
|
Map<String,List<Map<String,Object>>> lastYearData = lastYearMap.stream().collect(Collectors.groupingBy(item -> item.get("sectionName").toString())); |
|
|
|
Map<String,List<Map<String,Object>>> stateDurationData = stateDuration.stream().collect(Collectors.groupingBy(item -> item.get("sectionName").toString())); |
|
|
|
|
|
|
|
Set<String> allKeys = new HashSet<>(currentlyData.keySet()); |
|
|
|
allKeys.addAll(lastYearData.keySet()); |
|
|
|
allKeys.addAll(stateDurationData.keySet()); |
|
|
|
for (String key : allKeys) { |
|
|
|
SelectStateType selectStateType = new SelectStateType(); |
|
|
|
selectStateType.setSectionName(key); |
|
|
|
selectStateType.setSectionName(key); |
|
|
|
if (currentlyData.containsKey(key)){ |
|
|
|
List<Map<String,Object>> sectionData = currentlyData.get(key); |
|
|
|
for (int i = 0; i < sectionData.size(); i++) { |
|
|
|
if ("1".equals(sectionData.get(i).get("warningState").toString())){ |
|
|
|
selectStateType.setReporting(sectionData.get(i).get("num").toString()); |
|
|
|
} else if ("2".equals(sectionData.get(i).get("warningState").toString())){ |
|
|
|
selectStateType.setCompleted(sectionData.get(i).get("num").toString()); |
|
|
|
} else if ("3".equals(sectionData.get(i).get("warningState").toString())){ |
|
|
|
selectStateType.setTerminated(sectionData.get(i).get("num").toString()); |
|
|
|
} else if ("4".equals(sectionData.get(i).get("warningState").toString())){ |
|
|
|
selectStateType.setAutomaticTermination(sectionData.get(i).get("num").toString()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (lastYearData.containsKey(key)){ |
|
|
|
List<Map<String,Object>> sectionData = lastYearData.get(key); |
|
|
|
Integer total = 0; |
|
|
|
for (Map<String, Object> sectionDatum : sectionData) { |
|
|
|
total += Integer.parseInt(sectionDatum.get("num").toString()); |
|
|
|
} |
|
|
|
selectStateType.setContemporaneousData(total.toString()); |
|
|
|
} |
|
|
|
if (stateDurationData.containsKey(key)){ |
|
|
|
List<Map<String,Object>> sectionData = stateDurationData.get(key); |
|
|
|
selectStateType.setAverageDuration(sectionData.get(0).get("avg").toString()); |
|
|
|
} |
|
|
|
|
|
|
|
list.add(selectStateType); |
|
|
|
} |
|
|
|
|
|
|
|
ExcelUtil<SelectStateType> util = new ExcelUtil<>(SelectStateType.class); |
|
|
|
util.exportExcel(response, list, "感知事件路段分析"); |
|
|
|
|
|
|
|
return AjaxResult.success("导出感知事件路段分析成功"); |
|
|
|
} |
|
|
|
//查询感知数量按照路段数量进行排名
|
|
|
|
@PostMapping("/sectionPerceivedList") |
|
|
|
public AjaxResult getSectionPerceivedEventsList(){ |
|
|
|
return AjaxResult.success(perceivedEventsWarningService.selectSectionPerceivedEventsList()); |
|
|
|
} |
|
|
|
|
|
|
|
@ApiOperation(value = "导出感知事件路段排名",tags = {"ECharts导出"}) |
|
|
|
@GetMapping("/exportSectionPerceivedList") |
|
|
|
public AjaxResult exportSectionPerceivedList(HttpServletResponse response){ |
|
|
|
List<HashMap<String,Object>> dataList = perceivedEventsWarningService.selectSectionPerceivedEventsList(); |
|
|
|
List<SectionPerceivedList> list = new ArrayList<>(); |
|
|
|
if (dataList != null && dataList.size() > 0){ |
|
|
|
for (int i = 0; i < dataList.size(); i++) { |
|
|
|
SectionPerceivedList sectionPerceivedList = new SectionPerceivedList(); |
|
|
|
sectionPerceivedList.setRank(i+1); |
|
|
|
sectionPerceivedList.setSectionName(dataList.get(i).get("sectionName").toString()); |
|
|
|
sectionPerceivedList.setNumber(dataList.get(i).get("number").toString()); |
|
|
|
list.add(sectionPerceivedList); |
|
|
|
} |
|
|
|
} |
|
|
|
ExcelUtil<SectionPerceivedList> util = new ExcelUtil<>(SectionPerceivedList.class); |
|
|
|
util.exportExcel(response, list, "感知事件路段排名"); |
|
|
|
|
|
|
|
return AjaxResult.success("导出感知事件路段排名成功"); |
|
|
|
} |
|
|
|
} |
|
|
|