| | |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.mongodb.client.result.DeleteResult; |
| | | import com.ycl.feign.UYClient; |
| | | import com.ycl.platform.domain.entity.YwPoint; |
| | | import com.ycl.platform.domain.param.UY.*; |
| | | import com.ycl.platform.domain.result.UY.RecordMetaDSumResult; |
| | | import com.ycl.platform.domain.result.UY.*; |
| | | import com.ycl.platform.domain.vo.UpdateOnlineVO; |
| | | import com.ycl.platform.mapper.TMonitorMapper; |
| | | import com.ycl.platform.service.UYErrorTypeCheckService; |
| | | import com.ycl.platform.service.YwPointService; |
| | | import com.ycl.utils.DateUtils; |
| | | import com.ycl.utils.http.HttpUtils; |
| | | import com.ycl.utils.http.SelfHttpUtil; |
| | | import constant.ApiConstants; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | 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.http.HttpStatus; |
| | | import org.springframework.http.HttpStatusCode; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.io.IOException; |
| | | import java.net.InetAddress; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.concurrent.ArrayBlockingQueue; |
| | | import java.util.concurrent.ExecutorService; |
| | | import java.util.concurrent.ThreadPoolExecutor; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | //优云对接数据任务 |
| | | @Slf4j |
| | |
| | | private final UYClient uyClient; |
| | | private final UYErrorTypeCheckService uyErrorTypeCheckService; |
| | | private final YwPointService pointService; |
| | | private final TMonitorMapper monitorMapper; |
| | | private final SelfHttpUtil selfHttpUtil; |
| | | |
| | | @Value("${youYun.tenantId}") |
| | | private String tenantId; |
| | |
| | | private String email; |
| | | @Value("${youYun.passwd}") |
| | | private String passwd; |
| | | |
| | | private static final ExecutorService executorService = new ThreadPoolExecutor(16, |
| | | 128, |
| | | 5000, |
| | | TimeUnit.SECONDS, |
| | | new ArrayBlockingQueue<>(1000), |
| | | new ThreadPoolExecutor.CallerRunsPolicy() |
| | | ); |
| | | |
| | | // 图像检测 |
| | | public void imageDetection() { |
| | |
| | | } |
| | | }); |
| | | pointService.setDeviceTagByGB(records); |
| | | pointService.setNew(records); |
| | | //存放在mongo中 |
| | | mongoTemplate.insertAll(records); |
| | | // 工单生成 |
| | |
| | | log.info("结束一机一档合格率数据同步"); |
| | | } |
| | | |
| | | /** |
| | | * 点位在线检测 |
| | | */ |
| | | public void pointOnline() { |
| | | log.info("开始检测点位在线"); |
| | | // 先查出设备IP集合 |
| | | List<String> ipList = monitorMapper.getDistinctIP(); |
| | | String prefix = "http://"; |
| | | Date now = new Date(); |
| | | for (String ip : ipList) { |
| | | executorService.submit(() -> { |
| | | // 先检测能否访问该ip的网页 |
| | | ResponseEntity<Object> res = null; |
| | | UpdateOnlineVO online = new UpdateOnlineVO(); |
| | | online.setIp(ip); |
| | | if ("127.0.0.1".equals(ip)) { |
| | | online.setOnline(Boolean.FALSE); |
| | | monitorMapper.updateOnline(online); |
| | | return; |
| | | } |
| | | try { |
| | | res = selfHttpUtil.get(prefix + ip, null, null); |
| | | online.setOnline(Objects.nonNull(res) && HttpStatus.OK == res.getStatusCode()); |
| | | } catch (Exception e) { |
| | | online.setOnline(Boolean.FALSE); |
| | | } |
| | | online.setUpdateTime(now); |
| | | |
| | | // 如果http得到的不在线,那么再ping一下 |
| | | boolean reachable = false; |
| | | if (! online.getOnline()) { |
| | | try { |
| | | reachable = InetAddress.getByName(ip).isReachable(3000); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | online.setOnline(reachable); |
| | | } |
| | | monitorMapper.updateOnline(online); |
| | | }); |
| | | } |
| | | } |
| | | |
| | | //点位在线率 |
| | | public void videoOnlineTask() { |
| | | //视频图像质量 |