111
yanjinhui
2025-03-28 9f0add00d40fc00e039b92b2fb3469394b1a24f5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AutoMapper;
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.BaseRepository;
using WIDESEAWCS_Core.BaseServices;
using WIDESEAWCS_DTO.Telescopic;
using WIDESEAWCS_ITelescopicService;
using WIDESEAWCS_Model.Models;
 
namespace WIDESEAWCS_TelescopicService
{
    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 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);//登入时间
                }
                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 = true, Message = "错误" + ex };
            }
        }
 
      
 
        public WebResponseContent OutLoginTime(int id)
        {
            try
            {
                var log = BaseDal.QueryFirst(x => x.ID == id);
                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 };
            }
        }
    }
   
}