jiangping
2024-09-09 c47f7b9c4899036c52ad0e4f46c4aff7102110bc
server/visits/dmvisit_service/src/main/java/com/doumee/core/haikang/service/HKService.java
@@ -9,13 +9,18 @@
import com.doumee.core.haikang.model.param.BaseResponse;
import com.doumee.core.haikang.model.param.request.*;
import com.doumee.core.haikang.model.param.respose.*;
import com.doumee.core.utils.Constants;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.InputStream;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Slf4j
public class HKService {
@@ -408,6 +413,24 @@
        return  null;
    }
    /**
     *访客预约
     * @return
     */
    public  static  BaseResponse<IccmAppointmentResponse>   iccmAppointment(IccmAppointmentRequest param){
        log.info("【海康访客预约】================开始===="+JSONObject.toJSONString(param));
        try {
            String res = HKTools.iccmAppointment(JSONObject.toJSONString(param));
            TypeReference typeReference =
                    new TypeReference< BaseResponse<IccmAppointmentResponse>>(){};
            BaseResponse<IccmAppointmentResponse>  result = JSONObject.parseObject(res, typeReference.getType());
           logResult(result,"海康访客预约");
            return  result;
        }catch (Exception e){
            log.error("【海康访客预约】================失败====:\n"+ e.getMessage());
        }
        return  null;
    }
    /**
     *访客预约取消
     * @return
     */
@@ -462,6 +485,24 @@
        return  null;
    }
    /**
     *访客免登记预约
     * @return
     */
    public  static  BaseResponse<IccmAppointmentMDJResponse>   iccmAppiontmentMDJ(IccmAppointmentMDJRequest param){
        log.info("【海康访客免登记预约】================iccm开始===="+JSONObject.toJSONString(param));
        try {
            String res = HKTools.iccmAppointmentMDJ(JSONObject.toJSONString(param));
            TypeReference typeReference =
                    new TypeReference< BaseResponse<IccmAppointmentMDJResponse> >(){};
            BaseResponse<IccmAppointmentMDJResponse>   result = JSONObject.parseObject(res, typeReference.getType());
            logResult(result,"海康访客免登记预约");
            return  result;
        }catch (Exception e){
            log.error("【海康访客免登记预约】================iccm失败====:\n"+ e.getMessage());
        }
        return  null;
    }
    /**
     *访客权限组列表查询(分页)
     * @return
     */
@@ -469,6 +510,24 @@
        log.info("【海康访客权限组列表查询】================开始===="+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());
            logResult(result,"海康访客权限组列表查询");
            return  result;
        }catch (Exception e){
            log.error("【海康访客权限组列表查询】================失败====:\n"+ e.getMessage());
        }
        return  null;
    }
    /**
     *访客权限组列表查询(分页)
     * @return
     */
    public  static  BaseResponse<PrivilegeGroupListResponse>   privilegIccmeGroup(PrivilegeGroupRequest param){
        log.info("【海康访客权限组列表查询】================开始===="+JSONObject.toJSONString(param));
        try {
            String res = HKTools.privilegIccmeGroup(JSONObject.toJSONString(param));
            TypeReference typeReference =
                    new TypeReference< BaseResponse<PrivilegeGroupListResponse> >(){};
            BaseResponse<PrivilegeGroupListResponse>   result = JSONObject.parseObject(res, typeReference.getType());
@@ -802,6 +861,42 @@
        return  null;
    }
    /**
     *查询访客预约记录(分页)
     * @return
     */
    public  static  BaseResponse<BaseListPageResponse<IccmAppointmentListResponse>>   iccmAppointmentRecords(IccmAppointmentListRequest param){
        log.info("【海康访客预约记录查询】================开始===="+JSONObject.toJSONString(param));
        try {
            String res = HKTools.iccmAppointmentRecords(JSONObject.toJSONString(param));
            TypeReference typeReference =
                    new TypeReference<BaseResponse<BaseListPageResponse<IccmAppointmentListResponse>>>(){};
            BaseResponse<BaseListPageResponse<IccmAppointmentListResponse>>   result = JSONObject.parseObject(res, typeReference.getType());
            logResult(result,"海康访客预约记录查询");
            return  result;
        }catch (Exception e){
            log.error("【海康访客预约记录查询】================失败====:\n"+ e.getMessage());
        }
        return  null;
    }
    /**
     *1.9.1根据微信公众号信息获取AccessToken(分页)
     * @return
     */
    public  static  BaseResponse<String>   wxAccessToken(String configId,String tagId){
        log.info("【海康根据微信公众号信息获取AccessToken】================开始====configId:"+configId+" && tagId:"+tagId);
        try {
            String res = HKTools.wxAccessToken(configId,tagId);
            TypeReference typeReference =
                    new TypeReference<BaseResponse<String>>(){};
            BaseResponse<String>   result = JSONObject.parseObject(res, typeReference.getType());
            logResult(result,"海康根据微信公众号信息获取AccessToken");
            return  result;
        }catch (Exception e){
            log.error("【海康根据微信公众号信息获取AccessToken】================失败====:\n"+ e.getMessage());
        }
        return  null;
    }
    /**
     *查询访客来访记录(已登记)(分页)
     * @return
     */
@@ -834,6 +929,28 @@
            return  result;
        }catch (Exception e){
            log.error("【海康全量组织查询】================失败====:\n"+ e.getMessage());
        }
        return  null;
    }
    /**
     *获取工作台菜单免密登陆调整地址
     * @return
     */
    public  static  String   getMenuUrl(Integer type,String token){
        String menuId = HKConstants.MenuPageId.zhaf;
        if(Constants.equalsInteger(type,Constants.ONE)){
        }else  if(Constants.equalsInteger(type,Constants.TWO)){
        }else  if(Constants.equalsInteger(type,Constants.THREE)){
        }
        log.info("【海康获取工作台菜单免密登陆调整地址】================开始====menuId:"+menuId+"==token:"+token);
        try {
            String res = HKTools.getMenuUrl(menuId,token);
            return  res;
        }catch (Exception e){
            log.error("【海康获取工作台菜单免密登陆调整地址】================失败====:\n"+ e.getMessage());
        }
        return  null;
    }
@@ -950,16 +1067,16 @@
     * @return
     */
    public  static  BaseResponse<BaseListPageResponse<VehicleTimeRangeInfoResponse>>   vehicleTimeRangeList(TimeRangeListRequest param){
        log.info("【海康增量人员查询】================开始===="+JSONObject.toJSONString(param));
        log.info("【海康增量车辆查询】================开始===="+JSONObject.toJSONString(param));
        try {
            String res = HKTools.vehicleTimeRangeList(JSONObject.toJSONString(param));
            TypeReference typeReference =
                    new TypeReference< BaseResponse<BaseListPageResponse<VehicleTimeRangeInfoResponse>> >(){};
            BaseResponse<BaseListPageResponse<VehicleTimeRangeInfoResponse>>   result = JSONObject.parseObject(res, typeReference.getType());
            logResult(result,"海康增量人员查询");
            logResult(result,"海康增量车辆查询");
            return  result;
        }catch (Exception e){
            log.error("【海康增量人员查询】================失败====:\n"+ e.getMessage());
            log.error("【海康增量车辆查询】================失败====:\n"+ e.getMessage());
        }
        return  null;
    }
@@ -1000,6 +1117,144 @@
        return  null;
    }
    /**
     *分页获取广播点(分页)
     * @return
     */
    public  static  BaseResponse<BaseListPageResponse<FetchAudioChannelInfoResponse>>   fetchAudioChannel(FetchAudioChannelRequest param){
        log.info("【海康获取分页获取广播点】================开始===="+JSONObject.toJSONString(param));
        try {
            String res = HKTools.fetchAudioChannel(JSONObject.toJSONString(param));
            TypeReference typeReference =
                    new TypeReference< BaseResponse<BaseListPageResponse<FetchAudioChannelInfoResponse>> >(){};
            BaseResponse<BaseListPageResponse<FetchAudioChannelInfoResponse>>   result = JSONObject.parseObject(res, typeReference.getType());
            logResult(result,"海康获取分页获取广播点");
            return  result;
        }catch (Exception e){
            log.error("【海康获取分页获取广播点】================失败====:\n"+ e.getMessage());
        }
        return  null;
    }
    /**
     *分页获取广播点(分页)
     * @return
     */
    public  static  BaseResponse<BaseListPageResponse<FetchAudioChannelInfoResponse>>   fetchAudioDevice(FetchAudioChannelRequest param){
        log.info("【海康获取分页获取广播点】================开始===="+JSONObject.toJSONString(param));
        try {
            String res = HKTools.fetchAudioDevice(JSONObject.toJSONString(param));
            TypeReference typeReference =
                    new TypeReference< BaseResponse<BaseListPageResponse<FetchAudioChannelInfoResponse>> >(){};
            BaseResponse<BaseListPageResponse<FetchAudioChannelInfoResponse>>   result = JSONObject.parseObject(res, typeReference.getType());
            logResult(result,"海康获取分页获取广播点");
            return  result;
        }catch (Exception e){
            log.error("【海康获取分页获取广播点】================失败====:\n"+ e.getMessage());
        }
        return  null;
    }
    /**
     *获取全部月台信息
     * @return
     */
    public  static  BaseResponse<BaseListPageResponse<PlatformListInfoResponse>>   platformsList(PlatformsListRequest param){
        log.info("【海康获取全部月台信息】================开始===="+JSONObject.toJSONString(param));
        try {
            String res = HKTools.platformsList(JSONObject.toJSONString(param));
            TypeReference typeReference =
                    new TypeReference< BaseResponse<BaseListPageResponse<PlatformListInfoResponse>> >(){};
            BaseResponse<BaseListPageResponse<PlatformListInfoResponse>>   result = JSONObject.parseObject(res, typeReference.getType());
            logResult(result,"海康获取全部月台信息");
            return  result;
        }catch (Exception e){
            log.error("【海康获取全部月台信息】================失败====:\n"+ e.getMessage());
        }
        return  null;
    }
    /**
     *获取月台组件配置的LED设备清单
     * @return
     */
    public  static  BaseResponse<BaseListPageResponse<LedRecordsInfoResponse>>   ledRecords(LedRecordsRequest param){
        log.info("【海康获取月台组件配置的LED设备清单】================开始===="+JSONObject.toJSONString(param));
        try {
            String res = HKTools.ledRecords(JSONObject.toJSONString(param));
            TypeReference typeReference =
                    new TypeReference< BaseResponse<BaseListPageResponse<LedRecordsInfoResponse>> >(){};
            BaseResponse<BaseListPageResponse<LedRecordsInfoResponse>>   result = JSONObject.parseObject(res, typeReference.getType());
            logResult(result,"海康获取月台组件配置的LED设备清单");
            return  result;
        }catch (Exception e){
            log.error("【海康获取月台组件配置的LED设备清单】================失败====:\n"+ e.getMessage());
        }
        return  null;
    }
    /**
     *用于设置广播的自定播放和停止
     * @return
     */
    public  static  BaseResponse    customBroadcast(CustomBroadcastRequest param){
        log.info("【海康用于设置广播的自定播放和停止】================开始===="+JSONObject.toJSONString(param));
        try {
            String res = HKTools.customBroadcast(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;
    }
    /**
     *获取全部月台信息
     * @return
     */
    public  static  BaseResponse<BaseListPageResponse<PlatformStatusInfoResponse>>   platformStatus(PlatformStatusRequest param) {
        log.info("【海康获取全部月台信息】================开始====" + JSONObject.toJSONString(param));
        try {
            String res = HKTools.platformStatus(param.getPlatformIds());
            TypeReference typeReference =
                    new TypeReference<BaseResponse<BaseListPageResponse<PlatformStatusInfoResponse>>>() {
                    };
            BaseResponse<BaseListPageResponse<PlatformStatusInfoResponse>> result = JSONObject.parseObject(res, typeReference.getType());
            logResult(result, "海康获取全部月台信息");
            return result;
        } catch (Exception e) {
            log.error("【海康获取全部月台信息】================失败====:\n" + e.getMessage());
        }
        return null;
    }
    /**
     *发送消息给LED
     * @return
     */
    public  static  BaseResponse   transparentchannel(TransparentChannelHeadRequest head,TransparentChannelBodyRequest param){
        log.info("【海康发送消息给LED】================开始===="+JSONObject.toJSONString(param));
        try {
            Map<String,String> header = toMap(head);
            String res = HKTools.transparentchannel(header,JSONObject.toJSONString(param));
            TypeReference typeReference =
                    new TypeReference<BaseResponse>(){};
            BaseResponse  result = JSONObject.parseObject(res, typeReference.getType());
            logResult(result,"海康发送消息给LED");
            return  result;
        }catch (Exception e){
            log.error("【海康发送消息给LED】================失败====:\n"+ e.getMessage());
        }
        return  null;
    }
    public static Map<String, String> toMap(Object obj) throws IllegalAccessException {
        Map<String, String> map = new HashMap<>();
        Class<?> clazz = obj.getClass();
        for (Field field : clazz.getDeclaredFields()) {
            field.setAccessible(true); // 使得私有字段也可以访问
            map.put(field.getName(), (String) field.get(obj));
        }
        return map;
    }
    /**
     *查询场内车停车信息(分页)
     * @return
     */
@@ -1017,6 +1272,42 @@
        }
        return  null;
    }
    /**
     *根据用户标识获取客户端TGC接口
     * @return
     */
    public  static  BaseResponse<ApplyCTGTResponse>   applyCTGT(ApplyCTGTRequest param){
        log.info("【海康根据用户标识获取客户端TGC接口】================开始===="+JSONObject.toJSONString(param));
        try {
            String res = HKTools.applyCTGT(JSONObject.toJSONString(param));
            TypeReference typeReference =
                    new TypeReference< BaseResponse<ApplyCTGTResponse>>(){};
            BaseResponse<ApplyCTGTResponse>   result = JSONObject.parseObject(res, typeReference.getType());
            logResult(result,"海康根据用户标识获取客户端TGC接口");
            return  result;
        }catch (Exception e){
            log.error("【海康根据用户标识获取客户端TGC接口息】================失败====:\n"+ e.getMessage());
        }
        return  null;
    }
    /**
     *根据登录标识TGC申请登录凭证ST接口
     * @return
     */
    public  static  BaseResponse<ApplySTResponse>   applyST(ApplySTequest param){
        log.info("【海康根据登录标识TGC申请登录凭证ST接口】================开始===="+JSONObject.toJSONString(param));
        try {
            String res = HKTools.applyST(JSONObject.toJSONString(param));
            TypeReference typeReference =
                    new TypeReference< BaseResponse<ApplySTResponse>>(){};
            BaseResponse<ApplySTResponse>   result = JSONObject.parseObject(res, typeReference.getType());
            logResult(result,"海康根据登录标识TGC申请登录凭证ST接口口");
            return  result;
        }catch (Exception e){
            log.error("【海康根据登录标识TGC申请登录凭证ST接口息】================失败====:\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);