fuliqi
2024-07-22 77ce942a696de881cc703745b8b1d112ddb70fa5
车辆数据阈值检查接口
4个文件已修改
2个文件已添加
216 ■■■■■ 已修改文件
ycl-common/src/main/java/constant/CompareConstant.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-common/src/main/java/constant/YwThreadConstants.java 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-server/src/main/java/com/ycl/platform/mapper/YwThresholdMapper.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-server/src/main/java/com/ycl/platform/service/IYwThresholdService.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-server/src/main/java/com/ycl/platform/service/impl/YwThresholdServiceImpl.java 144 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-server/src/main/java/com/ycl/task/HKTask.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-common/src/main/java/constant/CompareConstant.java
New file
@@ -0,0 +1,13 @@
package constant;
//比较类型
public class CompareConstant {
    /**
     * 大于等于
     */
    public static final String MoreThanEq = "moreThanEq";
    /**
     * 小于等于
     */
    public static final String LessThanEq = "lessThanEq";
}
ycl-common/src/main/java/constant/YwThreadConstants.java
New file
@@ -0,0 +1,32 @@
package constant;
/**
 * 阈值常量
 */
public class YwThreadConstants {
    public static final String Car_ClockPercent = "时钟准确率";
    public static final String Car_TimelyPercent = "数据及时率";
    public static final String Car_DayNoNumberCount = "车辆未识别量";
    public static final String Car_NouniqueCount = "不唯一数据量";
    public static final String Car_NoIntegrityCount = "车辆六项属性不完整量";
    public static final String Car_ContinueNoDataCount = "持续无数据天数";
    public static final String Face_ClockPercent = "时钟准确率";
    public static final String Face_TimelyPercent = "数据及时率";
    public static final String Face_NouniqueCount = "不唯一数据量";
    public static final String Face_FailPercent = "建模失败率";
    public static final String Face_LowScorePercent = "平均人脸低平分率";
    public static final String Face_ContinueNoDataCount = "持续无数据天数";
    public static final String Video_Blur = "模糊分值";
    public static final String Video_Color = "颜色分值";
    public static final String Video_Light = "亮度分值";
    public static final String Video_Shade = "遮挡分值";
    public static final String Video_Shake = "抖动分值";
    public static final String Video_Snow = "雪花分值";
    public static final String Video_stripe = "条纹分值";
    public static final String Video_signal = "信号分值";
    public static final String Video_diffTime = "标注时间差";
}
ycl-server/src/main/java/com/ycl/platform/mapper/YwThresholdMapper.java
@@ -61,8 +61,4 @@
     */
    public int deleteYwThresholdByIds(Long[] ids);
    /**
     * 根据设备类型获取运维阈值
     */
    public List<YwThreshold> selectByType(String type);
}
ycl-server/src/main/java/com/ycl/platform/service/IYwThresholdService.java
@@ -2,6 +2,7 @@
import com.baomidou.mybatisplus.extension.service.IService;
import com.ycl.platform.domain.entity.YwThreshold;
import com.ycl.platform.domain.result.HK.VehicleDeviceInspectionResult;
import java.util.List;
import java.util.Map;
@@ -61,4 +62,19 @@
     * @return 结果
     */
    public int deleteYwThresholdById(Long id);
    /**
     * 判断车辆阈值条件
     */
    public void carCheck(List<VehicleDeviceInspectionResult> list);
    /**
     * 判断人脸阈值条件
     */
    public void faceCheck(List list);
    /**
     * 判断视频阈值条件
     */
    public void videoCheck(List list);
}
ycl-server/src/main/java/com/ycl/platform/service/impl/YwThresholdServiceImpl.java
@@ -1,16 +1,22 @@
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;
@@ -22,8 +28,7 @@
 * @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;
@@ -34,8 +39,7 @@
     * @return 运维阈值
     */
    @Override
    public YwThreshold selectYwThresholdById(Long id)
    {
    public YwThreshold selectYwThresholdById(Long id) {
        return ywThresholdMapper.selectYwThresholdById(id);
    }
@@ -46,8 +50,7 @@
     * @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;
@@ -60,8 +63,7 @@
     * @return 结果
     */
    @Override
    public int insertYwThreshold(YwThreshold ywThreshold)
    {
    public int insertYwThreshold(YwThreshold ywThreshold) {
        ywThreshold.setCreateTime(DateUtils.getNowDate());
        return ywThresholdMapper.insertYwThreshold(ywThreshold);
    }
@@ -73,8 +75,7 @@
     * @return 结果
     */
    @Override
    public Boolean updateYwThreshold(List<YwThreshold> list)
    {
    public Boolean updateYwThreshold(List<YwThreshold> list) {
        list.forEach(item -> item.setCreateTime(new Date()));
        return updateBatchById(list);
    }
@@ -86,8 +87,7 @@
     * @return 结果
     */
    @Override
    public int deleteYwThresholdByIds(Long[] ids)
    {
    public int deleteYwThresholdByIds(Long[] ids) {
        return ywThresholdMapper.deleteYwThresholdByIds(ids);
    }
@@ -98,8 +98,124 @@
     * @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 name = ywThreshold.getName();
            map.put(name, 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);
        }
    }
}
ycl-server/src/main/java/com/ycl/task/HKTask.java
@@ -7,6 +7,7 @@
import com.ycl.platform.domain.result.HK.FaceDeviceInspectionResult;
import com.ycl.platform.domain.result.HK.VehicleDeviceInspectionResult;
import com.ycl.platform.mapper.YwThresholdMapper;
import com.ycl.platform.service.IYwThresholdService;
import com.ycl.web.HKClient;
import enumeration.BusinessType;
import enumeration.general.BusinessTypeEnum;
@@ -30,7 +31,7 @@
    @Autowired
    private HKClient hkClient;
    @Autowired
    private YwThresholdMapper thresholdMapper;
    private IYwThresholdService ywThresholdService;
    private final static Integer pageNo = 1;
    private final static Integer pageSize = 5000;
@@ -53,10 +54,10 @@
            if (CollectionUtils.isEmpty(list)) {
                throw new RuntimeException("车辆设备全检指标监测结果数据为空");
            }
            //TODO:同步的数据可能需要工单阈值等处理
            List<YwThreshold> ywThresholds = thresholdMapper.selectByType(BusinessTypeEnum.CAR.name());
            //存放在mongo中
            mongoTemplate.insert(list);
            //同步的数据进行工单阈值处理
            ywThresholdService.carCheck(list);
        } else {
            log.error("同步车辆设备全检指标监测结果失败", jsonObject);
        }