using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using wcftest.BussinessExtension.Common; using wcftest.EnumDefine; using wcftest.EnumDefine.Position; using wcftest.Model; using wcftest.orm; using wcftest.sendToSap; namespace wcftest.BussinessExtension { /// /// 业务扩展类 /// public class BussinessExtension { //public static void xx() //{ // var isQrCode = false; // if (!string.IsNullOrEmpty(item.ExtendField06) && item.ExtendField06.Length > 15) // { // isQrCode = true; // addPP.qrCode_guid = item.ExtendField06; // } //} /// /// 是否存在 未结束的任务 【空托出库】 /// /// /// /// public static bool IsExistNoFinishedTaskFor空托出库(dbModel edm, string toPositionName) { var queryTaskType = ((int)TaskTypeEnum.空托出库).ToString(); var num = edm.Task_Queue.Where(x => x.TaskType == queryTaskType && (x.ToPositionName == toPositionName) && (x.TaskStatus == "未下发" || x.TaskStatus == "已下发" || x.TaskStatus == "下发中") ).Count(); return num > 0 ? true : false; } /// /// 是否存在 未结束的任务 【满空托回库】 /// /// /// /// public static bool IsExistNoFinishedTaskFor满空托回库(dbModel edm, string fromPositionName) { var queryTaskType = ((int)TaskTypeEnum.满空托回库).ToString(); var num = edm.Task_Queue.Where(x => x.TaskType == queryTaskType && (x.FromPositionName == fromPositionName) && (x.TaskStatus == "未下发" || x.TaskStatus == "已下发" || x.TaskStatus == "下发中") ).Count(); return num > 0 ? true : false; } /// /// 验证 指定库位号出库的条件 /// /// /// /// /// /// /// public static bool ValidateSale_OrderForPointPositionName(dbModel mod, List stockALL_No收货暂存区, Sale_Order sale, List saleList, ref string errMsg) { if (string.IsNullOrEmpty(sale.AuditRemark)) {//说明 不是指定库位号出库的 return true; } //按照指定库位号出库,要校验下 他要出库的明细跟库存匹配不? //获取该库位的库存 var stockList = stockALL_No收货暂存区.Where(x => x.PositionName == sale.AuditRemark).ToList(); if (stockList == null || stockList.Count == 0) { errMsg = "目标库位无库存"; return false; } var products = new List(); foreach (var item in saleList) { //按跟踪号查找 ContainerNo = "1";//库位锁定 if (item.TrackingNumber != null) { products = stockALL_No收货暂存区.Where(x => x.ExtendField04 == item.TrackingNumber && x.ContainerNo != "1" && x.ProductCode == item.ProductCode && x.IsLocked == (int)IsLockedEnum.未锁定 && x.PositionName != "收货暂存区" //排序改为 限用日期 升序排序 【Editby shaocx,2024-06-22】 //).OrderBy(x => x.InStorageDate).ToList(); ).OrderBy(x => x.LimitDate).ToList(); } //2021-6-19 修改为 picklist 有跟踪号的只能找跟踪号的,没跟踪号只能找没跟踪号 else { int prodectId = Convert.ToInt32(item.Product_Id); products = stockALL_No收货暂存区.Where(x => x.Product_Id == prodectId && x.PositionName != "收货暂存区" && (x.ExtendField04 == "" || x.ExtendField04 == null) && x.ContainerNo != "1" && x.IsLocked == (int)IsLockedEnum.未锁定 //排序改为 限用日期 升序排序 【Editby shaocx,2024-06-22】 //).OrderBy(x => x.InStorageDate).ToList(); ).OrderBy(x => x.LimitDate).ToList(); } #region 增加指定库位号的过滤 【EditBy shaocx,2022-06-15】 //增加指定库位号的过滤 【EditBy shaocx,2022-06-15】 products = products.Where(x => x.PositionName == sale.AuditRemark).ToList(); #endregion if (products.Count < 1) { //errMsg = "目标库位" + sale.AuditRemark + "无 " + item.ProductName + " 库存 "; errMsg = "目标库位无库存"; } decimal i = (decimal)products.Where(x => x.ProductCode == item.ProductCode).Sum(x => x.ProductStorage); if (i < item.QuantityOrder) { //errMsg = "目标库位" + sale.AuditRemark + " " + item.ProductName + " 库存数量" + i + ",小于需求数量:" + item.QuantityOrder; errMsg = "目标库位库存不足 "; return false; } } return true; } /// /// 获取出库口 /// /// /// public static string GetOut(dbModel edm, string last_toplace) { if (!string.IsNullOrEmpty(last_toplace)) {//增加此次循环的校验 [EditBy shaocx,2022-10-15] return DoGetOut(last_toplace); } //判断上一个出库任务是哪个出库口 var queryTaskType = ((int)TaskTypeEnum.常规出库).ToString(); var task = edm.Task_Queue.Where(x => x.TaskType == queryTaskType).OrderByDescending(x => x.CreateDate).FirstOrDefault(); if (task != null) { var toPlace = task.ToPositionName; return DoGetOut(toPlace); } return "1003";//默认二号口 } private static string DoGetOut(string toPlace) { if (toPlace == "1003") { return "1008";//三号口 } else if (toPlace == "1008") { return "1003";//二号口 } else if (toPlace == "1001") { return "1003";//二号口 } return "1003";//默认二号口 } /// /// 用 在库天数过滤数据 /// /// /// /// public static List FiltervvBase_ProductPositionByInStoreDays(List takeStockList, stockSearchEntity page , ref string errMsg) { if (!string.IsNullOrEmpty(page.inStoreDaysFilterTypeValue) && string.IsNullOrEmpty(page.inStoreDaysValue)) { errMsg = "在库天数值请输入数字!"; return takeStockList; } if (string.IsNullOrEmpty(page.inStoreDaysFilterTypeValue) && !string.IsNullOrEmpty(page.inStoreDaysValue)) { errMsg = "请选择在库天数选择条件!"; return takeStockList; } //判断在库天数,增加在库天数查询条件 if (!string.IsNullOrEmpty(page.inStoreDaysFilterTypeValue) && !string.IsNullOrEmpty(page.inStoreDaysValue)) { int i_inStoreDaysValue = 0; var isInt = int.TryParse(page.inStoreDaysValue, out i_inStoreDaysValue); if (isInt) { int i_inStoreDaysFilterTypeValue = 0; isInt = int.TryParse(page.inStoreDaysFilterTypeValue, out i_inStoreDaysFilterTypeValue); if (isInt) { NumberFilterType _NumberFilterType = (NumberFilterType)Enum.Parse(typeof(NumberFilterType), i_inStoreDaysFilterTypeValue.ToString()); switch (_NumberFilterType) { case NumberFilterType.大于: takeStockList = takeStockList.Where(x => x.InStoreDays > i_inStoreDaysValue).ToList(); break; case NumberFilterType.大于等于: takeStockList = takeStockList.Where(x => x.InStoreDays >= i_inStoreDaysValue).ToList(); break; case NumberFilterType.等于: takeStockList = takeStockList.Where(x => x.InStoreDays == i_inStoreDaysValue).ToList(); break; case NumberFilterType.小于: takeStockList = takeStockList.Where(x => x.InStoreDays < i_inStoreDaysValue).ToList(); break; case NumberFilterType.小于等于: takeStockList = takeStockList.Where(x => x.InStoreDays <= i_inStoreDaysValue).ToList(); break; } } else { errMsg = "请选择在库天数选择条件!"; } } else { errMsg = "在库天数值请输入数字!"; } } return takeStockList; } /// /// 用 在库天数过滤数据 /// /// /// /// public static List FiltervvBase_ProductPositionByInStoreDays(List takeStockList, stockSearchEntity page , ref string errMsg) { if (!string.IsNullOrEmpty(page.inStoreDaysFilterTypeValue) && string.IsNullOrEmpty(page.inStoreDaysValue)) { errMsg = "在库天数值请输入数字!"; return takeStockList; } if (string.IsNullOrEmpty(page.inStoreDaysFilterTypeValue) && !string.IsNullOrEmpty(page.inStoreDaysValue)) { errMsg = "请选择在库天数选择条件!"; return takeStockList; } //判断在库天数,增加在库天数查询条件 if (!string.IsNullOrEmpty(page.inStoreDaysFilterTypeValue) && !string.IsNullOrEmpty(page.inStoreDaysValue)) { int i_inStoreDaysValue = 0; var isInt = int.TryParse(page.inStoreDaysValue, out i_inStoreDaysValue); if (isInt) { int i_inStoreDaysFilterTypeValue = 0; isInt = int.TryParse(page.inStoreDaysFilterTypeValue, out i_inStoreDaysFilterTypeValue); if (isInt) { NumberFilterType _NumberFilterType = (NumberFilterType)Enum.Parse(typeof(NumberFilterType), i_inStoreDaysFilterTypeValue.ToString()); switch (_NumberFilterType) { case NumberFilterType.大于: takeStockList = takeStockList.Where(x => x.InStoreDays > i_inStoreDaysValue).ToList(); break; case NumberFilterType.大于等于: takeStockList = takeStockList.Where(x => x.InStoreDays >= i_inStoreDaysValue).ToList(); break; case NumberFilterType.等于: takeStockList = takeStockList.Where(x => x.InStoreDays == i_inStoreDaysValue).ToList(); break; case NumberFilterType.小于: takeStockList = takeStockList.Where(x => x.InStoreDays < i_inStoreDaysValue).ToList(); break; case NumberFilterType.小于等于: takeStockList = takeStockList.Where(x => x.InStoreDays <= i_inStoreDaysValue).ToList(); break; } } else { errMsg = "请选择在库天数选择条件!"; } } else { errMsg = "在库天数值请输入数字!"; } } return takeStockList; } /// /// 库存明细计算在库天数 /// /// /// public static List CalcInStoreDays(List list) { if (list != null && list.Count > 0) { var nowDate = DateTime.Now; foreach (var item in list) { TimeSpan ts = nowDate - item.InStorageDate; item.InStoreDays = ts.Days; } return list; } else { return new List(); } } /// /// 库存明细计算在库天数 /// /// /// public static List CalcInStoreDays(List list) { if (list != null && list.Count > 0) { var nowDate = DateTime.Now; foreach (var item in list) { TimeSpan ts = nowDate - item.InStorageDate; item.InStoreDays = ts.Days; } return list; } else { return new List(); } } /// /// 通过物料编码获取物料信息 /// /// /// public static Base_ProductInfo GetProductInfoByCode(dbModel mod, string productCode) { if (string.IsNullOrEmpty(productCode)) return null; Base_ProductInfo modify = mod.Base_ProductInfo.Where(x => x.ProductCode == productCode).FirstOrDefault(); return modify; } /// /// 配置对象 /// /// /// public static void SetSapSendInfoByGIMaterialEntity(dbModel mod, SapSendInfo sapGi, GIMaterialEntity item) { sapGi.Batch = item.Batch; //sapGi.FromStorageLocation = item.FromStorageLocation; sapGi.MaterialCode = item.MaterialCode; sapGi.Plant = item.Batch; sapGi.Quantity = item.Quantity; sapGi.SType = item.Batch; sapGi.SalesOrder = item.Batch; sapGi.SalesOrderItem = item.Batch; sapGi.SerialNo = item.Batch; //sapGi.ToStorageLocation = item.ToStorageLocation; sapGi.Unit = item.Unit; sapGi.Vendor = item.Batch; sapGi.WorkOrder = item.Batch; sapGi.StorageLocation = item.Batch; var product = GetProductInfoByCode(mod, sapGi.MaterialCode); if (product != null) sapGi.MaterialName = product.ProductName; } /// /// 配置对象 /// /// /// public static void SetSapSendInfoByGRMaterialEntity(dbModel mod, SapSendInfo sapGi, List resultSap) { var item = resultSap[0]; //sapGi.Batch = item.Batch; //sapGi.FromStorageLocation = item.FromStorageLocation; sapGi.MaterialCode = item.MaterialCode; //sapGi.Plant = item.Batch; sapGi.Quantity = item.Quantity; //sapGi.SType = item.Batch; // sapGi.SalesOrder = item.Batch; //sapGi.SalesOrderItem = item.Batch; //sapGi.SerialNo = item.Batch; //sapGi.ToStorageLocation = item.ToStorageLocation; //sapGi.Unit = item.Unit; //sapGi.Vendor = item.Batch; //sapGi.WorkOrder = item.Batch; //sapGi.StorageLocation = item.Batch; var product = GetProductInfoByCode(mod, sapGi.MaterialCode); if (product != null) sapGi.MaterialName = product.ProductName; } /// /// 配置对象 /// /// /// public static void SetSapSendInfoByMovMaterialEntity(dbModel mod, SapSendInfo sapGi, List moveMaterials) { var item = moveMaterials[0]; sapGi.Batch = item.Batch; sapGi.FromStorageLocation = item.FromStorageLocation; sapGi.MaterialCode = item.MaterialCode; sapGi.Plant = item.Batch; sapGi.Quantity = item.Quantity; sapGi.SType = item.Batch; sapGi.SalesOrder = item.Batch; sapGi.SalesOrderItem = item.Batch; sapGi.SerialNo = item.Batch; sapGi.ToStorageLocation = item.ToStorageLocation; sapGi.Unit = item.Unit; sapGi.Vendor = item.Batch; sapGi.WorkOrder = item.Batch; sapGi.StorageLocation = item.Batch; var product = GetProductInfoByCode(mod, sapGi.MaterialCode); if (product != null) sapGi.MaterialName = product.ProductName; } /// /// 寻找空库位时,增加判断是否有库存数据的筛选 【EditBy shaocx,2022-01-27】 /// /// /// /// public static List FitlterFindEmptyPlace(List finallyResultSql, int areaCode, dbModel edm) { if (finallyResultSql == null || finallyResultSql.Count == 0) { return finallyResultSql; } //排除出有库存的,优化 【EditBy shaocx,2022-09-21】 finallyResultSql = FilterProductPositionForFindEmptyPosition(finallyResultSql, edm); //排除掉有任务占用的情况,优化 【EditBy shaocx,2022-09-21】 finallyResultSql = FilterPositionTakeDoingTask(finallyResultSql, edm, areaCode); //原先的代码,效率较慢,使用上面的优化代码 【EditBy shaocx,2022-09-21】 /* foreach (var place in finallyResultSql) { num = edm.Base_ProductPosition.Where(x => x.PositionName == place.PositionName).Count(); if (num > 0) {//说明有库存,不允许再入东西了 continue; } else {//空闲库位 //继续判断该库位是否被未结束的任务占用 【EditBy shaocx,2022-03-11】 //下面这种方式满足条件也查询不到数据,应该是拼接字符串+的问题 【EditBy shaocx,2022-03-17】 //num = edm.Task_Queue.Where(x => // ((x.DoCount + '-' + x.ToPositionName) == place.PositionName || (x.DoCount + '-' + x.FromPositionName) == place.PositionName) // && (x.TaskStatus != "手工处理异常" && x.TaskStatus != "完成" && x.TaskStatus != "任务异常" && x.TaskStatus != "确认异常") // ).Count(); var queryPositionName = place.PositionName.Substring(2); num = GetDoingTaskCountByPosition(edm, areaCode, queryPositionName); //num = edm.Task_Queue.Where(x => // x.DoCount == areaCode && (x.ToPositionName == queryPositionName || x.FromPositionName == queryPositionName) && // (x.TaskStatus != "手工处理异常" && x.TaskStatus != "完成" && x.TaskStatus != "任务异常" && x.TaskStatus != "确认异常") // ).Count(); if (num > 0) {//说明有未结束的任务占用,不允许再入东西了 continue; } new_finallyResultSql.Add(place); } } //*/ return finallyResultSql; } /// /// 过滤掉 已经有库存的库位 /// /// /// /// public static List FilterProductPositionForFindEmptyPosition(List finallyResultSql, dbModel edm) { var allStoreList = edm.Base_ProductPosition.Where(x => x.PositionName != SysGlole.PositionName_SHZCQ).ToList();//目前所有的库存 if (allStoreList != null && allStoreList.Count > 0) { List positionNameList = allStoreList.Select(x => x.PositionName).ToList(); finallyResultSql = finallyResultSql.Where(x => !positionNameList.Contains(x.PositionName)).ToList(); } return finallyResultSql; } /// /// 过滤 库位目前正在被占用的任务,把任务占用的排除掉 /// /// /// /// /// public static List FilterPositionTakeDoingTask(List finallyResultSql, dbModel edm, int areaCode) { var list = GetDoingTaskList(edm, areaCode); var fromPositionNameList = list.Select(x => x.DoCount + "-" + x.FromPositionName).ToList();//任务占用的起点集合 var toPositionNameList = list.Select(x => x.DoCount + "-" + x.ToPositionName).ToList();//任务占用的目标集合 finallyResultSql = finallyResultSql.Where(x => !fromPositionNameList.Contains(x.PositionName)).ToList(); finallyResultSql = finallyResultSql.Where(x => !toPositionNameList.Contains(x.PositionName)).ToList(); return finallyResultSql; } /// /// 过滤 库位目前正在被占用的任务,把任务占用的排除掉 /// /// /// /// /// public static List FilterPositionTakeDoingTask(List finallyResultSql, dbModel edm, int areaCode) { var list = GetDoingTaskList(edm, areaCode); var fromPositionNameList = list.Select(x => x.DoCount + "-" + x.FromPositionName).ToList();//任务占用的起点集合 var toPositionNameList = list.Select(x => x.DoCount + "-" + x.ToPositionName).ToList();//任务占用的目标集合 finallyResultSql = finallyResultSql.Where(x => !fromPositionNameList.Contains(x.PositionName)).ToList(); finallyResultSql = finallyResultSql.Where(x => !toPositionNameList.Contains(x.PositionName)).ToList(); return finallyResultSql; } /// /// 过滤库位-把任务占用的排除掉 [EditBy shaocx,2022-05-31] /// /// /// /// public static List FilterPositionTakeDoingTask(dbModel edm, List positionList) { List positionList_01 = positionList.Where(x => x.ShelveCode == "01").ToList(); List positionList_02 = positionList.Where(x => x.ShelveCode == "02").ToList(); positionList_01 = FilterPositionTakeDoingTask(positionList_01, edm, 1); positionList_02 = FilterPositionTakeDoingTask(positionList_02, edm, 2); List newList = new List(); newList.AddRange(positionList_01); newList.AddRange(positionList_02); return newList; //优化下面的逻辑 //List new_positionList = new List(); //if (positionList != null && positionList.Count > 0) //{ // foreach (var item in positionList) // { // var queryPositionName = item.PositionName.Substring(2);//PositionName值:1-01-15-05 // var num = GetDoingTaskCountByPosition(edm, Convert.ToInt32(item.AreaCode), queryPositionName); // if (num > 0) // {//说明有未结束的任务占用,不允许再入东西了 // } // else // { // new_positionList.Add(item); // } // } //} //return new_positionList; } /// /// 获取目前正在被占用的任务列表 /// /// /// 库区 /// public static List GetDoingTaskList(dbModel edm, int areaCode) { var list = edm.Task_Queue.Where(x => x.DoCount == areaCode && (x.TaskStatus != "手工处理异常" && x.TaskStatus != "完成" && x.TaskStatus != "任务异常" && x.TaskStatus != "确认异常") ).ToList(); if (list == null) return new List(); else return list; } /// /// 获取目前正在被占用的任务列表 /// /// /// 库区 /// 库位 /// public static List GetDoingTaskList(dbModel edm, int areaCode, string positionName) { var list = edm.Task_Queue.Where(x => x.DoCount == areaCode && (x.ToPositionName == positionName || x.FromPositionName == positionName) && (x.TaskStatus != "手工处理异常" && x.TaskStatus != "完成" && x.TaskStatus != "任务异常" && x.TaskStatus != "确认异常") ).ToList(); if (list == null) return new List(); else return list; } /// /// 获取目前某个托盘正在被占用的任务列表 /// /// /// 库区 /// 库位 /// public static List GetDoingTaskListForPlateCode(dbModel edm, string plateCode) { var list = edm.Task_Queue.Where(x => x.PlateCode == plateCode && (x.TaskStatus != "手工处理异常" && x.TaskStatus != "完成" && x.TaskStatus != "任务异常" && x.TaskStatus != "确认异常") ).ToList(); if (list == null) return new List(); else return list; } /// /// 获取目前某个托盘正在被占用的任务列表 /// /// /// 库区 /// 库位 /// public static List GetDoingShelveTaskListForPlateCode(dbModel edm, string plateCode) { var list = edm.Purchase_Shelve.Where(x => x.PlateCode == plateCode && (x.OnShelveStatus == "待上架" || x.OnShelveStatus == "上架中" ) ).ToList(); if (list == null) return new List(); else return list; } /// /// 获取目前正在被占用的任务列表 /// /// /// 库区 /// 任务类型 /// public static List GetDoingTaskList(dbModel edm, int areaCode, TaskTypeEnum _taskType) { var queryTaskType = ((int)_taskType).ToString(); var list = edm.Task_Queue.Where(x => x.DoCount == areaCode && x.TaskType == queryTaskType && (x.TaskStatus != "手工处理异常" && x.TaskStatus != "完成" && x.TaskStatus != "任务异常" && x.TaskStatus != "确认异常") ).ToList(); if (list == null) return new List(); else return list; } /// /// 获取指定物料编码的当前库存数 /// /// /// 物料编码 /// 库位号 /// 常规货位的库存数 /// 暂存区的库存数 /// 当前库位的库存数 /// 当前库位的跟踪号 /// 当前库位的跟踪号库存数 public static void GetCurrentProductStorage(dbModel edm, string productCode, string positionName, out decimal cghw_ProductStorage, out decimal zcg_ProductStorage, out decimal dqkw_ProductStorage , string trackNumber, out decimal dqkw_trackNumber_ProductStorage) { cghw_ProductStorage = 0; zcg_ProductStorage = 0; dqkw_ProductStorage = 0; dqkw_trackNumber_ProductStorage = 0; var storeList = edm.vvBase_ProductPosition.Where(x => x.ProductCode == productCode && x.ProductStorage > 0).ToList(); if (storeList != null && storeList.Count > 0) { //常规货位的库存 var queryPositionType = (int)PositionType.常规货位; cghw_ProductStorage = (decimal)storeList.Where(x => x.PositionType == queryPositionType).Sum(x => x.ProductStorage); dqkw_ProductStorage = (decimal)storeList.Where(x => x.PositionType == queryPositionType && x.PositionName == positionName).Sum(x => x.ProductStorage); if (!string.IsNullOrEmpty(trackNumber)) { dqkw_trackNumber_ProductStorage = (decimal)storeList.Where(x => x.PositionType == queryPositionType && x.PositionName == positionName && x.ExtendField04 == trackNumber).Sum(x => x.ProductStorage); } queryPositionType = (int)PositionType.暂存区; zcg_ProductStorage = (decimal)storeList.Where(x => x.PositionType == queryPositionType).Sum(x => x.ProductStorage); } } #region 空库位统计 /// /// 巷道1空库位统计 /// /// /// public static void EmptyPositionTongJiForArea1(dbModel mod, ref List emtyps) { //巷道1空库位 List emptyPositionArea1 = mod.Base_Position.Where(x => x.AreaCode == "1" && x.Enable == 1 && x.IsFreeze == 0 && x.IsLocked == 0).ToList(); List allPositionArea1 = mod.Base_Position.Where(x => x.AreaCode == "1" && x.Enable == 1).ToList();//巷道1 总库位数 //过滤库位-把任务占用的排除掉 [EditBy shaocx,2022-05-31] emptyPositionArea1 = BussinessExtension.FilterPositionTakeDoingTask(mod, emptyPositionArea1); List emptyPositionArea1_height = emptyPositionArea1.Where(x => x.RowCode == "01" || x.RowCode == "11").ToList(); List allPositionArea1_height = allPositionArea1.Where(x => x.RowCode == "01" || x.RowCode == "11").ToList(); emtypPosition emptyHigh = new emtypPosition(); emptyHigh.name = "巷道1小托盘 [1到28列],1,11层 (975-1850)"; emptyHigh.quantity = emptyPositionArea1_height.Count; emptyHigh.all_quantity = allPositionArea1_height.Count; emtypPosition emptyLow = new emtypPosition(); emptyLow.name = "巷道1小托盘 [1到28列],2到10层 (0-975)"; emptyLow.quantity = emptyPositionArea1.Count - emptyPositionArea1_height.Count; emptyLow.all_quantity = allPositionArea1.Count - allPositionArea1_height.Count; emtyps.Add(emptyHigh); emtyps.Add(emptyLow); } ///// ///// 巷道2小库位 空库位统计 ///// ///// ///// //public static void EmptyPositionTongJiForArea2_Small(dbModel mod, ref List emtyps) //{ // string row2Sql = "select * from [dbo].[" + "Base_Position" + "] where AreaCode='2'and ColumnCode>1 and ColumnCode<10 and Enable=" + (int)usable.可用;//isFreeze 是否有货 先拿这个字段用 // List allPositionArea2_small = mod.Database.SqlQuery(row2Sql).ToList();//所有空库位 // List emptyPositionArea2_small = allPositionArea2_small.Where(x => x.IsLocked == (int)IsLockedEnum.未锁定 && x.IsFreeze == (int)IsFreezeEnum.无货).ToList(); // //过滤库位-把任务占用的排除掉 [EditBy shaocx,2022-05-31] // emptyPositionArea2_small = BussinessExtension.FilterPositionTakeDoingTask(mod, emptyPositionArea2_small); // List emptyPositionArea2_small_height2 = emptyPositionArea2_small.Where(x => x.RowCode == "03" || x.RowCode == "05" || x.RowCode == "07" || x.RowCode == "09" || x.RowCode == "10").ToList(); // List allPositionArea2_small_height2 = allPositionArea2_small.Where(x => x.RowCode == "03" || x.RowCode == "05" || x.RowCode == "07" || x.RowCode == "09" || x.RowCode == "10").ToList(); // List emptyPositionArea2_small_height3 = emptyPositionArea2_small.Where(x => x.RowCode == "01" || x.RowCode == "11").ToList(); // List allPositionArea2_small_height3 = allPositionArea2_small.Where(x => x.RowCode == "01" || x.RowCode == "11").ToList(); // emtypPosition empty1 = new emtypPosition(); // empty1.name = "巷道2小托盘2,4,6,8层(0-750)"; // empty1.quantity = emptyPositionArea2_small.Count - emptyPositionArea2_small_height2.Count - emptyPositionArea2_small_height3.Count; // empty1.all_quantity = allPositionArea2_small.Count - allPositionArea2_small_height2.Count - allPositionArea2_small_height3.Count; // emtypPosition empty2 = new emtypPosition(); // empty2.name = "巷道2小托盘3,5,7,9,10层(750-1150)"; // empty2.quantity = emptyPositionArea2_small_height2.Count; // empty2.all_quantity = allPositionArea2_small_height2.Count; // emtypPosition empty3 = new emtypPosition(); // empty3.name = "巷道2小托盘1,11层(1150-1350)"; // empty3.quantity = emptyPositionArea2_small_height3.Count; // empty3.all_quantity = allPositionArea2_small_height3.Count; // emtyps.Add(empty3); // emtyps.Add(empty2); // emtyps.Add(empty1); //} /// /// 巷道2小库位 空库位统计 /// /// /// public static void EmptyPositionTongJiForArea2_Small(dbModel mod, ref List emtyps) { string row2Sql = "select * from [dbo].[" + "Base_Position" + "] where AreaCode='2'and ColumnCode>1 and ColumnCode>1 and ColumnCode<10 and (RowCode>=1 AND RowCode<=11 ) and Enable=" + (int)usable.可用;//isFreeze 是否有货 先拿这个字段用 List allPositionArea2_small = mod.Database.SqlQuery(row2Sql).ToList();//所有空库位 List emptyPositionArea2_small = allPositionArea2_small.Where(x => x.IsLocked == (int)IsLockedEnum.未锁定 && x.IsFreeze == (int)IsFreezeEnum.无货).ToList(); //过滤库位-把任务占用的排除掉 [EditBy shaocx,2022-05-31] emptyPositionArea2_small = BussinessExtension.FilterPositionTakeDoingTask(mod, emptyPositionArea2_small); emtypPosition empty1 = new emtypPosition(); empty1.name = "巷道2小托盘 [2到9列],1到11层 (0-1150)"; empty1.quantity = emptyPositionArea2_small.Count; empty1.all_quantity = allPositionArea2_small.Count; emtyps.Add(empty1); } /// /// 巷道2大库位 空库位统计 /// /// /// public static void EmptyPositionTongJiForArea2_Big(dbModel mod, ref List emtyps) { //巷道2大库位-最高库位 string row2SqlBig4 = "select * from [dbo].[" + "Base_Position" + "] where AreaCode='2' and Enable=" + (int)usable.可用 + " and (ColumnCode<2 or ColumnCode>9) and (RowCode=1 or RowCode=13 or RowCode=14 ) ";//isFreeze 是否有货 先拿这个字段用 List allPositionArea2_big4 = mod.Database.SqlQuery(row2SqlBig4).ToList(); List emptyPositionArea2_big4 = allPositionArea2_big4.Where(x => x.IsLocked == (int)IsLockedEnum.未锁定 && x.IsFreeze == (int)IsFreezeEnum.无货).ToList(); //过滤库位-把任务占用的排除掉 [EditBy shaocx,2022-05-31] emptyPositionArea2_big4 = BussinessExtension.FilterPositionTakeDoingTask(mod, emptyPositionArea2_big4); //第3高 string row2SqlBig3 = "select * from [dbo].[" + "Base_Position" + "] where AreaCode='2' and Enable=" + (int)usable.可用 + " and (ColumnCode<2 or ColumnCode>9) and ( RowCode=2 ) ";//isFreeze 是否有货 先拿这个字段用 List allPositionArea2_big3 = mod.Database.SqlQuery(row2SqlBig3).ToList(); List emptyPositionArea2_big3 = allPositionArea2_big3.Where(x => x.IsLocked == (int)IsLockedEnum.未锁定 && x.IsFreeze == (int)IsFreezeEnum.无货).ToList(); //过滤库位-把任务占用的排除掉 [EditBy shaocx,2022-05-31] emptyPositionArea2_big3 = BussinessExtension.FilterPositionTakeDoingTask(mod, emptyPositionArea2_big3); //第2高 string row2SqlBig2 = "select * from [dbo].[" + "Base_Position" + "] where AreaCode='2' and Enable=" + (int)usable.可用 + " and (ColumnCode>=10 and ColumnCode<=21) and (RowCode=12 ) ";//isFreeze 是否有货 先拿这个字段用 List allPositionArea2_big2 = mod.Database.SqlQuery(row2SqlBig2).ToList(); List emptyPositionArea2_big2 = allPositionArea2_big2.Where(x => x.IsLocked == (int)IsLockedEnum.未锁定 && x.IsFreeze == (int)IsFreezeEnum.无货).ToList(); //过滤库位-把任务占用的排除掉 [EditBy shaocx,2022-05-31] emptyPositionArea2_big2 = BussinessExtension.FilterPositionTakeDoingTask(mod, emptyPositionArea2_big2); //最低库位 string row2SqlBig1 = "select * from [dbo].[" + "Base_Position" + "] where AreaCode='2' and Enable=" + (int)usable.可用 + " and ( ( (ColumnCode=1 and (RowCode>=3 and RowCode<=12) ) OR ( ColumnCode>=10 and ColumnCode<=21 and (RowCode>=3 and RowCode<=11)) ) ) ";//isFreeze 是否有货 先拿这个字段用 List allPositionArea2_big1 = mod.Database.SqlQuery(row2SqlBig1).ToList(); List emptyPositionArea2_big1 = allPositionArea2_big1.Where(x => x.IsLocked == (int)IsLockedEnum.未锁定 && x.IsFreeze == (int)IsFreezeEnum.无货).ToList(); //过滤库位-把任务占用的排除掉 [EditBy shaocx,2022-05-31] emptyPositionArea2_big1 = BussinessExtension.FilterPositionTakeDoingTask(mod, emptyPositionArea2_big1); emtypPosition emptyBig1 = new emtypPosition(); emptyBig1.name = "巷道2大托盘 [10到21列,3到11层],[第1列12层] (0-600)"; emptyBig1.quantity = emptyPositionArea2_big1.Count; emptyBig1.all_quantity = allPositionArea2_big1.Count; emtypPosition emptyBig2 = new emtypPosition(); emptyBig2.name = "巷道2大托盘 [10到21列],12层 (600-750)"; emptyBig2.quantity = emptyPositionArea2_big2.Count; emptyBig2.all_quantity = allPositionArea2_big2.Count; emtypPosition emptyBig3 = new emtypPosition(); emptyBig3.name = "巷道2大托盘 [10到21列],2层 (750-1150)"; emptyBig3.quantity = emptyPositionArea2_big3.Count; emptyBig3.all_quantity = allPositionArea2_big3.Count; emtypPosition emptyBig4 = new emtypPosition(); emptyBig4.name = "巷道2大托盘 [第1列],[10到21列],1,13,14层 (1150-1350)"; emptyBig4.quantity = emptyPositionArea2_big4.Count; emptyBig4.all_quantity = allPositionArea2_big4.Count; emtyps.Add(emptyBig1); emtyps.Add(emptyBig2); emtyps.Add(emptyBig3); emtyps.Add(emptyBig4); } #endregion } }