| | |
| | | package com.ycl.platform.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ycl.platform.domain.entity.WorkOrder; |
| | | import com.ycl.platform.domain.entity.YwThreshold; |
| | | import com.ycl.platform.domain.result.HK.VehicleDeviceInspectionResult; |
| | | import com.ycl.platform.mapper.WorkOrderMapper; |
| | | import com.ycl.platform.mapper.YwThresholdMapper; |
| | | import com.ycl.platform.service.IYwThresholdService; |
| | | import constant.CompareConstant; |
| | | import constant.YwThreadConstants; |
| | | import enumeration.general.BusinessTypeEnum; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import utils.DateUtils; |
| | | |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | |
| | | * @date 2024-07-19 |
| | | */ |
| | | @Service |
| | | public class YwThresholdServiceImpl extends ServiceImpl<YwThresholdMapper, YwThreshold> implements IYwThresholdService |
| | | { |
| | | public class YwThresholdServiceImpl extends ServiceImpl<YwThresholdMapper, YwThreshold> implements IYwThresholdService { |
| | | @Autowired |
| | | private YwThresholdMapper ywThresholdMapper; |
| | | |
| | |
| | | * @return 运维阈值 |
| | | */ |
| | | @Override |
| | | public YwThreshold selectYwThresholdById(Long id) |
| | | { |
| | | public YwThreshold selectYwThresholdById(Long id) { |
| | | return ywThresholdMapper.selectYwThresholdById(id); |
| | | } |
| | | |
| | |
| | | * @return 运维阈值 |
| | | */ |
| | | @Override |
| | | public Map<String, List<YwThreshold>> selectYwThresholdList(YwThreshold ywThreshold) |
| | | { |
| | | public Map<String, List<YwThreshold>> selectYwThresholdList(YwThreshold ywThreshold) { |
| | | List<YwThreshold> ywThresholds = ywThresholdMapper.selectYwThresholdList(ywThreshold); |
| | | Map<String, List<YwThreshold>> map = ywThresholds.stream().collect(Collectors.groupingBy(YwThreshold::getMonitorType)); |
| | | return map; |
| | |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int insertYwThreshold(YwThreshold ywThreshold) |
| | | { |
| | | public int insertYwThreshold(YwThreshold ywThreshold) { |
| | | ywThreshold.setCreateTime(DateUtils.getNowDate()); |
| | | return ywThresholdMapper.insertYwThreshold(ywThreshold); |
| | | } |
| | |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public Boolean updateYwThreshold(List<YwThreshold> list) |
| | | { |
| | | public Boolean updateYwThreshold(List<YwThreshold> list) { |
| | | list.forEach(item -> item.setCreateTime(new Date())); |
| | | return updateBatchById(list); |
| | | } |
| | |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int deleteYwThresholdByIds(Long[] ids) |
| | | { |
| | | public int deleteYwThresholdByIds(Long[] ids) { |
| | | return ywThresholdMapper.deleteYwThresholdByIds(ids); |
| | | } |
| | | |
| | |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int deleteYwThresholdById(Long id) |
| | | { |
| | | public int deleteYwThresholdById(Long id) { |
| | | return ywThresholdMapper.deleteYwThresholdById(id); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void faceCheck(List list) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void videoCheck(List list) { |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 判断车辆阈值是否满足下发条件 |
| | | * |
| | | * @param list |
| | | */ |
| | | @Override |
| | | public void carCheck(List<VehicleDeviceInspectionResult> list) { |
| | | QueryWrapper<YwThreshold> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("monitor_type", BusinessTypeEnum.CAR.name()); |
| | | List<YwThreshold> ywThresholds = ywThresholdMapper.selectList(wrapper); |
| | | Map<String, YwThreshold> map = new HashMap<>(); |
| | | for (YwThreshold ywThreshold : ywThresholds) { |
| | | String key = ywThreshold.getKey(); |
| | | map.put(key, ywThreshold); |
| | | } |
| | | //时钟准确率阈值 |
| | | Float clockPercent = Float.valueOf(map.get(YwThreadConstants.Car_ClockPercent).getValue()); |
| | | Float clockPercentAuto = Float.valueOf(map.get(YwThreadConstants.Car_ClockPercent).getValueAuto()); |
| | | //数据及时率阈值 |
| | | Float timelyPercent = Float.valueOf(map.get(YwThreadConstants.Car_TimelyPercent).getValue()); |
| | | Float timelyPercentAuto = Float.valueOf(map.get(YwThreadConstants.Car_TimelyPercent).getValueAuto()); |
| | | //持续无数据天数阈值 |
| | | Integer continueNoDataCount = Integer.valueOf(map.get(YwThreadConstants.Car_ContinueNoDataCount).getValue()); |
| | | Integer continueNoDataCountAuto = Integer.valueOf(map.get(YwThreadConstants.Car_ContinueNoDataCount).getValueAuto()); |
| | | //不唯一数据量阈值 |
| | | Integer nouniqueCount = Integer.valueOf(map.get(YwThreadConstants.Car_NouniqueCount).getValue()); |
| | | Integer nouniqueCountAuto = Integer.valueOf(map.get(YwThreadConstants.Car_NouniqueCount).getValueAuto()); |
| | | //白天未识别量阈值 |
| | | Integer dayNoNumberCount = Integer.valueOf(map.get(YwThreadConstants.Car_DayNoNumberCount).getValue()); |
| | | Integer dayNoNumberCountAuto = Integer.valueOf(map.get(YwThreadConstants.Car_DayNoNumberCount).getValueAuto()); |
| | | //车辆六项属性不完整量阈值 |
| | | Integer noIntegrityCount = Integer.valueOf(map.get(YwThreadConstants.Car_NoIntegrityCount).getValue()); |
| | | Integer noIntegrityCountAuto = Integer.valueOf(map.get(YwThreadConstants.Car_NoIntegrityCount).getValueAuto()); |
| | | |
| | | //处理接口数据 |
| | | for (VehicleDeviceInspectionResult result : list) { |
| | | if (result == null) { |
| | | log.error("车辆对象数据为空"); |
| | | continue; |
| | | } |
| | | //检查持续无数据天数 |
| | | Integer continueNoDataCountResult = result.getContinueNoDataCount(); |
| | | check(continueNoDataCount, continueNoDataCountAuto, result, continueNoDataCountResult, "车辆持续无数据天数为空", CompareConstant.MoreThanEq); |
| | | //检查时钟准确率 |
| | | Float clockPercentResult = result.getSnapClock().getClockPercent(); |
| | | check(clockPercent, clockPercentAuto, result, clockPercentResult, "车辆时钟准确率为空", CompareConstant.LessThanEq); |
| | | //检查数据及时率 |
| | | Float timelyPercentResult = result.getSnapTimely().getTimelyPercent(); |
| | | check(timelyPercent, timelyPercentAuto, result, timelyPercentResult, "车辆数据及时率为空", CompareConstant.LessThanEq); |
| | | //检查不唯一数据量 |
| | | Integer nouniqueCountResult = result.getSnapUnique().getNouniqueCount(); |
| | | check(nouniqueCount, nouniqueCountAuto, result, nouniqueCountResult, "车辆不唯一数据量为空", CompareConstant.MoreThanEq); |
| | | //检查白天未识别量 |
| | | Integer dayNoNumberCountResult = result.getSnapPlate().getDayNoNumberCount(); |
| | | check(dayNoNumberCount, dayNoNumberCountAuto, result, dayNoNumberCountResult, "车辆白天未识别量为空", CompareConstant.MoreThanEq); |
| | | //车辆六项属性不完整量 |
| | | Integer noIntegrityCountResult = result.getIntegrity().getNoIntegrityCount(); |
| | | check(noIntegrityCount, noIntegrityCountAuto, result, noIntegrityCountResult, "车辆六项属性不完整量为空", CompareConstant.MoreThanEq); |
| | | } |
| | | |
| | | } |
| | | |
| | | private void check(Integer threshold, Integer thresholdAuto, VehicleDeviceInspectionResult result, Integer thresholdResult, String message, String command) { |
| | | if (thresholdResult != null) { |
| | | //大于类型 |
| | | if (CompareConstant.MoreThanEq.equals(command)) { |
| | | if (thresholdResult >= thresholdAuto) { |
| | | //TODO:自动下发工单 |
| | | } else if (thresholdResult >= threshold) { |
| | | //TODO:进入下发工单页面 |
| | | } |
| | | } else if (CompareConstant.LessThanEq.equals(command)) { |
| | | //小于类型 |
| | | if (thresholdResult <= thresholdAuto) { |
| | | //TODO:自动下发工单 |
| | | } else if (thresholdResult <= threshold) { |
| | | //TODO:进入下发工单页面 |
| | | } |
| | | } |
| | | } else { |
| | | log.error(message + result); |
| | | } |
| | | } |
| | | |
| | | private void check(Float threshold, Float thresholdAuto, VehicleDeviceInspectionResult result, Float thresholdResult, String message, String command) { |
| | | if (thresholdResult != null) { |
| | | //大于类型 |
| | | if (CompareConstant.MoreThanEq.equals(command)) { |
| | | if (thresholdResult >= thresholdAuto) { |
| | | //TODO:自动下发工单 |
| | | } else if (thresholdResult >= threshold) { |
| | | //TODO:进入下发工单页面 |
| | | } |
| | | } else if (CompareConstant.LessThanEq.equals(command)) { |
| | | //小于类型 |
| | | if (thresholdResult <= thresholdAuto) { |
| | | //TODO:自动下发工单 |
| | | } else if (thresholdResult <= threshold) { |
| | | //TODO:进入下发工单页面 |
| | | } |
| | | } |
| | | } else { |
| | | log.error(message + result); |
| | | } |
| | | } |
| | | } |