Commit 2d4f99d8 authored by duanruiming's avatar duanruiming

[update] 济南测试平台-常发性偶发性优化

parent 56882d8d
...@@ -7,6 +7,7 @@ import cn.hutool.core.util.ObjectUtil; ...@@ -7,6 +7,7 @@ import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import net.wanji.common.enums.*; import net.wanji.common.enums.*;
import net.wanji.common.utils.tool.CrossUtil; import net.wanji.common.utils.tool.CrossUtil;
import net.wanji.common.utils.tool.StringUtils;
import net.wanji.databus.bo.CrossIdBO; import net.wanji.databus.bo.CrossIdBO;
import net.wanji.databus.dao.entity.*; import net.wanji.databus.dao.entity.*;
import net.wanji.databus.dao.mapper.*; import net.wanji.databus.dao.mapper.*;
...@@ -42,6 +43,7 @@ import java.math.RoundingMode; ...@@ -42,6 +43,7 @@ import java.math.RoundingMode;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.*; import java.time.*;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit; import java.time.temporal.ChronoUnit;
import java.util.*; import java.util.*;
import java.util.function.Function; import java.util.function.Function;
...@@ -252,9 +254,8 @@ public class TrendServiceImpl implements TrendService { ...@@ -252,9 +254,8 @@ public class TrendServiceImpl implements TrendService {
Double congestionIndex = abnormalCrossListVO.getCongestionIndex(); Double congestionIndex = abnormalCrossListVO.getCongestionIndex();
double lastWeekIndex = getIndex(congestionIndex, crossId, batchTime - 604800); double lastWeekIndex = getIndex(congestionIndex, crossId, batchTime - 604800);
double lastPeriodIndex = getIndex(congestionIndex, crossId, batchTime - 300); double lastPeriodIndex = getIndex(congestionIndex, crossId, batchTime - 300);
abnormalCrossListVO.setLastWeekIndex(Math.floor(lastWeekIndex));
abnormalCrossListVO.setLastWeekIndex(lastWeekIndex); abnormalCrossListVO.setLastPeriodIndex(Math.floor(lastPeriodIndex));
abnormalCrossListVO.setLastPeriodIndex(lastPeriodIndex);
// 常发性偶发性 一个月内超过三次 // 常发性偶发性 一个月内超过三次
int frequent = getFrequent(crossId, batchTime); int frequent = getFrequent(crossId, batchTime);
...@@ -277,9 +278,23 @@ public class TrendServiceImpl implements TrendService { ...@@ -277,9 +278,23 @@ public class TrendServiceImpl implements TrendService {
LambdaQueryWrapper<CrossDataHistPO> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<CrossDataHistPO> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(CrossDataHistPO::getCrossId, crossId); queryWrapper.eq(CrossDataHistPO::getCrossId, crossId);
queryWrapper.between(CrossDataHistPO::getBatchTime, batchTime - 30 * 86400 , batchTime); queryWrapper.between(CrossDataHistPO::getBatchTime, batchTime - 30 * 86400 , batchTime);
queryWrapper.eq(CrossDataHistPO::getIsCongestion, 1);
List<CrossDataHistPO> crossDataHistPOS = crossDataHistMapper.selectList(queryWrapper); List<CrossDataHistPO> crossDataHistPOS = crossDataHistMapper.selectList(queryWrapper);
int frequent = crossDataHistPOS.size() > 3 ? 1 : 0; List<CrossDataHistPO> result = new ArrayList<>();
return frequent; for (CrossDataHistPO crossDataHistPO : crossDataHistPOS) {
Date startTime = crossDataHistPO.getStartTime();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm");
LocalTime localTime = startTime.toInstant().atZone(ZoneId.of("Asia/Shanghai")).toLocalTime();
if ((localTime.isAfter(LocalTime.parse("06:30", formatter))
&& localTime.isBefore(LocalTime.parse("09:30", formatter))
&& StringUtils.equalsIgnoreCase(crossId, crossDataHistPO.getCrossId())) ||
(localTime.isAfter(LocalTime.parse("16:30", formatter))
&& localTime.isBefore(LocalTime.parse("19:30", formatter))
&& StringUtils.equalsIgnoreCase(crossId, crossDataHistPO.getCrossId()))) {
result.add(crossDataHistPO);
}
}
return result.size() > 3 ? 1 : 0;
} }
private double getIndex(Double congestionIndex, String crossId, Integer batchTime) { private double getIndex(Double congestionIndex, String crossId, Integer batchTime) {
......
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