All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.dahuatech.icc.multiinone.vims.VimsOpendoorListSDK Maven / Gradle / Ivy

The newest version!
package com.dahuatech.icc.multiinone.vims;

import com.dahuatech.hutool.json.JSONObject;
import com.dahuatech.hutool.log.Log;
import com.dahuatech.hutool.log.LogFactory;
import com.dahuatech.icc.event.enums.CategoryEnums;
import com.dahuatech.icc.vims.model.v202207.opendoor.OpendoorListResponse;
import com.dahuatech.icc.multiinone.Constants;
import com.dahuatech.icc.multiinone.event.EventSubcribeSDK;
import com.dahuatech.icc.multiinone.event.domain.BaseEventSubcribeInfo;
import com.dahuatech.icc.multiinone.event.vo.SimpleEventSubcribeRequest;
import com.dahuatech.icc.multiinone.exception.BusinessException;
import com.dahuatech.icc.multiinone.utils.EventParamsUtils;
import com.dahuatech.icc.multiinone.vims.enums.VimsAlarmTypeEnums;
import com.dahuatech.icc.multiinone.vo.BaseResponse;
import com.dahuatech.icc.vims.model.v202207.SDK.OpendoorListSDK;
import com.dahuatech.icc.vims.model.v202207.opendoor.OpendoorListRequest;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * program:java-sdk
 *
 * Author: 312013
 * Date:2022-08-17 09:08
 * Description: 可视对讲开门记录同步
 */
public class VimsOpendoorListSDK {
    private static final Log logger = LogFactory.get();

    /**
     *可视对讲开门记录同步
     */
    public BaseResponse opendoorList(BaseEventSubcribeInfo request) {
        logger.info("VimsOpendoorListSDK,opendoorList,param:{}",new JSONObject(request).toJSONString(0));
        //订阅可视对讲事件
        BaseResponse baseResponse = eventSubscribe(request);
        return baseResponse;
    }

    /**
     * 订阅可视对讲事件:只订阅报警类型,不订阅业务类型
     * 参考文档:可视对讲子系统-》报警事件-》开门记录(http://10.1.253.177:8082/web/#/2?page_id=2157)
     * **/
    public BaseResponse eventSubscribe(BaseEventSubcribeInfo request){
        BaseResponse baseResponse = null;
        try{
            request.valid();
            EventSubcribeSDK eventSubcribeSDK = new EventSubcribeSDK();
            SimpleEventSubcribeRequest eventSubcribeRequest = EventParamsUtils.buildSimpleEventSubcribeRequest(request);
            Map> config = new HashMap>();
            //List list = new ArrayList();
            //可视对讲业务类型
            //list.addAll(VimsBusinessEnum.getBusinessTypes());
            List alarmList = new ArrayList();
            //可视对讲报警类型
            alarmList.addAll(VimsAlarmTypeEnums.getOpenTypeList());
            config.put(CategoryEnums.alarm.getCode(), alarmList);
            //可视对讲只订阅报警类型,不订阅业务类型
            //config.put(CategoryEnums.business.getCode(), list);
            eventSubcribeRequest.setTypesConfigs(config);
            baseResponse = eventSubcribeSDK.simpleEventSubcribe(eventSubcribeRequest);
            if(baseResponse.isSuccess()){
                logger.info("Video talk event subscribe success.");
            }
        } catch (BusinessException businessException){
            logger.error("Video talk event subscribe fail,errorMsg:{}",businessException,businessException.getMessage());
            baseResponse = new BaseResponse();
            baseResponse.setCode(businessException.code);
            baseResponse.setErrMsg(businessException.msg);
            return baseResponse;
        } catch (Exception e){
            baseResponse = new BaseResponse();
            logger.error("Video talk event subscribe fail,errorMsg:{}",e,e.getMessage());
            baseResponse.setCode(Constants.SYSTEMERROR_CODE);
            baseResponse.setErrMsg(Constants.SYSTEMERROR_MSG);
            return baseResponse;
        }
        return baseResponse;
    }

    /**
     * 查询开门记录
     * **/
    public OpendoorListResponse getOpendoorRecord(OpendoorListRequest request) {
        OpendoorListResponse opendoorListResponse = null;
        //开门记录同步
        try {
            OpendoorListSDK opendoorListSDK = new OpendoorListSDK();
            opendoorListResponse = opendoorListSDK.opendoorList(request);
            if(opendoorListResponse.isSuccess()){
               logger.info("Query open door logs success.");
            }
        } catch (Exception exception) {
            logger.error("System error.");
            exception.printStackTrace();
        }
        return opendoorListResponse;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy