Commit dfc2871f authored by wang yecheng's avatar wang yecheng

Merge remote-tracking branch 'origin/master'

parents ea77f8d1 1f47e5e7
...@@ -57,6 +57,36 @@ public class EsDateIndexUtil { ...@@ -57,6 +57,36 @@ public class EsDateIndexUtil {
return sortedSet; return sortedSet;
} }
/**
* 获取时段范围内不同时间粒度的时间轴
* @param groupType 0:5分钟 1:15分钟 2:30分钟 3:1小时 4:天粒度 5:10分钟
* @param startTime 开始时间
* @param endTime 截止时间
* @return
*/
public static List<String> getTimeGranularityAxisAll(String groupType,String startTime, String endTime) {
//存放时段
List<String> sortedSet = new ArrayList<>();
//===========================根据开始、结束时间输出完整时刻点=================================================//
DateTime start = DateTime.parse(startTime, DateTimeFormat.forPattern(EsDateIndexUtil.YMD_HM_FORMATTER));
DateTime end = DateTime.parse(endTime, DateTimeFormat.forPattern(EsDateIndexUtil.YMD_HM_FORMATTER));
if (Objects.equals("0", groupType)) {
sortedSet.addAll(EsDateIndexUtil.getTimeScopeList(start, end, TimeGranularityEnum.FIVE_MINUTE, "yyyy-MM-dd HH:mm:00"));
} else if (Objects.equals("1", groupType)) {
sortedSet.addAll(EsDateIndexUtil.getTimeScopeList(start, end, TimeGranularityEnum.FIFTEEN_MINUTE, "yyyy-MM-dd HH:mm:00"));
} else if (Objects.equals("2", groupType)) {
sortedSet.addAll(EsDateIndexUtil.getTimeScopeList(start, end, TimeGranularityEnum.THIRTY_MINUTE, "yyyy-MM-dd HH:mm:00"));
} else if (Objects.equals("3", groupType)) {
sortedSet.addAll(EsDateIndexUtil.getTimeScopeList(start, end, TimeGranularityEnum.ONE_HOUR, "yyyy-MM-dd HH:00:00"));
} else if (Objects.equals("4", groupType)) {
sortedSet.addAll(EsDateIndexUtil.getTimeScopeList(start, end, TimeGranularityEnum.ONE_DAY, EsDateIndexUtil.YMD_FORMATTER));
} else if (Objects.equals("5", groupType)) {
sortedSet.addAll(EsDateIndexUtil.getTimeScopeList(start, end, TimeGranularityEnum.TEN_MINUTE, "yyyy-MM-dd HH:mm:00"));
}
return sortedSet;
}
/** /**
* 根据开始结束时间获取不同时间粒度的时刻点 * 根据开始结束时间获取不同时间粒度的时刻点
* *
......
package net.wanji.opt.controllerv2; package net.wanji.opt.controllerv2;
import cn.hutool.core.date.DateUtil;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
...@@ -30,6 +31,16 @@ public class TrendControllerV2 { ...@@ -30,6 +31,16 @@ public class TrendControllerV2 {
@Resource @Resource
private TrendServiceV2 trendServiceV2; private TrendServiceV2 trendServiceV2;
@ApiOperation(value = "通用接口获取服务器时间", notes = "通用接口获取服务器时间", response = JsonViewObject.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@GetMapping(value = "/getNow")
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = String.class),
})
public String getNow() {
return DateUtil.now();
}
@ApiOperation(value = "态势监测-区域体检-雷达图", notes = "态势监测-区域体检-雷达图", response = JsonViewObject.class, @ApiOperation(value = "态势监测-区域体检-雷达图", notes = "态势监测-区域体检-雷达图", response = JsonViewObject.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON) produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@GetMapping(value = "/crossGreenStatusTimeRate") @GetMapping(value = "/crossGreenStatusTimeRate")
...@@ -229,10 +240,10 @@ public class TrendControllerV2 { ...@@ -229,10 +240,10 @@ public class TrendControllerV2 {
@ApiResponses({ @ApiResponses({
@ApiResponse(code = 200, message = "OK", response = OptMonitoringVO.class), @ApiResponse(code = 200, message = "OK", response = OptMonitoringVO.class),
}) })
public JsonViewObject optStrategyResultInfo(String id) throws Exception { public JsonViewObject optStrategyResultInfo(String id, String date) throws Exception {
String result = "畅通-专家方案"; String result = "均衡调控-专家方案";
try { try {
result = trendServiceV2.optStrategyResultInfo(id); result = trendServiceV2.optStrategyResultInfo(id, date);
} catch (Exception e) { } catch (Exception e) {
log.error("态势监测-策略推荐-优化策略:", e); log.error("态势监测-策略推荐-优化策略:", e);
JsonViewObject.newInstance().success(result); JsonViewObject.newInstance().success(result);
......
package net.wanji.opt.controllerv2.judgeanalysis; package net.wanji.opt.controllerv2.judgeanalysis;
import io.swagger.annotations.Api; import io.swagger.annotations.*;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.wanji.common.framework.i18n.I18nResourceBundle; import net.wanji.common.framework.i18n.I18nResourceBundle;
import net.wanji.common.framework.rest.JsonViewObject; import net.wanji.common.framework.rest.JsonViewObject;
...@@ -16,11 +11,12 @@ import net.wanji.opt.controllerv2.judgeanalysis.design.response.crossproblem.Cro ...@@ -16,11 +11,12 @@ import net.wanji.opt.controllerv2.judgeanalysis.design.response.crossproblem.Cro
import net.wanji.opt.controllerv2.judgeanalysis.design.response.crossproblem.CrossProblemTimeDirReasonResult; import net.wanji.opt.controllerv2.judgeanalysis.design.response.crossproblem.CrossProblemTimeDirReasonResult;
import net.wanji.opt.entity.judgeanalysis.AnalysisProblemCrossDay; import net.wanji.opt.entity.judgeanalysis.AnalysisProblemCrossDay;
import net.wanji.opt.servicev2.judgeanalysis.AnalysisProblemCrossDayService; import net.wanji.opt.servicev2.judgeanalysis.AnalysisProblemCrossDayService;
import org.springframework.beans.factory.annotation.Autowired; import net.wanji.opt.vo2.CrossOptAnalysisVO;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -38,15 +34,9 @@ import java.util.Map; ...@@ -38,15 +34,9 @@ import java.util.Map;
@RequestMapping("/analysis-problem-cross-day") @RequestMapping("/analysis-problem-cross-day")
@Slf4j @Slf4j
public class AnalysisProblemCrossDayController { public class AnalysisProblemCrossDayController {
@Resource
@Autowired
private AnalysisProblemCrossDayService analysisProblemCrossDayService; private AnalysisProblemCrossDayService analysisProblemCrossDayService;
@ApiOperation(value = "单路口-问题数量总览", response = JsonViewObject.class, @ApiOperation(value = "单路口-问题数量总览", response = JsonViewObject.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON) produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@ApiImplicitParams({ @ApiImplicitParams({
...@@ -133,5 +123,26 @@ public class AnalysisProblemCrossDayController { ...@@ -133,5 +123,26 @@ public class AnalysisProblemCrossDayController {
return JsonViewObject.newInstance().success(null); return JsonViewObject.newInstance().success(null);
} }
@ApiOperation(value = "路口报警优化分析", notes = "路口报警优化分析", httpMethod = "GET")
@ApiImplicitParams({
@ApiImplicitParam(name = "crossID", value = "路口ID", required = true, dataType = "String"),
@ApiImplicitParam(name = "date", value = "日期 日期格式yyyy-MM-dd 如2025-03-20", required = true, dataType = "String"),
})
@GetMapping(value = "/getCrossOptAnalysis")
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = CrossOptAnalysisVO.class),
})
public JsonViewObject getCrossOptAnalysis(String crossID, String date) {
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
try {
CrossOptAnalysisVO info = analysisProblemCrossDayService.getCrossOptAnalysis(crossID, date);
return jsonViewObject.success(info);
} catch (Exception e) {
log.error("获取路口优化分析失败", e);
return jsonViewObject.fail("获取路口优化分析失败");
}
}
} }
\ No newline at end of file
package net.wanji.opt.dao.mapper.judgeanalysis;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import net.wanji.opt.entity.judgeanalysis.AnalysisProblemAndStrategyDay;
import net.wanji.opt.entity.judgeanalysis.AnalysisProblemCrossDay;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
public interface AnalysisProblemAndStrategyDayMapper extends BaseMapper<AnalysisProblemAndStrategyDay> {
List<AnalysisProblemAndStrategyDay> selectCrossEvent();
List<AnalysisProblemAndStrategyDay> selectGreenEvent();
Integer insertProblemAndStrategy(AnalysisProblemAndStrategyDay analysisProblemAndStrategyDay);
AnalysisProblemAndStrategyDay getGreenStrategy(@Param("greenID") String greenID, @Param("time") String time);
AnalysisProblemAndStrategyDay getCrossStrategy(@Param("crossID") String crossID, @Param("time") String time);
}
package net.wanji.opt.dao.mapper.judgeanalysis; package net.wanji.opt.dao.mapper.judgeanalysis;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import net.wanji.opt.entity.judgeanalysis.AnalysisProblemCrossDay; import net.wanji.opt.entity.judgeanalysis.AnalysisProblemCrossDay;
import net.wanji.opt.entity.judgeanalysis.CrossPoint;
import net.wanji.opt.synthesis.pojo.CrossOptAnalysisEntity;
import org.apache.ibatis.annotations.Param;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import net.wanji.opt.entity.judgeanalysis.CrossPoint;
import org.apache.ibatis.annotations.Param;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
public interface AnalysisProblemCrossDayMapper extends BaseMapper<AnalysisProblemCrossDay>{ public interface AnalysisProblemCrossDayMapper extends BaseMapper<AnalysisProblemCrossDay>{
/** /**
...@@ -108,6 +107,9 @@ public interface AnalysisProblemCrossDayMapper extends BaseMapper<AnalysisProble ...@@ -108,6 +107,9 @@ public interface AnalysisProblemCrossDayMapper extends BaseMapper<AnalysisProble
List<AnalysisProblemCrossDay> selectSingerByProblemTrend(Map<String, Object> map); List<AnalysisProblemCrossDay> selectSingerByProblemTrend(Map<String, Object> map);
/**
* 获取路口优化数据
*/
List<CrossOptAnalysisEntity> getCrossOptAnalysis(@Param("crossID") String crossID, @Param("date") String date);
} }
...@@ -9,6 +9,9 @@ import lombok.experimental.Accessors; ...@@ -9,6 +9,9 @@ import lombok.experimental.Accessors;
import net.wanji.common.framework.domain.TrackableEntity; import net.wanji.common.framework.domain.TrackableEntity;
import java.util.Date; import java.util.Date;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
/** /**
* <p> * <p>
...@@ -21,7 +24,6 @@ import java.math.BigDecimal; ...@@ -21,7 +24,6 @@ import java.math.BigDecimal;
@Data @Data
@ApiModel(value="EventInfo对象", description="交通事件信息") @ApiModel(value="EventInfo对象", description="交通事件信息")
public class EventInfo extends TrackableEntity { public class EventInfo extends TrackableEntity {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键ID") @ApiModelProperty(value = "主键ID")
......
package net.wanji.opt.entity.judgeanalysis;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("t_event_optimize_info")
public class AnalysisProblemAndStrategyDay implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 路口ID
*/
private String crossId;
/**
* 事件序列号作为主键
*/
private String eventSerialNumber;
/**
* 事件一级类别 1:机动车事件 2:非机动车事件 3:行人事件 4:路口事件
*/
private String eventCategory;
/**
* 二级类别
*/
private String eventType;
/**
* 事件发生开始时间
*/
private String happenStartTime;
/**
* 事件发生结束时间
*/
private String happenEndTime;
/**
* 事件持续时长,单位秒
*/
private String duration;
/**
* 优化状态 0 未优化 1-优化过
*/
private int optStatus;
/**
* 方向 1北...8西北
*/
private String dir;
/**
* 事件优化开始时间
*/
private String optStartTime;
/**
* 事件优化结束时间
*/
private String optEndTime;
/**
* 优化时长,单位秒
*/
private String optDuration;
/**
* 格式:yyyyMMdd
*/
private String dt;
/**
* 数据插入时间
*/
private String insertTime;
/**
* 干线id
*/
private String greenId;
}
...@@ -6,6 +6,7 @@ import io.swagger.models.auth.In; ...@@ -6,6 +6,7 @@ import io.swagger.models.auth.In;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.wanji.common.enums.BaseEnum; import net.wanji.common.enums.BaseEnum;
import net.wanji.common.enums.TurnConvertEnum; import net.wanji.common.enums.TurnConvertEnum;
import net.wanji.common.framework.Constants;
import net.wanji.common.framework.dubbointerface.impl.BaseDubboInterfaceImpl; import net.wanji.common.framework.dubbointerface.impl.BaseDubboInterfaceImpl;
import net.wanji.common.framework.exception.DubboProviderException; import net.wanji.common.framework.exception.DubboProviderException;
import net.wanji.common.framework.mapper.BaseInterfaceMapper; import net.wanji.common.framework.mapper.BaseInterfaceMapper;
...@@ -44,6 +45,7 @@ import java.math.BigDecimal; ...@@ -44,6 +45,7 @@ import java.math.BigDecimal;
import java.text.ParseException; import java.text.ParseException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator; import java.util.Comparator;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
...@@ -417,7 +419,7 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH ...@@ -417,7 +419,7 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH
params.put("dir", BaseEnum.SignalDirectionEnum.getCodeByName(directionName.substring(0, directionName.indexOf("进口")))); params.put("dir", BaseEnum.SignalDirectionEnum.getCodeByName(directionName.substring(0, directionName.indexOf("进口"))));
} }
//存放时段 //存放时段
Set<String> sortedSet = EsDateIndexUtil.getTimeGranularityAxis(groupType, startTime, endTime); List<String> sortedSet = EsDateIndexUtil.getTimeGranularityAxisAll(groupType, startTime, endTime);
//======================================================================================================// //======================================================================================================//
//存放所有数据 //存放所有数据
List<Map<String, Object>> allList = new ArrayList<>(); List<Map<String, Object>> allList = new ArrayList<>();
...@@ -534,19 +536,17 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH ...@@ -534,19 +536,17 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH
if (params.get("dir") != null) { if (params.get("dir") != null) {
allList = allList.stream().filter(o -> Objects.equals(params.get("dir").toString(), o.get("dirType").toString())).collect(Collectors.toList()); allList = allList.stream().filter(o -> Objects.equals(params.get("dir").toString(), o.get("dirType").toString())).collect(Collectors.toList());
} }
List<String> timeList = this.getTimeAxisList(groupType,sortedSet);
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("timeList", sortedSet); jsonObject.put("timeList", timeList);
jsonObject.put("dateTimeList", sortedSet);
jsonObject.put("dataList", allList); jsonObject.put("dataList", allList);
jsonObject.put("scopeList", scopeList); jsonObject.put("scopeList", scopeList);
return jsonObject; return jsonObject;
} }
public static void main(String[] args) {
DateTime dateTime = new DateTime(new Date());
System.out.println(dateTime.hourOfDay().get());
}
private void mockData(List<CrossLaneDataHistPoExtend> list) { private void mockData(List<CrossLaneDataHistPoExtend> list) {
if (mockFlag) { if (mockFlag) {
int maxFlow = list.stream().filter(o -> Objects.nonNull(o.getFlow())).mapToInt(CrossLaneDataHistPoExtend::getFlow).max().orElse(0); int maxFlow = list.stream().filter(o -> Objects.nonNull(o.getFlow())).mapToInt(CrossLaneDataHistPoExtend::getFlow).max().orElse(0);
...@@ -893,7 +893,7 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH ...@@ -893,7 +893,7 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH
* @param sortedSet * @param sortedSet
* @param startTime * @param startTime
*/ */
private List<CrossLaneDataHistPoExtend> processData(Map.Entry<String, List<CrossLaneDataHistPoExtend>> entry, String groupType, Set<String> sortedSet, String startTime) { private List<CrossLaneDataHistPoExtend> processData(Map.Entry<String, List<CrossLaneDataHistPoExtend>> entry, String groupType, Collection<String> sortedSet, String startTime) {
//按方向排序 //按方向排序
List<CrossLaneDataHistPoExtend> value = entry.getValue().stream().sorted(Comparator.comparing(o -> o.getStartTime())).collect(Collectors.toList()); List<CrossLaneDataHistPoExtend> value = entry.getValue().stream().sorted(Comparator.comparing(o -> o.getStartTime())).collect(Collectors.toList());
...@@ -904,10 +904,10 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH ...@@ -904,10 +904,10 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH
timeList.addAll(value.stream().map(po -> DateUtil.formatDate(po.getStartTime(), EsDateIndexUtil.YMD_FORMATTER)).collect(Collectors.toSet())); timeList.addAll(value.stream().map(po -> DateUtil.formatDate(po.getStartTime(), EsDateIndexUtil.YMD_FORMATTER)).collect(Collectors.toSet()));
} else if (Objects.equals("3", groupType)) { } else if (Objects.equals("3", groupType)) {
//小时粒度 //小时粒度
timeList.addAll(value.stream().map(po -> DateUtil.formatDate(po.getStartTime(), EsDateIndexUtil.H_FORMATTER)).collect(Collectors.toSet())); timeList.addAll(value.stream().map(po -> DateUtil.formatDate(po.getStartTime(), "yyyy-MM-dd HH:00:00")).collect(Collectors.toSet()));
} else { } else {
//小时分钟粒度 //小时分钟粒度
timeList.addAll(value.stream().map(po -> DateUtil.formatDate(po.getStartTime(), EsDateIndexUtil.HM_FORMATTER)).collect(Collectors.toSet())); timeList.addAll(value.stream().map(po -> DateUtil.formatDate(po.getStartTime(), "yyyy-MM-dd HH:mm:00")).collect(Collectors.toSet()));
} }
//补充缺少时段数据,保留时段字段默认值 //补充缺少时段数据,保留时段字段默认值
for (String timeSec : sortedSet) { for (String timeSec : sortedSet) {
...@@ -917,11 +917,11 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH ...@@ -917,11 +917,11 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH
tmp.setTurnType(value.get(0).getTurnType()); tmp.setTurnType(value.get(0).getTurnType());
tmp.setDirType(value.get(0).getDirType()); tmp.setDirType(value.get(0).getDirType());
tmp.setTimeAxis(timeSec); tmp.setTimeAxis(timeSec);
String parseTime = startTime.substring(0, startTime.lastIndexOf(" ") + 1) + timeSec; // String parseTime = startTime.substring(0, startTime.lastIndexOf(" ") + 1) + timeSec;
if (Objects.equals("4", groupType)) { if (Objects.equals("4", groupType)) {
tmp.setStartTime(DateTime.parse(timeSec, DateTimeFormat.forPattern(EsDateIndexUtil.YMD_FORMATTER)).toDate()); tmp.setStartTime(DateTime.parse(timeSec, DateTimeFormat.forPattern(EsDateIndexUtil.YMD_FORMATTER)).toDate());
} else { } else {
tmp.setStartTime(DateTime.parse(parseTime, DateTimeFormat.forPattern("yyyy-MM-dd HH:mm")).toDate()); tmp.setStartTime(DateTime.parse(startTime, DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:00")).toDate());
} }
value.add(tmp); value.add(tmp);
} }
...@@ -943,5 +943,16 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH ...@@ -943,5 +943,16 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH
return value; return value;
} }
private List<String> getTimeAxisList(String groupType,List<String> timeList) {
//存放时段
List<String> formatTimeList = new ArrayList<>();
if (Objects.equals("4", groupType)) {
//天粒度
formatTimeList.addAll(timeList);
} else {
//小时分钟粒度
formatTimeList.addAll(timeList.stream().map(dt -> dt.substring(dt.indexOf(" "),dt.lastIndexOf(":"))).collect(Collectors.toList()));
}
return formatTimeList;
}
} }
...@@ -29,7 +29,7 @@ public interface TrendServiceV2 { ...@@ -29,7 +29,7 @@ public interface TrendServiceV2 {
PageInfo<StatisticsEventTypeCountTimeVO> selectCrossGreenHistList(int pageNo, int pageSize) throws Exception; PageInfo<StatisticsEventTypeCountTimeVO> selectCrossGreenHistList(int pageNo, int pageSize) throws Exception;
String optStrategyResultInfo(String id) throws Exception; String optStrategyResultInfo(String id, String date) throws Exception;
GreenOptCrossOffsetVO optStrategyCrossOffsetList(Integer id, String date) throws Exception; GreenOptCrossOffsetVO optStrategyCrossOffsetList(Integer id, String date) throws Exception;
......
...@@ -354,43 +354,50 @@ public class TrendServiceV2Impl implements TrendServiceV2 { ...@@ -354,43 +354,50 @@ public class TrendServiceV2Impl implements TrendServiceV2 {
} }
@Override @Override
public String optStrategyResultInfo(String id) throws Exception { public String optStrategyResultInfo(String id, String dateStr) throws Exception {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
String result = ""; String result = "";
Date date = new Date();
if (!StringUtils.isEmpty(dateStr)) {
date = DateUtil.parse(dateStr, Constants.DATE_FORMAT.E_DATE_FORMAT_SECOND);
}
if (net.wanji.common.utils.tool.StringUtils.isNotBlank(id)) { if (net.wanji.common.utils.tool.StringUtils.isNotBlank(id)) {
if (id.length() > 1) { if (id.length() > 1) {
result = getOptCrossResult(id, sb); result = getOptCrossResult(id, sb, date);
} else { } else {
result = getOptGreenResult(id, sb); result = getOptGreenResult(id, sb, date);
} }
} }
return result; return result;
} }
private String getOptGreenResult(String id, StringBuilder sb) { private String getOptGreenResult(String id, StringBuilder sb, Date date) throws Exception {
String result = ""; String result = "";
List<GreenLastOptResultDTO> greenLastOptResultDTOS = strategyGreenOptHistMapper.selectLastGreenOptResultList(); LambdaQueryWrapper<StrategyGreenOptHistEntity> queryWrapper = new LambdaQueryWrapper<>();
if (!CollectionUtils.isEmpty(greenLastOptResultDTOS)) { queryWrapper.eq(StrategyGreenOptHistEntity::getGreenId, id);
for (GreenLastOptResultDTO dto : greenLastOptResultDTOS) { queryWrapper.le(StrategyGreenOptHistEntity::getControlTime, date);
if (StringUtils.endsWithIgnoreCase(id, String.valueOf(dto.getGreenId()))) { queryWrapper.eq(StrategyGreenOptHistEntity::getControlMethod, 1);
Integer controlMethod = dto.getControlMethod(); queryWrapper.orderByDesc(StrategyGreenOptHistEntity::getControlTime);
if (controlMethod >= 0) { queryWrapper.last("limit 1");
sb.append("动态绿波").append("-").append("均衡调控").append("-").append("神思策略"); List<StrategyGreenOptHistEntity> entities = strategyGreenOptHistMapper.selectList(queryWrapper);
} else { StrategyGreenOptHistEntity entity = entities.get(0);
sb.append("均衡调控").append("-").append("专家方案"); String controlTime = entity.getControlTime();
} // 如果最新一条在半小时内,取绿波优化数据
} Date parse = DateUtil.parse(controlTime, Constants.DATE_FORMAT.E_DATE_FORMAT_SECOND);
} long controlOptTime = parse.getTime();
if (date.getTime() - controlOptTime < 30 * 60 * 1000) {
sb.append("动态绿波").append("-").append("均衡调控").append("-").append("神思策略");
} else { } else {
sb.append("动态绿波-专家方案"); sb.append("均衡调控").append("-").append("专家方案");
} }
result = sb.toString(); result = sb.toString();
return result; return result;
} }
private String getOptCrossResult(String id, StringBuilder sb) { private String getOptCrossResult(String id, StringBuilder sb, Date date) {
LambdaQueryWrapper<StrategyCrossResultEntity> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<StrategyCrossResultEntity> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(StrategyCrossResultEntity::getCrossId, id); queryWrapper.eq(StrategyCrossResultEntity::getCrossId, id);
queryWrapper.le(StrategyCrossResultEntity::getIssueTime, date);
queryWrapper.orderByDesc(StrategyCrossResultEntity::getIssueTime); queryWrapper.orderByDesc(StrategyCrossResultEntity::getIssueTime);
queryWrapper.last("limit 1"); queryWrapper.last("limit 1");
List<StrategyCrossResultEntity> results = strategyCrossResultMapper.selectList(queryWrapper); List<StrategyCrossResultEntity> results = strategyCrossResultMapper.selectList(queryWrapper);
......
...@@ -7,7 +7,6 @@ import net.wanji.opt.synthesis.pojo.CrossRealTimeAlarmEntity; ...@@ -7,7 +7,6 @@ import net.wanji.opt.synthesis.pojo.CrossRealTimeAlarmEntity;
import net.wanji.opt.synthesis.pojo.TrunkLineCrossProblemEntity; import net.wanji.opt.synthesis.pojo.TrunkLineCrossProblemEntity;
import net.wanji.opt.synthesis.pojo.TrunkLineProblemDescribeEntity; import net.wanji.opt.synthesis.pojo.TrunkLineProblemDescribeEntity;
import net.wanji.opt.synthesis.pojo.vo.CrossOrGreenWaveTypeEntity; import net.wanji.opt.synthesis.pojo.vo.CrossOrGreenWaveTypeEntity;
import net.wanji.opt.vo2.CrossRealTimeAlarmVO;
import net.wanji.opt.vo2.TrunkLineCrossProblemVO; import net.wanji.opt.vo2.TrunkLineCrossProblemVO;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -144,7 +143,7 @@ public class TrunkLineImpl implements TrunkLineService { ...@@ -144,7 +143,7 @@ public class TrunkLineImpl implements TrunkLineService {
* @param status 状态 * @param status 状态
* @return 方向状态数组[方向1, 状态1, 方向2, 状态2] * @return 方向状态数组[方向1, 状态1, 方向2, 状态2]
*/ */
public String[] getDirStatus(Integer inDir, Integer outDir, String[] dirs, Integer status) { private String[] getDirStatus(Integer inDir, Integer outDir, String[] dirs, Integer status) {
Map<String, String> IODirMap = getDirName(inDir, outDir); Map<String, String> IODirMap = getDirName(inDir, outDir);
String[] result = new String[4]; String[] result = new String[4];
......
package net.wanji.opt.servicev2.judgeanalysis;
public interface AnalysisProblemAndStrategyDayService {
public void selectCountByType();
}
package net.wanji.opt.servicev2.judgeanalysis; package net.wanji.opt.servicev2.judgeanalysis;
import net.wanji.opt.entity.judgeanalysis.AnalysisProblemCrossDay;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.core.metadata.IPage; import net.wanji.opt.entity.judgeanalysis.AnalysisProblemCrossDay;
import net.wanji.opt.vo2.CrossOptAnalysisVO;
import java.text.ParseException; import java.text.ParseException;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map;
import java.util.Objects;
/** /**
* <p> * <p>
...@@ -69,5 +67,11 @@ public interface AnalysisProblemCrossDayService extends IService<AnalysisProblem ...@@ -69,5 +67,11 @@ public interface AnalysisProblemCrossDayService extends IService<AnalysisProblem
Map<String, Object> selectSingerByProblemTrend(String crossId, Integer startTime, Integer endTime) throws ParseException; Map<String, Object> selectSingerByProblemTrend(String crossId, Integer startTime, Integer endTime) throws ParseException;
/**
* 路口优化信息
*
* @param crossID 路口ID
* @param date 日期
*/
CrossOptAnalysisVO getCrossOptAnalysis(String crossID, String date);
} }
package net.wanji.opt.servicev2.judgeanalysis.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import net.wanji.opt.dao.mapper.judgeanalysis.AnalysisProblemAndStrategyDayMapper;
import net.wanji.opt.entity.judgeanalysis.AnalysisProblemAndStrategyDay;
import net.wanji.opt.servicev2.judgeanalysis.AnalysisProblemAndStrategyDayService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
/**
* <p>
* 事件问题于策略关系实现类
* </p>
*
* @author hwm
* @since 2025-03-20
*/
@Service
public class AnalysisProblemAndStrategyDayImpl extends ServiceImpl<AnalysisProblemAndStrategyDayMapper, AnalysisProblemAndStrategyDay> implements AnalysisProblemAndStrategyDayService {
@Resource
private AnalysisProblemAndStrategyDayMapper analysisProblemAndStrategyDayMapper;
public void selectCountByType() {
//查询路口事件数据
List<AnalysisProblemAndStrategyDay> crossEvenList = analysisProblemAndStrategyDayMapper.selectCrossEvent();
if (crossEvenList.size() > 0) {
//循环查找路口事件数据是否有策略下发
for (AnalysisProblemAndStrategyDay vo : crossEvenList) {
AnalysisProblemAndStrategyDay temp = analysisProblemAndStrategyDayMapper.getCrossStrategy(vo.getCrossId(), vo.getHappenStartTime());
if (temp == null) {
vo.setOptStatus(0);
} else {
vo.setOptStatus(1);
vo.setOptStartTime(temp.getOptStartTime());
vo.setOptEndTime(temp.getOptEndTime());
vo.setOptDuration(temp.getOptDuration());
}
LocalDate previousDay = LocalDate.now().minusDays(1);
String formattedDate = previousDay.format(DateTimeFormatter.ofPattern("yyyyMMdd"));
vo.setDt(formattedDate);
vo.setInsertTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
//写入数据--Error
analysisProblemAndStrategyDayMapper.insertProblemAndStrategy(vo);
}
}
//查询干线事件数据
List<AnalysisProblemAndStrategyDay> greenEvenList = analysisProblemAndStrategyDayMapper.selectGreenEvent();
if (greenEvenList.size() > 0) {
for (AnalysisProblemAndStrategyDay vo : greenEvenList) {
AnalysisProblemAndStrategyDay temp = analysisProblemAndStrategyDayMapper.getGreenStrategy(vo.getGreenId(), vo.getHappenStartTime());
if (temp == null) {
vo.setOptStatus(0);
} else {
vo.setOptStatus(1);
vo.setOptStartTime(temp.getOptStartTime());
vo.setOptEndTime(temp.getOptEndTime());
vo.setOptDuration(temp.getOptDuration());
}
LocalDate previousDay = LocalDate.now().minusDays(1);
String formattedDate = previousDay.format(DateTimeFormatter.ofPattern("yyyyMMdd"));
vo.setDt(formattedDate);
vo.setInsertTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
//写入数据
analysisProblemAndStrategyDayMapper.insertProblemAndStrategy(vo);
}
}
}
}
package net.wanji.opt.synthesis.pojo;
import lombok.Data;
@Data
public class CrossOptAnalysisEntity {
private String status;
private Integer num;
}
package net.wanji.opt.task;
import lombok.extern.slf4j.Slf4j;
import net.wanji.opt.servicev2.judgeanalysis.AnalysisProblemAndStrategyDayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.context.annotation.Profile;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.util.List;
@Component
@Configurable
@EnableScheduling
@Slf4j
@Profile("!dev")
public class AnalysisProblemAndStrategyDayTask {
@Autowired
private AnalysisProblemAndStrategyDayService analysisProblemAndStrategyDayService;
@Scheduled(cron = "0 15 1 * * ?")
public void task(){
analysisProblemAndStrategyDayService.selectCountByType();
}
}
package net.wanji.opt.vo2;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel(value = "CrossOptAnalysisVO", description = "优化分析-路口报警优化分析")
public class CrossOptAnalysisVO {
@ApiModelProperty(value = "优化总数")
private Integer total = 0;
@ApiModelProperty(value = "已优化")
private Integer optimized = 0;
@ApiModelProperty(value = "未优化")
private Integer unoptimized = 0;
}
...@@ -434,9 +434,9 @@ ...@@ -434,9 +434,9 @@
</set> </set>
</sql> </sql>
<select id="getListByStartAndEnd" parameterType="java.util.Map" resultType="map"> <select id="getListByStartAndEnd" parameterType="java.util.Map" resultType="java.util.Map">
SELECT start_time startTime, SELECT DATE_FORMAT(start_time,'%Y-%m-%d %H:%i:%s') startTime,
end_time endTime, DATE_FORMAT(end_time,'%Y-%m-%d %H:%i:%s') endTime,
ABS(TIMESTAMPDIFF( SECOND, start_time, end_time )) AS duration, ABS(TIMESTAMPDIFF( SECOND, start_time, end_time )) AS duration,
info.type, info.type,
c.label as typeName c.label as typeName
......
<?xml version="1.0" encoding="UTF-8"?>
<!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.judgeanalysis.AnalysisProblemAndStrategyDayMapper">
<!-- 通用查询映射结果 -->
<resultMap id="AnalysisProblemAndStrategyDayMap" type="net.wanji.opt.entity.judgeanalysis.AnalysisProblemAndStrategyDay">
<result column="crossId" property="crossId"/>
<result column="eventSerialNumber" property="eventSerialNumber"/>
<result column="eventCategory" property="eventCategory"/>
<result column="eventType" property="eventType"/>
<result column="happenStartTime" property="happenStartTime"/>
<result column="happenEndTime" property="happenEndTime"/>
<result column="duration" property="duration"/>
<result column="optStatus" property="optStatus"/>
<result column="dir" property="dir"/>
<result column="optStartTime" property="optStartTime"/>
<result column="optEndTime" property="optEndTime"/>
<result column="optDuration" property="optDuration"/>
<result column="dt" property="dt"/>
<result column="insertTime" property="insertTime"/>
<result column="greenId" property="greenId"/>
</resultMap>
<select id="selectCrossEvent" resultMap="AnalysisProblemAndStrategyDayMap">
select a.event_serial_number as eventSerialNumber , a.cross_id as crossId ,a.green_id as greenId,
a.category as eventCategory,a.type as eventType ,a.start_time as happenStartTime ,a.end_time as happenEndTime,
TIMESTAMPDIFF(SECOND, a.start_time , a.end_time) as duration , a.dir
from t_event_info a where a.dt = DATE_FORMAT(DATE_sub(now(),INTERVAL 24 HOUR ),'%Y%m%d') and a.type in (701,702,703,707)
</select>
<select id="selectGreenEvent" resultMap="AnalysisProblemAndStrategyDayMap">
select a.event_serial_number as eventSerialNumber , a.cross_id as crossId ,a.green_id as greenId,
a.category as eventCategory,a.type as eventType ,a.start_time as happenStartTime ,a.end_time as happenEndTime,
TIMESTAMPDIFF(SECOND, a.start_time , a.end_time) as duration , a.dir
from t_event_info a where a.dt = DATE_FORMAT(DATE_sub(now(),INTERVAL 24 HOUR ),'%Y%m%d') and a.type in (705,706)
</select>
<select id="getGreenStrategy" parameterType="String" resultMap="AnalysisProblemAndStrategyDayMap">
select DISTINCT a.control_time as optStartTime,DATE_ADD(a.control_time,INTERVAL a.control_duration SECOND ) as optEndTime ,a.control_duration as optDuration from t_strategy_green_opt_hist a
where a.control_time = (select MAX(control_time) from t_strategy_green_opt_hist where green_id = #{greenID}
and control_time <![CDATA[ >= ]]> DATE_FORMAT(DATE_sub(#{time},INTERVAL control_duration SECOND),'%Y-%m-%d %H:%i:%s') and control_time <![CDATA[ <= ]]> DATE_FORMAT(#{time}, '%Y-%m-%d %H:%i:%s')
and response_code = 200 )
and a.green_id = #{greenID}
</select>
<select id="getCrossStrategy" parameterType="String" resultMap="AnalysisProblemAndStrategyDayMap">
select a.issue_time as optStartTime,DATE_ADD(a.issue_time,INTERVAL a.duration SECOND ) as optEndTime,a.duration as optDuration from t_strategy_cross_result a
where a.issue_time = (select MIN(issue_time) from t_strategy_cross_result where cross_id = #{crossID}
and issue_time <![CDATA[ <= ]]> DATE_FORMAT(DATE_ADD(#{time},INTERVAL 2 MINUTE),'%Y-%m-%d %H:%i:%s') and issue_time >= DATE_FORMAT(#{time}, '%Y-%m-%d %H:%i:%s')
and response_code = 200
and dt = DATE_FORMAT(#{time}, '%Y%m%d') )
and a.cross_id = #{crossID}
</select>
<insert id="insertProblemAndStrategy" parameterType="net.wanji.opt.entity.judgeanalysis.AnalysisProblemAndStrategyDay">
insert into t_event_optimize_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="crossId != null">cross_id,</if>
<if test="eventSerialNumber != null">event_serial_number,</if>
<if test="eventCategory != null">event_category,</if>
<if test="eventType != null">event_type,</if>
<if test="happenStartTime != null">happen_start_time,</if>
<if test="happenEndTime != null">happen_end_time,</if>
<if test="duration != null">duration,</if>
<if test="optStatus != null">opt_status,</if>
<if test="dir != null">dir,</if>
<if test="optStartTime != null">opt_start_time,</if>
<if test="optEndTime != null">opt_end_time,</if>
<if test="optDuration != null">opt_duration,</if>
<if test="dt != null">dt,</if>
<if test="insertTime != null">insert_time,</if>
<if test="greenId != null and greenId != '' ">green_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="crossId != null">#{crossId},</if>
<if test="eventSerialNumber != null">#{eventSerialNumber},</if>
<if test="eventCategory != null">#{eventCategory},</if>
<if test="eventType != null">#{eventType},</if>
<if test="happenStartTime != null">DATE_FORMAT(#{happenStartTime},'%Y-%m-%d %H:%i:%s'),</if>
<if test="happenEndTime != null">DATE_FORMAT(#{happenEndTime},'%Y-%m-%d %H:%i:%s'),</if>
<if test="duration != null">#{duration},</if>
<if test="optStatus != null">#{optStatus},</if>
<if test="dir != null">#{dir},</if>
<if test="optStartTime != null">DATE_FORMAT(#{optStartTime},'%Y-%m-%d %H:%i:%s'),</if>
<if test="optEndTime != null">DATE_FORMAT(#{optEndTime},'%Y-%m-%d %H:%i:%s'),</if>
<if test="optDuration != null">#{optDuration},</if>
<if test="dt != null">#{dt},</if>
<if test="insertTime != null">DATE_FORMAT(#{insertTime},'%Y-%m-%d %H:%i:%s'),</if>
<if test="greenId != null and greenId != ''">#{greenId},</if>
</trim>
</insert>
</mapper>
\ No newline at end of file
...@@ -338,6 +338,22 @@ ...@@ -338,6 +338,22 @@
GROUP BY dt, t1.event_type GROUP BY dt, t1.event_type
ORDER BY dt ORDER BY dt
</select> </select>
<select id="getCrossOptAnalysis" parameterType="map"
resultType="net.wanji.opt.synthesis.pojo.CrossOptAnalysisEntity">
select (
case
t.opt_status
when 0 then '未优化'
when 1 then '已优化'
end
) status,
count(0) num
from t_event_optimize_info t
where 1 = 1
and t.cross_id = #{crossID}
and t.dt = #{date}
group by status
</select>
</mapper> </mapper>
package net.wanji.databus.vo; package net.wanji.databus.vo;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
...@@ -16,6 +17,7 @@ import java.util.List; ...@@ -16,6 +17,7 @@ import java.util.List;
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@Data @Data
@ApiModel(value = "LightsStatusVO2", description = "实时灯态信息实体版本2") @ApiModel(value = "LightsStatusVO2", description = "实时灯态信息实体版本2")
@JsonIgnoreProperties(ignoreUnknown = true)
public class LightsStatusVO2 extends BaseCrossInfo { public class LightsStatusVO2 extends BaseCrossInfo {
@ApiModelProperty(value = "运行模式 `2=手动锁定当前相位`,`3=手动全红`,`4=手动黄闪`,`5=手动关灯`," + @ApiModelProperty(value = "运行模式 `2=手动锁定当前相位`,`3=手动全红`,`4=手动黄闪`,`5=手动关灯`," +
"`6=全红闪控制`,`7=全黄控制`,`8=正常按计划运行`,`9=手动步进控制`,`10=自动步进控制`,`11=恢复时间表`," + "`6=全红闪控制`,`7=全黄控制`,`8=正常按计划运行`,`9=手动步进控制`,`10=自动步进控制`,`11=恢复时间表`," +
...@@ -38,6 +40,8 @@ public class LightsStatusVO2 extends BaseCrossInfo { ...@@ -38,6 +40,8 @@ public class LightsStatusVO2 extends BaseCrossInfo {
private String schemeId; private String schemeId;
@ApiModelProperty(value = "灯组状态") @ApiModelProperty(value = "灯组状态")
private List<DirInfo> dirLampGroupMapList; private List<DirInfo> dirLampGroupMapList;
@ApiModelProperty(value = "当前相位灯组状态")
private List<DirInfo> curPhaseLampGroupMapList;
@ApiModelProperty(value = "数据上报时间戳") @ApiModelProperty(value = "数据上报时间戳")
@Field(type = FieldType.Keyword, name = "timeStamp") @Field(type = FieldType.Keyword, name = "timeStamp")
private String timeStamp; private String timeStamp;
......
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