<update>[important]将api配置单独创建表
This commit is contained in:
parent
648b9ddbd7
commit
60fa5d7c97
|
|
@ -21,34 +21,6 @@ public class AppConfigEntity
|
|||
public string? WcsId { get; set; }
|
||||
|
||||
|
||||
/***************************** API信息 *************************************/
|
||||
|
||||
/// <summary>
|
||||
/// Wms 的根地址
|
||||
/// </summary>
|
||||
[ConfigKey("WmsBaseApiAddress")]
|
||||
public string? WmsBaseAddressApiAddress { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 请求入库的地址
|
||||
/// </summary>
|
||||
[ConfigKey("ApplyEnterApiAddress")]
|
||||
public string? ApplyEnterApiAddress { get; set;}
|
||||
|
||||
/// <summary>
|
||||
/// 发送 Wms 任务状态
|
||||
/// </summary>
|
||||
[ConfigKey("SendWmsTaskStatusApiAddress")]
|
||||
public string? SendWmsTaskStatusApiAddress { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 上报载具到达
|
||||
/// </summary>
|
||||
[ConfigKey("VehicleArriveApiAddress")]
|
||||
public string? VehicleArriveApiAddress { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
/****************************** 功能配置 ******************************/
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ using WcsMain.Common;
|
|||
using WcsMain.DataBase.Dao;
|
||||
using WcsMain.DataBase.TableEntity;
|
||||
using WcsMain.Enum;
|
||||
using WcsMain.ExtendMethod;
|
||||
using WcsMain.Plugins;
|
||||
using WcsMain.WcsAttribute.AutoFacAttribute;
|
||||
|
||||
|
|
@ -52,7 +53,7 @@ public class SendWmsTaskStatus(AppWmsTaskDao wmsTaskDao, WmsWebApiPost wmsWebApi
|
|||
};
|
||||
for (int i = 1; i <= count; i++)
|
||||
{
|
||||
var response = wmsWebApiPost.HttpPost<SendWmsTaskStatusRequest, WmsResponse>(request, CommonData.AppConfig.SendWmsTaskStatusApiAddress ?? "");
|
||||
var response = wmsWebApiPost.HttpPost<SendWmsTaskStatusRequest, WmsResponse>(request, CommonData.AppApiBaseInfos.GetAddress("SendWmsTaskStatusApiAddress") ?? "");
|
||||
if (!response.IsSend)
|
||||
{
|
||||
ConsoleLog.Error($"【异常】发送WMS[任务异常]失败,发送次数:{i},任务号:{wmsTask.TaskId},参考信息:{response.RequestException?.Message}");
|
||||
|
|
@ -110,7 +111,7 @@ public class SendWmsTaskStatus(AppWmsTaskDao wmsTaskDao, WmsWebApiPost wmsWebApi
|
|||
};
|
||||
for (int i = 1; i <= count; i++)
|
||||
{
|
||||
var response = wmsWebApiPost.HttpPost<SendWmsTaskStatusRequest, WmsResponse>(request, CommonData.AppConfig.SendWmsTaskStatusApiAddress ?? "");
|
||||
var response = wmsWebApiPost.HttpPost<SendWmsTaskStatusRequest, WmsResponse>(request, CommonData.AppApiBaseInfos.GetAddress("SendWmsTaskStatusApiAddress") ?? "");
|
||||
if (!response.IsSend)
|
||||
{
|
||||
ConsoleLog.Error($"【异常】发送WMS[取货位置无货]失败,发送次数:{i},任务号:{wmsTask.TaskId},参考信息:{response.RequestException?.Message}");
|
||||
|
|
@ -168,7 +169,7 @@ public class SendWmsTaskStatus(AppWmsTaskDao wmsTaskDao, WmsWebApiPost wmsWebApi
|
|||
};
|
||||
for (int i = 1; i <= count; i++)
|
||||
{
|
||||
var response = wmsWebApiPost.HttpPost<SendWmsTaskStatusRequest, WmsResponse>(request, CommonData.AppConfig.SendWmsTaskStatusApiAddress ?? "");
|
||||
var response = wmsWebApiPost.HttpPost<SendWmsTaskStatusRequest, WmsResponse>(request, CommonData.AppApiBaseInfos.GetAddress("SendWmsTaskStatusApiAddress") ?? "");
|
||||
if (!response.IsSend)
|
||||
{
|
||||
ConsoleLog.Error($"【异常】发送WMS[卸货位置有货]失败,发送次数:{i},任务号:{wmsTask.TaskId},参考信息:{response.RequestException?.Message}");
|
||||
|
|
@ -227,7 +228,7 @@ public class SendWmsTaskStatus(AppWmsTaskDao wmsTaskDao, WmsWebApiPost wmsWebApi
|
|||
};
|
||||
for (int i = 1; i <= count; i++)
|
||||
{
|
||||
var response = wmsWebApiPost.HttpPost<SendWmsTaskStatusRequest, WmsResponse>(request, CommonData.AppConfig.SendWmsTaskStatusApiAddress ?? "");
|
||||
var response = wmsWebApiPost.HttpPost<SendWmsTaskStatusRequest, WmsResponse>(request, CommonData.AppApiBaseInfos.GetAddress("SendWmsTaskStatusApiAddress") ?? "");
|
||||
if (!response.IsSend)
|
||||
{
|
||||
ConsoleLog.Error($"【异常】发送WMS[开始执行]失败,发送次数:{i},任务号:{wmsTask.TaskId},参考信息:{response.RequestException?.Message}");
|
||||
|
|
@ -285,7 +286,7 @@ public class SendWmsTaskStatus(AppWmsTaskDao wmsTaskDao, WmsWebApiPost wmsWebApi
|
|||
};
|
||||
for (int i = 1; i <= count; i++)
|
||||
{
|
||||
var response = wmsWebApiPost.HttpPost<SendWmsTaskStatusRequest, WmsResponse>(request, CommonData.AppConfig.SendWmsTaskStatusApiAddress ?? "");
|
||||
var response = wmsWebApiPost.HttpPost<SendWmsTaskStatusRequest, WmsResponse>(request, CommonData.AppApiBaseInfos.GetAddress("SendWmsTaskStatusApiAddress") ?? "");
|
||||
if (!response.IsSend)
|
||||
{
|
||||
ConsoleLog.Error($"【异常】发送WMS[任务完成]失败,发送次数:{i},任务号:{wmsTask.TaskId},参考信息:{response.RequestException?.Message}");
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ public class LoginGetData(WmsWebApiPost wmsWebApiPost) : IBaseGetData
|
|||
}
|
||||
/* 发送 WMS 请求入库 */
|
||||
ApplyInRequest applyInRequest = new(area, code, msg);
|
||||
var postResult = wmsWebApiPost.HttpPost<ApplyInRequest, WmsResponse>(applyInRequest, CommonData.AppConfig.ApplyEnterApiAddress ?? "");
|
||||
var postResult = wmsWebApiPost.HttpPost<ApplyInRequest, WmsResponse>(applyInRequest, CommonData.AppApiBaseInfos.GetAddress("ApplyEnterApiAddress") ?? "");
|
||||
if(!postResult.IsSend || postResult.ResponseEntity == default)
|
||||
{
|
||||
ConsoleLog.Exception($"【异常】注册口:{area} 箱码:{msg} 请求入库发生异常,异常信息:{postResult.RequestException}");
|
||||
|
|
|
|||
|
|
@ -46,6 +46,12 @@ public static class CommonData
|
|||
/// </summary>
|
||||
[NotNull]
|
||||
public static List<AppConveyStand>? AppConveyStands { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 基础 api 资料
|
||||
/// </summary>
|
||||
[NotNull]
|
||||
public static List<AppApiBaseInfo>? AppApiBaseInfos { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
28
WcsMain/DataBase/Dao/AppApiBaseInfoDao.cs
Normal file
28
WcsMain/DataBase/Dao/AppApiBaseInfoDao.cs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
using WcsMain.Common;
|
||||
using WcsMain.DataBase.TableEntity;
|
||||
using WcsMain.WcsAttribute.AutoFacAttribute;
|
||||
|
||||
namespace WcsMain.DataBase.Dao;
|
||||
|
||||
[Component]
|
||||
public class AppApiBaseInfoDao
|
||||
{
|
||||
/// <summary>
|
||||
/// 查询所有信息
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<AppApiBaseInfo>? Query()
|
||||
{
|
||||
try
|
||||
{
|
||||
var sqlFuc = CommonTool.DbServe.Queryable<AppApiBaseInfo>();
|
||||
return sqlFuc.ToList();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_ = e;
|
||||
return default;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
48
WcsMain/DataBase/TableEntity/AppApiBaseInfo.cs
Normal file
48
WcsMain/DataBase/TableEntity/AppApiBaseInfo.cs
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
using SqlSugar;
|
||||
|
||||
namespace WcsMain.DataBase.TableEntity;
|
||||
|
||||
/// <summary>
|
||||
/// API 基础资料表
|
||||
/// </summary>
|
||||
[SugarTable("tbl_app_api_base_info")]
|
||||
public class AppApiBaseInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// API 键
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "api_key", IsPrimaryKey = true)]
|
||||
public string? ApiKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 系统名称
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "system_name")]
|
||||
public string? SystemName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 地址类型
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "address_type")]
|
||||
public int? AddressType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 地址值
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "address")]
|
||||
public string? Address { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// API 名称
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "api_name")]
|
||||
public string? ApiName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "remark")]
|
||||
public string? Remark { get; set; }
|
||||
|
||||
|
||||
}
|
||||
19
WcsMain/ExtendMethod/AppApiBaseInfoExtendMethod.cs
Normal file
19
WcsMain/ExtendMethod/AppApiBaseInfoExtendMethod.cs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
using WcsMain.DataBase.TableEntity;
|
||||
|
||||
namespace WcsMain.ExtendMethod;
|
||||
|
||||
public static class AppApiBaseInfoExtendMethod
|
||||
{
|
||||
/// <summary>
|
||||
/// 根据键名查找一个api地址
|
||||
/// </summary>
|
||||
/// <param name="baseData"></param>
|
||||
/// <param name="apiKey"></param>
|
||||
/// <returns></returns>
|
||||
public static string? GetAddress(this List<AppApiBaseInfo>? baseData, string apiKey)
|
||||
{
|
||||
var baseInfo = baseData?.Find(f => f.ApiKey == apiKey);
|
||||
return baseInfo?.Address;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
using ApiTool;
|
||||
using WcsMain.Business.CommonAction;
|
||||
using WcsMain.Common;
|
||||
using WcsMain.ExtendMethod;
|
||||
using WcsMain.WcsAttribute.AutoFacAttribute;
|
||||
|
||||
namespace WcsMain.Plugins;
|
||||
|
|
@ -14,6 +15,6 @@ public class WmsWebApiPost : WebApiPost
|
|||
public WmsWebApiPost(WMSApiResponseAction wmsApiResponseAction)
|
||||
{
|
||||
SetResponseAction(wmsApiResponseAction.WMSApiResponse);
|
||||
SetBaseUrl(CommonData.AppConfig.WmsBaseAddressApiAddress ?? "");
|
||||
SetBaseUrl(CommonData.AppApiBaseInfos.GetAddress("WmsBaseApiAddress") ?? "");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
"WcsMain": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"launchBrowser": false,
|
||||
"launchUrl": "swagger",
|
||||
"applicationUrl": "http://localhost:890",
|
||||
"environmentVariables": {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ namespace WcsMain.StartAction;
|
|||
[Component]
|
||||
public class ServiceStart(WcsCirculation wcsCirculation, ConnectPLCs connectPLCs, SocketOperation socketOperation,
|
||||
AppStackerDao appStackerDao, AppLocationDao appLocationDao, AppConfigDao appConfigDao, ConnectPlcServe connectPlcServe,
|
||||
ConnectOprServe connectOprServe, AppElTagLocationDao appElTagBaseDao, AppConveyStandDao conveyStandDao)
|
||||
ConnectOprServe connectOprServe, AppElTagLocationDao appElTagBaseDao, AppConveyStandDao conveyStandDao, AppApiBaseInfoDao appApiBaseInfoDao)
|
||||
{
|
||||
private static string _errMsg = string.Empty;
|
||||
|
||||
|
|
@ -29,10 +29,12 @@ public class ServiceStart(WcsCirculation wcsCirculation, ConnectPLCs connectPLCs
|
|||
public void LoadingData()
|
||||
{
|
||||
LoadingConfig(); // 加载数据库中的配置项 (config 表)
|
||||
LoadApiBaseInfo(); // 加载API基础资料
|
||||
LoadingStackerData(); // 加载数据库中的堆垛机信息
|
||||
LoadingLocationData(); // 加载数据库中的库位信息
|
||||
LoadElTagBase(); // 加载电子标签基础资料
|
||||
LoadConveyStand(); // 加载输送线站台基础资料
|
||||
|
||||
|
||||
if (!string.IsNullOrEmpty(_errMsg))
|
||||
{
|
||||
|
|
@ -52,13 +54,13 @@ public class ServiceStart(WcsCirculation wcsCirculation, ConnectPLCs connectPLCs
|
|||
CreatePlcClient(); // 连接 PLC 客户端
|
||||
CreateSocketClient(); // Socket客户端
|
||||
ConnectOprServe(); // 连接 Opr 电子标签客户端
|
||||
CreateCieculateTask();// 创建并启用定时器
|
||||
CreateCirculateTask();// 创建并启用定时器
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建并连接 Plc
|
||||
/// </summary>
|
||||
public void CreatePlcClient()
|
||||
private void CreatePlcClient()
|
||||
{
|
||||
if (CommonData.AppConfig.UseConnectPlc == "1") // 1 表示允许连接PLC
|
||||
{
|
||||
|
|
@ -69,7 +71,7 @@ public class ServiceStart(WcsCirculation wcsCirculation, ConnectPLCs connectPLCs
|
|||
/// <summary>
|
||||
/// 创建并运行 Socket 客户端 ---- 待更新
|
||||
/// </summary>
|
||||
public void CreateSocketClient()
|
||||
private void CreateSocketClient()
|
||||
{
|
||||
if (CommonData.AppConfig.UseSocket == "1") // 1 表示允许开启Socket
|
||||
{
|
||||
|
|
@ -80,7 +82,7 @@ public class ServiceStart(WcsCirculation wcsCirculation, ConnectPLCs connectPLCs
|
|||
/// <summary>
|
||||
/// 连接Opr电子标签客户端
|
||||
/// </summary>
|
||||
public void ConnectOprServe()
|
||||
private void ConnectOprServe()
|
||||
{
|
||||
if (CommonData.AppConfig.UseOpr == "1") // 1 表示允许连接电子标签
|
||||
{
|
||||
|
|
@ -101,7 +103,7 @@ public class ServiceStart(WcsCirculation wcsCirculation, ConnectPLCs connectPLCs
|
|||
/// <summary>
|
||||
/// 创建并启用定时器
|
||||
/// </summary>
|
||||
public void CreateCieculateTask()
|
||||
private void CreateCirculateTask()
|
||||
{
|
||||
if (CommonData.AppConfig.UseCirculation == "1") // 1 表示允许开启 定时器
|
||||
{
|
||||
|
|
@ -121,7 +123,7 @@ public class ServiceStart(WcsCirculation wcsCirculation, ConnectPLCs connectPLCs
|
|||
/// <summary>
|
||||
/// 加载数据库内的 Config 配置信息
|
||||
/// </summary>
|
||||
public void LoadingConfig()
|
||||
private void LoadingConfig()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(_errMsg)) return;
|
||||
//ConsoleLog.Info("正在加载数据库配置信息...");
|
||||
|
|
@ -153,10 +155,28 @@ public class ServiceStart(WcsCirculation wcsCirculation, ConnectPLCs connectPLCs
|
|||
CommonData.AppConfig = appConfigEntity;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载API基础资料
|
||||
/// </summary>
|
||||
private void LoadApiBaseInfo()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(_errMsg)) return;
|
||||
//ConsoleLog.Info("正在加载API配置信息...");
|
||||
List<AppApiBaseInfo>? appApiBaseInfos = appApiBaseInfoDao.Query();
|
||||
if (appApiBaseInfos == default)
|
||||
{
|
||||
_errMsg = "加载API配置信息失败,请检查数据库服务器连接是否正常";
|
||||
CommonData.AppApiBaseInfos = [];
|
||||
return;
|
||||
}
|
||||
CommonData.AppApiBaseInfos = appApiBaseInfos;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 加载堆垛机数据
|
||||
/// </summary>
|
||||
public void LoadingStackerData()
|
||||
private void LoadingStackerData()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(_errMsg)) return;
|
||||
//ConsoleLog.Info("正在加载堆垛机参数信息...");
|
||||
|
|
@ -174,7 +194,7 @@ public class ServiceStart(WcsCirculation wcsCirculation, ConnectPLCs connectPLCs
|
|||
/// <summary>
|
||||
/// 加载库位信息
|
||||
/// </summary>
|
||||
public void LoadingLocationData()
|
||||
private void LoadingLocationData()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(_errMsg)) return;
|
||||
//ConsoleLog.Info("正在加载库位信息...");
|
||||
|
|
@ -191,7 +211,7 @@ public class ServiceStart(WcsCirculation wcsCirculation, ConnectPLCs connectPLCs
|
|||
/// <summary>
|
||||
/// 加载电子标签基础资料
|
||||
/// </summary>
|
||||
public void LoadElTagBase()
|
||||
private void LoadElTagBase()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(_errMsg)) return;
|
||||
//ConsoleLog.Info("正在电子标签基础资料信息...");
|
||||
|
|
@ -209,7 +229,7 @@ public class ServiceStart(WcsCirculation wcsCirculation, ConnectPLCs connectPLCs
|
|||
/// <summary>
|
||||
/// 加载输送线站台基础资料信息
|
||||
/// </summary>
|
||||
public void LoadConveyStand()
|
||||
private void LoadConveyStand()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(_errMsg)) return;
|
||||
//ConsoleLog.Info("正在加载输送线基础资料信息...");
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user