yusijie
2023-02-03 3c1f1bdf22437cf7382cab1aa5b99700c3a5b479
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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
using DBUtility;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using SQLHelper;
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web;
using System.Web.Http;
using WebAPI.Code;
using WebAPI.Models;
namespace WebAPI.Controllers
{
    public class EntrustOrderController : ApiController
    {
        private JsonResult objJsonResult = new JsonResult();
        private json objjson = new json();
        SQLHelper.ClsCNSRM oCn = new SQLHelper.ClsCNSRM();
 
        /// <summary>
        /// 采购单列表
        /// </summary>
        /// <param name="msg"></param>
        /// <param name="NowPage"></param>
        /// <param name="OnePage"></param>
        /// <returns></returns>
        [Route("GetEntrustOrderBill")]
        [HttpPost]
        public object GetEntrustOrderBill([FromBody] JObject msg)
        {
            string HSupNo = msg["HSupNo"].ToString(); string sqlWhere = msg["sqlWhere"].ToString();
            try
            {
                string VsWhere = "";
                string PcWhere = "";
                SQLHelper.ClsCNSRM oCn = new SQLHelper.ClsCNSRM();
                DataSet ds;
                string sql = " Where hsupid in (select HSupID from h_v_Gy_UserSupplierList where 用户=^^" + HSupNo.Trim() + "^^) " + sqlWhere;
                if (Common.SQLtoChange(sql, ref VsWhere, ref PcWhere) == false)
                {
                    objjson.code = "0";
                    objjson.count = 0;
                    objjson.Message = "转换特殊字符失败";
                    objjson.data = null;
                    return objjson;
                }
                //获取总行数
                Int64 RowTotal = Common.GetRowTotal("H_v_SRM_EntrustOrderBillList", VsWhere, ref DBUtility.ClsPub.sExeReturnInfo);
                //获取返回数据
                ds = oCn.RunProcReturn("exec H_p_SRM_EntrustOrderBillList '" + PcWhere + "'", "H_p_SRM_EntrustOrderBillList");
                //添加列名
                List<object> columnNameList = new List<object>();
                foreach (DataColumn col in ds.Tables[0].Columns)
                {
                    Type dataType = col.DataType;
                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
                }
 
                objjson.code = "0";
                objjson.count = 10000;
                objjson.Message = "获取成功";
                objjson.data = ds.Tables[0];
                objjson.list = columnNameList;
                return objjson;               
            }
            catch (Exception e)
            {
                objjson.code = "0";
                objjson.count = 0;
                objjson.Message = "获取失败" + e.ToString();
                objjson.data = null;
                return objjson;
            }
 
        }
        /// <summary>
        /// 委外订单表头信息
        /// </summary>
        /// <param name="sMsg"></param>
        /// <returns></returns>
        [Route("GetEntrustOrderShowBillMain")]
        [HttpGet]
        public object GetEntrustOrderShowBillMain(string sMsg)
        {
            try
            {
                DataSet ds;
                string ShowItem = " * ";//显示的字段
                if (DBUtility.ClsPub.isLong(sMsg) == 0)
                {
                    objjson.code = "0";
                    objjson.count = 0;
                    objjson.Message = "获取失败";
                    objjson.data = null;
                    return objjson;
                }
                DAL.ClsWW_EntrustOrderBill oClsWW_EntrustOrderBill = new DAL.ClsWW_EntrustOrderBill();
                ds = oClsWW_EntrustOrderBill.ShowBillMainTo(DBUtility.ClsPub.isLong(sMsg), ShowItem, ref DBUtility.ClsPub.sExeReturnInfo);
                if (ds == null || ds.Tables[0].Rows.Count == 0)
                {
                    objjson.code = "0";
                    objjson.count = 0;
                    objjson.Message = "获取失败";
                    objjson.data = null;
                    return objjson;
                }
                else
                {
                    objjson.code = "0";
                    objjson.count = 10000;
                    objjson.Message = "获取成功";
                    objjson.data = ds.Tables[0];
                    return objjson;
                }
            }
            catch (Exception e)
            {
                objjson.code = "0";
                objjson.count = 0;
                objjson.Message = "获取失败" + e.ToString();
                objjson.data = null;
                return objjson;
            }
        }
        /// <summary>
        /// 委外订单明细表体信息
        /// </summary>
        /// <param name="sMsg"></param>
        /// <param name="sMsg2"></param>
        /// <returns></returns>
        [Route("GetEntrustOrderShowBillSub")]
        [HttpGet]
        public object GetEntrustOrderShowBillSub(string sMsg)
        {
            try
            {
                DataSet ds = null;
                string ShowItem = " * ";//显示的字段
                if (DBUtility.ClsPub.isLong(sMsg) == 0)
                {
                    objjson.code = "0";
                    objjson.count = 0;
                    objjson.Message = "获取失败";
                    objjson.data = null;
                    return objjson;
                }
                DAL.ClsWW_EntrustOrderBill oClsWW_EntrustOrderBill = new DAL.ClsWW_EntrustOrderBill();
                ds = oClsWW_EntrustOrderBill.ShowBillSubTo(DBUtility.ClsPub.isLong(sMsg), ShowItem, ref DBUtility.ClsPub.sExeReturnInfo);
                if (ds == null || ds.Tables[0].Rows.Count == 0)
                {
                    //return DBUtility.ClsPub.sExeReturnInfo;
                    objjson.code = "0";
                    objjson.count = 0;
                    objjson.Message = "获取失败";
                    objjson.data = null;
                    return objjson;
                }
                else
                {
                    objjson.code = "0";
                    objjson.count = 10000;
                    objjson.Message = "获取成功";
                    objjson.data = ds.Tables[0];
                    return objjson;
                }
                //return s;
            }
            catch (Exception e)
            {
                objjson.code = "0";
                objjson.count = 0;
                objjson.Message = "获取失败" + e.ToString();
                objjson.data = null;
                return objjson;
            }
        }
 
 
 
        [Route("EntrustOrderAccept")]
        [HttpGet]
        /// <summary>
        /// 订单接受
        /// </summary>
        /// <param name="HInterID"></param>
        /// <returns></returns>
        public object EntrustOrderAccept(string HInterID, string HBillNo, string HUser)
        {
            try
            {
                if (DBUtility.ClsPub.isLong(HInterID) == 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "接受失败!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                DAL.ClsWW_EntrustOrderBill oBill = new DAL.ClsWW_EntrustOrderBill();
                oBill.WebAccept(DBUtility.ClsPub.isLong(HInterID), DBUtility.ClsPub.isStrNull(HBillNo), DBUtility.ClsPub.isStrNull(HUser), ref DBUtility.ClsPub.sExeReturnInfo);
                objJsonResult.code = "0";
                objJsonResult.count = 1;
                objJsonResult.Message = "接受成功!";
                objJsonResult.data = 1;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "接受失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        [Route("EntrustOrderRefuse")]
        [HttpGet]
        /// <summary>
        /// 订单拒绝
        /// </summary>
        /// <param name="HInterID"></param>
        /// <returns></returns>
        public object EntrustOrderRefuse(string HInterID, string HBillNo, string HUser, string HBackRemark)
        {
            try
            {
                if (DBUtility.ClsPub.isLong(HInterID) == 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "失败!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                DAL.ClsWW_EntrustOrderBill oBill = new DAL.ClsWW_EntrustOrderBill();
                oBill.WebRefuse(DBUtility.ClsPub.isLong(HInterID), DBUtility.ClsPub.isStrNull(HBillNo), DBUtility.ClsPub.isStrNull(HUser), DBUtility.ClsPub.isStrNull(HBackRemark), ref DBUtility.ClsPub.sExeReturnInfo);
                objJsonResult.code = "0";
                objJsonResult.count = 1;
                objJsonResult.Message = "拒绝成功!";
                objJsonResult.data = 1;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
 
        [Route("EntrustOrderBack")]
        [HttpGet]
        /// <summary>
        /// 订单反馈状态
        /// </summary>
        /// <param name=""></param>
        /// <returns></returns>
        public object EntrustOrderBack(string HmainidList, string OrderBackId)
        {
            try
            {
                string sql = "";
                for (int i = 0; i < HmainidList.Split(',').Length; i++)
                {
                    var Hmainid = HmainidList.Split(',')[i];
                    sql = string.Format(@"
                update WW_EntrustOrderBillSub set 
                HFeedback ='{0}'
                where HInterID = '{1}' and HEntryID = '{2}' ", OrderBackId, Hmainid.Split('-')[0], Hmainid.Split('-')[1]);
                    oCn.RunProc(sql);
 
                }
                objJsonResult.code = "0";
                objJsonResult.count = 1;
                objJsonResult.Message = "操作成功!";
                //objJsonResult.Message = string.Join(",", HmainidList.ToArray());
                objJsonResult.data = 1;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
    }
}