Commit f56fcf7a authored by wang yecheng's avatar wang yecheng

方案评价溢出优化

parent 37ececdd
......@@ -38,7 +38,6 @@ public class EvaluationInfoController {
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = AreaProblemOverview.class),
})
public JsonViewObject problemOverview(String crossId,String startTime, String endTime,String contrastStartTime,String constrastEndTime) {
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
try{
......@@ -51,6 +50,31 @@ public class EvaluationInfoController {
return jsonViewObject;
}
@ApiOperation(value = "方案评价-溢出", response = JsonViewObject.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@ApiImplicitParams({
@ApiImplicitParam(name = "crossId", value = "路口ID", required = true, dataType = "String"),
@ApiImplicitParam(name = "startTime", value = "分析时段开始时间", required = false, dataType = "string"),
@ApiImplicitParam(name = "endTime", value = "分析时段截止时间", required = false, dataType = "string"),
@ApiImplicitParam(name = "contrastStartTime", value = "对比时段开始时间", required = false, dataType = "string"),
@ApiImplicitParam(name = "constrastEndTime", value = "对比时段截止时间", required = false, dataType = "string"),
})
@GetMapping(value = "/overFlow")
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = AreaProblemOverview.class),
})
public JsonViewObject summaryEvaluation(String crossId,String startTime, String endTime,String contrastStartTime,String constrastEndTime) {
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
try{
Map<String,Object> resData=evaluationInfoService.summaryEvaluation(crossId,startTime,endTime,contrastStartTime,constrastEndTime);
jsonViewObject.success(resData);
}catch (Exception e){
jsonViewObject.fail(I18nResourceBundle.getConstants("GET_FAILED_MSG"));
log.error("{} getAll error", this.getClass().getSimpleName(), e);
}
return jsonViewObject;
}
}
......@@ -2,6 +2,7 @@ package net.wanji.opt.dao.mapper.evaluation;
import net.wanji.common.framework.mapper.BaseInterfaceMapper;
import net.wanji.opt.entity.evaluation.EventInfo;
import net.wanji.opt.entity.eventoptimize.TEventOptimizeInfo;
import net.wanji.opt.entity.judgeanalysis.AnalysisProblemAndStrategyDay;
import java.util.List;
......@@ -19,5 +20,8 @@ public interface CrossProblemEvaluationMapper {
public List<AnalysisProblemAndStrategyDay> findOVerFlowInfo();
List<TEventOptimizeInfo> getOverflow(String crossId, String startTime, String endTime);
List<TEventOptimizeInfo> getContrastOverflow(String crossId, String contrastStartTime, String constrastEndTime);
}
......@@ -8,4 +8,6 @@ import java.util.Map;
public interface EvaluationInfoService extends IService<CrossDataHistPO> {
Map<String,Object> getListEvaluationSummarize(String crossId, String startTime, String endTime, String contrastStartTime, String constrastEndTime);
Map<String, Object> summaryEvaluation(String crossId, String startTime, String endTime, String contrastStartTime, String constrastEndTime);
}
......@@ -6,6 +6,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import net.wanji.databus.dao.mapper.CrossDataHistMapper;
import net.wanji.databus.po.CrossDataHistPO;
import net.wanji.opt.constant.ServiceLevelEnum;
import net.wanji.opt.entity.eventoptimize.TEventOptimizeInfo;
import net.wanji.opt.entity.judgeanalysis.AnalysisProblemAndStrategyDay;
import net.wanji.opt.dao.mapper.evaluation.CrossProblemEvaluationMapper;
import net.wanji.opt.servicev2.evaluation.EvaluationInfoService;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -14,6 +16,7 @@ import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@Service
public class EvaluationInfoServiceImpl extends ServiceImpl<CrossDataHistMapper, CrossDataHistPO> implements EvaluationInfoService {
......@@ -100,7 +103,7 @@ public class EvaluationInfoServiceImpl extends ServiceImpl<CrossDataHistMapper,
*/
private static double calculatePercentage(double analyseValue, double contrastValue) {
// 防止除零错误
if (analyseValue == 0) {
if (contrastValue == 0) {
return 0;
}
......@@ -127,4 +130,82 @@ public class EvaluationInfoServiceImpl extends ServiceImpl<CrossDataHistMapper,
return serviceLevel;
}
@Override
public Map<String, Object> summaryEvaluation(String crossId, String startTime, String endTime, String contrastStartTime, String constrastEndTime) {
//分析时间
List<TEventOptimizeInfo> overFlowList = crossProblemEvaluationMapper.getOverflow(crossId, startTime, endTime);
//对比时间
List<TEventOptimizeInfo> contrastoverFlowList = crossProblemEvaluationMapper.getContrastOverflow(crossId, contrastStartTime, constrastEndTime);
//分析溢出次数
long overFlowcount = overFlowList.stream().filter(event -> "703".equals(event.getEventType())).count();
//对比溢出次数
long ontrastoverFlowcount = contrastoverFlowList.stream().filter(event -> "703".equals(event.getEventType())).count();
//分析溢出优化次数
long overFlowTime = overFlowList.stream().filter(event -> "703".equals(event.getEventType()) && "1".equals(event.getOptStatus())).count();
//对比溢出优化次数
long contrastoverFlowTime = contrastoverFlowList.stream().filter(event -> "703".equals(event.getEventType()) && "1".equals(event.getOptStatus())).count();
//分析溢出时长
int fenxioverflowTime = overFlowList.stream().filter(event -> "703".equals(event.getEventType())).mapToInt(TEventOptimizeInfo::getDuration).sum();
//对比溢出时长
int duibioverflowTime = contrastoverFlowList.stream().filter(event -> "703".equals(event.getEventType())).mapToInt(TEventOptimizeInfo::getDuration).sum();
//计算溢出次数百分比
double overFlowCishujisuan = calculatePercentage(overFlowcount, ontrastoverFlowcount);
//计算溢时长百分比
double overFlowtimejisuan = calculatePercentage(fenxioverflowTime, duibioverflowTime);
//分析时间的数据t_cross_data_hist
List<CrossDataHistPO> analyseList = crossDataHistMapper.getListEvaluationanalyse(crossId, startTime, endTime);
//比较时间的数据t_cross_data_hist
List<CrossDataHistPO> contrastList = crossDataHistMapper.getListEvaluationcontrast(crossId, contrastStartTime, constrastEndTime);
//溢出分析的延时时间
Integer overFlowdelayTime = 0;
for (CrossDataHistPO analyselist : analyseList) {
if (analyselist == null) {
continue; // 跳过空元素
}
overFlowdelayTime = analyselist.getDelayTime();
}
//溢出对比的延时时间
Integer conTrastoverFlowdelayTime = 0;
for (CrossDataHistPO contrastlist : contrastList) {
if (contrastlist == null) {
continue; // 跳过空元素
}
conTrastoverFlowdelayTime = contrastlist.getDelayTime();
}
//溢出的平均延误时间计算
double overFlowDelayjisuan = calculatePercentage(overFlowdelayTime, conTrastoverFlowdelayTime);
JSONObject jsonObject = new JSONObject();
//溢出次数
jsonObject.put("analyOverFlowTime", overFlowcount);
//溢出优化次数
jsonObject.put("analyOverFlowOptimize", overFlowTime);
//对比溢出次数
jsonObject.put("contrastOverFlowTime", ontrastoverFlowcount);
//对比的溢出优化次数
jsonObject.put("contrastOverFlowOptimize", contrastoverFlowTime);
//溢出次数分析对比计算
jsonObject.put("OverFlowTimeCalculate", overFlowCishujisuan+ "%");
//溢出时长分析对比计算
jsonObject.put("OverFlowHourCalculate", overFlowtimejisuan+ "%");
//溢出平均延误
jsonObject.put("OverFlowavgdelay", overFlowDelayjisuan+ "%");
return jsonObject;
}
}
......@@ -9,7 +9,37 @@
FROM t_event_optimize_info
WHERE 1=1
</select>
<select id="getOverflow" parameterType="net.wanji.opt.entity.eventoptimize.TEventOptimizeInfo" resultType="net.wanji.opt.entity.eventoptimize.TEventOptimizeInfo" >
SELECT
cross_id,duration,opt_status,
event_type,opt_duration
FROM
t_event_optimize_info
WHERE
1=1
<if test="crossId!=null and crossId!=''">
AND cross_id=#{crossId}
</if>
<if test="startTime!=null and startTime!='' and endTime!='' and endTime!=null">
AND happen_start_time>=#{startTime} and happen_start_time &lt;=#{endTime}
</if>
</select>
<select id="getContrastOverflow" parameterType="net.wanji.opt.entity.eventoptimize.TEventOptimizeInfo" resultType="net.wanji.opt.entity.eventoptimize.TEventOptimizeInfo">
SELECT
cross_id,duration,opt_status,
event_type,opt_duration
FROM
t_event_optimize_info
WHERE
1=1
<if test="crossId!=null and crossId!=''">
AND cross_id=#{crossId}
</if>
<if test="contrastStartTime!=null and contrastStartTime!='' and constrastEndTime!='' and constrastEndTime!=null">
AND happen_start_time>=#{contrastStartTime} and happen_start_time &lt;=#{constrastEndTime}
</if>
</select>
</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