1
This commit is contained in:
@@ -88,6 +88,7 @@
|
||||
"X-KDApi-AppSec": "df3e8fd75c794f11af72faa6f6df0d48",
|
||||
"X-KDApi-LCID": "2052",
|
||||
"X-KDApi-ServerUrl": "http://192.168.0.233/k3cloud/",
|
||||
"PRD_PickMtrl_Port": 1500,
|
||||
"CustomRequestRemoteSql": "",
|
||||
"VoucherGroup": "记",
|
||||
"MesSchema": "TEST",
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Kingdee.CDP.WebApi.SDK;
|
||||
using Kingdee.CDP.WebApi.SDK.DataEntity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Data.SqlClient;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
@@ -1060,7 +1061,20 @@ namespace RB_MES_API.Controllers
|
||||
Stopwatch stopwatch = new Stopwatch();
|
||||
// 开始计时
|
||||
stopwatch.Start();
|
||||
string result = LocalStaticRequest.cloudApi.BatchSave(formid, jsonstr);
|
||||
|
||||
string result = "";
|
||||
|
||||
string setPort = ApiSettingsHelper.GetConfig($"{formid}_Port");
|
||||
if (!setPort.IsNullOrEmpty())
|
||||
{
|
||||
string serverUrl = ApiSettingsHelper.GetConfig("X-KDApi-ServerUrl");
|
||||
serverUrl = ReplaceOrAddPortAdvanced(serverUrl, setPort);
|
||||
result = new K3CloudApi(serverUrl).BatchSave(formid, jsonstr);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = LocalStaticRequest.cloudApi.BatchSave(formid, jsonstr);
|
||||
}
|
||||
// 停止计时
|
||||
stopwatch.Stop();
|
||||
// 获取执行时间
|
||||
@@ -1092,6 +1106,34 @@ namespace RB_MES_API.Controllers
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 替换或添加URL中的端口号(支持指定协议)
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <param name="newPort"></param>
|
||||
/// <param name="protocol"></param>
|
||||
/// <returns></returns>
|
||||
public static string ReplaceOrAddPortAdvanced(string input, string newPort, string protocol = "http")
|
||||
{
|
||||
// 构建协议特定的模式
|
||||
string protocolPattern = string.IsNullOrEmpty(protocol) ? @"(https?|ftp)://" : $"{protocol}://";
|
||||
|
||||
// 匹配已有端口号
|
||||
string patternWithPort = $@"({protocolPattern}[^/]+?):\d+";
|
||||
// 匹配没有端口号
|
||||
string patternWithoutPort = $@"({protocolPattern}[^/:/]+)(?=/|$)";
|
||||
|
||||
// 先尝试替换已有端口号
|
||||
string result = Regex.Replace(input, patternWithPort, $"$1:{newPort}");
|
||||
|
||||
// 如果没有端口号被替换,尝试添加端口号
|
||||
if (result == input)
|
||||
result = Regex.Replace(input, patternWithoutPort, $"$1:{newPort}");
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量提交已保存的单据
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user