2023-04-21 17:29:50 +08:00
|
|
|
|
using Epost.Common;
|
|
|
|
|
using Epost.DAL.Cache;
|
|
|
|
|
using Epost.DAL.Enum;
|
|
|
|
|
using Epost.Model;
|
2024-09-02 16:42:28 +08:00
|
|
|
|
using Epost.Model.resource;
|
2023-04-21 17:29:50 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Data;
|
2024-11-27 15:44:15 +08:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Runtime.InteropServices.WindowsRuntime;
|
2023-04-21 17:29:50 +08:00
|
|
|
|
using System.Threading;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace Epost.BLL
|
|
|
|
|
{
|
|
|
|
|
public class Work_DisplayJobThread
|
|
|
|
|
{
|
|
|
|
|
public string tblock, id;
|
|
|
|
|
public bool OrisShow = false;
|
|
|
|
|
OrderBLL orderbll = new OrderBLL();
|
|
|
|
|
OrdersQueueBLL queueBLL = new OrdersQueueBLL();
|
|
|
|
|
CommandBLL comBLL = new CommandBLL();
|
|
|
|
|
JobModelCacheDAL JobCache = new JobModelCacheDAL();
|
2024-09-05 13:36:12 +08:00
|
|
|
|
|
2023-04-21 17:29:50 +08:00
|
|
|
|
AddressstorageBLL addrBLL = new AddressstorageBLL();
|
|
|
|
|
WorkIngCacheDAL workbll = new WorkIngCacheDAL();
|
|
|
|
|
public void Displayjob()
|
|
|
|
|
{
|
|
|
|
|
GetWorkList(tblock);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 获取订单信息
|
|
|
|
|
private void GetWorkList(object block)
|
|
|
|
|
{
|
2024-09-02 16:42:28 +08:00
|
|
|
|
string cm = "";
|
|
|
|
|
cm = "lockdisJob" + block;
|
|
|
|
|
object c = (Object)cm;
|
|
|
|
|
lock (c)
|
2023-04-21 17:29:50 +08:00
|
|
|
|
{
|
|
|
|
|
while (OrisShow)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
string workstate = workbll.GetWorkState();
|
|
|
|
|
if (!string.IsNullOrEmpty(workstate))
|
|
|
|
|
{
|
|
|
|
|
OrisShow = true;
|
|
|
|
|
DisplayJob_M(block.ToString());
|
|
|
|
|
Thread.Sleep(50);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
OrisShow = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogHelper.WriteLogInfo(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ":程序异常!\r\n" + ex.Message);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 标签控制M系列
|
|
|
|
|
public void DisplayJob_M(string tblock)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
string[] nlist = tblock.Split('|');
|
|
|
|
|
string nblock = nlist[0];
|
|
|
|
|
string shelfid = nlist[1];
|
|
|
|
|
List<AddressstorageModel> Arealist = addrBLL.GetAreaList(nblock, shelfid);
|
|
|
|
|
foreach (AddressstorageModel item in Arealist)
|
|
|
|
|
{
|
|
|
|
|
OrdersQueueModel model = new OrdersQueueModel(); ;
|
|
|
|
|
model.Taskarea = item.area;
|
|
|
|
|
model.Taskblock = nblock;
|
|
|
|
|
#region 开始作业
|
|
|
|
|
DataTable queueDT = queueBLL.getQueueOrderState(model);
|
|
|
|
|
if (queueDT != null && queueDT.Rows.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
//当前区没有作业
|
|
|
|
|
if (queueDT.Rows[0]["state"].ToString() == "0")
|
|
|
|
|
{
|
2024-12-12 10:34:24 +08:00
|
|
|
|
|
2023-04-21 17:29:50 +08:00
|
|
|
|
displayOrder(queueDT, nblock, item.area, model);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogHelper.WriteLogInfo("标签控制异常:" + ex.Message);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 点亮设备
|
|
|
|
|
public void displayOrder(DataTable queueDT, string nblock, string narea, OrdersQueueModel model)
|
|
|
|
|
{
|
|
|
|
|
List<LabelParamModel> list = new List<LabelParamModel>();
|
|
|
|
|
model.Id = Convert.ToInt32(queueDT.Rows[0]["id"].ToString());
|
|
|
|
|
#region 点亮任务
|
|
|
|
|
List<JobModel> jobList = JobCache.GetPlanJobList();
|
|
|
|
|
List<JobModel> isJobList = jobList.FindAll(p => p.Block == nblock && p.Area == narea && p.State != 3);
|
|
|
|
|
ShowMessageModel showmodel = new ShowMessageModel();
|
|
|
|
|
//获取当前区任务并加入缓存
|
2025-06-05 15:11:19 +08:00
|
|
|
|
//if (!isJobList.Any())
|
|
|
|
|
//{
|
2023-04-21 17:29:50 +08:00
|
|
|
|
model.State = 1;
|
|
|
|
|
orderbll.GetOrderList(queueDT.Rows[0]["matchid"].ToString(), nblock, queueDT.Rows[0]["sku"].ToString(), narea, queueDT.Rows[0]["usercode"].ToString());
|
|
|
|
|
List<JobModel> nowJoblist = jobList.FindAll(p => p.State == 0 && p.Block == model.Taskblock && p.Area == model.Taskarea);
|
|
|
|
|
if (nowJoblist.Any())
|
|
|
|
|
{
|
|
|
|
|
var nowmodel = nowJoblist.FirstOrDefault();
|
|
|
|
|
|
|
|
|
|
LogHelper.WriteLogInfo("进入任务点亮=====matchid=" + nowmodel.Matchid + "===orderid===" + nowmodel.OrderID + "=====sku==" + nowmodel.Sku + "========");
|
2025-06-26 16:13:59 +08:00
|
|
|
|
#region 点亮任务标签
|
|
|
|
|
foreach (JobModel item in nowJoblist.ToArray())
|
|
|
|
|
{
|
2023-04-21 17:29:50 +08:00
|
|
|
|
|
2025-06-26 16:13:59 +08:00
|
|
|
|
//#region 回显设备锁定
|
|
|
|
|
//if (queueDT.Rows[0]["lightcolor"].ToString() == EnumHelper.EMToDescriptionString(LightColor.Color.Blue))
|
|
|
|
|
//{
|
|
|
|
|
|
|
|
|
|
// LabelParamModel locklamodel = new LabelParamModel();
|
|
|
|
|
// locklamodel.Address = item.Address.ToString();
|
|
|
|
|
// locklamodel.ControlIP = item.ControlIP.ToString();
|
|
|
|
|
// locklamodel.Command = "LOCK";
|
|
|
|
|
// locklamodel.Parameter = "11111000";
|
|
|
|
|
// locklamodel.Type = "N";
|
|
|
|
|
// list.Add(locklamodel);
|
|
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
//#endregion
|
|
|
|
|
// else
|
|
|
|
|
//{
|
|
|
|
|
//判断设备当前有没有被点亮
|
|
|
|
|
List<JobModel> isshowList = jobList.FindAll(p => p.Address == item.Address && p.ControlIP == item.ControlIP && p.State == 1);
|
|
|
|
|
if (!isshowList.Any())
|
|
|
|
|
{
|
|
|
|
|
List<JobModel> manyJoblist = nowJoblist.FindAll(m => m.Tolocation == item.Tolocation && m.Address == item.Address);
|
2023-04-21 17:29:50 +08:00
|
|
|
|
int quantity = item.Quantity;
|
|
|
|
|
LabelParamModel lamodel = new LabelParamModel();
|
|
|
|
|
lamodel.Address = item.Address.ToString();
|
|
|
|
|
lamodel.ControlIP = item.ControlIP.ToString();
|
|
|
|
|
lamodel.Command = "DISPLAY_JOB";
|
2025-06-26 16:13:59 +08:00
|
|
|
|
#region 同一个货位的数据合并显示
|
|
|
|
|
if (manyJoblist.Count > 1)
|
2025-06-26 13:39:30 +08:00
|
|
|
|
{
|
2025-06-26 16:13:59 +08:00
|
|
|
|
quantity = 0;
|
|
|
|
|
if (manyJoblist.FindAll(m => m.State == 0).Any())
|
2025-06-26 13:39:30 +08:00
|
|
|
|
{
|
2025-06-26 16:13:59 +08:00
|
|
|
|
foreach (JobModel mitem in manyJoblist)
|
|
|
|
|
{
|
|
|
|
|
quantity += mitem.Quantity;
|
|
|
|
|
mitem.State = 1;
|
|
|
|
|
mitem.ManyState = 1;
|
|
|
|
|
}
|
2025-06-26 13:39:30 +08:00
|
|
|
|
|
2025-06-26 16:13:59 +08:00
|
|
|
|
}
|
2025-06-26 13:39:30 +08:00
|
|
|
|
}
|
2025-06-26 16:13:59 +08:00
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
lamodel.Type = "N";
|
2023-04-21 17:29:50 +08:00
|
|
|
|
lamodel.Quantity = quantity.ToString();
|
|
|
|
|
lamodel.Uid = "U" + item.ID;
|
|
|
|
|
lamodel.Mode = queueDT.Rows[0]["lightcolor"].ToString() + "0";
|
|
|
|
|
list.Add(lamodel);
|
|
|
|
|
//}
|
|
|
|
|
item.State = 1;
|
|
|
|
|
item.ColorCode = queueDT.Rows[0]["lightcolor"].ToString();
|
|
|
|
|
item.DisplayTime = DateTime.Now;
|
|
|
|
|
}
|
2025-06-26 16:13:59 +08:00
|
|
|
|
}
|
2023-04-21 17:29:50 +08:00
|
|
|
|
#endregion
|
|
|
|
|
#region 点亮通道灯
|
|
|
|
|
comBLL.DISPLAY_LIGHT_BLOCK(model.Taskblock, model.Taskarea, "1");
|
|
|
|
|
#endregion
|
|
|
|
|
if (list != null && list.Count > 0)
|
|
|
|
|
{
|
2024-09-02 16:42:28 +08:00
|
|
|
|
LogHelper.WriteLogInfo("添加到点亮的list————————:" + list.Count);
|
2023-04-21 17:29:50 +08:00
|
|
|
|
comBLL.DISPLAY_JOBALL(list);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{//无任务
|
|
|
|
|
LogHelper.WriteLogInfo("点亮====无任务=======================");
|
|
|
|
|
model.State = 3;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
if (jobList.Any())
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var finishList = jobList.FindAll(p => p.State == 0);
|
|
|
|
|
if (!finishList.Any())
|
|
|
|
|
{
|
|
|
|
|
queueBLL.UpdateQueueOrderState(model);//缓存队列状态修改
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-06-05 15:11:19 +08:00
|
|
|
|
//}
|
|
|
|
|
//else
|
|
|
|
|
//{
|
|
|
|
|
|
|
|
|
|
// LogHelper.WriteLogInfo("还有未完成任务" + isJobList.Count);
|
|
|
|
|
// foreach (JobModel item in isJobList)
|
|
|
|
|
// {
|
|
|
|
|
// LogHelper.WriteLogInfo("还有未完成任务" + item.Address + item.ID);
|
|
|
|
|
// }
|
|
|
|
|
//}
|
2023-04-21 17:29:50 +08:00
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|