| | |
| | | import com.ruoyi.device.hiksdk.service.IHikClientService;
|
| | | import lombok.extern.slf4j.Slf4j;
|
| | | import org.springframework.beans.factory.SmartInitializingSingleton;
|
| | | import org.springframework.boot.ApplicationArguments;
|
| | | import org.springframework.boot.ApplicationRunner;
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import javax.annotation.PostConstruct;
|
| | |
| | | **/
|
| | | @Service
|
| | | @Slf4j(topic = "SDK")
|
| | | public class CameraSdkServiceImpl implements ICameraSdkService {
|
| | | public class CameraSdkServiceImpl implements ICameraSdkService, ApplicationRunner {
|
| | | @Resource
|
| | | private IArdCamerasService ardCamerasService;
|
| | | @Resource
|
| | |
| | | IDhClientService dhClientService;
|
| | | @Resource
|
| | | RedisCache redisCache;
|
| | | @Resource
|
| | | AsyncLogin asyncLogin;
|
| | |
|
| | |
|
| | |
|
| | | //初始化SDK
|
| | | @PostConstruct
|
| | | @Override
|
| | | public void loginAll() {
|
| | | public void run(ApplicationArguments args) throws Exception {
|
| | | try {
|
| | | List<ArdCameras> ardCameras = ardCamerasService.selectArdCamerasListNoDataScope(new ArdCameras());
|
| | | for (ArdCameras camera : ardCameras) {
|
| | | if ("1".equals(camera.getFactory())) {
|
| | | asyncLogin.hikLogin(camera);
|
| | | hikClientService.login(camera);
|
| | | } else if ("2".equals(camera.getFactory())) {
|
| | | asyncLogin.dhLogin(camera);
|
| | | dhClientService.login(camera);
|
| | | }
|
| | | }
|
| | | } catch (Exception ex) {
|
| | |
| | | if (ardCamera != null) {
|
| | | String factory = ardCamera.getFactory();
|
| | | if (factory.equals("1")) {
|
| | | asyncLogin.hikLogin(ardCamera);
|
| | | hikClientService.login(ardCamera);
|
| | | result = true;
|
| | | } else if (factory.equals("2")) {
|
| | | asyncLogin.dhLogin(ardCamera);
|
| | | dhClientService.login(ardCamera);
|
| | | result = true;
|
| | | }
|
| | | }
|