zhao
2021-06-24 02ca96debc6056275d58e55d97f7885a195542d0
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
using HH.TOOLS.LOG;
using HH.WMS.BLL;
using HH.WMS.BLL.Check;
using HH.WMS.Common;
using HH.WMS.Entitys;
using HH.WMS.Entitys.Check;
using HH.WMS.WebApi.Areas.Common.Controllers;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
 
namespace HH.WMS.WebApi.Areas.Check.Controllers
{
    /// <summary>
    /// 盘点(南通桑德)
    /// </summary>
    public class CheckWxysController : BaseController
    {
        #region GET
 
        /// <summary>
        /// 获取盘点主表分页
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        /// <History>[Hanhe(lt)] created by 2018-7-4</History>
        [HttpPost]
        public string GetCheckMst(dynamic obj)
        {
            string tokenId = Util.ToString(obj.tokenId);
            return ValidateToken(tokenId, t =>
            {
                DataTable dt = BLLCreator.Create<TN_WM_CHECK_MSTBLL>().GetDataTable(obj);
                OperateResult res = OperateResult.Succeed(null, new { rows = dt, total = obj.PageCount });
                IsoDateTimeConverter timeFormat = new IsoDateTimeConverter();
                timeFormat.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
                return JsonConvert.SerializeObject(res, timeFormat);
            });
 
        }
 
        /// <summary>
        /// 获取盘点明细
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        /// <history>[HanHe(lt)] CREATED 2018/12/6</history>
        /// <history>[HanHe(dbs)] CREATED 2019/3/18</history>
        public OperateResult GetCheckDtl(string opNo)
        {
            return ValidateToken(t =>
            {
                var result = BLLCreator.Create<TN_WM_CHECK_WXYSBLL>().GetCheckDtl(opNo);
                return result;
            });
        }
 
        /// <summary>
        /// 获取盘点记录
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        [HttpPost]
        public string GetCheckList(dynamic obj)
        {
            string tokenId = Util.ToString(obj.tokenId);
            return ValidateToken(tokenId, t =>
            {
                DataTable dt = BLLCreator.Create<TN_WM_CHECK_WXYSBLL>().GetCheckList(obj);
                OperateResult res = OperateResult.Succeed(null, new { rows = dt, total = obj.PageCount });
                IsoDateTimeConverter timeFormat = new IsoDateTimeConverter();
                timeFormat.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
                return JsonConvert.SerializeObject(res, timeFormat);
            });
        }
 
        /// <summary>
        /// 根据单号获取盘点单列表
        /// </summary>
        /// <param name="opNo"></param>
        /// <returns></returns>
        [HttpGet]
        public OperateResult GetCheckListByOpNo(string opNo)
        {
            var result = BLLCreator.Create<TN_WM_CHECK_WXYSBLL>().GetCheckListByOpNo(opNo);
            return result;
        }
 
        /// <summary>
        /// 获取主子表
        /// </summary>
        /// <param name="opNo"></param>
        /// <returns></returns>
        [HttpGet]
        public OperateResult GetMstAndDtl(string opNo)
        {
            var result = BLLCreator.Create<TN_WM_CHECK_WXYSBLL>().GetMstAndDtl(opNo);
            return result;
        }
 
        #endregion
 
        #region ADD
 
        /// <summary>
        /// 盘点单新增
        /// </summary>
        /// <param name="checkAddDto"></param>
        /// <returns></returns>
        [HttpPost]
        public OperateResult Add(CheckAddDto checkAddDto)
        {
            var logPara = new LogPara("盘点单新增");
            try
            {
                return ValidateToken(checkAddDto.tokenId, t =>
                {
                    logPara.Push("接收参数:" + JsonConvert.SerializeObject(checkAddDto));
                    var result = BLLCreator.Create<TN_WM_CHECK_WXYSBLL>().Add(checkAddDto.checkList, t, logPara);
                    logPara.PushAndAdd("返回结果:" + (result.Success ? "成功" : "失败" + result.Msg));
                    return result;
                });
            }
            catch (Exception ex)
            {
                logPara.PushAndAdd(ex);
                return OperateResult.Error(ex.Message);
            }
        }
 
        #endregion
 
        #region UPDATE
 
        /// <summary>
        /// 盘点单更新
        /// </summary>
        /// <param name="checkAddDto"></param>
        /// <returns></returns>
        [HttpPost]
        public OperateResult Update(CheckAddDto checkAddDto)
        {
            return ValidateToken(checkAddDto.tokenId, t =>
            {
                var result = BLLCreator.Create<TN_WM_CHECK_WXYSBLL>().Update(checkAddDto, t);
                return result;
            });
        }
 
        /// <summary>
        /// 提交盘点单
        /// </summary>
        /// <param name="opNo"></param>
        /// <returns></returns>
        [HttpPost]
        public OperateResult Submit(CheckAuditDto checkAuditDto)
        {
            return BLLCreator.Create<TN_WM_CHECK_WXYSBLL>().Submit(checkAuditDto);
        }
 
        /// <summary>
        /// 审核
        /// </summary>
        /// <param name="checkAuditDto"></param>
        /// <returns></returns>
        [HttpPost]
        public OperateResult Audit(CheckAuditDto checkAuditDto)
        {
            var logPara = new LogPara("盘点单审核");
            var checkAuditPara = new CheckAuditPara { checkAuditDto = checkAuditDto };
            try
            {
                logPara.Push("接收参数:" + JsonConvert.SerializeObject(checkAuditDto));
                var result = BLLCreator.Create<TN_WM_CHECK_WXYSBLL>().Audit(checkAuditPara, logPara);
                logPara.PushAndAdd("返回结果:" + result.Describe());
                return result;
            }
            catch (Exception ex)
            {
                logPara.PushAndAdd(ex);
                return OperateResult.Error(ex.Message);
            }
            
        }
 
        /// <summary>
        /// 盘点单反审
        /// </summary>
        /// <param name="checkAuditDto"></param>
        /// <returns></returns>
        [HttpPost]
        public OperateResult ReAudit(CheckAuditDto checkAuditDto)
        {
            var logPara = new LogPara("盘点单反审");
            try
            {
                logPara.Push("接收参数:" + JsonConvert.SerializeObject(checkAuditDto));
                var result = BLLCreator.Create<TN_WM_CHECK_WXYSBLL>().ReAudit(checkAuditDto, logPara);
                logPara.PushAndAdd("返回结果:" + result.Describe());
                return result;
            }
            catch (Exception ex)
            {
                return OperateResult.Error("系统异常:" + ex.Message);
            }
            
        }
 
        #endregion
 
        #region DELETE
 
        /// <summary>
        /// 盘点单删除
        /// </summary>
        /// <param name="opNo">盘点单号</param>
        /// <returns></returns>
        [HttpGet]
        public OperateResult Delete(string opNo)
        {
            var logPara = new LogPara("盘点单删除");
            try
            {
                logPara.Push("接收参数opNo:" + opNo);
                var result = BLLCreator.Create<TN_WM_CHECK_WXYSBLL>().Delete(opNo, logPara);
                logPara.PushAndAdd("执行结果:" + (result.Success ? "成功" : "失败," + result.Msg));
                return result;
            }
            catch (Exception ex)
            {
                logPara.PushAndAdd(ex);
                return OperateResult.Error("系统异常:" + ex.Message);
            }
            
        }
 
        #endregion
 
    }
}