|
@@ -1,24 +1,33 @@
|
|
|
-using Hotline.Share.Tools;
|
|
|
+using Hotline.Orders;
|
|
|
+using Hotline.Share.Dtos.Snapshot;
|
|
|
+using Hotline.Share.Tools;
|
|
|
+using Hotline.Snapshot;
|
|
|
+using Hotline.Snapshot.Interfaces;
|
|
|
+using Mapster;
|
|
|
+using Microsoft.Extensions.Logging;
|
|
|
using Newtonsoft.Json;
|
|
|
using Renci.SshNet;
|
|
|
using System.Net.Http.Headers;
|
|
|
using System.Text;
|
|
|
+using TianQue.Sdk.Models;
|
|
|
+using XF.Domain.Dependency;
|
|
|
|
|
|
namespace TianQue.Sdk;
|
|
|
|
|
|
-public class TiqnQueService
|
|
|
+public class TiqnQueService : IGuiderSystemService, IScopeDependency
|
|
|
{
|
|
|
private readonly string appSecret = "c01eb299b9d784bf55681af4da86bab6ba428101";
|
|
|
private readonly string appKey = "TAjYAYuA";
|
|
|
+ private readonly ILogger<TQHttpClient> _logger;
|
|
|
+ private readonly string _url = "http://10.0.188.11:6090/api/v1/test/accept/saveAcceptInfoApi";
|
|
|
|
|
|
+ public TiqnQueService(ILogger<TQHttpClient> logger)
|
|
|
+ {
|
|
|
+ _logger = logger;
|
|
|
+ }
|
|
|
|
|
|
public async Task<string> PostAcceptInfo()
|
|
|
{
|
|
|
- var headers = new Dictionary<string, object>
|
|
|
- {
|
|
|
- { "_timeStamp", DateTime.Now.ToUnixTimeMilliseconds() },
|
|
|
- { "_nonce", SignUtils.GenerateNonce() }
|
|
|
- };
|
|
|
|
|
|
var bodyDic = new SortedDictionary<string, object>
|
|
|
{
|
|
@@ -26,42 +35,38 @@ public class TiqnQueService
|
|
|
{ "p1", "p1"}
|
|
|
};
|
|
|
|
|
|
- var body = bodyDic.ToJson(new JsonSerializerSettings {
|
|
|
- StringEscapeHandling = StringEscapeHandling.Default,
|
|
|
- });
|
|
|
-
|
|
|
- var postJsonSign = SignUtils.Sign(appSecret, headers, body);
|
|
|
- headers.Add("_sign", postJsonSign);
|
|
|
- headers.Add("_appKey", appKey);
|
|
|
-
|
|
|
|
|
|
- string sshHost = "171.94.154.2";
|
|
|
- int sshPort = 22;
|
|
|
- string sshUsername = "root";
|
|
|
- string sshPassword = "ZGbyy@2024!";
|
|
|
- string targetHost = "10.0.188.11";
|
|
|
- uint targetPort = 6090;
|
|
|
-
|
|
|
- // 创建 SSH 隧道
|
|
|
- var sshClient = new SshClient(sshHost, sshPort, sshUsername, sshPassword);
|
|
|
- sshClient.Connect();
|
|
|
-
|
|
|
- // 创建一个转发的端口(本地端口,目标主机,目标端口)
|
|
|
- var forwardedPort = new ForwardedPortLocal("127.0.0.1", 8090, targetHost, targetPort);
|
|
|
- sshClient.AddForwardedPort(forwardedPort);
|
|
|
- forwardedPort.Start();
|
|
|
+ return "ok";
|
|
|
+ }
|
|
|
|
|
|
- var url = "http://127.0.0.1:8090/api/v1/test/accept/saveAcceptInfoApi";
|
|
|
+ public async Task<string> PostOrder(Order order, OrderSnapshot orderSnapshot, ThirdTokenDto tokenDto)
|
|
|
+ {
|
|
|
+ TQHttpClient httpClient;
|
|
|
+#if DEBUG
|
|
|
+ httpClient = new TQHttpClient(appSecret, appKey, "171.94.154.2", 22, "root" , "ZGbyy@2024!", _logger);
|
|
|
+#else
|
|
|
+ httpClient = new TQHttpClient(appSecret, appKey, _logger);
|
|
|
+#endif
|
|
|
+ var acceptInfo = order.Adapt<AcceptInfo>();
|
|
|
+ acceptInfo.ReplyCode = order.No!; // 唯一标识
|
|
|
+ acceptInfo.OrgId = order.ActualHandleOrgAreaCode.NotNullOrEmpty() ? long.Parse(order.ActualHandleOrgAreaCode) : 0; // 区域Id
|
|
|
+ acceptInfo.DepartmentNo = order.ActualHandleOrgCode!; // 部门编码
|
|
|
+ acceptInfo.TypeName = order.AcceptType!; // 诉求类型名称
|
|
|
+ acceptInfo.OccurDate = order.CreationTime; // 事发时间
|
|
|
+ acceptInfo.DetailAddress = order.FullAddress!; // 详细地址
|
|
|
+ acceptInfo.Topic = order.Title!; // 线索主题
|
|
|
+ acceptInfo.DetailContent = order.Content!; // 详细内容
|
|
|
|
|
|
- var content = new StringContent(body, Encoding.GetEncoding("UTF-8"));
|
|
|
- content.Headers.ContentType = new MediaTypeHeaderValue("application/json") { CharSet = "UTF-8"};
|
|
|
- foreach (var header in headers)
|
|
|
+ // 反映人信息
|
|
|
+ acceptInfo.PersonList = new List<PersonInfo>
|
|
|
{
|
|
|
- content.Headers.Add(header.Key, header.Value.ToString());
|
|
|
- }
|
|
|
- var resp = await (new HttpClient()).PostAsync(url, content);
|
|
|
- resp.EnsureSuccessStatusCode();
|
|
|
- var result = await resp.Content.ReadAsStringAsync();
|
|
|
- return result;
|
|
|
+ new() {
|
|
|
+ // ReflectCardId = // 反映人身份证号
|
|
|
+ ReflectPhone = order.Contact!,
|
|
|
+ ReflectUserName = order.FromName!,
|
|
|
+ }
|
|
|
+ };
|
|
|
+ var result = await httpClient.PostAsync<ApiReponse<string>>(new Uri(_url), acceptInfo);
|
|
|
+ return result.ToJson();
|
|
|
}
|
|
|
}
|