bklLiudl
2024-05-25 484e5129e4c9a671c5660a556a24bd306f1fdd9b
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
using Model.ModelDto.SysDto;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using WMS.Entity.Context;
using WMS.Entity.SysEntity;
using WMS.IDAL.ISysInterface;
 
namespace WMS.DAL.SysInfrastructure
{
    public class ExceptionRepository : BaseRepository<SysException>, IExceptionRepository
    {
        private static readonly SqlSugarScope Db = DataContext.Db;
        public ExceptionRepository() : base(DataContext.Db)
        {
        }
 
 
        /// <summary>
        /// 获取异常处理信息列表
        /// </summary>
        /// <param name="exceptionNo">异常号</param>
        /// <param name="palletNo">托盘号</param>
        /// <param name="excLocatNo">异常储位</param>
        /// <param name="orderNo">关联单号</param>
        /// <param name="taskNo">关联任务号</param>
        /// <param name="type">异常类型</param>
        /// <param name="status">状态</param>
        /// <returns></returns>
        public List<ExceptionDto> GetExceptionList(string exceptionNo, string palletNo, string excLocatNo, string orderNo, string taskNo, string type, string status)
        {
            string str = "select exception.*,user1.UserName CreateUserName from SysException exception left join SysUserInfor user1 on exception.CreateUser = user1.Id where exception.IsDel = @isdel";
            //判断异常号
            if (!string.IsNullOrEmpty(exceptionNo))
            {
                str += " and exception.ExceptionNo like @exceptionno";
            }
            //判断托盘号
            if (!string.IsNullOrEmpty(palletNo))
            {
                str += " and exception.PalletNo like @palletno";
            }
            //判断异常储位号
            if (!string.IsNullOrEmpty(excLocatNo))
            {
                str += " and exception.ExcLocatNo like @exclocatno";
            }
            //判断关联单号
            if (!string.IsNullOrEmpty(orderNo))
            {
                str += " and exception.OrderNo like @orderno";
            }
            //判断关联任务号
            if (!string.IsNullOrEmpty(taskNo))
            {
                str += " and exception.TaskNo like @taskno";
            }
            //判断异常类型
            if (!string.IsNullOrEmpty(type))
            {
                str += " and exception.Type = @type";
            }
            //判断状态
            if (!string.IsNullOrEmpty(status))
            {
                str += " and exception.Status = @status";
            }
            str += " order by exception.CreateTime desc";
            List<ExceptionDto> tablelist = Db.Ado.SqlQuery<ExceptionDto>(str, new
            {
                isdel = "0", //是否删除
                exceptionno = "%" + exceptionNo + "%", //异常号
                palletno = "%" + palletNo + "%", //托盘号
                exclocatno = "%" + excLocatNo + "%", //异常储位
                orderno = "%" + orderNo + "%", //关联单号
                taskno = "%" + taskNo + "%", //关联任务号
                type, //异常类型
                status //状态
            });
            return tablelist;
        }
 
        /// <summary>
        /// 根据id获取异常信息
        /// </summary>
        /// <param name="id">异常id</param>
        /// <returns></returns>
        public SysException GetExceptionById(int id)
        {
            string str = "select * from SysException where IsDel = @isdel and Id = @id";
            SysException exception = Db.Ado.SqlQuerySingle<SysException>(str, new
            {
                isdel = "0", //是否删除
                id //id
            });
            return exception;
        }
 
        /// <summary>
        /// 新增异常处理
        /// </summary>
        /// <param name="exceptionNo">异常号</param>
        /// <param name="type">异常类型</param>
        /// <param name="palletNo">托盘号</param>
        /// <param name="excLocatNo">异常储位</param>
        /// <param name="orderNo">关联单号</param>
        /// <param name="taskNo">关联任务号</param>
        /// <param name="demo">备注</param>
        /// <param name="uid">创建人</param>
        /// <returns></returns>
        public async Task<int> InsertException(string exceptionNo, string type, string palletNo, string excLocatNo, string orderNo, string taskNo, string demo, int uid)
        {
            string str = "Insert into SysException values(@exceptionno, @type, @palletno, @exclocatno, @orderno, @taskno, @status, @text, @demo, @isdel, @createtime, @createuser, null, null)";
            int i = await Db.Ado.ExecuteCommandAsync(str, new
            {
                exceptionno = exceptionNo, //异常号
                type, //异常类型
                palletno = palletNo, //托盘号
                exclocatno = excLocatNo, //异常储位
                orderno = orderNo, //关联单号
                taskno = taskNo, //关联任务号
                status = "0", //状态
                text = "", //处理描述
                demo, //备注
                isdel = "0",//是否删除
                createtime = Db.GetDate(), //创建时间
                createuser = uid //创建人
            });
            return i;
 
            //异常号获取最大值加一 ExceptionNo 1
            //异常类型 0:空取 要去一个库取东西 到了以后发现没东西 1:满入 要去一个地方放东西 到了以后发现放不下 2:双工位异常 例如:目标区域有两个地方可以放东西 我要把东西放在二号区域 二号区域被一号区域挡住了 放不了 取货反之Type
            //托盘号PalletNo
            //异常储位 多储位用;号区分ExcLocatNo
            //关联单号 入库单、出库单、移库单OrderNo
            //关联任务号TaskNo
            //状态Status 默认未处理
            //处理描述Text //空
            //备注Demo 1
 
            //是否删除 0 1
            //创建时间 Db.GetDate(); 1
            //创建人 :操作人 1
 
        }
 
        /// <summary>
        /// 处理异常状态
        /// </summary>
        /// <param name="exception"></param>
        /// <returns></returns>
        public async Task<int> EditStatus(SysException exception)
        {
            string str = "update SysException set Status = @status,Demo = @demo,Text = @text,UpdateTime = @updatetime,UpdateUser = @updateuser where Id = @id";
            int i = await Db.Ado.ExecuteCommandAsync(str, new
            {
                status = "1", //状态
                demo = exception.Demo, //备注
                text = exception.Text, //处理描述
                updatetime = Db.GetDate(), //更改时间
                updateuser = exception.UpdateUser, //更改人
                id = exception.Id //id
            });
            return i;
        }
 
        /// <summary>
        /// 获取最大异常号
        /// </summary>
        /// <returns></returns>
        public SysException GetMaxExceptionNo()
        {
            string str = "select MAX(ExceptionNo) ExceptionNo from SysException";
            SysException table = Db.Ado.SqlQuerySingle<SysException>(str);
            return table;
        }
    }
}