zhanghonglin
2026-04-10 8f9b9411ca279670bd85fcfa7763987295ed9abf
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEA_Common.LocationEnum;
using WIDESEA_Common.StockEnum;
using WIDESEA_Core;
using WIDESEA_Core.BaseRepository;
using WIDESEA_Core.BaseServices;
using WIDESEA_IStockService;
using WIDESEA_Model.Models;
using WIDESEA_Model.Models.Stock;
using WIDESEAWCS_Model.Models.TaskInfo;
 
namespace WIDESEA_StockService
{
    public class StockService : ServiceBase<Dt_StockInfo, IRepository<Dt_StockInfo>>, IStockService
    {
 
        private readonly IRepository<Dt_StockInfo_hty> _StockInfo_htyRepository;
 
        public StockService(IRepository<Dt_StockInfo> BaseDal, IRepository<Dt_StockInfo_hty> StockInfo_htyRepository) : base(BaseDal)
        {
            _StockInfo_htyRepository = StockInfo_htyRepository;
        }
 
        public IRepository<Dt_StockInfo> Repository => BaseDal;
 
 
        //查询物料数量
        public int MaterielNum(string MaterielName)
        {
            List<Dt_StockInfo> stockInfo = BaseDal.QueryData(x=>x.MaterielName == MaterielName);
            int k = stockInfo.Count();
            return k;
        }
 
        //优先出满
        public List<Dt_StockInfo> PriorityBig(int Num, string Type)
        {
            List<Dt_StockInfo> stockInfo = new List<Dt_StockInfo>();
            List<Dt_StockInfo> stockInfos = BaseDal.QueryData(x => x.MaterielName == Type && x.StockStatus == (int)StockStatusEmun.空闲 && !x.MaterielCode1.Equals("") && !x.MaterielCode2.Equals("") && !x.MaterielCode3.Equals("") && !x.MaterielCode4.Equals("")).ToList();
            //分配数量
            int k = stockInfos.Count();
            if (k >= Num)
            {
                stockInfo.AddRange(stockInfos.Take(Num));
            }
            //锁定库存
            int s = stockInfo.Count() - 1;
            for (int i = 0; i <= s; i++)
            {
                stockInfo[i].StockStatus = (int)StockStatusEmun.出库锁定;
            }
 
            return stockInfo;
        }
 
        //优先出残
        public List<Dt_StockInfo> PriorityLittle(int Num, string Type)
        {
            List<Dt_StockInfo> stockInfo = BaseDal.QueryData(x => x.MaterielName == Type && (x.MaterielCode4.Equals("") || x.MaterielCode4 == null) && x.StockStatus == (int)StockStatusEmun.空闲).ToList();
            int k = stockInfo.Count();
 
            //分配数量
            if (k >= Num)
            {
                //锁定库存
                for (int i = 0; i <= k - 1; i++)
                {
                    stockInfo[i].StockStatus = (int)StockStatusEmun.出库锁定;
                }
            }
 
            return stockInfo;
        }
    }
}