| | |
| | | package com.ycl.platform.service.impl; |
| | | |
| | | import com.ycl.platform.controller.YwThresholdController; |
| | | import com.ycl.platform.domain.entity.WorkOrder; |
| | | import com.ycl.platform.domain.entity.YwThreshold; |
| | | import com.ycl.platform.domain.result.HK.SnapshotDataMonitorResult; |
| | | import com.ycl.platform.domain.result.UY.*; |
| | | import com.ycl.platform.mapper.WorkOrderMapper; |
| | | import com.ycl.platform.service.IYwThresholdService; |
| | | import com.ycl.platform.service.UYErrorTypeCheckService; |
| | | import com.ycl.platform.service.WorkOrderService; |
| | | import com.ycl.utils.DateUtils; |
| | | import com.ycl.utils.uuid.IdUtils; |
| | | import constant.ApiConstants; |
| | | import constant.YwThreadConstants; |
| | | import enumeration.CompareType; |
| | | import enumeration.ErrorType; |
| | | import enumeration.general.BusinessTypeEnum; |
| | | import enumeration.general.WorkOrderStatusEnum; |
| | | import lombok.Data; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | @Slf4j |
| | | public class UYErrorTypeCheckServiceImpl implements UYErrorTypeCheckService { |
| | | |
| | | private final WorkOrderService workOrderService; |
| | | private final IYwThresholdService ywThresholdService; |
| | | private final WorkOrderMapper workOrderMapper; |
| | | |
| | | /** |
| | | * 图像检测生成工单 |
| | |
| | | */ |
| | | @Override |
| | | public void imageDetectionCheck(List<ImageDetectionResult> dataList) { |
| | | List<WorkOrder> workOrderList = dataList.stream().filter(item -> 0 == item.getSigna1() |
| | | || 0 == item.getColor() |
| | | || 0 == item.getSnow() |
| | | || 0 == item.getStripe() |
| | | || 0 == item.getShade() |
| | | || 0 == item.getBlur() |
| | | || 0 == item.getLight() |
| | | ) |
| | | .map(item -> { |
| | | WorkOrder workOrder = new WorkOrder(); |
| | | // 信号缺失 |
| | | if (0 == item.getSigna1() ) { |
| | | this.genWorkOrder(workOrder, ErrorType.SIGNAL_LOSS, item.getDeviceId()); |
| | | } |
| | | // 画面偏色 |
| | | if ( 0 == item.getColor()) { |
| | | this.genWorkOrder(workOrder, ErrorType.SCREEN_COLOR_DEVIATION, item.getDeviceId()); |
| | | } |
| | | // 雪花干扰 |
| | | if ( 0 == item.getSnow()) { |
| | | this.genWorkOrder(workOrder, ErrorType.SNOW_STORM, item.getDeviceId()); |
| | | } |
| | | // 条纹干扰 |
| | | if (0 == item.getStripe()) { |
| | | this.genWorkOrder(workOrder, ErrorType.STRIPE_INTERFERENCE, item.getDeviceId()); |
| | | } |
| | | // 画面遮挡 |
| | | if (0 == item.getShade()) { |
| | | this.genWorkOrder(workOrder, ErrorType.SCREEN_OCCLUSION, item.getDeviceId()); |
| | | } |
| | | // 清晰度异常 |
| | | if (0 == item.getBlur()) { |
| | | this.genWorkOrder(workOrder, ErrorType.ABNORMAL_CLARITY, item.getDeviceId()); |
| | | } |
| | | // 亮度异常 |
| | | if (0 == item.getLight()) { |
| | | this.genWorkOrder(workOrder, ErrorType.ABNORMAL_BRIGHTNESS, item.getDeviceId()); |
| | | } |
| | | return workOrder; |
| | | }).collect(Collectors.toList()); |
| | | List<WorkOrder> workOrderList = dataList.stream().filter(item -> -1 == item.getSignal() |
| | | || -1 == item.getImage() |
| | | ) |
| | | .map(item -> { |
| | | WorkOrder workOrder = new WorkOrder(); |
| | | // 信号缺失 |
| | | if (-1 == item.getSigna1()) { |
| | | this.genWorkOrder(workOrder, ErrorType.ABNORMAL_PIC, item.getDeviceId()); |
| | | } |
| | | // 画面偏色 |
| | | if (-1 == item.getColor()) { |
| | | this.genWorkOrder(workOrder, ErrorType.ABNORMAL_PIC, item.getDeviceId()); |
| | | } |
| | | // 雪花干扰 |
| | | if (-1 == item.getSnow()) { |
| | | this.genWorkOrder(workOrder, ErrorType.ABNORMAL_PIC, item.getDeviceId()); |
| | | } |
| | | // 条纹干扰 |
| | | if (-1 == item.getStripe()) { |
| | | this.genWorkOrder(workOrder, ErrorType.ABNORMAL_PIC, item.getDeviceId()); |
| | | } |
| | | // 画面遮挡 |
| | | if (-1 == item.getShade()) { |
| | | this.genWorkOrder(workOrder, ErrorType.ABNORMAL_PIC, item.getDeviceId()); |
| | | } |
| | | // 清晰度异常 |
| | | if (-1 == item.getBlur()) { |
| | | this.genWorkOrder(workOrder, ErrorType.ABNORMAL_PIC, item.getDeviceId()); |
| | | } |
| | | // // 亮度异常 |
| | | // if (-1 == item.getLight()) { |
| | | // this.genWorkOrder(workOrder, ErrorType.ABNORMAL_BRIGHTNESS, item.getDeviceId()); |
| | | // } |
| | | return workOrder; |
| | | }).collect(Collectors.toList()); |
| | | workOrderService.innerAddWorkOrder(workOrderList); |
| | | } |
| | | |
| | |
| | | public void monitorQualifyCheck(List<MonitorQualifyResult> dataList) { |
| | | List<WorkOrder> workOrderList = dataList.stream().map(item -> { |
| | | WorkOrder workOrder = new WorkOrder(); |
| | | if (item.getSerialNumber().getError() |
| | | || item.getCivilCode().getError() |
| | | || item.getIntegrated_device().getError() |
| | | || item.getIp().getError() |
| | | || item.getJkdwlx().getError() |
| | | || item.getLatitude().getError() |
| | | || item.getLongitude().getError() |
| | | || item.getMacdz().getError() |
| | | || item.getSbzt().getError() |
| | | || item.getName().getError() |
| | | || item.getSxjcjqy().getError() |
| | | || item.getSxjgnlx().getError()) { |
| | | //TODO:待优云修复,避免工单 |
| | | MonitorQualifyResult.QualifyResult qualifyResult = new MonitorQualifyResult.QualifyResult(); |
| | | qualifyResult.setError(false); |
| | | item.setIntegrated_device(qualifyResult); |
| | | if (item.getSerialNumber() == null || item.getSerialNumber().getError() || |
| | | item.getCivilCode() == null || item.getCivilCode().getError() || |
| | | item.getIntegrated_device() == null || item.getIntegrated_device().getError() || |
| | | item.getIp() == null || item.getIp().getError() || |
| | | item.getJkdwlx() == null || item.getJkdwlx().getError() || |
| | | item.getLatitude() == null || item.getLatitude().getError() || |
| | | item.getLongitude() == null || item.getLongitude().getError() || |
| | | item.getMacdz() == null || item.getMacdz().getError() || |
| | | item.getSbzt() == null || item.getSbzt().getError() || |
| | | item.getName() == null || item.getName().getError() || |
| | | item.getSxjcjqy() == null || item.getSxjcjqy().getError() || |
| | | item.getSxjgnlx() == null || item.getSxjgnlx().getError()) { |
| | | this.genWorkOrder(workOrder, ErrorType.POINT_INFO_ERROR, item.getSerialNumber().getValue()); |
| | | } |
| | | return workOrder; |
| | |
| | | |
| | | @Override |
| | | public void videoOnlineCheck(List<VideoOnlineResult> dataList) { |
| | | List<WorkOrder> workOrderList = dataList.stream().map(item -> { |
| | | WorkOrder workOrder = new WorkOrder(); |
| | | if (-1 == item.getStatus()) { |
| | | this.genWorkOrder(workOrder, ErrorType.DEVICE_OFFLINE, item.getDeviceId()); |
| | | } else if (0 == item.getStatus()) { |
| | | this.genWorkOrder(workOrder, ErrorType.UNKNOWN, item.getDeviceId()); |
| | | } |
| | | return workOrder; |
| | | }).collect(Collectors.toList()); |
| | | //查询数据库已存在的离线工单获取ip集合,剔除 |
| | | List<String> ips = workOrderMapper.getOfflineWorkOrder(); |
| | | List<WorkOrder> workOrderList = dataList.stream() |
| | | .filter(item -> CollectionUtils.isEmpty(ips) || !ips.contains(item.getIpAddr())) |
| | | .map(item -> { |
| | | WorkOrder workOrder = new WorkOrder(); |
| | | if (ApiConstants.UY_OnlineSite_Offline.equals(item.getStatus())) { |
| | | this.genWorkOrder(workOrder, ErrorType.DEVICE_OFFLINE, item.getDeviceId()); |
| | | } |
| | | return workOrder; |
| | | }).collect(Collectors.toList()); |
| | | workOrderService.innerAddWorkOrder(workOrderList); |
| | | } |
| | | |
| | | @Override |
| | | public void hkOnlineCheck(List<SnapshotDataMonitorResult> dataList) { |
| | | //查询数据库已存在的离线工单获取ip集合,剔除 |
| | | List<String> ips = workOrderMapper.getOfflineWorkOrder(); |
| | | List<WorkOrder> workOrderList = dataList.stream() |
| | | .filter(item -> CollectionUtils.isEmpty(ips) || !ips.contains(item.getIp())) |
| | | .map(item -> { |
| | | WorkOrder workOrder = new WorkOrder(); |
| | | this.genWorkOrder(workOrder, ErrorType.DEVICE_OFFLINE, item.getExternalIndexCode()); |
| | | return workOrder; |
| | | }).collect(Collectors.toList()); |
| | | workOrderService.innerAddWorkOrder(workOrderList); |
| | | } |
| | | |
| | | @Override |
| | | public void recordMetaDSumCheck(List<RecordMetaDSumResult> dataList) { |
| | | List<WorkOrder> workOrderList = dataList.stream().map(item -> { |
| | | WorkOrder workOrder = new WorkOrder(); |
| | | if (0 == item.getRecordStatus()) { |
| | | this.genWorkOrder(workOrder, ErrorType.VIDEO_LOSS, item.getDeviceId()); |
| | | } else if (-1 == item.getRecordStatus()) { |
| | | this.genWorkOrder(workOrder, ErrorType.VIDEO_NONE, item.getDeviceId()); |
| | | } |
| | | return workOrder; |
| | | }).collect(Collectors.toList()); |
| | | workOrderService.innerAddWorkOrder(workOrderList); |
| | | // List<WorkOrder> workOrderList = dataList.stream().map(item -> { |
| | | // WorkOrder workOrder = new WorkOrder(); |
| | | // if (0 == item.getRecordStatus()) { |
| | | // this.genWorkOrder(workOrder, ErrorType.VIDEO_LOSS, item.getDeviceId()); |
| | | // } else if (-1 == item.getRecordStatus()) { |
| | | // this.genWorkOrder(workOrder, ErrorType.VIDEO_NONE, item.getDeviceId()); |
| | | // } |
| | | // return workOrder; |
| | | // }).collect(Collectors.toList()); |
| | | // workOrderService.innerAddWorkOrder(workOrderList); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void osdCheck(List<OsdCheckResult> dataList) { |
| | | Map<String, YwThreshold> ywThresholdMap = ywThresholdService.getYwThresholdMap(BusinessTypeEnum.VIDEO.name()); |
| | | List<WorkOrder> workOrderList = dataList.stream().map(item -> { |
| | | WorkOrder workOrder = new WorkOrder(); |
| | | // osd时间 |
| | | if (!ApiConstants.OSD_Correct.equals(item.getOsdTimeCorrect())) { |
| | | this.genWorkOrder(workOrder, ErrorType.CLOCK_SKEW, item.getDeviceNo()); |
| | | } |
| | | // osd信息 |
| | | if (!ApiConstants.OSD_Correct.equals(item.getOsdProvinceCorrect()) |
| | | || (!ApiConstants.OSD_Correct.equals(item.getOsdCityCorrect())) |
| | |
| | | ) { |
| | | this.genWorkOrder(workOrder, ErrorType.OSD_ERROR, item.getDeviceNo()); |
| | | } |
| | | // osd时间 时间需要走阈值检查 这里需要把时间放在后面:如果时间处于待下发的阈值那么工单状态会改为待下发的工单 |
| | | // if (!ApiConstants.OSD_Correct.equals(item.getOsdTimeCorrect())) { |
| | | // this.genWorkOrder(workOrder, ErrorType.CLOCK_SKEW, item.getDeviceNo()); |
| | | // } |
| | | long checkTime = item.getCheckTime().getTime(); |
| | | long osdTime = item.getSetTime().getTime(); |
| | | Long timeDiff = Math.abs((checkTime - osdTime) / 1000); |
| | | ywThresholdService.check(YwThreadConstants.Video_DiffTime, timeDiff, item.getDeviceNo(), ywThresholdMap, workOrder, CompareType.MORE_THAN_EQ, ErrorType.CLOCK_SKEW.getValue()); |
| | | return workOrder; |
| | | }).collect(Collectors.toList()); |
| | | |
| | | log.error("osdCheck获得插入工单:{}",workOrderList); |
| | | workOrderService.innerAddWorkOrder(workOrderList); |
| | | } |
| | | |
| | |
| | | * 工单信息 |
| | | * |
| | | * @param workOrder |
| | | * @param errorType 故障类型 |
| | | * @param errorType 故障类型 |
| | | * @param serialNumber 国标码 |
| | | */ |
| | | private void genWorkOrder(WorkOrder workOrder, ErrorType errorType, String serialNumber) { |
| | | if (! StringUtils.hasText(workOrder.getWorkOrderNo())) { |
| | | workOrder.setWorkOrderNo(IdUtils.randomNO()); |
| | | } |
| | | if (CollectionUtils.isEmpty(workOrder.getErrorTypeList())) { |
| | | workOrder.setErrorTypeList(new ArrayList<>()); |
| | | workOrder.getErrorTypeList().add(errorType.getValue()); |