|
|
|
@ -4,9 +4,14 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
import com.jcraft.jsch.ChannelSftp;
|
|
|
|
import com.jcraft.jsch.ChannelSftp;
|
|
|
|
import com.jcraft.jsch.SftpATTRS;
|
|
|
|
import com.jcraft.jsch.SftpATTRS;
|
|
|
|
import com.leaper.web.config.ConfigProperties;
|
|
|
|
import com.leaper.web.config.ConfigProperties;
|
|
|
|
|
|
|
|
import com.leaper.web.entity.Camera;
|
|
|
|
import com.leaper.web.entity.LightSource;
|
|
|
|
import com.leaper.web.entity.LightSource;
|
|
|
|
import com.leaper.web.entity.OrderLive;
|
|
|
|
import com.leaper.web.entity.OrderLive;
|
|
|
|
import com.leaper.web.entity.PicData;
|
|
|
|
import com.leaper.web.entity.PicData;
|
|
|
|
|
|
|
|
import com.leaper.web.lib.CameraConnMap;
|
|
|
|
|
|
|
|
import com.leaper.web.lib.hik.HikLoginModuleImpl;
|
|
|
|
|
|
|
|
import com.leaper.web.lib.joyware.JoywareLoginModuleImpl;
|
|
|
|
|
|
|
|
import com.leaper.web.mapper.CameraMapper;
|
|
|
|
import com.leaper.web.mapper.LightSourceMapper;
|
|
|
|
import com.leaper.web.mapper.LightSourceMapper;
|
|
|
|
import com.leaper.web.mapper.OrderLiveMapper;
|
|
|
|
import com.leaper.web.mapper.OrderLiveMapper;
|
|
|
|
import com.leaper.web.mapper.PicDataMapper;
|
|
|
|
import com.leaper.web.mapper.PicDataMapper;
|
|
|
|
@ -31,12 +36,16 @@ import java.util.HashMap;
|
|
|
|
import java.util.Iterator;
|
|
|
|
import java.util.Iterator;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
import java.util.concurrent.CountDownLatch;
|
|
|
|
|
|
|
|
|
|
|
|
@Component
|
|
|
|
@Component
|
|
|
|
@EnableScheduling
|
|
|
|
@EnableScheduling
|
|
|
|
@Slf4j
|
|
|
|
@Slf4j
|
|
|
|
public class CronTab {
|
|
|
|
public class CronTab {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
|
|
private CameraMapper cameraMapper;
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private ConfigProperties configProperties;
|
|
|
|
private ConfigProperties configProperties;
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
@ -89,6 +98,61 @@ public class CronTab {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Scheduled(cron = "0 * * * * ?")
|
|
|
|
|
|
|
|
//@Scheduled(cron = "0 0/1 * * * *")
|
|
|
|
|
|
|
|
public void cameraConn() {
|
|
|
|
|
|
|
|
log.info("球机连接判断");
|
|
|
|
|
|
|
|
List<Camera> cameras = cameraMapper.selectByMap(new HashMap<>(0));
|
|
|
|
|
|
|
|
if (cameras.size() > 0) {
|
|
|
|
|
|
|
|
CountDownLatch latch = new CountDownLatch(cameras.size());
|
|
|
|
|
|
|
|
cameras.forEach(camera -> {
|
|
|
|
|
|
|
|
StatusThread statusThread = new StatusThread(camera, latch);
|
|
|
|
|
|
|
|
statusThread.start();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
latch.await();
|
|
|
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class StatusThread extends Thread {
|
|
|
|
|
|
|
|
private Camera camera;
|
|
|
|
|
|
|
|
private CountDownLatch latch;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public StatusThread(Camera camera, CountDownLatch latch) {
|
|
|
|
|
|
|
|
this.camera = camera;
|
|
|
|
|
|
|
|
this.latch = latch;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void run() {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
Boolean ok = false;
|
|
|
|
|
|
|
|
if (configProperties.getCameraConfig().getCameraType() == ConfigProperties.HIK_CAMERA) {
|
|
|
|
|
|
|
|
ok = HikLoginModuleImpl.connectStatus(CameraConnMap.getConnId(camera.getId()).intValue());
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
ok = JoywareLoginModuleImpl.connectStatus(CameraConnMap.getConnId(camera.getId()));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (ok) {
|
|
|
|
|
|
|
|
camera.setStatus("连接正常");
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
CameraConnMap.disConn(camera.getId());
|
|
|
|
|
|
|
|
camera.setStatus("未连接");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
CameraConnMap.disConn(camera.getId());
|
|
|
|
|
|
|
|
camera.setStatus("未连接");
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
latch.countDown();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void putTime(Integer streetId){
|
|
|
|
public static void putTime(Integer streetId){
|
|
|
|
lightTimeMap.put(streetId,System.currentTimeMillis());
|
|
|
|
lightTimeMap.put(streetId,System.currentTimeMillis());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|