| | |
| | | for (NET_TITLE_OSD_INFO osd : stuOSD) { |
| | | String osdStr = null; |
| | | osdStr = new String(osd.szText, StandardCharsets.UTF_8).trim(); |
| | | // log.info("TEXT:"+osdStr); |
| | | log.error("DHTEXTLeftDown:"+osdStr); |
| | | if (!StringUtils.isEmpty(osdStr)) { |
| | | osdResult.setOSD4(osdStr); |
| | | } |
| | |
| | | for (NET_TITLE_OSD_INFO osd : stuOSD) { |
| | | String osdStr = null; |
| | | osdStr = new String(osd.szText, StandardCharsets.UTF_8).trim(); |
| | | log.error("TEXT:"+osdStr); |
| | | log.error("DHTEXTRightDown:"+osdStr); |
| | | if (!StringUtils.isEmpty(osdStr)) { |
| | | if (osdStr.contains("|")) { |
| | | String[] osdNames = osdStr.split("\\|"); |
| | |
| | | * @param loginId |
| | | * @return |
| | | */ |
| | | public static OSDResult getOsdOld(String serialNumber, LLong loginId) { |
| | | public static OSDResult getOsdOld(String moName,String serialNumber, LLong loginId) { |
| | | OSDResult result = new OSDResult(); |
| | | NetSDKLib.NET_OSD_CUSTOM_TITLE osdInfo4 = new NetSDKLib.NET_OSD_CUSTOM_TITLE(); |
| | | osdInfo4.emOsdBlendType = NetSDKLib.NET_EM_OSD_BLEND_TYPE.NET_EM_OSD_BLEND_TYPE_MAIN; |
| | | NetSDKLib.NET_OSD_CUSTOM_TITLE reserve4 = new NetSDKLib.NET_OSD_CUSTOM_TITLE(); |
| | | osdInfo4.write(); |
| | | boolean e = false; |
| | | e = netsdk.CLIENT_GetConfig(loginId, NET_EM_CFG_CUSTOMTITLE, 0, osdInfo4.getPointer(), osdInfo4.size(), 3000, reserve4.getPointer()); |
| | | if (!e) { |
| | | log.error("e为空,尝试另一个通道"); |
| | | if (moName.startsWith("DX_R2")){ //判断设备是否是DX_R2开头 |
| | | if (serialNumber.charAt(ApiConstants.SerialNumber_Channel) == ApiConstants.SerialNumber_All) { |
| | | e = netsdk.CLIENT_GetConfig(loginId, NET_EM_CFG_CUSTOMTITLE, 0, osdInfo4.getPointer(), osdInfo4.size(), 3000, reserve4.getPointer()); |
| | | } |
| | | else if (serialNumber.charAt(ApiConstants.SerialNumber_Channel) == ApiConstants.SerialNumber_Detail) { |
| | | e = netsdk.CLIENT_GetConfig(loginId, NET_EM_CFG_CUSTOMTITLE, 1, osdInfo4.getPointer(), osdInfo4.size(), 3000, reserve4.getPointer()); |
| | | } |
| | | if (!e) { |
| | | log.error("e为空"); |
| | | } |
| | | }else { |
| | | e = netsdk.CLIENT_GetConfig(loginId, NET_EM_CFG_CUSTOMTITLE, 0, osdInfo4.getPointer(), osdInfo4.size(), 3000, reserve4.getPointer()); |
| | | if (!e) { |
| | | log.error("e为空,尝试另一个通道"); |
| | | e = netsdk.CLIENT_GetConfig(loginId, NET_EM_CFG_CUSTOMTITLE, 1, osdInfo4.getPointer(), osdInfo4.size(), 3000, reserve4.getPointer()); |
| | | } |
| | | } |
| | | if (e) { |
| | | osdInfo4.read(); |
| | | NetSDKLib.NET_CUSTOM_TITLE_INFO[] stuCustomTitle = osdInfo4.stuCustomTitle; |
| | | for (NetSDKLib.NET_CUSTOM_TITLE_INFO net_custom_title_info : stuCustomTitle) { |
| | | String name = new String(net_custom_title_info.szText, StandardCharsets.UTF_8).trim(); |
| | | log.error("name:{}", name); |
| | | log.error("DHname:{}", name); |
| | | if (StringUtils.isNotEmpty(name) && name.contains("|")) { |
| | | String[] osdNames = name.split("\\|"); |
| | | //剔除掉空串 |
| | |
| | | // nonEmptyList.add(osd); |
| | | // } |
| | | // } |
| | | result.setOSD1(osdNames[0]); |
| | | result.setOSD2(osdNames[1]); |
| | | result.setOSD3(osdNames[2]); |
| | | result.setName(osdNames[3]); |
| | | for (int i = 0; i < osdNames.length; i++) { |
| | | if (i == 0) { |
| | | result.setOSD1(osdNames[i]); |
| | | } |
| | | if (i == 1) { |
| | | result.setOSD2(osdNames[i]); |
| | | } |
| | | if (i == 2) { |
| | | result.setOSD3(osdNames[i]); |
| | | } |
| | | if (i == 3) { |
| | | result.setName(osdNames[i]); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | } else { |
| | | log.error(serialNumber, "利旧osd为空"); |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |
| | |
| | | @Slf4j |
| | | public class DHApi { |
| | | |
| | | public static OSDResult getOsd(String serialNumber,String ip, String userName, String password){ |
| | | public static OSDResult getOsd(String name,String serialNumber,String ip, String userName, String password){ |
| | | NetSDKLib.LLong loginId = LoginModule.login(ip, 80, userName, password); |
| | | if(loginId.longValue() ==0){ |
| | | return null; |
| | | } |
| | | OSDResult osd = LoginModule.getOsd(serialNumber,loginId); |
| | | if(osd!=null && osd.getOSD1() ==null &&osd.getOSD2()==null && osd.getOSD3()==null &&osd.getName()==null) { |
| | | OSDResult osdOld = LoginModule.getOsdOld(serialNumber, loginId); |
| | | OSDResult osdOld = LoginModule.getOsdOld(name,serialNumber, loginId); |
| | | osd.setOSD1(osdOld.getOSD1()); |
| | | osd.setOSD2(osdOld.getOSD2()); |
| | | osd.setOSD3(osdOld.getOSD3()); |
| | |
| | | LoginModule.logout(loginId); |
| | | return osd; |
| | | } |
| | | public static OSDResult getOsdOld(String serialNumber,String ip, String userName, String password){ |
| | | public static OSDResult getOsdOld(String name,String serialNumber,String ip, String userName, String password){ |
| | | NetSDKLib.LLong loginId = LoginModule.login(ip, 80, userName, password); |
| | | if(loginId.longValue() ==0){ |
| | | return null; |
| | | } |
| | | OSDResult osdOld = LoginModule.getOsdOld(serialNumber, loginId); |
| | | OSDResult osdOld = LoginModule.getOsdOld(name,serialNumber, loginId); |
| | | LoginModule.logout(loginId); |
| | | return osdOld; |
| | | } |
| | |
| | | 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); |
| | | log.info("HKTEXT : " + textContent); |
| | | if (i == 0) { |
| | | osdResult.setOSD1(textContent); |
| | | } else if (i == 1) { |
| | |
| | | log.error("YSname:{}" , name); |
| | | if (StringUtils.isNotEmpty(name) && name.contains("|")){ |
| | | String[] osdNames = name.split("\\|"); |
| | | osdResult.setOSD1(osdNames[0]); |
| | | osdResult.setOSD2(osdNames[1]); |
| | | osdResult.setOSD3(osdNames[2]); |
| | | osdResult.setName(osdNames[3]); |
| | | osdResult.setOSD4(osdNames[4]); |
| | | for (int i = 0; i < osdNames.length; i++) { |
| | | if (i == 0) { |
| | | osdResult.setOSD1(osdNames[i]); |
| | | } |
| | | if (i == 1) { |
| | | osdResult.setOSD2(osdNames[i]); |
| | | } |
| | | if (i == 2) { |
| | | osdResult.setOSD3(osdNames[i]); |
| | | } |
| | | if (i == 3) { |
| | | osdResult.setName(osdNames[i]); |
| | | } |
| | | } |
| | | }else { |
| | | //省份 |
| | | osdResult.setOSD1(name); |
| | |
| | | int num = 0; |
| | | for (NetDEVSDKLib.NETDEV_OSD_TEXT_OVERLAY_S osd : stOSDInfo.astTextOverlay) { |
| | | String text = new String(osd.szOSDText, StandardCharsets.UTF_8).trim(); |
| | | // log.info("YSnum:"+num+",YStexr:"+text); |
| | | log.info("YSnum:"+num+",YStexr:"+text); |
| | | if (num == 0) { |
| | | osdResult.setOSD2(text); |
| | | } else if (num == 1) { |
| | |
| | | |
| | | @Override |
| | | public void calculate(List<PlatformOnlineVO> list) { |
| | | //list 对象是查询 t_platform_online 昨天时段的集合对象 |
| | | Map<String,Double> map = new HashMap<>(); |
| | | if (!CollectionUtils.isEmpty(list)) { |
| | | for (PlatformOnlineVO platformOnlineVO : list) { |
| | |
| | | Integer deptId = AreaDeptEnum.fromCode(area).getDeptId(); |
| | | //离线时长 |
| | | Integer time = platformOnlineVO.getTodayOutlineSed(); |
| | | //离线时长转换位分钟 |
| | | //离线时长转换为分钟 |
| | | int num = (time / 60) / 30; |
| | | double score = Math.max(1 - num * 0.1, 0); |
| | | map.put(deptId+"",score); |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result page(DataCenterQuery query) { |
| | | public Result page(DataCenterQuery query) { //分页 平台 |
| | | Page<PlatformOnlineVO> page = new Page<>(query.getPageNum(), query.getPageSize()); |
| | | baseMapper.getPage(page, query); |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | |
| | | /** 添加工单 */ |
| | | workOrderService.innerAddWorkOrder(workOrderList); |
| | | workOrderService.innerAddWorkOrder(distributeList); |
| | | |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | public void test() throws ExecutionException, InterruptedException { |
| | | log.info("测试获取OSD"); |
| | | OSDResult osd3 = DHApi.getOsdOld("51030340001320207201", "51.95.34.20", DHUserName, DHPassword); |
| | | OSDResult osd3 = DHApi.getOsdOld("","51030340001320207201", "51.95.34.20", DHUserName, DHPassword); |
| | | log.info("osd3:{}", osd3); |
| | | OSDResult osd4 = DHApi.getOsdOld("51030342001320173201", "51.95.33.174", DHUserName, DHPassword); |
| | | OSDResult osd4 = DHApi.getOsdOld("","51030342001320173201", "51.95.33.174", DHUserName, DHPassword); |
| | | log.info("osd4:{}", osd4); |
| | | } |
| | | } |
| | |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.swing.text.DateFormatter; |
| | | import java.io.IOException; |
| | | import java.net.InetAddress; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | |
| | | } |
| | | if (!reachable) { |
| | | // 如果ping不通,离线时长加5秒 |
| | | redisTemplate.opsForValue().increment(REDIS_KEY_PREFIX + platform.getPlatformIP(), 5); |
| | | LocalDateTime localDateTime = LocalDateTime.now(); |
| | | DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | String todayTime = localDateTime.format(dateTimeFormatter); |
| | | //每次redis累增5s |
| | | redisTemplate.opsForValue().increment(REDIS_KEY_PREFIX + todayTime + platform.getPlatformIP(), 5); |
| | | log.warn(platform.getPlatformName() + "平台未ping通"); |
| | | } |
| | | } catch (Exception e) { |
| | |
| | | .list(); |
| | | // 将java.util.Date转换为java.sql.Date |
| | | java.sql.Date sqlDate = new java.sql.Date(new Date().getTime()); |
| | | |
| | | LocalDateTime localDateTime = LocalDateTime.now(); |
| | | DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | String todayTime = localDateTime.format(dateTimeFormatter); |
| | | for (Platform platform : platformList) { |
| | | Object outLineTime = redisTemplate.opsForValue().get(REDIS_KEY_PREFIX + platform.getPlatformIP()); |
| | | Object outLineTime = redisTemplate.opsForValue().get(REDIS_KEY_PREFIX + todayTime + platform.getPlatformIP()); |
| | | Integer outlineTimeSed = Objects.isNull(outLineTime) ? 0 : (Integer) outLineTime; |
| | | PlatformOnline one = new LambdaQueryChainWrapper<>(platformOnlineService.getBaseMapper()) |
| | | .eq(PlatformOnline::getPlatformId, platform.getId()) |
| | |
| | | } |
| | | } else if (DeviceType.DH.getType().equals(monitor.getDeviceType())) { |
| | | //大华 |
| | | OSDResult osd = DHApi.getOsd(monitor.getSerialNumber(),monitor.getIp(), monitor.getUsername(),monitor.getPassword()); |
| | | OSDResult osd = DHApi.getOsd(monitor.getName(),monitor.getSerialNumber(),monitor.getIp(), monitor.getUsername(),monitor.getPassword()); |
| | | OSDResult osdResult = checkSuccess(monitor, osd); |
| | | if (osdResult!=null) { |
| | | return osd; |
| | |
| | | return hkosd; |
| | | } |
| | | //尝试大华的api |
| | | OSDResult dhosd = DHApi.getOsd(monitor.getSerialNumber(),monitor.getIp(),monitor.getUsername(),monitor.getPassword()); |
| | | OSDResult dhosd = DHApi.getOsd(monitor.getName(),monitor.getSerialNumber(),monitor.getIp(),monitor.getUsername(),monitor.getPassword()); |
| | | if (dhosd != null) { |
| | | dhosd.setSerialNumber(monitor.getSerialNumber()); |
| | | return dhosd; |