服务端的TigerApi 框架,基于.NET6 2024 版本
YangYuGang
2025-03-07 d2f57e228f8ba8e606d89b3501ce9558c81246dd
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
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 : IWMS_U9C
    {
        public static string U9CAuthLoginUrl { get; set; } = ApiConfig.IsTestServer ? Cache.SysParam["U9CAuthLoginUrl_Test", "U9CUrl"].PARAM_VALUE : Cache.SysParam["U9CAuthLoginUrl", "U9CUrl"].PARAM_VALUE; // "http://172.16.80.20/U9C/webapi/OAuth2/AuthLogin?"; 测试
        //public static string U9CAuthLoginUrl { get; set; } = Cache.SysParam["U9CAuthLoginUrl", "U9CUrl"].PARAM_VALUE; //正式
        public static string secret = "&entcode=02&orgcode=101&clientid=mes&clientsecret=12c8ee7e9bb74ad2a6a0fb3315c8af20";
        public static string CreateRcvBySrcASNUrl
        { get; set; } = ApiConfig.IsTestServer ? Cache.SysParam["CreateRcvBySrcASNUrl_Test", "U9CUrl"].PARAM_VALUE : Cache.SysParam["CreateRcvBySrcASNUrl", "U9CUrl"].PARAM_VALUE;  //"http://172.16.80.20/U9C/webapi/Receivement/CreateRcvBySrcASN"; 测试
        public static string CreateReceivementUrl
        { get; set; } = ApiConfig.IsTestServer ? Cache.SysParam["CreateReceivementUrl_Test", "U9CUrl"].PARAM_VALUE : Cache.SysParam["CreateReceivementUrl", "U9CUrl"].PARAM_VALUE;  //"http://172.16.80.20/U9C/webapi/Receivement/CreateReceivement"; 测试
 
        /// <summary>
        /// 新增收货单-来源ASN单接口
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task<ApiAction<CreateRcvBySrcASNInput>> CreateRcvBySrcASN(CreateRcvBySrcASNInput input)
        {
            Logger.Interface.Info($"/**\r\n *进入新增收货单-来源ASN单接口....\r\n */\r\n"); //固定写法
            var action = new ApiAction<CreateRcvBySrcASNInput>();
            try
            {
                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}");
                    }
                }
                List<CreateRcvBySrcASNParam> param = new() {
                     new() {
                        aSNToRcvTransDTOs = new(){
                            new(){
                                TransQty=new() {
                                    m_amount1= input.CurRevQty,
                                    m_uOM1 = new() {
                                        UOMMain = "1002212260110007",
                                        UOMMain_SKey=new(){
                                            ID="1002212260110007",
                                        },
                                        UOMSub_SKey = new(){
                                            ID="1002212260110007",
                                        }
                                    },
                                },
                                ASNLineKey=input.ASNLineKey,
                            }
                        }
                     }
                };
                var response = await HttpHelper.PostAsync(CreateRcvBySrcASNUrl, JsonConvert.SerializeObject(param), new Dictionary<string, string>() { { "token", input.token } });
                var result = JsonConvert.DeserializeObject<U9CResult2>(response.Message);
                if (result != null)
                {
                    if (result.Success && result.Data[0].IsSucess)
                    {
                        Logger.Interface.Info($"新增收货单-来源ASN单接口提交Json: {JsonConvert.SerializeObject(param)},返回Json: {response.Message}");
                    }
                    else
                    {
                        action.IsSuccessed = false;
                        action.LocaleMsg = new($"{action.Message}; {result.Data[0].ErrorMsg}");
                        Logger.Interface.Info($"新增收货单-来源ASN单失败:{result.Data[0].ErrorMsg}");
                    }
                }
            }
            catch (System.Exception ex)
            {
                action.CatchExceptionWithLog(ex, "新增收货单-来源ASN单异常");
            }
            Logger.Interface.Info($"/* 新增收货单-来源ASN单接口结束 */\r\n"); //固定写法
            return action;
        }
 
        public async Task<ApiAction<CreateReceivementInput>> CreateReceivement(CreateReceivementInput input)
        {
            Logger.Interface.Info($"/**\r\n *进入新增收货单-无来源接口....\r\n */\r\n"); //固定写法
            var action = new ApiAction<CreateReceivementInput>();
            try
            {
                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}");
                    }
                }
                CreateReceivementParam param = new()
                {
                    rcvDTO = new()
                    {
                        BusinessDate = DateTime.Now,
                        Supplier = new() { m_code = "C.9999" },
                        RcvDocType = new() { m_code = "RCV01" },
                        RcvLines= new() { 
                        
                        },
                        IsRcvByChangeable =true,
                        IsPriceListChangeable = true,
                        IsConfirmTermChangeable = true,
                        IsPaymentTermChangeable = true,
                        IsLineApprove= true,
                    },
                    OtherID = "WMS"
                };
                var response = await HttpHelper.PostAsync(CreateReceivementUrl, JsonConvert.SerializeObject(param), new Dictionary<string, string>() { { "token", input.token } });
                var result = JsonConvert.DeserializeObject<U9CResult2>(response.Message);
                if (result != null)
                {
                    if (result.Success && result.Data[0].IsSucess)
                    {
                        Logger.Interface.Info($"新增收货单-无来源接口提交Json: {JsonConvert.SerializeObject(param)},返回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;
        }
    }
}