447 lines
17 KiB
C#
447 lines
17 KiB
C#
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();
|
||
UserModelCacheDAL UserCacheDAL = new UserModelCacheDAL();
|
||
ShowMesCacheDAL msgCache = new ShowMesCacheDAL();
|
||
LocationCacheDAL locCache = new LocationCacheDAL();
|
||
BoxCodeCacheDAL boxcache = new BoxCodeCacheDAL();
|
||
private static object showmes = new object();
|
||
public static bool OrisShow = false;
|
||
WorkIngCacheDAL workbll = new WorkIngCacheDAL();
|
||
#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_T();
|
||
// GetOrderQueue(); //加载任务显示器信息
|
||
|
||
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;
|
||
workbll.UpdateWorkModel(WorkEcommendType.Create);
|
||
////【多少个大区多少个线程】
|
||
//List<AddressstorageModel> Arealist = addrBLL.GetshelfidList();
|
||
//if (Arealist.Any())
|
||
//{
|
||
Work_JobDownThread downthread = new Work_JobDownThread();
|
||
downthread.tblock = "01|01";
|
||
Work_DisplayJobThread jobthread = new Work_DisplayJobThread();
|
||
jobthread.tblock = "01|01";
|
||
|
||
//foreach (AddressstorageModel item in Arealist)
|
||
//{
|
||
string block = "01|01";
|
||
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();
|
||
|
||
|
||
// }
|
||
// }
|
||
}
|
||
|
||
}
|
||
#endregion
|
||
|
||
|
||
|
||
|
||
|
||
#region 设备检测
|
||
public ResultModel TestStart(string batchno)
|
||
{
|
||
|
||
ResultModel result = comBLL.GetAllLabelList_M(batchno);
|
||
return result;
|
||
|
||
}
|
||
#endregion
|
||
|
||
#region 停止检测
|
||
public void TestEnd()
|
||
{
|
||
comBLL.clearALL_M();
|
||
|
||
}
|
||
#endregion
|
||
|
||
#region 结束作业
|
||
public void EndWork()
|
||
{
|
||
try
|
||
{
|
||
workbll.UpdateWorkModel(WorkEcommendType.Complete);
|
||
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
|
||
|
||
|
||
#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();
|
||
}
|
||
|
||
//规格
|
||
// 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 = "复核显示";
|
||
islock = false;
|
||
|
||
if (qdt != null && qdt.Rows.Count > 0)
|
||
{
|
||
show.Contents = qdt.Rows[0]["location"].ToString() + "(" + scanStr + ")" + "\r" + mes;
|
||
}
|
||
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;
|
||
show.Location = "check";
|
||
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);
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#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)
|
||
{
|
||
// bool bo = orderbll.isTask(sblock, sarea);
|
||
string msg = string.Empty;
|
||
//if (!bo)
|
||
//{
|
||
// msg = "当前商品无任务\r请送至下一区";
|
||
//}
|
||
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
|
||
|
||
|
||
|
||
|
||
}
|
||
}
|