schangxiang@126.com
2024-11-21 60735779c303c2dd10feea45d7fd761103b225e0
CC/iWareCC_ASRS/WmsTask/AutoUpdateEngineInfoTask.cs
@@ -35,17 +35,17 @@
            while (true)
            {
                Thread.Sleep(2000);//休眠2秒,将休眠写到前面,是为了下面的continue方法执行后不显示错误信息的提示!!!【EditBy shaocx,2022-05-24】
                SystemWarningMsg._lbl_alert_AutoUpdateEngineInfoTask = string.Empty;
                SystemWarningMsg._lbl_alert_DataProcess_269 = string.Empty;
                try
                {
                    if (SystemValue.isAllowRuning_AutoUpdateEngineInfoTask && SystemValue.isStartedModel)
                    if (SystemValue.isAllowRuning_DataProcess_269 && SystemValue.isStartedModel)
                    {
                        using (DbModel context = new DbModel())
                        {
                            var needIssueTask = context.Task_Main.Where(x => x.IsUpdateMatFinish == false).OrderBy(x => x.Id).FirstOrDefault();
                            if (needIssueTask == null)
                            {
                                SystemWarningMsg._lbl_alert_AutoUpdateEngineInfoTask = $"没有要处理[重新获取发动机信息,并赋值]任务,此次循环结束";
                                SystemWarningMsg._lbl_alert_DataProcess_269 = $"没有要处理[重新获取发动机信息,并赋值]任务,此次循环结束";
                                continue;
                            }
                            if (needIssueTask.UpdateMatFinishNum != null)
@@ -58,8 +58,8 @@
                            //符合条件,即将进行重新获取发动机信息,并赋值
                            var _scan_salverCode = needIssueTask.SalverCode;
                            alertMsg = $"发动机码为{needIssueTask.SerialNumber},托盘码为{_scan_salverCode},符合条件,即将进行重新获取发动机信息,并赋值";
                            SystemWarningMsg._lbl_alert_AutoUpdateEngineInfoTask = alertMsg;
                            Log4NetHelper.WriteInfoLog(LogType.AutoUpdateEngineInfoTask, alertMsg);
                            SystemWarningMsg._lbl_alert_DataProcess_269 = alertMsg;
                            Log4NetHelper.WriteInfoLog(LogType.DataProcess_269, alertMsg);
                            try
                            {
@@ -68,8 +68,8 @@
                                if (getEngineInfoResult.code != 200)
                                {
                                    alertMsg = ($"查询MES发动机信息失败,参数{material.CargoNo},MES返回code:" + getEngineInfoResult.code + ",信息:" + getEngineInfoResult.message);
                                    SystemWarningMsg._lbl_alert_AutoUpdateEngineInfoTask = alertMsg;
                                    Log4NetHelper.WriteInfoLog(LogType.AutoUpdateEngineInfoTask, alertMsg);
                                    SystemWarningMsg._lbl_alert_DataProcess_269 = alertMsg;
                                    Log4NetHelper.WriteInfoLog(LogType.DataProcess_269, alertMsg);
                                    needIssueTask.UpdateMatFinishNum = needIssueTask.UpdateMatFinishNum == null ? 1 : (Convert.ToInt32(needIssueTask.UpdateMatFinishNum) + 1);
                                    UpdateMat(context, needIssueTask);
@@ -82,8 +82,8 @@
                                        + ",信息:" + getEngineInfoResult.message + ",data:" + JsonConvert.SerializeObject(getEngineInfoResult.data)
                                        ); ; ;
                                    SystemWarningMsg._lbl_alert_AutoUpdateEngineInfoTask = alertMsg;
                                    Log4NetHelper.WriteInfoLog(LogType.AutoUpdateEngineInfoTask, alertMsg);
                                    SystemWarningMsg._lbl_alert_DataProcess_269 = alertMsg;
                                    Log4NetHelper.WriteInfoLog(LogType.DataProcess_269, alertMsg);
                                    needIssueTask.UpdateMatFinishNum = needIssueTask.UpdateMatFinishNum == null ? 1 : (Convert.ToInt32(needIssueTask.UpdateMatFinishNum) + 1);
                                    UpdateMat(context, needIssueTask);
@@ -101,8 +101,8 @@
                                if (ret.success)
                                {//处理成功了,WMS API会把这个状态更新的IsUpdateMatFinish
                                    alertMsg = $"发动机码为{needIssueTask.SerialNumber},托盘码为{_scan_salverCode},请求参数:{JsonConvert.SerializeObject(param)},重新获取发动机信息,并赋值请求WMSAPI成功!";
                                    SystemWarningMsg._lbl_alert_AutoUpdateEngineInfoTask = alertMsg;
                                    Log4NetHelper.WriteInfoLog(LogType.AutoUpdateEngineInfoTask, alertMsg);
                                    SystemWarningMsg._lbl_alert_DataProcess_269 = alertMsg;
                                    Log4NetHelper.WriteInfoLog(LogType.DataProcess_269, alertMsg);
                                    needIssueTask.IsUpdateMatFinish = true;
                                    needIssueTask.UpdateMatFinishTime = DateTime.Now;
@@ -111,9 +111,9 @@
                                else
                                {//失败
                                    alertMsg = $"发动机码为{needIssueTask.SerialNumber},托盘码为{_scan_salverCode},请求参数:{JsonConvert.SerializeObject(param)},重新获取发动机信息,并赋值请求WMSAPI失败:WMS返回消息为->{ret.msg}";
                                    SystemWarningMsg._lbl_alert_AutoUpdateEngineInfoTask = alertMsg;
                                    Log4NetHelper.WriteInfoLog(LogType.AutoUpdateEngineInfoTask, alertMsg);
                                    Log4NetHelper.WriteErrorLog(LogType.AutoUpdateEngineInfoTask, alertMsg, null);
                                    SystemWarningMsg._lbl_alert_DataProcess_269 = alertMsg;
                                    Log4NetHelper.WriteInfoLog(LogType.DataProcess_269, alertMsg);
                                    Log4NetHelper.WriteErrorLog(LogType.DataProcess_269, alertMsg, null);
                                    needIssueTask.UpdateMatFinishNum = needIssueTask.UpdateMatFinishNum == null ? 1 : (Convert.ToInt32(needIssueTask.UpdateMatFinishNum) + 1);
                                    UpdateMat(context, needIssueTask);
@@ -122,9 +122,9 @@
                            catch (Exception ex)
                            {
                                alertMsg = $"发动机码为{needIssueTask.SerialNumber},托盘码为{_scan_salverCode},重新获取发动机信息,并赋值请求WMSAPI失败:出现异常->{ex.Message}";
                                SystemWarningMsg._lbl_alert_AutoUpdateEngineInfoTask = alertMsg;
                                Log4NetHelper.WriteInfoLog(LogType.AutoUpdateEngineInfoTask, alertMsg);
                                Log4NetHelper.WriteErrorLog(LogType.AutoUpdateEngineInfoTask, alertMsg, ex);
                                SystemWarningMsg._lbl_alert_DataProcess_269 = alertMsg;
                                Log4NetHelper.WriteInfoLog(LogType.DataProcess_269, alertMsg);
                                Log4NetHelper.WriteErrorLog(LogType.DataProcess_269, alertMsg, ex);
                                needIssueTask.UpdateMatFinishNum = needIssueTask.UpdateMatFinishNum == null ? 1 : (Convert.ToInt32(needIssueTask.UpdateMatFinishNum) + 1);
                                UpdateMat(context, needIssueTask);
@@ -135,8 +135,8 @@
                }
                catch (Exception ex)
                {
                    SystemWarningMsg._lbl_alert_AutoUpdateEngineInfoTask += "重新获取发动机信息,并赋值 出现异常:" + ex.Message + SysGloble.SPLIT_STR;
                    Log4NetHelper.WriteErrorLog(LogType.AutoUpdateEngineInfoTask, "AutoUpdateEngineInfoTask 出现异常:" + ex.Message, ex);
                    SystemWarningMsg._lbl_alert_DataProcess_269 += "重新获取发动机信息,并赋值 出现异常:" + ex.Message + SysGloble.SPLIT_STR;
                    Log4NetHelper.WriteErrorLog(LogType.DataProcess_269, "AutoUpdateEngineInfoTask 出现异常:" + ex.Message, ex);
                }
            }