chengsc
2024-07-21 45490d814b84159f269813e6cff3c79fab6e170b
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
using Model.ModelDto.BllAsnDto;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using WMS.DAL;
using WMS.Entity.BllAsnEntity;
using WMS.Entity.Context;
using WMS.Entity.SysEntity;
using WMS.IBLL.IBllAsnServer;
 
namespace WMS.BLL.BllAsnServer
{
    public class PalletUpShelfServer : DbHelper<BllPalletUpShelf>, IPalletUpShelfServer
    {
        private static readonly SqlSugarScope Db = DataContext.Db;
        public PalletUpShelfServer() : base(Db)
        {
        }
 
        public async Task<List<PalletUpShelfDto>> GetPalletUpShelfList(string traceNo, string taskNo, string palletNo, string skuNo, string skuName, string lotNo, string status, int page, int limit, RefAsync<int> count)
        {
            Expression<Func<BllPalletUpShelf, bool>> item = Expressionable.Create<BllPalletUpShelf>()
                   .AndIF(!string.IsNullOrWhiteSpace(traceNo), it => it.TraceNo.Contains(traceNo.Trim()))
                   .AndIF(!string.IsNullOrWhiteSpace(taskNo), it => it.TaskNo.Contains(taskNo.Trim()))
                   .AndIF(!string.IsNullOrWhiteSpace(palletNo), it => it.PalletNo.Contains(palletNo.Trim()))
                   .AndIF(!string.IsNullOrWhiteSpace(skuNo), it => it.SkuNo.Contains(skuNo.Trim()))
                   .AndIF(!string.IsNullOrWhiteSpace(skuName), it => it.SkuName.Contains(skuName.Trim()))
                   .AndIF(!string.IsNullOrWhiteSpace(lotNo), it => it.LotNo.Contains(lotNo.Trim()))
                   .AndIF(!string.IsNullOrWhiteSpace(status), it => it.Status == status)
                   .And(it => it.IsDel == "0")
                   .ToExpression();//注意 这一句 不能少
 
            
            var list = await Db.Queryable<BllPalletUpShelf>().Where(item)
                .LeftJoin<SysUserInfor>((a, b) => a.CreateUser == b.Id)
                .LeftJoin<SysUserInfor>((a, b, c) => a.UpdateUser == c.Id)
                .LeftJoin<SysWareHouse>((a,b,c,d)=> a.WareHouseNo == d.WareHouseNo)
                .LeftJoin<SysStorageRoadway>((a,b,c,d,e) => a.RoadwayNo == e.RoadwayNo)
                .LeftJoin<SysStorageArea>((a,b,c,d,e,f) => a.AreaNo == f.AreaNo)
                .Select((a, b,c,d,e,f) => new PalletUpShelfDto
                {
                    Id = a.Id,
                    TraceNo = a.TraceNo,
                    TaskNo = a.TaskNo,
                    PalletNo = a.PalletNo,
                    SkuNo = a.SkuNo,
                    SkuName = a.SkuName,
                    LotNo = a.LotNo,
                    Status = a.Status,
                    WareHouseNo = a.WareHouseNo,
                    WareHouseName = d.WareHouseName,
                    RoadwayNo = a.RoadwayNo,
                    RoadwayName = e.RoadwayName,
                    AreaNo = a.AreaNo,
                    AreaName = f.AreaName,
                    LocatNo = a.LocatNo,
 
                    CreateTime = a.CreateTime,
                    CreateUserName = b.RealName,
                    UpdateTime = a.UpdateTime,
                    UpdateUserName = c.RealName,
 
                }).OrderByDescending(a => a.CreateTime).ToOffsetPageAsync(page, limit, count);
 
            return list;
        }
    }
}