|
@@ -1,45 +1,62 @@
|
|
|
-using SCADA.CommonLib.Data.DIL;
|
|
|
+using Mysqlx;
|
|
|
+using SCADA.CommonLib.Data.DIL;
|
|
|
+using SCADA.CommonLib.Helper;
|
|
|
using SCADA_DAQ.Customer.Models.FaceRecognition;
|
|
|
+using SCADA_DAQ.Customer.Service.Websocket;
|
|
|
+using SCADA_DAQ.Plugin.CoreUI.UserManage;
|
|
|
using SqlSchema.DBNames;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
+using System.Net.Sockets;
|
|
|
+using System.Text;
|
|
|
+using System.Web;
|
|
|
using System.Web.Http;
|
|
|
+using System.Windows.Forms;
|
|
|
+using static Mono.Security.X509.X520;
|
|
|
|
|
|
namespace SCADA_DAQ.Customer.Service.Controllers
|
|
|
{
|
|
|
/// <summary>
|
|
|
- ///
|
|
|
+ /// 人脸识别设备接口
|
|
|
/// </summary>
|
|
|
[RoutePrefix("api/v1")]
|
|
|
public class HttpForFaceController : ApiController
|
|
|
{
|
|
|
+ // 服务实例
|
|
|
+ private WssForFace WssForFaceService = ServiceHost.Instance.GetService<WssForFace>("FaceRecognitionWs");
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 上传识别成功记录
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="payload"></param>
|
|
|
+ /// <returns></returns>
|
|
|
[HttpPost]
|
|
|
[Route("record/face")]
|
|
|
- public object RecordFace([FromBody] Dictionary<string, object> payload)
|
|
|
+ public object RecordFace([FromBody] ReceiveModel payload)
|
|
|
{
|
|
|
- if (payload.TryGetValue("logs", out object logs))
|
|
|
- {
|
|
|
- var x = logs.ToString();
|
|
|
- }
|
|
|
- return new { Result = 0, Msg = "" };
|
|
|
+
|
|
|
+ return new { Result = 1, Msg = "" };
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ /// <summary>
|
|
|
+ /// 上传陌生人记录(识别失败)
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="payload"></param>
|
|
|
+ /// <returns></returns>
|
|
|
[HttpPost]
|
|
|
[Route("stranger")]
|
|
|
- public object Stranger([FromBody] Dictionary<string, object> payload)
|
|
|
+ public object Stranger([FromBody] ReceiveModel payload)
|
|
|
{
|
|
|
- Dictionary<string, object> x;
|
|
|
- if (payload.TryGetValue("logs", out object logs))
|
|
|
- {
|
|
|
- x = logs as Dictionary<string, object>;
|
|
|
- }
|
|
|
- return new { Result = 0, Msg = "" };
|
|
|
+
|
|
|
+ return new { Result = 1, Msg = "" };
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ /// <summary>
|
|
|
+ /// 识别后在线验证
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="payload"></param>
|
|
|
+ /// <returns></returns>
|
|
|
[HttpPost]
|
|
|
[Route("verify_user")]
|
|
|
public object VerifyUser([FromBody] Dictionary<string, object> payload)
|
|
@@ -47,15 +64,27 @@ namespace SCADA_DAQ.Customer.Service.Controllers
|
|
|
payload.TryGetValue("user_id", out object userId);
|
|
|
payload.TryGetValue("confidence", out object confidence);
|
|
|
|
|
|
- var user = Env.SgIDAL.App_HongShi_Users.GetData<UsersModel>().Where(t => t.UserId == userId.ToString()).LastOrDefault();
|
|
|
- var res = user.ConfidenceLevel <= Convert.ToDouble(confidence)
|
|
|
- ? new { Result = 0, Msg = "验证通过" }
|
|
|
- : new { Result = 3, Msg = "验证失败" };
|
|
|
-
|
|
|
+ var user = Env.SgIDAL.App_HongShi_Users.GetData<UsersModel>()?
|
|
|
+ .Where(t => t.UserId == userId.ToString()).LastOrDefault();
|
|
|
+ if (user == null)
|
|
|
+ {
|
|
|
+ WssForFaceService.CheckResult = WssForFace.CheckState.NG;
|
|
|
+
|
|
|
+ return new { Result = 3, Msg = "用户不存在" };
|
|
|
+ }
|
|
|
+
|
|
|
+ var res = user.ConfidenceLevel <= Convert.ToDouble(confidence)
|
|
|
+ ? new { Result = 0, Msg = "验证通过" }
|
|
|
+ : new { Result = 3, Msg = "验证失败" };
|
|
|
+ WssForFaceService.CheckResult = WssForFace.CheckState.OK;
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ /// <summary>
|
|
|
+ /// 设备录入自定义编号判断——在设备上添加人员
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="payload"></param>
|
|
|
+ /// <returns></returns>
|
|
|
[HttpPost]
|
|
|
[Route("addFace")]
|
|
|
public object AddFace([FromBody] Dictionary<string, object> payload)
|
|
@@ -74,6 +103,9 @@ namespace SCADA_DAQ.Customer.Service.Controllers
|
|
|
payload.TryGetValue("photo", out object photo);
|
|
|
payload.TryGetValue("validity_period", out object idValid);
|
|
|
|
|
|
+ if (Env.SgIDAL.App_HongShi_Users.Exist($"UserId_Str='{userId}'"))
|
|
|
+ return new { Result = 1, Msg = "用户ID已存在" };
|
|
|
+
|
|
|
Env.SgIDAL.App_HongShi_Users.Insert(
|
|
|
new UpdateItem(T_Col_Name.App_HongShi_Users.UserId_Str, userId?.ToString()),
|
|
|
new UpdateItem(T_Col_Name.App_HongShi_Users.Name_Str, name?.ToString()),
|
|
@@ -86,5 +118,38 @@ namespace SCADA_DAQ.Customer.Service.Controllers
|
|
|
return new { Result = 0, Msg = "" };
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 更新用户信息
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="payload"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpPost]
|
|
|
+ [Route("user/inf_photo")]
|
|
|
+ public object UpdateUserInfo([FromBody] ReceiveModel payload)
|
|
|
+ {
|
|
|
+ var res = false;
|
|
|
+ for (int i = 0; i < payload.Content.Count; i++)
|
|
|
+ {
|
|
|
+ var item = payload.Content[i];
|
|
|
+ item.TryGetValue("user_id", out object userId);
|
|
|
+ item.TryGetValue("vl_photo", out object vlPhoto);
|
|
|
+ item.TryGetValue("id_valid", out object idValid);
|
|
|
+ string base64 = HttpUtility.UrlDecode(vlPhoto.ToString(), Encoding.UTF8);
|
|
|
+ base64 = base64.Replace("data:image/png;base64,", "").Replace("data:image/jgp;base64,", "")
|
|
|
+ .Replace("data:image/jpg;base64,", "").Replace("data:image/jpeg;base64,", "");//将base64头部信息替换
|
|
|
+ if (userId == null || vlPhoto == null || idValid == null)
|
|
|
+ continue;
|
|
|
+ res = Env.SgIDAL.App_HongShi_Users.Update($"UserId_Str='{userId}'",
|
|
|
+ new UpdateItem(T_Col_Name.App_HongShi_Users.Photo_Str, base64),
|
|
|
+ new UpdateItem(T_Col_Name.App_HongShi_Users.IdValid_Dt, idValid),
|
|
|
+ new UpdateItem(T_Col_Name.App_HongShi_Users.ModifyTime_Dt, DateTime.Now.Format())
|
|
|
+ );
|
|
|
+ };
|
|
|
+
|
|
|
+ return new { Result = res ? 0 : 1, Msg = res ? "更新成功" : "更新失败", Content = "" };
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
}
|