Commit ba1e4365 authored by Zheng Yi Fan's avatar Zheng Yi Fan

feat(signal-optimize-service):增加路口和干线类型信息功能

- 新增 CrossOrGreenWaveTypeEntity 类用于路口和绿波类型信息
- 在 CrossController 和 TrunkLineController 中添加相关 API 接口
- 在 CrossService 和 TrunkLineService 中新增获取类型信息的方法
- 在 CrossMapper 和 TrunkLineMapper 中添加对应的 SQL 查询
- 优化了原有方法,支持按日期获取信息
parent 9047edd2
......@@ -6,6 +6,7 @@ import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.opt.servicev2.CrossService;
import net.wanji.opt.synthesis.pojo.CrossRealTimeAlarmEntity;
import net.wanji.opt.synthesis.pojo.CrossStatusDisOptTimeEntity;
import net.wanji.opt.synthesis.pojo.vo.CrossOrGreenWaveTypeEntity;
import net.wanji.opt.vo2.CrossBaseInfoVO;
import net.wanji.opt.vo2.CrossRealTimeAlarmVO;
import net.wanji.opt.vo2.CrossStatusDistributionVO;
......@@ -48,7 +49,9 @@ public class CrossController {
try {
Map<String, Object> result = crossService.getCrossStatusDistribution(crossID, date, groupType, objectType, condition);
List<CrossStatusDisOptTimeEntity> optTimes = crossService.getOptTimeList(crossID);
List<CrossOrGreenWaveTypeEntity> typeList = crossService.getCrossTypeList(crossID, date);
result.put("optTimesList", optTimes);
result.put("typeList", typeList);
return jsonViewObject.success(result);
} catch (Exception e) {
log.error("监测详情-路口事件详情-路口状态分布: ", e);
......
......@@ -5,17 +5,19 @@ import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.opt.po.base.EventStatisticPo;
import net.wanji.opt.servicev2.TrendServiceV2;
import net.wanji.opt.servicev2.TrunkLineService;
import net.wanji.opt.servicev2.TrunkLineStatusDisService;
import net.wanji.opt.synthesis.pojo.TrunkLineProblemDescribeEntity;
import net.wanji.opt.vo2.*;
import org.springframework.web.bind.annotation.*;
import net.wanji.opt.vo2.CrossRealTimeAlarmVO;
import net.wanji.opt.vo2.TrunkLineCrossProblemVO;
import net.wanji.opt.vo2.TrunkLineProblemDescribeVO;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.ws.rs.core.MediaType;
import java.util.*;
import java.util.stream.Collectors;
import java.util.List;
/**
* @author zhengyifan
......@@ -47,6 +49,7 @@ public class TrunkLineController {
try {
JsonViewObject object = JsonViewObject.newInstance();
JSONObject list = trunkLineStatusDisService.trunkLineStatusDisInfoList(greenID, date, timeGranule);
return object.success(list);
} catch (Exception e) {
log.error("监测详情-干线事件详情-干线交通状态分布趋势: ", e);
......
package net.wanji.opt.dao.mapper;
import net.wanji.opt.synthesis.pojo.*;
import net.wanji.opt.synthesis.pojo.vo.CrossOrGreenWaveTypeEntity;
import org.apache.ibatis.annotations.Param;
import java.util.List;
......@@ -15,15 +17,13 @@ public interface CrossMapper {
/**
* 监测详情-路口事件详情-路口状态分布趋势-优化时间
* @param crossID 路口ID
* @return
*/
List<CrossStatusDisOptTimeEntity> getOptTimes(String crossID);
/**
* 监测详情-路口事件详情-路口实时告警
* @param crossID
* @param time
* @return
* @param crossID 路口ID
* @param time 时间
*/
List<CrossRealTimeAlarmEntity> getCrossRealTimeAlarms(String crossID, String time);
......@@ -47,4 +47,12 @@ public interface CrossMapper {
* @param crossID 路口ID
*/
List<CrossLaneInfoEntity> getCrossLaneInfo(String crossID);
/**
* 路口类型信息
*
* @param crossID 路口ID
* @param date 日期 格式:yyyyMMdd
*/
List<CrossOrGreenWaveTypeEntity> getCrossTypeInfo(@Param("crossID") String crossID, @Param("dt") String date);
}
package net.wanji.opt.dao.mapper;
import io.lettuce.core.dynamic.annotation.Param;
import net.wanji.opt.synthesis.pojo.TrunkLineCrossProblemEntity;
import net.wanji.opt.synthesis.pojo.TrunkLineProblemDescribeEntity;
import net.wanji.opt.synthesis.pojo.vo.CrossOrGreenWaveTypeEntity;
import net.wanji.opt.vo2.CrossRealTimeAlarmVO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
......@@ -17,19 +18,15 @@ import java.util.List;
public interface TrunkLineMapper{
/**
* 获取干线问题描述
* @return
*/
List<TrunkLineProblemDescribeEntity> getTrunkLineProblemDescribe(@Param("greenID") String greenID , @Param("time") String time);
/**
* 获取干线实时告警
* @return
*/
List<CrossRealTimeAlarmVO> getTrunkLineRealTimeAlarm(@Param("greenID") Integer greenID,@Param("time") String time);
/**
* 获取干线路口事件描述
* @return
*/
List<TrunkLineCrossProblemEntity> getTrunkLineCrossProblem(@Param("greenID") Integer greenID, @Param("time") String time);
......@@ -38,4 +35,12 @@ public interface TrunkLineMapper{
*/
TrunkLineCrossProblemEntity getIODir(@Param("greenID") Integer greenID);
/**
* 获取干线类型信息
*
* @param greenID 绿波ID
* @param date 日期
*/
List<CrossOrGreenWaveTypeEntity> getGreenWaveTypeList(@Param("greenID") String greenID, @Param("dt") String date);
}
......@@ -2,6 +2,7 @@ package net.wanji.opt.servicev2;
import net.wanji.opt.synthesis.pojo.CrossRealTimeAlarmEntity;
import net.wanji.opt.synthesis.pojo.CrossStatusDisOptTimeEntity;
import net.wanji.opt.synthesis.pojo.vo.CrossOrGreenWaveTypeEntity;
import net.wanji.opt.vo2.CrossBaseInfoVO;
import net.wanji.opt.vo2.CrossStatusDistributionVO;
......@@ -60,5 +61,13 @@ public interface CrossService {
*/
CrossBaseInfoVO getCrossBaseInfos(String crossID);
/**
* 获取路口类型信息
*
* @param crossID 路口ID
* @param date 日期
*/
List<CrossOrGreenWaveTypeEntity> getCrossTypeList(String crossID, String date);
}
package net.wanji.opt.servicev2;
import net.wanji.opt.synthesis.pojo.TrunkLineProblemDescribeEntity;
import net.wanji.opt.synthesis.pojo.vo.CrossOrGreenWaveTypeEntity;
import net.wanji.opt.vo2.CrossRealTimeAlarmVO;
import net.wanji.opt.vo2.TrunkLineCrossProblemVO;
......@@ -14,7 +15,6 @@ import java.util.List;
public interface TrunkLineService {
/**
* 获取干线事件描述
* @return
*/
List<TrunkLineProblemDescribeEntity> getTrunkLineProblemDescribe(String greenID , String time);
......@@ -27,4 +27,13 @@ public interface TrunkLineService {
* 干线路口事件描述列表
*/
List<TrunkLineCrossProblemVO> getTrunkLineCrossProblem(Integer greenID, String time);
/**
* 获取路口类型信息
*
* @param crossID 路口ID
* @param date 日期
*/
List<CrossOrGreenWaveTypeEntity> getGreenWaveTypeList(String crossID, String date);
}
......@@ -7,6 +7,7 @@ import net.wanji.opt.dao.mapper.GreenwaveHistoryMapper;
import net.wanji.opt.po.base.CrossLaneDataHistPoExtend;
import net.wanji.opt.servicev2.CrossService;
import net.wanji.opt.synthesis.pojo.*;
import net.wanji.opt.synthesis.pojo.vo.CrossOrGreenWaveTypeEntity;
import net.wanji.opt.vo2.CrossBaseInfoVO;
import net.wanji.opt.vo2.CrossStatusDistributionVO;
import org.springframework.stereotype.Service;
......@@ -55,7 +56,7 @@ public class CrossServiceImpl implements CrossService {
}
} else if (objectType == 3) {
// 车道级
// condition是dir:turn:laneNum
// condition是dir:turn(int):laneNum
String[] conditions = condition.split(";");
for (String c : conditions) {
List<CrossStatusDistributionVO> list = getCrossStatusDistribution_SingleCondition(crossID, date, groupType, objectType, c);
......@@ -94,6 +95,8 @@ public class CrossServiceImpl implements CrossService {
params.put("objectType", objectType);
// 方向级时多传一个dir参数
if (objectType == 1) params.put("dir", condition);
if (objectType == 2) params.put("dir", condition.split(":")[0]);
if (objectType == 3) params.put("dir", condition.split(":")[0]);
List<CrossLaneDataHistPoExtend> firstList = greenwaveHistoryMapper.findCrossObjectIndex(params);
List<CrossStatusDistributionVO> results = new ArrayList<>();
......@@ -119,13 +122,11 @@ public class CrossServiceImpl implements CrossService {
if (objectType == 2) {
// 转向级
String[] con = condition.split(":");
results.removeIf(c -> c.getDirType() != Integer.parseInt(con[0]));
results.removeIf(c -> !Objects.equals(c.getTurnType(), BaseEnum.TurnTypeEnum.getIntCodeByStrCode(con[1])));
} else if (objectType == 3) {
// 车道级
String[] con = condition.split(":");
results.removeIf(c -> c.getDirType() != Integer.parseInt(con[0]));
results.removeIf(c -> c.getTurnType() != Integer.parseInt(con[1]));
results.removeIf(c -> c.getLaneNo() != Integer.parseInt(con[2]));
}
......@@ -137,7 +138,6 @@ public class CrossServiceImpl implements CrossService {
*
* @param crossID 路口ID
* @param time 可选参数
* @return
*/
@Override
public List<CrossRealTimeAlarmEntity> getCrossRealTimeAlarm(String crossID, String time) {
......@@ -171,4 +171,9 @@ public class CrossServiceImpl implements CrossService {
return crossBaseInfoVO;
}
@Override
public List<CrossOrGreenWaveTypeEntity> getCrossTypeList(String crossID, String date) {
return crossMapper.getCrossTypeInfo(crossID, date.replace("-", ""));
}
}
......@@ -5,6 +5,7 @@ import net.wanji.opt.dao.mapper.TrunkLineMapper;
import net.wanji.opt.servicev2.TrunkLineService;
import net.wanji.opt.synthesis.pojo.TrunkLineCrossProblemEntity;
import net.wanji.opt.synthesis.pojo.TrunkLineProblemDescribeEntity;
import net.wanji.opt.synthesis.pojo.vo.CrossOrGreenWaveTypeEntity;
import net.wanji.opt.vo2.CrossRealTimeAlarmVO;
import net.wanji.opt.vo2.TrunkLineCrossProblemVO;
import org.springframework.stereotype.Service;
......@@ -67,6 +68,11 @@ public class TrunkLineImpl implements TrunkLineService {
return voList;
}
@Override
public List<CrossOrGreenWaveTypeEntity> getGreenWaveTypeList(String greenID, String date) {
return trunkLineMapper.getGreenWaveTypeList(greenID, date.replace("-", ""));
}
private Map<String, String> getDirName(Integer inDir, Integer outDir) {
Map<String, String> result = new HashMap<>();
......
......@@ -3,14 +3,17 @@ package net.wanji.opt.servicev2.implv2;
import com.alibaba.fastjson.JSONObject;
import groovy.util.logging.Slf4j;
import net.wanji.opt.dao.mapper.TrunkLineStatusDisMapper;
import net.wanji.opt.entity.GreenwaveHist;
import net.wanji.opt.servicev2.TrunkLineService;
import net.wanji.opt.servicev2.TrunkLineStatusDisService;
import net.wanji.opt.synthesis.pojo.vo.CrossOrGreenWaveTypeEntity;
import net.wanji.opt.vo2.TrunkLineOptTimeInfoVO;
import net.wanji.opt.vo2.TrunkLineStatusDisInfoVO;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author zhengyifan
......@@ -22,6 +25,8 @@ import java.util.*;
public class TrunkLineStatusDisImpl implements TrunkLineStatusDisService {
@Resource
private TrunkLineStatusDisMapper trunkLineStatusDisMapper;
@Resource
private TrunkLineService trunkLineService;
@Override
public JSONObject trunkLineStatusDisInfoList(String greenID, String date, String timeGranule) {
......@@ -32,10 +37,12 @@ public class TrunkLineStatusDisImpl implements TrunkLineStatusDisService {
List<TrunkLineStatusDisInfoVO> list= trunkLineStatusDisMapper.findStatusDistribution(params);
List<TrunkLineOptTimeInfoVO> list1= trunkLineStatusDisMapper.findPlanTime(params);
List<CrossOrGreenWaveTypeEntity> gvList = trunkLineService.getGreenWaveTypeList(greenID, date);
JSONObject jsonObject = new JSONObject();
jsonObject.put("dataList", list);
jsonObject.put("timeList", list1);
jsonObject.put("gvTypeList", gvList);
return jsonObject;
}
......
package net.wanji.opt.synthesis.pojo.vo;
import lombok.Data;
@Data
public class CrossOrGreenWaveTypeEntity {
private String startTime;
private String endTime;
private String type;
}
......@@ -200,4 +200,24 @@
where 1 = 1
and t3.cross_id = #{crossID}
</select>
<select id="getCrossTypeInfo" parameterType="map"
resultType="net.wanji.opt.synthesis.pojo.vo.CrossOrGreenWaveTypeEntity">
select DATE_FORMAT(sub.start_time, '%H:%i') as startTime,
case
when minute(sub.start_time) = minute(sub.end_time) then
DATE_FORMAT(DATE_ADD(sub.end_time, interval 1 minute), '%H:%i')
else
DATE_FORMAT(sub.end_time, '%H:%i')
end as endTime,
sub.`type`
from (select t.start_time,
IFNULL(t.end_time, CURTIME()) as end_time,
t.`type`
from t_event_info t
where 1 = 1
and t.cross_id = #{crossID}
and t.`type` in (701, 702, 703, 707)
and t.dt = #{dt}) as sub
order by startTime
</select>
</mapper>
......@@ -95,5 +95,25 @@
where
a.green_id = #{greenID}
</select>
<select id="getGreenWaveTypeList" parameterType="map"
resultType="net.wanji.opt.synthesis.pojo.vo.CrossOrGreenWaveTypeEntity">
select DATE_FORMAT(sub.start_time, '%H:%i') as startTime,
case
when minute(sub.start_time) = minute(sub.end_time) then
DATE_FORMAT(DATE_ADD(sub.end_time, interval 1 minute), '%H:%i')
else
DATE_FORMAT(sub.end_time, '%H:%i')
end as endTime,
sub.`type`
from (select t.start_time,
IFNULL(t.end_time, CURTIME()) as end_time,
t.`type`
from t_event_info t
where 1 = 1
and t.green_id = #{greenID}
and t.`type` in (705, 706)
and t.dt = #{dt}) as sub
order by startTime
</select>
</mapper>
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