Commit 207cc171 authored by wang yecheng's avatar wang yecheng

方案评价追加trycatch

parent 525a80a9
...@@ -3,6 +3,7 @@ package net.wanji.opt.servicev2.evaluation.impl; ...@@ -3,6 +3,7 @@ package net.wanji.opt.servicev2.evaluation.impl;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.alibaba.nacos.common.utils.CollectionUtils; import com.alibaba.nacos.common.utils.CollectionUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import net.wanji.databus.dao.mapper.CrossDataHistMapper; import net.wanji.databus.dao.mapper.CrossDataHistMapper;
import net.wanji.databus.po.CrossDataHistPO; import net.wanji.databus.po.CrossDataHistPO;
import net.wanji.opt.constant.ServiceLevelEnum; import net.wanji.opt.constant.ServiceLevelEnum;
...@@ -19,6 +20,7 @@ import java.util.stream.Collectors; ...@@ -19,6 +20,7 @@ import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
@Service @Service
@Slf4j
public class EvaluationInfoServiceImpl extends ServiceImpl<CrossDataHistMapper, CrossDataHistPO> implements EvaluationInfoService { public class EvaluationInfoServiceImpl extends ServiceImpl<CrossDataHistMapper, CrossDataHistPO> implements EvaluationInfoService {
@Autowired @Autowired
...@@ -28,45 +30,47 @@ public class EvaluationInfoServiceImpl extends ServiceImpl<CrossDataHistMapper, ...@@ -28,45 +30,47 @@ public class EvaluationInfoServiceImpl extends ServiceImpl<CrossDataHistMapper,
@Override @Override
public Map<String,Object> getListEvaluationSummarize(String crossId, String startTime, String endTime, String contrastStartTime, String constrastEndTime) { public Map<String,Object> getListEvaluationSummarize(String crossId, String startTime, String endTime, String contrastStartTime, String constrastEndTime) {
try {
//分析时间的数据 //分析时间的数据
List<CrossDataHistPO> analyseList= crossDataHistMapper.getListEvaluationanalyse(crossId,startTime,endTime); List<CrossDataHistPO> analyseList = crossDataHistMapper.getListEvaluationanalyse(crossId, startTime, endTime);
//比较时间的数据 //比较时间的数据
List<CrossDataHistPO> contrastList= crossDataHistMapper.getListEvaluationcontrast(crossId,contrastStartTime,constrastEndTime); List<CrossDataHistPO> contrastList = crossDataHistMapper.getListEvaluationcontrast(crossId, contrastStartTime, constrastEndTime);
//分析时间服务水平 //分析时间服务水平
List<CrossDataHistPO> ServiceLevelanalyseList= crossDataHistMapper.getEvaluationanalyseServiceLevel(crossId,startTime,endTime); // List<CrossDataHistPO> ServiceLevelanalyseList = crossDataHistMapper.getEvaluationanalyseServiceLevel(crossId, startTime, endTime);
//比较时间的服务水平 //比较时间的服务水平
List<CrossDataHistPO> contrastServiceLevelList= crossDataHistMapper.getServiceLevelEvaluationcontrast(crossId,contrastStartTime,constrastEndTime); // List<CrossDataHistPO> contrastServiceLevelList = crossDataHistMapper.getServiceLevelEvaluationcontrast(crossId, contrastStartTime, constrastEndTime);
//取出分析时间 的速度 延误 排队长度 //取出分析时间 的速度 延误 排队长度
Double speed=0.00; Double speed = 0.00;
Integer delayTime =0; Integer delayTime = 0;
Double queueLength=0.00; Double queueLength = 0.00;
//分析的交通流量 //分析的交通流量
int analyseFlow=0; int analyseFlow = 0;
for (CrossDataHistPO analyselist:analyseList){ for (CrossDataHistPO analyselist : analyseList) {
if (analyselist == null) { if (analyselist == null) {
continue; // 跳过空元素 continue; // 跳过空元素
} }
speed = analyselist.getSpeed(); speed = analyselist.getSpeed();
delayTime = analyselist.getDelayTime(); delayTime = analyselist.getDelayTime();
queueLength = analyselist.getQueueLength(); queueLength = analyselist.getQueueLength();
analyseFlow= analyselist.getFlow(); analyseFlow = analyselist.getFlow();
} }
//取出对比时间 的速度 延误 排队长度 //取出对比时间 的速度 延误 排队长度
Double speedCompare=0.00; Double speedCompare = 0.00;
Integer delayTimeCompare =0; Integer delayTimeCompare = 0;
Double queueLengthCompare=0.00; Double queueLengthCompare = 0.00;
//对比的交通流量 //对比的交通流量
int contrastFlow=0; int contrastFlow = 0;
for (CrossDataHistPO contrastlist:contrastList){ for (CrossDataHistPO contrastlist : contrastList) {
if (contrastlist == null) { if (contrastlist == null) {
continue; // 跳过空元素 continue; // 跳过空元素
} }
speedCompare = contrastlist.getSpeed(); speedCompare = contrastlist.getSpeed();
delayTimeCompare = contrastlist.getDelayTime(); delayTimeCompare = contrastlist.getDelayTime();
queueLengthCompare = contrastlist.getQueueLength(); queueLengthCompare = contrastlist.getQueueLength();
contrastFlow= contrastlist.getFlow(); contrastFlow = contrastlist.getFlow();
} }
// 计算速度变化百分比 // 计算速度变化百分比
...@@ -79,20 +83,28 @@ public class EvaluationInfoServiceImpl extends ServiceImpl<CrossDataHistMapper, ...@@ -79,20 +83,28 @@ public class EvaluationInfoServiceImpl extends ServiceImpl<CrossDataHistMapper,
double queueLengthChangePercent = calculatePercentage(queueLength, queueLengthCompare); double queueLengthChangePercent = calculatePercentage(queueLength, queueLengthCompare);
// 计算交通流量百分比 // 计算交通流量百分比
double flow= calculatePercentage(analyseFlow, contrastFlow); double flow = calculatePercentage(analyseFlow, contrastFlow);
//取出分析时间的服务水平 //取出分析时间的服务水平
String analyseserviceLevel = getServiceLevel(ServiceLevelanalyseList); // String analyseserviceLevel = getServiceLevel(ServiceLevelanalyseList);
//取出对比时间的服务水平 //取出对比时间的服务水平
String compareServiceLevel = getServiceLevel(contrastServiceLevelList); // String compareServiceLevel = getServiceLevel(contrastServiceLevelList);
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("speed", speedChangePercent+"%"); //平均速度
jsonObject.put("delay",delayTimeChangePercent+"%"); jsonObject.put("speed", speedChangePercent + "%");
jsonObject.put("queueLength",queueLengthChangePercent+"%"); //平均延误
jsonObject.put("flow",flow+"%"); jsonObject.put("delay", delayTimeChangePercent + "%");
jsonObject.put("analyseserviceLevel",analyseserviceLevel); //平均排队时长
jsonObject.put("compareServiceLevel",compareServiceLevel); jsonObject.put("queueLength", queueLengthChangePercent + "%");
// 计算交通流量百分比
jsonObject.put("flow", flow + "%");
// jsonObject.put("analyseserviceLevel", analyseserviceLevel);
// jsonObject.put("compareServiceLevel", compareServiceLevel);
return jsonObject; return jsonObject;
}catch (Exception e){
log.error("{} getListEvaluationSummarize error", this.getClass().getSimpleName(), e);
throw e;
}
} }
/** /**
* 计算变化百分比 * 计算变化百分比
...@@ -134,6 +146,7 @@ public class EvaluationInfoServiceImpl extends ServiceImpl<CrossDataHistMapper, ...@@ -134,6 +146,7 @@ public class EvaluationInfoServiceImpl extends ServiceImpl<CrossDataHistMapper,
@Override @Override
public Map<String, Object> summaryEvaluation(String crossId, String startTime, String endTime, String contrastStartTime, String constrastEndTime) { public Map<String, Object> summaryEvaluation(String crossId, String startTime, String endTime, String contrastStartTime, String constrastEndTime) {
try {
//分析时间 //分析时间
List<TEventOptimizeInfo> overFlowList = crossProblemEvaluationMapper.getOverflow(crossId, startTime, endTime); List<TEventOptimizeInfo> overFlowList = crossProblemEvaluationMapper.getOverflow(crossId, startTime, endTime);
...@@ -199,14 +212,19 @@ public class EvaluationInfoServiceImpl extends ServiceImpl<CrossDataHistMapper, ...@@ -199,14 +212,19 @@ public class EvaluationInfoServiceImpl extends ServiceImpl<CrossDataHistMapper,
//对比的溢出优化次数 //对比的溢出优化次数
jsonObject.put("contrastOverFlowOptimize", contrastoverFlowTime); jsonObject.put("contrastOverFlowOptimize", contrastoverFlowTime);
//溢出次数分析对比计算 //溢出次数分析对比计算
jsonObject.put("OverFlowTimeCalculate", overFlowCishujisuan+ "%"); jsonObject.put("OverFlowTimeCalculate", overFlowCishujisuan + "%");
//溢出时长分析对比计算 //溢出时长分析对比计算
jsonObject.put("OverFlowHourCalculate", overFlowtimejisuan+ "%"); jsonObject.put("OverFlowHourCalculate", overFlowtimejisuan + "%");
//溢出平均延误 //溢出平均延误
jsonObject.put("OverFlowavgdelay", overFlowDelayjisuan+ "%"); jsonObject.put("OverFlowavgdelay", overFlowDelayjisuan + "%");
return jsonObject; return jsonObject;
} }
catch (Exception e){
log.error("{} summaryEvaluation error", this.getClass().getSimpleName(), e);
throw e;
}
}
/*失衡702 /*失衡702
...@@ -214,6 +232,7 @@ public class EvaluationInfoServiceImpl extends ServiceImpl<CrossDataHistMapper, ...@@ -214,6 +232,7 @@ public class EvaluationInfoServiceImpl extends ServiceImpl<CrossDataHistMapper,
* */ * */
@Override @Override
public Map<String, Object> unbalanceEvaluation(String crossId, String startTime, String endTime, String contrastStartTime, String constrastEndTime) { public Map<String, Object> unbalanceEvaluation(String crossId, String startTime, String endTime, String contrastStartTime, String constrastEndTime) {
try {
//分析时间 //分析时间
List<TEventOptimizeInfo> overFlowList = crossProblemEvaluationMapper.getOverflow(crossId, startTime, endTime); List<TEventOptimizeInfo> overFlowList = crossProblemEvaluationMapper.getOverflow(crossId, startTime, endTime);
...@@ -279,13 +298,17 @@ public class EvaluationInfoServiceImpl extends ServiceImpl<CrossDataHistMapper, ...@@ -279,13 +298,17 @@ public class EvaluationInfoServiceImpl extends ServiceImpl<CrossDataHistMapper,
//对比的失衡的优化次数 //对比的失衡的优化次数
jsonObject.put("contrastunbalanceTime", contrastunbalanceTime); jsonObject.put("contrastunbalanceTime", contrastunbalanceTime);
//失衡次数分析对比计算 //失衡次数分析对比计算
jsonObject.put("unbalanceCishucalculate", unbalanceCishujisuan+ "%"); jsonObject.put("unbalanceCishucalculate", unbalanceCishujisuan + "%");
//失衡时长分析对比计算 //失衡时长分析对比计算
jsonObject.put("unbalancetimecalculate", unbalancetimejisuan+ "%"); jsonObject.put("unbalancetimecalculate", unbalancetimejisuan + "%");
//失衡平均停车次数 //失衡平均停车次数
jsonObject.put("unbalanceStopTimescalculate", unbalanceStopTimesjisuan+ "%"); jsonObject.put("unbalanceStopTimescalculate", unbalanceStopTimesjisuan + "%");
return jsonObject; return jsonObject;
}catch (Exception e){
log.error("{} unbalanceEvaluation error", this.getClass().getSimpleName(), e);
throw e;
}
} }
/* /*
...@@ -294,6 +317,8 @@ public class EvaluationInfoServiceImpl extends ServiceImpl<CrossDataHistMapper, ...@@ -294,6 +317,8 @@ public class EvaluationInfoServiceImpl extends ServiceImpl<CrossDataHistMapper,
@Override @Override
public Map<String, Object> idleEvaluation(String crossId, String startTime, String endTime, String contrastStartTime, String constrastEndTime) { public Map<String, Object> idleEvaluation(String crossId, String startTime, String endTime, String contrastStartTime, String constrastEndTime) {
try {
//分析时间 //分析时间
List<TEventOptimizeInfo> overFlowList = crossProblemEvaluationMapper.getOverflow(crossId, startTime, endTime); List<TEventOptimizeInfo> overFlowList = crossProblemEvaluationMapper.getOverflow(crossId, startTime, endTime);
...@@ -310,7 +335,6 @@ public class EvaluationInfoServiceImpl extends ServiceImpl<CrossDataHistMapper, ...@@ -310,7 +335,6 @@ public class EvaluationInfoServiceImpl extends ServiceImpl<CrossDataHistMapper,
long dileTime = overFlowList.stream().filter(event -> "701".equals(event.getEventType()) && "1".equals(event.getOptStatus())).count(); long dileTime = overFlowList.stream().filter(event -> "701".equals(event.getEventType()) && "1".equals(event.getOptStatus())).count();
//对比时间空放优化次数 //对比时间空放优化次数
long contrastDileTime = contrastoverFlowList.stream().filter(event -> "701".equals(event.getEventType()) && "1".equals(event.getOptStatus())).count(); long contrastDileTime = contrastoverFlowList.stream().filter(event -> "701".equals(event.getEventType()) && "1".equals(event.getOptStatus())).count();
//分析空放时长 //分析空放时长
...@@ -360,14 +384,17 @@ public class EvaluationInfoServiceImpl extends ServiceImpl<CrossDataHistMapper, ...@@ -360,14 +384,17 @@ public class EvaluationInfoServiceImpl extends ServiceImpl<CrossDataHistMapper,
//对比的空放的优化次数 //对比的空放的优化次数
jsonObject.put("contrastDileTime", contrastDileTime); jsonObject.put("contrastDileTime", contrastDileTime);
//空放次数分析对比计算 //空放次数分析对比计算
jsonObject.put("dileCishucalculate", dileCishujisuan+ "%"); jsonObject.put("dileCishucalculate", dileCishujisuan + "%");
//空放时长分析对比计算 //空放时长分析对比计算
jsonObject.put("dileTimecalculate", dileTimejisuan+ "%"); jsonObject.put("dileTimecalculate", dileTimejisuan + "%");
//空放评价速度对比计算 //空放评价速度对比计算
jsonObject.put("dileSpeedcalculate", dileSpeedjisuan+ "%"); jsonObject.put("dileSpeedcalculate", dileSpeedjisuan + "%");
return jsonObject; return jsonObject;
}catch (Exception e){
log.error("{} idleEvaluation error", this.getClass().getSimpleName(), e);
throw e;
}
} }
} }
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