k94314517
2024-10-30 47a53d22a025c0ed095c9c4ed2e1ce35ce54184e
server/visits/dmvisit_service/src/main/java/com/doumee/core/haikang/service/HKService.java
@@ -1,8 +1,10 @@
package com.doumee.core.haikang.service;
import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
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.HKTools;
import com.doumee.core.haikang.model.param.BaseListPageResponse;
@@ -11,20 +13,19 @@
import com.doumee.core.haikang.model.param.request.*;
import com.doumee.core.haikang.model.param.respose.*;
import com.doumee.core.utils.Constants;
import com.doumee.core.utils.HttpsUtil;
import com.hikvision.artemis.sdk.config.ArtemisConfig;
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 org.springframework.beans.BeanUtils;
import oshi.hardware.Sensors;
import sun.management.Sensor;
import java.io.InputStream;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@Slf4j
public class HKService {
@@ -235,6 +236,8 @@
     */
    public static InputStream getFaceInputStream(FacePictureRequest param) {
        log.info("【海康人脸访问图片流】================开始===="+JSONObject.toJSONString(param));
        log.error("********************ArtemisConfig.host***********************************"+ ArtemisConfig.host);
        log.error("********************ArtemisConfig.key********************************"+ArtemisConfig.appKey);
        try {
            InputStream res = HKTools.getFaceInputStream(JSONObject.toJSONString(param));
            log.error("【海康人脸访问图片流】================成功====\n");
@@ -904,17 +907,35 @@
     *根据配置微信公众号编号查询微信公众号信息
     * @return
     */
    public  static  BaseResponse<BaseListPageResponse<WxConfigInfoResponse>>   getWxConfig(WxConfigInfoRequest param){
    public  static  BaseResponse< WxConfigInfoResponse>  getWxConfig(WxConfigInfoRequest param){
        log.info("【海康根据配置微信公众号编号查询微信公众号信息】================开始===="+JSONObject.toJSONString(param));
        try {
            String res = HKTools.getWxConfig(toMap(param));
            TypeReference typeReference =
                    new TypeReference<BaseResponse<BaseListPageResponse<WxConfigInfoResponse>>>(){};
            BaseResponse<BaseListPageResponse<WxConfigInfoResponse>>   result = JSONObject.parseObject(res, typeReference.getType());
                    new TypeReference<BaseResponse<WxConfigInfoResponse>>(){};
            BaseResponse<WxConfigInfoResponse>   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<GetTodoListResponse>>   getTodoListPage(GetTodoListRequest param){
        log.info("【海康分页获取待办列表】================开始===="+JSONObject.toJSONString(param));
        try {
            String res = HKTools.getTodoListPage(toMap(param));
            TypeReference typeReference =
                    new TypeReference<BaseResponse<BaseListPageResponse<GetTodoListResponse>>>(){};
            BaseResponse<BaseListPageResponse<GetTodoListResponse>>   result = JSONObject.parseObject(res, typeReference.getType());
            logResult(result,"海康分页获取待办列表");
            return  result;
        }catch (Exception e){
            log.error("【海康分页获取待办列表】================失败====:\n"+ e.getMessage());
        }
        return  null;
    }
@@ -1069,13 +1090,15 @@
     * @return
     */
    public  static  String   getMenuUrl(Integer type,String token){
        String menuId = HKConstants.MenuPageId.zhaf;
        String menuId = HKConstants.MenuPageId.afzx;
        if(Constants.equalsInteger(type,Constants.ONE)){
            menuId = HKConstants.MenuPageId.wyhq;
            menuId = HKConstants.MenuPageId.xkzx;
        }else  if(Constants.equalsInteger(type,Constants.TWO)){
            menuId = HKConstants.MenuPageId.xzbg;
            menuId = HKConstants.MenuPageId.ngzx;
        }else  if(Constants.equalsInteger(type,Constants.THREE)){
            menuId = HKConstants.MenuPageId.yyzx;
            menuId = HKConstants.MenuPageId.jsc;
        }else  if(Constants.equalsInteger(type,Constants.FOUR)){
            menuId = HKConstants.MenuPageId.kqgzt;
        }
        log.info("【海康获取工作台菜单免密登陆调整地址】================开始====menuId:"+menuId+"==token:"+token);
        try {
@@ -1213,20 +1236,20 @@
        return  null;
    }
    /**
     *增量车辆查询(分页)
     *人脸评分
     * @return
     */
    public  static  BaseResponse<BaseListPageResponse<VehicleTimeRangeInfoResponse>>   facePictureCheck(TimeRangeListRequest param){
        log.info("【海康增量人员查询】================开始===="+JSONObject.toJSONString(param));
    public  static  BaseResponse<FacePictureCheckResponse>   facePictureCheck(FacePictureCheckRequest param){
        log.info("【人脸评分】================开始===="+JSONObject.toJSONString(param));
        try {
            String res = HKTools.facePictureCheck(JSONObject.toJSONString(param));
            TypeReference typeReference =
                    new TypeReference< BaseResponse<BaseListPageResponse<VehicleTimeRangeInfoResponse>> >(){};
            BaseResponse<BaseListPageResponse<VehicleTimeRangeInfoResponse>>   result = JSONObject.parseObject(res, typeReference.getType());
            logResult(result,"海康增量人员查询");
                    new TypeReference<BaseResponse<FacePictureCheckResponse>>(){};
            BaseResponse<FacePictureCheckResponse>   result = JSONObject.parseObject(res, typeReference.getType());
            logResult(result,"人脸评分");
            return  result;
        }catch (Exception e){
            log.error("【海康增量人员查询】================失败====:\n"+ e.getMessage());
            log.error("【人脸评分】================失败====:\n"+ e.getMessage());
        }
        return  null;
    }
@@ -1302,6 +1325,10 @@
        }
        return  null;
    }
    /**
     *获取月台组件配置的LED设备清单
     * @return
@@ -1439,6 +1466,42 @@
        }
        return  null;
    }
    public static BaseResponse sendSmsByHk(Map<String,Object> param,String url){
        log.info("【海康发送短信】================开始===="+JSONObject.toJSONString(param));
        try {
            TypeReference typeReference =
                    new TypeReference<BaseResponse>(){};
            String res = HttpsUtil.postJson(url, JSONObject.toJSONString(param));
            BaseResponse result = JSONObject.parseObject(res, typeReference.getType());
            logResult(result,"海康发送短信");
            return  result;
        }catch (Exception e){
            log.error("【海康发送短信】================失败====:\n"+ e.getMessage());
            e.printStackTrace();
        }
       return null;
    }
    public static BaseResponse<MenuDataResponse> getMenuConfig(Map<String,String> param){
        log.info("【获取菜单功能配置项】================开始===="+ JSONObject.toJSONString(param));
        try {
            String res = HKTools.getHkMenu(param);
            TypeReference typeReference =
                    new TypeReference<BaseResponse<MenuDataResponse>>(){};
            BaseResponse<MenuDataResponse>   result = JSONObject.parseObject(res, typeReference.getType());
            logResult(result,"获取菜单功能配置项");
            return  result;
        }catch (Exception e){
            log.error("【获取菜单功能配置项】================失败====:\n"+ e.getMessage());
            e.printStackTrace();
        }
        return null;
    }
    private static void logResult(BaseResponse res,String name) {
        if(StringUtils.equals(res.getCode(),HKConstants.RESPONSE_SUCCEE)){
            log.info("【"+name+"】================成功====\n"+res);