xxyy
2025-03-02 e376a1f56a3fcd133afc5fead8a2fbc1a499e865
新增异常消息处理及WMS API调用逻辑优化

在 `MOMErrorMessage.cs` 中添加了 `MOMErrorMessage` 类,包含多个属性并使用 `SqlSugar` 进行数据库映射。
在 `AgingInOrOutInputService.cs` 和 `CellStateService.cs` 中移除不必要的 `using` 语句,更新 WMS API 调用逻辑,增加响应处理和异常消息记录。
在 `MoMErrorMsg.cs` 中实现了异常消息的添加和删除功能。
在 `ProcessApplyService.cs` 中优化了 WMS API 调用逻辑,保留了日志记录功能。
已修改3个文件
已添加2个文件
216 ■■■■ 文件已修改
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_DTO/MOM/MOMErrorMessage.cs 54 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/AgingInOrOutInput/AgingInOrOutInputService.cs 30 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/CellState/CellStateService.cs 47 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/Error/MoMErrorMsg.cs 72 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/ProcessApply/ProcessApplyService.cs 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_DTO/MOM/MOMErrorMessage.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,54 @@
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; }
    }
}
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/AgingInOrOutInput/AgingInOrOutInputService.cs
@@ -1,12 +1,13 @@
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;
@@ -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);
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/CellState/CellStateService.cs
@@ -1,4 +1,5 @@
using LogLibrary.Log;
using 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)}");
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/Error/MoMErrorMsg.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,72 @@
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;
        }
    }
}
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);