pan
2025-11-20 246622a6e9c2563bd21d627c21c6012017f0f04e
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 WIDESEA_Core;
using WIDESEA_Core.BaseRepository;
using WIDESEA_Core.BaseServices;
using WIDESEA_Core.HttpContextUser;
using WIDESEA_DTO.Stock;
using WIDESEA_IStockService;
using WIDESEA_Model.Models;
 
namespace WIDESEA_StockService
{
    public partial class StockInfoDetailService : ServiceBase<Dt_StockInfoDetail, IRepository<Dt_StockInfoDetail>>, IStockInfoDetailService
    {
        public StockInfoDetailService(IRepository<Dt_StockInfoDetail> BaseDal, IRepository<Dt_StockInfo> stockinfoRepository) : base(BaseDal)
        {
            _stockinfoRepository = stockinfoRepository;
        }
 
        public IRepository<Dt_StockInfo> _stockinfoRepository;
        public IRepository<Dt_StockInfoDetail> Repository => BaseDal;
 
        public bool ExistBarcodes(string barcode)
        {
            return BaseDal.QueryFirst(x => x.Barcode == barcode) != null;
        }
 
        public bool ExistBarcodes(List<string> barcodes)
        {
            return BaseDal.QueryFirst(x => !string.IsNullOrEmpty(x.Barcode) && barcodes.Contains(x.Barcode)) != null;
        }
 
        public PageGridData<StockInfoDetailWithPalletDto> GetPageData2(PageDataOptions options)
        {
            PageGridData<Dt_StockInfoDetail> lists =  base.GetPageData (options);
 
            List<int> stockIds = lists.Rows.Select(detail => detail.StockId).Distinct().ToList();
            var stocks= _stockinfoRepository.QueryData(x => stockIds.Contains(x.Id)).ToList();
 
 
            List<StockInfoDetailWithPalletDto> dtoList = lists.Rows
                .Select(detail => new StockInfoDetailWithPalletDto
                {
                    
                    Id = detail.Id,
                    StockId = detail.StockId,
                    MaterielCode = detail.MaterielCode,
                    MaterielName = detail.MaterielName,
                    OrderNo = detail.OrderNo,
                    BatchNo = detail.BatchNo,
                    ProductionDate = detail.ProductionDate,
                    EffectiveDate = detail.EffectiveDate,
                    SerialNumber = detail.SerialNumber,
                    StockQuantity = detail.StockQuantity,
                    OutboundQuantity = detail.OutboundQuantity,
                    Status = detail.Status,
                    Unit = detail.Unit,
                    InboundOrderRowNo = detail.InboundOrderRowNo,
                    SupplyCode = detail.SupplyCode,
                    WarehouseCode = detail.WarehouseCode,
                    Barcode = detail.Barcode,
                    BusinessType = detail.BusinessType,
                    Remark = detail.Remark,
                    Creater = detail.Creater,
                    CreateDate = detail.CreateDate,
                    Modifier = detail.Modifier,
                    ModifyDate = detail.ModifyDate,
                    PalletCode= stocks
                        .FirstOrDefault(stock => stock.Id == detail.StockId)?
                        .PalletCode ?? "无托盘编号"  
                })
                .ToList();
 
            return new PageGridData<StockInfoDetailWithPalletDto> { Rows = dtoList, Total = lists.Total, Summary = lists.Summary  };
        }
    }
 }