服务端的TigerApi 框架,基于.NET6 2024 版本
Rodney Chen
2025-04-02 a8fcfbb5e5ed9a07b1a30ef2d7ef9d407e9b04dd
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
using Tiger.Model;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using Rhea.Common;
using System.Net;
using System.Linq;
using Newtonsoft.Json;
using Tiger.IBusiness;
using Microsoft.AspNetCore.Http;
using Tiger.Model.Minsun;
using Org.BouncyCastle.Asn1.Tsp;
using Tiger.Model.Entitys.MES.Position;
using Apache.NMS.ActiveMQ.Commands;
using System.Security.Cryptography;
using System.Diagnostics;
using Tiger.Model.Entitys.MES.U9C;
using Newtonsoft.Json.Linq;
using System.Security.Policy;
using NetTaste;
 
namespace Tiger.Business.WMS
{
    public partial class WMS_U9C
    {
        public static string TransferInSubmitUrl
        { get; set; } = "http://172.16.80.20/u9c/webapi/TransferIn/Submit"; // ApiConfig.IsTestServer ? Cache.SysParam["TransferInSubmitUrl_Test", "U9CUrl"].PARAM_VALUE : Cache.SysParam["TransferInSubmitUrl", "U9CUrl"].PARAM_VALUE; //http://172.16.80.20/u9c/webapi/TransferIn/Submit
        public static string TransferInApproveUrl
        { get; set; } = "http://172.16.80.20/u9c/webapi/TransferIn/Approve"; // ApiConfig.IsTestServer ? Cache.SysParam["TransferInApproveUrl_Test", "U9CUrl"].PARAM_VALUE : Cache.SysParam["TransferInApproveUrl", "U9CUrl"].PARAM_VALUE; //http://172.16.80.20/u9c/webapi/TransferIn/Approve
 
        /// <summary>
        /// 创建调入单接口
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task<ApiAction<List<U9CReturnData>>> CreateTransferIn(CreateTransferInInput input) {
            Logger.Interface.Info($"/**\r\n *进入创建调入单接口....\r\n */\r\n"); //固定写法
            var action = new ApiAction<List<U9CReturnData>>();
            try
            {
                //如果已经登录则不需要再次登录,直接使用传入的token
                if (input.IsLogin)
                {
                    var u9CLoginResult = await HttpHelper.GetAsync<U9CLoginResult>($"{U9CAuthLoginUrl}userCode={input.userId}{secret}");
                    if (u9CLoginResult.Success)
                    {
                        input.token = u9CLoginResult.Data;
                        Logger.Interface.Info($"U9C登录token: {input.token}");
                    }
                }
 
                var response = await HttpHelper.PostAsync(CreateTransferInUrl, JsonConvert.SerializeObject(input.CreateTransferInParam), new Dictionary<string, string>() { { "token", input.token } });
                var result = JsonConvert.DeserializeObject<U9CResult>(response.Message);
                if (result != null)
                {
                    if (result.Success && result.Data[0].m_isSucess)
                    {
                        action.Data = result.Data;
                        Logger.Interface.Info($"创建调入单接口提交Json: {JsonConvert.SerializeObject(input.CreateTransferInParam)},返回Json: {response.Message}");
                    }
                    else
                    {
                        action.IsSuccessed = false;
                        action.LocaleMsg = new($"{action.Message}; {result.Data[0].m_errorMsg}");
                        Logger.Interface.Info($"创建调入单接口失败:{result.Data[0].m_errorMsg}");
                    }
                }
            }
            catch (System.Exception ex)
            {
                action.CatchExceptionWithLog(ex, "创建调入单异常");
            }
            Logger.Interface.Info($"/* 创建调入单接口结束 */\r\n"); //固定写法
            return action;
        }
 
 
 
        /// <summary>
        /// 调入单审核总入口接口
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task<ApiAction<List<U9CReturnData2>>> TransferInApprove(TransferInSubmitInput input)
        {
            Logger.Interface.Info($"/**\r\n *进入调入单审核总入口接口....\r\n */\r\n"); //固定写法
            var action = new ApiAction<List<U9CReturnData2>>();
            try
            {
                //action = await Submit(input);
                //if (action.IsSuccessed)
                //{
                //    input.IsLogin = false;
                //    action = await Approve(input);
                //}
 
                action = await Approve(input);
            }
            catch (System.Exception ex)
            {
                action.CatchExceptionWithLog(ex, "调入单审核异常");
            }
            Logger.Interface.Info($"/* 调入单审核总入口接口结束 */\r\n"); //固定写法
            return action;
        }
 
        /// <summary>
        /// 调入单提交
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        private async Task<ApiAction<List<U9CReturnData2>>> Submit(TransferInSubmitInput input)
        {
            Logger.Interface.Info($"/**\r\n *进入调入单提交接口....\r\n */\r\n"); //固定写法
            var action = new ApiAction<List<U9CReturnData2>>();
            try
            {
                //如果已经登录则不需要再次登录,直接使用传入的token
                if (input.IsLogin)
                {
                    var u9CLoginResult = await HttpHelper.GetAsync<U9CLoginResult>($"{U9CAuthLoginUrl}userCode={input.userId}{secret}");
                    if (u9CLoginResult.Success)
                    {
                        input.token = u9CLoginResult.Data;
                        Logger.Interface.Info($"U9C登录token: {input.token}");
                    }
                }
                var response = await HttpHelper.PostAsync(TransferInSubmitUrl, JsonConvert.SerializeObject(input.TransferInSubmitParam), new Dictionary<string, string>() { { "token", input.token } });
                var result = JsonConvert.DeserializeObject<U9CResult2>(response.Message);
                if (result != null)
                {
                    if (result.Success && result.Data[0].IsSucess)
                    {
                        action.Data = result.Data;
                        Logger.Interface.Info($"调入单提交接口提交Json: {JsonConvert.SerializeObject(input.TransferInSubmitParam)},返回Json: {response.Message}");
                    }
                    else
                    {
                        action.IsSuccessed = false;
                        action.LocaleMsg = new($"{action.Message}; {result.Data[0].ErrorMsg}");
                        Logger.Interface.Info($"调入单提交接口失败:{result.Data[0].ErrorMsg}");
                    }
                }
            }
            catch (System.Exception ex)
            {
                action.CatchExceptionWithLog(ex, "调入单提交异常");
            }
            Logger.Interface.Info($"/* 调入单提交接口结束 */\r\n"); //固定写法
            return action;
        }
 
        /// <summary>
        /// 调入单审核
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        private async Task<ApiAction<List<U9CReturnData2>>> Approve(TransferInSubmitInput input)
        {
            Logger.Interface.Info($"/**\r\n *进入调入单审核接口....\r\n */\r\n"); //固定写法
            var action = new ApiAction<List<U9CReturnData2>>();
            try
            {
                //如果已经登录则不需要再次登录,直接使用传入的token
                if (input.IsLogin)
                {
                    var u9CLoginResult = await HttpHelper.GetAsync<U9CLoginResult>($"{U9CAuthLoginUrl}userCode={input.userId}{secret}");
                    if (u9CLoginResult.Success)
                    {
                        input.token = u9CLoginResult.Data;
                        Logger.Interface.Info($"U9C登录token: {input.token}");
                    }
                }
                var response = await HttpHelper.PostAsync(TransferInApproveUrl, JsonConvert.SerializeObject(input.TransferInSubmitParam), new Dictionary<string, string>() { { "token", input.token } });
                var result = JsonConvert.DeserializeObject<U9CResult2>(response.Message);
                if (result != null)
                {
                    if (result.Success && result.Data[0].IsSucess)
                    {
                        action.Data = result.Data;
                        Logger.Interface.Info($"调入单审核接口提交Json: {JsonConvert.SerializeObject(input.TransferInSubmitParam)},返回Json: {response.Message}");
                    }
                    else
                    {
                        action.IsSuccessed = false;
                        action.LocaleMsg = new($"{action.Message}; {result.Data[0].ErrorMsg}");
                        Logger.Interface.Info($"调入单审核接口失败:{result.Data[0].ErrorMsg}");
                    }
                }
            }
            catch (System.Exception ex)
            {
                action.CatchExceptionWithLog(ex, "调入单审核异常");
            }
            Logger.Interface.Info($"/* 调入单审核接口结束 */\r\n"); //固定写法
            return action;
        }
    }
}