222
schangxiang@126.com
2024-12-05 2225959bc5c3588407e90a6285ab2c32b3481d90
CC/iWareCC_ASRS/FormCC.cs
@@ -1,4 +1,5 @@
using iWareCC.Common.Helper;
using Admin.NET.Application;
using iWareCC.Common.Helper;
using iWareCC.DeviceThreadFactory;
using iWareCC.Forms;
using iWareCC.RgvService;
@@ -6,6 +7,7 @@
using iWareCC.StationService;
using iWareCC.ThreadService;
using iWareCC.ThreadService._03_BZ12_机器人码包工位_;
using iWareCC.ThreadService._04_BZ21_搬运整垛机器人_;
using iWareCC.WCF;
using iWareCommon.Common.Globle;
using iWareCommon.Utils;
@@ -27,6 +29,7 @@
using System.Windows.Forms;
using XiGang.Core.Model;
using XiGang.Core.Model.ViewModels;
namespace iWareCC
{
@@ -200,13 +203,14 @@
            //堆垛机UI赋值
            SetSrmUI();
            tskSetSrmLable = new Thread(SrmRead_Label);
            tskSetSrmLable.Start();
            #endregion
            #region 设置显示UI
            tskSetSrmLable = new Thread(SrmRead_Label);
            tskSetSrmLable.Start();
            tskSetRgvLable = new Thread(SetRgvLable);
            tskSetRgvLable.Start();
            #endregion
            #region 服务线程启动
@@ -229,6 +233,7 @@
            new Thread(DataProcess_RobotBuffer_FinishTaskForOutbound.Handler).Start();
            new Thread(DataProcess_RobotBuffer_ForceOutbound.Handler).Start();
            new Thread(DataProcess_RobotBuffer_FinishTask.Handler).Start();
@@ -239,14 +244,23 @@
            new Thread(DataProcess_BZ39.Handler).Start();
            new Thread(DataProcess_BZ39_IssueInboundTask.Handler).Start();
            new Thread(DataProcess_BZ12.Hander).Start();
            new Thread(DataProcess_BZ12_IssueTask.Handler).Start();
            new Thread(DataProcess_BZ12_FinishTask.Handler).Start();
            new Thread(DataProcess_BZ21.Hander).Start();
            new Thread(DataProcess_BZ21_IssueTask.Handler).Start();
            new Thread(DataProcess_BZ21_FinishTask.Handler).Start();
            new Thread(DeleteData).Start();
            //new Thread(LineInSacnResult.HandlerLineInSacnResult).Start();
            new Thread(PushPackageCodeToMes.Handler).Start();
            new Thread(PushPaperCutToMes.Handler).Start();
            new Thread(DataProcess_ValidateQiTao.Handler).Start();
            //*/
            #endregion
@@ -322,10 +336,6 @@
            //btn_Start_Click(null, null);
        }
        #region 堆垛机线程和UI处理
        /// <summary>
        /// 设置1/2号堆垛机的前端显示
        /// </summary>
@@ -339,33 +349,35 @@
                    var showNowTime = "(" + DateTimeHelper.ConvertToStringForOnlyShowTime(DateTime.Now) + ")";
                    //设置堆垛机任务下发和任务确认线程消息
                    this.lbl_Alter_Srm1Release.Text = showNowTime + SystemWarningMsg._lbl_Alert_Srm1Release;
                    this.lbl_Alert_Srm2Release.Text = showNowTime + SystemWarningMsg._lbl_Alert_Srm2Release;
                    this.lbl_Alert_Srm3Release.Text = showNowTime + SystemWarningMsg._lbl_Alert_Srm3Release;
                    this.lbl_Alert_DataProcess_BZ39_IssueInboundTask.Text = showNowTime + SystemWarningMsg._lbl_Alert_DataProcess_BZ39_IssueInboundTask;
                    this.lbl_Alert_DataProcess_RobotBuffer_ForceOutbound.Text = showNowTime + SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_ForceOutbound;
                    this.lbl_Alert_DataProcess_BZ12.Text = showNowTime + SystemWarningMsg._lbl_alert_DataProcess_BZ12;
                    this.lbl_Alert_Srm4Release.Text = showNowTime + SystemWarningMsg._lbl_Alert_Srm4Release;
                    //设置堆垛机任务下发和任务完成确认线程消息
                    this.lbl_Alter_Srm1ReleaseFinish.Text = showNowTime + SystemWarningMsg._lbl_Alert_Srm1ReleaseFinish;
                    this.lbl_Alert_Srm2ReleaseFinish.Text = showNowTime + SystemWarningMsg._lbl_Alert_Srm2ReleaseFinish;
                    this.lbl_Alert_Srm3ReleaseFinish.Text = showNowTime + SystemWarningMsg._lbl_Alert_Srm3ReleaseFinish;
                    this.lbl_Alert_Srm4ReleaseFinish.Text = showNowTime + SystemWarningMsg._lbl_Alert_Srm4ReleaseFinish;
                    this.lbl_Alert_DataProcess_BZ12_FinishTask.Text = showNowTime + SystemWarningMsg._lbl_Alert_DataProcess_BZ12_FinishTask;
                    this.lbl_Alert_DataProcess_BZ21_FinishTask.Text = showNowTime + SystemWarningMsg._lbl_Alert_DataProcess_BZ21_FinishTask;
                    this.lbl_Alert_RgvRelease.Text = showNowTime + SystemWarningMsg._lbl_Alert_RgvRelease;
                    this.lbl_Alert_RgvReleaseFinish.Text = showNowTime + SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_ModeChange;
                    this.lbl_Alert_RgvReleaseFinish_BuChang.Text = showNowTime + SystemWarningMsg._lbl_Alert_RgvReleaseFinish_BuChang;
                    this.lbl_Alert_HandlerIssuingTask.Text = showNowTime + SystemWarningMsg._lbl_Alert_HandlerIssuingTask;
                    this.lbl_Alert_PushPaperCutToMes.Text = showNowTime + SystemWarningMsg._lbl_Alert_PushPaperCutToMes;
                    this.lbl_Alert_PushPackageCodeToMes.Text = showNowTime + SystemWarningMsg._lbl_Alert_PushPackageCodeToMes;
                    this.lbl_Alert_DataProcess_BZ12_IssueTask.Text = showNowTime + SystemWarningMsg._lbl_Alert_DataProcess_BZ12_IssueTask;
                    this.lbl_Alert_DataProcess_RobotBuffer_FinishTask.Text = showNowTime + SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_FinishTask;
                    this.lbl_MainTaskDecompose.Text = showNowTime + SystemWarningMsg._lbl_Alert_MainTaskDecompose;
                    this.lbl_DataProcess_BZ21_IssueTask.Text = showNowTime + SystemWarningMsg._lbl_Alert_DataProcess_BZ21_IssueTask;
                    this.lbl_DataProcess_RobotBuffer_ModeChange.Text = showNowTime + SystemWarningMsg._lbl_Alert_MainTaskDecompose_ZPRK;
                    this.lbl_DataProcess_RobotBuffer_ModeChange.Text = showNowTime + SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_ModeChange;
                    this.lbl_Alert_DataProcess_RobotBuffer_FinishTaskForOutbound.Text = showNowTime + SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_FinishTaskForOutbound;
                    this.lbl_Alert_DeleteData.Text = showNowTime + SystemWarningMsg._lbl_Alert_DeleteData;
                    this.lbl_Alert_DataProcess_RobotBuffer_AutoQiTaoOutbound.Text = showNowTime + SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_AutoQiTaoOutbound;
                    this.lbl_Alter_DataProcess_BZ21.Text = showNowTime + SystemWarningMsg._lbl_Alert_DataProcess_BZ21;
                    this.lbl_alert_DataProcess_BZ39.Text = showNowTime + SystemWarningMsg._lbl_alert_DataProcess_BZ39;
@@ -376,19 +388,19 @@
                    this.lbl_Alert_DataProcess_RobotBuffer_IssueOutboundTask.Text = showNowTime + SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_IssueOutboundTask;
                    this.lbl_Alter_OutTaskRetryToMes.Text = showNowTime + SystemWarningMsg._lbl_Alert_OutTaskRetryToMes;
                    //this.lblSrmPosX1.Text="111";
                }
                catch (Exception ex)
                {
                    Log4NetHelper.WriteErrorLog(iWareCommon.Utils.LogType.SrmTheadService, "方法SrmRead_Label出现异常:" + ex.Message, ex);
                    continue;
                }
            }
        }
        #region 堆垛机线程和UI处理
        /// <summary>
        /// 获取堆垛机的实时信息
@@ -413,18 +425,18 @@
                            {
                                for (int i = 0; i < waringList.Count; i++)
                                {
                                    DeviceWarningHandler.SaveWarning(device, iWareCommon.Utils.LogType.SrmTheadService,
                                    DeviceWarningHandler.SaveWarning(device, iWareCommon.Utils.LogType.DataProcess_BZ39_IssueInboundTask,
                                        waringList[i].Code, waringList[i].Address, waringList[i].Context);//新增报警
                                    warningAddressList.Add(waringList[i].Address);
                                }
                            }
                        }
                        DeviceWarningHandler.AutoCloseWarning(device, iWareCommon.Utils.LogType.SrmTheadService, warningAddressList);//自动关闭报警
                        DeviceWarningHandler.AutoCloseWarning(device, iWareCommon.Utils.LogType.DataProcess_BZ39_IssueInboundTask, warningAddressList);//自动关闭报警
                    }
                }
                catch (Exception ex)
                {
                    Log4NetHelper.WriteErrorLog(iWareCommon.Utils.LogType.SrmTheadService, "获取" + device.ToString() + "的实时信息异常:" + ex.Message, ex);
                    Log4NetHelper.WriteErrorLog(iWareCommon.Utils.LogType.DataProcess_BZ39_IssueInboundTask, "获取" + device.ToString() + "的实时信息异常:" + ex.Message, ex);
                    continue;
                }
            };
@@ -465,7 +477,7 @@
            };
            realTimeList.Add(obj);
            DeviceSrmRealTimeHandler.Update(realTimeList, iWareCommon.Utils.LogType.SrmTheadService);
            DeviceSrmRealTimeHandler.Update(realTimeList, iWareCommon.Utils.LogType.DataProcess_BZ39_IssueInboundTask);
        }
@@ -1177,7 +1189,7 @@
                using (var opcClinet = new SrmService.SrmServiceClient())
                {
                    var result = opcClinet.SendEStop((int)_EDevice);
                    Log4NetHelper.WriteInfoLog(iWareCommon.Utils.LogType.SrmTheadService, "字符串:" + JsonConvert.SerializeObject(result));
                    Log4NetHelper.WriteInfoLog(iWareCommon.Utils.LogType.DataProcess_BZ39_IssueInboundTask, "字符串:" + JsonConvert.SerializeObject(result));
                    if (result.result)
                    {
                        WZ.Useful.Commons.MessageUtil.ShowTips("发送" + _EDevice.ToString() + "急停指令成功");
@@ -1480,8 +1492,8 @@
                this.lbl_ModelText.Text = title + currentCheckModelText;
                SetAllCheckBoxChecked(true);
                //将特殊的取消
                this.ckHandlerIssuingTask.Checked = false;
                this.ckMainTaskDecompose.Checked = false;
                this.ck_DataProcess_BZ12_IssueTask.Checked = false;
                this.ck_DataProcess_BZ21_IssueTask.Checked = false;
                this.gBoxThread.Enabled = true;
            }
@@ -1517,16 +1529,16 @@
        private void CommonCheckedChanged(object sender, EventArgs e)
        {
            //堆垛机1任务下发
            DoCommonCheckedChanged(ref SystemValue.isAllowRuning_SrmTaskThreadService_1, ckBSrm1Release);
            DoCommonCheckedChanged(ref SystemValue.isAllowRuning_SrmTaskThreadService_1, ckB_DataProcess_BZ39_IssueInboundTask);
            DoCommonCheckedChanged(ref SystemValue.isAllowRuning_SrmTaskThreadService_1_Finish, ckBSrm1FinishedHandle);
            //堆垛机2任务下发
            DoCommonCheckedChanged(ref SystemValue.isAllowRuning_SrmTaskThreadService_2, ckBSrm2Release);
            DoCommonCheckedChanged(ref SystemValue.isAllowRuning_SrmTaskThreadService_2_Finish, ckBSrm2FinishedHandle);
            DoCommonCheckedChanged(ref SystemValue.isAllowRuning_SrmTaskThreadService_2, ckBDataProcess_RobotBuffer_ForceOutbound);
            DoCommonCheckedChanged(ref SystemValue.isAllowRuning_SrmTaskThreadService_2_Finish, ckBDataProcess_BZ12_FinishTask);
            //堆垛机3任务下发
            DoCommonCheckedChanged(ref SystemValue.isAllowRuning_SrmTaskThreadService_3, ckBSrm3Release);
            DoCommonCheckedChanged(ref SystemValue.isAllowRuning_SrmTaskThreadService_3_Finish, ckBSrm3FinishedHandle);
            DoCommonCheckedChanged(ref SystemValue.isAllowRuning_SrmTaskThreadService_3, ckBDataProcess_BZ12);
            DoCommonCheckedChanged(ref SystemValue.isAllowRuning_SrmTaskThreadService_3_Finish, ckBDataProcess_BZ21_FinishTask);
            //堆垛机4任务下发
            DoCommonCheckedChanged(ref SystemValue.isAllowRuning_SrmTaskThreadService_4, ckBSrm4Release);
@@ -1535,16 +1547,18 @@
            //RGV任务下发
            DoCommonCheckedChanged(ref SystemValue.isAllowRuning_RgvThreadService, ckBRgvRelease);
            DoCommonCheckedChanged(ref SystemValue.isAllowRuning_RgvThreadService_Finish, ckBRgvFinishedHandle);
            DoCommonCheckedChanged(ref SystemValue.isAllowRuning_RgvThreadService_Finish_BuChang, ckBRgvFinishedHandle_BuChang);
            DoCommonCheckedChanged(ref SystemValue.isAllowRuning_RgvThreadService_Finish, ckB_PushPaperCutToMes);
            DoCommonCheckedChanged(ref SystemValue.isAllowRuning_RgvThreadService_Finish_BuChang, ck_PushPackageCodeToMes);
            DoCommonCheckedChanged(ref SystemValue.isAllowRuning_HandlerIssuingTask, ckHandlerIssuingTask);
            DoCommonCheckedChanged(ref SystemValue.isAllowRuning_HandlerIssuingTask, ck_DataProcess_BZ12_IssueTask);
            DoCommonCheckedChanged(ref SystemValue.isAllowRuning_DataProcess_RobotBuffer_FinishTask, ck_DataProcess_RobotBuffer_FinishTask);
            DoCommonCheckedChanged(ref SystemValue.isAllowRuning_MainTaskDecompose, ckMainTaskDecompose);
            DoCommonCheckedChanged(ref SystemValue.isAllowRuning_MainTaskDecompose, ck_DataProcess_BZ21_IssueTask);
            DoCommonCheckedChanged(ref SystemValue.isAllowRuning_DataProcess_RobotBuffer_ModeChange, ck_DataProcess_RobotBuffer_ModeChange);
            DoCommonCheckedChanged(ref SystemValue.isAllowRuning_DataProcess_ValidateQiTao, ck_DataProcess_ValidateQiTao);
            DoCommonCheckedChanged(ref SystemValue.isAllowRuning_DataProcess_RobotBuffer_FinishTaskForOutbound, checkBox_DataProcess_RobotBuffer_FinishTaskForOutbound);
@@ -1561,7 +1575,7 @@
            DoCommonCheckedChanged(ref SystemValue.isAllowRuning_DataProcess_RobotBuffer_IssueOutboundTask, ck_DataProcess_RobotBuffer_IssueOutboundTask);
            DoCommonCheckedChanged(ref SystemValue.isAllowRuning_OutTaskRetryToMes, checkBox_OutTaskRetryToMes);
            DoCommonCheckedChanged(ref SystemValue.isAllowRuning_OutTaskRetryToMes, checkBox_DataProcess_BZ21);
        }
        private void DoCommonCheckedChanged(ref bool isAllowValue, CheckBox cb)
@@ -3550,7 +3564,40 @@
            var packageCode = this.tb_PackageCode.Text.Trim();
            var alertMsg = "";
            DataProcess_RobotBuffer_ForceOutbound.Handler(packageCode, ref alertMsg);
            CC_DataProcess_RobotBuffer_ForceOutbound.Handler(packageCode, ref alertMsg);
            if (!string.IsNullOrEmpty(alertMsg))
            {
                MessageBox.Show("错误:" + alertMsg);
            }
            else
            {
                MessageBox.Show("已处理");
            }
        }
        private void button25_Click(object sender, EventArgs e)
        {
            var packageCode = this.tb_PackageCode.Text.Trim();
            var alertMsg = "";
            using (WmsDBModel db = new WmsDBModel())
            {
                var upiList = db.mes_batchOrderUPI_new.Where(x => x.PackageCode == packageCode).ToList();
                foreach (var item in upiList)
                {
                    item.AreaCode = (int)AreaCodeEnum.无区域;
                    item.UpiStatus = (int)UpiStatusEnum.初始;
                }
                var pList = db.mes_package_gather.Where(x => x.PackageCode == packageCode).ToList();
                foreach (var item in pList)
                {
                    item.AreaCode = (int)AreaCodeEnum.无区域;
                    item.UpiStatus = (int)UpiStatusEnum.初始;
                }
                db.SaveChanges();
            }
            if (!string.IsNullOrEmpty(alertMsg))
            {
                MessageBox.Show("错误:" + alertMsg);