From bb7f59a301a390e04443fa4745bd2afa1fa58e0f Mon Sep 17 00:00:00 2001
From: qiuyao <qiuyao@hnkhzn.com>
Date: 星期一, 28 四月 2025 16:38:30 +0800
Subject: [PATCH] 人脸识别离线SDK

---
 项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_TelescopicService/LoginhsyService.cs |  120 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 110 insertions(+), 10 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_TelescopicService/LoginhsyService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_TelescopicService/LoginhsyService.cs"
index e1c56c0..e2edc32 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_TelescopicService/LoginhsyService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_TelescopicService/LoginhsyService.cs"
@@ -4,9 +4,11 @@
 using System.Text;
 using System.Threading.Tasks;
 using AutoMapper;
+using SqlSugar;
 using WIDESEAWCS_Core;
 using WIDESEAWCS_Core.BaseRepository;
 using WIDESEAWCS_Core.BaseServices;
+using WIDESEAWCS_DTO.Telescopic;
 using WIDESEAWCS_ITelescopicService;
 using WIDESEAWCS_Model.Models;
 
@@ -15,20 +17,118 @@
     public class LoginhsyService : ServiceBase<Dt_Loginhsy, IRepository<Dt_Loginhsy>>, ILoginhsyService
     {
         public IRepository<Dt_Loginhsy> Repository => BaseDal;
+        private readonly IRepository<Sys_User> _user;
 
-        public LoginhsyService(IRepository<Dt_Loginhsy> BaseDal) : base(BaseDal)
+        public LoginhsyService(IRepository<Sys_User> user, IRepository<Dt_Loginhsy> BaseDal) : base(BaseDal)
         {
-            
+            _user = user;
         }
-        //public override PageGridData<Dt_Loginhsy> GetPageData(PageDataOptions options)
-        //{
-        //    OrderByParameters = new Dictionary<string, SqlSugar.OrderByType> {
-        //        {
-        //            nameof(Dt_Loginhsy.CreateDate),SqlSugar.OrderByType.Desc//鎸夋椂闂撮檷搴忔帓鍒�
-        //        } };
-        //    return base.GetPageData(options);
-        //}
 
+        public WebResponseContent LoginRecord(PaginationDTO pagination)
+        {
+            try
+            {
+                int totalCount = 0;
+
+                var sys = _user.Db.Queryable<Sys_User>();
+                var main = Db.Queryable<Dt_Loginhsy>();
+
+                //妯$硦鏌ヨ
+                var query = sys.InnerJoin<Dt_Loginhsy>((a, b) => a.UserName == b.UserName);
+                if (!string.IsNullOrEmpty(pagination.searchKeyword))
+                {
+                    query = query.Where((a, b) =>
+                        a.UserTrueName.Contains(pagination.searchKeyword) ||
+                        a.Userteam.Contains(pagination.searchKeyword) ||
+                        b.OpCenten.Contains(pagination.searchKeyword));
+                }
+                
+                //鏃堕棿鏌ヨ
+                if (pagination.startDate.HasValue && pagination.endDate.HasValue)
+                {
+                    query = query.Where((a, b) => b.LoginTiem >= pagination.startDate.Value && b.LoginTiem <= pagination.endDate.Value);
+                }
+
+                // 鎺掑簭澶勭悊
+                if (!string.IsNullOrEmpty(pagination.sortField))
+                {
+                    //isAsc锛氳繖鏄竴涓竷灏斿�硷紝鍒ゆ柇鎺掑簭鏄崌搴� (true)"asc" ,杩樻槸闄嶅簭 (false) "desc"
+                    var isAsc = pagination.sortOrder?.ToLower() == "asc";//pagination.sortOrder 涓嶄负绌猴紝鍒欒皟鐢� ToLower() 鏂规硶灏嗗叾杞负灏忓啓瀛楁瘝
+
+                    query = pagination.sortField.ToLower() switch
+                    {
+                        //濡傛灉isAsc 涓簍ure灏辨墽琛宷uery.OrderBy((a, b) => b.LoginTiem, OrderByType.Asc)鍗囧簭鎺掑簭锛�
+                        //濡傛灉涓篺ales灏辨墽琛宷uery.OrderBy((a, b) => b.LoginTiem, OrderByType.Desc)闄嶅簭鎺掑簭
+                        "logintiem" => isAsc ? query.OrderBy((a, b) => b.LoginTiem, OrderByType.Asc)
+                                             : query.OrderBy((a, b) => b.LoginTiem, OrderByType.Desc),
+
+                        "outtiem" => isAsc ? query.OrderBy((a, b) => b.OutTiem, OrderByType.Asc)
+                                           : query.OrderBy((a, b) => b.OutTiem, OrderByType.Desc),
+
+                        //"usertruename" => isAsc ? query.OrderBy((a, b) => a.UserTrueName, OrderByType.Asc)
+                        //: query.OrderBy((a, b) => a.UserTrueName, OrderByType.Desc),
+                        _ => query.OrderBy((a, b) => b.LoginTiem, OrderByType.Desc) // 榛樿鎸夌櫥鍏ユ椂闂撮檷搴�
+                    };
+                }
+                else
+                {
+                    // 榛樿鎸� LoginTiem 闄嶅簭
+                    query = query.OrderBy((a, b) => b.LoginTiem, OrderByType.Desc);
+                }
+
+
+                //杩斿洖缁撴灉
+                var result = query.Select((a, b) => new
+                {
+                    a.User_Id,
+                    a.UserTrueName,
+                    a.Userteam,
+                    a.HeadImageUrl,
+                    b.LoginTiem,
+                    b.OutTiem,
+                    b.OpCenten,
+                }).ToPageList(pagination.pageIndex, pagination.pageSize, ref totalCount);
+
+                return new WebResponseContent
+                {
+                    Status = true,
+                    Data = new
+                    {
+                        TotalCount = totalCount, // 鎬绘暟
+                        PageIndex = pagination.pageIndex, // 椤垫暟
+                        PageSize = pagination.pageSize, // 涓�椤靛灏戜釜鏁版嵁
+                        Items = result
+                    }
+                };
+            }
+            catch (Exception ex)
+            {
+                return new WebResponseContent { Status = false, Message = "閿欒: " + ex.Message };
+            }
+        }
+
+
+
+
+        public WebResponseContent OutLoginTime(string account)
+        {
+            try
+            {
+                var log = BaseDal.QueryData(x=>x.UserName== account).OrderByDescending(x=>x.UserName).FirstOrDefault();
+                if (log==null)
+                {
+                    return new WebResponseContent { Status = false, Message = "澶辫触" };
+                }
+                log.OutTiem = DateTime.Now;
+                BaseDal.UpdateData(log);
+                return new WebResponseContent { Status = true, Data = log.OutTiem };
+            }
+            catch (Exception ex)
+            {
+
+                return new WebResponseContent { Status = false, Message = "閿欒淇℃伅"+ex };
+            }
+        }
     }
    
 }

--
Gitblit v1.9.3