zhangliwen 1 year ago
parent
commit
08a82c20cb
17 changed files with 327 additions and 229 deletions
  1. 3 0
      aliyun_eicp3.0/skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Machines/CNCMachines1.cs
  2. 23 1
      aliyun_eicp3.0/skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Models/FaceRecognition/QueryUsersModel.cs
  3. 39 2
      aliyun_eicp3.0/skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Models/FaceRecognition/ReceiveModel.cs
  4. 0 165
      aliyun_eicp3.0/skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Models/HttpModel/PayloadModel.cs
  5. 2 2
      aliyun_eicp3.0/skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Models/PropertyManagement/AddPropertyModel.cs
  6. 1 1
      aliyun_eicp3.0/skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Models/PropertyManagement/QueryPropertyModel.cs
  7. 1 1
      aliyun_eicp3.0/skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Models/TaskManagement/AddTaskModel.cs
  8. 88 23
      aliyun_eicp3.0/skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Service/Controllers/HttpForFaceController.cs
  9. 20 0
      aliyun_eicp3.0/skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Service/websocket/WssForFace.cs
  10. 1 1
      aliyun_eicp3.0/skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/UctFrmDeviceState.xaml.cs
  11. 5 2
      aliyun_eicp3.0/skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/UctFrmFaceRecognition.xaml.cs
  12. 1 1
      aliyun_eicp3.0/skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/UctFrmProcessing.xaml.cs
  13. 107 4
      aliyun_eicp3.0/skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/UctFrmProcessingManagement.xaml.cs
  14. 1 1
      aliyun_eicp3.0/skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/UctFrmPropertyManagement.xaml.cs
  15. 4 1
      aliyun_eicp3.0/skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/UctFrmQCManagement.xaml.cs
  16. 1 1
      aliyun_eicp3.0/skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/UctFrmTaskManagement.xaml.cs
  17. 30 23
      aliyun_eicp3.0/skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Views/Uct/UctAddUserInfo.xaml.cs

+ 3 - 0
aliyun_eicp3.0/skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Machines/CNCMachines1.cs

@@ -18,6 +18,9 @@ using static System.Windows.Forms.VisualStyles.VisualStyleElement.TaskbarClock;
 
 namespace SCADA_DAQ.Customer.Machines
 {
+    /// <summary>
+    /// 
+    /// </summary>
     [DisplayName("1#数控机床")]
     public class CNCMachines1 : BasePLCMachine
     {

+ 23 - 1
aliyun_eicp3.0/skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Models/FaceRecognition/QueryUsersModel.cs

@@ -12,6 +12,9 @@ namespace SCADA_DAQ.Customer.Models.FaceRecognition
 {
     public class QueryUsersModel : BaseQuery
     {
+        /// <summary>
+        /// 
+        /// </summary>
         public QueryUsersModel() : base(Env.SgIDAL.App_HongShi_Users)
         {
 
@@ -20,7 +23,7 @@ namespace SCADA_DAQ.Customer.Models.FaceRecognition
         /// <summary>
         /// 时间
         /// </summary>
-        [AutoViewProperty("时间", Icon = "Timetable")]
+        [AutoViewProperty("创建时间", Icon = "Timetable")]
         [Query(T_Col_Name.App_HongShi_Users.CreateTime_Dt)]
         public DateRange DATETIME
         {
@@ -38,5 +41,24 @@ namespace SCADA_DAQ.Customer.Models.FaceRecognition
 
 
 
+        /// <summary>
+        /// 人员有效期
+        /// </summary>
+        [AutoViewProperty("人员有效期", Icon = "Timetable")]
+        [Query(T_Col_Name.App_HongShi_Users.IdValid_Dt)]
+        public DateRange IdValid
+        {
+            get { return _IdValid; }
+            set
+            {
+                if (value != _IdValid)
+                {
+                    _IdValid = value;
+                    OnPropertyChanged(nameof(IdValid));
+                }
+            }
+        }
+        private DateRange _IdValid = new DateRange(Env.Schedual) { TimeInterval = DateRangeInterval.All };
+
     }
 }

+ 39 - 2
aliyun_eicp3.0/skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Models/FaceRecognition/ReceiveModel.cs

@@ -69,7 +69,7 @@ namespace SCADA_DAQ.Customer.Models.FaceRecognition
 
 
         /// <summary>
-        /// 
+        /// 客户端id
         /// </summary>
         public string Form
         {
@@ -88,7 +88,7 @@ namespace SCADA_DAQ.Customer.Models.FaceRecognition
 
 
         /// <summary>
-        /// 
+        /// 发送方
         /// </summary>
         public string To
         {
@@ -124,6 +124,43 @@ namespace SCADA_DAQ.Customer.Models.FaceRecognition
         private Dictionary<string, object> _Data;
 
 
+        
+        /// <summary>
+        /// 内容
+        /// </summary>
+        public List<Dictionary<string, object>> Content
+        {
+            get { return _Content; }
+            set
+            {
+                if (value != _Content)
+                {
+                    _Content = value;
+                    OnPropertyChanged(nameof(Content));
+                }
+            }
+        }
+        private List<Dictionary<string, object>> _Content;
+
+
+
+        /// <summary>
+        /// 记录
+        /// </summary>
+        public List<Dictionary<string, object>> Logs
+        {
+            get { return _Logs; }
+            set
+            {
+                if (value != _Logs)
+                {
+                    _Logs = value;
+                    OnPropertyChanged(nameof(Logs));
+                }
+            }
+        }
+        private List<Dictionary<string, object>> _Logs;
+
 
     }
 }

+ 0 - 165
aliyun_eicp3.0/skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Models/HttpModel/PayloadModel.cs

@@ -1,165 +0,0 @@
-using LiveCharts.Defaults;
-using SCADA.CommonLib;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace SCADA_DAQ.Customer.Models.HttpModel
-{
-
-    /// <summary>
-    /// 
-    /// </summary>
-    public class PayloadModel : ObservableObject
-    {
-
-        /// <summary>
-        /// 设备号
-        /// </summary>
-        public string Sn
-        {
-            get { return _Sn; }
-            set
-            {
-                if (value != _Sn)
-                {
-                    _Sn = value;
-                    OnPropertyChanged(nameof(Sn));
-                }
-            }
-        }
-        private string _Sn;
-
-        /// <summary>
-        /// 温度
-        /// </summary>
-        public float Temperature
-        {
-            get { return _Temperature; }
-            set
-            {
-                if (value != _Temperature)
-                {
-                    _Temperature = value;
-                    OnPropertyChanged(nameof(Temperature));
-                }
-            }
-        }
-        private float _Temperature;
-
-
-        /// <summary>
-        /// 设备识别类型:1:刷人脸 2:刷卡 3:刷身份证
-        /// </summary>
-        public int Type
-        {
-            get { return _Type; }
-            set
-            {
-                if (value != _Type)
-                {
-                    _Type = value;
-                    OnPropertyChanged(nameof(Type));
-                }
-            }
-        }
-        private int _Type;
-
-
-
-        /// <summary>
-        /// 用户id
-        /// </summary>
-        public int User_Id
-        {
-            get { return _User_Id; }
-            set
-            {
-                if (value != _User_Id)
-                {
-                    _User_Id = value;
-                    OnPropertyChanged(nameof(User_Id));
-                }
-            }
-        }
-        private int _User_Id;
-
-
-        /// <summary>
-        /// 刷卡用户的卡号,type 为 3 时为空,为 1 或者 2 时取人员信息中的卡号
-        /// </summary>
-        public string Card
-        {
-            get { return _Card; }
-            set
-            {
-                if (value != _Card)
-                {
-                    _Card = value;
-                    OnPropertyChanged(nameof(Card));
-                }
-            }
-        }
-        private string _Card;
-
-
-
-        /// <summary>
-        /// 这个值为人证访客接口下发的 user_id ,只有 type 为 3 并且设备使用【指定身份证模式】这个字段的内容才有值
-        /// </summary>
-        public string Visit_Id
-        {
-            get { return _Visit_Id; }
-            set
-            {
-                if (value != _Visit_Id)
-                {
-                    _Visit_Id = value;
-                    OnPropertyChanged(nameof(Visit_Id));
-                }
-            }
-        }
-        private string _Visit_Id;
-
-
-        /// <summary>
-        /// 人脸算法识别到的相识度
-        /// </summary>
-        public float Confidence
-        {
-            get { return _Confidence; }
-            set
-            {
-                if (value != _Confidence)
-                {
-                    _Confidence = value;
-                    OnPropertyChanged(nameof(Confidence));
-                }
-            }
-        }
-        private float _Confidence;
-
-
-
-        /// <summary>
-        /// 彩色人脸图片 格式:Base64编码图片,这里上传的直接是 base64 数据,不需要 url decoder
-        /// </summary>
-        public string Photo
-        {
-            get { return _Photo; }
-            set
-            {
-                if (value != _Photo)
-                {
-                    _Photo = value;
-                    OnPropertyChanged(nameof(Photo));
-                }
-            }
-        }
-        private string _Photo;
-
-
-    }
-}

+ 2 - 2
aliyun_eicp3.0/skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Models/PropertyManagement/AddPropertyModel.cs

@@ -24,7 +24,7 @@ namespace SCADA_DAQ.Customer.Models.PropertyManagement
         /// <summary>
         /// 属性名
         /// </summary>
-        [AutoViewProperty("属性名", Icon = "", OptionItemsSource = nameof(PropertyNameList), 
+        [AutoViewProperty("属性名", Icon = "ViewDay", OptionItemsSource = nameof(PropertyNameList), 
             StringType = StringType.IsLimited,
             DisplayMemberPath = T_Col_Name.App_HongShi_PropertyItem.PropertyName_Str,
             SelectedValuePath = T_Col_Name.App_HongShi_PropertyItem.PropertyName_Str)]
@@ -53,7 +53,7 @@ namespace SCADA_DAQ.Customer.Models.PropertyManagement
         /// <summary>
         /// 属性值
         /// </summary>
-        [AutoViewProperty("属性值", Icon = "")]
+        [AutoViewProperty("属性值", Icon = "ViewDayOutline")]
         [Column(T_Col_Name.App_HongShi_PropertyManagement.PropertyValue_Str)]
         public string PropertyValue
         {

+ 1 - 1
aliyun_eicp3.0/skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Models/PropertyManagement/QueryPropertyModel.cs

@@ -29,7 +29,7 @@ namespace SCADA_DAQ.Customer.Models.PropertyManagement
         /// <summary>
         /// 属性名
         /// </summary>
-        [AutoViewProperty("属性名", Icon = "",
+        [AutoViewProperty("属性名", Icon = "ViewDay",
             OptionItemsSource = nameof(PropertyNameList),
             StringType = StringType.IsLimited,
             DisplayMemberPath = T_Col_Name.App_HongShi_PropertyItem.PropertyName_Str,

+ 1 - 1
aliyun_eicp3.0/skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Models/TaskManagement/AddTaskModel.cs

@@ -278,7 +278,7 @@ namespace SCADA_DAQ.Customer.Models.TaskManagement
         /// <summary>
         /// 操作编号
         /// </summary>
-        [AutoViewProperty("操作编号", Icon = "CurrencyUsd", OptionItemsSource = nameof(OperationNoList),
+        [AutoViewProperty("操作编号", Icon = "Vhs", OptionItemsSource = nameof(OperationNoList),
             StringType = StringType.IsLimited,
             DisplayMemberPath = "PropertyValue",
             SelectedValuePath = "PropertyValue")]

+ 88 - 23
aliyun_eicp3.0/skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Service/Controllers/HttpForFaceController.cs

@@ -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 = "" };
+        }
+
+
     }
 }

+ 20 - 0
aliyun_eicp3.0/skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Service/websocket/WssForFace.cs

@@ -35,6 +35,26 @@ namespace SCADA_DAQ.Customer.Service.Websocket
         /// </summary>
         public readonly ConcurrentDictionary<string, WebSocketClient> Sockets = new ConcurrentDictionary<string, WebSocketClient>();
 
+        /// <summary>
+        /// 校验结果
+        /// </summary>
+        public enum CheckState
+        {       
+            OK = 0,   // 通过
+            NG = 1,   // 不通过
+            None = 2  // 未识别
+        }
+
+        /// <summary>
+        /// 当前校验结果
+        /// </summary>
+        public CheckState CheckResult = CheckState.None;
+
+        /// <summary>
+        /// 校验结果事件
+        /// </summary>
+        public event EventHandler<CheckState> CheckResultEvent;
+
         /// <summary>
         /// 接收消息事件
         /// </summary>

+ 1 - 1
aliyun_eicp3.0/skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/UctFrmDeviceState.xaml.cs

@@ -26,7 +26,7 @@ namespace SCADA_DAQ.Customer
     /// <summary>
     /// UctFrmDeviceState.xaml 的交互逻辑
     /// </summary>
-    [UctMenu("设备状态", Icon = "看板")]
+    [UctMenu("设备状态", Icon = "CellphoneLink")]
     public partial class UctFrmDeviceState : BaseUctFrm<QueryDeviceStateModel>
     {
         /// <summary>

+ 5 - 2
aliyun_eicp3.0/skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/UctFrmFaceRecognition.xaml.cs

@@ -5,6 +5,7 @@ using SCADA.CommonLib.Helper;
 using SCADA_DAQ.Customer.Models.FaceRecognition;
 using SCADA_DAQ.Customer.Service.Websocket;
 using SCADA_DAQ.Customer.Views.Uct;
+using SCADA_DAQ.Plugin.MachineUI.ExTool.ScadaTestTool;
 using SqlSchema.DBNames;
 using System;
 using System.Data;
@@ -18,10 +19,10 @@ namespace SCADA_DAQ.Customer
     /// <summary>
     /// UctFrmFaceRecognition.xaml 的交互逻辑
     /// </summary>
-    [UctMenu("人脸识别管理", Icon = "看板")]
+    [UctMenu("人脸识别管理", Icon = "AdminFill")]
     public partial class UctFrmFaceRecognition : BaseUctFrm
     {
-        // 服务实例
+        // 服务实例
         private WssForFace WssForFaceService = ServiceHost.Instance.GetService<WssForFace>("FaceRecognitionWs");
 
         /// <summary>
@@ -108,6 +109,7 @@ namespace SCADA_DAQ.Customer
                         if (item == null)
                             continue;
                         var device = WssForFaceService.Sockets.Values.Where(t => t.DeviceName == deviceMode.DeviceName)?.LastOrDefault();
+                        if (device != null) return;
                         device.SocketConnection.Send(JsonHelper.JsonSerialize(new
                         {
                             cmd = "to_device",
@@ -260,6 +262,7 @@ namespace SCADA_DAQ.Customer
             base.CloseThis();
         }
 
+        
     }
 
 }

+ 1 - 1
aliyun_eicp3.0/skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/UctFrmProcessing.xaml.cs

@@ -27,7 +27,7 @@ namespace SCADA_DAQ.Customer
     /// UctFrmProcessing.xaml 的交互逻辑
     /// 废弃
     /// </summary>
-    [UctMenu("加工界面", Icon = "看板")]
+    [UctMenu("加工界面", Icon = "CashMultiple")]
     public partial class UctFrmProcessing : BaseUctFrm
     {
         // 数据库对象

+ 107 - 4
aliyun_eicp3.0/skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/UctFrmProcessingManagement.xaml.cs

@@ -1,12 +1,17 @@
-using SCADA.CommonCtrl.WpfControl;
+using NPOI.SS.Formula.Functions;
+using SCADA.CommonCtrl.WpfControl;
 using SCADA.CommonLib;
 using SCADA.CommonLib.CommonModel;
 using SCADA.CommonLib.Data.DIL;
 using SCADA.CommonLib.Helper;
 using SCADA_DAQ.Customer.Models;
+using SCADA_DAQ.Customer.Models.FaceRecognition;
 using SCADA_DAQ.Customer.Models.ProcessingManagement;
 using SCADA_DAQ.Customer.Models.PropertyManagement;
 using SCADA_DAQ.Customer.Models.TaskManagement;
+using SCADA_DAQ.Customer.Service.Controllers;
+using SCADA_DAQ.Customer.Service.Websocket;
+using SCADA_DAQ.Plugin.MachineUI.ExTool.ScadaTestTool;
 using SqlSchema.DBNames;
 using System;
 using System.Collections.Generic;
@@ -33,12 +38,20 @@ namespace SCADA_DAQ.Customer
     [UctMenu("加工管理", Icon = "看板")]
     public partial class UctFrmProcessingManagement : BaseUctFrm
     {
+        // 服务实例
+        private WssForFace WssForFaceService = ServiceHost.Instance.GetService<WssForFace>("FaceRecognitionWs");
+
+        private DevicesModel DeviceMode = new DevicesModel();
+
         /// <summary>
         /// 
         /// </summary>
         public UctFrmProcessingManagement()
         {
             InitializeComponent();
+
+            Env.Schedual.DateTimeChanged += Schedual_DateTimeChanged;
+
             //FrmQuery.QueryModel = QueryModel;
             //QueryProcessingModel queryProcessingModel = new QueryProcessingModel();
             //ChildFrmQuery.QueryModel = queryProcessingModel;
@@ -54,6 +67,37 @@ namespace SCADA_DAQ.Customer
             ChildGrid.DataTableColumnLables = column;
 
             //MainGrid.CurrentCellChanged += MainGrid_CurrentCellChanged;
+            WssForFaceService.ClientMessage += WssForFace_ClientMessage;
+        }
+
+        /// <summary>
+        /// ws消息接收事件
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void WssForFace_ClientMessage(object sender, WebSocketClientMessage e)
+        {
+            //var id = e.Guid;
+            var message = e.Message as ReceiveModel;
+            if (message.Data != null)
+            {
+                message.Data.TryGetValue("cmd", out object cmd);
+                if (cmd == null) return;
+                if (cmd.ToString() == "setSwitchRet")
+                {
+                    message.Data.TryGetValue("code", out object code);
+                    message.Data.TryGetValue("msg", out object msg);
+                    if (code.ToString() == "0")
+                    {
+                        ((IApp)System.Windows.Application.Current).ShowShortToast(msg.ToString(), ControlStyle.Success);
+                    }
+                    else
+                    {
+                        ((IApp)System.Windows.Application.Current).ShowShortToast(msg.ToString(), ControlStyle.Warning);
+                    }
+                }
+            }
+
         }
 
 
@@ -73,7 +117,11 @@ namespace SCADA_DAQ.Customer
             var res = false;
             string filter = "";
             string orderString = "";
-            int count = grid.SelectedItems.Count;
+            int count = grid.SelectedItems.Count;  // 选择项数量
+
+            var isFace = false;  // 是否人脸
+            var isCard = false;  // 是否刷卡
+
             // 遍历选中项
             for (int i = 0; i < count; i++)
             {
@@ -90,6 +138,8 @@ namespace SCADA_DAQ.Customer
                     filter += $"OrderNo_Str='{drv[T_Col_Name.App_HongShi_TaskInfo.OrderNo_Str]?.ToString()}'";
                     orderString += $"{drv[T_Col_Name.App_HongShi_TaskInfo.OrderNo_Str]?.ToString()}";
                 }
+                isFace = (bool)drv[T_Col_Name.App_HongShi_TaskInfo.IsFaceRecognition_Bool] || isFace;
+                isCard = (bool)drv[T_Col_Name.App_HongShi_TaskInfo.IsCardOnline_Bool] || isCard;
             }
 
             if (filter == null || filter == "")
@@ -98,8 +148,9 @@ namespace SCADA_DAQ.Customer
             {
                 if (System.Windows.MessageBox.Show($"是否开始加工{orderString}?", "提示", MessageBoxButton.OKCancel) != MessageBoxResult.OK)
                     return;
-                res = Env.SgIDAL.App_HongShi_TaskInfo.Update(filter,
-                    new UpdateItem(T_Col_Name.App_HongShi_TaskInfo.TaskState_Str, "加工中"));
+                Checkout(isFace, isCard, "on");
+                //res = Env.SgIDAL.App_HongShi_TaskInfo.Update(filter,
+                //    new UpdateItem(T_Col_Name.App_HongShi_TaskInfo.TaskState_Str, "加工中"));
             }
             else if (btTag == "Done")
             {
@@ -131,6 +182,45 @@ namespace SCADA_DAQ.Customer
             }
         }
 
+        /// <summary>
+        /// 开启/禁用设备
+        /// </summary>
+        /// <param name="sw"></param>
+        private void SetSwitch(string sw)
+        {
+            Dispatcher.Invoke(() =>
+            {
+                var device = WssForFaceService.Sockets.Values.Where(t => t.DeviceName == DeviceMode.DeviceName)?.LastOrDefault();
+                if (device != null) return;
+                device.SocketConnection.Send(JsonHelper.JsonSerialize(new
+                {
+                    cmd = "to_device",
+                    form = device.Guid.ToString(),
+                    to = device.DeviceName,
+                    data = new
+                    {
+                        cmd = "setSwitch",
+                        value = sw,
+                        offtime = "00:00-24:00"
+                    }
+                }));
+            });
+        }
+
+        /// <summary>
+        /// 校验
+        /// </summary>
+        /// <param name="isFace"></param>
+        /// <param name="isCard"></param>
+        /// <param name="sw"></param>
+        /// <returns></returns>
+        private void Checkout(bool isFace, bool isCard, string sw)
+        {
+            ShowChildWindow(new AutoView(DeviceMode), true, true, "选择在线设备", () => {
+                SetSwitch(sw);
+                return true;
+            });
+        }
 
         /// <summary>
         /// 双击事件
@@ -163,6 +253,19 @@ namespace SCADA_DAQ.Customer
             //ChildGrid.DataSource = Env.SgIDAL.App_HongShi_TaskInfo.GetData($"OrderNo_Str='{orderNo}'");
         }
 
+        private void Schedual_DateTimeChanged(object sender, DateTimeChangedArgs e)
+        {
+            if (e.TimeFlag.Second % 1 == 0)
+            {
+                if (WssForFaceService.CheckResult == WssForFace.CheckState.OK)
+                {
+                    WssForFaceService.CheckResult = WssForFace.CheckState.None;
+                    ((IApp)System.Windows.Application.Current).ShowShortToast("识别成功!", ControlStyle.Success);
+                    SetSwitch("off");
+                }
+            }
+        }
+
         /// <summary>
         /// 查询
         /// </summary>

+ 1 - 1
aliyun_eicp3.0/skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/UctFrmPropertyManagement.xaml.cs

@@ -24,7 +24,7 @@ namespace SCADA_DAQ.Customer
     /// <summary>
     /// UctFrmPropertyManagement.xaml 的交互逻辑
     /// </summary>
-    [UctMenu("属性管理", Icon = "看板")]
+    [UctMenu("属性管理", Icon = "ViewDay")]
     public partial class UctFrmPropertyManagement : BaseUctFrm<QueryPropertyModel, AddPropertyModel>
     {
         /// <summary>

+ 4 - 1
aliyun_eicp3.0/skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/UctFrmQCManagement.xaml.cs

@@ -118,7 +118,10 @@ namespace SCADA_DAQ.Customer
                 if (res)
                 {
                     ((IApp)Application.Current).ShowShortToast("操作成功!", ControlStyle.Success);
-                    Query();
+                    Dispatcher.Invoke(() =>
+                    {
+                        Query();
+                    });
                     QCCheckModelValue.Performance = "";
                 }
                 else

+ 1 - 1
aliyun_eicp3.0/skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/UctFrmTaskManagement.xaml.cs

@@ -25,7 +25,7 @@ namespace SCADA_DAQ.Customer
     /// <summary>
     /// UctFrmHistoryQuery.xaml 的交互逻辑
     /// </summary>
-    [UctMenu("订单管理", Icon = "看板")]
+    [UctMenu("订单管理", Icon = "Calendar2Fill")]
     public partial class UctFrmTaskManagement : BaseUctFrm<QueryTaskModel, AddTaskModel>
     {
         /// <summary>

+ 30 - 23
aliyun_eicp3.0/skoda-scada-daq3.0-master/skoda-scada-daq3.0-master/scada_-daq3.0-master/SCADA_DAQ/Customer/Views/Uct/UctAddUserInfo.xaml.cs

@@ -17,6 +17,11 @@ using System.Windows.Input;
 using System.Windows.Controls.Primitives;
 using System.Windows.Threading;
 using NPOI.POIFS.Properties;
+using SCADA.CommonLib.Data.DIL;
+using System.Drawing;
+using System.Drawing.Imaging;
+using NPOI.SS.Formula.Functions;
+using static Mysqlx.Datatypes.Scalar.Types;
 
 namespace SCADA_DAQ.Customer.Views.Uct
 {
@@ -98,11 +103,7 @@ namespace SCADA_DAQ.Customer.Views.Uct
         /// <exception cref="NotImplementedException"></exception>
         private void WssForFaceService_ClientConnected(object sender, Plugin.Core.Service.WebSocketClientConnected e)
         {
-            // 更新设备列表
-            //Dispatcher.Invoke(() =>
-            //{
-            //    deviceCell.Add(WssForFaceService.Sockets[e.SocketConnection.ConnectionInfo.Id.ToString()].DeviceName);
-            //});
+
         }
 
         /// <summary>
@@ -116,7 +117,8 @@ namespace SCADA_DAQ.Customer.Views.Uct
             // 更新设备列表
             Dispatcher.Invoke(() =>
             {
-                DeviceCell.Remove(WssForFaceService.Sockets[e.SocketConnection.ConnectionInfo.Id.ToString()].DeviceName);
+                if(WssForFaceService.Sockets.TryGetValue(e.SocketConnection.ConnectionInfo.Id.ToString(), out var name))
+                    DeviceCell.Remove(name.DeviceName);
             });
         }
 
@@ -214,35 +216,40 @@ namespace SCADA_DAQ.Customer.Views.Uct
 
             if (dlg.ShowDialog() == DialogResult.OK)
             {
+                // 预览
                 try
                 {
-                    // 预览
                     string filename = dlg.FileName;
-
-                    // 复制到内存中
-                    //Image img = Image.FromFile(filename);
-                    //Bitmap bmp = new Bitmap(img);
-                    //img.Dispose();
-                    //MemoryStream memStream = new MemoryStream();
-                    //bmp.Save(memStream, ImageFormat.Png);
-                    //memStream.Position = 0;
-                    //BitmapImage result = new BitmapImage();
-                    //result.BeginInit();
-                    //result.CacheOption = BitmapCacheOption.OnLoad;
-                    //result.StreamSource = memStream;
-                    //result.EndInit();
-                    //result.Freeze();
+                    // 将图片复制到内存流中
+                    Image img = Image.FromFile(filename);
+                    Bitmap bmp = new Bitmap(img);
+                    img.Dispose();
+                    MemoryStream memStream = new MemoryStream();
+                    bmp.Save(memStream, ImageFormat.Png);
+                    memStream.Position = 0;
+                    BitmapImage result = new BitmapImage();
+                    result.BeginInit();
+                    result.CacheOption = BitmapCacheOption.OnLoad;
+                    result.StreamSource = memStream;
+                    result.EndInit();
+                    result.Freeze();
 
                     // 直接打开
-                    BitmapImage result = new BitmapImage(new Uri(filename));
+                    //BitmapImage result = new BitmapImage(new Uri(filename));
                     Dispatcher.Invoke(() =>
                     {
                         FaceImg.Source = result;
                     });
+
+                    // 图片流转base64
+                    byte[] arr = memStream.ToArray();
+                    memStream.Close();
+                    string strbaser64 = Convert.ToBase64String(arr);
+                    UsersModelValues.Photo = strbaser64;
                 }
                 catch (SecurityException ex)
                 {
-                    System.Windows.MessageBox.Show($"Error: {ex.Message}\n\n");
+                    System.Windows.MessageBox.Show($"Error: {ex.Message}");
                 }
             }
         }