From 31313886399748bdd01b5c88977d168f4b4e31c0 Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期三, 15 四月 2026 13:51:40 +0800
Subject: [PATCH] 添加接口日志表,添加接口调用方法,api表添加推送次数,优化成品出库任务被阻碍托阻挡修改任务状态为新建重新走出库任务流程
---
代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_BasicInfoService/ApiInfoService.cs | 74 ++++++++++++++++++++++++++++++++++++
1 files changed, 73 insertions(+), 1 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 19486f1..99a8888 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"
@@ -3,8 +3,12 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using WIDESEAWCS_Core;
using WIDESEAWCS_Core.BaseRepository;
using WIDESEAWCS_Core.BaseServices;
+using WIDESEAWCS_Core.Helper;
+using WIDESEAWCS_DTO;
+using WIDESEAWCS_DTO.RGV.FOURBOT;
using WIDESEAWCS_IBasicInfoService;
using WIDESEAWCS_Model.Models;
@@ -12,10 +16,78 @@
{
public class ApiInfoService : ServiceBase<Dt_ApiInfo, IRepository<Dt_ApiInfo>>, IApiInfoService
{
- public ApiInfoService(IRepository<Dt_ApiInfo> BaseDal) : base(BaseDal)
+ private readonly IInterfaceLogService _interfaceLogService;
+ public ApiInfoService(IRepository<Dt_ApiInfo> BaseDal, IInterfaceLogService interfaceLogService) : base(BaseDal)
{
+ _interfaceLogService = interfaceLogService;
}
public IRepository<Dt_ApiInfo> Repository => BaseDal;
+
+ /// <summary>
+ /// Post鎺ュ彛璇锋眰
+ /// </summary>
+ /// <param name="apiCode">鎺ュ彛缂栧彿</param>
+ /// <param name="requestParameters">璇锋眰鍐呭</param>
+ /// <param name="remark">澶囨敞</param>
+ /// <param name="isAdd">鏄惁娣诲姞鏃ュ織</param>
+ /// <returns></returns>
+ public WebResponseContent PostInterfaceRequest(string apiCode, string requestParameters, string remark, bool isAdd = true)
+ {
+ WebResponseContent content = new WebResponseContent();
+ string response = 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("鍥涘悜杞�"))
+ {
+ FOURBOTReturn fOURBOTReturn = response.DeserializeObject<FOURBOTReturn>();
+ if (fOURBOTReturn == null) throw new Exception($"{apiInfo.Remark}鍝嶅簲鍐呭杞崲瀹炰綋澶辫触锛�");
+ if (fOURBOTReturn.returnCode != 0) throw new Exception(fOURBOTReturn.returnUserMsg);
+ content.Data = fOURBOTReturn;
+ }
+ else if (apiInfo.Remark.Contains("鍑箰澹�"))
+ {
+
+ }
+ else if (apiInfo.Remark.Contains("娴峰悍"))
+ {
+
+ }
+ else if (apiInfo.Remark.Contains("WMS"))
+ {
+
+ }
+ content.OK();
+ }
+ catch (Exception ex)
+ {
+ content.Error(ex.Message);
+ }
+ finally
+ {
+ if (isAdd && !string.IsNullOrEmpty(response) && apiInfo != null)
+ {
+ Dt_InterfaceLog interfaceLog = new Dt_InterfaceLog()
+ {
+ 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);
+ }
+ }
+ return content;
+ }
}
}
--
Gitblit v1.9.3