服务端的TigerApi 框架,基于.NET6 2024 版本
YangYuGang
2025-04-07 7f75d4c1a1a3bd348042eb0fec8480f5df9cd1d2
Tiger.Business.WMS/ERP/WMS_U9C.cs
@@ -1,5 +1,4 @@
using Tiger.Model;
using SqlSugar;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
@@ -10,17 +9,7 @@
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
{
@@ -29,25 +18,35 @@
        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";
        /// <summary>
        /// 审核人
        /// </summary>
        public static string Reviewer = Cache.SysParam["Reviewer", "U9CUrl"].PARAM_VALUE;
        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"; 测试
        { get; set; } = "http://172.16.80.20/U9C/webapi/Receivement/CreateRcvBySrcASN"; //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"; 测试
        { get; set; } = "http://172.16.80.20/U9C/webapi/Receivement/CreateReceivement"; // ApiConfig.IsTestServer ? Cache.SysParam["CreateReceivementUrl_Test", "U9CUrl"].PARAM_VALUE : Cache.SysParam["CreateReceivementUrl", "U9CUrl"].PARAM_VALUE;  //"http://172.16.80.20/U9C/webapi/Receivement/CreateReceivement"; 测试
        public static string SubmitLineUrl
        { get; set; } = ApiConfig.IsTestServer ? Cache.SysParam["SubmitLineUrl_Test", "U9CUrl"].PARAM_VALUE : Cache.SysParam["SubmitLineUrl", "U9CUrl"].PARAM_VALUE;  //http://172.16.80.20/u9c/webapi/Receivement/SubmitLine; 测试
        { get; set; } = "http://172.16.80.20/u9c/webapi/Receivement/SubmitLine";  // ApiConfig.IsTestServer ? Cache.SysParam["SubmitLineUrl_Test", "U9CUrl"].PARAM_VALUE : Cache.SysParam["SubmitLineUrl", "U9CUrl"].PARAM_VALUE;  //http://172.16.80.20/u9c/webapi/Receivement/SubmitLine; 测试
        public static string ApproveLineUrl
        { get; set; } = ApiConfig.IsTestServer ? Cache.SysParam["ApproveLineUrl_Test", "U9CUrl"].PARAM_VALUE : Cache.SysParam["ApproveLineUrl", "U9CUrl"].PARAM_VALUE;  //http://172.16.80.20/u9c/webapi/Receivement/ApproveLine; 测试
        public static string CreateProdMaterialReqUrl
        { get; set; } = ApiConfig.IsTestServer ? Cache.SysParam["CreateProdMaterialReqUrl_Test", "U9CUrl"].PARAM_VALUE : Cache.SysParam["CreateProdMaterialReqUrl", "U9CUrl"].PARAM_VALUE; //http://172.16.80.20/u9c/webapi/IssueDoc/Create
        public static string CreateProdReturnOrderUrl
        { get; set; } = ApiConfig.IsTestServer ? Cache.SysParam["CreateProdReturnOrderUrl_Test", "U9CUrl"].PARAM_VALUE : Cache.SysParam["CreateProdReturnOrderUrl", "U9CUrl"].PARAM_VALUE; //http://172.16.80.20/u9c/webapi/IssueDoc/CreateRecedeIssueDocNew
        public static string CreateOutProdMaterialReqUrl
        { get; set; } = ApiConfig.IsTestServer ? Cache.SysParam["CreateOutProdMaterialReqUrl_Test", "U9CUrl"].PARAM_VALUE : Cache.SysParam["CreateOutProdMaterialReqUrl", "U9CUrl"].PARAM_VALUE; //http://172.16.80.20/u9c/webapi/PMIssueDoc/Create
        { get; set; } = "http://172.16.80.20/u9c/webapi/Receivement/ApproveLine"; // ApiConfig.IsTestServer ? Cache.SysParam["ApproveLineUrl_Test", "U9CUrl"].PARAM_VALUE : Cache.SysParam["ApproveLineUrl", "U9CUrl"].PARAM_VALUE;  //http://172.16.80.20/u9c/webapi/Receivement/ApproveLine; 测试
        /// <summary>
        /// 创建生产退料单-按行退料
        /// </summary>
        public static string CreateProdReturnOrderNewUrl
        { get; set; } = "http://172.16.80.20/u9c/webapi/IssueDoc/CreateRecedeIssueDocNew"; // ApiConfig.IsTestServer ? Cache.SysParam["CreateProdReturnOrderUrl_Test", "U9CUrl"].PARAM_VALUE : Cache.SysParam["CreateProdReturnOrderUrl", "U9CUrl"].PARAM_VALUE; //http://172.16.80.20/u9c/webapi/IssueDoc/CreateRecedeIssueDocNew
        /// <summary>
        /// 创建委外生产退料单
        /// </summary>
        public static string CreateOutProdReturnOrderUrl
        { get; set; } = ApiConfig.IsTestServer ? Cache.SysParam["CreateOutProdReturnOrderUrl_Test", "U9CUrl"].PARAM_VALUE : Cache.SysParam["CreateOutProdReturnOrderUrl", "U9CUrl"].PARAM_VALUE; //http://172.16.80.20/u9c/webapi/PMIssueDoc/CreateRecedeIssueDoc
        { get; set; } = "http://172.16.80.20/u9c/webapi/PMIssueDoc/CreateRecedeIssueDoc"; // ApiConfig.IsTestServer ? Cache.SysParam["CreateOutProdReturnOrderUrl_Test", "U9CUrl"].PARAM_VALUE : Cache.SysParam["CreateOutProdReturnOrderUrl", "U9CUrl"].PARAM_VALUE; //http://172.16.80.20/u9c/webapi/PMIssueDoc/CreateRecedeIssueDoc
        /// <summary>
        /// 创建调入单
        /// </summary>
        public static string CreateTransferInUrl
        { get; set; } = ApiConfig.IsTestServer ? Cache.SysParam["CreateTransferInUrl_Test", "U9CUrl"].PARAM_VALUE : Cache.SysParam["CreateTransferInUrl", "U9CUrl"].PARAM_VALUE; //http://172.16.80.20/u9c/webapi/TransferIn/Create
        { get; set; } = "http://172.16.80.20/u9c/webapi/TransferIn/Create"; // ApiConfig.IsTestServer ? Cache.SysParam["CreateTransferInUrl_Test", "U9CUrl"].PARAM_VALUE : Cache.SysParam["CreateTransferInUrl", "U9CUrl"].PARAM_VALUE; //http://172.16.80.20/u9c/webapi/TransferIn/Create
        /// <summary>
        /// 新增收货单-来源ASN单接口
        /// </summary>
@@ -69,35 +68,18 @@
                        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,
                            }
                        }
                     }
                };
                List<CreateRcvBySrcASNParam> param = new();
                param.Add(input.CreateRcvBySrcASNParam);
                var response = await HttpHelper.PostAsync(CreateRcvBySrcASNUrl, JsonConvert.SerializeObject(param), new Dictionary<string, string>() { { "token", input.token } });
                //var response = new ApiAction("{\"ResCode\":0,\"Success\":true,\"ResMsg\":null,\"Data\":[{\"IsSucess\":true,\"U9CVersion\":null,\"OtherID\":\"WMS\",\"ID\":1002503210000100,\"Code\":\"YDRC250300003\",\"ErrorMsg\":null}]}");
                var result = JsonConvert.DeserializeObject<U9CResult2>(response.Message);
                if (result != null)
                {
                    if (result.Success && result.Data[0].IsSucess)
                    {
                        action.Data = result.Data;
                        Logger.Interface.Info($"新增收货单-来源ASN单接口提交Json: {JsonConvert.SerializeObject(param)},返回Json: {response.Message}");
                       Logger.Interface.Info($"新增收货单-来源ASN单接口提交Json: {JsonConvert.SerializeObject(param)},返回Json: {response.Message}");
                    }
                    else
                    {
@@ -141,16 +123,9 @@
                    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,
                        Supplier = new() { m_code = input.Supplier },
                        RcvDocType = new() { m_code = input.RcvDocType },
                        RcvLines= input.RcvLines,
                    },
                    OtherID = "WMS"
                };
@@ -189,36 +164,12 @@
            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(ApproveLineUrl, JsonConvert.SerializeObject(input.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(input.param)},返回Json: {response.Message}");
                    }
                    else
                    {
                        action.IsSuccessed = false;
                        action.LocaleMsg = new($"{action.Message}; {result.Data[0].ErrorMsg}");
                        Logger.Interface.Info($"收货单-行审核总入口接口失败:{result.Data[0].ErrorMsg}");
                    }
                }
                action = await SubmitLine(input);
                if (action.IsSuccessed) {
                    action = await ApproveLine(input);
                }
                //action = await SubmitLine(input);
                //if (action.IsSuccessed) {
                //    input.IsLogin = false;
                //    action = await ApproveLine(input);
                //}
                action = await ApproveLine(input);
            }
            catch (System.Exception ex)
            {
@@ -249,19 +200,21 @@
                        Logger.Interface.Info($"U9C登录token: {input.token}");
                    }
                }
                var response = await HttpHelper.PostAsync(SubmitLineUrl, JsonConvert.SerializeObject(input.param), new Dictionary<string, string>() { { "token", input.token } });
                var _params = new List<SubmitLineInputParam>();
                _params.Add(input.param);
                var response = await HttpHelper.PostAsync(SubmitLineUrl, JsonConvert.SerializeObject(_params), 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.param)},返回Json: {response.Message}");
                        Logger.Interface.Info($"收货单-行提交接口提交Json: {JsonConvert.SerializeObject(_params)},返回Json: {response.Message}");
                    }
                    else
                    {
                        action.IsSuccessed = false;
                        action.LocaleMsg = new($"{action.Message}; {result.Data[0].ErrorMsg}");
                        action.LocaleMsg = new($"收货单-行提交接口失败: {result.Data[0].ErrorMsg}");
                        Logger.Interface.Info($"收货单-行提交接口失败:{result.Data[0].ErrorMsg}");
                    }
                }
@@ -288,27 +241,29 @@
                //如果已经登录则不需要再次登录,直接使用传入的token
                if (input.IsLogin)
                {
                    var u9CLoginResult = await HttpHelper.GetAsync<U9CLoginResult>($"{U9CAuthLoginUrl}userCode={input.userId}{secret}");
                    var u9CLoginResult = await HttpHelper.GetAsync<U9CLoginResult>($"{U9CAuthLoginUrl}userCode={Reviewer}{secret}");
                    if (u9CLoginResult.Success)
                    {
                        input.token = u9CLoginResult.Data;
                        Logger.Interface.Info($"U9C登录token: {input.token}");
                    }
                }
                var response = await HttpHelper.PostAsync(ApproveLineUrl, JsonConvert.SerializeObject(input.param), new Dictionary<string, string>() { { "token", input.token } });
                var _params = new List<SubmitLineInputParam>();
                _params.Add(input.param);
                var response = await HttpHelper.PostAsync(ApproveLineUrl, JsonConvert.SerializeObject(_params), 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.param)},返回Json: {response.Message}");
                        Logger.Interface.Info($"收货单-行审核接口提交Json: {JsonConvert.SerializeObject(_params)},返回Json: {response.Message}");
                    }
                    else
                    {
                        action.IsSuccessed = false;
                        action.LocaleMsg = new($"{action.Message}; {result.Data[0].ErrorMsg}");
                        Logger.Interface.Info($"收货单-行审核接口失败:{result.Data[0].ErrorMsg}");
                        action.LocaleMsg = new($"收货单 - 行审核接口失败:{result.Data[0].ErrorMsg}");
                        Logger.Interface.Info($"收货单-行审核接口提交Json: {JsonConvert.SerializeObject(_params)},失败:{result.Data[0].ErrorMsg}");
                    }
                }
            }