Files
T-DAS/Epost.BLL/OrderControlBLL.cs

453 lines
17 KiB
C#
Raw Normal View History

2023-01-13 15:30:20 +08:00
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Epost.Common;
using Epost.DAL.Cache;
using Epost.DAL.Enum;
using Epost.Model;
namespace Epost.BLL
{
public class OrderControlBLL
{
OrderBLL orderbll = new OrderBLL();
OrdersQueueBLL queueBLL = new OrdersQueueBLL();
CommandBLL comBLL = new CommandBLL();
JobModelCacheDAL JobCache = new JobModelCacheDAL();
ScanModelCacheDAL scanCacheDAL = new ScanModelCacheDAL();
JobDownCacheDAL downCacheDAL = new JobDownCacheDAL();
AddressstorageBLL addrBLL = new AddressstorageBLL();
2023-04-21 17:29:50 +08:00
UserModelCacheDAL UserCacheDAL = new UserModelCacheDAL();
2023-01-13 15:30:20 +08:00
ShowMesCacheDAL msgCache = new ShowMesCacheDAL();
LocationCacheDAL locCache = new LocationCacheDAL();
BoxCodeCacheDAL boxcache = new BoxCodeCacheDAL();
private static object showmes = new object();
public static bool OrisShow = false;
2023-04-21 17:29:50 +08:00
WorkIngCacheDAL workbll = new WorkIngCacheDAL();
2023-01-13 15:30:20 +08:00
#region
#region
public ResultModel ClearALL()
{
try
{
bool t = addrBLL.UpdateState();
LogHelper.WriteLogInfo("初始化@@@@@@@@@@@@----V20220705-1---");
JobCache.ClearJobList();
downCacheDAL.ClearJobDownList();
locCache.ClearScanList();
queueBLL.UpdateQueueState();
// queueboxBLL.UpdateQueueState();
orderbll.UpOrderstate();
UserCacheDAL.ClearUserCodeList();
boxcache.ClearBoxList();
ResultModel resultModel = comBLL.Initialization_M();
2024-09-02 16:42:28 +08:00
// GetOrderQueue(); //加载任务显示器信息
2023-04-21 17:29:50 +08:00
2023-01-13 15:30:20 +08:00
return resultModel;
}
catch (Exception ex)
{
LogHelper.WriteLogInfo("初始化异常" + ex.ToString());
ResultModel resultModel = new ResultModel();
resultModel.result = "-1";
resultModel.msg = "初始化异常";
return resultModel;
}
}
#endregion
#region
public void StartWork()
{
if (!OrisShow)
{
OrisShow = true;
2023-04-21 17:29:50 +08:00
workbll.UpdateWorkModel(WorkEcommendType.Create);
2023-01-13 15:30:20 +08:00
//【多少个大区多少个线程】
2023-04-21 17:29:50 +08:00
List<AddressstorageModel> Arealist = addrBLL.GetshelfidList();
2023-01-13 15:30:20 +08:00
if (Arealist.Any())
{
2023-04-21 17:29:50 +08:00
Work_JobDownThread downthread = new Work_JobDownThread();
downthread.tblock = "01|01";
Work_DisplayJobThread jobthread = new Work_DisplayJobThread();
jobthread.tblock = "01|01";
2024-09-02 16:42:28 +08:00
Work_ScanThread scantherad = new Work_ScanThread();
scantherad.tblock = "01|01";
2023-01-13 15:30:20 +08:00
foreach (AddressstorageModel item in Arealist)
{
2023-04-21 17:29:50 +08:00
string block = item.block + "|" + item.shelfid;
jobthread = new Work_DisplayJobThread();
jobthread.id = block;
jobthread.tblock = block;
jobthread.OrisShow = OrisShow;
Thread disthread = new Thread(new ThreadStart(jobthread.Displayjob));
disthread.Start();
downthread = new Work_JobDownThread();
downthread.id = block;
downthread.tblock = block;
downthread.OrisShow = OrisShow;
Thread thread = new Thread(new ThreadStart(downthread.Work));
thread.Start();
2024-09-02 16:42:28 +08:00
scantherad = new Work_ScanThread();
scantherad.id = block;
scantherad.tblock = block;
scantherad.OrisShow = OrisShow;
Thread scanthread = new Thread(new ThreadStart(scantherad.ScanList));
scanthread.Start();
2023-01-13 15:30:20 +08:00
}
}
}
}
#endregion
2023-04-21 17:29:50 +08:00
2023-01-13 15:30:20 +08:00
2023-04-21 17:29:50 +08:00
2023-01-13 15:30:20 +08:00
#region
public ResultModel TestStart()
{
ResultModel result = comBLL.GetAllLabelList_M();
return result;
}
#endregion
#region
public void TestEnd()
{
comBLL.clearALL_M();
}
#endregion
#region
public void EndWork()
{
try
{
2023-04-21 17:29:50 +08:00
workbll.UpdateWorkModel(WorkEcommendType.Complete);
2023-01-13 15:30:20 +08:00
LogHelper.WriteLogInfo("结束作业!");
OrisShow = false;
Thread.Sleep(500);
comBLL.CloseALL_M();
JobCache.ClearJobList();
downCacheDAL.ClearJobDownList();
scanCacheDAL.ClearScanList();
}
catch (Exception ex)
{
LogHelper.WriteLogInfo("结束作业异常" + ex.Message);
}
}
#endregion
#endregion
#region
public void GetOrderQueue()
{
DataTable dt = queueBLL.getQueueOrderStateList();
if (dt != null && dt.Rows.Count > 0)
{
foreach (DataRow item in dt.Rows)
{
if (item["lightcolor"].ToString() == EnumHelper.EMToDescriptionString(LightColor.Color.Blue))
{
Mes_Echo(item["sku"].ToString(), item["taskblock"].ToString(), item["taskarea"].ToString(), 1, null, "", item["matchid"].ToString());
}
else
{
showSummaryMes(item["sku"].ToString(), item["taskblock"].ToString(), item["taskarea"].ToString(), 1, null, "", item["matchid"].ToString());
}
}
}
}
#endregion
2023-04-21 17:29:50 +08:00
2023-01-13 15:30:20 +08:00
#region
public void Mes_Echo(string scanStr, string sblock, string sarea, int type, ResultMessageModel data = null, string location = "", string matchid = "", bool islock = true)
{
DataTable sudt = orderbll.GetSumList_Echo("", scanStr, sblock);
if (type == 2)
{
sudt = orderbll.GetSumList_Echo("", scanStr, sblock, sarea);
}
//查询当前区任务队列
DataTable qdt = queueBLL.getQueuesOrderbyState(sblock, sarea, "1");
if (sudt != null && sudt.Rows.Count > 0)
{
matchid = sudt.Rows[0]["matchid"].ToString();
string sku = string.Empty;
string qty = string.Empty;
string color = string.Empty;
if (qdt != null && qdt.Rows.Count > 0)
{
sku = qdt.Rows[0]["sku"].ToString();
qty = sudt.Rows[0]["SumQuantity"].ToString();
color = qdt.Rows[0]["LightColor"].ToString();
}
//规格
2023-04-21 17:29:50 +08:00
// int discount = Convert.ToInt32(sudt.Rows[0]["discount"].ToString());
2023-01-13 15:30:20 +08:00
//整件总数
int SumCkQuantity = 0;// Convert.ToInt32(sudt.Rows[0]["SumCkQuantity"].ToString());
2023-04-21 17:29:50 +08:00
//散件总数
2023-01-13 15:30:20 +08:00
int SumQuantity = Convert.ToInt32(sudt.Rows[0]["SumQuantity"].ToString());
//if (discount != 1)
//{
// if (SumQuantity >= discount)
// {
// SumCkQuantity = SumQuantity / discount;
// SumQuantity = SumQuantity % discount;
// }
//}
ShowMessageModel_M show = new ShowMessageModel_M();
show.Title = sudt.Rows[0]["goodsname"].ToString();
string mes = "复核显示";
islock = false;
if (qdt != null && qdt.Rows.Count > 0)
{
2023-04-21 17:29:50 +08:00
show.Contents = qdt.Rows[0]["location"].ToString() + "(" + scanStr + ")" + "\r" + mes;
2023-01-13 15:30:20 +08:00
}
if (data != null)
{
show.Contents = data.ScanCode + "(" + scanStr + ")" + "\r"+ mes;
sku = data.Parameter;
}
show.Color = EnumHelper.EMToDescriptionString(LightColor.Color.Blue);
show.Qty = SumQuantity.ToString();
show.Wholeqty = SumCkQuantity;
show.Unit = "件";
show.Type = 8;
show.Wholeunit = "箱";
show.Block = sblock;
show.Area = sarea;
show.Islock = islock;
2023-04-21 17:29:50 +08:00
show.Location = "check";
2023-01-13 15:30:20 +08:00
comBLL.ShowBoxMessage_M(show);
if (data != null)
{
data.Status = "1";
}
}
else
{
//查询当前区任务队列
DataTable finshqdt = queueBLL.getQueuesOrderbyState(sblock, sarea, "3");
ShowMessageModel_M show = new ShowMessageModel_M();
//根据sku获取商品名称
string goodsname = orderbll.GetGoodsname(location);
show.Title = goodsname + "分播完成";
show.Contents = scanStr + "\r请扫描继续作业";
show.Color = EnumHelper.EMToDescriptionString(LightColor.Color.Red);
show.Qty = "0";
show.Type = 8;
show.Block = sblock;
show.Area = sarea;
show.Islock = true;
comBLL.ShowBoxMessage_M(show);
}
}
2023-04-21 17:29:50 +08:00
#endregion
2023-01-13 15:30:20 +08:00
#region
/// <summary>
/// 订单显示器中分提示
/// </summary>
/// <param name="scanStr"></param>
/// <param name="sblock"></param>
/// <param name="sarea"></param>
/// <param name="type">type=1查询整个通道block的汇总数量type=2查询当前通道下某 一区area的汇总数量</param>
/// <param name="data"></param>
public void showSummaryMes(string scanStr, string sblock, string sarea, int type, ResultMessageModel data = null, string location = "", string matchid = "", bool islock = true)
{
try
{
lock (showmes)
{
2024-09-02 16:42:28 +08:00
// bool bo = orderbll.isTask(sblock, sarea);
2023-01-13 15:30:20 +08:00
string msg = string.Empty;
2024-09-02 16:42:28 +08:00
//if (!bo)
//{
// msg = "当前商品无任务\r请送至下一区";
//}
2023-01-13 15:30:20 +08:00
DataTable sudt = orderbll.GetSumList("", scanStr, sblock);
if (type == 2)
{
sudt = orderbll.GetSumList("", scanStr, sblock, sarea);
}
//查询当前区任务队列
DataTable qdt = queueBLL.getQueuesOrderbyState(sblock, sarea, "1");
if (sudt != null && sudt.Rows.Count > 0)
{
matchid = sudt.Rows[0]["matchid"].ToString();
string showqty = string.Empty;
string showsku = string.Empty;
List<ShowMesModel> msglist = msgCache.GetMsgList().FindAll(p => p.Block == sblock && p.Area == sarea && p.Matchid == matchid && p.Sku == scanStr);
if (msglist.Any())
{
ShowMesModel showmodel = msglist.FirstOrDefault();
showqty = showmodel.Qty;
showsku = showmodel.Sku;
}
//////qdt.Rows[0]["sku"].ToString() 为null data.ScanCode
string sku = string.Empty;
string qty = string.Empty;
string color = string.Empty;
if (qdt != null && qdt.Rows.Count > 0)
{
sku = qdt.Rows[0]["sku"].ToString();
qty = sudt.Rows[0]["SumQuantity"].ToString();
color = qdt.Rows[0]["LightColor"].ToString();
}
//规格
int discount = Convert.ToInt32(sudt.Rows[0]["discount"].ToString());
//整件总数
int SumCkQuantity = 0; //Convert.ToInt32(sudt.Rows[0]["SumCkQuantity"].ToString());
//散件总数
int SumQuantity = Convert.ToInt32(sudt.Rows[0]["SumQuantity"].ToString());
//if (discount != 1)
//{
// if (SumQuantity >= discount)
// {
// SumCkQuantity = SumQuantity / discount;
// SumQuantity = SumQuantity % discount;
// }
//}
ShowMessageModel_M show = new ShowMessageModel_M();
show.Title = sudt.Rows[0]["goodsname"].ToString();
string mes = "拣货任务";
if (qdt != null && qdt.Rows.Count > 0)
{
show.Contents = qdt.Rows[0]["location"].ToString() + "(" + scanStr + ")" + "\r"+ mes;//sudt.Rows[0]["goodscode"].ToString().Replace(';','\r');
}
if (data != null)
{
show.Contents = data.ScanCode + "(" + scanStr + ")" + "\r"+ mes;// sudt.Rows[0]["goodscode"].ToString().Replace(';', '\r');
sku = data.Parameter;
}
show.Color = EnumHelper.EMToDescriptionString(LightColor.Color.Green);
show.Qty = SumQuantity.ToString();
show.Wholeqty = SumCkQuantity;
show.Unit = "件";
show.Type = 8;
show.Wholeunit = "箱";
show.Block = sblock;
show.Area = sarea;
show.Islock = islock;
ShowMesModel megmodel = new ShowMesModel();
megmodel.Qty = sudt.Rows[0]["SumQuantity"].ToString();
megmodel.Sku = sku;
megmodel.Area = sarea;
megmodel.Block = sblock;
megmodel.Matchid = matchid;
msgCache.UpdateMsgModelList(new List<ShowMesModel> { megmodel }, EmsgCommend.Create);
comBLL.ShowBoxMessage_M(show);
if (data != null)
{
data.Status = "1";
}
}
else
{
//查询当前区任务队列
DataTable finshqdt = queueBLL.getQueuesOrderbyState(sblock, sarea, "3");
ShowMessageModel_M show = new ShowMessageModel_M();
//根据sku获取商品名称
string goodsname = orderbll.GetGoodsname(location);
show.Title = goodsname + "分播完成";
show.Contents = scanStr + "\r请扫描继续作业";
show.Color = EnumHelper.EMToDescriptionString(LightColor.Color.Green);
show.Qty = "0";
show.Type = 8;
show.Block = sblock;
show.Area = sarea;
show.Islock = true;
comBLL.ShowBoxMessage_M(show);
}
}
}
catch (Exception ex)
{
LogHelper.WriteLogInfo("刷新显示器异常:" + ex.Message);
}
}
#endregion
#region
public void ShowMatchMes(string scanStr, string sblock)
{
DataTable sumlist = orderbll.GetMatchSumList(scanStr, sblock);
if (sumlist != null && sumlist.Rows.Count > 0)
{
ShowMessageModel_M show = new ShowMessageModel_M();
show.Title = "波次号:" + scanStr;
show.Color = EnumHelper.EMToDescriptionString(LightColor.Color.Red);
show.Block = sblock;
show.Islock = true;
// string qty = ConvertHexHelper.ConvertString(sumlist.Rows[0]["incompleteCount"].ToString(), 10, 16); //拣货数量
show.Qty = sumlist.Rows[0]["incompleteCount"].ToString();
show.Location = sumlist.Rows[0]["completeCount"].ToString();
show.Contents = "SKU总数:" + sumlist.Rows[0]["completeCount"].ToString() + "\rSKU待播数:" + sumlist.Rows[0]["incompleteCount"].ToString();
comBLL.ShowBoxMessage_M(show);
}
}
#endregion
2023-04-21 17:29:50 +08:00
2023-01-13 15:30:20 +08:00
2023-04-21 17:29:50 +08:00
2023-01-13 15:30:20 +08:00
}
}