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;
|
using static System.Net.WebRequestMethods;
|
|
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; } = "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; } = "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; } = "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; } = "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; 测试
|
public static string CreateProdMaterialReqUrl
|
{ get; set; } = "http://172.16.80.20/u9c/webapi/IssueDoc/Create"; // 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; } = "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
|
public static string CreateOutProdMaterialReqUrl
|
{ get; set; } = "http://172.16.80.20/u9c/webapi/PMIssueDoc/Create"; // ApiConfig.IsTestServer ? Cache.SysParam["CreateOutProdMaterialReqUrl_Test", "U9CUrl"].PARAM_VALUE : Cache.SysParam["CreateOutProdMaterialReqUrl", "U9CUrl"].PARAM_VALUE; //http://172.16.80.20/u9c/webapi/PMIssueDoc/Create
|
public static string CreateOutProdReturnOrderUrl
|
{ 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
|
public static string CreateTransferInUrl
|
{ 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>
|
/// <param name="input"></param>
|
/// <returns></returns>
|
public async Task<ApiAction<List<U9CReturnData2>>> CreateRcvBySrcASN(CreateRcvBySrcASNInput input)
|
{
|
Logger.Interface.Info($"/**\r\n *进入新增收货单-来源ASN单接口....\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}");
|
}
|
}
|
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 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}");
|
}
|
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;
|
}
|
|
/// <summary>
|
/// 新增收货单-无来源接口
|
/// </summary>
|
/// <param name="input"></param>
|
/// <returns></returns>
|
public async Task<ApiAction<List<U9CReturnData2>>> CreateReceivement(CreateReceivementInput 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}");
|
}
|
}
|
CreateReceivementParam param = new()
|
{
|
rcvDTO = new()
|
{
|
BusinessDate = DateTime.Now,
|
Supplier = new() { m_code = input.Supplier },
|
RcvDocType = new() { m_code = input.RcvDocType },
|
RcvLines= input.RcvLines,
|
},
|
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)
|
{
|
action.Data = result.Data;
|
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;
|
}
|
|
/// <summary>
|
/// 收货单-行审核总入口接口
|
/// </summary>
|
/// <param name="input"></param>
|
/// <returns></returns>
|
public async Task<ApiAction<List<U9CReturnData2>>> ReceivementApproveLine(SubmitLineInput input) {
|
Logger.Interface.Info($"/**\r\n *进入收货单-行审核总入口接口....\r\n */\r\n"); //固定写法
|
var action = new ApiAction<List<U9CReturnData2>>();
|
try
|
{
|
action = await SubmitLine(input);
|
if (action.IsSuccessed) {
|
input.IsLogin = false;
|
action = await ApproveLine(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>>> SubmitLine(SubmitLineInput 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(SubmitLineUrl, 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)
|
{
|
action.Data = result.Data;
|
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}");
|
}
|
}
|
}
|
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>>> ApproveLine(SubmitLineInput 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(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)
|
{
|
action.Data = result.Data;
|
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}");
|
}
|
}
|
}
|
catch (System.Exception ex)
|
{
|
action.CatchExceptionWithLog(ex, "收货单-行审核异常");
|
}
|
Logger.Interface.Info($"/* 收货单-行审核接口结束 */\r\n"); //固定写法
|
return action;
|
}
|
}
|
}
|