//using iWareCommon.Utils;
|
//using iWareModel.Entity.MES;
|
//using iWareSql.MyDbContext;
|
//using Newtonsoft.Json;
|
//using System;
|
//using System.Collections.Generic;
|
//using System.Threading;
|
//using System.Linq;
|
//using Admin.NET.Core.TaskModule.Enum;
|
//using System.Configuration;
|
//using iWareModel.Entity.WCS;
|
//using iWareCC.Common.Helper;
|
//using Newtonsoft.Json.Bson;
|
//using System.Data.Entity;
|
//using System.Web;
|
//using iWareModel.Entity.WMS;
|
//using iWareCommon;
|
//using System.Threading.Tasks;
|
//using static System.Windows.Forms.VisualStyles.VisualStyleElement.TrackBar;
|
//using System.Windows.Forms;
|
//using iWareSql.DataAccess;
|
|
//namespace iWareCC
|
//{
|
// /// <summary>
|
// /// 3巷道下发任务处理的线程
|
// /// </summary>
|
// public class IssueTask3Handler
|
// {
|
// public static void Handler()
|
// {
|
// var errMsg = "";
|
// while (true)
|
// {
|
// try
|
// {
|
// //SystemWarningMsg._lbl_Alert_OutPlanTaskHandler3 = "循环开始...";
|
// if (SystemValue.isAllowRuning_OutTaskIssueTaskHandler3 && SystemValue.isStartedModel)
|
// {
|
// errMsg = "";//重置
|
// try
|
// {
|
|
// #region 查询堆垛机是否空闲
|
// //var utl = string.Format(WcsIp + @"GetDevicesInfo?Timestamp={0}&Creator={1}", DateTime.Now.ToString(), "cc");
|
// //var result1 = HttpHelper.Post(utl, "");
|
|
// WCSDevicesOutput data1 = null;
|
// if (FormCC.IsSimulationPLC)
|
// {//如果是模拟
|
// data1 = MyExtendHelper.GetSimulationSrmDevicesOutput();
|
// Log4NetHelper.WriteInfoLog(LogType.IssueTask3, "出库处理的线程(OutPlanTaskHandler)查询堆垛机是否空闲,模拟环境");
|
// SystemWarningMsg._lbl_Alert_OutPlanTaskHandler3 = "堆垛机状态查询模拟";
|
// }
|
// else
|
// {
|
// var utl = string.Format(@"GetDevicesInfo?Timestamp={0}&Creator={1}", DateTime.Now.ToString(), "cc");
|
// IDictionary<string, string> parameter = new Dictionary<string, string>();
|
// var result1 = new HTTPService(FormCC.WcsIp).postContentForString(utl, parameter, "");
|
|
// Log4NetHelper.WriteInfoLog(LogType.IssueTask3, "出库处理的线程(OutPlanTaskHandler)查询堆垛机是否空闲,返回结果:" + result1);
|
// if (result1 == null)
|
// {
|
// SystemWarningMsg._lbl_Alert_OutPlanTaskHandler3 = "堆垛机状态查询失败,WCS返回NULL";
|
// continue;//继续下一次循环
|
// }
|
// data1 = JsonConvert.DeserializeObject<WCSDevicesOutput>(result1);
|
// if (data1 == null || !data1.Success || data1.Data == null)
|
// {
|
// SystemWarningMsg._lbl_Alert_OutPlanTaskHandler3 = "堆垛机状态查询失败,WCS返回结果:" + result1;
|
// continue;//继续下一次循环
|
// }
|
// }
|
|
|
// if (data1.Data != null && data1.Data.SRM3 != null && data1.Data.SRM3.isfree == "1")
|
// {
|
// using (MyDbContext mycontext3 = new MyDbContext())
|
// {
|
// int Lane = int.Parse(data1.Data.SRM3.SrmNo);
|
// //如果有 ,就不下发出库任务了 【Editby shaocx,2023-03-07】
|
// var wareTask = TaskHandler.IsExistNoFinishedAndHasIssueWCSTaskByLane(mycontext3, 3);
|
// if (wareTask != null)
|
// {
|
// SystemWarningMsg._lbl_Alert_OutPlanTaskHandler3 = $"|| 3巷道下发出库任务失败,因为存在未结束,但是已下发WCS的任务!任务号:{wareTask.TaskNo},起点:{wareTask.FromLocationCode},目标点:{wareTask.ToLocationCode}";
|
// continue;//继续下一次循环
|
// }
|
|
// var ware_Tasks = mycontext3.ware_task.Where(x => (x.IsDeleted == null || x.IsDeleted == false) && x.State == 0 && x.AreaType == (int)AreaTypeEnum.立体库 && x.TaskCategory == 2 && x.Lane == Lane)
|
// .Where(TaskHandler.CommonFilterExpressionForNoFinishAndNoCancel())
|
// .OrderByDescending(x => x.TaskPriority).ToList();//查询未WCS下发未完成的任务
|
// if (ware_Tasks != null && ware_Tasks.Count > 0)
|
// {
|
// IssueTaskHelper.Out(mycontext3, FormCC.WcsIp, Lane, ware_Tasks, ref errMsg);
|
// if (!string.IsNullOrEmpty(errMsg))
|
// {
|
// SystemWarningMsg._lbl_Alert_OutPlanTaskHandler3 = "|| 3巷道下发出库任务失败," + errMsg;
|
// }
|
// }
|
// }
|
// }
|
// else
|
// {
|
// SystemWarningMsg._lbl_Alert_OutPlanTaskHandler3 = "|| 3号巷道无任务或者3号堆垛机不是空闲状态!";
|
// }
|
// #endregion
|
// // SystemWarningMsg._lbl_Alert_OutPlanTaskHandler3 = "循环结束...";
|
// }
|
// catch (Exception ex)
|
// {
|
// Log4NetHelper.WriteErrorLog(LogType.IssueTask3, "处理出入库下发=>" + errMsg + ",异常:" + ex.Message, ex);
|
// SystemWarningMsg._lbl_Alert_OutPlanTaskHandler3 = "处理出入库下发=>" + errMsg + ",异常:" + ex.Message;
|
// }
|
// }
|
// }
|
// catch (Exception ex)
|
// {
|
// SystemWarningMsg._lbl_Alert_OutPlanTaskHandler3 = "出现异常:" + ex.Message;
|
// Log4NetHelper.WriteErrorLog(LogType.IssueTask3, "OutPlanTaskHandler 出库任务 出现异常:" + ex.Message, ex);
|
// }
|
// Thread.Sleep(3 * 1000);//休眠3秒
|
// }
|
// }
|
// }
|
//}
|