xxyy
2025-03-04 3bb8be2b84ab6456d28881b3cf99a4b40560ed6b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
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;
        }
    }
}