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
| using MES.Service.DB;
| using MES.Service.Dto.service;
| using MES.Service.Dto.webApi;
| using MES.Service.Modes;
| using SqlSugar;
|
| namespace MES.Service.service.Warehouse;
|
| /// <summary>
| /// 销售托盘管理服务
| /// </summary>
| public class SalesPalletManager : Repository<SalesPallet>
| {
| /// <summary>
| /// 获取销售托盘分页数据
| /// </summary>
| /// <param name="request">查询请求参数</param>
| /// <returns></returns>
| public (List<SalesPalletQueryDto> item, int TotalCount)
| GetSalesPalletPage(SalesPalletSearchDto request)
| {
| var query = Db.Queryable<SalesPallet>()
| .LeftJoin<SalesDeliveryNotice>((z, a) => a.BillNo == z.BillNo)
| .LeftJoin<SalesDeliveryNoticeDetail>((z, a, b) =>
| a.ErpId == b.ErpHeadId && z.ItemId.ToString() == b.MaterialId)
| .LeftJoin<MesItems>((z, a, b, s) => s.Id.ToString() == b.MaterialId)
| .LeftJoin<MesUnit>((z, a, b, s, u) =>
| u.Id.ToString() == b.SalesUnitId)
| .LeftJoin<SysUser>((z, a, b, s, u, su) => su.Fcode == z.CheckUser)
| .LeftJoin<MesDepots>((z, a, b, s, u, su, d) =>
| d.DepotId.ToString() == b.Warehouse)
| .Where((z, a, b, s, u, su, d)=>z.SalesQuantity > 0)
| .WhereIF(!string.IsNullOrEmpty(request.BillNo),
| (z, a, b, s, u, su, d) => z.BillNo.Contains(request.BillNo))
| .WhereIF(!string.IsNullOrEmpty(request.ItemNo),
| (z, a, b, s, u, su, d) => s.ItemNo.Contains(request.ItemNo))
| .WhereIF(!string.IsNullOrEmpty(request.ItemName),
| (z, a, b, s, u, su, d) => s.ItemName.Contains(request.ItemName))
| .WhereIF(request.Status.HasValue,
| (z, a, b, s, u, su, d) => z.Status == request.Status)
| .Select((z, a, b, s, u, su, d) => new SalesPalletQueryDto
| {
| Id = z.Id,
| Status = z.Status,
| CheckDate = z.CheckDate,
| CheckUser = su.Fname,
| BillNo = z.BillNo,
| ItemNo = s.ItemNo,
| ItemName = s.ItemName,
| ItemModel = s.ItemModel,
| UnitName = u.Fname,
| Xsdd = b.SalesQuantity,
| Yb = z.SalesQuantity,
| Wyj = a.BillNo + s.Id.ToString()
| });
|
| var totalCount = 0;
| var items = query.ToPageList(request.PageIndex, request.Limit,
| ref totalCount);
|
| return (items, totalCount);
| }
|
| public List<SalesPalletDetailQueryDto>
| GetSalesPalletDetail(SalesPalletDetailQueryDto request)
| {
| var subQuery = Db.Queryable<MesPalletBinding1>()
| .LeftJoin<Womdaa>((a, b) => a.TicketNo == b.Daa001)
| .LeftJoin<MesItems>((a, b, it) => it.Id.ToString() == b.Daa002)
| .GroupBy((a, b, it) => new { a.Stackcode, it.Id })
| .Select((a, b, it) => new
| {
| StackCode = a.Stackcode,
| ItemId = it.Id,
| ItemNo = SqlFunc.AggregateMax(it.ItemNo),
| ItemName = SqlFunc.AggregateMax(it.ItemName),
| ItemModel = SqlFunc.AggregateMax(it.ItemModel)
| });
|
| var query = Db.Queryable<SalesPalletDetail>()
| .LeftJoin(subQuery, (b, o) => b.Stackcode == o.StackCode)
| .Where((b, o) => b.Mid == request.Mid)
| .Select((b, o) => new SalesPalletDetailQueryDto
| {
| Id = b.Id,
| Mid = b.Mid,
| BillNo = b.BillNo,
| Stackcode = b.Stackcode,
| Qty = b.Qty,
| ItemNo = o.ItemNo,
| ItemName = o.ItemName,
| ItemModel = o.ItemModel
| });
|
| return query.ToList();
| }
| }
|
|