From 8467804705615f7614c29e7ef7ac3e99f5c13a54 Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期二, 11 二月 2025 13:53:05 +0800
Subject: [PATCH] 优化WMS接口日志记录,添加接口名称和接口描述

---
 项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_DTO/WMSInfo/RequestWMS.cs |   57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 55 insertions(+), 2 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_DTO/WMSInfo/RequestWMS.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_DTO/WMSInfo/RequestWMS.cs"
index 3597641..1eac4c7 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_DTO/WMSInfo/RequestWMS.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_DTO/WMSInfo/RequestWMS.cs"
@@ -1,13 +1,66 @@
-锘縰sing System;
+锘縰sing Newtonsoft.Json;
+using System;
 using System.Collections.Generic;
+using System.Diagnostics;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using WIDESEAWCS_Core;
+using WIDESEAWCS_Core.Helper;
+using WIDESEAWCS_Model.Models;
 
 namespace WIDESEAWCS_DTO.WMSInfo
 {
     public class RequestWMS
     {
-        
+        private static DateTime _BeginDate;
+        private static DateTime _EndDate;
+        /// <summary>
+        /// 鍚慦MS鐢宠骞惰褰曟棩蹇�
+        /// </summary>
+        /// <param name="serviceAddress">璇锋眰鍦板潃</param>
+        /// <param name="requestJson">璇锋眰鍙傛暟</param>
+        /// <param name="contentType"></param>
+        /// <param name="headers"></param>
+        /// <param name="Remark"></param>
+        /// <returns></returns>
+        public static WebResponseContent PostWMSLog(string serviceAddress, string requestJson = null, string Remark = null, string contentType = "application/json", Dictionary<string, string>? headers = null)
+        {
+            WebResponseContent content = new WebResponseContent();
+            Stopwatch stopwatch = new Stopwatch();
+            int taskSeconds = 0;
+            try
+            {
+                stopwatch.Start();
+                _BeginDate = DateTime.Now;
+                var ResultData = HttpHelper.PostAsync(serviceAddress, requestJson, contentType, headers);
+                stopwatch.Stop();
+                _EndDate = DateTime.Now;
+                if (ResultData.Result == null) throw new Exception($"{Remark}鍝嶅簲寮傚父");
+
+                content = JsonConvert.DeserializeObject<WebResponseContent>(ResultData.Result);
+            }
+            catch (Exception ex)
+            {
+                content.Error(ex.Message);
+            }
+            finally
+            {
+                taskSeconds = (int)Math.Round(stopwatch.Elapsed.TotalSeconds);
+                Dt_Interfacerecord interfacerecord = new Dt_Interfacerecord()
+                {
+                    Request = "WCS",
+                    RequestParam = requestJson,
+                    Response = "WMS",
+                    ResponseParam = content.ToJson(),
+                    Success = content.Status ? 1 : 2,
+                    BeginDate = _BeginDate,
+                    ElapsedTime = taskSeconds,
+                    EndDate = _EndDate,
+                    Url = serviceAddress,
+                };
+            }
+            return content;
+        }
     }
 }

--
Gitblit v1.9.3