zhao
2021-07-19 8347f2fbddbd25369359dcb2da1233ac48a19fdc
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
using HH.WMS.BLL;
using HH.WMS.BLL.Basic;
using HH.WMS.Entitys;
using HH.WMS.Entitys.Basic;
using HH.WMS.Entitys.Common;
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.Basic
{
    public class LotInfoController : BaseController
    {
        /// <summary>
        /// 分页获取批次列表
        /// </summary>
        /// <param name="pageIndex">页码</param>
        /// <param name="pageSize">页显示条数</param>
        /// <returns></returns>
        /// <History>[HANHE(XDL)] CREATED BY 2018-12-03</History>
        [HttpGet]
        public OperateResult GetLotList(int pageIndex, int pageSize)
        {
            try
            {
                return ValidateToken(x =>
                {
                    var list = BLLCreator.Create<TN_WM_LOT_INFOBLL>().GetLotList(pageIndex, pageSize);
                    return list;
                });
            }
            catch (Exception ex)
            {
                return OperateResult.Error(ex.Message);
            }
        }
 
        #region 查询批次
        /// <summary>
        /// 查询批次
        /// </summary>
        /// <param name="searchModel">查询实体</param>
        /// <returns></returns>
        [HttpPost]
        public string GetLotList(SearchModel searchModel)
        {
            return ValidateToken(searchModel.TokenId, m =>
            {
                OperateResult resultInfo = GetTokenInfo(searchModel.TokenId);
                if (!resultInfo.Success) return JsonConvert.SerializeObject(resultInfo);
                IsoDateTimeConverter timeFormat = new IsoDateTimeConverter();
                timeFormat.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
                long total;
                DataTable dt = BLLCreator.Create<TN_WM_LOT_INFOBLL>().GetLotList(searchModel, out total);
                OperateResult pagingList = OperateResult.Succeed("", new
                {
                    rows = dt,
                    total = total
                });
                return JsonConvert.SerializeObject(pagingList, timeFormat);
            });
        }
        #endregion
 
        [HttpGet]
        public string GetLotInfoList()
        {
            return ValidateToken(m =>
            {
                try
                {
                    List<TN_WM_LOT_INFOEntity> lotList = BLLCreator.Create<DapperBLL<TN_WM_LOT_INFOEntity>>().GetList();
                    return JsonConvert.SerializeObject(lotList);
                }
                catch (Exception ex)
                {
                    return "";
                }
            });
        }
 
        /// <summary>
        /// U8服务调用
        /// </summary>
        /// <param name="lotInfoList">批次集合</param>
        /// <returns></returns>
        [HttpPost]
        public string AddLotInfo(List<TN_WM_LOT_INFOEntity> lotInfoList)
        {
            OperateResult or = BLLCreator.Create<DapperBLL<TN_WM_LOT_INFOEntity>>().AddRange(lotInfoList);
            return JsonConvert.SerializeObject(or);
 
        }
    }
}