2020-12-28 14:55:48 +08:00
|
|
|
|
using BaseInfoClient.Response.Visitor;
|
|
|
|
|
|
using Etor.Infrastructure.Common;
|
|
|
|
|
|
using Etor.Infrastructure.Data;
|
|
|
|
|
|
using Etor.Infrastructure.Serializer;
|
|
|
|
|
|
using Etor.Infrastructure.WebApi;
|
|
|
|
|
|
using ServiceClient;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace BaseInfoClient.Extension
|
|
|
|
|
|
{
|
|
|
|
|
|
public static class QueryVisitorByOpenidOrId
|
|
|
|
|
|
{
|
|
|
|
|
|
public static async Task<List<VisitorResponseItem>> QueryVisitorByOpenId(this BaseInfoHttpClient client
|
|
|
|
|
|
, QueryMenJinVisitorRequest param, bool throwException = false)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
var response = await client.CreateHttpClient().GetAsync(
|
|
|
|
|
|
$"{client.BaseUrl}/api/visitor/v1/Request/QueryByOpenId?OwnerId={param.OwnerId}&Data.OpenId={param.OpenId}");
|
|
|
|
|
|
|
|
|
|
|
|
var content = await response.Content.ReadAsStringAsync();
|
|
|
|
|
|
var result = content.FromJsonTo<ApiResult<List<VisitorResponseItem>>>();
|
|
|
|
|
|
return result.Data;
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
|
{
|
|
|
|
|
|
LogHelper.Error("根据OwnerId获取住户", e);
|
|
|
|
|
|
|
|
|
|
|
|
if (throwException)
|
|
|
|
|
|
{
|
|
|
|
|
|
BusinessException.Throw("获取住户信息失败");
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return new List<VisitorResponseItem>();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return new List<VisitorResponseItem>();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static async Task<VisitorResponseItem> QueryVisitorById(this BaseInfoHttpClient client
|
|
|
|
|
|
, QueryMenJinVisitorRequest param, bool throwException = false)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
var response = await client.CreateHttpClient().GetAsync(
|
|
|
|
|
|
$"{client.BaseUrl}/api/visitor/v1/Request/QueryById?OwnerId={param.OwnerId}&Data.Id={param.Id}&Data.Type={param.Type}");
|
|
|
|
|
|
|
|
|
|
|
|
var content = await response.Content.ReadAsStringAsync();
|
|
|
|
|
|
var result = content.FromJsonTo<ApiResult<VisitorResponseItem>>();
|
|
|
|
|
|
return result.Data;
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
|
{
|
|
|
|
|
|
LogHelper.Error("根据OwnerId获取住户", e);
|
|
|
|
|
|
|
|
|
|
|
|
if (throwException)
|
|
|
|
|
|
{
|
|
|
|
|
|
BusinessException.Throw("获取住户信息失败");
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return new VisitorResponseItem();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return new VisitorResponseItem();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 根据人脸ID获取访客信息
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="client"></param>
|
|
|
|
|
|
/// <param name="param"></param>
|
|
|
|
|
|
/// <param name="throwException"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static async Task<VisitorResponseItem> QueryVisitorByFaceId(this BaseInfoHttpClient client
|
|
|
|
|
|
, int ownerId,string faceId, bool throwException = false)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
var response = await client.CreateHttpClient().GetAsync(
|
|
|
|
|
|
$"{client.BaseUrl}/api/visitor/v1/Request/QueryByFaceId?OwnerId={ownerId}&Data.FaceId={faceId}");
|
|
|
|
|
|
|
|
|
|
|
|
var content = await response.Content.ReadAsStringAsync();
|
|
|
|
|
|
var result = content.FromJsonTo<ApiResult<VisitorResponseItem>>();
|
|
|
|
|
|
return result.Data;
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
|
{
|
|
|
|
|
|
LogHelper.Error("根据OwnerId获取住户", e);
|
|
|
|
|
|
|
|
|
|
|
|
if (throwException)
|
|
|
|
|
|
{
|
|
|
|
|
|
BusinessException.Throw("获取住户信息失败");
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return new VisitorResponseItem();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return new VisitorResponseItem();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 根据人脸ID获取访客信息
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="client"></param>
|
|
|
|
|
|
/// <param name="param"></param>
|
|
|
|
|
|
/// <param name="throwException"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static async Task<List<QueryDeviceByBuildResponse>> QueryVisitorProFace(this BaseInfoHttpClient client
|
|
|
|
|
|
, int projectCode, string buildCode,string unit,int operaterID, int ownerID, bool throwException = false)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
var response = await client.CreateHttpClient().GetAsync(
|
|
|
|
|
|
$"{client.BaseUrl}/api/doorway/v1/device/GetFacesClient?OperaterID={operaterID}&OwnerID={ownerID}&Data.ProjectCode={projectCode}&Data.BuildCode={buildCode}&Data.Unit={unit}&Data.UserType=0");
|
|
|
|
|
|
|
|
|
|
|
|
var content = await response.Content.ReadAsStringAsync();
|
|
|
|
|
|
var result = content.FromJsonTo<ApiResult<List<QueryDeviceByBuildResponse>>>();
|
|
|
|
|
|
return result.Data;
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
|
{
|
|
|
|
|
|
LogHelper.Error("根据OwnerId获取住户", e);
|
|
|
|
|
|
|
|
|
|
|
|
if (throwException)
|
|
|
|
|
|
{
|
|
|
|
|
|
BusinessException.Throw("获取住户设备信息失败");
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return new List<QueryDeviceByBuildResponse>();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return new List<QueryDeviceByBuildResponse>();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|