| | |
| | | public final static Integer UY_OnlineStatus_Offline = -1; |
| | | public final static Integer UY_OnlineStatus_Unknown = 0; |
| | | |
| | | //Python校验标识 |
| | | public final static Integer PY_OSD_Correct = 1; |
| | | public final static Integer PY_OSD_Unknown = 0; |
| | | public final static Integer PY_OSD_Error = -1; |
| | | //OSD校验标识 |
| | | public final static Integer OSD_Correct = 1; |
| | | public final static Integer OSD_Unknown = 0; |
| | | public final static Integer OSD_Error = -1; |
| | | |
| | | //自贡行政编码 |
| | | public final static String AreaNo = "5103"; |
| | |
| | | //省厅前缀 |
| | | public final static String Province = "Province_"; |
| | | |
| | | |
| | | //海康访问OSD路径 |
| | | public final static String HK_OSD_PATH = "/ISAPI/System/Video/inputs/channels/1/overlays"; |
| | | //海康访问时间路径 |
| | | public final static String HK_OSD_TIME = "/ISAPI/System/time"; |
| | | |
| | | |
| | | } |
| | |
| | | */ |
| | | @Getter |
| | | public enum AreaDeptEnum { |
| | | ZLJQ("自流井区", "510302", 201), |
| | | GJQ("贡井区", "510303", 202), |
| | | DAQ("大安区", "510304", 102), |
| | | YTQ("沿滩区", "510311", 211), |
| | | ZLJQ("自流井", "510302", 201), |
| | | GJQ("贡井", "510303", 202), |
| | | DAQ("大安", "510304", 102), |
| | | YTQ("沿滩", "510311", 211), |
| | | RX("荣县", "510321", 203), |
| | | FSX("富顺县", "510322", 101), |
| | | GXQ("高新区", "510399", 210), |
| | | FSX("富顺", "510322", 101), |
| | | GXQ("高新", "510399", 210), |
| | | ; |
| | | |
| | | private final String name; |
| | |
| | | package com.ycl.platform.base; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import enumeration.ContractStatus; |
| | | import lombok.Data; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 基础响应 |
| | |
| | | |
| | | import annotation.Excel; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ycl.system.entity.BaseEntity; |
| | | import lombok.Data; |
New file |
| | |
| | | package com.ycl.platform.domain.result; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.util.Date; |
| | | |
| | | @Data |
| | | public class OSDResult { |
| | | /** |
| | | * 设备编号 |
| | | */ |
| | | private String serialNumber; |
| | | /** |
| | | * 设备时间 |
| | | */ |
| | | private Date osdTime; |
| | | /** |
| | | * 检测时间 |
| | | */ |
| | | private Date checkTime; |
| | | //osd右下按顺序 |
| | | /** |
| | | * 省份 |
| | | */ |
| | | private String OSD1; |
| | | /** |
| | | * 城市 |
| | | */ |
| | | private String OSD2; |
| | | /** |
| | | * 区县 |
| | | */ |
| | | private String OSD3; |
| | | /** |
| | | * 通道名(monitor的设备名) |
| | | */ |
| | | private String name; |
| | | |
| | | //osd左下 |
| | | /** |
| | | * 固、枪、路、西北 |
| | | */ |
| | | private String OSD4; |
| | | } |
New file |
| | |
| | | package com.ycl.platform.domain.result.UY; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ycl.platform.domain.result.BaseResult; |
| | | import lombok.Data; |
| | | import org.springframework.data.mongodb.core.annotation.Collation; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * python获取osd数据 |
| | | * |
| | | * @author:xp |
| | | * @date:2024/8/8 19:35 |
| | | */ |
| | | @Data |
| | | @Collation("osd_check_result") |
| | | public class OsdCheckResult extends BaseResult { |
| | | |
| | | /** |
| | | * 国标码 |
| | | */ |
| | | private String deviceNo; |
| | | |
| | | /** |
| | | * 设备类型 |
| | | */ |
| | | private String deviceType; |
| | | |
| | | /** |
| | | * ip |
| | | */ |
| | | private String ip; |
| | | |
| | | /** |
| | | * 检测时间 |
| | | */ |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date checkTime; |
| | | |
| | | /** |
| | | * 标注时间 |
| | | */ |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date setTime; |
| | | |
| | | /** |
| | | * osd通道名 |
| | | */ |
| | | private String osdName; |
| | | /** |
| | | * osd省 |
| | | */ |
| | | private String osdProvince; |
| | | |
| | | /** |
| | | * osd市 |
| | | */ |
| | | private String osdCity; |
| | | |
| | | /** |
| | | * osd区 |
| | | */ |
| | | private String osdPart; |
| | | |
| | | /** |
| | | * osd 左下角 |
| | | */ |
| | | private String osdLB; |
| | | |
| | | /** |
| | | * osdTimeCorrect时间是否正确 |
| | | */ |
| | | private Integer osdTimeCorrect; |
| | | |
| | | /** |
| | | * osd通道名是否正确 |
| | | */ |
| | | private Integer osdNameCorrect; |
| | | /** |
| | | * osd省是否正确 |
| | | */ |
| | | private Integer osdProvinceCorrect; |
| | | |
| | | /** |
| | | * osd市是否正确 |
| | | */ |
| | | private Integer osdCityCorrect; |
| | | |
| | | /** |
| | | * osd区是否正确 |
| | | */ |
| | | private Integer osdPartCorrect; |
| | | |
| | | /** |
| | | * osd左下角是否正确 |
| | | */ |
| | | private Integer osdLbCorrect; |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | import com.ycl.api.DH.lib.NetSDKLib.NET_OUT_LOGIN_WITH_HIGHLEVEL_SECURITY; |
| | | import com.ycl.api.DH.lib.ToolKits; |
| | | import com.ycl.api.DH.lib.structure.*; |
| | | import com.ycl.platform.domain.result.OSDResult; |
| | | import com.ycl.utils.StringUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import java.io.File; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | | |
| | | import static com.ycl.api.DH.lib.NetSDKLib.NET_EM_OSD_BLEND_TYPE.NET_EM_OSD_BLEND_TYPE_MAIN; |
| | | import static com.ycl.api.DH.lib.enumeration.NET_EM_CFG_OPERATE_TYPE.NET_EM_CFG_CUSTOMTITLE; |
| | |
| | | return bRet; |
| | | } |
| | | |
| | | public static String getOsdTime() { |
| | | public static OSDResult getOsd() { |
| | | OSDResult osdResult = new OSDResult(); |
| | | NetSDKLib.NET_TIME deviceTime = new NetSDKLib.NET_TIME(); |
| | | |
| | | if (!netsdk.CLIENT_QueryDeviceTime(m_hLoginHandle, deviceTime, 3000)) { |
| | | System.err.println("CLIENT_QueryDeviceTime Failed!" + ToolKits.getErrorCodePrint()); |
| | | log.error("CLIENT_QueryDeviceTime Failed!" + ToolKits.getErrorCodePrint()); |
| | | return null; |
| | | } |
| | | Date checkTime = new Date(); |
| | | osdResult.setCheckTime(checkTime); |
| | | String date = deviceTime.toStringTime(); |
| | | date = date.replace("/", "-"); |
| | | log.info("成功获取检测osd时间" + date); |
| | | |
| | | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | try { |
| | | Date time = simpleDateFormat.parse(date); |
| | | osdResult.setOsdTime(time); |
| | | } catch (ParseException e) { |
| | | log.error("时间解析失败"); |
| | | } |
| | | NET_CFG_GBMODE_INFO reserve = new NET_CFG_GBMODE_INFO(); |
| | | |
| | | NET_CFG_GBMODE_INFO osdInfo = new NET_CFG_GBMODE_INFO(); |
| | | osdInfo.write(); |
| | | boolean b = netsdk.CLIENT_GetConfig(m_hLoginHandle, NET_EM_CFG_GBMODE, 0, osdInfo.getPointer(), osdInfo.size(), 3000, reserve.getPointer()); |
| | | if (!b) { |
| | | log.info(("CLIENT_GetConfig Failed!" + ToolKits.getErrorCodePrint())); |
| | | log.error("CLIENT_GetConfig Failed!" + ToolKits.getErrorCodePrint()); |
| | | return null; |
| | | } else { |
| | | osdInfo.read(); |
| | | NET_GBMODE_CUSTOMTITLE_INFO[] stuCustomTitle = osdInfo.stuCustomTitle; |
| | | for (NET_GBMODE_CUSTOMTITLE_INFO title : stuCustomTitle) { |
| | | NET_TITLE_OSD_INFO[] stuOSD = title.stuOSD; |
| | | for (NET_TITLE_OSD_INFO osd : stuOSD) { |
| | | String osdStr = null; |
| | | osdStr = new String(osd.szText, StandardCharsets.UTF_8); |
| | | if (!StringUtils.isEmpty(osdStr)) { |
| | | log.info("osd二级文本" + osdStr); |
| | | String position = new String(title.szPositon, StandardCharsets.UTF_8).trim(); |
| | | if("LeftDown".equals(position)) { |
| | | NET_TITLE_OSD_INFO[] stuOSD = title.stuOSD; |
| | | for (NET_TITLE_OSD_INFO osd : stuOSD) { |
| | | String osdStr = null; |
| | | osdStr = new String(osd.szText, StandardCharsets.UTF_8); |
| | | if (!StringUtils.isEmpty(osdStr)) { |
| | | osdResult.setOSD4(osdStr); |
| | | } |
| | | } |
| | | }else if("RightDown".equals(position)){ |
| | | NET_TITLE_OSD_INFO[] stuOSD = title.stuOSD; |
| | | int num = 0; |
| | | for (NET_TITLE_OSD_INFO osd : stuOSD) { |
| | | String osdStr = null; |
| | | osdStr = new String(osd.szText, StandardCharsets.UTF_8); |
| | | if (!StringUtils.isEmpty(osdStr)) { |
| | | if(num ==0){ |
| | | osdResult.setOSD1(osdStr); |
| | | }else if(num ==1){ |
| | | osdResult.setOSD2(osdStr); |
| | | }else if(num ==2){ |
| | | osdResult.setOSD3(osdStr); |
| | | }else if(num ==3){ |
| | | osdResult.setName(osdStr); |
| | | } |
| | | } |
| | | num++; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | return date; |
| | | return osdResult; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.ycl.api.DH.utils; |
| | | |
| | | import com.ycl.api.DH.module.LoginModule; |
| | | import com.ycl.platform.domain.result.OSDResult; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | |
| | | @Slf4j |
| | | public class DHApi { |
| | | |
| | | public static OSDResult getOsd(String ip, String userName, String password){ |
| | | LoginModule.login(ip, 80, userName, password); |
| | | OSDResult osd = LoginModule.getOsd(); |
| | | LoginModule.logout(); |
| | | return osd; |
| | | } |
| | | } |
| | |
| | | package com.ycl.api.HK; |
| | | |
| | | import com.ycl.platform.domain.result.OSDResult; |
| | | import constant.ApiConstants; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.http.HttpResponse; |
| | | import org.apache.http.auth.AuthScope; |
| | | import org.apache.http.auth.Credentials; |
| | | import org.apache.http.auth.UsernamePasswordCredentials; |
| | | import org.apache.http.client.CredentialsProvider; |
| | | import org.apache.http.client.config.RequestConfig; |
| | | import org.apache.http.client.methods.HttpGet; |
| | | import org.apache.http.impl.client.DefaultHttpClient; |
| | | import org.apache.http.impl.client.BasicCredentialsProvider; |
| | | import org.apache.http.impl.client.CloseableHttpClient; |
| | | import org.apache.http.impl.client.HttpClientBuilder; |
| | | import org.apache.http.impl.client.HttpClients; |
| | | import org.apache.http.util.EntityUtils; |
| | | import org.w3c.dom.Document; |
| | | import org.w3c.dom.Element; |
| | | import org.w3c.dom.Node; |
| | | import org.w3c.dom.NodeList; |
| | | import org.xml.sax.InputSource; |
| | | import org.xml.sax.SAXException; |
| | | |
| | | import javax.xml.parsers.DocumentBuilder; |
| | | import javax.xml.parsers.DocumentBuilderFactory; |
| | | import javax.xml.parsers.ParserConfigurationException; |
| | | import java.io.IOException; |
| | | import java.io.StringReader; |
| | | import java.net.URI; |
| | | import java.net.URISyntaxException; |
| | | import java.time.OffsetDateTime; |
| | | import java.util.Date; |
| | | |
| | | @Slf4j |
| | | public class HKApi { |
| | | public static void getOsdByIP(String ip) { |
| | | DefaultHttpClient httpclient = new DefaultHttpClient(); |
| | | //TODO:验证错误的情况 |
| | | public static OSDResult getOsdByIP(String ip, String userName, String password) { |
| | | OSDResult osdResult = new OSDResult(); |
| | | CloseableHttpClient httpClient = HttpClients.createDefault(); |
| | | String hostUrl = "http://" + ip; |
| | | // 获取焦距 |
| | | String url = hostUrl + "/ISAPI/System/Video/inputs/channels/1/overlays"; |
| | | URI serverURI = null; |
| | | try { |
| | | serverURI = new URI(url); |
| | | HttpGet httpGet = new HttpGet(url); |
| | | String username = "admin"; |
| | | String password = "zg@2024dx"; |
| | | Credentials creds = new UsernamePasswordCredentials(username, |
| | | password); |
| | | httpclient.getCredentialsProvider(). |
| | | |
| | | setCredentials( |
| | | new AuthScope(serverURI.getHost(), serverURI. |
| | | |
| | | getPort()), (Credentials) creds); |
| | | |
| | | HttpResponse response = httpclient.execute(httpGet); |
| | | |
| | | String resultString = EntityUtils.toString(response.getEntity(), "utf-8"); |
| | | log.info(resultString); |
| | | //获取OSD |
| | | HttpResponse OSDResponse = getHttpResponse(httpClient, hostUrl + ApiConstants.HK_OSD_PATH, userName, password); |
| | | String OSDString = EntityUtils.toString(OSDResponse.getEntity(), "utf-8"); |
| | | //解析xml |
| | | DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); |
| | | DocumentBuilder builder = factory.newDocumentBuilder(); |
| | | Document document = builder.parse(new InputSource(new StringReader(resultString))); |
| | | document.getDocumentElement().normalize(); |
| | | NodeList nodeList = document.getElementsByTagName("TextOverlay"); |
| | | for (int i = 0; i < nodeList.getLength(); i++) { |
| | | Node node = nodeList.item(i); |
| | | if (node.getNodeType() == Node.ELEMENT_NODE) { |
| | | Element element = (Element) node; |
| | | log.info("TEXT : " + element.getElementsByTagName("displayText").item(0).getTextContent()); |
| | | } |
| | | } |
| | | parseXMl(OSDString, "TextOverlay", "displayText", osdResult, null); |
| | | //获取Time |
| | | HttpResponse TimeResponse = getHttpResponse(httpClient, hostUrl + ApiConstants.HK_OSD_TIME, userName, password); |
| | | Date date = new Date(); |
| | | String timeString = EntityUtils.toString(TimeResponse.getEntity(), "utf-8"); |
| | | //解析xml |
| | | parseXMl(timeString, "Time", "localTime", osdResult, date); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | log.error(e.getMessage()); |
| | | return null; |
| | | } |
| | | return osdResult; |
| | | } |
| | | |
| | | private static void parseXMl(String OSDString, String tagName1, String tagName2, OSDResult osdResult, Date date) throws ParserConfigurationException, SAXException, IOException { |
| | | DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); |
| | | DocumentBuilder builder = factory.newDocumentBuilder(); |
| | | Document document = builder.parse(new InputSource(new StringReader(OSDString))); |
| | | document.getDocumentElement().normalize(); |
| | | NodeList nodeList = document.getElementsByTagName(tagName1); |
| | | for (int i = 0; i < nodeList.getLength(); i++) { |
| | | Node node = nodeList.item(i); |
| | | if (node.getNodeType() == Node.ELEMENT_NODE && "TextOverlay".equals(tagName1)) { |
| | | Element element = (Element) node; |
| | | String textContent = element.getElementsByTagName(tagName2).item(0).getTextContent(); |
| | | log.info("TEXT : " + textContent); |
| | | if (i == 0) { |
| | | osdResult.setOSD1(textContent); |
| | | } else if (i == 1) { |
| | | osdResult.setOSD2(textContent); |
| | | } else if (i == 2) { |
| | | osdResult.setOSD3(textContent); |
| | | } else if (i == 3) { |
| | | osdResult.setName(textContent); |
| | | } else if (i == 4) { |
| | | osdResult.setOSD4(textContent); |
| | | } |
| | | } else if (node.getNodeType() == Node.ELEMENT_NODE && "Time".equals(tagName1)) { |
| | | Element element = (Element) node; |
| | | String textContent = element.getElementsByTagName(tagName2).item(0).getTextContent(); |
| | | log.info("TEXT : " + textContent); |
| | | osdResult.setCheckTime(date); |
| | | OffsetDateTime dateTime = OffsetDateTime.parse(textContent); |
| | | // 将OffsetDateTime转换为Date对象 |
| | | osdResult.setOsdTime(Date.from(dateTime.toInstant())); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private static HttpResponse getHttpResponse(CloseableHttpClient httpClient, String url, String userName, String password) throws URISyntaxException, IOException { |
| | | CredentialsProvider credsProvider = new BasicCredentialsProvider(); |
| | | credsProvider.setCredentials( |
| | | new AuthScope(new URI(url).getHost(), new URI(url).getPort()), |
| | | new UsernamePasswordCredentials(userName, password)); |
| | | |
| | | HttpGet httpGet = new HttpGet(url); |
| | | |
| | | // 设置请求配置 |
| | | RequestConfig requestConfig = RequestConfig.custom() |
| | | .setConnectTimeout(2000) |
| | | .setSocketTimeout(2000) |
| | | .build(); |
| | | httpGet.setConfig(requestConfig); |
| | | |
| | | // 绑定凭证提供者到HttpClient |
| | | httpClient = HttpClientBuilder.create() |
| | | .setDefaultCredentialsProvider(credsProvider) |
| | | .build(); |
| | | try { |
| | | return httpClient.execute(httpGet); |
| | | } catch (Exception e){ |
| | | throw new RuntimeException("海康OSD执行失败"); |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | //返回monitor |
| | | //TODO:时间写死了 |
| | | public List<String> getMonitorFromMongo() { |
| | | Date date = DateUtils.getDay(2024, 7, 13); |
| | | Query query = new Query(Criteria.where("mongoCreateTime").gte(DateUtils.getDayStart(date)).lt(DateUtils.getDayEnd(date))); |
| | | // Query query = new Query(Criteria.where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))); |
| | | Query query = new Query(Criteria.where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))); |
| | | List<MonitorQualifyResult> oneMachineFileResults = mongoTemplate.find(query, MonitorQualifyResult.class); |
| | | |
| | | return CollectionUtils.isEmpty(oneMachineFileResults) ? new ArrayList<>() : oneMachineFileResults.stream().map(result -> result.getSerialNumber().getValue()).collect(Collectors.toList()); |
| | |
| | | package com.ycl.calculate; |
| | | |
| | | import com.ycl.platform.domain.entity.CheckIndexVideo; |
| | | import com.ycl.platform.domain.result.UY.PyOsdResult; |
| | | import com.ycl.platform.domain.result.UY.VideoOnlineResult; |
| | | import com.ycl.platform.domain.result.UY.OsdCheckResult; |
| | | import com.ycl.platform.domain.vo.TMonitorVO; |
| | | import com.ycl.platform.mapper.CheckIndexVideoMapper; |
| | | import com.ycl.platform.mapper.TMonitorMapper; |
| | |
| | | */ |
| | | @Component |
| | | @Slf4j |
| | | public class VideoOsdCalculation extends IndexCalculationServe implements CalculationStrategy<PyOsdResult> { |
| | | public class VideoOsdCalculation extends IndexCalculationServe implements CalculationStrategy<OsdCheckResult> { |
| | | @Autowired |
| | | private CheckIndexVideoMapper checkIndexVideoMapper; |
| | | @Autowired |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void calculate(List<PyOsdResult> list) { |
| | | public void calculate(List<OsdCheckResult> list) { |
| | | if (CollectionUtils.isEmpty(list)) { |
| | | log.info("数据为空"); |
| | | return; |
| | | } |
| | | |
| | | //获得国标码为key的设备map |
| | | Map<String, TMonitorVO> monitorMap = monitorMapper.selectListByIds(list.stream().map(PyOsdResult::getDeviceNo).collect(Collectors.toList())) |
| | | Map<String, TMonitorVO> monitorMap = monitorMapper.selectListByIds(list.stream().map(OsdCheckResult::getDeviceNo).collect(Collectors.toList())) |
| | | .stream().collect(Collectors.toMap(TMonitorVO::getSerialNumber, Function.identity())); |
| | | //获取省厅国标码集合 |
| | | List<String> provinceIds = getProvince(); |
| | |
| | | List<String> important = getImportant(); |
| | | |
| | | Map<String, AreaStats> areaStatsMap = new HashMap<>(); |
| | | for (PyOsdResult result : list) { |
| | | for (OsdCheckResult result : list) { |
| | | TMonitorVO monitor = monitorMap.get(result.getDeviceNo()); |
| | | if (monitor == null) continue; |
| | | |
| | |
| | | /** |
| | | * 累计osd合格数、时间偏差合格数 |
| | | */ |
| | | private void updateAreaStats(Map<String, AreaStats> areaStatsMap, String key, PyOsdResult result, List<String> important) { |
| | | private void updateAreaStats(Map<String, AreaStats> areaStatsMap, String key, OsdCheckResult result, List<String> important) { |
| | | //返回对象的引用,如果不存在会放入新的key,value |
| | | AreaStats stats = areaStatsMap.computeIfAbsent(key, k -> new AreaStats()); |
| | | stats.totalSites++; |
| | |
| | | } |
| | | } |
| | | |
| | | private Boolean checkOsd(PyOsdResult result) { |
| | | return ApiConstants.PY_OSD_Correct.equals(result.getOsd1Province()) && |
| | | ApiConstants.PY_OSD_Correct.equals(result.getOsd1City()) && |
| | | ApiConstants.PY_OSD_Correct.equals(result.getOsd1Part()) && |
| | | ApiConstants.PY_OSD_Correct.equals(result.getOsd1LB()) && |
| | | ApiConstants.PY_OSD_Correct.equals(result.getOsd1OSD()) && |
| | | ApiConstants.PY_OSD_Correct.equals(result.getOsd1TimeFormat()) && |
| | | ApiConstants.PY_OSD_Correct.equals(result.getOsd1OsdSet()); |
| | | private Boolean checkOsd(OsdCheckResult result) { |
| | | return ApiConstants.OSD_Correct.equals(result.getOsdTimeCorrect()) && |
| | | ApiConstants.OSD_Correct.equals(result.getOsdNameCorrect()) && |
| | | ApiConstants.OSD_Correct.equals(result.getOsdProvinceCorrect()) && |
| | | ApiConstants.OSD_Correct.equals(result.getOsdCityCorrect()) && |
| | | ApiConstants.OSD_Correct.equals(result.getOsdPartCorrect()); |
| | | } |
| | | |
| | | private Boolean checkTime(PyOsdResult result) { |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | // 解析时间字符串 |
| | | LocalDateTime checkTime = LocalDateTime.parse(result.getCheckTime(), formatter); |
| | | LocalDateTime osdTime = LocalDateTime.parse(result.getSetTime(), formatter); |
| | | // 计算时间差(Duration) |
| | | Duration duration = Duration.between(checkTime, osdTime); |
| | | // 将时间差转换为秒 |
| | | long secondsBetween = duration.getSeconds(); |
| | | // 判断时间差是否在60秒以内 |
| | | return secondsBetween <= 60; |
| | | private Boolean checkTime(OsdCheckResult result) { |
| | | return ApiConstants.OSD_Correct.equals(result.getOsdTimeCorrect()); |
| | | } |
| | | |
| | | /** |
| | |
| | | import com.ycl.utils.DateUtils; |
| | | import constant.ApiConstants; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.ArrayList; |
| | |
| | | @Slf4j |
| | | public class HkApiUtil { |
| | | |
| | | @Value("${HK.host}") |
| | | public static String host; |
| | | @Value("${HK.appKey}") |
| | | public static String appKey; |
| | | @Value("${HK.appSecret}") |
| | | public static String appSecret; |
| | | /** |
| | | * 调用海康接口 |
| | | * |
| | |
| | | public static <T> List<T> sendAPI(String apiUrl, BaseParam params, Class<T> resultType) { |
| | | |
| | | // STEP1:设置平台参数,根据实际情况,设置host appkey appsecret 三个参数. |
| | | ArtemisConfig.host = "51.92.65.49"; // 平台的ip端口 |
| | | ArtemisConfig.appKey = "29555942"; // 密钥appkey |
| | | ArtemisConfig.appSecret = "t9U7tCplCyYHzQPPL7cH";// 密钥appSecret |
| | | ArtemisConfig.host = host; // 平台的ip端口 |
| | | ArtemisConfig.appKey = appKey; // 密钥appkey |
| | | ArtemisConfig.appSecret = appSecret;// 密钥appSecret |
| | | |
| | | // STEP2:设置OpenAPI接口的上下文 |
| | | final String ARTEMIS_PATH = "/artemis"; |
| | |
| | | package com.ycl.platform.controller.SynPY; |
| | | |
| | | import com.ycl.platform.domain.result.UY.PyOsdResult; |
| | | import com.ycl.platform.domain.result.UY.OsdCheckResult; |
| | | import com.ycl.system.Result; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.data.mongodb.core.MongoTemplate; |
| | |
| | | private final MongoTemplate mongoTemplate; |
| | | |
| | | @PostMapping("/osd") |
| | | public Result pySynOSD(@RequestBody List<PyOsdResult> dataList) { |
| | | public Result pySynOSD(@RequestBody List<OsdCheckResult> dataList) { |
| | | mongoTemplate.insertAll(dataList); |
| | | return Result.ok(); |
| | | } |
| | |
| | | * @date 2024-03-04 |
| | | */ |
| | | @Mapper |
| | | public interface TMonitorMapper extends BaseMapper<TMonitor> |
| | | public interface TMonitorMapper |
| | | { |
| | | /** |
| | | * 查询设备资产 |
| | |
| | | * @param list |
| | | * @return |
| | | */ |
| | | int batchUpdateDeviceType(@Param("list") List<TMonitor> list); |
| | | int batchUpdateDeviceType(@Param("numbers") List<String> list,@Param("deviceType") Integer deviceType); |
| | | |
| | | List<TMonitor> selectByNumbers(@Param("numbers")List<String> numbers); |
| | | } |
| | |
| | | * |
| | | * @param dataList |
| | | */ |
| | | void osdCheck(List<PyOsdResult> dataList); |
| | | void osdCheck(List<OsdCheckResult> dataList); |
| | | |
| | | // /** |
| | | // * 视频标注 |
| | |
| | | import com.ycl.platform.service.UYErrorTypeCheckService; |
| | | import com.ycl.platform.service.WorkOrderService; |
| | | import com.ycl.utils.uuid.IdUtils; |
| | | import constant.ApiConstants; |
| | | import enumeration.ErrorType; |
| | | import enumeration.general.WorkOrderStatusEnum; |
| | | import lombok.RequiredArgsConstructor; |
| | |
| | | |
| | | |
| | | @Override |
| | | public void osdCheck(List<PyOsdResult> dataList) { |
| | | public void osdCheck(List<OsdCheckResult> dataList) { |
| | | List<WorkOrder> workOrderList = dataList.stream().map(item -> { |
| | | WorkOrder workOrder = new WorkOrder(); |
| | | // osd时间 |
| | | if (!item.getCheckTime().equals(item.getSetTime())) { |
| | | if (!ApiConstants.OSD_Correct.equals(item.getOsdTimeCorrect())) { |
| | | this.genWorkOrder(workOrder, ErrorType.CLOCK_SKEW, item.getDeviceNo()); |
| | | } |
| | | // osd信息 |
| | | if (!"设置正确".equals(item.getOsd1Province()) |
| | | || (!"设置正确".equals(item.getOsd1City())) |
| | | || (!"设置正确".equals(item.getOsd1Part())) |
| | | || (!"设置正确".equals(item.getOsd1TimeFormat())) |
| | | || (!"设置正确".equals(item.getOsd1OSD())) |
| | | if (!ApiConstants.OSD_Correct.equals(item.getOsdProvinceCorrect()) |
| | | || (!ApiConstants.OSD_Correct.equals(item.getOsdCityCorrect())) |
| | | || (!ApiConstants.OSD_Correct.equals(item.getOsdPartCorrect())) |
| | | || (!ApiConstants.OSD_Correct.equals(item.getOsdNameCorrect())) |
| | | ) { |
| | | this.genWorkOrder(workOrder, ErrorType.OSD_ERROR, item.getDeviceNo()); |
| | | } |
| | |
| | | public void siteOnlineTask() { |
| | | log.info("开始计算车辆点位在线率和视图库对接稳定性"); |
| | | Date yesterday = DateUtils.addDays(new Date(), -1); |
| | | //TODO:时间写死了 |
| | | Date date = DateUtils.getDay(2024,7,13); |
| | | //计算点位在线率和视图库对接稳定性 |
| | | Query query = new Query(); |
| | | query.addCriteria(Criteria |
| | | .where("mongoCreateTime").gte(DateUtils.getDayStart(date)).lt(DateUtils.getDayEnd(date)) |
| | | .where("mongoCreateTime").gte(DateUtils.getDayStart(yesterday)).lt(DateUtils.getDayEnd(yesterday)) |
| | | .and("dataType").is(ApiConstants.HK_DataType_CAR)); |
| | | List<SnapshotDataMonitorResult> results = mongoTemplate.find(query, SnapshotDataMonitorResult.class); |
| | | CalculationStrategy<SnapshotDataMonitorResult> calculator = IndexCalculationFactory.getCalculator(CalculationStrategyConstants.Car_SiteOnline_ViewStability); |
| | |
| | | public void deviceSampleTask() { |
| | | log.info("开始计算车辆卡口设备数据识别准确性、url可用性、大图可用性"); |
| | | Date yesterday = DateUtils.addDays(new Date(), -1); |
| | | //TODO:时间写死了 |
| | | Date date = DateUtils.getDay(2024,7,13); |
| | | //计算车辆卡口设备数据识别准确性、url可用性、大图可用性 |
| | | Query query = new Query(); |
| | | query.addCriteria(Criteria |
| | | .where("mongoCreateTime").gte(DateUtils.getDayStart(date)).lt(DateUtils.getDayEnd(date))); |
| | | .where("mongoCreateTime").gte(DateUtils.getDayStart(yesterday)).lt(DateUtils.getDayEnd(yesterday))); |
| | | List<VehicleDeviceSamplingResult> results = mongoTemplate.find(query, VehicleDeviceSamplingResult.class); |
| | | CalculationStrategy calculator = IndexCalculationFactory.getCalculator(CalculationStrategyConstants.Car_DataAccuracy_Url_PicUsability); |
| | | calculator.calculate(results); |
| | |
| | | public void infoAccuracyTask() { |
| | | log.info("开始计算车辆卡口信息采集准确率"); |
| | | Date yesterday = DateUtils.addDays(new Date(), -1); |
| | | //TODO:时间写死了 |
| | | Date date = DateUtils.getDay(2024,7,13); |
| | | //计算车辆卡口信息采集准确率 |
| | | Query query = new Query(); |
| | | query.addCriteria(Criteria |
| | | .where("mongoCreateTime").gte(DateUtils.getDayStart(date)).lt(DateUtils.getDayEnd(date))); |
| | | .where("mongoCreateTime").gte(DateUtils.getDayStart(yesterday)).lt(DateUtils.getDayEnd(yesterday))); |
| | | List<CrossDetailResult> results = mongoTemplate.find(query, CrossDetailResult.class); |
| | | CalculationStrategy calculator = IndexCalculationFactory.getCalculator(CalculationStrategyConstants.Car_InfoAccuracy); |
| | | calculator.calculate(results); |
| | |
| | | public void snapShopDelayTask() { |
| | | log.info("开始计算车辆抓拍数据上传及时性"); |
| | | Date yesterday = DateUtils.addDays(new Date(), -1); |
| | | //TODO:时间写死了 |
| | | Date date = DateUtils.getDay(2024,7,13); |
| | | //计算车辆抓拍数据上传及时性 |
| | | Query query = new Query(); |
| | | query.addCriteria(Criteria |
| | | .where("mongoCreateTime").gte(DateUtils.getDayStart(date)).lt(DateUtils.getDayEnd(date)) |
| | | .where("mongoCreateTime").gte(DateUtils.getDayStart(yesterday)).lt(DateUtils.getDayEnd(yesterday)) |
| | | .and("dataType").is(ApiConstants.HK_DataType_CAR)); |
| | | List<SnapshotDelayMonitorResult> results = mongoTemplate.find(query, SnapshotDelayMonitorResult.class); |
| | | CalculationStrategy calculator = IndexCalculationFactory.getCalculator(CalculationStrategyConstants.Car_SnapshotDelay); |
| | |
| | | public void snapShopDataIntegrity() { |
| | | log.info("开始计算车辆数据抓拍完整性"); |
| | | Date yesterday = DateUtils.addDays(new Date(), -1); |
| | | //TODO:时间写死了 |
| | | Date date = DateUtils.getDay(2024,7,13); |
| | | //计算车辆数据抓拍完整性 |
| | | Query query = new Query(); |
| | | query.addCriteria(Criteria |
| | | .where("mongoCreateTime").gte(DateUtils.getDayStart(date)).lt(DateUtils.getDayEnd(date))); |
| | | .where("mongoCreateTime").gte(DateUtils.getDayStart(yesterday)).lt(DateUtils.getDayEnd(yesterday))); |
| | | List<DataIntegrityMonitoringResult> results = mongoTemplate.find(query, DataIntegrityMonitoringResult.class); |
| | | CalculationStrategy calculator = IndexCalculationFactory.getCalculator(CalculationStrategyConstants.Car_DataIntegrity); |
| | | calculator.calculate(results); |
| | |
| | | public void clockAccuracyTask() { |
| | | log.info("开始计算车辆卡口设备时钟准确性"); |
| | | Date yesterday = DateUtils.addDays(new Date(), -1); |
| | | //TODO:时间写死了 |
| | | Date date = DateUtils.getDay(2024,7,13); |
| | | //计算车辆卡口设备时钟准确性 |
| | | Query query = new Query(); |
| | | query.addCriteria(Criteria |
| | | .where("mongoCreateTime").gte(DateUtils.getDayStart(date)).lt(DateUtils.getDayEnd(date))); |
| | | .where("mongoCreateTime").gte(DateUtils.getDayStart(yesterday)).lt(DateUtils.getDayEnd(yesterday))); |
| | | List<VehicleDeviceInspectionResult> results = mongoTemplate.find(query, VehicleDeviceInspectionResult.class); |
| | | CalculationStrategy calculator = IndexCalculationFactory.getCalculator(CalculationStrategyConstants.Car_ClockAccuracy); |
| | | calculator.calculate(results); |
| | |
| | | public void siteOnlineTask() { |
| | | log.info("开始计算人脸点位在线率和视图库对接稳定性"); |
| | | Date yesterday = DateUtils.addDays(new Date(), -1); |
| | | //TODO:时间写死了 |
| | | Date date = DateUtils.getDay(2024,7,13); |
| | | //点位在线率和视图库对接稳定性 |
| | | Query query = new Query(); |
| | | query.addCriteria(Criteria |
| | | .where("mongoCreateTime").gte(DateUtils.getDayStart(date)).lt(DateUtils.getDayEnd(date)) |
| | | .where("mongoCreateTime").gte(DateUtils.getDayStart(yesterday)).lt(DateUtils.getDayEnd(yesterday)) |
| | | .and("dataType").is(ApiConstants.HK_DataType_FACE)); |
| | | List<SnapshotDataMonitorResult> results = mongoTemplate.find(query, SnapshotDataMonitorResult.class); |
| | | CalculationStrategy calculator = IndexCalculationFactory.getCalculator(CalculationStrategyConstants.Face_SiteOnline_ViewStability); |
| | |
| | | public void deviceSampleTask() { |
| | | log.info("开始计算人脸图片合格率、大图可用性"); |
| | | Date yesterday = DateUtils.addDays(new Date(), -1); |
| | | //TODO:时间写死了 |
| | | Date date = DateUtils.getDay(2024,7,13); |
| | | //计算人脸图片合格率、大图可用性 |
| | | Query query = new Query(); |
| | | query.addCriteria(Criteria |
| | | .where("mongoCreateTime").gte(DateUtils.getDayStart(date)).lt(DateUtils.getDayEnd(date))); |
| | | .where("mongoCreateTime").gte(DateUtils.getDayStart(yesterday)).lt(DateUtils.getDayEnd(yesterday))); |
| | | List<FaceDeviceSamplingResult> results = mongoTemplate.find(query, FaceDeviceSamplingResult.class); |
| | | CalculationStrategy calculator = IndexCalculationFactory.getCalculator(CalculationStrategyConstants.Face_DataAccuracy_PicUsability); |
| | | calculator.calculate(results); |
| | |
| | | public void infoAccuracyTask(){ |
| | | log.info("开始计算人脸卡口信息采集准确率"); |
| | | Date yesterday = DateUtils.addDays(new Date(), -1); |
| | | //TODO:时间写死了 |
| | | Date date = DateUtils.getDay(2024,7,13); |
| | | //计算人脸卡口信息采集准确率 |
| | | Query query = new Query(); |
| | | query.addCriteria(Criteria |
| | | .where("mongoCreateTime").gte(DateUtils.getDayStart(date)).lt(DateUtils.getDayEnd(date))); |
| | | .where("mongoCreateTime").gte(DateUtils.getDayStart(yesterday)).lt(DateUtils.getDayEnd(yesterday))); |
| | | List<MonitoringDetailResult> results = mongoTemplate.find(query, MonitoringDetailResult.class); |
| | | CalculationStrategy calculator = IndexCalculationFactory.getCalculator(CalculationStrategyConstants.Face_InfoAccuracy); |
| | | calculator.calculate(results); |
| | |
| | | public void snapShopDelay(){ |
| | | log.info("开始计算人脸抓拍数据上传及时性"); |
| | | Date yesterday = DateUtils.addDays(new Date(), -1); |
| | | //TODO:时间写死了 |
| | | Date date = DateUtils.getDay(2024,7,13); |
| | | //计算人脸抓拍数据上传及时性 |
| | | Query query = new Query(); |
| | | query.addCriteria(Criteria |
| | | .where("mongoCreateTime").gte(DateUtils.getDayStart(date)).lt(DateUtils.getDayEnd(date)) |
| | | .where("mongoCreateTime").gte(DateUtils.getDayStart(yesterday)).lt(DateUtils.getDayEnd(yesterday)) |
| | | .and("dataType").is(ApiConstants.HK_DataType_FACE)); |
| | | List<SnapshotDelayMonitorResult> results = mongoTemplate.find(query, SnapshotDelayMonitorResult.class); |
| | | CalculationStrategy calculator = IndexCalculationFactory.getCalculator(CalculationStrategyConstants.Face_SnapshotDelay); |
| | |
| | | public void clockAccuracyTask() { |
| | | log.info("开始计算人脸设备时钟准确性"); |
| | | Date yesterday = DateUtils.addDays(new Date(), -1); |
| | | //TODO:时间写死了 |
| | | Date date = DateUtils.getDay(2024,7,13); |
| | | //计算人脸设备时钟准确性 |
| | | Query query = new Query(); |
| | | query.addCriteria(Criteria |
| | | .where("mongoCreateTime").gte(DateUtils.getDayStart(date)).lt(DateUtils.getDayEnd(date))); |
| | | .where("mongoCreateTime").gte(DateUtils.getDayStart(yesterday)).lt(DateUtils.getDayEnd(yesterday))); |
| | | List<FaceDeviceInspectionResult> results = mongoTemplate.find(query, FaceDeviceInspectionResult.class); |
| | | CalculationStrategy calculator = IndexCalculationFactory.getCalculator(CalculationStrategyConstants.Face_ClockAccuracy); |
| | | calculator.calculate(results); |
| | |
| | | package com.ycl.task; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.mongodb.client.result.DeleteResult; |
| | | import com.ycl.api.DH.module.LoginModule; |
| | | import com.ycl.api.DH.utils.DHApi; |
| | | import com.ycl.api.HK.HKApi; |
| | | import com.ycl.platform.domain.entity.TMonitor; |
| | | import com.ycl.platform.domain.result.OSDResult; |
| | | import com.ycl.platform.domain.result.UY.MonitorQualifyResult; |
| | | import com.ycl.platform.domain.result.UY.OsdCheckResult; |
| | | import com.ycl.platform.mapper.TMonitorMapper; |
| | | import com.ycl.platform.service.UYErrorTypeCheckService; |
| | | import com.ycl.utils.DateUtils; |
| | | import com.ycl.utils.StringUtils; |
| | | import constant.ApiConstants; |
| | | import enumeration.DeviceType; |
| | | import enumeration.general.AreaDeptEnum; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.data.mongodb.core.MongoTemplate; |
| | | import org.springframework.data.mongodb.core.query.Criteria; |
| | | import org.springframework.data.mongodb.core.query.Query; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.concurrent.ArrayBlockingQueue; |
| | | import java.util.concurrent.ExecutorService; |
| | | import java.util.concurrent.ThreadPoolExecutor; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.function.Function; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Slf4j |
| | | @Component("OsdTask") |
| | | public class OsdTask { |
| | | @Value("${HK.userName}") |
| | | public String HKUserName; |
| | | @Value("${HK.password}") |
| | | public String HKPassword; |
| | | @Value("${DH.userName}") |
| | | public String DHUserName; |
| | | @Value("${DH.password}") |
| | | public String DHPassword; |
| | | @Autowired |
| | | private MongoTemplate mongoTemplate; |
| | | @Autowired |
| | | private TMonitorMapper monitorMapper; |
| | | @Autowired |
| | | private UYErrorTypeCheckService uyErrorTypeCheckService; |
| | | |
| | | private static final ExecutorService executorService = new ThreadPoolExecutor(8, |
| | | 24, |
| | | 5000, |
| | | TimeUnit.SECONDS, |
| | | new ArrayBlockingQueue<>(10), |
| | | new ThreadPoolExecutor.CallerRunsPolicy() |
| | | ); |
| | | |
| | | /** |
| | | * 通过查mongoDB每日一机一档数据获取设备ip |
| | | * 通过设备ip、品牌调用不同api获取osd信息 |
| | | * 比对mongoDB一机一档信息,整理成result存入mongo |
| | | * 同步品牌到mysql |
| | | */ |
| | | public void getOSD() { |
| | | HKApi.getOsdByIP("51.95.68.80"); |
| | | long loginId = LoginModule.login("51.95.67.189", 80, "admin", "zg@2024dx"); |
| | | String osdTime = LoginModule.getOsdTime(); |
| | | LoginModule.logout(); |
| | | //批量修改海康品牌集合 |
| | | List<String> hkList = new ArrayList<>(); |
| | | //批量修改大华品牌集合 |
| | | List<String> dhList = new ArrayList<>(); |
| | | //批量修改宇视品牌集合 |
| | | List<String> ysList = new ArrayList<>(); |
| | | List<OSDResult> osdResultList = new ArrayList<>(); |
| | | //查一机一档monitor |
| | | Query query = new Query(Criteria.where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))); |
| | | List<MonitorQualifyResult> oneMachineFileResults = mongoTemplate.find(query, MonitorQualifyResult.class); |
| | | //需要考核的数据 |
| | | List<String> serialNumbers = oneMachineFileResults.stream().map(result -> result.getSerialNumber().getValue()).collect(Collectors.toList()); |
| | | |
| | | List<TMonitor> monitors = monitorMapper.selectByNumbers(serialNumbers); |
| | | for (TMonitor monitor : monitors) { |
| | | executorService.submit(() -> { |
| | | if (DeviceType.HK.getType().equals(monitor.getDeviceType())) { |
| | | //海康品牌 |
| | | OSDResult osd = HKApi.getOsdByIP(monitor.getIp(), HKUserName, HKPassword); |
| | | if (checkSuccess(osdResultList, monitor, osd)) return; |
| | | } else if (DeviceType.DH.getType().equals(monitor.getDeviceType())) { |
| | | //大华品牌 |
| | | OSDResult osd = DHApi.getOsd(monitor.getIp(), DHUserName, DHPassword); |
| | | if (checkSuccess(osdResultList, monitor, osd)) return; |
| | | } else if (DeviceType.YS.getType().equals(monitor.getDeviceType())) { |
| | | //TODO:宇视api |
| | | } |
| | | //未知品牌或者api调用失败,挨个执行所有api |
| | | OSDResult osd = tryAllApi(monitor, hkList, dhList, ysList); |
| | | if (osd != null) { |
| | | synchronized (osdResultList) { |
| | | osdResultList.add(osd); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | executorService.shutdown(); |
| | | //结束api执行,开始校验 |
| | | List<OsdCheckResult> checkResults = new ArrayList<>(); |
| | | Map<String, TMonitor> monitorMap = monitors.stream().collect(Collectors.toMap(TMonitor::getSerialNumber, Function.identity())); |
| | | for (OSDResult osdResult : osdResultList) { |
| | | TMonitor monitor = monitorMap.get(osdResult.getSerialNumber()); |
| | | //封装OsdCheckResult |
| | | OsdCheckResult osdCheckResult = getOsdCheckResult(osdResult, monitor); |
| | | checkCorrect(osdResult, monitor, osdCheckResult); |
| | | checkResults.add(osdCheckResult); |
| | | } |
| | | //结果存入mongo |
| | | if(CollectionUtils.isEmpty(checkResults)){ |
| | | //如果今天存在之前的数据先删除 |
| | | Query pyQuery = new Query(Criteria |
| | | .where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))); |
| | | DeleteResult result = mongoTemplate.remove(pyQuery, OsdCheckResult.class); |
| | | //存放在mongo中 |
| | | mongoTemplate.insertAll(checkResults); |
| | | // 工单生成 |
| | | uyErrorTypeCheckService.osdCheck(checkResults); |
| | | } |
| | | //修改数据库品牌 |
| | | if(!CollectionUtils.isEmpty(hkList)){ |
| | | monitorMapper.batchUpdateDeviceType(hkList,DeviceType.HK.getType()); |
| | | } |
| | | if(!CollectionUtils.isEmpty(dhList)){ |
| | | monitorMapper.batchUpdateDeviceType(dhList,DeviceType.DH.getType()); |
| | | } |
| | | //TODO:宇视 |
| | | log.info("结束获取OSD"); |
| | | } |
| | | |
| | | private OsdCheckResult getOsdCheckResult(OSDResult osdResult, TMonitor monitor) { |
| | | OsdCheckResult osdCheckResult = new OsdCheckResult(); |
| | | osdCheckResult.setDeviceNo(osdResult.getSerialNumber()); |
| | | osdCheckResult.setIp(monitor.getIp()); |
| | | osdCheckResult.setDeviceType(monitor.getCameraFunType()); |
| | | osdCheckResult.setCheckTime(osdResult.getCheckTime()); |
| | | osdCheckResult.setSetTime(osdResult.getOsdTime()); |
| | | osdCheckResult.setOsdProvince(osdResult.getOSD1()); |
| | | osdCheckResult.setOsdCity(osdResult.getOSD2()); |
| | | osdCheckResult.setOsdPart(osdResult.getOSD3()); |
| | | osdCheckResult.setOsdLB(osdResult.getOSD4()); |
| | | osdCheckResult.setOsdName(osdResult.getName()); |
| | | return osdCheckResult; |
| | | } |
| | | |
| | | private void checkCorrect(OSDResult osdResult, TMonitor monitor, OsdCheckResult osdCheckResult) { |
| | | //检查时间是否正确 |
| | | if (osdResult.getCheckTime() != null && osdResult.getOsdTime() != null) { |
| | | long checkTime = osdResult.getCheckTime().getTime(); |
| | | long osdTime = osdResult.getOsdTime().getTime(); |
| | | long timeDiff = (checkTime - osdTime) / 1000; |
| | | if (timeDiff <=60) { |
| | | osdCheckResult.setOsdTimeCorrect(ApiConstants.OSD_Correct); |
| | | } else { |
| | | osdCheckResult.setOsdTimeCorrect(ApiConstants.OSD_Error); |
| | | } |
| | | } |
| | | //检查通道名是否正确 |
| | | if (!StringUtils.isEmpty(osdResult.getName()) && !StringUtils.isEmpty(monitor.getName())) { |
| | | if (monitor.getName().equals(osdResult.getName())) { |
| | | osdCheckResult.setOsdNameCorrect(ApiConstants.OSD_Correct); |
| | | } else { |
| | | osdCheckResult.setOsdNameCorrect(ApiConstants.OSD_Error); |
| | | } |
| | | } |
| | | //检查省是否正确 |
| | | if (!StringUtils.isEmpty(osdResult.getOSD1())) { |
| | | if ("四川".equals(osdResult.getOSD1())) { |
| | | osdCheckResult.setOsdProvinceCorrect(ApiConstants.OSD_Correct); |
| | | } else { |
| | | osdCheckResult.setOsdProvinceCorrect(ApiConstants.OSD_Error); |
| | | } |
| | | } |
| | | //检查市是否正确 |
| | | if (!StringUtils.isEmpty(osdResult.getOSD2())) { |
| | | if ("自贡".equals(osdResult.getOSD2())) { |
| | | osdCheckResult.setOsdCityCorrect(ApiConstants.OSD_Correct); |
| | | } else { |
| | | osdCheckResult.setOsdCityCorrect(ApiConstants.OSD_Error); |
| | | } |
| | | } |
| | | //检查区县是否正确 |
| | | if (!StringUtils.isEmpty(osdResult.getOSD3())) { |
| | | AreaDeptEnum areaDeptEnum = AreaDeptEnum.fromCode(monitor.getSerialNumber().substring(0, 6)); |
| | | if (areaDeptEnum != null && osdResult.getOSD3().equals(areaDeptEnum.getName())) { |
| | | osdCheckResult.setOsdPartCorrect(ApiConstants.OSD_Correct); |
| | | } else { |
| | | osdCheckResult.setOsdPartCorrect(ApiConstants.OSD_Error); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private boolean checkSuccess(List<OSDResult> osdResultList, TMonitor monitor, OSDResult osd) { |
| | | if (osd != null) { |
| | | osd.setSerialNumber(monitor.getSerialNumber()); |
| | | synchronized (osdResultList) { |
| | | osdResultList.add(osd); |
| | | } |
| | | return true; |
| | | } else { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | private OSDResult tryAllApi(TMonitor monitor, List<String> hkList, List<String> dhList, List<String> ysList) { |
| | | //尝试海康的api |
| | | OSDResult hkosd = HKApi.getOsdByIP(monitor.getIp(), HKUserName, HKPassword); |
| | | if (hkosd != null) { |
| | | hkosd.setSerialNumber(monitor.getSerialNumber()); |
| | | synchronized (hkList) { |
| | | hkList.add(monitor.getSerialNumber()); |
| | | } |
| | | return hkosd; |
| | | } |
| | | //尝试大华的api |
| | | OSDResult dhosd = DHApi.getOsd(monitor.getIp(), DHUserName, DHPassword); |
| | | if (dhosd != null) { |
| | | dhosd.setSerialNumber(monitor.getSerialNumber()); |
| | | synchronized (dhList) { |
| | | dhList.add(monitor.getSerialNumber()); |
| | | } |
| | | return dhosd; |
| | | } |
| | | //TODO:宇视api |
| | | return null; |
| | | } |
| | | } |
| | |
| | | log.info("结束执行录像可用数据同步"); |
| | | } |
| | | |
| | | |
| | | //视频标注 |
| | | public void OsdMonitorTask() { |
| | | //视频标注 |
| | | log.info("开始执行视频标注数据同步"); |
| | | OsdMonitorParam param = new OsdMonitorParam(); |
| | | param.setPageNum(ApiConstants.PageNo); |
| | | param.setPageSize(ApiConstants.PageSize); |
| | | JSONObject jsonObject = uyClient.osdMonitorList(param, tenantId); |
| | | if (jsonObject != null) { |
| | | if (ApiConstants.UYSuccessCodeStr.equals(jsonObject.getString("code"))) { |
| | | JSONObject data = jsonObject.getJSONObject("data"); |
| | | if (data != null) { |
| | | List<OsdMonitorResult> records = data.getList("records", OsdMonitorResult.class); |
| | | if (!CollectionUtils.isEmpty(records)) { |
| | | //如果今天存在之前的数据先删除 |
| | | Query query = new Query(Criteria |
| | | .where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))); |
| | | DeleteResult result = mongoTemplate.remove(query, OsdMonitorResult.class); |
| | | //存放在mongo中 |
| | | mongoTemplate.insertAll(records); |
| | | } else { |
| | | log.error("视频标注数据为空{}", data); |
| | | } |
| | | } else { |
| | | log.error("视频标注数据为空{}", jsonObject); |
| | | } |
| | | } else { |
| | | log.error("视频标注数据为空{}", jsonObject); |
| | | } |
| | | } else { |
| | | log.error("视频标注数据为空"); |
| | | } |
| | | log.info("结束执行视频标注数据同步"); |
| | | } |
| | | } |
| | |
| | | |
| | | import com.ycl.calculate.CalculationStrategy; |
| | | import com.ycl.factory.IndexCalculationFactory; |
| | | import com.ycl.platform.domain.entity.CheckIndexVideo; |
| | | import com.ycl.platform.domain.param.UY.RecordMetaDSumParam; |
| | | import com.ycl.platform.domain.result.HK.SnapshotDataMonitorResult; |
| | | import com.ycl.platform.domain.result.UY.*; |
| | | import com.ycl.platform.domain.vo.PlatformOnlineVO; |
| | | import com.ycl.platform.domain.vo.TMonitorVO; |
| | | import com.ycl.platform.mapper.CheckIndexVideoMapper; |
| | | import com.ycl.platform.mapper.PlatformOnlineMapper; |
| | | import com.ycl.platform.mapper.TMonitorMapper; |
| | | import com.ycl.platform.service.PlatformOnlineService; |
| | | import com.ycl.system.mapper.SysDeptMapper; |
| | | import com.ycl.utils.DateUtils; |
| | | import constant.ApiConstants; |
| | | import constant.CalculationStrategyConstants; |
| | | import constant.CheckConstants; |
| | | import enumeration.general.AreaDeptEnum; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.mongodb.core.MongoTemplate; |
| | | import org.springframework.data.mongodb.core.query.Criteria; |
| | | import org.springframework.data.mongodb.core.query.Query; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 视频计算考核指标任务 |
| | |
| | | |
| | | public void siteOnlineTask() { |
| | | Date yesterday = DateUtils.addDays(new Date(), -1); |
| | | //TODO:时间写死了 |
| | | Date date = DateUtils.getDay(2024,7,13); |
| | | //计算点位在线率和重点点位在线率和指挥图像在线率 |
| | | Query query = new Query(); |
| | | query.addCriteria(Criteria |
| | | .where("mongoCreateTime").gte(DateUtils.getDayStart(date)).lt(DateUtils.getDayEnd(date))); |
| | | .where("mongoCreateTime").gte(DateUtils.getDayStart(yesterday)).lt(DateUtils.getDayEnd(yesterday))); |
| | | |
| | | List<VideoOnlineResult> results = mongoTemplate.find(query, VideoOnlineResult.class); |
| | | CalculationStrategy calculator = IndexCalculationFactory.getCalculator(CalculationStrategyConstants.Video_SiteOnline); |
| | |
| | | |
| | | public void videoUsabilityTask() { |
| | | Date yesterday = DateUtils.addDays(new Date(), -1); |
| | | //TODO:时间写死了 |
| | | Date date = DateUtils.getDay(2024,7,13); |
| | | //计算录像可用率和重点录像可用率 |
| | | Query query = new Query(); |
| | | query.addCriteria(Criteria |
| | | .where("mongoCreateTime").gte(DateUtils.getDayStart(date)).lt(DateUtils.getDayEnd(date))); |
| | | .where("mongoCreateTime").gte(DateUtils.getDayStart(yesterday)).lt(DateUtils.getDayEnd(yesterday))); |
| | | |
| | | List<RecordMetaDSumResult> results = mongoTemplate.find(query, RecordMetaDSumResult.class); |
| | | CalculationStrategy calculator = IndexCalculationFactory.getCalculator(CalculationStrategyConstants.Video_Usability); |
| | |
| | | } |
| | | public void oneMonitorQualifyTask(){ |
| | | //计算一机一档合格率 |
| | | // Date yesterday = DateUtils.addDays(new Date(), -1); |
| | | //TODO:时间写死了 |
| | | Date date = DateUtils.getDay(2024,7,13); |
| | | Date yesterday = DateUtils.addDays(new Date(), -1); |
| | | |
| | | Query query = new Query(); |
| | | query.addCriteria(Criteria |
| | | .where("mongoCreateTime").gte(DateUtils.getDayStart(date)).lt(DateUtils.getDayEnd(date))); |
| | | .where("mongoCreateTime").gte(DateUtils.getDayStart(yesterday)).lt(DateUtils.getDayEnd(yesterday))); |
| | | List<MonitorQualifyResult> results = mongoTemplate.find(query, MonitorQualifyResult.class); |
| | | CalculationStrategy calculator = IndexCalculationFactory.getCalculator(CalculationStrategyConstants.Video_MonitorQualify); |
| | | calculator.calculate(results); |
| | |
| | | public void osdTask() { |
| | | //计算Osd标注、时间准确率 |
| | | Date yesterday = DateUtils.addDays(new Date(), -1); |
| | | //TODO:时间写死了 |
| | | Date date = DateUtils.getDay(2024,7,13); |
| | | Query query = new Query(); |
| | | query.addCriteria(Criteria |
| | | .where("mongoCreateTime").gte(DateUtils.getDayStart(date)).lt(DateUtils.getDayEnd(date))); |
| | | List<PyOsdResult> results = mongoTemplate.find(query, PyOsdResult.class); |
| | | .where("mongoCreateTime").gte(DateUtils.getDayStart(yesterday)).lt(DateUtils.getDayEnd(yesterday))); |
| | | List<OsdCheckResult> results = mongoTemplate.find(query, OsdCheckResult.class); |
| | | CalculationStrategy calculator = IndexCalculationFactory.getCalculator(CalculationStrategyConstants.Video_OsdTime); |
| | | calculator.calculate(results); |
| | | } |
| | |
| | | spring.data: |
| | | redis: |
| | | # 地址 |
| | | #host: 42.193.1.25 |
| | | host: 127.0.0.1 |
| | | host: 42.193.1.25 |
| | | # host: 127.0.0.1 |
| | | # 端口,默认为6379 |
| | | port: 6379 |
| | | #password: ycl2018 |
| | | password: |
| | | password: ycl2018 |
| | | # password: |
| | | # 数据库索引 |
| | | database: 0 |
| | | # 密码(如没有密码请注释掉) |
| | |
| | | apikey: 72fcfd6825304f7fa0453134de620f3a |
| | | accesskey: fc9503a521544e76a8e69b912a2f177bc6362b19 |
| | | |
| | | HK: |
| | | userName: admin |
| | | passWord: zg@2024dx |
| | | host: 51.92.65.49 |
| | | appKey: 29555942 |
| | | appSecret: t9U7tCplCyYHzQPPL7cH |
| | | |
| | | DH: |
| | | userName: admin |
| | | password: zg@2024dx |
| | | # gb281视频网关地址,用于获取rtsp格式的流地址 |
| | | rtsp: |
| | | server: http://192.168.3.88:7788 |
| | |
| | | retry: 4 # 最大重试次数 |
| | | youYunDomain: http://51.92.65.56 # 优云地址 |
| | | haiKangDomain: 51.92.65.48 # 海康地址 |
| | | |
| | | youYun: |
| | | tenantId: e10adc3949ba59abbe56e057f20f88dd |
| | | email: yunwei |
| | |
| | | apikey: 72fcfd6825304f7fa0453134de620f3a |
| | | accesskey: fc9503a521544e76a8e69b912a2f177bc6362b19 |
| | | |
| | | HK: |
| | | userName: admin |
| | | passWord: zg@2024dx |
| | | host: 51.92.65.49 |
| | | appKey: 29555942 |
| | | appSecret: t9U7tCplCyYHzQPPL7cH |
| | | |
| | | DH: |
| | | userName: admin |
| | | password: zg@2024dx |
| | | # gb281视频网关地址,用于获取rtsp格式的流地址 |
| | | rtsp: |
| | | server: http://192.168.3.88:7788 |
| | |
| | | </foreach> |
| | | </select> |
| | | |
| | | <select id="selectByNumbers" resultType="com.ycl.platform.domain.vo.TMonitor"> |
| | | select * from t_monitor where serial_number in |
| | | <foreach collection="numbers" separator="," open="(" close=")" item="number"> |
| | | #{number} |
| | | </foreach> |
| | | </select> |
| | | |
| | | <select id="selectTMonitorList" resultType="com.ycl.platform.domain.vo.TMonitorVO"> |
| | | select m.id, m.serial_number, name, site_type, mac_addr, ip, camera_fun_type, longitude, latitude, |
| | | camera_capture_area, on_state, civil_code, d.dept_id, d.dept_name, d.area, p.province_tag, |
| | |
| | | </insert> |
| | | |
| | | <update id="batchUpdateDeviceType"> |
| | | <foreach collection="list" separator=";" item="item"> |
| | | UPDATE t_monitor |
| | | SET |
| | | update_time = #{item.updateTime}, |
| | | device_type = #{item.deviceType} |
| | | WHERE id = #{item.id} |
| | | update t_monitor set device_type = #{deviceType} where serial_number in |
| | | <foreach collection="numbers" separator="," open="(" close=")" item="number"> |
| | | #{number} |
| | | </foreach> |
| | | </update> |
| | | |