新增异常消息处理及WMS API调用逻辑优化
在 `MOMErrorMessage.cs` 中添加了 `MOMErrorMessage` 类,包含多个属性并使用 `SqlSugar` 进行数据库映射。
在 `AgingInOrOutInputService.cs` 和 `CellStateService.cs` 中移除不必要的 `using` 语句,更新 WMS API 调用逻辑,增加响应处理和异常消息记录。
在 `MoMErrorMsg.cs` 中实现了异常消息的添加和删除功能。
在 `ProcessApplyService.cs` 中优化了 WMS API 调用逻辑,保留了日志记录功能。
¶Ô±ÈÐÂÎļþ |
| | |
| | | using SqlSugar; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | |
| | | namespace WIDESEA_DTO.MOM |
| | | { |
| | | public class MOMErrorMessage |
| | | { |
| | | /// <summary> |
| | | /// å¤ æ³¨:ä¸»é® |
| | | /// é»è®¤å¼: |
| | | ///</summary> |
| | | [SugarColumn(ColumnName = "ID", IsPrimaryKey = true, IsIdentity = true)] |
| | | public int ID { get; set; } |
| | | |
| | | /// <summary> |
| | | /// å¤ æ³¨:ä»»å¡å· |
| | | /// é»è®¤å¼: |
| | | ///</summary> |
| | | [SugarColumn(ColumnName = "TaskNum")] |
| | | public int? TaskNum { get; set; } |
| | | |
| | | /// <summary> |
| | | /// å¤ æ³¨:æçå· |
| | | /// é»è®¤å¼: |
| | | ///</summary> |
| | | [SugarColumn(ColumnName = "PalletCode")] |
| | | public string? PalletCode { get; set; } |
| | | |
| | | /// <summary> |
| | | /// å¤ æ³¨:å¼å¸¸æ¶æ¯ |
| | | /// é»è®¤å¼: |
| | | ///</summary> |
| | | [SugarColumn(ColumnName = "ErrorMessage")] |
| | | public string? ErrorMessage { get; set; } |
| | | |
| | | /// <summary> |
| | | /// å¤ æ³¨:å¼å¸¸æ¶æ¯ |
| | | /// é»è®¤å¼: |
| | | ///</summary> |
| | | [SugarColumn(ColumnName = "APIåç§°")] |
| | | public string? APIName { get; set; } |
| | | |
| | | /// <summary> |
| | | /// å¤ æ³¨:å建æ¶é´ |
| | | /// é»è®¤å¼: |
| | | ///</summary> |
| | | [SugarColumn(ColumnName = "CreateTime")] |
| | | public DateTime? CreateTime { get; set; } |
| | | } |
| | | } |
| | |
| | | using LogLibrary.Log; |
| | | using AngleSharp.Io; |
| | | using LogLibrary.Log; |
| | | using Masuit.Tools; |
| | | using Newtonsoft.Json; |
| | | using WIDESEA_Common; |
| | | using WIDESEA_Core; |
| | | using WIDESEA_Core.Const; |
| | | using WIDESEA_DTO; |
| | | using WIDESEA_DTO.MOM; |
| | | using WIDESEA_IServices; |
| | | using WIDESEA_IStorageBasicService; |
| | | using WIDESEA_IStoragIntegrationServices; |
| | | |
| | | namespace WIDESEA_StoragIntegrationServices; |
| | |
| | | var wmsIpAddress = wmsBase + ipAddress; |
| | | |
| | | var result = HttpsClient.PostAsync(wmsIpAddress, inputJson).Result; |
| | | //var x = await HttpsClient.PostAsync("http://c24-cellmi3:12020/api/MachineIntegration/AgingInput", inputJson); |
| | | content.OK(data: result); |
| | | |
| | | var respone = JsonConvert.DeserializeObject<ResponeAgingInputDto>(result.ToString()); |
| | | if (!respone.Success) |
| | | { |
| | | MoMErrorMsg.AddMoMErrorMsg(0, input.TrayBarcode, respone.MOMMessage, SysConfigConst.AgingInput); |
| | | } |
| | | else |
| | | { |
| | | MoMErrorMsg.DeleteMoMErrorMsg(0, input.TrayBarcode); |
| | | } |
| | | |
| | | LogFactory.GetLog("éç½®éåå
¥åºï¼æ´æçï¼").Info(true, $"\r\r--------------------------------------"); |
| | | LogFactory.GetLog("éç½®éåå
¥åºï¼æ´æçï¼").Info(true, input.TrayBarcode); |
| | |
| | | } |
| | | catch (Exception err) |
| | | { |
| | | MoMErrorMsg.AddMoMErrorMsg(0, input.TrayBarcode, err.Message, SysConfigConst.AgingInput); |
| | | Console.WriteLine(err.Message.ToString()); |
| | | LogFactory.GetLog("éç½®éåå
¥åºï¼æ´æçï¼").Error(true, $"\r\r--------------------------------------"); |
| | | LogFactory.GetLog("éç½®éåå
¥åºï¼æ´æçï¼").Error(true, err.StackTrace); |
| | |
| | | var wmsIpAddress = wmsBase + ipAddress; |
| | | |
| | | var result = HttpsClient.PostAsync(wmsIpAddress, inputJson).Result; |
| | | //var x = await HttpsClient.PostAsync("http://c24-cellmi3:12020/api/MachineIntegration/AgingOutput", inputJson); |
| | | |
| | | var respone = JsonConvert.DeserializeObject<ResponeAgingInputDto>(result.ToString()); |
| | | if (!respone.Success) |
| | | { |
| | | MoMErrorMsg.AddMoMErrorMsg(0, input.TrayBarcode, respone.MOMMessage, SysConfigConst.AgingOutput); |
| | | } |
| | | else |
| | | { |
| | | MoMErrorMsg.DeleteMoMErrorMsg(0, input.TrayBarcode); |
| | | } |
| | | |
| | | content.OK(data: result); |
| | | LogFactory.GetLog("éç½®éååºåºï¼æ´æçï¼").Info(true, $"\r\r--------------------------------------"); |
| | | LogFactory.GetLog("éç½®éååºåºï¼æ´æçï¼").Info(true, input.TrayBarcode); |
| | |
| | | } |
| | | catch (Exception err) |
| | | { |
| | | MoMErrorMsg.AddMoMErrorMsg(0, input.TrayBarcode, err.Message, SysConfigConst.AgingOutput); |
| | | Console.WriteLine(err.Message.ToString()); |
| | | LogFactory.GetLog("éç½®éååºåºï¼æ´æçï¼").Error(true, $"\r\r--------------------------------------"); |
| | | LogFactory.GetLog("éç½®éååºåºï¼æ´æçï¼").Error(true, err.StackTrace); |
| | |
| | | using LogLibrary.Log; |
| | | using AngleSharp.Io; |
| | | using LogLibrary.Log; |
| | | using Masuit.Tools; |
| | | using Newtonsoft.Json; |
| | | using WIDESEA_Common; |
| | |
| | | using WIDESEA_Core.Const; |
| | | using WIDESEA_Core.Helper; |
| | | using WIDESEA_DTO; |
| | | using WIDESEA_DTO.MOM; |
| | | using WIDESEA_IRepository; |
| | | using WIDESEA_IServices; |
| | | using WIDESEA_IStorageBasicService; |
| | |
| | | var wmsIpAddress = wmsBase + ipAddress; |
| | | |
| | | var result = HttpsClient.PostAsync(wmsIpAddress, inputJson).Result; |
| | | //var x = await HttpsClient.PostAsync("http://c24-cellmi3:12020/api/MachineIntegration/CellState", inputJson); |
| | | #region |
| | | //if (x != null) |
| | | //{ |
| | | // ResultCellState result = JsonConvert.DeserializeObject<ResultCellState>(x); |
| | | // DtBoxingInfo boxingInfo = new DtBoxingInfo() |
| | | // { |
| | | // IsFull = true, |
| | | // PalletCode = "", |
| | | // }; |
| | | // var details = new List<DtBoxingInfoDetail>(); |
| | | // foreach (var item in result.SerialNos) |
| | | // { |
| | | // DtBoxingInfoDetail detail = new DtBoxingInfoDetail() |
| | | // { |
| | | // SerialNumber = item.SerialNo, |
| | | // OrderNo = item.BindCode, |
| | | // Status = item.SerialNoStatus, |
| | | // }; |
| | | // details.Add(detail); |
| | | // } |
| | | // boxingInfo.BoxingInfoDetails = details; |
| | | // var abc = await _boxingInfoService.AddBoxingInfoAsync(boxingInfo); |
| | | // if (abc.Status) |
| | | // return content.OK("ç»çæå"); |
| | | // else |
| | | // return content.Error("ç»ç失败"); |
| | | //} |
| | | #endregion |
| | | |
| | | LogFactory.GetLog("åçµè¯å±æ§è·å").Info(true, $"\r\r--------------------------------------"); |
| | | LogFactory.GetLog("åçµè¯å±æ§è·å").Info(true, result); |
| | |
| | | var wmsIpAddress = wmsBase + ipAddress; |
| | | |
| | | var result = HttpsClient.PostAsync(wmsIpAddress, inputJson).Result; |
| | | //var x = await HttpsClient.PostAsync("http://c24-cellmi3:12020/api/MachineIntegration/TrayCellsStatus", inputJson); |
| | | |
| | | var respone = JsonConvert.DeserializeObject<ResultTrayCellsStatus>(result.ToString()); |
| | | |
| | | if (!respone.Success) |
| | | { |
| | | MoMErrorMsg.AddMoMErrorMsg(0, input.TrayBarcode, respone.MOMMessage, SysConfigConst.TrayCellsStatus); |
| | | } |
| | | else |
| | | { |
| | | MoMErrorMsg.DeleteMoMErrorMsg(0, input.TrayBarcode); |
| | | } |
| | | |
| | | LogFactory.GetLog("æ´ççµè¯å±æ§è·å").Info(true, $"\r\r--------------------------------------"); |
| | | LogFactory.GetLog("æ´ççµè¯å±æ§è·å").Info(true, result); |
| | |
| | | } |
| | | catch (Exception err) |
| | | { |
| | | MoMErrorMsg.AddMoMErrorMsg(0, input.TrayBarcode, err.Message, SysConfigConst.TrayCellsStatus); |
| | | |
| | | Console.WriteLine(err.Message.ToString()); |
| | | LogFactory.GetLog("æ´ççµè¯å±æ§è·å").Error(true, $"\r\r--------------------------------------"); |
| | | LogFactory.GetLog("æ´ççµè¯å±æ§è·å").Error(true, $"请æ±åæ°: {JsonConvert.SerializeObject(input)}"); |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using Masuit.Tools; |
| | | using SqlSugar; |
| | | using WIDESEA_Core; |
| | | using WIDESEA_Core.Helper; |
| | | using WIDESEA_DTO.MOM; |
| | | |
| | | namespace WIDESEA_StoragIntegrationServices |
| | | { |
| | | public class MoMErrorMsg |
| | | { |
| | | public static SqlSugarScope Db = SqlSugarHelper.DbWMS; |
| | | |
| | | public static WebResponseContent AddMoMErrorMsg(int TaskNum, string PalletCode, string ErrorMsg,string ApiName) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | var err = Db.Queryable<MOMErrorMessage>().Where(it => it.PalletCode == PalletCode).First(); |
| | | if (!err.IsNullOrEmpty()) |
| | | { |
| | | if (err.ErrorMessage == ErrorMsg) |
| | | { |
| | | return content.Error("该æçå·å·²åå¨å¼å¸¸ä¿¡æ¯"); |
| | | } |
| | | |
| | | err.ErrorMessage = ErrorMsg; |
| | | err.CreateTime = DateTime.Now; |
| | | var isUpdate = Db.Updateable(err).ExecuteCommand() > 0; |
| | | content.OK(data: err); |
| | | } |
| | | else |
| | | { |
| | | var result = new MOMErrorMessage |
| | | { |
| | | TaskNum = TaskNum, |
| | | PalletCode = PalletCode, |
| | | ErrorMessage = ErrorMsg, |
| | | APIName = ApiName, |
| | | CreateTime = DateTime.Now |
| | | }; |
| | | |
| | | var isResult = Db.Insertable(result).ExecuteCommand() > 0; |
| | | content.OK(data: result); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | |
| | | public static WebResponseContent DeleteMoMErrorMsg(int TaskNum, string PalletCode) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | var err = Db.Queryable<MOMErrorMessage>().Where(it => it.PalletCode == PalletCode).First(); |
| | | if (!err.IsNullOrEmpty()) |
| | | { |
| | | var isUpdate = Db.Deleteable(err).ExecuteCommand() > 0; |
| | | content.OK(data: err); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | } |
| | | } |
| | |
| | | var wmsIpAddress = wmsBase + ipAddress; |
| | | |
| | | var result = HttpsClient.PostAsync(wmsIpAddress, inputJson).Result; |
| | | //var x = await HttpsClient.PostAsync("http://c24-cellmi3:12020/api/MachineIntegration/ProcessApply", inputJson); |
| | | |
| | | if (result != null) |
| | | { |
| | | //var ResultProcess = JsonConvert.DeserializeObject<ResultProcessApply>(x); |
| | | content.OK(data: result); |
| | | |
| | | //var respone = JsonConvert.DeserializeObject<ResultProcessApply>(result.ToString()); |
| | | //if (!respone.Success) |
| | | //{ |
| | | // MoMErrorMsg.AddMoMErrorMsg(0, input.WipOrderNo, respone.MOMMessage, SysConfigConst.TrayCellsStatus); |
| | | //} |
| | | //else |
| | | //{ |
| | | // MoMErrorMsg.DeleteMoMErrorMsg(0, input.WipOrderNo); |
| | | //} |
| | | } |
| | | LogFactory.GetLog("å·¥èºè·¯çº¿ç³è¯·").Info(true, $"\r\r--------------------------------------"); |
| | | LogFactory.GetLog("å·¥èºè·¯çº¿ç³è¯·").Info(true, result); |