服务端的TigerApi 框架,基于.NET6 2024 版本
Ben Lin
2025-03-18 4a06db3a52e5523db8bf0e11c9590ba29f21247d
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 CreateTransferFormUrl
        { get; set; } = "http://172.16.80.20/u9c/webapi/TransferForm/Create";  // ApiConfig.IsTestServer ? Cache.SysParam["CreateTransferFormUrl_Test", "U9CUrl"].PARAM_VALUE : Cache.SysParam["CreateTransferFormUrl", "U9CUrl"].PARAM_VALUE; //http://172.16.80.20/u9c/webapi/TransferForm/Create
        public static string TransferFormSubmitUrl
        { get; set; } = "http://172.16.80.20/u9c/webapi/TransferIn/Submit"; // ApiConfig.IsTestServer ? Cache.SysParam["TransferFormSubmitUrl_Test", "U9CUrl"].PARAM_VALUE : Cache.SysParam["TransferFormSubmitUrl", "U9CUrl"].PARAM_VALUE; //http://172.16.80.20/u9c/webapi/TransferIn/Submit
        public static string TransferFormApproveUrl
        { get; set; } = "http://172.16.80.20/u9c/webapi/TransferIn/Approve"; // ApiConfig.IsTestServer ? Cache.SysParam["TransferFormApproveUrl_Test", "U9CUrl"].PARAM_VALUE : Cache.SysParam["TransferFormApproveUrl", "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>>> CreateTransferForm(CreateTransferFormInput 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(CreateTransferFormUrl, JsonConvert.SerializeObject(input.CreateTransferFormParam), 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.CreateTransferFormParam)},返回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>>> TransferFormApprove(TransferFormSubmitInput input)
        {
            Logger.Interface.Info($"/**\r\n *进入形态转换单审核总入口接口....\r\n */\r\n"); //固定写法
            var action = new ApiAction<List<U9CReturnData2>>();
            try
            {
                action = await TransferSubmit(input);
                if (action.IsSuccessed)
                {
                    input.IsLogin = false;
                    action = await TransferApprove(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>>> TransferSubmit(TransferFormSubmitInput 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(TransferFormSubmitUrl, JsonConvert.SerializeObject(input.TransferFormSubmitParam), 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.TransferFormSubmitParam)},返回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>>> TransferApprove(TransferFormSubmitInput 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(TransferFormApproveUrl, JsonConvert.SerializeObject(input.TransferFormSubmitParam), 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.TransferFormSubmitParam)},返回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;
        }
    }
}