From e8de46acfd30dab344ef529a76c04bce6410ecf1 Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期五, 27 三月 2026 17:32:37 +0800
Subject: [PATCH] feat(MES): 新增陕西顷刻能源科技MES系统对接服务
---
Code/WMS/WIDESEA_WMSServer/WIDESEA_DTO/MES/MesResponseDto.cs | 23 +++
Code/WMS/WIDESEA_WMSServer/WIDESEA_DTO/MES/MesRequestDto.cs | 243 ++++++++++++++++++++++++++++++++++
Code/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/WIDESEA_BasicService.csproj | 1
Code/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/appsettings.json | 4
Code/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/MesService.cs | 77 +++++++++++
Code/WMS/WIDESEA_WMSServer/WIDESEA_IBasicService/IMesService.cs | 37 +++++
6 files changed, 385 insertions(+), 0 deletions(-)
diff --git a/Code/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/MesService.cs b/Code/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/MesService.cs
new file mode 100644
index 0000000..79bd0bd
--- /dev/null
+++ b/Code/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/MesService.cs
@@ -0,0 +1,77 @@
+using Newtonsoft.Json;
+using System.Collections.Generic;
+using WIDESEA_Core;
+using WIDESEA_Core.Helper;
+using WIDESEA_IBasicService;
+using WIDESEA_DTO.MES;
+
+namespace WIDESEA_BasicService
+{
+ /// <summary>
+ /// MES鏈嶅姟瀹炵幇 - 闄曡タ椤峰埢鑳芥簮绉戞妧MES绯荤粺瀵规帴
+ /// </summary>
+ public class MesService : IMesService
+ {
+ private readonly HttpClientHelper _httpClient;
+ private readonly string _baseUrl;
+ private readonly string _authorization;
+
+ private const string BindContainerPath = "/EquipmentService/api/v1/BindContainer";
+ private const string UnBindContainerPath = "/EquipmentService/api/v1/UnBindContainer";
+ private const string ContainerNgReportPath = "/EquipmentService/api/v1/ContainerNgReport";
+ private const string InboundInContainerPath = "/EquipmentService/api/v1/InboundInContainer";
+ private const string OutboundInContainerPath = "/EquipmentService/api/v1/OutboundInContainer";
+
+ public MesService(HttpClientHelper httpClient)
+ {
+ _httpClient = httpClient;
+ _baseUrl = AppSettings.Get("MES:BaseUrl").TrimEnd('/');
+ _authorization = AppSettings.Get("MES:Authorization");
+ }
+
+ private HttpRequestConfig BuildConfig()
+ {
+ return new HttpRequestConfig
+ {
+ Headers = new Dictionary<string, string>
+ {
+ { "Authorization", _authorization }
+ },
+ TimeoutMs = 30000,
+ MaxRetryCount = 0,
+ EnableLogging = true
+ };
+ }
+
+ private HttpResponseResult<MesResponse> Post<T>(string url, T request)
+ {
+ string json = JsonConvert.SerializeObject(request);
+ return _httpClient.Post<MesResponse>(url, json, "application/json", BuildConfig());
+ }
+
+ public HttpResponseResult<MesResponse> BindContainer(BindContainerRequest request)
+ {
+ return Post(_baseUrl + BindContainerPath, request);
+ }
+
+ public HttpResponseResult<MesResponse> UnBindContainer(UnBindContainerRequest request)
+ {
+ return Post(_baseUrl + UnBindContainerPath, request);
+ }
+
+ public HttpResponseResult<MesResponse> ContainerNgReport(ContainerNgReportRequest request)
+ {
+ return Post(_baseUrl + ContainerNgReportPath, request);
+ }
+
+ public HttpResponseResult<MesResponse> InboundInContainer(InboundInContainerRequest request)
+ {
+ return Post(_baseUrl + InboundInContainerPath, request);
+ }
+
+ public HttpResponseResult<MesResponse> OutboundInContainer(OutboundInContainerRequest request)
+ {
+ return Post(_baseUrl + OutboundInContainerPath, request);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Code/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/WIDESEA_BasicService.csproj b/Code/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/WIDESEA_BasicService.csproj
index 555f689..276a598 100644
--- a/Code/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/WIDESEA_BasicService.csproj
+++ b/Code/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/WIDESEA_BasicService.csproj
@@ -9,6 +9,7 @@
<ItemGroup>
<ProjectReference Include="..\WIDESEA_IBasicService\WIDESEA_IBasicService.csproj" />
<ProjectReference Include="..\WIDESEA_IRecordService\WIDESEA_IRecordService.csproj" />
+ <ProjectReference Include="..\WIDESEA_Core\WIDESEA_Core.csproj" />
</ItemGroup>
</Project>
diff --git a/Code/WMS/WIDESEA_WMSServer/WIDESEA_DTO/MES/MesRequestDto.cs b/Code/WMS/WIDESEA_WMSServer/WIDESEA_DTO/MES/MesRequestDto.cs
new file mode 100644
index 0000000..c118686
--- /dev/null
+++ b/Code/WMS/WIDESEA_WMSServer/WIDESEA_DTO/MES/MesRequestDto.cs
@@ -0,0 +1,243 @@
+using System;
+using System.Collections.Generic;
+
+namespace WIDESEA_DTO.MES
+{
+ #region 鎵樼洏鐢佃姱缁戝畾
+
+ /// <summary>
+ /// 鎵樼洏鐢佃姱缁戝畾 - 璇锋眰
+ /// </summary>
+ public class BindContainerRequest
+ {
+ /// <summary>
+ /// 璁惧缂栫爜
+ /// </summary>
+ public string EquipmentCode { get; set; }
+
+ /// <summary>
+ /// 璧勬簮缂栫爜
+ /// </summary>
+ public string ResourceCode { get; set; }
+
+ /// <summary>
+ /// 璋冪敤鏈湴鏃堕棿
+ /// </summary>
+ public DateTime LocalTime { get; set; }
+
+ /// <summary>
+ /// 鎵樼洏鐮�
+ /// </summary>
+ public string ContainerCode { get; set; }
+
+ /// <summary>
+ /// 缁戝畾鐨勭數鑺潯鐮佸垪琛�
+ /// </summary>
+ public List<ContainerSfcItem> ContainerSfcList { get; set; }
+
+ /// <summary>
+ /// 鎿嶄綔绫诲瀷锛�0-榛樿 1-杩涚珯 2-鍑虹珯 3-杩涘嚭绔�
+ /// </summary>
+ public int OperationType { get; set; }
+ }
+
+ /// <summary>
+ /// 鎵樼洏鐢佃姱椤�
+ /// </summary>
+ public class ContainerSfcItem
+ {
+ /// <summary>
+ /// 鐢佃姱鐮�
+ /// </summary>
+ public string Sfc { get; set; }
+
+ /// <summary>
+ /// 浣嶇疆淇℃伅
+ /// </summary>
+ public string Location { get; set; }
+ }
+
+ #endregion
+
+ #region 鎵樼洏鐢佃姱瑙g粦
+
+ /// <summary>
+ /// 鎵樼洏鐢佃姱瑙g粦 - 璇锋眰
+ /// </summary>
+ public class UnBindContainerRequest
+ {
+ /// <summary>
+ /// 璁惧缂栫爜
+ /// </summary>
+ public string EquipmentCode { get; set; }
+
+ /// <summary>
+ /// 璧勬簮缂栫爜
+ /// </summary>
+ public string ResourceCode { get; set; }
+
+ /// <summary>
+ /// 璋冪敤鏈湴鏃堕棿
+ /// </summary>
+ public DateTime LocalTime { get; set; }
+
+ /// <summary>
+ /// 鎵樼洏鐮�
+ /// </summary>
+ public string ContainCode { get; set; }
+
+ /// <summary>
+ /// 鐢佃姱鏉$爜缁�
+ /// </summary>
+ public List<string> SfcList { get; set; }
+ }
+
+ #endregion
+
+ #region 鎵樼洏NG鐢佃姱涓婃姤
+
+ /// <summary>
+ /// 鎵樼洏NG鐢佃姱涓婃姤 - 璇锋眰
+ /// </summary>
+ public class ContainerNgReportRequest
+ {
+ /// <summary>
+ /// 璁惧缂栫爜
+ /// </summary>
+ public string EquipmentCode { get; set; }
+
+ /// <summary>
+ /// 璧勬簮缂栫爜
+ /// </summary>
+ public string ResourceCode { get; set; }
+
+ /// <summary>
+ /// 璋冪敤鏈湴鏃堕棿
+ /// </summary>
+ public DateTime LocalTime { get; set; }
+
+ /// <summary>
+ /// 鎵樼洏鐮�
+ /// </summary>
+ public string ContainerCode { get; set; }
+
+ /// <summary>
+ /// NG鐢佃姱鏉$爜鍒楄〃
+ /// </summary>
+ public List<NgSfcItem> NgSfcList { get; set; }
+ }
+
+ /// <summary>
+ /// NG鐢佃姱椤�
+ /// </summary>
+ public class NgSfcItem
+ {
+ /// <summary>
+ /// 浜у搧鏉$爜
+ /// </summary>
+ public string Sfc { get; set; }
+
+ /// <summary>
+ /// NG浠g爜
+ /// </summary>
+ public string NgCode { get; set; }
+
+ /// <summary>
+ /// NG璁惧
+ /// </summary>
+ public string NgEquipmentCode { get; set; }
+
+ /// <summary>
+ /// NG璧勬簮
+ /// </summary>
+ public string NgResourceCode { get; set; }
+ }
+
+ #endregion
+
+ #region 鎵樼洏杩涚珯
+
+ /// <summary>
+ /// 鎵樼洏杩涚珯 - 璇锋眰
+ /// </summary>
+ public class InboundInContainerRequest
+ {
+ /// <summary>
+ /// 璁惧缂栫爜
+ /// </summary>
+ public string EquipmentCode { get; set; }
+
+ /// <summary>
+ /// 璧勬簮缂栫爜
+ /// </summary>
+ public string ResourceCode { get; set; }
+
+ /// <summary>
+ /// 璋冪敤鏈湴鏃堕棿
+ /// </summary>
+ public DateTime LocalTime { get; set; }
+
+ /// <summary>
+ /// 鎵樼洏鐮�
+ /// </summary>
+ public string ContainerCode { get; set; }
+ }
+
+ #endregion
+
+ #region 鎵樼洏鍑虹珯
+
+ /// <summary>
+ /// 鎵樼洏鍑虹珯 - 璇锋眰
+ /// </summary>
+ public class OutboundInContainerRequest
+ {
+ /// <summary>
+ /// 璁惧缂栫爜
+ /// </summary>
+ public string EquipmentCode { get; set; }
+
+ /// <summary>
+ /// 璧勬簮缂栫爜
+ /// </summary>
+ public string ResourceCode { get; set; }
+
+ /// <summary>
+ /// 璋冪敤鏈湴鏃堕棿
+ /// </summary>
+ public DateTime LocalTime { get; set; }
+
+ /// <summary>
+ /// 鎵樼洏鐮�
+ /// </summary>
+ public string ContainerCode { get; set; }
+
+ /// <summary>
+ /// 浜у搧鍙傛暟鍒楄〃
+ /// </summary>
+ public List<ParamItem> ParamList { get; set; }
+ }
+
+ /// <summary>
+ /// 鍙傛暟椤�
+ /// </summary>
+ public class ParamItem
+ {
+ /// <summary>
+ /// 鍙傛暟缂栫爜
+ /// </summary>
+ public string ParamCode { get; set; }
+
+ /// <summary>
+ /// 鍙傛暟鍊�
+ /// </summary>
+ public string ParamValue { get; set; }
+
+ /// <summary>
+ /// 閲囬泦鍙傛暟鐨勬椂闂�
+ /// </summary>
+ public DateTime CollectionTime { get; set; }
+ }
+
+ #endregion
+}
\ No newline at end of file
diff --git a/Code/WMS/WIDESEA_WMSServer/WIDESEA_DTO/MES/MesResponseDto.cs b/Code/WMS/WIDESEA_WMSServer/WIDESEA_DTO/MES/MesResponseDto.cs
new file mode 100644
index 0000000..4d481f6
--- /dev/null
+++ b/Code/WMS/WIDESEA_WMSServer/WIDESEA_DTO/MES/MesResponseDto.cs
@@ -0,0 +1,23 @@
+namespace WIDESEA_DTO.MES
+{
+ /// <summary>
+ /// MES鎺ュ彛缁熶竴鍝嶅簲
+ /// </summary>
+ public class MesResponse
+ {
+ /// <summary>
+ /// 鎵ц浠g爜锛�0-鎴愬姛锛屽叾浠�-澶辫触
+ /// </summary>
+ public int Code { get; set; }
+
+ /// <summary>
+ /// 杩斿洖淇℃伅
+ /// </summary>
+ public string Msg { get; set; }
+
+ /// <summary>
+ /// 鏄惁鎴愬姛
+ /// </summary>
+ public bool IsSuccess => Code == 0;
+ }
+}
\ No newline at end of file
diff --git a/Code/WMS/WIDESEA_WMSServer/WIDESEA_IBasicService/IMesService.cs b/Code/WMS/WIDESEA_WMSServer/WIDESEA_IBasicService/IMesService.cs
new file mode 100644
index 0000000..b9b27a1
--- /dev/null
+++ b/Code/WMS/WIDESEA_WMSServer/WIDESEA_IBasicService/IMesService.cs
@@ -0,0 +1,37 @@
+using System.Net.Http;
+using WIDESEA_Core;
+using WIDESEA_DTO.MES;
+
+namespace WIDESEA_IBasicService
+{
+ /// <summary>
+ /// MES鏈嶅姟鎺ュ彛 - 闄曡タ椤峰埢鑳芥簮绉戞妧MES绯荤粺瀵规帴
+ /// </summary>
+ public interface IMesService : IDependency
+ {
+ /// <summary>
+ /// 鎵樼洏鐢佃姱缁戝畾
+ /// </summary>
+ HttpResponseResult<MesResponse> BindContainer(BindContainerRequest request);
+
+ /// <summary>
+ /// 鎵樼洏鐢佃姱瑙g粦
+ /// </summary>
+ HttpResponseResult<MesResponse> UnBindContainer(UnBindContainerRequest request);
+
+ /// <summary>
+ /// 鎵樼洏NG鐢佃姱涓婃姤
+ /// </summary>
+ HttpResponseResult<MesResponse> ContainerNgReport(ContainerNgReportRequest request);
+
+ /// <summary>
+ /// 鎵樼洏杩涚珯
+ /// </summary>
+ HttpResponseResult<MesResponse> InboundInContainer(InboundInContainerRequest request);
+
+ /// <summary>
+ /// 鎵樼洏鍑虹珯
+ /// </summary>
+ HttpResponseResult<MesResponse> OutboundInContainer(OutboundInContainerRequest request);
+ }
+}
\ No newline at end of file
diff --git a/Code/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/appsettings.json b/Code/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/appsettings.json
index c628c08..42a6bb4 100644
--- a/Code/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/appsettings.json
+++ b/Code/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/appsettings.json
@@ -68,5 +68,9 @@
"GW": [ "11001", "11010", "11068" ],
"CW": [ "10080" ]
}
+ },
+ "MES": {
+ "BaseUrl": "http://localhost:5000",
+ "Authorization": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjMwMTcyNzM5Mzk5NzYxOTIwIiwibmFtZSI6IlBBQ0voo4XphY3lt6XkvY0wMSIsIkZhY3RvcnlJZCI6IjEyMzQ1NiIsIlNpdGVJZCI6IjEyMzQ1NiIsIkNvZGUiOiJYWExQQUNLMDRBRTAzMiIsIm5iZiI6MTcwNDE4NzY5MCwiZXhwIjoyMTQ1NjkxNjkwLCJpc3MiOiJodHRwczovL3d3dy5oeW1zb24uY29tIiwiYXVkIjoiaHR0cHM6Ly93d3cuaHltc29uLmNvbSJ9.An1BE7UgfcSP--LtTOmmmWVE2RQFPDahLkDg1xy5KqY"
}
}
\ No newline at end of file
--
Gitblit v1.9.3