1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- package com.njyunzhi.nanyang.common;
-
- import com.hikvision.ae.hatc.sdk.service.SDKService;
- import com.hikvision.ae.hatc.sdk.service.impl.HatcClientFactory;
- import com.njyunzhi.nanyang.config.HatcConfig;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Component;
-
- @Component
- public class HatcUtil {
- SDKService sdkService;
- HatcConfig hatcConfig;
-
- @Autowired
- public HatcUtil(HatcConfig hatcConfig) {
- this.hatcConfig = hatcConfig;
- try {
- initSDK();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
- public SDKService getSdkService() {
- if (sdkService == null) {
- try {
- initSDK();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
- return sdkService;
- }
-
- public void initSDK() throws InterruptedException {
- Boolean enabled = hatcConfig.getEnable();
- if (enabled == null || !enabled) return;
-
- sdkService = HatcClientFactory.getSDKClient(
- hatcConfig.getCmsAddress(),
- hatcConfig.getCmsPort(),
- hatcConfig.getHatcAccount(),
- hatcConfig.getHatcSecret()
- );
- }
- }
|