1
huangxiaoqiang
3 天以前 2da4ff61e1004f55330b369869650bd8d5c05d73
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
using AngleSharp.Dom;
using Mapster;
using SqlSugar;
using System.Threading.Tasks;
using WIDESEA_Common;
using WIDESEA_Core;
using WIDESEA_DTO;
using WIDESEA_Model.Models;
 
namespace WIDESEA_StorageBasicService;
 
public class LocationErrorService : ServiceBase<DtLocationInfo, ILocationErrorRepository>, ILocationErrorService
{
    private readonly IMapper _mapper;
 
    public LocationErrorService(ILocationErrorRepository BaseDal,IMapper mapper,IDt_TaskService taskService) : base(BaseDal)
    {
        _mapper = mapper;
    }
    public override PageGridData<DtLocationInfo> GetPageData(PageDataOptions options)
    {
        string wheres = ValidatePageOptions(options);
        //获取排序字段
        Dictionary<string, SqlSugar.OrderByType> orderbyDic = GetPageDataSort(options, TProperties);
        List<OrderByModel> orderByModels = new List<OrderByModel>();
        foreach (var item in orderbyDic)
        {
            OrderByModel orderByModel = new()
            {
                FieldName = item.Key,
                OrderByType = item.Value
            };
            orderByModels.Add(orderByModel);
        }
 
 
        int totalCount = 0;
        List<SearchParameters> searchParametersList = new List<SearchParameters>();
        if (!string.IsNullOrEmpty(options.Wheres))
        {
            try
            {
                searchParametersList = options.Wheres.DeserializeObject<List<SearchParameters>>();
                options.Filter = searchParametersList;
            }
            catch { }
        }
 
        var now = DateTime.Now;
        // 使用Subtract方法
        var threeHoursAgo = now.Subtract(TimeSpan.FromHours(3));
 
        var data = BaseDal.Db.Queryable<DtLocationInfo>()
            .Where(x => x.LocationStatus != 2 && x.LocationStatus != 0)
            .WhereIF(!wheres.IsNullOrEmpty(), wheres)
            .OrderBy(orderByModels)
            .ToPageList(options.Page, options.Rows, ref totalCount);
        return new PageGridData<DtLocationInfo>(totalCount, data);
    }
}