Commit bed7eba0 authored by fengyasheng's avatar fengyasheng

干线拥堵分析,干线缓行分析

parent c824d5c6
package net.wanji.opt.controllerv2.judgeanalysis; package net.wanji.opt.controllerv2.judgeanalysis;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
...@@ -163,6 +164,50 @@ public class AnalysisProblemGreenDayController { ...@@ -163,6 +164,50 @@ public class AnalysisProblemGreenDayController {
} }
} }
@ApiOperation(value = "干线拥堵分析", notes = "干线拥堵分析")
@ApiImplicitParams({
@ApiImplicitParam(name = "greenId", value = "绿波ID", required = true, dataType = "Integer", paramType = "query"),
@ApiImplicitParam(name = "startTime", value = "日期,格式:yyyy-MM-dd HH:mm:ss", required = true, dataType = "String"),
@ApiImplicitParam(name = "endTime", value = "日期,格式:yyyy-MM-dd HH:mm:ss", required = true, dataType = "String"),
})
@GetMapping(value = "/getGreenCongestionAnalysis")
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = GreenHighFrequencyProblemReasonResult.class),
})
public JsonViewObject getGreenCongestionAnalysis(Integer greenId, String startTime ,String endTime) {
JsonViewObject object = JsonViewObject.newInstance();
try {
JSONObject jsonObject = analysisProblemCrossDayService.getGreenCongestionAnalysis(greenId,startTime,endTime);
object.success(jsonObject);
} catch (Exception e) {
log.error("干线拥堵分析: ", e);
return JsonViewObject.newInstance().fail("干线拥堵分析");
}
return object;
}
@ApiOperation(value = "干线缓行分析", notes = "干线缓行分析")
@ApiImplicitParams({
@ApiImplicitParam(name = "greenId", value = "绿波ID", required = true, dataType = "Integer", paramType = "query"),
@ApiImplicitParam(name = "startTime", value = "日期,格式:yyyy-MM-dd HH:mm:ss", required = true, dataType = "String"),
@ApiImplicitParam(name = "endTime", value = "日期,格式:yyyy-MM-dd HH:mm:ss", required = true, dataType = "String"),
})
@GetMapping(value = "/getGreenSlowAnalysis")
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = GreenHighFrequencyProblemReasonResult.class),
})
public JsonViewObject getGreenSlowAnalysis(Integer greenId, String startTime ,String endTime) {
JsonViewObject object = JsonViewObject.newInstance();
try {
JSONObject jsonObject = analysisProblemCrossDayService.getGreenSlowAnalysis(greenId,startTime,endTime);
object.success(jsonObject);
} catch (Exception e) {
log.error("干线拥堵分析: ", e);
return JsonViewObject.newInstance().fail("干线拥堵分析");
}
return object;
}
@ApiOperation(value = "干线频发问题监测【研判分析-干线-左下角】", notes = "干线频发问题监测") @ApiOperation(value = "干线频发问题监测【研判分析-干线-左下角】", notes = "干线频发问题监测")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "greenId", value = "绿波ID", required = true, dataType = "Integer", paramType = "query"), @ApiImplicitParam(name = "greenId", value = "绿波ID", required = true, dataType = "Integer", paramType = "query"),
......
...@@ -5,6 +5,7 @@ import net.wanji.opt.entity.judgeanalysis.AnalysisProblemCrossDay; ...@@ -5,6 +5,7 @@ import net.wanji.opt.entity.judgeanalysis.AnalysisProblemCrossDay;
import net.wanji.opt.entity.judgeanalysis.CrossPoint; import net.wanji.opt.entity.judgeanalysis.CrossPoint;
import net.wanji.opt.synthesis.pojo.CrossOptAnalysisEntity; import net.wanji.opt.synthesis.pojo.CrossOptAnalysisEntity;
import net.wanji.opt.vo2.GreenwaveCrossResult; import net.wanji.opt.vo2.GreenwaveCrossResult;
import net.wanji.opt.vo2.LaneSturationInfo;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
...@@ -114,5 +115,13 @@ public interface AnalysisProblemCrossDayMapper extends BaseMapper<AnalysisProble ...@@ -114,5 +115,13 @@ public interface AnalysisProblemCrossDayMapper extends BaseMapper<AnalysisProble
List<CrossOptAnalysisEntity> getCrossOptAnalysis(@Param("greenId") String greenId,@Param("crossID") String crossID, @Param("startTime")String startTime,@Param("endTime")String endTime); List<CrossOptAnalysisEntity> getCrossOptAnalysis(@Param("greenId") String greenId,@Param("crossID") String crossID, @Param("startTime")String startTime,@Param("endTime")String endTime);
List<GreenwaveCrossResult> getTrunkLineCrossProblem(@Param("greenId") Integer greenId,@Param("status") Integer status,@Param("startTime") String startTime,@Param("endTime") String endTime); List<GreenwaveCrossResult> getTrunkLineCrossProblem(@Param("greenId") Integer greenId,@Param("status") Integer status,@Param("startTime") String startTime,@Param("endTime") String endTime);
Double getGreenStopTimeAvg(@Param("greenId") Integer greenId,@Param("startTime") String startTime,@Param("endTime") String endTime);
Double getGreenStopTimeSum(@Param("greenId") Integer greenId,@Param("startTime") String startTime,@Param("endTime") String endTime);
Double getGreenSlowStopTimeSum(@Param("greenId") Integer greenId,@Param("startTime") String startTime,@Param("endTime") String endTime);
List<LaneSturationInfo> getSturationInfoList(@Param("crossId") String crossId,@Param("startTime") String startTime,@Param("endTime") String endTime);
} }
package net.wanji.opt.servicev2.judgeanalysis; package net.wanji.opt.servicev2.judgeanalysis;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import net.wanji.opt.entity.judgeanalysis.AnalysisProblemCrossDay; import net.wanji.opt.entity.judgeanalysis.AnalysisProblemCrossDay;
import net.wanji.opt.vo2.CrossOptAnalysisVO; import net.wanji.opt.vo2.CrossOptAnalysisVO;
...@@ -77,4 +78,8 @@ public interface AnalysisProblemCrossDayService extends IService<AnalysisProblem ...@@ -77,4 +78,8 @@ public interface AnalysisProblemCrossDayService extends IService<AnalysisProblem
CrossOptAnalysisVO getCrossOptAnalysis(String crossID, String startTime,String endTime); CrossOptAnalysisVO getCrossOptAnalysis(String crossID, String startTime,String endTime);
List<JudTrunkLineCrossProblemEntityVO> getTrunkLineCrossProblem(Integer greenId, Integer status, String startTime, String endTime); List<JudTrunkLineCrossProblemEntityVO> getTrunkLineCrossProblem(Integer greenId, Integer status, String startTime, String endTime);
JSONObject getGreenCongestionAnalysis(Integer greenId, String startTime, String endTime);
JSONObject getGreenSlowAnalysis(Integer greenId, String startTime, String endTime);
} }
...@@ -18,6 +18,7 @@ import net.wanji.opt.synthesis.pojo.CrossOptAnalysisEntity; ...@@ -18,6 +18,7 @@ import net.wanji.opt.synthesis.pojo.CrossOptAnalysisEntity;
import net.wanji.opt.vo2.CrossOptAnalysisVO; import net.wanji.opt.vo2.CrossOptAnalysisVO;
import net.wanji.opt.vo2.GreenwaveCrossResult; import net.wanji.opt.vo2.GreenwaveCrossResult;
import net.wanji.opt.vo2.JudTrunkLineCrossProblemEntityVO; import net.wanji.opt.vo2.JudTrunkLineCrossProblemEntityVO;
import net.wanji.opt.vo2.LaneSturationInfo;
import net.wanji.opt.vo2.report.JudTrunkLineCrossProblemEntityDTO; import net.wanji.opt.vo2.report.JudTrunkLineCrossProblemEntityDTO;
import org.locationtech.jts.geom.Geometry; import org.locationtech.jts.geom.Geometry;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
...@@ -299,4 +300,48 @@ public class AnalysisProblemCrossDayServiceImpl extends ServiceImpl<AnalysisProb ...@@ -299,4 +300,48 @@ public class AnalysisProblemCrossDayServiceImpl extends ServiceImpl<AnalysisProb
return judTrunkLineCrossProblemEntityVOS; return judTrunkLineCrossProblemEntityVOS;
} }
@Override
public JSONObject getGreenCongestionAnalysis(Integer greenId, String startTime, String endTime) {
Double stoptimes = analysisProblemCrossDayMapper.getGreenStopTimeAvg(greenId, startTime, endTime);
Double stoptimesSum = analysisProblemCrossDayMapper.getGreenStopTimeSum(greenId, startTime, endTime);
List<GreenwaveCrossPO> greenwaveCrossPOS = greenwaveCrossMapper.selectByGreenwaveId(greenId);
JSONObject jsonObject = new JSONObject();
if (stoptimesSum > greenwaveCrossPOS.size()) {
jsonObject.put("slowAnalysis", "干线相位协调不佳,干线频繁停车,平均停车次数" + stoptimes + "次,易拥堵");
}
String crossName = "";
for (GreenwaveCrossPO greenwaveCrossPO : greenwaveCrossPOS) {
List<LaneSturationInfo> sturationInfoList = analysisProblemCrossDayMapper.getSturationInfoList(greenwaveCrossPO.getCrossId(), startTime, endTime);
List<LaneSturationInfo> infoList = sturationInfoList.stream().filter(x -> greenwaveCrossPO.getInDir() == x.getDir() || greenwaveCrossPO.getOutDir() == x.getDir()).collect(Collectors.toList());
if (ObjectUtil.isEmpty(infoList) || infoList.size() == 0) {
continue;
}
List<LaneSturationInfo> sturationInfos = infoList.stream().filter(x -> ObjectUtil.isNotEmpty(x.getSturation()) && x.getSturation() > 0.8).collect(Collectors.toList());
if (sturationInfos.size() * 1.0 / infoList.size() > 0.5) {
BaseCrossInfoPO baseCrossInfoPO = baseCrossInfoMapper.selectById(greenwaveCrossPO.getCrossId());
if (ObjectUtil.isEmpty(crossName)) {
crossName = baseCrossInfoPO.getName();
} else {
crossName = crossName + "、" + baseCrossInfoPO.getName();
}
}
if (ObjectUtil.isNotEmpty(crossName)) {
jsonObject.put("crossAnalysis", crossName + "协调方向流量饱和,易引发拥堵");
}
}
return jsonObject;
}
@Override
public JSONObject getGreenSlowAnalysis(Integer greenId, String startTime, String endTime) {
Double stoptimes = analysisProblemCrossDayMapper.getGreenSlowStopTimeSum(greenId, startTime, endTime);
List<GreenwaveCrossPO> greenwaveCrossPOS = greenwaveCrossMapper.selectByGreenwaveId(greenId);
JSONObject jsonObject = new JSONObject();
if (stoptimes > greenwaveCrossPOS.size() / 2) {
jsonObject.put("slowAnalysis", "干线绿波协调不连续,易引发缓行");
}
return jsonObject;
}
} }
package net.wanji.opt.vo2;
import lombok.Data;
@Data
public class LaneSturationInfo {
/**
* 路口ID
*/
private String crossId;
/**
* 方向
*/
private Integer dir;
/**
* 车道ID
*/
private String id;
/**
* 平均饱和度
*/
private Double sturation;
}
\ No newline at end of file
...@@ -391,4 +391,52 @@ ...@@ -391,4 +391,52 @@
</select> </select>
<select id="getGreenStopTimeAvg" resultType="java.lang.Double">
select COALESCE(AVG(stop_times), 0) stop_time from t_greenwave_hist
where 1=1
<if test="greenId != null">
green_id = #{greenId}
</if>
<if test="startTime != null and endTime != null">
and start_time BETWEEN #{startTime} AND #{endTime}
</if>
and status in (3,4)
</select>
<select id="getGreenStopTimeSum" resultType="java.lang.Double">
select COALESCE(sum(stop_times), 0) stop_time from t_greenwave_hist
where 1=1
<if test="greenId != null">
green_id = #{greenId}
</if>
<if test="startTime != null and endTime != null">
and start_time BETWEEN #{startTime} AND #{endTime}
</if>
and status in (3,4)
</select>
<select id="getGreenSlowStopTimeSum" resultType="java.lang.Double">
select COALESCE(sum(stop_times), 0) stop_time from t_greenwave_hist
where 1=1
<if test="greenId != null">
green_id = #{greenId}
</if>
<if test="startTime != null and endTime != null">
and start_time BETWEEN #{startTime} AND #{endTime}
</if>
and status = 2
</select>
<select id="getSturationInfoList" resultType="net.wanji.opt.vo2.LaneSturationInfo">
SELECT a.cross_id,a.dir,a.id,avg(b.sturation) sturation
from t_base_lane_info a
LEFT JOIN
(
SELECT id,sturation from t_lane_data_hist
where cross_id = #{crossId} and start_time BETWEEN #{startTime} AND #{endTime}
) b
on a.id=b.id
where a.cross_id = #{crossId} and a.type=2
GROUP BY a.cross_id,a.dir,a.id
</select>
</mapper> </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