rk
3 天以前 4f6565cb9cca05981abdeb85dfc023a28c892e42
server/visits/dmvisit_admin/src/main/java/com/doumee/service/impl/HkSyncEventServiceImpl.java
@@ -1,5 +1,6 @@
package com.doumee.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.doumee.biz.system.SystemDictDataBiz;
import com.doumee.core.haikang.model.HKConstants;
import com.doumee.core.haikang.model.HKTools;
@@ -8,18 +9,21 @@
import com.doumee.core.haikang.model.param.respose.OrgInfoResponse;
import com.doumee.core.haikang.service.HKService;
import com.doumee.core.utils.Constants;
import com.doumee.dao.business.WarningMapper;
import com.doumee.dao.business.model.Warning;
import com.doumee.dao.system.model.SystemDictData;
import com.doumee.service.business.InterfaceLogService;
import com.doumee.service.business.impl.hksync.HkSyncBaseServiceImpl;
import com.github.xiaoymin.knife4j.core.util.CollectionUtils;
import com.hikvision.artemis.sdk.config.ArtemisConfig;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.DependsOn;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
 * 海康事件订阅表Service实现
@@ -33,6 +37,8 @@
    private SystemDictDataBiz systemDictDataBiz;
    @Autowired
    private InterfaceLogService interfaceLogService;
    @Autowired
    private WarningMapper warningMapper;
    @PostConstruct
    public  int  initHkConfig(){
@@ -45,15 +51,10 @@
    }
    public  int  initHkParamConfig(){
        if(StringUtils.isBlank(ArtemisConfig.appKey )
                ||StringUtils.isBlank(ArtemisConfig.host )
                ||StringUtils.isBlank(ArtemisConfig.appSecret )
        ){
            ArtemisConfig.host = systemDictDataBiz.queryByCode(Constants.HK_PARAM, Constants.HK_HOST).getCode();
            ArtemisConfig.appKey = systemDictDataBiz.queryByCode(Constants.HK_PARAM, Constants.HK_APPKEY).getCode();
            ArtemisConfig.appSecret = systemDictDataBiz.queryByCode(Constants.HK_PARAM, Constants.HK_APPSECRET).getCode();
            HKConstants.https = systemDictDataBiz.queryByCode(Constants.HK_PARAM, Constants.HK_HTTPS).getCode();
        }
        ArtemisConfig.host = systemDictDataBiz.queryByCode(Constants.HK_PARAM, Constants.HK_HOST).getCode();
        ArtemisConfig.appKey = systemDictDataBiz.queryByCode(Constants.HK_PARAM, Constants.HK_APPKEY).getCode();
        ArtemisConfig.appSecret = systemDictDataBiz.queryByCode(Constants.HK_PARAM, Constants.HK_APPSECRET).getCode();
        HKConstants.https = systemDictDataBiz.queryByCode(Constants.HK_PARAM, Constants.HK_HTTPS).getCode();
        HKTools.interfaceLogService=interfaceLogService;
        return  0;
    }
@@ -106,6 +107,41 @@
        HKService.cancelEventSub(param);//先取消
        HKService.eventSub(param);//门禁事件
        param.setEventDest(path+"/visitIccm");
        param.setEventTypes(new Integer[]{HKConstants.EventTypes.VISIT_SIGN_ICCM_IN.getKey()
                ,HKConstants.EventTypes.VISIT_SIGN_ICCM_PASS.getKey()
                ,HKConstants.EventTypes.VISIT_SIGN_ICCM_OUT.getKey()});
        HKService.cancelEventSub(param);//先取消
        HKService.eventSub(param);//访客事件
        param.setEventDest(path+"/platform/workstatus");
        param.setEventTypes(new Integer[]{HKConstants.EventTypes.PLATFORM_WORKSTATUS.getKey()});
        HKService.cancelEventSub(param);//先取消
//        HKService.eventSub(param);//月台工作状态事件
        try{
            List<Warning> warningList = warningMapper.selectList(new QueryWrapper<Warning>().lambda()
                    .eq(Warning::getIsdeleted,Constants.ZERO)
                    .eq(Warning::getStatus,Constants.ONE)
                    .in(Warning::getType,Constants.ZERO,Constants.ONE)
                    .isNotNull(Warning::getCode)
            );
            if(CollectionUtils.isNotEmpty(warningList)){
                List<String> codeList = warningList.stream().map(i->i.getCode()).collect(Collectors.toList());
                if(CollectionUtils.isNotEmpty(codeList)){
                    param.setEventDest(path+"/notice");
                    param.setEventTypes(codeList.stream().map(i->Integer.valueOf(i)).toArray(Integer[]::new));
                    HKService.cancelEventSub(param);//先取消
                    HKService.eventSub(param);//安防事件
                }
            }
        }catch (Exception e){
        }
    }
    /**
     * 取消订阅门禁事件、访客事件、和停车场事件