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
|
{
|
/// <summary>
|
/// 业务扩展类
|
/// </summary>
|
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;
|
// }
|
//}
|
|
/// <summary>
|
/// 是否存在 未结束的任务 【空托出库】
|
/// </summary>
|
/// <param name="edm"></param>
|
/// <param name="toPositionName"></param>
|
/// <returns></returns>
|
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;
|
}
|
|
/// <summary>
|
/// 是否存在 未结束的任务 【满空托回库】
|
/// </summary>
|
/// <param name="edm"></param>
|
/// <param name="toPositionName"></param>
|
/// <returns></returns>
|
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;
|
}
|
|
|
|
/// <summary>
|
/// 验证 指定库位号出库的条件
|
/// </summary>
|
/// <param name="mod"></param>
|
/// <param name="stockALL_No收货暂存区"></param>
|
/// <param name="sale"></param>
|
/// <param name="saleList"></param>
|
/// <param name="errMsg"></param>
|
/// <returns></returns>
|
public static bool ValidateSale_OrderForPointPositionName(dbModel mod, List<vvBase_ProductPosition> stockALL_No收货暂存区, Sale_Order sale, List<Sale_OrderList> 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<vvBase_ProductPosition>();
|
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;
|
}
|
|
/// <summary>
|
/// 获取出库口
|
/// </summary>
|
/// <param name="edm"></param>
|
/// <returns></returns>
|
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";//默认二号口
|
}
|
|
|
/// <summary>
|
/// 用 在库天数过滤数据
|
/// </summary>
|
/// <param name="takeStockList"></param>
|
/// <param name="page"></param>
|
/// <returns></returns>
|
public static List<vvBase_ProductPosition> FiltervvBase_ProductPositionByInStoreDays(List<vvBase_ProductPosition> 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;
|
}
|
|
|
/// <summary>
|
/// 用 在库天数过滤数据
|
/// </summary>
|
/// <param name="takeStockList"></param>
|
/// <param name="page"></param>
|
/// <returns></returns>
|
public static List<vvBase_ProductPosition_all> FiltervvBase_ProductPositionByInStoreDays(List<vvBase_ProductPosition_all> 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;
|
}
|
|
|
/// <summary>
|
/// 库存明细计算在库天数
|
/// </summary>
|
/// <param name="list"></param>
|
/// <returns></returns>
|
public static List<vvBase_ProductPosition> CalcInStoreDays(List<vvBase_ProductPosition> 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<vvBase_ProductPosition>();
|
}
|
}
|
|
/// <summary>
|
/// 库存明细计算在库天数
|
/// </summary>
|
/// <param name="list"></param>
|
/// <returns></returns>
|
public static List<vvBase_ProductPosition_all> CalcInStoreDays(List<vvBase_ProductPosition_all> 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<vvBase_ProductPosition_all>();
|
}
|
}
|
|
|
|
/// <summary>
|
/// 通过物料编码获取物料信息
|
/// </summary>
|
/// <param name="mod"></param>
|
/// <param name="productCode"></param>
|
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;
|
}
|
|
/// <summary>
|
/// 配置对象
|
/// </summary>
|
/// <param name="sapGi"></param>
|
/// <param name="resultSap"></param>
|
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;
|
}
|
/// <summary>
|
/// 配置对象
|
/// </summary>
|
/// <param name="sapGi"></param>
|
/// <param name="resultSap"></param>
|
public static void SetSapSendInfoByGRMaterialEntity(dbModel mod, SapSendInfo sapGi, List<GRMaterialEntity> 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;
|
}
|
/// <summary>
|
/// 配置对象
|
/// </summary>
|
/// <param name="sapGi"></param>
|
/// <param name="resultSap"></param>
|
public static void SetSapSendInfoByMovMaterialEntity(dbModel mod, SapSendInfo sapGi, List<MovMaterialEntity> 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;
|
}
|
|
|
|
|
/// <summary>
|
/// 寻找空库位时,增加判断是否有库存数据的筛选 【EditBy shaocx,2022-01-27】
|
/// </summary>
|
/// <param name="finallyResultSql"></param>
|
/// <param name="edm"></param>
|
/// <returns></returns>
|
public static List<Base_Position> FitlterFindEmptyPlace(List<Base_Position> 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;
|
}
|
|
/// <summary>
|
/// 过滤掉 已经有库存的库位
|
/// </summary>
|
/// <param name="finallyResultSql"></param>
|
/// <param name="edm"></param>
|
/// <returns></returns>
|
public static List<Base_Position> FilterProductPositionForFindEmptyPosition(List<Base_Position> finallyResultSql, dbModel edm)
|
{
|
var allStoreList = edm.Base_ProductPosition.Where(x => x.PositionName != SysGlole.PositionName_SHZCQ).ToList();//目前所有的库存
|
if (allStoreList != null && allStoreList.Count > 0)
|
{
|
List<string> positionNameList = allStoreList.Select(x => x.PositionName).ToList();
|
finallyResultSql = finallyResultSql.Where(x => !positionNameList.Contains(x.PositionName)).ToList();
|
}
|
return finallyResultSql;
|
}
|
|
|
/// <summary>
|
/// 过滤 库位目前正在被占用的任务,把任务占用的排除掉
|
/// </summary>
|
/// <param name="edm"></param>
|
/// <param name="areaCode"></param>
|
/// <param name="queryPositionName"></param>
|
/// <returns></returns>
|
public static List<vvBase_ProductPosition> FilterPositionTakeDoingTask(List<vvBase_ProductPosition> 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;
|
}
|
/// <summary>
|
/// 过滤 库位目前正在被占用的任务,把任务占用的排除掉
|
/// </summary>
|
/// <param name="edm"></param>
|
/// <param name="areaCode"></param>
|
/// <param name="queryPositionName"></param>
|
/// <returns></returns>
|
public static List<Base_Position> FilterPositionTakeDoingTask(List<Base_Position> 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;
|
}
|
|
/// <summary>
|
/// 过滤库位-把任务占用的排除掉 [EditBy shaocx,2022-05-31]
|
/// </summary>
|
/// <param name="edm"></param>
|
/// <param name="positionList"></param>
|
/// <returns></returns>
|
public static List<Base_Position> FilterPositionTakeDoingTask(dbModel edm, List<Base_Position> positionList)
|
{
|
List<Base_Position> positionList_01 = positionList.Where(x => x.ShelveCode == "01").ToList();
|
List<Base_Position> positionList_02 = positionList.Where(x => x.ShelveCode == "02").ToList();
|
|
positionList_01 = FilterPositionTakeDoingTask(positionList_01, edm, 1);
|
positionList_02 = FilterPositionTakeDoingTask(positionList_02, edm, 2);
|
|
List<Base_Position> newList = new List<Base_Position>();
|
newList.AddRange(positionList_01);
|
newList.AddRange(positionList_02);
|
return newList;
|
//优化下面的逻辑
|
//List<Base_Position> new_positionList = new List<Base_Position>();
|
//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;
|
}
|
|
|
|
|
/// <summary>
|
/// 获取目前正在被占用的任务列表
|
/// </summary>
|
/// <param name="edm"></param>
|
/// <param name="areaCode">库区</param>
|
/// <returns></returns>
|
public static List<Task_Queue> 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<Task_Queue>();
|
else return list;
|
}
|
|
/// <summary>
|
/// 获取目前正在被占用的任务列表
|
/// </summary>
|
/// <param name="edm"></param>
|
/// <param name="areaCode">库区</param>
|
/// <param name="positionName">库位</param>
|
/// <returns></returns>
|
public static List<Task_Queue> 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<Task_Queue>();
|
else return list;
|
}
|
/// <summary>
|
/// 获取目前某个托盘正在被占用的任务列表
|
/// </summary>
|
/// <param name="edm"></param>
|
/// <param name="areaCode">库区</param>
|
/// <param name="positionName">库位</param>
|
/// <returns></returns>
|
public static List<Task_Queue> 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<Task_Queue>();
|
else return list;
|
}
|
|
/// <summary>
|
/// 获取目前某个托盘正在被占用的任务列表
|
/// </summary>
|
/// <param name="edm"></param>
|
/// <param name="areaCode">库区</param>
|
/// <param name="positionName">库位</param>
|
/// <returns></returns>
|
public static List<Purchase_Shelve> 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<Purchase_Shelve>();
|
else return list;
|
}
|
|
/// <summary>
|
/// 获取目前正在被占用的任务列表
|
/// </summary>
|
/// <param name="edm"></param>
|
/// <param name="areaCode">库区</param>
|
/// <param name="_taskType">任务类型</param>
|
/// <returns></returns>
|
public static List<Task_Queue> 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<Task_Queue>();
|
else return list;
|
}
|
|
|
|
/// <summary>
|
/// 获取指定物料编码的当前库存数
|
/// </summary>
|
/// <param name="edm"></param>
|
/// <param name="productCode">物料编码</param>
|
/// <param name="positionName">库位号</param>
|
/// <param name="cghw_ProductStorage">常规货位的库存数</param>
|
/// <param name="zcg_ProductStorage">暂存区的库存数</param>
|
/// <param name="dqkw_ProductStorage">当前库位的库存数</param>
|
/// <param name="trackNumber">当前库位的跟踪号</param>
|
/// <param name="dqkw_trackNumber_ProductStorage">当前库位的跟踪号库存数</param>
|
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 空库位统计
|
|
/// <summary>
|
/// 巷道1空库位统计
|
/// </summary>
|
/// <param name="mod"></param>
|
/// <param name="emtyps"></param>
|
public static void EmptyPositionTongJiForArea1(dbModel mod, ref List<emtypPosition> emtyps)
|
{
|
//巷道1空库位
|
List<Base_Position> emptyPositionArea1 = mod.Base_Position.Where(x => x.AreaCode == "1" && x.Enable == 1 && x.IsFreeze == 0 && x.IsLocked == 0).ToList();
|
List<Base_Position> 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<Base_Position> emptyPositionArea1_height = emptyPositionArea1.Where(x => x.RowCode == "01" || x.RowCode == "11").ToList();
|
List<Base_Position> 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);
|
}
|
|
///// <summary>
|
///// 巷道2小库位 空库位统计
|
///// </summary>
|
///// <param name="mod"></param>
|
///// <param name="emtyps"></param>
|
//public static void EmptyPositionTongJiForArea2_Small(dbModel mod, ref List<emtypPosition> emtyps)
|
//{
|
// string row2Sql = "select * from [dbo].[" + "Base_Position" + "] where AreaCode='2'and ColumnCode>1 and ColumnCode<10 and Enable=" + (int)usable.可用;//isFreeze 是否有货 先拿这个字段用
|
|
// List<Base_Position> allPositionArea2_small = mod.Database.SqlQuery<Base_Position>(row2Sql).ToList();//所有空库位
|
|
// List<Base_Position> 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<Base_Position> emptyPositionArea2_small_height2 = emptyPositionArea2_small.Where(x => x.RowCode == "03" || x.RowCode == "05" || x.RowCode == "07" || x.RowCode == "09" || x.RowCode == "10").ToList();
|
// List<Base_Position> allPositionArea2_small_height2 = allPositionArea2_small.Where(x => x.RowCode == "03" || x.RowCode == "05" || x.RowCode == "07" || x.RowCode == "09" || x.RowCode == "10").ToList();
|
// List<Base_Position> emptyPositionArea2_small_height3 = emptyPositionArea2_small.Where(x => x.RowCode == "01" || x.RowCode == "11").ToList();
|
// List<Base_Position> 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);
|
//}
|
|
/// <summary>
|
/// 巷道2小库位 空库位统计
|
/// </summary>
|
/// <param name="mod"></param>
|
/// <param name="emtyps"></param>
|
public static void EmptyPositionTongJiForArea2_Small(dbModel mod, ref List<emtypPosition> 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<Base_Position> allPositionArea2_small = mod.Database.SqlQuery<Base_Position>(row2Sql).ToList();//所有空库位
|
|
List<Base_Position> 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);
|
}
|
|
/// <summary>
|
/// 巷道2大库位 空库位统计
|
/// </summary>
|
/// <param name="mod"></param>
|
/// <param name="emtyps"></param>
|
public static void EmptyPositionTongJiForArea2_Big(dbModel mod, ref List<emtypPosition> 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<Base_Position> allPositionArea2_big4 = mod.Database.SqlQuery<Base_Position>(row2SqlBig4).ToList();
|
List<Base_Position> 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<Base_Position> allPositionArea2_big3 = mod.Database.SqlQuery<Base_Position>(row2SqlBig3).ToList();
|
List<Base_Position> 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<Base_Position> allPositionArea2_big2 = mod.Database.SqlQuery<Base_Position>(row2SqlBig2).ToList();
|
List<Base_Position> 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<Base_Position> allPositionArea2_big1 = mod.Database.SqlQuery<Base_Position>(row2SqlBig1).ToList();
|
List<Base_Position> 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
|
}
|
}
|