schangxiang@126.com
2025-04-01 de7dbe7cf85aa01abb64040aae1c04dfba74c135
优化 和plc交互问题
已添加2个文件
已修改6个文件
607 ■■■■■ 文件已修改
CC/iWareCC_ASRS/ThreadService/02_BZ39工位(补板后工位)/Inbound/2、DataProcess_BZ39_IssueInboundTask.cs 41 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
CC/iWareCC_ASRS/ThreadService/02_BZ39工位(补板后工位)/Inbound/3、DataProcess_RobotBuffer_FinishTask.cs 44 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
CC/iWareCC_ASRS/ThreadService/02_BZ39工位(补板后工位)/Outbound/2、DataProcess_RobotBuffer_IssueOutboundTask - 复制.cs 185 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
CC/iWareCC_ASRS/ThreadService/02_BZ39工位(补板后工位)/Outbound/2、DataProcess_RobotBuffer_IssueOutboundTask.cs 68 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
CC/iWareCC_ASRS/ThreadService/02_BZ39工位(补板后工位)/Outbound/3、DataProcess_RobotBuffer_FinishTaskForOutbound - 复制.cs 262 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
CC/iWareCC_ASRS/ThreadService/02_BZ39工位(补板后工位)/Outbound/3、DataProcess_RobotBuffer_FinishTaskForOutbound.cs 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
CC/iWareCC_ASRS/iWareCC.csproj 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
CC/iWareCommon/BusinessHelper/BusinessHelper.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
CC/iWareCC_ASRS/ThreadService/02_BZ39¹¤Î»£¨²¹°åºó¹¤Î»£©/Inbound/2¡¢DataProcess_BZ39_IssueInboundTask.cs
@@ -67,6 +67,35 @@
                            ////这里下发 å…¥åº“库任务
                            //using (StationServiceClient client = new StationServiceClient())
                            //{
                            //    var res = await client.WriteInStoreTaskInfoAsync((int)EDevice.Station, rgvLocation, doTask.PlaceCode,
                            //       (short)doTask.Length,
                            //       (short)doTask.Width, (short)doTask.Thk, Convert.ToInt32(doTask.TaskNo));
                            //    if (!res.result)
                            //    {
                            //        SystemWarningMsg._lbl_alert_DataProcess_BZ39 = $"{rgvLocation.ToString()}-下发入库任务 å¤±è´¥,WriteInStoreTaskInfoAsync è¿”回:{res.resMsg}";
                            //        Log4NetHelper.WriteErrorLog(logType, $"{rgvLocation.ToString()}-下发PLC入库任务失败 ,WriteInStoreTaskInfoAsync,返回:{res.resMsg},参数: PlaceCode:{doTask.PlaceCode},TaskNo:{doTask.TaskNo}", null);
                            //        continue;
                            //    }
                            //    else
                            //    {
                            //        Log4NetHelper.WriteInfoLog(logType, $"{rgvLocation.ToString()}-下发PLC入库任务 æˆåŠŸ,WriteInStoreTaskInfoAsync,参数: PlaceCode:{doTask.PlaceCode},TaskNo:{doTask.TaskNo}");
                            //    }
                            //}
                            doTask.TaskStatus = (int)TaskStatusEnum.已下发;
                            doTask.IssueTime = DateTime.Now;
                            int changeNum = wmsDB.SaveChanges();
                            if (changeNum > 0)
                            {
                                //必须要给PLC下发成功,解决可能会给PLC重复下发任务的情况
                                var isRight = true;
                                while (isRight)
                                {
                            //这里下发 å…¥åº“库任务
                            using (StationServiceClient client = new StationServiceClient())
                            {
@@ -77,18 +106,18 @@
                                if (!res.result)
                                {
                                    SystemWarningMsg._lbl_alert_DataProcess_BZ39 = $"{rgvLocation.ToString()}-下发入库任务 å¤±è´¥,WriteInStoreTaskInfoAsync è¿”回:{res.resMsg}";
                                            Log4NetHelper.WriteErrorLog(logType, $"{rgvLocation.ToString()}-下发PLC入库任务失败 ,WriteInStoreTaskInfoAsync,返回:{res.resMsg},参数: PlaceCode:{doTask.PlaceCode},TaskNo:{doTask.TaskNo},条码:{doTask.Upi}", null);
                                    continue;
                                }
                                else
                                {
                                    Log4NetHelper.WriteInfoLog(logType, $"{rgvLocation.ToString()}-下发入库任务 æˆåŠŸ,WriteInStoreTaskInfoAsync,参数: ç«™ç‚¹{rgvLocation}");
                                            Log4NetHelper.WriteInfoLog(logType, $"{rgvLocation.ToString()}-下发PLC入库任务 æˆåŠŸ,WriteInStoreTaskInfoAsync,参数: PlaceCode:{doTask.PlaceCode},TaskNo:{doTask.TaskNo},条码:{doTask.Upi}");
                                            isRight = false;
                                }
                            }
                            doTask.TaskStatus = (int)TaskStatusEnum.已下发;
                            doTask.IssueTime = DateTime.Now;
                            wmsDB.SaveChanges();
                                    Thread.Sleep(1000);
                                }
                            }
                        }
                    }
CC/iWareCC_ASRS/ThreadService/02_BZ39¹¤Î»£¨²¹°åºó¹¤Î»£©/Inbound/3¡¢DataProcess_RobotBuffer_FinishTask.cs
@@ -225,8 +225,39 @@
            var place = StationHandler.GetPlaceByPlaceCode(task.PlaceCode, wmsDB);
            place.PlaceStatus = (int)PlaceStatusEnum.正常;
            //if (isFlagFinish == false)
            //{
            //    //给PLC推送任务完成确认信号
            //    using (StationServiceClient client = new StationServiceClient())
            //    {
            //        var res = await client.InboundFinishConfirmAsync((int)EDevice.Station, true, rgvLocation);
            //        if (!res.result)
            //        {
            //            SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_FinishTask = $"{rgvLocation.ToString()}-下发入库任务 å¤±è´¥,InboundFinishConfirmAsync è¿”回:{res.resMsg}";
            //            return false;
            //        }
            //        else
            //        {
            //            Log4NetHelper.WriteInfoLog(logType, $"{rgvLocation.ToString()}-下发入库任务 æˆåŠŸ,InboundFinishConfirmAsync,参数: ç«™ç‚¹{rgvLocation}");
            //        }
            //    }
            //}
            var flag = isFlagFinish ? "人工强制完成" : "(自动完成)";
            WmsRecordUpiProcessHandler.SaveWmsRecordUpiProcess(wmsDB, upiObj, task.PlaceCode, "缓存入库完成(" + flag + "):" + task.PlaceCode);
            int changeNum = wmsDB.SaveChanges();
            if (changeNum > 0)
            {
                //必须要给PLC下发成功,解决可能会给PLC重复下发任务的情况
                var isRight = true;
            if (isFlagFinish == false)
            {
                    while (isRight)
                    {
                        var obj = FormCC.stationView.R_StationForReadCommList.Where(x => x.StationCode == rgvLocation.ToString()).FirstOrDefault();
                        isRight = obj.R_InboundFinish;
                //给PLC推送任务完成确认信号
                using (StationServiceClient client = new StationServiceClient())
                {
@@ -234,19 +265,18 @@
                    if (!res.result)
                    {
                        SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_FinishTask = $"{rgvLocation.ToString()}-下发入库任务 å¤±è´¥,InboundFinishConfirmAsync è¿”回:{res.resMsg}";
                        return false;
                                Log4NetHelper.WriteErrorLog(logType, $"{rgvLocation.ToString()}-完成入库任务写入【true】 å¤±è´¥,InboundFinishConfirmAsync,返回:{res.resMsg},参数:TaskNo:{task.TaskNo}, PlaceCode:{task.PlaceCode},条码:{task.Upi}");
                    }
                    else
                    {
                        Log4NetHelper.WriteInfoLog(logType, $"{rgvLocation.ToString()}-下发入库任务 æˆåŠŸ,InboundFinishConfirmAsync,参数: ç«™ç‚¹{rgvLocation}");
                                Log4NetHelper.WriteInfoLog(logType, $"{rgvLocation.ToString()}-完成入库任务写入【true】 æˆåŠŸ,InboundFinishConfirmAsync,参数:TaskNo:{task.TaskNo}, PlaceCode:{task.PlaceCode},条码:{task.Upi}");
                                //isRight = false;
                            }
                        }
                        Thread.Sleep(1000);
                    }
                }
            }
            var flag = isFlagFinish ? "人工强制完成" : "(自动完成)";
            WmsRecordUpiProcessHandler.SaveWmsRecordUpiProcess(wmsDB, upiObj, task.PlaceCode, "缓存入库完成(" + flag + "):" + task.PlaceCode);
            wmsDB.SaveChanges();
            return true;
        }
CC/iWareCC_ASRS/ThreadService/02_BZ39¹¤Î»£¨²¹°åºó¹¤Î»£©/Outbound/2¡¢DataProcess_RobotBuffer_IssueOutboundTask - ¸´ÖÆ.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,185 @@
//using Admin.NET.Application;
//using iWareCC.Common.Helper;
//using iWareCC.StationService;
//using iWareCommon.Common.Globle;
//using iWareCommon.Utils;
//using iWareModel;
//using iWareSql.DataAccess;
//using iWareSql.DBModel;
//using iWareSql.WmsDBModel;
//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.ServiceModel.Configuration;
//using System.Text;
//using System.Threading;
//using System.Threading.Tasks;
//using WZ.Useful.Commons;
//using XiGang.Core.Model;
//namespace iWareCC.ThreadService
//{
//    /// <summary>
//    /// æœºå™¨äººç¼“存岛 è‡ªåŠ¨ä¸‹å‘å‡ºåº“ä»»åŠ¡ å¤„理
//    /// </summary>
//    public static class DataProcess_RobotBuffer_IssueOutboundTask
//    {
//        public static async void Handler()
//        {
//            var alertMsg = "";
//            LogType logType = LogType.DataProcess_RobotBuffer_IssueOutboundTask;
//            while (true)
//            {
//                Thread.Sleep(1000);//休眠2秒,将休眠写到前面,是为了下面的continue方法执行后不显示错误信息的提示!!!【EditBy shaocx,2022-05-24】
//                SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_IssueOutboundTask = string.Empty;
//                try
//                {//SystemValue.isAllowRuning_DataProcess_RobotBuffer_IssueOutboundTask &&
//                    if (SystemValue.isStartedModel)
//                    {
//                        var rgvLocation = StationLocationEnum.BZ39.ToString();
//                        /*
//                         * 1、从数据库中判断是否齐套
//                         * 2、根据齐套结果,推送给PLC
//                         */
//                        using (WmsDBModel wmsDB = new WmsDBModel())
//                        {
//                            var noFinishOutTask = TaskHandler.ValidateIssueTaskForNoFinishTaskByOutStore(wmsDB);
//                            if (noFinishOutTask == true)
//                            {//表示没有未结束的出库任务,那么就 åˆå§‹åŒ–请求出库指令
//                                using (StationServiceClient client = new StationServiceClient())
//                                {
//                                    var res = await client.WriteOutStoreTaskInfoAsync(true, (int)EDevice.Station, rgvLocation, "", 0);
//                                    if (!res.result)
//                                    {
//                                        SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_IssueOutboundTask = $"{rgvLocation.ToString()}-初始化请求出库指令 å¤±è´¥,WriteOutStoreTaskInfoAsync è¿”回:{res.resMsg}";
//                                        continue;
//                                    }
//                                    else
//                                    {
//                                        //Log4NetHelper.WriteInfoLog(logType, $"{rgvLocation.ToString()}-初始化请求出库指令 æˆåŠŸ,WriteOutStoreTaskInfoAsync,参数: ç«™ç‚¹{rgvLocation}");
//                                    }
//                                }
//                            }
//                            //要是有已下发的任务,就不要执行
//                            var isValidate = TaskHandler.ValidateIssueOutTaskForRobotBuffer(wmsDB);
//                            if (!isValidate)
//                            {
//                                SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_IssueOutboundTask = $"{rgvLocation.ToString()}-有‘已下发’的任务,不能处理,此次循环结束";
//                                continue;
//                            }
//                            //取创建时间最早的那个要出库的包
//                            if (string.IsNullOrEmpty(FormCC.currHandlerPackageCodeForIssueOutboundTask))
//                            {
//                                var firstTask = wmsDB.wms_rbline_task.Where(x =>
//                           (x.RbTaskType == (int)RbTaskTypeEnum.齐包出库任务 || x.RbTaskType == (int)RbTaskTypeEnum.强制出库任务)
//                          && x.TaskStatus == (int)TaskStatusEnum.新建).OrderBy(x => x.CreateTime).FirstOrDefault();
//                                if (firstTask == null)
//                                {
//                                    SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_IssueOutboundTask = $"{rgvLocation.ToString()},根据 æ²¡æœ‰æ‰¾åˆ° æ–°å»º çš„任务 ";
//                                    FormCC.currHandlerPackageCodeForIssueOutboundTask = "";
//                                    continue;
//                                }
//                                FormCC.currHandlerPackageCodeForIssueOutboundTask = firstTask.PackageCode;
//                            }
//                            else
//                            {
//                                var firstTask = wmsDB.wms_rbline_task.Where(x =>
//                           (x.RbTaskType == (int)RbTaskTypeEnum.齐包出库任务 || x.RbTaskType == (int)RbTaskTypeEnum.强制出库任务)
//                          && x.TaskStatus == (int)TaskStatusEnum.新建
//                          && x.PackageCode == FormCC.currHandlerPackageCodeForIssueOutboundTask
//                          ).OrderBy(x => x.CreateTime).FirstOrDefault();
//                                if (firstTask == null)
//                                {
//                                    SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_IssueOutboundTask = $"{rgvLocation.ToString()},根据 æ²¡æœ‰æ‰¾åˆ° æ–°å»º çš„任务 ";
//                                    FormCC.currHandlerPackageCodeForIssueOutboundTask = "";
//                                    continue;
//                                }
//                            }
//                            var taskList = wmsDB.wms_rbline_task.Where(x =>
//                          (x.RbTaskType == (int)RbTaskTypeEnum.齐包出库任务 || x.RbTaskType == (int)RbTaskTypeEnum.强制出库任务)
//                          && x.TaskStatus == (int)TaskStatusEnum.新建).Where(x => x.PackageCode == FormCC.currHandlerPackageCodeForIssueOutboundTask).OrderBy(x => x.CreateTime).ToList();
//                            if (taskList == null)
//                            {
//                                SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_IssueOutboundTask = $"{rgvLocation.ToString()},根据 æ²¡æœ‰æ‰¾åˆ° æ–°å»º çš„任务 ";
//                                continue;
//                            }
//                            var doTask = taskList.FirstOrDefault();
//                            ////这里下发 å‡ºåº“任务
//                            //using (StationServiceClient client = new StationServiceClient())
//                            //{
//                            //    //首先要清理
//                            //    //var res = await client.OutboundFinishConfirmAsync((int)EDevice.Station, false, rgvLocation);
//                            //    //if (!res.result)
//                            //    //{
//                            //    //    SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_FinishTaskForOutbound = $"{rgvLocation.ToString()}-下发出库任务 å¤±è´¥,OutboundFinishConfirmAsync è¿”回:{res.resMsg}";
//                            //    //    continue;
//                            //    //}
//                            //    //else
//                            //    //{
//                            //    //    Log4NetHelper.WriteInfoLog(logType, $"{rgvLocation.ToString()}-下发出库任务 æˆåŠŸ,OutboundFinishConfirmAsync,参数: ç«™ç‚¹{rgvLocation}");
//                            //    //}
//                            //    var res = await client.WriteOutStoreTaskInfoAsync(false, (int)EDevice.Station, rgvLocation, doTask.PlaceCode, Convert.ToInt32(doTask.TaskNo));
//                            //    if (!res.result)
//                            //    {
//                            //        SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_IssueOutboundTask = $"{rgvLocation.ToString()}-下发出库任务 å¤±è´¥,WriteOutStoreTaskInfoAsync è¿”回:{res.resMsg}";
//                            //        continue;
//                            //    }
//                            //    else
//                            //    {
//                            //        Log4NetHelper.WriteInfoLog(logType, $"{rgvLocation.ToString()}-下发出库任务 æˆåŠŸ,WriteOutStoreTaskInfoAsync,参数: ç«™ç‚¹{rgvLocation}");
//                            //    }
//                            //}
//                            doTask.TaskStatus = (int)TaskStatusEnum.已下发;
//                            doTask.IssueTime = DateTime.Now;
//                            int changeNum = wmsDB.SaveChanges();
//                            if (changeNum > 0)
//                            {
//                                //必须要给PLC下发成功,解决可能会给PLC重复下发任务的情况
//                                var isRight = true;
//                                while (isRight)
//                                {
//                                    //这里下发 å‡ºåº“任务
//                                    using (StationServiceClient client = new StationServiceClient())
//                                    {
//                                        var res = await client.WriteOutStoreTaskInfoAsync(false, (int)EDevice.Station, rgvLocation, doTask.PlaceCode, Convert.ToInt32(doTask.TaskNo));
//                                        if (!res.result)
//                                        {
//                                            SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_IssueOutboundTask = $"{rgvLocation.ToString()}-下发出库任务 å¤±è´¥,WriteOutStoreTaskInfoAsync è¿”回:{res.resMsg}参数: PlaceCode:{doTask.PlaceCode},TaskNo:{doTask.TaskNo}";
//                                            Log4NetHelper.WriteErrorLog(logType, $"{rgvLocation.ToString()}-下发出库任务 å¤±è´¥,WriteOutStoreTaskInfoAsync,参数: PlaceCode:{doTask.PlaceCode},TaskNo:{doTask.TaskNo},条码:{doTask.Upi}");
//                                            continue;
//                                        }
//                                        else
//                                        {
//                                            Log4NetHelper.WriteInfoLog(logType, $"{rgvLocation.ToString()}-下发出库任务 æˆåŠŸ,WriteOutStoreTaskInfoAsync,参数: PlaceCode:{doTask.PlaceCode},TaskNo:{doTask.TaskNo},条码:{doTask.Upi}");
//                                            isRight = false;
//                                        }
//                                    }
//                                    Thread.Sleep(1000);
//                                }
//                            }
//                        }
//                    }
//                }
//                catch (Exception ex)
//                {
//                    SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_IssueOutboundTask += " å‡ºçް异叏:" + ex.Message + SysGloble.SPLIT_STR;
//                    Log4NetHelper.WriteErrorLog(logType, " å‡ºçŽ°å¼‚å¸¸ï¼š" + ex.Message, ex);
//                }
//            }
//        }
//    }
//}
CC/iWareCC_ASRS/ThreadService/02_BZ39¹¤Î»£¨²¹°åºó¹¤Î»£©/Outbound/2¡¢DataProcess_RobotBuffer_IssueOutboundTask.cs
@@ -67,7 +67,7 @@
                            var isValidate = TaskHandler.ValidateIssueOutTaskForRobotBuffer(wmsDB);
                            if (!isValidate)
                            {
                                SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_IssueOutboundTask = $"{rgvLocation.ToString()}-有‘已下发’的任务,不能处理,此次循环结束";
                                SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_IssueOutboundTask = $" å½“前有‘已下发’的出库任务,不能再次处理下发任务,此次循环结束";
                                continue;
                            }
@@ -112,37 +112,63 @@
                            var doTask = taskList.FirstOrDefault();
                            //这里下发 å‡ºåº“任务
                            using (StationServiceClient client = new StationServiceClient())
                            {
                                //首先要清理
                                //var res = await client.OutboundFinishConfirmAsync((int)EDevice.Station, false, rgvLocation);
                            ////这里下发 å‡ºåº“任务
                            //using (StationServiceClient client = new StationServiceClient())
                            //{
                            //    //首先要清理
                            //    //var res = await client.OutboundFinishConfirmAsync((int)EDevice.Station, false, rgvLocation);
                            //    //if (!res.result)
                            //    //{
                            //    //    SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_FinishTaskForOutbound = $"{rgvLocation.ToString()}-下发出库任务 å¤±è´¥,OutboundFinishConfirmAsync è¿”回:{res.resMsg}";
                            //    //    continue;
                            //    //}
                            //    //else
                            //    //{
                            //    //    Log4NetHelper.WriteInfoLog(logType, $"{rgvLocation.ToString()}-下发出库任务 æˆåŠŸ,OutboundFinishConfirmAsync,参数: ç«™ç‚¹{rgvLocation}");
                            //    //}
                            //    var res = await client.WriteOutStoreTaskInfoAsync(false, (int)EDevice.Station, rgvLocation, doTask.PlaceCode, Convert.ToInt32(doTask.TaskNo));
                                //if (!res.result)
                                //{
                                //    SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_FinishTaskForOutbound = $"{rgvLocation.ToString()}-下发出库任务 å¤±è´¥,OutboundFinishConfirmAsync è¿”回:{res.resMsg}";
                            //        SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_IssueOutboundTask = $"{rgvLocation.ToString()}-下发出库任务 å¤±è´¥,WriteOutStoreTaskInfoAsync è¿”回:{res.resMsg}";
                                //    continue;
                                //}
                                //else
                                //{
                                //    Log4NetHelper.WriteInfoLog(logType, $"{rgvLocation.ToString()}-下发出库任务 æˆåŠŸ,OutboundFinishConfirmAsync,参数: ç«™ç‚¹{rgvLocation}");
                            //        Log4NetHelper.WriteInfoLog(logType, $"{rgvLocation.ToString()}-下发出库任务 æˆåŠŸ,WriteOutStoreTaskInfoAsync,参数: ç«™ç‚¹{rgvLocation}");
                                //}
                                var res = await client.WriteOutStoreTaskInfoAsync(false, (int)EDevice.Station, rgvLocation, doTask.PlaceCode, Convert.ToInt32(doTask.TaskNo));
                                if (!res.result)
                                {
                                    SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_IssueOutboundTask = $"{rgvLocation.ToString()}-下发出库任务 å¤±è´¥,WriteOutStoreTaskInfoAsync è¿”回:{res.resMsg}";
                                    continue;
                                }
                                else
                                {
                                    Log4NetHelper.WriteInfoLog(logType, $"{rgvLocation.ToString()}-下发出库任务 æˆåŠŸ,WriteOutStoreTaskInfoAsync,参数: ç«™ç‚¹{rgvLocation}");
                                }
                            }
                            //}
                            doTask.TaskStatus = (int)TaskStatusEnum.已下发;
                            doTask.IssueTime = DateTime.Now;
                            wmsDB.SaveChanges();
                            int changeNum = wmsDB.SaveChanges();
                            if (changeNum > 0)
                            {
                                //必须要给PLC下发成功,解决可能会给PLC重复下发任务的情况
                                var isRight = true;
                                while (isRight)
                                {
                                    //这里下发 å‡ºåº“任务
                                    using (StationServiceClient client = new StationServiceClient())
                                    {
                                        var res = await client.WriteOutStoreTaskInfoAsync(false, (int)EDevice.Station, rgvLocation, doTask.PlaceCode, Convert.ToInt32(doTask.TaskNo));
                                        if (!res.result)
                                        {
                                            SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_IssueOutboundTask = $"{rgvLocation.ToString()}-下发出库任务 å¤±è´¥,WriteOutStoreTaskInfoAsync è¿”回:{res.resMsg}参数: PlaceCode:{doTask.PlaceCode},TaskNo:{doTask.TaskNo}";
                                            Log4NetHelper.WriteErrorLog(logType, $"{rgvLocation.ToString()}-下发出库任务 å¤±è´¥,WriteOutStoreTaskInfoAsync,参数: PlaceCode:{doTask.PlaceCode},TaskNo:{doTask.TaskNo},条码:{doTask.Upi}");
                                            continue;
                                        }
                                        else
                                        {
                                            Log4NetHelper.WriteInfoLog(logType, $"{rgvLocation.ToString()}-下发出库任务 æˆåŠŸ,WriteOutStoreTaskInfoAsync,参数: PlaceCode:{doTask.PlaceCode},TaskNo:{doTask.TaskNo},条码:{doTask.Upi}");
                                            isRight = false;
                                        }
                                    }
                                    Thread.Sleep(1000);
                                }
                            }
                        }
                    }
CC/iWareCC_ASRS/ThreadService/02_BZ39¹¤Î»£¨²¹°åºó¹¤Î»£©/Outbound/3¡¢DataProcess_RobotBuffer_FinishTaskForOutbound - ¸´ÖÆ.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,262 @@
//using Admin.NET.Application;
//using iWareCC.StationService;
//using iWareCommon.Common.Globle;
//using iWareCommon.Utils;
//using iWareModel;
//using iWareSql.DataAccess;
//using iWareSql.WmsDBModel;
//using System;
//using System.Linq;
//using System.Threading;
//using System.Threading.Tasks;
//namespace iWareCC.ThreadService
//{
//    /// <summary>
//    /// æœºå™¨äººç¼“存岛出库任务完成处理
//    /// </summary>
//    public static class DataProcess_RobotBuffer_FinishTaskForOutbound
//    {
//        public static async void Handler()
//        {
//            var alertMsg = "";
//            LogType logType = LogType.DataProcess_RobotBuffer_FinishTaskForOutbound;
//            while (true)
//            {
//                Thread.Sleep(500);//休眠2秒,将休眠写到前面,是为了下面的continue方法执行后不显示错误信息的提示!!!【EditBy shaocx,2022-05-24】
//                SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_FinishTaskForOutbound = string.Empty;
//                try
//                {//SystemValue.isAllowRuning_DataProcess_RobotBuffer_FinishTaskForOutbound &&
//                    if (SystemValue.isStartedModel)
//                    {
//                        var rgvLocation = StationLocationEnum.BZ39.ToString();
//                        if (FormCC.stationView == null)
//                        {
//                            SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_FinishTaskForOutbound = $"{rgvLocation.ToString()}-获取PLC对象为null";
//                            continue;
//                        }
//                        var obj = FormCC.stationView.R_StationForReadCommList.Where(x => x.StationCode == rgvLocation.ToString()).FirstOrDefault();
//                        if (obj.R_OutboundFinish)
//                        {
//                            //var result = obj.R_OutboundNumber;
//                            //if (string.IsNullOrEmpty(result))
//                            //{
//                            //    SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_FinishTaskForOutbound = $"{rgvLocation.ToString()}- å‡ºåº“库位号是空的,此次循环结束";
//                            //    continue;
//                            //}
//                            var result2 = obj.R_Outbound_TaskID;
//                            if (result2 == 0)
//                            {
//                                SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_FinishTaskForOutbound = $"{rgvLocation.ToString()}- å‡ºåº“任务号是空的,此次循环结束";
//                                continue;
//                            }
//                            using (WmsDBModel wmsDB = new WmsDBModel())
//                            {
//                                var task = wmsDB.wms_rbline_task.Where(x =>
//                                 x.TaskNo == obj.R_Outbound_TaskID.ToString()
//                                && (x.RbTaskType == (int)RbTaskTypeEnum.齐包出库任务 || x.RbTaskType == (int)RbTaskTypeEnum.强制出库任务)
//                                ).OrderByDescending(x => x.Id).FirstOrDefault();
//                                if (task == null)
//                                {
//                                    SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_FinishTaskForOutbound = $"{rgvLocation.ToString()},根据 R_OutboundNumber:{obj.R_OutboundNumber}没有找到已下发的任务 ";
//                                    continue;
//                                }
//                                else
//                                {
//                                    if (task.TaskStatus == (int)TaskStatusEnum.已完成)
//                                    {
//                                        using (StationServiceClient client = new StationServiceClient())
//                                        {
//                                            var res = await client.OutboundFinishConfirmAsync((int)EDevice.Station, true, rgvLocation, false);
//                                        }
//                                        continue;
//                                    }
//                                }
//                                var isSuccess = await HandlerData(wmsDB, task, rgvLocation, logType, false);
//                                if (isSuccess == false)
//                                {
//                                    continue;
//                                }
//                                //var upiCode = task.Upi;
//                                //var upiObj = wmsDB.mes_batchOrderUPI_new.Where(x => x.UPI == upiCode).FirstOrDefault();
//                                //if (upiObj == null)
//                                //{
//                                //    SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_FinishTaskForOutbound = $"{rgvLocation.ToString()},根据UPI:{upiCode}没有找到对象 ";
//                                //    continue;
//                                //}
//                                ////更新板件的状态和区域
//                                //if (task.RbTaskType == (int)RbTaskTypeEnum.齐包出库任务)
//                                //{
//                                //    upiObj.UpiStatus = (int)UpiStatusEnum.已齐包;
//                                //    upiObj.AreaCode = (int)AreaCodeEnum.码垛区域;
//                                //}
//                                //else if (task.RbTaskType == (int)RbTaskTypeEnum.强制出库任务)
//                                //{
//                                //    upiObj.UpiStatus = (int)UpiStatusEnum.已下线;
//                                //    upiObj.AreaCode = (int)AreaCodeEnum.下线区域;
//                                //}
//                                ////库存减少
//                                //wms_stock_quan qun = wmsDB.wms_stock_quan.Where(x => x.PlaceCode == task.PlaceCode).FirstOrDefault();
//                                //wmsDB.wms_stock_quan.Remove(qun);
//                                //task.TaskStatus = (int)TaskStatusEnum.已完成;
//                                //task.FinishedTime = DateTime.Now;
//                                //var place = StationHandler.GetPlaceByPlaceCode(task.PlaceCode, wmsDB);
//                                //place.PlaceStatus = (int)PlaceStatusEnum.正常;
//                                ////给PLC推送任务完成确认信号
//                                //using (StationServiceClient client = new StationServiceClient())
//                                //{
//                                //    var res = await client.OutboundFinishConfirmAsync((int)EDevice.Station, true, rgvLocation, true);
//                                //    if (!res.result)
//                                //    {
//                                //        SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_FinishTaskForOutbound = $"{rgvLocation.ToString()}-下发出库任务 å¤±è´¥,OutboundFinishConfirmAsync è¿”回:{res.resMsg}";
//                                //        continue;
//                                //    }
//                                //    else
//                                //    {
//                                //        Log4NetHelper.WriteInfoLog(logType, $"{rgvLocation.ToString()}-下发出库任务 æˆåŠŸ,OutboundFinishConfirmAsync,参数: ç«™ç‚¹{rgvLocation}");
//                                //    }
//                                //}
//                                //WmsRecordUpiProcessHandler.SaveWmsRecordUpiProcess(wmsDB, upiObj, task.PlaceCode, $"出缓存库:{task.PlaceCode}," + task.TaskMsg);
//                                //wmsDB.SaveChanges();
//                            }
//                        }
//                        else
//                        {
//                            using (StationServiceClient client = new StationServiceClient())
//                            {
//                                var res = await client.OutboundFinishConfirmAsync((int)EDevice.Station, false, rgvLocation, false);
//                            }
//                            using (WmsDBModel wmsDB = new WmsDBModel())
//                            {
//                                var task = wmsDB.wms_rbline_task.Where(x =>
//                                 x.IsFlagFinish == true
//                               && (x.RbTaskType == (int)RbTaskTypeEnum.齐包出库任务 || x.RbTaskType == (int)RbTaskTypeEnum.强制出库任务)
//                                && x.TaskStatus == (int)TaskStatusEnum.已下发
//                                ).OrderByDescending(x => x.Id).FirstOrDefault();
//                                if (task == null)
//                                {
//                                    SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_FinishTaskForOutbound = $"{rgvLocation.ToString()},没有找到已下发,并且标记强制完成的任务 ";
//                                    continue;
//                                }
//                                var isSuccess = await HandlerData(wmsDB, task, rgvLocation, logType, true);
//                                if (isSuccess == false)
//                                {
//                                    continue;
//                                }
//                            }
//                        }
//                    }
//                }
//                catch (Exception ex)
//                {
//                    SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_FinishTaskForOutbound += " å‡ºçް异叏:" + ex.Message + SysGloble.SPLIT_STR;
//                    Log4NetHelper.WriteErrorLog(logType, " å‡ºçŽ°å¼‚å¸¸ï¼š" + ex.Message, ex);
//                }
//            }
//        }
//        public static async Task<bool> HandlerData(WmsDBModel wmsDB, wms_rbline_task task, string rgvLocation, iWareCommon.Utils.LogType logType, bool isFlagFinish)
//        {
//            var upiCode = task.Upi;
//            var upiObj = wmsDB.mes_batchOrderUPI_new.Where(x => x.UPI == upiCode).FirstOrDefault();
//            if (upiObj == null)
//            {
//                SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_FinishTaskForOutbound = $"{rgvLocation.ToString()},根据UPI:{upiCode}没有找到对象 ";
//                return false;
//            }
//            //更新板件的状态和区域
//            if (task.RbTaskType == (int)RbTaskTypeEnum.齐包出库任务)
//            {
//                upiObj.UpiStatus = (int)UpiStatusEnum.已齐包;
//                upiObj.AreaCode = (int)AreaCodeEnum.码垛区域;
//            }
//            else if (task.RbTaskType == (int)RbTaskTypeEnum.强制出库任务)
//            {
//                upiObj.UpiStatus = (int)UpiStatusEnum.已下线;
//                upiObj.AreaCode = (int)AreaCodeEnum.下线区域;
//            }
//            //库存减少
//            wms_stock_quan qun = wmsDB.wms_stock_quan.Where(x => x.PlaceCode == task.PlaceCode).FirstOrDefault();
//            wmsDB.wms_stock_quan.Remove(qun);
//            task.TaskStatus = (int)TaskStatusEnum.已完成;
//            task.FinishedTime = DateTime.Now;
//            var place = StationHandler.GetPlaceByPlaceCode(task.PlaceCode, wmsDB);
//            place.PlaceStatus = (int)PlaceStatusEnum.正常;
//            //if (isFlagFinish == false)
//            //{
//            //    //给PLC推送任务完成确认信号
//            //    using (StationServiceClient client = new StationServiceClient())
//            //    {
//            //        var res = await client.OutboundFinishConfirmAsync((int)EDevice.Station, true, rgvLocation, true);
//            //        if (!res.result)
//            //        {
//            //            SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_FinishTaskForOutbound = $"{rgvLocation.ToString()}-下发出库任务 å¤±è´¥,OutboundFinishConfirmAsync è¿”回:{res.resMsg}";
//            //            return false;
//            //        }
//            //        else
//            //        {
//            //            Log4NetHelper.WriteInfoLog(logType, $"{rgvLocation.ToString()}-下发出库任务 æˆåŠŸ,OutboundFinishConfirmAsync,参数: ç«™ç‚¹{rgvLocation}");
//            //        }
//            //    }
//            //}
//            var flag = isFlagFinish ? "人工强制完成" : "(自动完成)";
//            WmsRecordUpiProcessHandler.SaveWmsRecordUpiProcess(wmsDB, upiObj, task.PlaceCode, $"出缓存库:{task.PlaceCode}(" + flag + ")," + task.TaskMsg);
//            int changeNum = wmsDB.SaveChanges();
//            if (changeNum > 0)
//            {
//                //必须要给PLC下发成功,解决可能会给PLC重复下发任务的情况
//                var isRight = true;
//                if (isFlagFinish == false)
//                {
//                    while (isRight)
//                    {
//                        var obj = FormCC.stationView.R_StationForReadCommList.Where(x => x.StationCode == rgvLocation.ToString()).FirstOrDefault();
//                        isRight = obj.R_OutboundFinish;
//                        //给PLC推送任务完成确认信号
//                        using (StationServiceClient client = new StationServiceClient())
//                        {
//                            var res = await client.OutboundFinishConfirmAsync((int)EDevice.Station, true, rgvLocation, true);
//                            if (!res.result)
//                            {
//                                SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_FinishTaskForOutbound = $"{rgvLocation.ToString()}-下发入库任务 å¤±è´¥,InboundFinishConfirmAsync è¿”回:{res.resMsg}";
//                                Log4NetHelper.WriteErrorLog(logType, $"{rgvLocation.ToString()}-完成出库任务【true】 å¤±è´¥,OutboundFinishConfirmAsync,返回:{res.resMsg},参数:TaskNo:{task.TaskNo}, PlaceCode:{task.PlaceCode},条码:{task.Upi}");
//                            }
//                            else
//                            {
//                                Log4NetHelper.WriteInfoLog(logType, $"{rgvLocation.ToString()}-完成出库任务【true】 æˆåŠŸ,OutboundFinishConfirmAsync,,参数:TaskNo:{task.TaskNo}, PlaceCode:{task.PlaceCode},条码:{task.Upi}");
//                                //isRight = false;
//                            }
//                        }
//                        Thread.Sleep(1000);
//                    }
//                }
//            }
//            return true;
//        }
//    }
//}
CC/iWareCC_ASRS/ThreadService/02_BZ39¹¤Î»£¨²¹°åºó¹¤Î»£©/Outbound/3¡¢DataProcess_RobotBuffer_FinishTaskForOutbound.cs
@@ -58,6 +58,9 @@
                            {
                                var task = wmsDB.wms_rbline_task.Where(x =>
                                 x.TaskNo == obj.R_Outbound_TaskID.ToString()
                                //增加这两个限制条件 ã€Editby shaocx,2025-03-27】
                                && x.TaskStatus == (int)TaskStatusEnum.已下发
                                && (x.IsFlagFinish == false)
                                && (x.RbTaskType == (int)RbTaskTypeEnum.齐包出库任务 || x.RbTaskType == (int)RbTaskTypeEnum.强制出库任务)
                                ).OrderByDescending(x => x.Id).FirstOrDefault();
                                if (task == null)
CC/iWareCC_ASRS/iWareCC.csproj
@@ -171,6 +171,8 @@
    <Compile Include="ThreadService\01_BZ01工位(清灰,洗板后工位)\DataProcess_BZ01.cs" />
    <Compile Include="ThreadService\02_BZ39工位(补板后工位)\DataProcess_RobotBuffer_ModeChange.cs" />
    <Compile Include="ThreadService\02_BZ39工位(补板后工位)\Inbound\2、DataProcess_BZ39_IssueInboundTask.cs" />
    <Compile Include="ThreadService\02_BZ39工位(补板后工位)\Outbound\2、DataProcess_RobotBuffer_IssueOutboundTask - å¤åˆ¶.cs" />
    <Compile Include="ThreadService\02_BZ39工位(补板后工位)\Outbound\3、DataProcess_RobotBuffer_FinishTaskForOutbound - å¤åˆ¶.cs" />
    <Compile Include="ThreadService\02_BZ39工位(补板后工位)\Outbound\5、DataProcess_RobotBuffer_PesonOutbound.cs" />
    <Compile Include="ThreadService\02_BZ39工位(补板后工位)\Outbound\4、DataProcess_RobotBuffer_ForceOutbound.cs" />
    <Compile Include="ThreadService\02_BZ39工位(补板后工位)\Outbound\CC_DataProcess_RobotBuffer_ForceOutbound.cs" />
CC/iWareCommon/BusinessHelper/BusinessHelper.cs
@@ -136,7 +136,7 @@
        {
            int iSeed = 9999;
            //从101-9999,为什么要从101开始,因为1-100作为手动任务下发。【EditBy shaocx,2022-05-10】
            return new Random(Guid.NewGuid().GetHashCode()).Next(101, iSeed).ToString();
            return new Random(Guid.NewGuid().GetHashCode()).Next(100, iSeed).ToString();
        }
    }
}