1
huangxiaoqiang
2025-12-18 9753fb2756f6b4e30ff79d901a7bb86145517c8b
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SqlSugar;
using WIDESEA_Common.StockEnum;
using WIDESEA_Core;
using WIDESEA_DTO.CalcOut;
using WIDESEA_Model.Models;
 
namespace WIDESEA_OutboundService
{
    public partial class OutboundService
    {
 
        public WebResponseContent QueryPickingTasks(string palletCode, string orderNo)
        {
            try
            {
                Dt_StockInfo stockInfo = _stockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.PalletCode == palletCode).Includes(x => x.Details).First();
                bool isMatMixed = false;
                if (stockInfo != null)
                {
                    isMatMixed = stockInfo.Details.GroupBy(x => new
                    {
                        x.MaterielCode,
                        x.MaterielName,
                        x.BatchNo,
                        x.SupplyCode,
                        x.WarehouseCode
                    }).Count() > 1;
                }
 
 
                List<Dt_OutStockLockInfo> outStockLockInfos = _outboundLockInfoRepository.QueryData(x => x.PalletCode == palletCode && x.OrderNo == orderNo);
                return WebResponseContent.Instance.OK(data: new { outStockLockInfos, stockInfo, isMatMixed });
            }
            catch (Exception ex)
            {
                return WebResponseContent.Instance.Error(ex.Message);
            }
        }
 
        /// <summary>
        /// 查询已拣选列表(通过库存变动记录)
        /// </summary>
        /// <param name="request">查询请求</param>
        /// <returns>已拣选列表</returns>
        public WebResponseContent QueryPickedList(string orderNo, string palletCode)
        {
            WebResponseContent content = WebResponseContent.Instance;
 
            try
            {
                // 构建查询条件
                var query = _stockChangeRepository.Db
                    .Queryable<Dt_StockQuantityChangeRecord>()
                    .LeftJoin<Dt_OutboundOrder>((r, o) => r.OrderNo == o.OrderNo)
                    .Where((r, o) => r.ChangeType == (int)StockChangeTypeEnum.Outbound)
                    .Where((r, o) => r.OrderNo == orderNo)
                    .Where((r, o) => r.PalleCode == palletCode)
                    .OrderBy((r, o) => r.CreateDate, OrderByType.Desc)
                    .Select((r, o) => new PickedListItemDTO
                    {
                        Id = r.Id,
                        OrderNo = r.OrderNo,
                        TaskNum = r.TaskNum,
                        PalletCode = r.PalleCode,
                        MaterielCode = r.MaterielCode,
                        MaterielName = r.MaterielName,
                        BatchNo = r.BatchNo,
                        OriginalBarcode = r.OriginalSerilNumber,
                        NewBarcode = r.NewSerilNumber,
                        ChangeQuantity = r.ChangeQuantity,
                        BeforeQuantity = r.BeforeQuantity,
                        AfterQuantity = r.AfterQuantity,
                        SupplyCode = r.SupplyCode,
                        WarehouseCode = r.WarehouseCode,
                        Remark = r.Remark,
                        CreateDate = r.CreateDate,
                        OrderStatus = o.OrderStatus,
                        FactoryArea = o.FactoryArea
                    });
 
                var result = query.ToList();
 
                return WebResponseContent.Instance.OK(data: result);
            }
            catch (Exception ex)
            {
                return WebResponseContent.Instance.Error($"查询已拣选列表失败:{ex.Message}");
            }
        }
    }
}