From a8367fa42d18c40407408c79e8a5fd32cd09f05c Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期二, 21 四月 2026 11:21:03 +0800
Subject: [PATCH] 更新WMS接口文档,添加修改出入口站台类型接口,优化接口日志记录方法
---
代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_BasicInfoService/ApiInfoService.cs | 90 ++++++++++++++++++++++++++++++++++++---------
1 files changed, 72 insertions(+), 18 deletions(-)
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_BasicInfoService/ApiInfoService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_BasicInfoService/ApiInfoService.cs"
index 99a8888..f856096 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_BasicInfoService/ApiInfoService.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_BasicInfoService/ApiInfoService.cs"
@@ -1,6 +1,7 @@
锘縰sing System;
using System.Collections.Generic;
using System.Linq;
+using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using WIDESEAWCS_Core;
@@ -9,6 +10,7 @@
using WIDESEAWCS_Core.Helper;
using WIDESEAWCS_DTO;
using WIDESEAWCS_DTO.RGV.FOURBOT;
+using WIDESEAWCS_DTO.WMS;
using WIDESEAWCS_IBasicInfoService;
using WIDESEAWCS_Model.Models;
@@ -36,12 +38,16 @@
{
WebResponseContent content = new WebResponseContent();
string response = string.Empty;
+ string requestHash = string.Empty;
+ string responseHash = string.Empty;
Dt_ApiInfo? apiInfo = null;
try
{
apiInfo = BaseDal.QueryFirst(x => x.ApiCode == apiCode) ?? throw new Exception($"鏈壘鍒皗remark}鎺ュ彛閰嶇疆淇℃伅锛佽妫�鏌ユ帴鍙i厤缃�");
response = HttpHelper.Post(apiInfo.ApiAddress, requestParameters);
- if (apiInfo.Remark.Contains("鍥涘悜杞�"))
+ requestHash = ComputeHash(requestParameters);
+ responseHash = ComputeHash(response);
+ if (apiInfo.Remark.Contains("鍥涘悜绌挎杞�"))
{
FOURBOTReturn fOURBOTReturn = response.DeserializeObject<FOURBOTReturn>();
if (fOURBOTReturn == null) throw new Exception($"{apiInfo.Remark}鍝嶅簲鍐呭杞崲瀹炰綋澶辫触锛�");
@@ -50,15 +56,24 @@
}
else if (apiInfo.Remark.Contains("鍑箰澹�"))
{
-
+ GALAXISReturn gALAXISReturn = response.DeserializeObject<GALAXISReturn>();
+ if (gALAXISReturn == null) throw new Exception($"{apiInfo.Remark}鍝嶅簲鍐呭杞崲瀹炰綋澶辫触");
+ if (gALAXISReturn.data.returnStatus != 0) throw new Exception(gALAXISReturn.data.returnInfo);
+ content.Data = gALAXISReturn;
}
else if (apiInfo.Remark.Contains("娴峰悍"))
{
-
+ HIKROBOTReturn hIKROBOTReturn = response.DeserializeObject<HIKROBOTReturn>();
+ if (hIKROBOTReturn == null) throw new Exception($"{apiInfo.Remark}鍝嶅簲鍐呭杞崲瀹炰綋澶辫触");
+ if (hIKROBOTReturn.code != "SUCCESS") throw new Exception(hIKROBOTReturn.message);
+ content.Data = hIKROBOTReturn;
}
else if (apiInfo.Remark.Contains("WMS"))
{
-
+ WMSReturn wMSReturn = response.DeserializeObject<WMSReturn>();
+ if (wMSReturn == null) throw new Exception($"{apiInfo.Remark}鍝嶅簲鍐呭杞崲瀹炰綋澶辫触");
+ if (wMSReturn.code != 200) throw new Exception(wMSReturn.message);
+ content.Data = wMSReturn;
}
content.OK();
}
@@ -70,24 +85,63 @@
{
if (isAdd && !string.IsNullOrEmpty(response) && apiInfo != null)
{
- Dt_InterfaceLog interfaceLog = new Dt_InterfaceLog()
+ #region 鏌ヨ褰撳ぉ鏄惁瀛樺湪鐩稿悓璁板綍
+ var today = DateTime.Now.Date;
+ var existingLog = _interfaceLogService.Repository.QueryFirst(x =>
+ x.ApiCode == apiCode &&
+ x.RequestParametersHash == requestHash &&
+ x.ResponseParametersHash == responseHash &&
+ x.CreateDate.Date == today);
+ if (existingLog != null)
{
- ApiCode = apiCode,
- RequestParameters = requestParameters,
- ApiAddress = apiInfo.ApiAddress,
- ApiName = apiInfo.ApiName,
- PushFrequency = 1,
- PushState = content.Status ? 1 : 2,
- Requestor = "WCS",
- Recipient = apiInfo.Remark,
- ResponseParameters = response,
- Creater = "System",
- Remark = content.Status ? remark : content.Message,
- };
- _interfaceLogService.Repository.AddData(interfaceLog);
+ existingLog.PushFrequency = existingLog.PushFrequency + 1;
+ existingLog.PushState = content.Status ? 1 : 2;
+ existingLog.ResponseParameters = response;
+ existingLog.Remark = content.Status ? remark : content.Message;
+ existingLog.Modifier = App.User?.UserName ?? "System";
+ existingLog.ModifyDate = DateTime.Now;
+ _interfaceLogService.Repository.UpdateData(existingLog);
+ }
+ #endregion
+ else
+ {
+ Dt_InterfaceLog interfaceLog = new Dt_InterfaceLog()
+ {
+ ApiCode = apiCode,
+ RequestParameters = requestParameters,
+ ApiAddress = apiInfo.ApiAddress,
+ ApiName = apiInfo.ApiName,
+ RequestParametersHash = requestHash,
+ ResponseParametersHash = responseHash,
+ PushFrequency = 1,
+ PushState = content.Status ? 1 : 2,
+ Requestor = "WCS",
+ Recipient = apiInfo.Remark,
+ ResponseParameters = response,
+ Creater = "System",
+ Remark = content.Status ? remark : content.Message,
+ };
+ _interfaceLogService.Repository.AddData(interfaceLog);
+ }
}
}
return content;
}
+
+ /// <summary>
+ /// 璁$畻瀛楃涓茬殑SHA256鍝堝笇鍊�
+ /// </summary>
+ private static string ComputeHash(string input)
+ {
+ if (string.IsNullOrEmpty(input))
+ return string.Empty;
+
+ using (SHA256 sha256 = SHA256.Create())
+ {
+ byte[] bytes = Encoding.UTF8.GetBytes(input);
+ byte[] hashBytes = sha256.ComputeHash(bytes);
+ return BitConverter.ToString(hashBytes).Replace("-", "").ToLower();
+ }
+ }
}
}
--
Gitblit v1.9.3