jiangping
2024-08-13 6765787baa5e0b771d71f865c4deb776367410c4
server/dmvisit_admin/src/main/java/com/doumee/service/impl/HkSyncEventServiceImpl.java
@@ -1,11 +1,12 @@
package com.doumee.service.impl;
import com.doumee.biz.system.SystemDictDataBiz;
import com.doumee.core.erp.ErpTool;
import com.doumee.core.haikang.model.HKConstants;
import com.doumee.core.haikang.model.HKTools;
import com.doumee.core.haikang.model.param.BaseResponse;
import com.doumee.core.haikang.model.param.request.EventSubRequest;
import com.doumee.core.haikang.model.param.respose.OrgListResponse;
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.system.model.SystemDictData;
@@ -34,13 +35,12 @@
    @PostConstruct
    public  int  initHkConfig(){
        if(StringUtils.isBlank( ArtemisConfig.host )){
            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;
        ErpTool.interfaceLogService=interfaceLogService;
        //获取根组织编码
        getRootOrgCode();
        //开始订阅门禁事件、访客事件、和停车场事件
@@ -53,13 +53,18 @@
    private void getRootOrgCode() {
        SystemDictData org =  systemDictDataBiz.queryByCode(Constants.HK_PARAM, Constants.HK_ROOTORG_CODE);
        if(org!=null){
            SystemDictData orgName =  systemDictDataBiz.queryByCode(Constants.HK_PARAM, Constants.HK_ROOTORG_NAME);
            String rootOrgId =org.getCode();
            if(StringUtils.isBlank(rootOrgId)){
                BaseResponse<OrgListResponse> res = HKService.getRootOrg(null);
                BaseResponse<OrgInfoResponse> res = HKService.getRootOrg(null);
                if(res !=null && res.getData()!=null && StringUtils.isNotBlank(res.getData().getOrgIndexCode())){
                    org.setCode(res.getData().getOrgIndexCode());
                    org.setUpdateTime(new Date());
                    systemDictDataBiz.updateById( org);
                    orgName.setCode(res.getData().getOrgName());
                    orgName.setUpdateTime(new Date());
                    systemDictDataBiz.updateById( orgName);
                }
            }
        }
@@ -69,6 +74,7 @@
     * 订阅门禁事件、访客事件、和停车场事件
     */
    public void startHkEventSub(){
        cancelEventSub();
        EventSubRequest param = new EventSubRequest();
        String path =systemDictDataBiz.queryByCode(Constants.HK_PARAM, Constants.HK_PUSH_URL).getCode();
        param.setEventDest(path+"/parks");
@@ -76,17 +82,26 @@
                ,HKConstants.EventTypes.PARK_LINE_OUT.getKey()
                ,HKConstants.EventTypes.PARK_PASS_IN.getKey()
                ,HKConstants.EventTypes.PARK_PASS_OUT.getKey() });
        HKService.cancelEventSub(param);////先取消
        HKService.eventSub(param);//停车场事件
        param.setEventDest(path+"/visit");
        param.setEventTypes(new Integer[]{HKConstants.EventTypes.VISIT_SIGN_OUT.getKey()
                ,HKConstants.EventTypes.VISIT_SIGN_OUT.getKey()});
        param.setEventTypes(new Integer[]{HKConstants.EventTypes.VISIT_SIGN_IN.getKey()
                ,HKConstants.EventTypes.VISIT_SIGN_OUT.getKey() });
        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+"/acs");
        param.setEventTypes(new Integer[]{HKConstants.EventTypes.DOOR_FACE_AUTH_FAIL.getKey(),HKConstants.EventTypes.DOOR_FACE_AUTH_SUCCESS.getKey()});
        HKService.cancelEventSub(param);//先取消
        HKService.eventSub(param);//门禁事件
    }
    /**
     * 取消订阅门禁事件、访客事件、和停车场事件
@@ -98,8 +113,11 @@
                ,HKConstants.EventTypes.PARK_LINE_OUT.getKey()
                ,HKConstants.EventTypes.PARK_PASS_IN.getKey()
                ,HKConstants.EventTypes.PARK_PASS_OUT.getKey()
                ,HKConstants.EventTypes.VISIT_SIGN_IN.getKey()
                ,HKConstants.EventTypes.VISIT_SIGN_OUT.getKey(),
                HKConstants.EventTypes.DOOR_FACE_AUTH_SUCCESS.getKey()});
        String path =systemDictDataBiz.queryByCode(Constants.HK_PARAM, Constants.HK_PUSH_URL).getCode();
        param.setEventDest(path);
        HKService.cancelEventSub(param);//停车场事件
    }