任务台创建参数

usertest
嵇文龙 4 months ago
parent c1bee4dfee
commit 4f815bdf72

@ -1,48 +1,31 @@
using System.Collections.Specialized;
using System.Security;
using System.Text;
using DS.Module.Core;
using DS.Module.Core.Extensions;
using Microsoft.Extensions.Configuration;
using Newtonsoft.Json;
namespace DS.WMS.Core.Invoice.Method
namespace DS.Module.Core
{
/// <summary>
/// 提供对HTTP请求的低级别访问
/// </summary>
internal class ApiFox
public class ApiFox
{
/// <summary>
/// 发票API的基URL
/// 基URI
/// </summary>
public string? BaseUrl { get; set; }
public Uri? BaseUri { get; set; }
/// <summary>
/// 用户Key
/// 默认请求头
/// </summary>
public string? UserKey { get; set; }
public IDictionary<string, string> DefaultHeaders { get; private set; }
/// <summary>
/// 用户密钥
/// 初始化
/// </summary>
public SecureString? UserSecret { get; private set; }
public ApiFox(IConfiguration config)
public ApiFox()
{
BaseUrl = config.GetValue<string>("InvoiceApi:BaseUrl");
UserKey = config.GetValue<string>("InvoiceApi:UserKey");
string? us = config.GetValue<string>("InvoiceApi:UserSecret");
if (!us.IsNullOrEmpty())
{
UserSecret = new SecureString();
for (int i = 0; i < us.Length; i++)
UserSecret.AppendChar(us[i]);
UserSecret.MakeReadOnly();
}
us = null;
DefaultHeaders = new Dictionary<string, string>();
}
/// <summary>
@ -55,9 +38,7 @@ namespace DS.WMS.Core.Invoice.Method
/// <exception cref="ArgumentException"><paramref name="url"/>为null或空字符串</exception>
public async Task<DataResult<T>> GetAsync<T>(string url, NameValueCollection? keyValues = null)
{
ArgumentException.ThrowIfNullOrEmpty(nameof(url));
string? queryString = null;
string queryString = string.Empty;
if (keyValues != null && keyValues.Count > 0)
{
StringBuilder sb = new StringBuilder();
@ -101,8 +82,6 @@ namespace DS.WMS.Core.Invoice.Method
/// <exception cref="ArgumentException"><paramref name="url"/>为null或空字符串</exception>
public async Task<DataResult<T>> PostAsync<T>(string url, object? requestParams = null)
{
ArgumentException.ThrowIfNullOrEmpty(nameof(url));
var result = await SendRequestAsync(HttpMethod.Post, url, requestParams);
if (!result.Succeeded)
return DataResult<T>.Failed(result.Message, result.MultiCode);
@ -113,27 +92,42 @@ namespace DS.WMS.Core.Invoice.Method
}
/// <summary>
/// 发起请求
/// 发起HTTP请求
/// </summary>
/// <param name="method">请求方法</param>
/// <param name="url">请求Url</param>
/// <param name="requestParams">请求参数</param>
/// <returns></returns>
public async Task<DataResult<HttpResponseMessage>> SendRequestAsync(HttpMethod method, string url, object? requestParams = null)
/// <exception cref="ArgumentNullException"><paramref name="method"/>为null</exception>
/// <exception cref="ArgumentException"><paramref name="url"/>为null或空字符串</exception>
public virtual async Task<DataResult<HttpResponseMessage>> SendRequestAsync(HttpMethod method, string url, object? requestParams = null)
{
if (!Uri.TryCreate(BaseUrl, UriKind.RelativeOrAbsolute, out Uri? uri))
return DataResult<HttpResponseMessage>.FailedWithDesc(nameof(MultiLanguageConst.InvoiceAPIUrlNull));
ArgumentNullException.ThrowIfNull(method);
ArgumentException.ThrowIfNullOrEmpty(url);
Uri? reqUri = default;
if (BaseUri == null)
{
if (!Uri.TryCreate(url, UriKind.RelativeOrAbsolute, out Uri? uri))
throw new ArgumentException("给定的URL格式无效", nameof(url));
reqUri = new Uri(url);
}
else
{
reqUri = new(BaseUri, url);
}
HttpClient http = new();
http.DefaultRequestHeaders.Add("User-Agent", "X-HttpClient");
http.DefaultRequestHeaders.Add("User-Agent", $"X-{nameof(ApiFox)}");
if (!UserKey.IsNullOrEmpty())
http.DefaultRequestHeaders.Add("USER_KEY", UserKey);
if (DefaultHeaders.Count > 0)
foreach (var header in DefaultHeaders)
http.DefaultRequestHeaders.Add(header.Key, header.Value);
if (UserSecret != null)
http.DefaultRequestHeaders.Add("USER_SECRET", UserSecret.ToString());
if (!http.DefaultRequestHeaders.Contains("Accept"))
http.DefaultRequestHeaders.Add("Accept", "application/json, text/plain");
Uri reqUri = new(uri, url);
try
{
HttpResponseMessage? response = null;

@ -0,0 +1,46 @@
using System.Security;
using DS.Module.Core;
using DS.Module.Core.Extensions;
using Microsoft.Extensions.Configuration;
namespace DS.WMS.Core.Invoice.Method
{
/// <summary>
/// 提供对HTTP请求的低级别访问
/// </summary>
internal sealed class InvoiceApiFox : ApiFox
{
/// <summary>
/// 用户Key
/// </summary>
public string? UserKey { get; set; }
/// <summary>
/// 用户密钥
/// </summary>
public SecureString? UserSecret { get; private set; }
public InvoiceApiFox(IConfiguration config)
{
BaseUri = new Uri(config.GetValue<string>("InvoiceApi:BaseUrl"));
UserKey = config.GetValue<string>("InvoiceApi:UserKey");
string? us = config.GetValue<string>("InvoiceApi:UserSecret");
if (!us.IsNullOrEmpty())
{
UserSecret = new SecureString();
for (int i = 0; i < us.Length; i++)
UserSecret.AppendChar(us[i]);
UserSecret.MakeReadOnly();
}
us = null;
DefaultHeaders.Add("USER_KEY", UserKey ?? string.Empty);
DefaultHeaders.Add("USER_SECRET", UserSecret?.ToString());
}
}
}

@ -11,7 +11,7 @@ namespace DS.WMS.Core.Invoice.Method
/// </summary>
public sealed class InvoiceIssuanceService : ApplicationServiceBase
{
readonly ApiFox api;
readonly InvoiceApiFox api;
/// <summary>
/// 初始化并加载配置
@ -20,7 +20,7 @@ namespace DS.WMS.Core.Invoice.Method
public InvoiceIssuanceService(IServiceProvider provider) : base(provider)
{
var config = provider.GetRequiredService<IConfiguration>();
api = new ApiFox(config);
api = new InvoiceApiFox(config);
}
/// <summary>
@ -78,15 +78,19 @@ namespace DS.WMS.Core.Invoice.Method
return DataResult<string>.Failed(result.Message, result.MultiCode);
var invResult = result.Data;
if (!invResult.Success)
if (invResult.Success)
{
return DataResult<string>.Success(invResult.Data);
}
else
{
if (invResult.Code == 1)
return await InitiateAsync(invoices);
return DataResult<string>.Failed(invResult.Message);
}
return DataResult<string>.Success(invResult.Data);
}
/// <summary>

@ -0,0 +1,149 @@
using System.Runtime.Serialization;
using DS.Module.Core;
namespace DS.WMS.Core.Op.Dtos.TaskInteraction
{
/// <summary>
/// 任务台创建参数
/// </summary>
public class TaskCreation
{
[DataMember(Name = "head")]
public TaskHeader Head { get; set; }
[DataMember(Name = "main")]
public TaskMain Main { get; set; }
public TaskCreation()
{
Head = new TaskHeader();
Main = new TaskMain();
}
}
/// <summary>
/// 任务标头
/// </summary>
public class TaskHeader
{
/// <summary>
/// 流水ID
/// </summary>
[DataMember(Name = "gid")]
public Guid GID { get; set; } = Guid.NewGuid();
/// <summary>
/// 订单Id
/// </summary>
[DataMember(Name = "bsno")]
public long BSNO { get; set; }
/// <summary>
/// 消息类型
/// </summary>
[DataMember(Name = "messageType")]
public string MessageType { get; set; } = "WORK_FLOW_TASK";
[DataMember(Name = "senderId")]
public string SenderId { get; set; } = "WorkFlow";
[DataMember(Name = "senderName")]
public string SenderName { get; set; } = "工作流平台";
[DataMember(Name = "receiverId")]
public string ReceiverId { get; set; } = "TaskManage";
[DataMember(Name = "receiverName")]
public string ReceiverName { get; set; } = "任务管理平台";
/// <summary>
/// 标识符
/// </summary>
[DataMember(Name = "token")]
public string? Token { get; set; }
/// <summary>
/// 版本
/// </summary>
[DataMember(Name = "version")]
public string? Version { get; set; } = "1.0";
/// <summary>
/// 请求时间
/// </summary>
[DataMember(Name = "requestDate")]
public DateTime RequestDate { get; set; } = DateTime.Now;
[DataMember(Name = "senderKey")]
public string? SenderKey { get; set; }
[DataMember(Name = "requestAction")]
public string? RequestAction { get; set; } = "Add";
}
/// <summary>
/// 任务主信息
/// </summary>
public class TaskMain
{
/// <summary>
/// 任务类型
/// </summary>
[DataMember(Name = "taskType")]
public TaskBaseTypeEnum TaskType { get; set; }
/// <summary>
/// 任务来源
/// </summary>
[DataMember(Name = "taskSource")]
public int TaskSource { get; set; } = 9;
/// <summary>
/// 任务标题
/// </summary>
[DataMember(Name = "taskTitle")]
public string TaskTitle { get; set; } = string.Empty;
/// <summary>
/// 任务描述
/// </summary>
[DataMember(Name = "taskDesp")]
public string? TaskDescription { get; set; }
/// <summary>
/// 任务创建者ID
/// </summary>
[DataMember(Name = "taskUserId")]
public long TaskUserId { get; set; }
/// <summary>
/// 任务创建者
/// </summary>
[DataMember(Name = "taskUserName")]
public string? TaskUserName { get; set; }
/// <summary>
/// 任务接收者ID
/// </summary>
[DataMember(Name = "recvUserId")]
public long RecvUserId { get; set; }
/// <summary>
/// 任务创建者
/// </summary>
[DataMember(Name = "recvUserName")]
public string? RecvUserName { get; set; }
/// <summary>
/// 任务租户ID
/// </summary>
[DataMember(Name = "taskTenatId")]
public long TaskTenatId { get; set; }
/// <summary>
/// 任务租户
/// </summary>
[DataMember(Name = "taskTenatName")]
public string? TaskTenatName { get; set; }
}
}

@ -5,7 +5,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<Project>
<PropertyGroup>
<_PublishTargetUrl>D:\Publish\DS8\FeeApi</_PublishTargetUrl>
<History>True|2024-07-23T09:25:11.8773492Z||;True|2024-07-23T17:07:16.5460273+08:00||;True|2024-07-22T08:59:23.3235603+08:00||;True|2024-07-12T17:35:11.1225017+08:00||;True|2024-07-11T11:40:17.3581147+08:00||;True|2024-07-04T17:20:50.0175739+08:00||;True|2024-07-02T11:26:14.2092751+08:00||;True|2024-07-02T09:21:51.3513605+08:00||;True|2024-07-01T17:47:56.0407256+08:00||;True|2024-07-01T16:42:55.7374984+08:00||;True|2024-07-01T15:49:58.9266967+08:00||;True|2024-07-01T14:35:48.1117178+08:00||;True|2024-07-01T11:41:52.2969338+08:00||;True|2024-07-01T11:13:02.6561160+08:00||;True|2024-06-28T15:28:43.1470725+08:00||;True|2024-06-28T15:16:20.1999596+08:00||;True|2024-06-28T15:14:56.2534743+08:00||;True|2024-06-28T15:02:41.3033806+08:00||;True|2024-06-28T13:37:28.2462742+08:00||;True|2024-06-28T11:06:30.7400535+08:00||;True|2024-06-26T15:24:17.1939896+08:00||;True|2024-06-26T14:33:06.3530466+08:00||;True|2024-06-26T09:45:24.4055568+08:00||;True|2024-06-25T15:45:57.6052473+08:00||;True|2024-06-25T10:17:17.7408916+08:00||;False|2024-06-25T10:16:23.5639654+08:00||;False|2024-06-25T10:15:28.3857721+08:00||;False|2024-06-25T10:10:59.5536995+08:00||;False|2024-06-25T10:07:10.4050937+08:00||;True|2024-06-24T15:22:18.2672769+08:00||;True|2024-06-24T15:01:04.8153621+08:00||;False|2024-06-24T15:00:29.9618848+08:00||;True|2024-06-24T14:07:19.9401637+08:00||;False|2024-06-24T14:06:36.1250570+08:00||;True|2024-06-21T15:13:57.4273503+08:00||;True|2024-06-21T15:04:37.8218608+08:00||;True|2024-06-21T14:12:48.0266638+08:00||;True|2024-06-21T13:52:30.0950155+08:00||;True|2024-06-20T11:02:42.9508506+08:00||;True|2024-06-19T11:43:01.1899282+08:00||;True|2024-06-19T11:23:01.2938141+08:00||;True|2024-06-18T08:51:21.6222152+08:00||;True|2024-06-17T09:20:35.0804494+08:00||;True|2024-06-17T08:41:58.1319484+08:00||;True|2024-06-17T08:38:09.0137102+08:00||;True|2024-06-14T15:19:45.7395180+08:00||;True|2024-06-14T14:38:49.7094421+08:00||;True|2024-06-14T14:27:39.2815370+08:00||;True|2024-06-14T09:42:21.5397525+08:00||;True|2024-06-13T16:03:39.8475642+08:00||;True|2024-06-13T14:12:10.1725629+08:00||;True|2024-06-13T10:46:52.6971321+08:00||;True|2024-06-11T17:03:44.8328978+08:00||;True|2024-06-06T17:41:51.1810315+08:00||;True|2024-06-06T10:57:27.8273617+08:00||;True|2024-06-04T14:23:21.3742450+08:00||;True|2024-05-31T17:01:42.4717460+08:00||;True|2024-05-31T13:56:03.0734064+08:00||;True|2024-05-31T08:45:52.3549394+08:00||;True|2024-05-30T17:16:32.8907958+08:00||;True|2024-05-30T16:18:06.9957657+08:00||;True|2024-05-29T15:44:18.4051203+08:00||;True|2024-05-29T15:11:03.1518632+08:00||;True|2024-05-29T14:52:26.0823495+08:00||;True|2024-05-29T11:17:20.2245101+08:00||;True|2024-05-29T08:36:28.9569161+08:00||;True|2024-05-28T08:44:31.4427261+08:00||;False|2024-05-28T08:44:02.5254826+08:00||;True|2024-05-27T15:16:32.9413631+08:00||;True|2024-05-27T15:03:42.9803879+08:00||;True|2024-05-27T08:49:54.3933663+08:00||;True|2024-05-27T08:46:13.5862236+08:00||;True|2024-05-23T17:19:32.8154451+08:00||;True|2024-05-23T17:19:01.4587615+08:00||;True|2024-05-22T16:52:42.2166228+08:00||;True|2024-05-22T15:19:49.1773202+08:00||;True|2024-05-22T15:13:31.9485525+08:00||;True|2024-05-22T13:29:02.1355808+08:00||;True|2024-05-22T09:48:40.8753914+08:00||;True|2024-05-22T09:25:06.2068137+08:00||;True|2024-05-22T09:18:53.0759815+08:00||;True|2024-05-21T17:13:36.4091775+08:00||;True|2024-05-21T14:41:18.8486299+08:00||;True|2024-05-21T11:04:27.3649637+08:00||;</History>
<History>True|2024-07-23T09:41:01.7494842Z||;True|2024-07-23T17:25:11.8773492+08:00||;True|2024-07-23T17:07:16.5460273+08:00||;True|2024-07-22T08:59:23.3235603+08:00||;True|2024-07-12T17:35:11.1225017+08:00||;True|2024-07-11T11:40:17.3581147+08:00||;True|2024-07-04T17:20:50.0175739+08:00||;True|2024-07-02T11:26:14.2092751+08:00||;True|2024-07-02T09:21:51.3513605+08:00||;True|2024-07-01T17:47:56.0407256+08:00||;True|2024-07-01T16:42:55.7374984+08:00||;True|2024-07-01T15:49:58.9266967+08:00||;True|2024-07-01T14:35:48.1117178+08:00||;True|2024-07-01T11:41:52.2969338+08:00||;True|2024-07-01T11:13:02.6561160+08:00||;True|2024-06-28T15:28:43.1470725+08:00||;True|2024-06-28T15:16:20.1999596+08:00||;True|2024-06-28T15:14:56.2534743+08:00||;True|2024-06-28T15:02:41.3033806+08:00||;True|2024-06-28T13:37:28.2462742+08:00||;True|2024-06-28T11:06:30.7400535+08:00||;True|2024-06-26T15:24:17.1939896+08:00||;True|2024-06-26T14:33:06.3530466+08:00||;True|2024-06-26T09:45:24.4055568+08:00||;True|2024-06-25T15:45:57.6052473+08:00||;True|2024-06-25T10:17:17.7408916+08:00||;False|2024-06-25T10:16:23.5639654+08:00||;False|2024-06-25T10:15:28.3857721+08:00||;False|2024-06-25T10:10:59.5536995+08:00||;False|2024-06-25T10:07:10.4050937+08:00||;True|2024-06-24T15:22:18.2672769+08:00||;True|2024-06-24T15:01:04.8153621+08:00||;False|2024-06-24T15:00:29.9618848+08:00||;True|2024-06-24T14:07:19.9401637+08:00||;False|2024-06-24T14:06:36.1250570+08:00||;True|2024-06-21T15:13:57.4273503+08:00||;True|2024-06-21T15:04:37.8218608+08:00||;True|2024-06-21T14:12:48.0266638+08:00||;True|2024-06-21T13:52:30.0950155+08:00||;True|2024-06-20T11:02:42.9508506+08:00||;True|2024-06-19T11:43:01.1899282+08:00||;True|2024-06-19T11:23:01.2938141+08:00||;True|2024-06-18T08:51:21.6222152+08:00||;True|2024-06-17T09:20:35.0804494+08:00||;True|2024-06-17T08:41:58.1319484+08:00||;True|2024-06-17T08:38:09.0137102+08:00||;True|2024-06-14T15:19:45.7395180+08:00||;True|2024-06-14T14:38:49.7094421+08:00||;True|2024-06-14T14:27:39.2815370+08:00||;True|2024-06-14T09:42:21.5397525+08:00||;True|2024-06-13T16:03:39.8475642+08:00||;True|2024-06-13T14:12:10.1725629+08:00||;True|2024-06-13T10:46:52.6971321+08:00||;True|2024-06-11T17:03:44.8328978+08:00||;True|2024-06-06T17:41:51.1810315+08:00||;True|2024-06-06T10:57:27.8273617+08:00||;True|2024-06-04T14:23:21.3742450+08:00||;True|2024-05-31T17:01:42.4717460+08:00||;True|2024-05-31T13:56:03.0734064+08:00||;True|2024-05-31T08:45:52.3549394+08:00||;True|2024-05-30T17:16:32.8907958+08:00||;True|2024-05-30T16:18:06.9957657+08:00||;True|2024-05-29T15:44:18.4051203+08:00||;True|2024-05-29T15:11:03.1518632+08:00||;True|2024-05-29T14:52:26.0823495+08:00||;True|2024-05-29T11:17:20.2245101+08:00||;True|2024-05-29T08:36:28.9569161+08:00||;True|2024-05-28T08:44:31.4427261+08:00||;False|2024-05-28T08:44:02.5254826+08:00||;True|2024-05-27T15:16:32.9413631+08:00||;True|2024-05-27T15:03:42.9803879+08:00||;True|2024-05-27T08:49:54.3933663+08:00||;True|2024-05-27T08:46:13.5862236+08:00||;True|2024-05-23T17:19:32.8154451+08:00||;True|2024-05-23T17:19:01.4587615+08:00||;True|2024-05-22T16:52:42.2166228+08:00||;True|2024-05-22T15:19:49.1773202+08:00||;True|2024-05-22T15:13:31.9485525+08:00||;True|2024-05-22T13:29:02.1355808+08:00||;True|2024-05-22T09:48:40.8753914+08:00||;True|2024-05-22T09:25:06.2068137+08:00||;True|2024-05-22T09:18:53.0759815+08:00||;True|2024-05-21T17:13:36.4091775+08:00||;True|2024-05-21T14:41:18.8486299+08:00||;True|2024-05-21T11:04:27.3649637+08:00||;</History>
<LastFailureDetails />
</PropertyGroup>
</Project>
Loading…
Cancel
Save