1
huangxiaoqiang
13 小时以前 af5847927931d3f491d7be5e0178cff3c37ac6f9
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
using SqlSugar;
using System.Linq.Expressions;
using WIDESEA_Core;
using WIDESEA_Core.BaseRepository;
using WIDESEA_Core.BaseServices;
using WIDESEA_Core.Helper;
using WIDESEA_IOrderRepository;
using WIDESEA_IOrderServices;
using WIDESEA_IStorageBasicRepository;
using WIDESEA_IStorageTaskRepository;
using WIDESEA_IStorageTaskServices;
using WIDESEA_Model.Models;
using WIDESEA_Model.Models.Order;
 
namespace WIDESEA_OrderServices
{
    public class Dt_ProductionOutboundOrderDetailService : ServiceBase<Dt_ProductionOutboundOrderDetail, IDt_ProductionOutboundOrderDetailRepository>, IDt_ProductionOutboundOrderDetailService
    {
        private readonly IUnitOfWorkManage _unitOfWorkManage;
        private readonly IStockInfoDetailRepository _stockInfoDetailRepository;
        public Dt_ProductionOutboundOrderDetailService(IDt_ProductionOutboundOrderDetailRepository BaseDal,
                                        IUnitOfWorkManage unitOfWorkManage,
                                        IStockInfoDetailRepository stockInfoDetailRepository) : base(BaseDal)
        {
            _unitOfWorkManage = unitOfWorkManage;
            _stockInfoDetailRepository = stockInfoDetailRepository;
        }
        public override PageGridData<Dt_ProductionOutboundOrderDetail> GetPageData(PageDataOptions options)
        {
            string wheres = ValidatePageOptions(options);
            //获取排序字段
            Dictionary<string, 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 data = BaseDal.Db.Queryable<Dt_ProductionOutboundOrderDetail>()
                .WhereIF(!wheres.IsNullOrEmpty(), wheres)
                .OrderBy(orderByModels)
                .ToPageList(options.Page, options.Rows, ref totalCount);
 
            foreach (var item in data)
            {
                var detail = _stockInfoDetailRepository.QueryFirst(x => x.MaterielCode == item.MaterielCode);
                if (detail != null)
                {
                    item.Remark = "有库存";
                }
                else
                {
                    item.Remark = "无库存";
                }
            }
            return new PageGridData<Dt_ProductionOutboundOrderDetail>(totalCount, data);
        }
    }
}