| using LogLibrary.Log; | 
| using Masuit.Tools; | 
| using SqlSugar; | 
| using WIDESEA_Core; | 
| using WIDESEA_Core.Helper; | 
| using WIDESEA_Model.Models; | 
|   | 
| 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; | 
|         } | 
|     } | 
| } |