yl
2022-08-26 8427cbd12ab2cd1923054ff72e263f5bdebc0803
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
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web;
using System.Web.Http;
using VueWebApi.DLL.BLL;
using VueWebApi.Tools;
 
namespace VueWebApi.Controllers
{
    [RoutePrefix(prefix: "api/MaterialManager")]
    [ControllerGroup("物料管理", "在线接口")]
    [ChannelActionFilter]
    public class MaterialManagerController : ApiController
    {
        //定义全局信息返回变量
        ToMessage mes = new ToMessage();
        RedisHelper redis = new RedisHelper();
 
        #region[仓库定义查询]
        /// <summary>
        /// 仓库定义查询
        /// </summary>
        /// <param name="warehousecode">仓库编码</param>
        /// <param name="warehousename">仓库名称</param>
        /// <param name="description">仓库描述</param>
        /// <param name="createuser">创建人员</param>
        /// <param name="page">页码</param>
        /// <param name="rows">每页显示条数</param>
        /// <param name="prop">排序字段</param>
        /// <param name="order">排序规则</param>
        /// <returns></returns>
        [Route(template: "WareHouseDefSearch")]
        [HttpGet]
        public HttpResponseMessage WareHouseDefSearch(string warehousecode = null, string warehousename = null, string description = null, string createuser = null, int page = 0, int rows = 0, string prop = null, string order = null)
        {
            int startNum = rows * (page - 1) + 1;  //起始记录rowNum
            int endNum = rows * page;   //结束记录 rowNum
            mes = MaterialManagerBLL.WareHouseDefSearch(warehousecode, warehousename, description, createuser, startNum, endNum, prop, order);
            return TJson.toJson(mes);
        }
        #endregion
 
        #region[仓库定义新增编辑]
        /// <summary>
        /// 仓库定义新增编辑
        /// </summary>
        /// <param name="obj">提交数据对象</param>
        /// <returns></returns>
        [Route(template: "AddUpdateWareHouseDef")]
        [HttpPost]
        public HttpResponseMessage AddUpdateWareHouseDef([FromBody] JObject obj)
        {
            string warehouseid = obj["id"].ToString();    //仓库id(主键)
            string warehousecode = obj["warehousecode"].ToString(); //仓库编码
            string warehousename = obj["warehousename"].ToString(); //仓库名称
            string description = obj["description"].ToString(); //仓库描述
            var username = HttpContext.Current.Request.Cookies["admin"].Value.ToString(); //操作人员
            string OperType = obj["OperType"].ToString();  //操作类型
            mes = MaterialManagerBLL.AddUpdateWareHouseDef(warehouseid, warehousecode, warehousename, description, username,OperType);
            return TJson.toJson(mes);
        }
        #endregion
 
        #region[仓库删除]
        /// <summary>
        /// 仓库删除
        /// </summary>
        /// <param name="warehousecode">仓库编码</param>
        /// <returns></returns>
        [Route(template: "DeleteWareHouseDef")]
        [HttpPost]
        public HttpResponseMessage DeleteWareHouseDef(string warehousecode)
        {
            mes = MaterialManagerBLL.DeleteWareHouseDef(warehousecode);
            return TJson.toJson(mes);
        }
        #endregion
 
 
 
        #region[所属仓库接口]
        /// <summary>
        /// 所属仓库接口
        /// </summary>
        /// <returns></returns>
        [Route(template: "WareHouseSelect")]
        [HttpGet]
        public HttpResponseMessage WareHouseSelect()
        {
            try
            {
                mes = MaterialManagerBLL.WareHouseSelect();
            }
            catch (Exception e)
            {
                mes.code = "300";
                mes.Message = e.Message;
            }
            return TJson.toJson(mes);
        }
        #endregion
 
        #region[库位定义查询]
        /// <summary>
        /// 库位定义查询
        /// </summary>
        /// <param name="storagecode">库位编码</param>
        /// <param name="storagename">库位名称</param>
        /// <param name="description">仓库描述</param>
        /// <param name="createuser">创建人员</param>
        /// <param name="stockcode">所属仓库编码</param>
        /// <param name="page">页码</param>
        /// <param name="rows">每页显示条数</param>
        /// <param name="prop">排序字段</param>
        /// <param name="order">排序规则</param>
        /// <returns></returns>
        [Route(template: "StorageDefSearch")]
        [HttpGet]
        public HttpResponseMessage StorageDefSearch(string storagecode = null, string storagename = null, string description = null, string createuser = null,string stockcode=null,int page = 0, int rows = 0, string prop = null, string order = null)
        {
            int startNum = rows * (page - 1) + 1;  //起始记录rowNum
            int endNum = rows * page;   //结束记录 rowNum
            mes = MaterialManagerBLL.StorageDefSearch(storagecode, storagename, description, createuser, stockcode, startNum, endNum, prop, order);
            return TJson.toJson(mes);
        }
        #endregion
 
        #region[库位定义新增编辑]
        /// <summary>
        /// 库位定义新增编辑
        /// </summary>
        /// <param name="obj">提交数据对象</param>
        /// <returns></returns>
        [Route(template: "AddUpdateStorageDef")]
        [HttpPost]
        public HttpResponseMessage AddUpdateStorageDef([FromBody] JObject obj)
        {
            string storageid = obj["id"].ToString();    //库位id(主键)
            string storagecode = obj["storagecode"].ToString(); //库位编码
            string storagename = obj["storagename"].ToString(); //库位名称
            string description = obj["description"].ToString(); //库位描述
            string stockcode = obj["stockcode"].ToString(); //所属仓库编码
            var username = HttpContext.Current.Request.Cookies["admin"].Value.ToString(); //操作人员
            string OperType = obj["OperType"].ToString();  //操作类型
            mes = MaterialManagerBLL.AddUpdateStorageDef(storageid, storagecode, storagename, description, stockcode, username, OperType);
            return TJson.toJson(mes);
        }
        #endregion
 
        #region[库位删除]
        /// <summary>
        /// 库位删除
        /// </summary>
        /// <param name="storagecode">库位编码</param>
        /// <returns></returns>
        [Route(template: "DeleteStorageDef")]
        [HttpPost]
        public HttpResponseMessage DeleteStorageDef(string storagecode)
        {
            mes = MaterialManagerBLL.DeleteStorageDef(storagecode);
            return TJson.toJson(mes);
        }
        #endregion
    }
}