Commit bd0327a7 authored by duanruiming's avatar duanruiming

Merge remote-tracking branch 'origin/master'

parents 73add64c 3ddf29dc
...@@ -11,6 +11,7 @@ import lombok.extern.slf4j.Slf4j; ...@@ -11,6 +11,7 @@ import lombok.extern.slf4j.Slf4j;
import net.wanji.common.framework.exception.DubboProviderException; import net.wanji.common.framework.exception.DubboProviderException;
import net.wanji.common.framework.rest.JsonViewObject; import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.opt.dto.CrossIdAndMinutesDTO; import net.wanji.opt.dto.CrossIdAndMinutesDTO;
import net.wanji.opt.entity.EventAlarmInfo;
import net.wanji.opt.po.base.EventStatisticPo; import net.wanji.opt.po.base.EventStatisticPo;
import net.wanji.opt.service.EvaluateService; import net.wanji.opt.service.EvaluateService;
import net.wanji.opt.service.EventService; import net.wanji.opt.service.EventService;
...@@ -21,6 +22,7 @@ import org.springframework.web.bind.annotation.GetMapping; ...@@ -21,6 +22,7 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
...@@ -89,4 +91,30 @@ public class EventController { ...@@ -89,4 +91,30 @@ public class EventController {
} }
@GetMapping("/getAlarmInfo")
@ApiOperation(hidden = false, value = "事件报警", notes = "", produces = "application/json")
@ApiImplicitParams({
@ApiImplicitParam(name = "timeScope", value = "时间范围:为1查询最近实时30条,为空时查询当天历史", required = false, dataType = "String"),
@ApiImplicitParam(name = "eventType", value = "事件类型,701:空放 702:失衡 703:溢出 705:干线缓行 706:干线拥堵 707:路口拥堵", required = false, dataType = "String"),
@ApiImplicitParam(name = "name", value = "按名称模糊查询", required = false, dataType = "String"),
}
)
@ApiResponses({
@ApiResponse(code = 200, message = "成功", response = EventAlarmInfo.class,
responseHeaders = {@ResponseHeader(name = "Content-Type", description = "application/json")})
})
public JsonViewObject list(@RequestParam(defaultValue = "") String timeScope, @RequestParam(defaultValue = "") String eventType , @RequestParam(defaultValue = "") String name) {
try {
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
List<EventAlarmInfo> eventAlarmInfo = eventService.findEventAlarmInfo(timeScope,eventType,name);
return jsonViewObject.success(eventAlarmInfo);
} catch (Exception e) {
log.error("", e);
return JsonViewObject.newInstance().fail("请求失败");
}
}
} }
\ No newline at end of file
...@@ -2,9 +2,11 @@ package net.wanji.opt.dao.mapper; ...@@ -2,9 +2,11 @@ package net.wanji.opt.dao.mapper;
import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import net.wanji.opt.entity.EventAlarmInfo;
import net.wanji.opt.po.base.EventStatisticPo; import net.wanji.opt.po.base.EventStatisticPo;
import net.wanji.opt.po.trend.EventInfoSimplePo; import net.wanji.opt.po.trend.EventInfoSimplePo;
import net.wanji.opt.po.trend.HoloEventInfoPO; import net.wanji.opt.po.trend.HoloEventInfoPO;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.Date; import java.util.Date;
...@@ -29,4 +31,7 @@ public interface HoloEventMapper extends BaseMapper<HoloEventInfoPO> { ...@@ -29,4 +31,7 @@ public interface HoloEventMapper extends BaseMapper<HoloEventInfoPO> {
EventStatisticPo findCrossEventCount(Map<String,Object> params); EventStatisticPo findCrossEventCount(Map<String,Object> params);
List<EventInfoSimplePo> findEventDistribute(Map<String,Object> params); List<EventInfoSimplePo> findEventDistribute(Map<String,Object> params);
List<EventAlarmInfo> findEventAlarmInfo(String timeScope,String eventType,String name);
} }
package net.wanji.opt.entity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* <p>
* 运行监控 路口方案下发查询
* </p>
*
* @Author hwm
* @Date 2024-12-1
*/
@Data
@ApiModel(value="EventAlarmInfo对象", description="运行监控-预警事件查询")
public class EventAlarmInfo {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "绿波ID")
private Integer greenId;
@ApiModelProperty(value = "路口ID")
private String crossId;
@ApiModelProperty(value = "路口名称/绿波名称")
private String crossName;
@ApiModelProperty(value = "预警类型")
private String currentAlgo;
@ApiModelProperty(value = "下发时间")
private String issueTime;
@ApiModelProperty(value = "状态类型")
private String type;
@ApiModelProperty(value = "是否新记录,0否,1是")
private String newRecoder;
@ApiModelProperty(value = "坐标点")
private String wkt;
@ApiModelProperty(value = "是否优化标识")
private String optStatus;
}
...@@ -18,8 +18,8 @@ public class CrossLaneDataHistPoExtend { ...@@ -18,8 +18,8 @@ public class CrossLaneDataHistPoExtend {
@ApiModelProperty(name = "路口编号",notes = "") @ApiModelProperty(name = "路口编号",notes = "")
private String crossId; private String crossId;
//车道ID //车道ID
@ApiModelProperty(value = "车道ID", notes = "") @ApiModelProperty(value = "车道", notes = "")
private String laneId; private Integer laneNo;
//方向 //方向
@ApiModelProperty(value = "方向", notes = "") @ApiModelProperty(value = "方向", notes = "")
private Integer dirType; private Integer dirType;
......
...@@ -12,6 +12,7 @@ import net.wanji.opt.bo.GreenwaveIdBO; ...@@ -12,6 +12,7 @@ import net.wanji.opt.bo.GreenwaveIdBO;
import net.wanji.opt.bo.SaveGreenwaveStrategyBO; import net.wanji.opt.bo.SaveGreenwaveStrategyBO;
import net.wanji.opt.dto.trend.AbnormalCrossListDTO; import net.wanji.opt.dto.trend.AbnormalCrossListDTO;
import net.wanji.opt.dto.trend.GreenwaveListDTO; import net.wanji.opt.dto.trend.GreenwaveListDTO;
import net.wanji.opt.entity.EventAlarmInfo;
import net.wanji.opt.po.base.EventStatisticPo; import net.wanji.opt.po.base.EventStatisticPo;
import net.wanji.opt.po.trend.AnalysisRidTurnIndicators; import net.wanji.opt.po.trend.AnalysisRidTurnIndicators;
import net.wanji.opt.po.trend.HoloEventInfoPO; import net.wanji.opt.po.trend.HoloEventInfoPO;
...@@ -69,4 +70,14 @@ public interface EventService { ...@@ -69,4 +70,14 @@ public interface EventService {
* @return * @return
*/ */
List<Map<String,Object>> findEventDistribute(String crossId, String startTime, String endTime) throws DubboProviderException; List<Map<String,Object>> findEventDistribute(String crossId, String startTime, String endTime) throws DubboProviderException;
/**
* 当时事件报警数据监测
* @param greenId
* @param crossId
* @param type 为1时查询当天最近30条,为空时查询当天所有
* @return
* @throws DubboProviderException
*/
List<EventAlarmInfo> findEventAlarmInfo(String timeScope,String eventType,String name) throws DubboProviderException;
} }
...@@ -45,6 +45,7 @@ import net.wanji.opt.dao.mapper.base.BaseRidInfoMapper; ...@@ -45,6 +45,7 @@ import net.wanji.opt.dao.mapper.base.BaseRidInfoMapper;
import net.wanji.opt.dao.mapper.strategy.SceneMapper; import net.wanji.opt.dao.mapper.strategy.SceneMapper;
import net.wanji.opt.dao.mapper.strategy.SceneStrategyMapper; import net.wanji.opt.dao.mapper.strategy.SceneStrategyMapper;
import net.wanji.opt.dao.mapper.strategy.StrategyMapper; import net.wanji.opt.dao.mapper.strategy.StrategyMapper;
import net.wanji.opt.entity.EventAlarmInfo;
import net.wanji.opt.po.base.BaseRidInfo; import net.wanji.opt.po.base.BaseRidInfo;
import net.wanji.opt.po.base.CrossLaneDataHistPoExtend; import net.wanji.opt.po.base.CrossLaneDataHistPoExtend;
import net.wanji.opt.po.base.EventStatisticPo; import net.wanji.opt.po.base.EventStatisticPo;
...@@ -224,9 +225,9 @@ public class EventServiceImpl implements EventService { ...@@ -224,9 +225,9 @@ public class EventServiceImpl implements EventService {
} }
}); });
}); });
List<EventInfoSimplePo> sortList = tmpList.stream().sorted(Comparator.comparing(o->o.getStartTime())).collect(Collectors.toList()); List<EventInfoSimplePo> sortList = tmpList.stream().sorted(Comparator.comparing(o -> o.getStartTime())).collect(Collectors.toList());
sortList.forEach(po -> { sortList.forEach(po -> {
String axis = DateUtil.formatDate(po.getStartTime(), "M/d") + "," + DateUtil.formatDate(po.getStartTime(), "HH:mm:ss") +","+ po.getEventType(); String axis = DateUtil.formatDate(po.getStartTime(), "M/d") + "," + DateUtil.formatDate(po.getStartTime(), "HH:mm:ss") + "," + po.getEventType();
dataserList.add(axis); dataserList.add(axis);
}); });
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
...@@ -249,6 +250,14 @@ public class EventServiceImpl implements EventService { ...@@ -249,6 +250,14 @@ public class EventServiceImpl implements EventService {
return retList; return retList;
} }
@Override
public List<EventAlarmInfo> findEventAlarmInfo(String timeScope, String eventType, String name) throws DubboProviderException {
//获取数据库数据
List<EventAlarmInfo> eventAlarmInfo = holoEventMapper.findEventAlarmInfo(timeScope, eventType, name);
return eventAlarmInfo;
}
public Set<String> getTimeScopeList(DateTime start, DateTime end, String dateFormat) { public Set<String> getTimeScopeList(DateTime start, DateTime end, String dateFormat) {
Set<String> indexList = new HashSet<>(); Set<String> indexList = new HashSet<>();
......
...@@ -53,6 +53,8 @@ import java.util.Random; ...@@ -53,6 +53,8 @@ import java.util.Random;
import java.util.Set; import java.util.Set;
import java.util.TreeMap; import java.util.TreeMap;
import java.util.TreeSet; import java.util.TreeSet;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -75,8 +77,7 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH ...@@ -75,8 +77,7 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH
private MainlineEvaluateService mainlineEvaluateService; private MainlineEvaluateService mainlineEvaluateService;
@Resource @Resource
BaseCrossInfoMapper baseCrossInfoMapper BaseCrossInfoMapper baseCrossInfoMapper;
;
@Override @Override
public BaseInterfaceMapper<GreenwaveHist> getBaseInterfaceMapper() { public BaseInterfaceMapper<GreenwaveHist> getBaseInterfaceMapper() {
...@@ -156,36 +157,36 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH ...@@ -156,36 +157,36 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH
params.put("endDate", endTime); params.put("endDate", endTime);
params.put("greenDir", greenDir); params.put("greenDir", greenDir);
List<Map<String,Object>> getList = greenwaveHistoryMapper.findUnCoordinateCrossIndex(params); List<Map<String, Object>> getList = greenwaveHistoryMapper.findUnCoordinateCrossIndex(params);
List<GreenwaveCrossTrendPo> list = new ArrayList<>(); List<GreenwaveCrossTrendPo> list = new ArrayList<>();
//存放时段 //存放时段
Set<String> sortedSet = new TreeSet<>(); Set<String> sortedSet = new TreeSet<>();
for (Map<String,Object> map : getList) { for (Map<String, Object> map : getList) {
GreenwaveCrossTrendPo po = new GreenwaveCrossTrendPo(); GreenwaveCrossTrendPo po = new GreenwaveCrossTrendPo();
String crossNo = map.get("cross_id").toString(); String crossNo = map.get("cross_id").toString();
String st = map.get("start_time").toString(); String st = map.get("start_time").toString();
po.setCrossId(crossNo); po.setCrossId(crossNo);
po.setStartTime(DateTime.parse(st,DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss")).toDate()); po.setStartTime(DateTime.parse(st, DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss")).toDate());
//提取时间 //提取时间
sortedSet.add(DateUtil.formatDate(po.getStartTime(), "HH:mm")); sortedSet.add(DateUtil.formatDate(po.getStartTime(), "HH:mm"));
String indexList = map.get("index_list").toString(); String indexList = map.get("index_list").toString();
List<GreenwaveCrossTrendPo> finalList = new ArrayList<>(); List<GreenwaveCrossTrendPo> finalList = new ArrayList<>();
Arrays.stream(indexList.split("@")).forEach(o->{ Arrays.stream(indexList.split("@")).forEach(o -> {
String[] sps = o.split(","); String[] sps = o.split(",");
String type = sps[0]; String type = sps[0];
String queueLength = sps[1]; String queueLength = sps[1];
String stopTimes = sps[2]; String stopTimes = sps[2];
String flow = sps[3]; String flow = sps[3];
if (Objects.equals("1",type)) { if (Objects.equals("1", type)) {
//非协调方向 //非协调方向
po.setFlow(new BigDecimal(flow)); po.setFlow(new BigDecimal(flow));
po.setQueueLength(new BigDecimal(queueLength)); po.setQueueLength(new BigDecimal(queueLength));
po.setStopTimes(new BigDecimal(stopTimes)); po.setStopTimes(new BigDecimal(stopTimes));
} else if (Objects.equals("2",type)){ } else if (Objects.equals("2", type)) {
//协调方向 //协调方向
po.setCordFlow(new BigDecimal(flow)); po.setCordFlow(new BigDecimal(flow));
po.setCordQueueLength(new BigDecimal(queueLength)); po.setCordQueueLength(new BigDecimal(queueLength));
...@@ -417,29 +418,26 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH ...@@ -417,29 +418,26 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH
List<CrossLaneDataHistPoExtend> list = greenwaveHistoryMapper.findGreenWaveCrossLaneIndex(params); List<CrossLaneDataHistPoExtend> list = greenwaveHistoryMapper.findGreenWaveCrossLaneIndex(params);
list = list.stream().sorted(Comparator.comparing(o -> o.getStartTime())).collect(Collectors.toList()); list = list.stream().sorted(Comparator.comparing(o -> o.getStartTime())).collect(Collectors.toList());
//按时间分组分组 //按时间分组分组
Map<String, List<CrossLaneDataHistPoExtend>> groupByDir = list.stream().collect(Collectors.groupingBy(o -> o.getCrossId() + "_" + o.getLaneId() + "_" + o.getDirType() + "_" + o.getTurnType(), TreeMap::new, Collectors.toList())); Map<String, List<CrossLaneDataHistPoExtend>> groupByDir = list.stream().collect(Collectors.groupingBy(o -> o.getCrossId() + "_" + o.getLaneNo() + "_" + o.getDirType() + "_" + o.getTurnType(), TreeMap::new, Collectors.toList()));
Set<String> hasDataScopeList = new HashSet<>(); Set<String> hasDataScopeList = new HashSet<>();
for (Map.Entry<String, List<CrossLaneDataHistPoExtend>> entry : groupByDir.entrySet()) { for (Map.Entry<String, List<CrossLaneDataHistPoExtend>> entry : groupByDir.entrySet()) {
String key = entry.getKey(); String key = entry.getKey();
String[] sps = key.split("_"); String[] sps = key.split("_");
String laneId = sps[1]; String laneNo = sps[1];
String laneNo = laneId.substring(laneId.length() - 2);
Integer dirType = null; Integer dirType = null;
String dirName = null; String dirName = null;
String turnDesc = null; String turnDesc = null;
String dirTurnDesc = null; String dirTurnDesc = null;
Map<String, Object> mapList = new HashMap<>(); Map<String, Object> mapList = new HashMap<>();
if (Objects.equals(4,objectType)){ if (Objects.equals(4, objectType)) {
TBaseCrossInfo tBaseCrossInfo = baseCrossInfoMapper.selectByPrimaryKey(sps[0]); TBaseCrossInfo tBaseCrossInfo = baseCrossInfoMapper.selectByPrimaryKey(sps[0]);
dirTurnDesc = tBaseCrossInfo.getName(); dirTurnDesc = tBaseCrossInfo.getName();
}else if (Objects.equals(3, objectType)) { } else if (Objects.equals(3, objectType)) {
mapList.put("laneId", laneId);
mapList.put("laneNo", laneNo); mapList.put("laneNo", laneNo);
dirType = Integer.parseInt(sps[2]); dirType = Integer.parseInt(sps[2]);
dirName = BaseEnum.SignalDirectionEnum.getNameByCode(dirType); dirName = BaseEnum.SignalDirectionEnum.getNameByCode(dirType);
...@@ -462,7 +460,6 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH ...@@ -462,7 +460,6 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH
List<CrossLaneDataHistPoExtend> value = this.processData(entry, groupType, sortedSet, startTime); List<CrossLaneDataHistPoExtend> value = this.processData(entry, groupType, sortedSet, startTime);
mapList.put("scopeCode", key); mapList.put("scopeCode", key);
mapList.put("scopeName", dirTurnDesc); mapList.put("scopeName", dirTurnDesc);
mapList.put("list", value); mapList.put("list", value);
...@@ -539,6 +536,7 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH ...@@ -539,6 +536,7 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH
Set<String> hasDataScopeList = new HashSet<>(); Set<String> hasDataScopeList = new HashSet<>();
BottomMenuBO bo = new BottomMenuBO(); BottomMenuBO bo = new BottomMenuBO();
bo.setCrossId(crossId); bo.setCrossId(crossId);
bo.setScope(objectType); bo.setScope(objectType);
...@@ -551,40 +549,130 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH ...@@ -551,40 +549,130 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH
String cid = sps[0]; String cid = sps[0];
String dirType = sps[1]; String dirType = sps[1];
String dirName = BaseEnum.SignalDirectionEnum.getNameByCode(Integer.valueOf(dirType)); String dirName = null;
if (!Objects.equals("null",dirType)) {
dirName = BaseEnum.SignalDirectionEnum.getNameByCode(Integer.valueOf(dirType));
}
String dirTurnDesc = dirName + "进口"; String dirTurnDesc = dirName + "进口";
Map<String, Object> mapList = new HashMap<>(); Map<String, Object> mapList = new HashMap<>();
List<CrossLaneDataHistPoExtend> value = entry.getValue().stream().sorted(Comparator.comparing(o->o.getTurnType())).collect(Collectors.toList()); List<CrossLaneDataHistPoExtend> value = entry.getValue().stream().sorted(Comparator.comparing(o -> o.getTurnType())).collect(Collectors.toList());
value.forEach(o->{ //========================路口级服务水平加权平均 start=================================================================//
if (Objects.equals(2,objectType) || Objects.equals(3,objectType)) { String serviceLevelList = value.get(0).getServiceLevel();
StringBuilder serviceLevelBuf = new StringBuilder();
if (serviceLevelList != null) {
Map<String, Long> serviceGroup = Arrays.stream(serviceLevelList.split(",")).collect(Collectors.groupingBy(String::valueOf, Collectors.counting()));
double total = 0;
for (Map.Entry<String, Long> entry1 : serviceGroup.entrySet()) {
String key1 = entry1.getKey();
total += ServiceLevelEnum.getByType(key1).getVal() * entry1.getValue();
}
//服务水平加权平均计算:给服务水平(等级得分*该等级的数量)累加/总数量
int avgService = (int) Math.round(total / value.size());
String avgServiceLevel = ServiceLevelEnum.getByVal(avgService) == null ? "A" : ServiceLevelEnum.getByVal(avgService).getType();
serviceLevelBuf.append(avgServiceLevel);
}
//========================路口级服务水平加权平均 end=================================================================//
value.forEach(o -> {
o.setServiceLevel(serviceLevelBuf.toString());
o.setDirTypeName(dirTurnDesc);
if (Objects.equals(2, objectType)) {
o.setTurnTypeName(TurnConvertEnum.getDescByKey(o.getTurnType())); o.setTurnTypeName(TurnConvertEnum.getDescByKey(o.getTurnType()));
hasDataScopeList.add(dirTurnDesc+o.getTurnTypeName()); hasDataScopeList.add(dirTurnDesc + o.getTurnTypeName());
} else if (Objects.equals(3, objectType)) {
o.setTurnTypeName(TurnConvertEnum.getDescByKey(o.getTurnType())+ o.getLaneNo() + "车道");
hasDataScopeList.add(dirTurnDesc + o.getTurnTypeName() + o.getLaneNo() + "车道");
} else { } else {
hasDataScopeList.add(dirTurnDesc); hasDataScopeList.add(dirTurnDesc);
} }
}); });
//===============补充某个方向有数据但是不完整的================================================================================//
if (Objects.nonNull(scopeList)) { if (Objects.nonNull(scopeList)) {
//补充 //补充
for (String scopeName1 : scopeList) { for (String scopeName1 : scopeList) {
if (!hasDataScopeList.contains(scopeName1) && scopeName1.contains(dirTurnDesc)) { if (!hasDataScopeList.contains(scopeName1) && scopeName1.contains(dirTurnDesc)) {
CrossLaneDataHistPoExtend tmp = new CrossLaneDataHistPoExtend(); CrossLaneDataHistPoExtend tmp = new CrossLaneDataHistPoExtend();
tmp.setCrossId(cid);
tmp.setDirType(BaseEnum.SignalDirectionEnum.getCodeByName(scopeName1.substring(0,scopeName1.indexOf("进口"))));
tmp.setDirTypeName(dirTurnDesc);
tmp.setTurnTypeName(scopeName1.substring(dirTurnDesc.length())); tmp.setTurnTypeName(scopeName1.substring(dirTurnDesc.length()));
tmp.setTurnType(TurnConvertEnum.getKeyByDesc(tmp.getTurnTypeName())); tmp.setTurnType(TurnConvertEnum.getKeyByDesc(tmp.getTurnTypeName()));
//利用正则表达式取车道号
if (Objects.equals(3, objectType)) {
Pattern pattern = Pattern.compile("\\d+");
Matcher matcher = pattern.matcher(scopeName1);
if (matcher.find()) {
Integer laneNo = Integer.valueOf(matcher.group());
tmp.setLaneNo(laneNo);
tmp.setTurnType(TurnConvertEnum.getKeyByDesc(tmp.getTurnTypeName().substring(0,tmp.getTurnTypeName().indexOf(laneNo.toString()))));
hasDataScopeList.add(tmp.getDirTypeName()+tmp.getTurnTypeName());
}
}
value.add(tmp); value.add(tmp);
} }
} }
} }
value = value.stream().sorted(Comparator.comparing(o->o.getLaneId()+"_"+o.getTurnType())).collect(Collectors.toList()); //===============补充某个方向有数据但是不完整的================================================================================//
if (Objects.equals(2, objectType)) {
value = value.stream().sorted(Comparator.comparing(o -> o.getTurnType())).collect(Collectors.toList());
} else if (Objects.equals(3, objectType)) {
value = value.stream().sorted(Comparator.comparing(o -> o.getLaneNo())).collect(Collectors.toList());
}
mapList.put("scopeCode", key); mapList.put("scopeCode", key);
mapList.put("dirName", dirTurnDesc); mapList.put("dirName", dirTurnDesc);
mapList.put("dirType", BaseEnum.SignalDirectionEnum.getCodeByName(dirTurnDesc.substring(0,dirTurnDesc.indexOf("进口"))));
mapList.put("list", value); mapList.put("list", value);
allList.add(mapList); allList.add(mapList);
} }
//====================补充方向上无任何车道数据====================================================================================//
if (Objects.nonNull(scopeList)) {
Map<Integer,List<CrossLaneDataHistPoExtend>> tmpListMap = new TreeMap<>();
for (String scopeName1 : scopeList) {
if (!hasDataScopeList.contains(scopeName1)) {
Pattern pattern = Pattern.compile("\\d+");
Matcher matcher = pattern.matcher(scopeName1);
String dirName = scopeName1.substring(0,scopeName1.indexOf("进口")+2);
String turnDesc = scopeName1.substring(dirName.length());
CrossLaneDataHistPoExtend tmp = new CrossLaneDataHistPoExtend();
tmp.setCrossId(crossId);
tmp.setDirType(BaseEnum.SignalDirectionEnum.getCodeByName(scopeName1.substring(0,scopeName1.indexOf("进口"))));
tmp.setDirTypeName(dirName);
tmp.setTurnTypeName(turnDesc);
if (matcher.find()) {
Integer laneNo = Integer.valueOf(matcher.group());
tmp.setTurnType(TurnConvertEnum.getKeyByDesc(tmp.getTurnTypeName().substring(0,tmp.getTurnTypeName().indexOf(laneNo.toString()))));
} else {
tmp.setTurnType(TurnConvertEnum.getKeyByDesc(tmp.getTurnTypeName()));
}
List<CrossLaneDataHistPoExtend> tmpList = tmpListMap.get(tmp.getDirType());
if (tmpList==null){
tmpList = new ArrayList<>();
}
tmpList.add(tmp);
tmpListMap.put(tmp.getDirType(),tmpList);
}
}
for (Map.Entry<Integer,List<CrossLaneDataHistPoExtend>> tmpEntry : tmpListMap.entrySet()) {
Map<String, Object> mapList = new HashMap<>();
String dirDesc = BaseEnum.SignalDirectionEnum.getNameByCode(tmpEntry.getKey());
mapList.put("scopeCode", null);
mapList.put("isLost", true);
mapList.put("dirName", dirDesc+"进口");
mapList.put("dirType", tmpEntry.getKey());
mapList.put("list", tmpEntry.getValue());
allList.add(mapList);
}
}
//=========================================================================================================================================================//
allList = allList.stream().sorted(Comparator.comparing(o->Integer.valueOf(o.get("dirType").toString()))).collect(Collectors.toList());
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("timeList", sortedSet); jsonObject.put("timeList", sortedSet);
...@@ -612,16 +700,14 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH ...@@ -612,16 +700,14 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH
list = list.stream().sorted(Comparator.comparing(o -> o.getStartTime())).collect(Collectors.toList()); list = list.stream().sorted(Comparator.comparing(o -> o.getStartTime())).collect(Collectors.toList());
//按时间分组分组 //按时间分组分组
Map<String, List<CrossLaneDataHistPoExtend>> groupByDir = list.stream().collect(Collectors.groupingBy(o -> o.getCrossId() + "_" + o.getLaneId() + "_" + o.getDirType() + "_" + o.getTurnType(), TreeMap::new, Collectors.toList())); Map<String, List<CrossLaneDataHistPoExtend>> groupByDir = list.stream().collect(Collectors.groupingBy(o -> o.getCrossId() + "_" + o.getLaneNo() + "_" + o.getDirType() + "_" + o.getTurnType(), TreeMap::new, Collectors.toList()));
Set<String> scopeList = new TreeSet<>(); Set<String> scopeList = new TreeSet<>();
for (Map.Entry<String, List<CrossLaneDataHistPoExtend>> entry : groupByDir.entrySet()) { for (Map.Entry<String, List<CrossLaneDataHistPoExtend>> entry : groupByDir.entrySet()) {
String key = entry.getKey(); String key = entry.getKey();
String[] sps = key.split("_"); String[] sps = key.split("_");
String laneNo = sps[1];
String laneId = sps[1];
String laneNo = laneId.substring(laneId.length() - 2);
Integer dirType = Integer.parseInt(sps[2]); Integer dirType = Integer.parseInt(sps[2]);
String dirName = null; String dirName = null;
String turnDesc = null; String turnDesc = null;
...@@ -629,7 +715,6 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH ...@@ -629,7 +715,6 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH
Map<String, Object> mapList = new HashMap<>(); Map<String, Object> mapList = new HashMap<>();
mapList.put("laneId", laneId);
mapList.put("laneNo", laneNo); mapList.put("laneNo", laneNo);
dirName = BaseEnum.SignalDirectionEnum.getNameByCode(dirType); dirName = BaseEnum.SignalDirectionEnum.getNameByCode(dirType);
turnDesc = TurnConvertEnum.getDescByKey(Integer.valueOf(sps[3])); turnDesc = TurnConvertEnum.getDescByKey(Integer.valueOf(sps[3]));
...@@ -679,16 +764,14 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH ...@@ -679,16 +764,14 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH
list = list.stream().sorted(Comparator.comparing(o -> o.getStartTime())).collect(Collectors.toList()); list = list.stream().sorted(Comparator.comparing(o -> o.getStartTime())).collect(Collectors.toList());
//按时间分组分组 //按时间分组分组
Map<String, List<CrossLaneDataHistPoExtend>> groupByDir = list.stream().collect(Collectors.groupingBy(o -> o.getCrossId() + "_" + o.getLaneId() + "_" + o.getDirType() + "_" + o.getTurnType(), TreeMap::new, Collectors.toList())); Map<String, List<CrossLaneDataHistPoExtend>> groupByDir = list.stream().collect(Collectors.groupingBy(o -> o.getCrossId() + "_" + o.getLaneNo() + "_" + o.getDirType() + "_" + o.getTurnType(), TreeMap::new, Collectors.toList()));
Set<String> scopeList = new TreeSet<>(); Set<String> scopeList = new TreeSet<>();
for (Map.Entry<String, List<CrossLaneDataHistPoExtend>> entry : groupByDir.entrySet()) { for (Map.Entry<String, List<CrossLaneDataHistPoExtend>> entry : groupByDir.entrySet()) {
String key = entry.getKey(); String key = entry.getKey();
String[] sps = key.split("_"); String[] sps = key.split("_");
String laneNo = sps[1];
String laneId = sps[1];
String laneNo = laneId.substring(laneId.length() - 2);
Integer dirType = Integer.parseInt(sps[2]); Integer dirType = Integer.parseInt(sps[2]);
String dirName = null; String dirName = null;
String turnDesc = null; String turnDesc = null;
...@@ -696,7 +779,6 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH ...@@ -696,7 +779,6 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH
Map<String, Object> mapList = new HashMap<>(); Map<String, Object> mapList = new HashMap<>();
mapList.put("laneId", laneId);
mapList.put("laneNo", laneNo); mapList.put("laneNo", laneNo);
if (objectType == 1) { if (objectType == 1) {
dirName = BaseEnum.SignalDirectionEnum.getNameByCode(dirType); dirName = BaseEnum.SignalDirectionEnum.getNameByCode(dirType);
...@@ -711,6 +793,7 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH ...@@ -711,6 +793,7 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH
//补充缺少时段数据,保留时段字段默认值 //补充缺少时段数据,保留时段字段默认值
List<CrossLaneDataHistPoExtend> value = this.processData(entry, groupType, sortedSet, startTime); List<CrossLaneDataHistPoExtend> value = this.processData(entry, groupType, sortedSet, startTime);
mapList.put("scopeCode", key); mapList.put("scopeCode", key);
mapList.put("scopeName", dirTurnDesc); mapList.put("scopeName", dirTurnDesc);
mapList.put("list", value); mapList.put("list", value);
...@@ -740,15 +823,15 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH ...@@ -740,15 +823,15 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH
String serviceLevelList = value.get(0).getServiceLevel(); String serviceLevelList = value.get(0).getServiceLevel();
StringBuilder serviceLevelBuf = new StringBuilder(); StringBuilder serviceLevelBuf = new StringBuilder();
if (serviceLevelList != null) { if (serviceLevelList != null) {
Map<String,Long> serviceGroup = Arrays.stream(serviceLevelList.split(",")).collect(Collectors.groupingBy(String::valueOf,Collectors.counting())); Map<String, Long> serviceGroup = Arrays.stream(serviceLevelList.split(",")).collect(Collectors.groupingBy(String::valueOf, Collectors.counting()));
double total = 0; double total = 0;
for (Map.Entry<String, Long> entry1 : serviceGroup.entrySet()) { for (Map.Entry<String, Long> entry1 : serviceGroup.entrySet()) {
String key = entry1.getKey(); String key = entry1.getKey();
total += ServiceLevelEnum.getByType(key).getVal() * entry1.getValue(); total += ServiceLevelEnum.getByType(key).getVal() * entry1.getValue();
} }
//服务水平加权平均计算:给服务水平(等级得分*该等级的数量)累加/总数量 //服务水平加权平均计算:给服务水平(等级得分*该等级的数量)累加/总数量
int avgService = (int) Math.round(total/value.size()); int avgService = (int) Math.round(total / value.size());
String avgServiceLevel = ServiceLevelEnum.getByVal(avgService)==null?"A":ServiceLevelEnum.getByVal(avgService).getType(); String avgServiceLevel = ServiceLevelEnum.getByVal(avgService) == null ? "A" : ServiceLevelEnum.getByVal(avgService).getType();
serviceLevelBuf.append(avgServiceLevel); serviceLevelBuf.append(avgServiceLevel);
} }
...@@ -782,7 +865,6 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH ...@@ -782,7 +865,6 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH
value = value.stream().sorted(Comparator.comparing(CrossLaneDataHistPoExtend::getStartTime)).collect(Collectors.toList()); value = value.stream().sorted(Comparator.comparing(CrossLaneDataHistPoExtend::getStartTime)).collect(Collectors.toList());
//==========================================================================================================// //==========================================================================================================//
//时间轴 //时间轴
value.forEach(o -> { value.forEach(o -> {
......
...@@ -249,7 +249,7 @@ ...@@ -249,7 +249,7 @@
resultType="net.wanji.opt.po.base.CrossLaneDataHistPoExtend"> resultType="net.wanji.opt.po.base.CrossLaneDataHistPoExtend">
SELECT MIN(ifnull(t.unit_time,#{startDate})) start_time, SELECT MIN(ifnull(t.unit_time,#{startDate})) start_time,
cross_id , cross_id ,
lane_id , lane_no ,
dir_type , dir_type ,
turn_type , turn_type ,
SUM(flow) flow, SUM(flow) flow,
...@@ -278,7 +278,7 @@ ...@@ -278,7 +278,7 @@
<!-- 方向级 --> <!-- 方向级 -->
<when test="objectType==1"> <when test="objectType==1">
dir_type, dir_type,
null as lane_id, null as lane_no,
null as turn_type, null as turn_type,
null as service_level, null as service_level,
</when> </when>
...@@ -286,19 +286,19 @@ ...@@ -286,19 +286,19 @@
<when test="objectType==2"> <when test="objectType==2">
t.in_dir+1 as dir_type, t.in_dir+1 as dir_type,
t.turn_type, t.turn_type,
null as lane_id, null as lane_no,
null as service_level, null as service_level,
</when> </when>
<!-- 车道级 --> <!-- 车道级 -->
<when test="objectType==3"> <when test="objectType==3">
t.id as lane_id, t2.sort as lane_no,
t2.dir as dir_type, t2.dir as dir_type,
t2.turn as turn_type, t2.turn as turn_type,
null as service_level, null as service_level,
</when> </when>
<!-- 路口级 --> <!-- 路口级 -->
<when test="objectType==4"> <when test="objectType==4">
null as lane_id, null as lane_no,
null as dir_type, null as dir_type,
null as turn_type, null as turn_type,
ifnull(service_level,'A') service_level, ifnull(service_level,'A') service_level,
...@@ -352,7 +352,7 @@ ...@@ -352,7 +352,7 @@
</when> </when>
<!-- 车道级 --> <!-- 车道级 -->
<when test="objectType==3"> <when test="objectType==3">
GROUP BY t.cross_id,t.lane_id,t.dir_type,t.turn_type,unit_time GROUP BY t.cross_id,t.lane_no,t.dir_type,t.turn_type,unit_time
</when> </when>
<!-- 路口级 --> <!-- 路口级 -->
<when test="objectType==4"> <when test="objectType==4">
......
...@@ -2,6 +2,19 @@ ...@@ -2,6 +2,19 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="net.wanji.opt.dao.mapper.HoloEventMapper"> <mapper namespace="net.wanji.opt.dao.mapper.HoloEventMapper">
<resultMap id="eventAlarm" type="net.wanji.opt.entity.EventAlarmInfo">
<id column="green_id" property="greenId" />
<result column="cross_id" property="crossId"/>
<result column="cross_name" property="crossName" />
<result column="current_algo" property="currentAlgo"/>
<result column="issue_time" property="issueTime" />
<result column="type" property="type"/>
<result column="opt_status" property="optStatus"/>
<result column="new_recoder" property="newRecoder" />
<result column="wkt" property="wkt" />
</resultMap>
<select id="selectCrossEmergencyCount" resultType="java.lang.Integer"> <select id="selectCrossEmergencyCount" resultType="java.lang.Integer">
SELECT COUNT(*) SELECT COUNT(*)
FROM t_event_info FROM t_event_info
...@@ -108,5 +121,69 @@ ...@@ -108,5 +121,69 @@
</select> </select>
<select id="findEventAlarmInfo" parameterType="String" resultMap="eventAlarm">
<!-- 已结束的排在后面,未结束的排在前面 -->
select d.green_id ,d.cross_id , d.cross_name ,d.issue_time ,d.current_algo ,d.wkt , d.type,d.new_recoder , d.opt_status from
(
( <!-- 查询未结束事件b.alarm_status in (0,1,2) -->
select b.green_id ,b.cross_id , b.cross_name , DATE_FORMAT(b.issue_time,'%H:%i') as issue_time ,b.current_algo ,b.wkt ,
case b.alarm_status when 0 then '未处理' when 1 then '分析中' when 2 then '优化中' end as type, b.opt_status,
case when b.issue_time > DATE_SUB(NOW(), INTERVAL 1 MINUTE) then '1' else '0' end as new_recoder, 1 as type2,b.event_type
from
(
<!-- 查询路口事件 -->
select a.type as event_type,a.green_id,a.cross_id,c.name as cross_name , a.start_time as issue_time, b.label as current_algo, SUBSTRING(c.location FROM 7 FOR 20) as wkt,a.alarm_status,a.opt_status
from t_event_info a
left join (select a.event_type, a.label from t_config_event_category a where a.category = 4) b on a.type = b.event_type
left join t_base_cross_info c on a.cross_id = c.id
where a.type in (701,702,703,707) and DATE(a.start_time) = CURDATE()
union
<!-- 查询干线事件 -->
select a.type as event_type,a.green_id,a.cross_id,c.name as cross_name , a.start_time as issue_time, b.label as current_algo, c.wkt,a.alarm_status,a.opt_status
from t_event_info a
left join (select a.event_type, a.label from t_config_event_category a where a.category = 4) b on a.type = b.event_type
left join t_greenwave_info c on a.green_id = c.id
where a.type in (705,706) and DATE(a.start_time) = CURDATE()
) b where b.alarm_status in (0,1,2)
order by b.issue_time desc
)
union
( <!-- 查询事件结束b.alarm_status in (3,4) -->
select b.green_id ,b.cross_id , b.cross_name , b.issue_time ,b.current_algo ,b.wkt ,
'已结束' as type, b.opt_status,'0' as new_recoder, 2 as type2,b.event_type
from
( <!-- 查询路口空放、失衡、溢出、拥堵事件 -->
select a.type as event_type,a.green_id,a.cross_id,c.name as cross_name , DATE_FORMAT(a.start_time,'%H:%i') as issue_time, b.label as current_algo, SUBSTRING(c.location FROM 7 FOR 20) as wkt,
a.alarm_status ,a.opt_status
from t_event_info a
left join (select a.event_type, a.label from t_config_event_category a where a.category = 4) b on a.type = b.event_type
left join t_base_cross_info c on a.cross_id = c.id
where a.type in (701,702,703,707) and DATE(a.start_time) = CURDATE()
union
<!-- 查询干线事件缓行、拥堵事件 -->
select a.type as event_type,a.green_id,a.cross_id,c.name as cross_name , DATE_FORMAT(a.start_time,'%H:%i') as issue_time, b.label as current_algo, c.wkt,a.alarm_status ,a.opt_status
from t_event_info a
left join (select a.event_type, a.label from t_config_event_category a where a.category = 4 ) b on a.type = b.event_type
left join t_greenwave_info c on a.green_id = c.id
where a.type in (705,706) and DATE(a.start_time) = CURDATE()
) b
where b.alarm_status in (3,4)
order by b.issue_time desc
)
ORDER BY type2,issue_time desc
) d
where 1=1
<if test= "name != null and name != '' ">
and instr(d.cross_name,#{name})>0
</if>
<if test= "eventType != null and eventType != '' ">
and d.event_type = #{eventType}
</if>
<if test="timeScope != null and timeScope != '' ">
LIMIT 30
</if>
</select>
</mapper> </mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment