jt
2021-06-10 5d0d028456874576560552f5a5c4e8b801786f11
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HH.MData;
using HH.WMS.Entitys.Algorithm;
using MongoDB.Driver.Builders;
using MongoDB.Bson;
using MongoDB.Driver;
using HH.WMS.Entitys.Basic;
 
namespace HH.WMS.DAL.Algorithm
{
    /// <summary>
    /// 用户读取mongodb中的货位信息
    /// </summary>
    public class TN_WMS_LOCATIONDAL : BaseDAL
    {
        #region 根据仓库编号获得所有货位
        /// <summary>
        /// 根据仓库编号获得所有货位
        /// </summary>
        /// <param name="stockCode"></param>
        /// <returns></returns>
        public List<AutoBomLocationAbbreEntity> GetLocationByStockCode(string stockCode)
        {
            List<AutoBomLocationAbbreEntity> lstLocation = new List<AutoBomLocationAbbreEntity>();
            //作为查询条件
            var query = Query.And(Query.EQ("CN_S_STOCK_CODE", stockCode), Query.NE("CN_S_STATUS", "报废"));
            lstLocation = MongoDBSingleton.Instance.Find<AutoBomLocationAbbreEntity>(query, "TN_AB_STOCK_LOCATION");
            return lstLocation;
        }
        #endregion
 
        #region 根据货位编号获得货位
        /// <summary>
        /// 根据货位编号获得货位
        /// </summary>
        /// <param name="locationCode">货位编号</param>
        /// <returns></returns>
        public List<AutoBomLocationAbbreEntity> GetLocationByLocationCode(List<string> locationCodes)
        {
            List<AutoBomLocationAbbreEntity> lstLocation = new List<AutoBomLocationAbbreEntity>();
            //作为查询条件
            var listLocation = locationCodes.ConvertAll<BsonValue>(x => x);
            var query = Query.And(Query.In("CN_S_LOCATION_CODE", listLocation), Query.NE("CN_S_STATUS", "报废"));
            lstLocation = MongoDBSingleton.Instance.Find<AutoBomLocationAbbreEntity>(query, "TN_AB_STOCK_LOCATION");
            return lstLocation;
        }
        public List<AutoBomLocationAbbreEntity> GetLocationByLocationCode(List<string> locationCodes, string CN_S_TYPE)
        {
            List<AutoBomLocationAbbreEntity> lstLocation = new List<AutoBomLocationAbbreEntity>();
            //作为查询条件
            //获得排列表
            var listLocation = locationCodes.ConvertAll<BsonValue>(x => x);
            var query = Query.And(Query.In("CN_S_LOCATION_CODE", listLocation), Query.EQ("CN_S_TYPE", CN_S_TYPE), Query.NE("CN_S_STATUS", "报废"));
            lstLocation = MongoDBSingleton.Instance.Find<AutoBomLocationAbbreEntity>(query, "TN_AB_STOCK_LOCATION");
            return lstLocation;
        }
        #endregion
        #region 获取仓库中货位状态为报废的数据
 
        public List<string> GetScrapLocationByCondition(List<string> lstAreaCode)
        {
            List<AutoBomLocationAbbreEntity> lstLocation = new List<AutoBomLocationAbbreEntity>();
            //作为查询条件
            var listAreaCode = lstAreaCode.ConvertAll<BsonValue>(x => x);
            var query = Query.And(Query.In("CN_S_AREA_CODE", listAreaCode), Query.EQ("CN_S_STATUS", "报废"));
            lstLocation = MongoDBSingleton.Instance.Find<AutoBomLocationAbbreEntity>(query, "TN_AB_STOCK_LOCATION");
            return lstLocation.Select(o => o.CN_S_LOCATION_CODE).ToList();
        }
        #endregion
        #region 获取货位的配送节拍
 
        public List<AutoBomLocationAbbreEntity> GetBeatBitByLocation(List<string> lstLocationCode)
        {
            List<AutoBomLocationAbbreEntity> lstLocation = new List<AutoBomLocationAbbreEntity>();
            //作为查询条件
            var listLocationCode = lstLocationCode.ConvertAll<BsonValue>(x => x);
            var query = Query.And(Query.In("CN_S_LOCATION_CODE", listLocationCode));
            lstLocation = MongoDBSingleton.Instance.Find<AutoBomLocationAbbreEntity>(query, "TN_AB_STOCK_LOCATION");
            return lstLocation;
        }
        #endregion
        #region 根据货位编号获得货位详细信息
        /// <summary>
        /// 根据货位编号获得货位详细信息
        /// </summary>
        /// <param name="locationCode"></param>
        /// <returns></returns>
        public AutoBomLocationAbbreEntity GetLocationByLocationCodeAbbre(string locationCode)
        {
            //作为查询条件
            //获得排列表
            var query = Query.And(Query.EQ("CN_S_LOCATION_CODE", locationCode), Query.NE("CN_S_STATUS", "报废"));
            AutoBomLocationAbbreEntity lstLocation = MongoDBSingleton.Instance.FindOne<AutoBomLocationAbbreEntity>(query, "TN_AB_STOCK_LOCATION");
            return lstLocation;
        }
 
 
        /// <summary>
        /// 根据货位编号获得货位详细信息
        /// </summary>
        /// <param name="locationCode"></param>
        /// <returns></returns>
        public AutoBomLocationEntity GetModel(string locationCode)
        {
            //作为查询条件
            //获得排列表
            var query = Query.And(Query.EQ("CN_S_LOCATION_CODE", locationCode), Query.NE("CN_S_STATUS", "报废"));
            AutoBomLocationEntity lstLocation = MongoDBSingleton.Instance.FindOne<AutoBomLocationEntity>(query, "TN_AB_STOCK_LOCATION");
            return lstLocation;
        }
        #endregion
        public List<AutoBomLocationAbbreEntity> GetScrapLocationCode(List<string> locationCodes)
        {
            List<AutoBomLocationAbbreEntity> lstLocation = new List<AutoBomLocationAbbreEntity>();
            //作为查询条件
            var listLocation = locationCodes.ConvertAll<BsonValue>(x => x);
            var query = Query.And(Query.In("CN_S_LOCATION_CODE", listLocation), Query.EQ("CN_S_STATUS", "报废"));
            lstLocation = MongoDBSingleton.Instance.Find<AutoBomLocationAbbreEntity>(query, "TN_AB_STOCK_LOCATION");
            return lstLocation;
        }
        #region 根据库区编码获得该库区下所有的货位,针对货位有效,站点无效
        /// <summary>
        /// 根据库区编码获得该库区下所有的货位
        /// </summary>
        /// <param name="areaCode"></param>
        /// <returns></returns>
        public List<AutoBomLocationAbbreEntity> GetLocationByAreaCode(string areaCode)
        {
            var query = Query.And(Query.EQ("CN_S_AREA_CODE", areaCode), Query.NE("CN_S_STATUS", "报废"));
            //var query = Query.And(Query.EQ("CN_S_AREA_CODE", areaCode),Query.EQ("CN_S_AREA_CODE", areaCode), Query.NE("CN_S_STATUS", "报废"));
            List<AutoBomLocationAbbreEntity> lstLocation = MongoDBSingleton.Instance.Find<AutoBomLocationAbbreEntity>(query, "TN_AB_STOCK_LOCATION");
            //List<AutoBomStockStructreEntity> lstStruct = GetStructList(areaCode);
            //if (lstStruct != null && lstStruct.Count > 0)
            //{
            //    //获得仓库编号
            //    string stockCode = lstStruct[0].CN_S_STOCK_CODE;
            //    //获得排列表
            //    var listRow = lstStruct.ConvertAll<BsonValue>(x => x.CN_S_ROW);
            //    //作为查询条件
            //    var query = Query.And(Query.EQ("CN_S_STOCK_CODE", stockCode), Query.NE("CN_S_STATUS", "报废"), Query.In("CN_S_ROW", listRow));
            //    lstLocation = MongoDBSingleton.Instance.Find<AutoBomLocationEntity>(oquery, "TN_AB_STOCK_LOCATION");
            //}
            return lstLocation;
        }
        #endregion
        #region 根据库区编码获得该库区下所有的货位,针对货位有效,站点无效
        /// <summary>
        /// 根据库区编码获得该库区下所有的货位
        /// </summary>
        /// <param name="areaCode"></param>
        /// <returns></returns>
        public List<AutoBomLocationAbbreEntity> GetLocationByAreaCode(string areaCode,string CN_S_TYPE)
        {
            var query = Query.And(Query.EQ("CN_S_AREA_CODE", areaCode), Query.EQ("CN_S_TYPE", CN_S_TYPE), Query.NE("CN_S_STATUS", "报废"));
            List<AutoBomLocationAbbreEntity> lstLocation = MongoDBSingleton.Instance.Find<AutoBomLocationAbbreEntity>(query, "TN_AB_STOCK_LOCATION");
            //List<AutoBomStockStructreEntity> lstStruct = GetStructList(areaCode);
            //if (lstStruct != null && lstStruct.Count > 0)
            //{
            //    //获得仓库编号
            //    string stockCode = lstStruct[0].CN_S_STOCK_CODE;
            //    //获得排列表
            //    var listRow = lstStruct.ConvertAll<BsonValue>(x => x.CN_S_ROW);
            //    //作为查询条件
            //    var query = Query.And(Query.EQ("CN_S_STOCK_CODE", stockCode), Query.NE("CN_S_STATUS", "报废"), Query.In("CN_S_ROW", listRow));
            //    lstLocation = MongoDBSingleton.Instance.Find<AutoBomLocationEntity>(query, "TN_AB_STOCK_LOCATION");
            //}
            return lstLocation;
        }
        #endregion
 
        #region 更新货位表中的入库任务数量
        /// <summary>
        /// 根据库区编码获得该库区下所有的货位
        /// </summary>
        /// <param name="areaCode"></param>
        /// <returns></returns>
        public bool UpdateLocationTaskQty(string locationCode, int CN_N_INTASK_QTY)
        {
            bool result = false;
            var query = Query.EQ("CN_S_LOCATION_CODE", locationCode);
            IMongoUpdate update = Update.Set("CN_N_INTASK_QTY", CN_N_INTASK_QTY);
            result = MongoDBSingleton.Instance.Update<AutoBomLocationAbbreEntity>(query, update, "TN_AB_STOCK_LOCATION", UpdateFlags.Multi);
            return result;
        }
        #endregion
 
 
        #region 查询mongo
        public List<AutoBomItemEntity> GetItemList(string itemcode, int pageIndex, int pageSize)
        {
            var query = Query.And(Query.EQ("CN_S_ITEM_CODE", itemcode));
            //SortByDocument sortBy = new SortByDocument();
            //List<AutoBomItemEntity> lstStruct = MongoDBSingleton.Instance.Find<AutoBomItemEntity>(query, pageIndex, pageSize, sortBy, "TN_AB_ITEM");
            List<AutoBomItemEntity> lstStruct = MongoDBSingleton.Instance.Find<AutoBomItemEntity>(query, "TN_AB_ITEM");
            return lstStruct;
        }
        #endregion
 
 
    }
}