From e376a1f56a3fcd133afc5fead8a2fbc1a499e865 Mon Sep 17 00:00:00 2001
From: xxyy <cathay_xy@163.com>
Date: 星期日, 02 三月 2025 22:23:56 +0800
Subject: [PATCH] 新增异常消息处理及WMS API调用逻辑优化
---
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/AgingInOrOutInput/AgingInOrOutInputService.cs | 30 ++++++-
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/CellState/CellStateService.cs | 47 ++++-------
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_DTO/MOM/MOMErrorMessage.cs | 54 +++++++++++++
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/Error/MoMErrorMsg.cs | 72 ++++++++++++++++++
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/ProcessApply/ProcessApplyService.cs | 13 ++
5 files changed, 179 insertions(+), 37 deletions(-)
diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_DTO/MOM/MOMErrorMessage.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_DTO/MOM/MOMErrorMessage.cs
new file mode 100644
index 0000000..45f205a
--- /dev/null
+++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_DTO/MOM/MOMErrorMessage.cs
@@ -0,0 +1,54 @@
+锘縰sing 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; }
+ }
+}
diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/AgingInOrOutInput/AgingInOrOutInputService.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/AgingInOrOutInput/AgingInOrOutInputService.cs
index 9abfeac..67b5f60 100644
--- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/AgingInOrOutInput/AgingInOrOutInputService.cs
+++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/AgingInOrOutInput/AgingInOrOutInputService.cs
@@ -1,12 +1,13 @@
-锘縰sing LogLibrary.Log;
+锘縰sing 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;
@@ -45,8 +46,17 @@
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);
@@ -54,6 +64,7 @@
}
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);
@@ -85,7 +96,17 @@
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);
@@ -93,6 +114,7 @@
}
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);
diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/CellState/CellStateService.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/CellState/CellStateService.cs
index 2746a02..7c2baf4 100644
--- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/CellState/CellStateService.cs
+++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/CellState/CellStateService.cs
@@ -1,4 +1,5 @@
-锘縰sing LogLibrary.Log;
+锘縰sing AngleSharp.Io;
+using LogLibrary.Log;
using Masuit.Tools;
using Newtonsoft.Json;
using WIDESEA_Common;
@@ -6,6 +7,7 @@
using WIDESEA_Core.Const;
using WIDESEA_Core.Helper;
using WIDESEA_DTO;
+using WIDESEA_DTO.MOM;
using WIDESEA_IRepository;
using WIDESEA_IServices;
using WIDESEA_IStorageBasicService;
@@ -51,35 +53,6 @@
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);
@@ -120,7 +93,17 @@
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);
@@ -128,6 +111,8 @@
}
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)}");
diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/Error/MoMErrorMsg.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/Error/MoMErrorMsg.cs
new file mode 100644
index 0000000..4a55dd1
--- /dev/null
+++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/Error/MoMErrorMsg.cs
@@ -0,0 +1,72 @@
+锘縰sing 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;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/ProcessApply/ProcessApplyService.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/ProcessApply/ProcessApplyService.cs
index d4776a2..0725b0b 100644
--- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/ProcessApply/ProcessApplyService.cs
+++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/ProcessApply/ProcessApplyService.cs
@@ -58,11 +58,20 @@
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);
--
Gitblit v1.9.3