jiangping
2023-12-06 915dcb3800c0cbd63f53e33f9638715b93c9ea6f
海康接口对接开发
已添加2个文件
已修改9个文件
291 ■■■■ 文件已修改
server/dmvisit_service/src/main/java/com/doumee/core/haikang/model/HKConstants.java 58 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/dmvisit_service/src/main/java/com/doumee/core/haikang/model/HKTools.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/dmvisit_service/src/main/java/com/doumee/core/haikang/model/param/request/EventSubRequest.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/dmvisit_service/src/main/java/com/doumee/core/haikang/service/HKService.java 124 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/dmvisit_service/src/main/java/com/doumee/core/utils/Constants.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/dmvisit_service/src/main/java/com/doumee/service/business/impl/DeviceServiceImpl.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/dmvisit_service/src/main/java/com/doumee/service/business/impl/hksync/HkSyncBaseServiceImpl.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/dmvisit_service/src/main/java/com/doumee/service/business/impl/hksync/HkSyncDeviceServiceImpl.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/dmvisit_service/src/main/java/com/doumee/service/business/impl/hksync/HkSyncEventServiceImpl.java 65 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/dmvisit_service/src/main/java/com/doumee/service/business/impl/hksync/HkSyncParkServiceImpl.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/dmvisit_service/src/main/java/com/doumee/service/business/impl/hksync/HkSyncPrivilegeServiceImpl.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/dmvisit_service/src/main/java/com/doumee/core/haikang/model/HKConstants.java
@@ -20,7 +20,9 @@
     * æŽ¥å£åœ°å€é›†åˆ
     */
    public interface InterfacePath{
        String doorEvents = "/api/acs/v2/door/events";//门禁事件查询
//        String doorEvents = "/api/acs/v2/door/events";//门禁事件查询
//        String visitEvents = "/api/visitor/v1/event/turnover/search";//访客事件查询
//        String parkEvents = "/api/pms/v1/crossRecords/page";//停车场事件查询
        String rootOrg = "/api/resource/v1/org/rootOrg";//获取跟组织
        String addBatchOrg = "/api/resource/v1/org/batch/add";//批量新增组织
        String delBatchOrg = "/api/resource/v1/org/batch/delete";//批量删除组织
@@ -45,11 +47,65 @@
        String visitCancel= "/api/visitor/v1/appointment/cancel";//取消访客预约
        String facePicture= "/api/resource/v1/person/picture";//提取用户人脸照片
        String privilegeGroup= "/api/visitor/v1/privilege/group";//查询访客权限组
        String eventSub= "/api/eventService/v1/eventSubscriptionByEventTypes";//事件订阅
    }
    /**
     * é¡”色枚举
     */
    public  enum EventTypes {
        PARK_LINE_IN(771760130, "入场压线事件"  ),
        PARK_PASS_IN(771760131, "入场放行事件"  ),
        PARK_LINE_OUT(771760133, "出场压线事件"  ),
        PARK_PASS_OUT(771760134, "出场放行事件"  ),
        VISIT_SIGN_IN(1392513025, "访客登记"  ),
        VISIT_SIGN_OUT(1392513026, "访客签离"  ),
        DOOR_FACE_AUTH_FAIL(197163, "人脸认证失败"  ),
        DOOR_FACE_AUTH_SUCCESS(196893, "人脸认证通过"  )
        ;
        // æˆå‘˜å˜é‡
        private String name;
        private int key;
        // æž„造方法
        EventTypes(int key, String name ) {
            this.name = name;
            this.key = key;
        }
        // æ™®é€šæ–¹æ³•
        public static String getName(int index) {
            for (Constants.UserType c : Constants.UserType.values()) {
                if (c.getKey() == index) {
                    return c.getName();
                }
            }
            return null;
        }
        // get set æ–¹æ³•
        public String getName() {
            return name;
        }
        public void setName(String name) {
            this.name = name;
        }
        public int getKey() {
            return key;
        }
        public void setKey(int key) {
            this.key = key;
        }
    }
    /**
     * é¡”色枚举
     */
    public  enum Colors {
        SYSTEM(0, "系统用户"  )
server/dmvisit_service/src/main/java/com/doumee/core/haikang/model/HKTools.java
@@ -290,6 +290,16 @@
        String result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, "application/json", null);// post请求application/json类型参数
        return  result;
    }
    /**
     *    äº‹ä»¶è®¢é˜…
     * @param body
     * @return
     */
    public static String eventSub(String body) {
        Map<String, String> path = getPath(HKConstants.InterfacePath.eventSub);
        String result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, "application/json", null);// post请求application/json类型参数
        return  result;
    }
server/dmvisit_service/src/main/java/com/doumee/core/haikang/model/param/request/EventSubRequest.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,14 @@
package com.doumee.core.haikang.model.param.request;
import lombok.Data;
@Data
public class EventSubRequest {
 private String   name    ;//string    False    åç§°ï¼Œæ¨¡ç³Šæœç´¢ï¼Œæœ€å¤§é•¿åº¦32,若包含中文,最大长度指不超过按照指定编码的字节长度,即getBytes(“utf-8”).length
   private Integer[]    eventTypes;//    number[]    True    äº‹ä»¶ç±»åž‹,详见附录D
   private String    eventDest;//    string    True    æŒ‡å®šäº‹ä»¶æŽ¥æ”¶çš„地址,采用restful回调模式,支持http和https,样式如下:http://ip:port/eventRcv或者https://ip:port/eventRcv不超过1024个字符事件接收地址由应用方负责按指定的规范提供,事件接收接口不需要认证三方客户收到消息,请注意立即返回HTTP/1.1 200 OK, å¦åˆ™å› ä¸ºæŽ¥æ”¶å¤ªæ…¢ï¼Œå¯¼è‡´äº‹ä»¶ç§¯åŽ‹
   private Integer[]     subType;//    number    False    è®¢é˜…类型,0-订阅原始事件,1-联动事件,2-原始事件和联动事件,不填使用默认值0
   private Integer[]     eventLvl;//    number[]    False    äº‹ä»¶ç­‰çº§ï¼Œ0-未配置,1-低,2-中,3-高 æ­¤å¤„事件等级是指在事件联动中配置的等级订阅类型为0时,此参数无效,使用默认值0在订阅类型为1时,不填使用默认值[1,2,3]   åœ¨è®¢é˜…类型为2时,不填使用默认值[0,1,2,3]数组大小不超过32,事件等级大小不超过31
}
server/dmvisit_service/src/main/java/com/doumee/core/haikang/service/HKService.java
@@ -11,6 +11,7 @@
import com.doumee.core.haikang.model.param.BaseResponse;
import com.hikvision.artemis.sdk.config.ArtemisConfig;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -22,33 +23,22 @@
import java.io.InputStream;
import java.util.List;
@Service
//@Service
@Slf4j
public class HKService {
    private Logger logger = LoggerFactory.getLogger(HKService.class);
    @Autowired
    private SystemDictDataBiz  systemDictDataBiz;
    @PostConstruct
    public  int  initHkConfig(){
        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();
        return  0;
    }
    /**
     * èŽ·å–æ ¹ç»„ç»‡æ•°æ®
     * @return
     */
    public  BaseResponse<OrgListResponse>  getRootOrg(BaseRequst param){
    public  static  BaseResponse<OrgListResponse>  getRootOrg(BaseRequst param){
        log.error("【海康获取根组织】================开始====");
        try {
            String res = HKTools.getRootOrg ();
            TypeReference typeReference =
                    new TypeReference< BaseResponse<OrgListResponse>>(){};
            BaseResponse<OrgListResponse> result = JSONObject.parseObject(res, typeReference.getType());
            log.error("【海康获取根组织】================成功====\n"+res);
            logResult(result,"海康获取根组织");
            return  result;
        }catch (Exception e){
            log.error("【海康获取根组织】================失败====:\n"+ e.getMessage());
@@ -60,7 +50,7 @@
     * ä¿®æ”¹ç»„织数据
     * @return
     */
    public  BaseResponse editOrg(OrgEditRequest param){
    public  static  BaseResponse editOrg(OrgEditRequest param){
        log.error("【海康修改组织】================开始===="+JSONObject.toJSONString(param));
        try {
@@ -68,7 +58,7 @@
            TypeReference typeReference =
                    new TypeReference< BaseResponse>(){};
            BaseResponse  result = JSONObject.parseObject(res, typeReference.getType());
            log.error("【海康修改组织】================成功====\n"+res);
            logResult(result,"海康修改组织");
            return  result;
        }catch (Exception e){
            log.error("【海康修改组织】================失败====:\n"+ e.getMessage());
@@ -79,7 +69,7 @@
     *批量新增组织数据
     * @return
     */
    public  BaseResponse<OrgOrUserAddResponse>  addBatchOrg(List<OrgAddRequest> param){
    public  static  BaseResponse<OrgOrUserAddResponse>  addBatchOrg(List<OrgAddRequest> param){
        log.error("【海康新增组织】================开始===="+JSONObject.toJSONString(param));
        try {
@@ -87,7 +77,7 @@
            TypeReference typeReference =
                    new TypeReference< BaseResponse<OrgOrUserAddResponse>>(){};
            BaseResponse<OrgOrUserAddResponse> result = JSONObject.parseObject(res, typeReference.getType());
            log.error("【海康新增组织】================成功====\n"+res);
            logResult(result,"海康新增组织");
            return  result;
        }catch (Exception e){
            log.error("【海康新增组织】================失败====:\n"+ e.getMessage());
@@ -98,7 +88,7 @@
     *批量删除组织数据
     * @return
     */
    public  BaseResponse   delBatchOrg(OrgDelRequest param){
    public  static  BaseResponse   delBatchOrg(OrgDelRequest param){
        log.error("【海康删除组织】================开始===="+JSONObject.toJSONString(param));
        try {
@@ -106,7 +96,7 @@
            TypeReference typeReference =
                    new TypeReference< BaseResponse >(){};
            BaseResponse result = JSONObject.parseObject(res, typeReference.getType());
            log.error("【海康删除组织】================成功====\n"+res);
            logResult(result,"海康删除组织");
            return  result;
        }catch (Exception e){
            log.error("【海康删除组织】================失败====:\n"+ e.getMessage());
@@ -117,14 +107,14 @@
     *新增人员信息(支持人脸数据)
     * @return
     */
    public  BaseResponse<UserAddResponse>  addUser(UserAddRequest param){
    public  static  BaseResponse<UserAddResponse>  addUser(UserAddRequest param){
        log.error("【海康新增人员】================开始===="+JSONObject.toJSONString(param));
        try {
            String res = HKTools.addUser(JSONObject.toJSONString(param));
            TypeReference typeReference =
                    new TypeReference< BaseResponse<UserAddResponse>>(){};
            BaseResponse<UserAddResponse> result = JSONObject.parseObject(res, typeReference.getType());
            log.error("【海康新增人员】================成功====\n"+res);
            logResult(result,"海康新增人员");
            return  result;
        }catch (Exception e){
            log.error("【海康新增人员】================失败====:\n"+ e.getMessage());
@@ -135,14 +125,14 @@
     *修改人员信息(不支持人脸数据)
     * @return
     */
    public  BaseResponse editUser(UserAddRequest param){
    public  static  BaseResponse editUser(UserAddRequest param){
        log.error("【海康修改人员】================开始===="+JSONObject.toJSONString(param));
        try {
            String res = HKTools.editUser(JSONObject.toJSONString(param));
            TypeReference typeReference =
                    new TypeReference< BaseResponse<UserAddResponse>>(){};
            BaseResponse<UserAddResponse> result = JSONObject.parseObject(res, typeReference.getType());
            log.error("【海康修改人员】================成功====\n"+res);
            logResult(result,"海康修改人员");
            return  result;
        }catch (Exception e){
            log.error("【海康修改人员】================失败====:\n"+ e.getMessage());
@@ -153,14 +143,14 @@
     *批量新增人员信息(无人脸)
     * @return
     */
    public  BaseResponse<OrgOrUserAddResponse>  addBatchUser(List<UserAddRequest> param){
    public  static  BaseResponse<OrgOrUserAddResponse>  addBatchUser(List<UserAddRequest> param){
        log.error("【海康批量新增人员】================开始===="+JSONObject.toJSONString(param));
        try {
            String res = HKTools.addBatchUser(JSONObject.toJSONString(param));
            TypeReference typeReference =
                    new TypeReference< BaseResponse<OrgOrUserAddResponse>>(){};
            BaseResponse<OrgOrUserAddResponse> result = JSONObject.parseObject(res, typeReference.getType());
            log.error("【海康批量新增人员】================成功====\n"+res);
            logResult(result,"海康批量新增人员");
            return  result;
        }catch (Exception e){
            log.error("【海康批量新增人员】================失败====:\n"+ e.getMessage());
@@ -171,14 +161,14 @@
     *批量删除人员信息
     * @return
     */
    public  BaseResponse<OrgOrUserAddFailureResponse>  delBatchUser(List<UserAddRequest> param){
    public  static  BaseResponse<OrgOrUserAddFailureResponse>  delBatchUser(List<UserAddRequest> param){
        log.error("【海康批量新增人员】================开始===="+JSONObject.toJSONString(param));
        try {
            String res = HKTools.delBatchUser(JSONObject.toJSONString(param));
            TypeReference typeReference =
                    new TypeReference< BaseResponse<OrgOrUserAddFailureResponse>>(){};
            BaseResponse<OrgOrUserAddFailureResponse> result = JSONObject.parseObject(res, typeReference.getType());
            log.error("【海康批量新增人员】================成功====\n"+res);
            logResult(result,"海康批量新增人员");
            return  result;
        }catch (Exception e){
            log.error("【海康批量新增人员】================失败====:\n"+ e.getMessage());
@@ -189,14 +179,14 @@
     *添加人脸信息
     * @return
     */
    public  BaseResponse<FaceAddOrEditesponse>  addFace(List<FaceAddRequest> param){
    public  static  BaseResponse<FaceAddOrEditesponse>  addFace(List<FaceAddRequest> param){
        log.error("【海康添加人脸信息】================开始===="+JSONObject.toJSONString(param));
        try {
            String res = HKTools.addFace(JSONObject.toJSONString(param));
            TypeReference typeReference =
                    new TypeReference< BaseResponse<FaceAddOrEditesponse>>(){};
            BaseResponse<FaceAddOrEditesponse> result = JSONObject.parseObject(res, typeReference.getType());
            log.error("【海康添加人脸信息】================成功====\n"+res);
            logResult(result,"海康添加人脸信息");
            return  result;
        }catch (Exception e){
            log.error("【海康添加人脸信息】================失败====:\n"+ e.getMessage());
@@ -207,14 +197,14 @@
     *编辑人脸信息
     * @return
     */
    public  BaseResponse<FaceAddOrEditesponse>  editFace(List<FaceEditRequest> param){
    public  static  BaseResponse<FaceAddOrEditesponse>  editFace(List<FaceEditRequest> param){
        log.error("【海康编辑人脸信息】================开始===="+JSONObject.toJSONString(param));
        try {
            String res = HKTools.editFace(JSONObject.toJSONString(param));
            TypeReference typeReference =
                    new TypeReference< BaseResponse<FaceAddOrEditesponse>>(){};
            BaseResponse<FaceAddOrEditesponse> result = JSONObject.parseObject(res, typeReference.getType());
            log.error("【海康编辑人脸信息】================成功====\n"+res);
            logResult(result,"海康编辑人脸信息");
            return  result;
        }catch (Exception e){
            log.error("【海康编辑人脸信息】================失败====:\n"+ e.getMessage());
@@ -225,14 +215,14 @@
     *删除人脸信息
     * @return
     */
    public  BaseResponse   delFace(List<FaceEditRequest> param){
    public  static  BaseResponse   delFace(List<FaceEditRequest> param){
        log.error("【海康删除人脸信息】================开始===="+JSONObject.toJSONString(param));
        try {
            String res = HKTools.editFace(JSONObject.toJSONString(param));
            TypeReference typeReference =
                    new TypeReference< BaseResponse>(){};
            BaseResponse  result = JSONObject.parseObject(res, typeReference.getType());
            log.error("【海康删除人脸信息】================成功====\n"+res);
            logResult(result,"海康删除人脸信息");
            return  result;
        }catch (Exception e){
            log.error("【海康删除人脸信息】================失败====:\n"+ e.getMessage());
@@ -259,14 +249,14 @@
     *获取车库列表数据(全量)
     * @return
     */
    public  BaseResponse<List<ParkListResponse>>   parkList(ParkListRequest param){
    public  static  BaseResponse<List<ParkListResponse>>   parkList(ParkListRequest param){
        log.error("【海获取车库列表数据】================开始===="+JSONObject.toJSONString(param));
        try {
            String res = HKTools.parkList(JSONObject.toJSONString(param));
            TypeReference typeReference =
                    new TypeReference< BaseResponse<List<ParkListResponse>>>(){};
            BaseResponse  result = JSONObject.parseObject(res, typeReference.getType());
            log.error("【海康获取车库列表数据】================成功====\n"+res);
            logResult(result,"海康获取车库列表数据");
            return  result;
        }catch (Exception e){
            log.error("【海康获取车库列表数据】================失败====:\n"+ e.getMessage());
@@ -277,14 +267,14 @@
     *获取车库列表数据(全量)
     * @return
     */
    public  BaseResponse<List<EntranceListResponse>>   entranceList(EntranceListRequest param){
    public  static  BaseResponse<List<EntranceListResponse>>   entranceList(EntranceListRequest param){
        log.error("【海获取车库列表数据】================开始===="+JSONObject.toJSONString(param));
        try {
            String res = HKTools.entranceList(JSONObject.toJSONString(param));
            TypeReference typeReference =
                    new TypeReference< BaseResponse<List<EntranceListResponse>>>(){};
            BaseResponse  result = JSONObject.parseObject(res, typeReference.getType());
            log.error("【海康获取车库列表数据】================成功====\n"+res);
            logResult(result,"海康获取车库列表数据");
            return  result;
        }catch (Exception e){
            log.error("【海康获取车库列表数据】================失败====:\n"+ e.getMessage());
@@ -295,14 +285,14 @@
     *固定车辆充值(包期)
     * @return
     */
    public  BaseResponse   carChargeAddtion(CarChargeAddRequest param){
    public  static  BaseResponse   carChargeAddtion(CarChargeAddRequest param){
        log.error("【海康固定车辆充值】================开始===="+JSONObject.toJSONString(param));
        try {
            String res = HKTools.carChargeAddtion(JSONObject.toJSONString(param));
            TypeReference typeReference =
                    new TypeReference< BaseResponse>(){};
            BaseResponse  result = JSONObject.parseObject(res, typeReference.getType());
            log.error("【海康固定车辆充值】================成功====\n"+res);
            logResult(result,"海康固定车辆充值");
            return  result;
        }catch (Exception e){
            log.error("【海康固定车辆充值】================失败====:\n"+ e.getMessage());
@@ -313,14 +303,14 @@
     *固定车辆取消包期
     * @return
     */
    public  BaseResponse   carChargeDeletion(CarChargeDelRequest param){
    public  static  BaseResponse   carChargeDeletion(CarChargeDelRequest param){
        log.error("【海康固定车辆取消包期】================开始===="+JSONObject.toJSONString(param));
        try {
            String res = HKTools.carChargeDeletion(JSONObject.toJSONString(param));
            TypeReference typeReference =
                    new TypeReference< BaseResponse>(){};
            BaseResponse  result = JSONObject.parseObject(res, typeReference.getType());
            log.error("【海康固定车辆取消包期】================成功====\n"+res);
            logResult(result,"海康固定车辆取消包期");
            return  result;
        }catch (Exception e){
            log.error("【海康固定车辆取消包期】================失败====:\n"+ e.getMessage());
@@ -331,14 +321,14 @@
     *车位预约
     * @return
     */
    public  BaseResponse<ParkReservationAddResponse>   parkReservationAddition(ParkReservationAddRequest param){
    public  static  BaseResponse<ParkReservationAddResponse>   parkReservationAddition(ParkReservationAddRequest param){
        log.error("【海康车位预约】================开始===="+JSONObject.toJSONString(param));
        try {
            String res = HKTools.parkAddition(JSONObject.toJSONString(param));
            TypeReference typeReference =
                    new TypeReference< BaseResponse<ParkReservationAddResponse>>(){};
            BaseResponse<ParkReservationAddResponse>  result = JSONObject.parseObject(res, typeReference.getType());
            log.error("【海康车位预约】================成功====\n"+res);
            logResult(result,"海康车位预约");
            return  result;
        }catch (Exception e){
            log.error("【海康车位预约】================失败====:\n"+ e.getMessage());
@@ -349,14 +339,14 @@
     *车位取消预约
     * @return
     */
    public  BaseResponse   parkReservationDeletion(ParkReservationDelRequest param){
    public  static  BaseResponse   parkReservationDeletion(ParkReservationDelRequest param){
        log.error("【海康车位取消预约】================开始===="+JSONObject.toJSONString(param));
        try {
            String res = HKTools.carChargeDeletion(JSONObject.toJSONString(param));
            TypeReference typeReference =
                    new TypeReference< BaseResponse>(){};
            BaseResponse  result = JSONObject.parseObject(res, typeReference.getType());
            log.error("【海康车位取消预约】================成功====\n"+res);
            logResult(result,"海康车位取消预约");
            return  result;
        }catch (Exception e){
            log.error("【海康车位取消预约】================失败====:\n"+ e.getMessage());
@@ -367,14 +357,14 @@
     *访客预约
     * @return
     */
    public  BaseResponse<VisitAppointmentResponse>   visitAppiontment(VisitAppointmentRequest param){
    public  static  BaseResponse<VisitAppointmentResponse>   visitAppiontment(VisitAppointmentRequest param){
        log.error("【海康访客预约】================开始===="+JSONObject.toJSONString(param));
        try {
            String res = HKTools.visitAppiontment(JSONObject.toJSONString(param));
            TypeReference typeReference =
                    new TypeReference< BaseResponse<VisitAppointmentResponse>>(){};
            BaseResponse<VisitAppointmentResponse>  result = JSONObject.parseObject(res, typeReference.getType());
            log.error("【海康访客预约】================成功====\n"+res);
           logResult(result,"海康访客预约");
            return  result;
        }catch (Exception e){
            log.error("【海康访客预约】================失败====:\n"+ e.getMessage());
@@ -385,14 +375,14 @@
     *访客免登记预约
     * @return
     */
    public  BaseResponse<VisitAppointmentVistorResponse>   visitAppiontmentMDJ(VisitAppointmentMDJRequest param){
    public  static  BaseResponse<VisitAppointmentVistorResponse>   visitAppiontmentMDJ(VisitAppointmentMDJRequest param){
        log.error("【海康访客免登记预约】================开始===="+JSONObject.toJSONString(param));
        try {
            String res = HKTools.visitAppiontmentMDJ(JSONObject.toJSONString(param));
            TypeReference typeReference =
                    new TypeReference< BaseResponse<VisitAppointmentVistorResponse> >(){};
            BaseResponse<VisitAppointmentVistorResponse>   result = JSONObject.parseObject(res, typeReference.getType());
            log.error("【海康访客免登记预约】================成功====\n"+res);
            logResult(result,"海康访客免登记预约");
            return  result;
        }catch (Exception e){
            log.error("【海康访客免登记预约】================失败====:\n"+ e.getMessage());
@@ -403,14 +393,14 @@
     *访客权限组列表查询(分页)
     * @return
     */
    public  BaseResponse<PrivilegeGroupListResponse>   privilegeGroup(PrivilegeGroupRequest param){
    public  static  BaseResponse<PrivilegeGroupListResponse>   privilegeGroup(PrivilegeGroupRequest param){
        log.error("【海康访客权限组列表查询】================开始===="+JSONObject.toJSONString(param));
        try {
            String res = HKTools.privilegeGroup(JSONObject.toJSONString(param));
            TypeReference typeReference =
                    new TypeReference< BaseResponse<PrivilegeGroupListResponse> >(){};
            BaseResponse<PrivilegeGroupListResponse>   result = JSONObject.parseObject(res, typeReference.getType());
            log.error("【海康访客权限组列表查询】================成功====\n"+res);
            logResult(result,"海康访客权限组列表查询");
            return  result;
        }catch (Exception e){
            log.error("【海康访客权限组列表查询】================失败====:\n"+ e.getMessage());
@@ -421,20 +411,46 @@
     *门禁设备查询(分页)
     * @return
     */
    public  BaseResponse<AcsDeviceListResponse>   acsDeviceList(AcsDeviceListRequest param){
    public  static  BaseResponse<AcsDeviceListResponse>   acsDeviceList(AcsDeviceListRequest param){
        log.error("【海康门禁设备查询】================开始===="+JSONObject.toJSONString(param));
        try {
            String res = HKTools.acsDeviceList(JSONObject.toJSONString(param));
            TypeReference typeReference =
                    new TypeReference< BaseResponse<AcsDeviceListResponse> >(){};
            BaseResponse<AcsDeviceListResponse>   result = JSONObject.parseObject(res, typeReference.getType());
            log.error("【海康门禁设备查询】================成功====\n"+res);
            logResult(result,"海康门禁设备查询");
            return  result;
        }catch (Exception e){
            log.error("【海康门禁设备查询】================失败====:\n"+ e.getMessage());
        }
        return  null;
    }
    /**
     *事件订阅
     * @return
     */
    public  static  BaseResponse   eventSub(EventSubRequest param){
        log.error("【海康事件订阅】================开始===="+JSONObject.toJSONString(param));
        try {
            String res = HKTools.eventSub(JSONObject.toJSONString(param));
            TypeReference typeReference =
                    new TypeReference< BaseResponse >(){};
            BaseResponse   result = JSONObject.parseObject(res, typeReference.getType());
            logResult(result,"海康事件订阅");
            return  result;
        }catch (Exception e){
            log.error("【海康事件订阅】================失败====:\n"+ e.getMessage());
        }
        return  null;
    }
    private static void logResult(BaseResponse res,String name) {
        if(StringUtils.equals(res.getCode(),HKConstants.RESPONSE_SUCCEE)){
            log.info("【"+name+"】================成功====\n"+res);
        }else{
            log.error("【"+name+"】================失败====:\n"+ res);
        }
    }
}
server/dmvisit_service/src/main/java/com/doumee/core/utils/Constants.java
@@ -19,6 +19,7 @@
    public static final String HK_APPKEY ="HK_APPKEY" ;
    public static final String HK_APPSECRET ="HK_APPSECRET" ;
    public static final String HK_HTTPS ="HK_HTTPS" ;
    public static final String HK_PUSH_URL = "HK_PUSH_URL";
    /**
     * mq tag
server/dmvisit_service/src/main/java/com/doumee/service/business/impl/DeviceServiceImpl.java
@@ -40,8 +40,6 @@
    @Autowired
    private DeviceMapper deviceMapper;
    @Autowired
    private HKService hkService;
    @Override
    public Integer create(Device device) {
server/dmvisit_service/src/main/java/com/doumee/service/business/impl/hksync/HkSyncBaseServiceImpl.java
@@ -1,10 +1,12 @@
package com.doumee.service.business.impl.hksync;
import com.doumee.biz.system.SystemDictDataBiz;
import com.doumee.core.constants.ResponseStatus;
import com.doumee.core.exception.BusinessException;
import com.doumee.core.haikang.model.HKConstants;
import com.doumee.core.haikang.model.param.BaseResponse;
import com.doumee.core.haikang.model.param.request.AcsDeviceListRequest;
import com.doumee.core.haikang.model.param.request.EventSubRequest;
import com.doumee.core.haikang.model.param.request.ParkListRequest;
import com.doumee.core.haikang.model.param.request.PrivilegeGroupRequest;
import com.doumee.core.haikang.model.param.respose.AcsDeviceInfoResponse;
@@ -18,10 +20,12 @@
import com.doumee.dao.business.model.Device;
import com.doumee.dao.business.model.Parks;
import com.doumee.service.business.HkSyncService;
import com.hikvision.artemis.sdk.config.ArtemisConfig;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -33,9 +37,6 @@
 */
@Service
public class HkSyncBaseServiceImpl implements HkSyncService {
    @Autowired
    public HKService hkService;
    /**
     * åŒæ­¥æµ·åº·åœè½¦åº“数据
server/dmvisit_service/src/main/java/com/doumee/service/business/impl/hksync/HkSyncDeviceServiceImpl.java
@@ -58,7 +58,7 @@
            param = new AcsDeviceListRequest();
            param.setPageNo(curPage);
            param.setPageSize(10000);
            BaseResponse<AcsDeviceListResponse> response = hkService.acsDeviceList(param);
            BaseResponse<AcsDeviceListResponse> response = HKService.acsDeviceList(param);
            if(response == null || !StringUtils.equals(response.getCode(), HKConstants.RESPONSE_SUCCEE)){
                throw  new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "对不起,海康同步数据失败~");
            }
server/dmvisit_service/src/main/java/com/doumee/service/business/impl/hksync/HkSyncEventServiceImpl.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,65 @@
package com.doumee.service.business.impl.hksync;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.doumee.biz.system.SystemDictDataBiz;
import com.doumee.core.constants.ResponseStatus;
import com.doumee.core.exception.BusinessException;
import com.doumee.core.haikang.model.HKConstants;
import com.doumee.core.haikang.model.param.BaseResponse;
import com.doumee.core.haikang.model.param.request.EventSubRequest;
import com.doumee.core.haikang.model.param.request.PrivilegeGroupRequest;
import com.doumee.core.haikang.model.param.respose.PrivilegeGroupInfoResponse;
import com.doumee.core.haikang.model.param.respose.PrivilegeGroupListResponse;
import com.doumee.core.haikang.service.HKService;
import com.doumee.core.utils.Constants;
import com.doumee.dao.business.DeviceRoleMapper;
import com.doumee.dao.business.model.DeviceRole;
import com.hikvision.artemis.sdk.config.ArtemisConfig;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
 * æµ·åº·äº‹ä»¶è®¢é˜…表Service实现
 * @author æ±Ÿè¹„蹄
 * @date 2023/11/30 15:33
 */
@Service
public class HkSyncEventServiceImpl extends HkSyncBaseServiceImpl {
    @Autowired
    private SystemDictDataBiz systemDictDataBiz;
    @PostConstruct
    public  int  initHkConfig(){
        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();
        //开始订阅门禁事件、访客事件、和停车场事件
        startHkEventSub();
        return  0;
    }
    /**
     * è®¢é˜…门禁事件、访客事件、和停车场事件
     */
    public void startHkEventSub(){
        EventSubRequest param = new EventSubRequest();
        param.setEventDest(systemDictDataBiz.queryByCode(Constants.HK_PARAM, Constants.HK_PUSH_URL).getCode());
        param.setEventTypes(new Integer[]{HKConstants.EventTypes.PARK_LINE_IN.getKey()
                ,HKConstants.EventTypes.PARK_LINE_OUT.getKey()
                ,HKConstants.EventTypes.PARK_PASS_IN.getKey()
                ,HKConstants.EventTypes.PARK_PASS_OUT.getKey()
                ,HKConstants.EventTypes.VISIT_SIGN_OUT.getKey()
                ,HKConstants.EventTypes.VISIT_SIGN_OUT.getKey()
                ,HKConstants.EventTypes.DOOR_FACE_AUTH_SUCCESS.getKey()});
        HKService.eventSub(param);
    }
}
server/dmvisit_service/src/main/java/com/doumee/service/business/impl/hksync/HkSyncParkServiceImpl.java
@@ -51,7 +51,7 @@
        List<Parks> allList = parksMapper.selectList(null);
            //分页遍历循环查询所有门禁设备数据
        param = new ParkListRequest();
        BaseResponse<List<ParkListResponse>> response = hkService.parkList(param);
        BaseResponse<List<ParkListResponse>> response = HKService.parkList(param);
        if(response == null || !StringUtils.equals(response.getCode(), HKConstants.RESPONSE_SUCCEE)){
            throw  new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "对不起,海康同步数据失败~");
        }
server/dmvisit_service/src/main/java/com/doumee/service/business/impl/hksync/HkSyncPrivilegeServiceImpl.java
@@ -6,13 +6,11 @@
import com.doumee.core.haikang.model.HKConstants;
import com.doumee.core.haikang.model.param.BaseResponse;
import com.doumee.core.haikang.model.param.request.PrivilegeGroupRequest;
import com.doumee.core.haikang.model.param.respose.AcsDeviceInfoResponse;
import com.doumee.core.haikang.model.param.respose.PrivilegeGroupInfoResponse;
import com.doumee.core.haikang.model.param.respose.PrivilegeGroupListResponse;
import com.doumee.core.haikang.service.HKService;
import com.doumee.core.utils.Constants;
import com.doumee.core.utils.DateUtil;
import com.doumee.dao.business.DeviceRoleMapper;
import com.doumee.dao.business.model.Device;
import com.doumee.dao.business.model.DeviceRole;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -58,7 +56,7 @@
            param = new PrivilegeGroupRequest();
            param.setPageNo(curPage);
            param.setPageSize(10000);
            BaseResponse<PrivilegeGroupListResponse> response = hkService.privilegeGroup(param);
            BaseResponse<PrivilegeGroupListResponse> response = HKService.privilegeGroup(param);
            if(response == null || !StringUtils.equals(response.getCode(), HKConstants.RESPONSE_SUCCEE)){
                throw  new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "对不起,海康同步数据失败~");
            }