using Microsoft.AspNetCore.Http;
using Rhea.Common;
using SqlSugar;
using Swifter.Tools;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.WebSockets;
using System.Text;
using System.Threading.Tasks;
using Tiger.IBusiness;
using Tiger.IBusiness.WMS;
using Tiger.Model;
using Tiger.Model.Base;
using Tiger.Model.Entitys.MES.Position;
namespace Tiger.Business
{
///
/// 业务单据 上下文
///
public class OrderContext : IOrderContext
{
#region 业务单据管理
///
/// 业务单据缓存字典
///
public static Dictionary> OrderDic { get; set; } = new Dictionary>();
public Dictionary> GetOrderDic() => OrderDic;
///
/// 从业务单据字典中获取一个业务单据对象
///
///
///
public static IWmsOrder Get(string order)
{
if (OrderDic.ContainsKey(order))
{
return OrderDic[order];
}
return null;
}
///
/// 从业务单据字典中获取一个业务单据对象
///
///
///
public IWmsOrder GetOrder(string order)
{
return Get(order);
}
///
/// 判断业务单据是否存在于业务单据字典中
///
///
///
public static bool Exists(string order)
{
return OrderDic.ContainsKey(order);
}
///
/// 判断业务单据是否存在于业务单据字典中
///
///
///
public bool ExistsOrder(string order)
{
return Exists(order);
}
///
/// 增加一个业务单据对象到业务单据字典中
///
///
///
public static bool Add(IWmsOrder order)
{
try
{
if (OrderDic.ContainsKey(order.OrderNo))
{
OrderDic[order.OrderNo] = order;
}
else
{
OrderDic.Add(order.OrderNo, order);
}
return true;
}
catch (Exception ex)
{
Logger.Default.Fatal(ex, $"从业务单据字典中删除业务单据[{order}]对象异常");
return false;
}
}
///
/// 增加一个业务单据对象到业务单据字典中
///
///
///
public static bool Add(string type, string order)
{
throw new NotImplementedException();
}
///
/// 增加一个业务单据对象到业务单据字典中
///
///
///
public bool AddOrder(string type, string order)
{
return Add(type, order);
}
///
/// 从业务单据字典中删除一个业务单据对象
///
///
///
public static bool Remove(string order)
{
try
{
if (OrderDic.ContainsKey(order))
{
OrderDic.Remove(order);
}
return true;
}
catch (Exception ex)
{
Logger.Default.Fatal(ex, $"从业务单据字典中删除业务单据[{order}]对象异常");
return false;
}
}
///
/// 从业务单据字典中删除一个业务单据对象
///
///
///
public bool RemoveOrder(string order)
{
return Remove(order);
}
///
/// 清空业务单据字典
///
///
///
public static bool Clear()
{
try
{
OrderDic.Clear();
return true;
}
catch (Exception ex)
{
Logger.Default.Fatal(ex, $"清空业务单据字典异常");
return false;
}
}
///
/// 清空业务单据字典
///
///
///
public bool ClearOrder()
{
return Clear();
}
#endregion
}
}