From ce1292c9cf37195b6abd2699dfc5d6cb3e143c9b Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期日, 12 四月 2026 23:38:19 +0800
Subject: [PATCH] feat(MES): 添加MES接口相关实体和DTO JS扩展文件至JSX格式并更新配置
---
Code/WMS/WIDESEA_WMSServer/WIDESEA_MesService/MesLogService.cs | 95 +++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 95 insertions(+), 0 deletions(-)
diff --git a/Code/WMS/WIDESEA_WMSServer/WIDESEA_MesService/MesLogService.cs b/Code/WMS/WIDESEA_WMSServer/WIDESEA_MesService/MesLogService.cs
new file mode 100644
index 0000000..30b40c9
--- /dev/null
+++ b/Code/WMS/WIDESEA_WMSServer/WIDESEA_MesService/MesLogService.cs
@@ -0,0 +1,95 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using SqlSugar;
+using WIDESEA_Core;
+using WIDESEA_DTO.MES;
+using WIDESEA_IMesService;
+using WIDESEA_Model.Models.Mes;
+
+namespace WIDESEA_MesService
+{
+ /// <summary>
+ /// MES鎺ュ彛鏃ュ織鏈嶅姟瀹炵幇
+ /// </summary>
+ public class MesLogService : IMesLogService
+ {
+ private readonly ISqlSugarClient _db;
+
+ /// <summary>
+ /// 鏋勯�犲嚱鏁�
+ /// </summary>
+ /// <param name="db">鏁版嵁搴撳鎴风</param>
+ public MesLogService(ISqlSugarClient db)
+ {
+ _db = db;
+ }
+
+ /// <summary>
+ /// 璁板綍MES鎺ュ彛璋冪敤鏃ュ織
+ /// </summary>
+ /// <param name="log">鏃ュ織DTO</param>
+ /// <returns>鏄惁璁板綍鎴愬姛</returns>
+ public async Task<bool> LogAsync(MesApiLogDto log)
+ {
+ try
+ {
+ var entity = new Dt_MesApiLog
+ {
+ ApiType = log.ApiType,
+ RequestJson = log.RequestJson,
+ ResponseJson = log.ResponseJson,
+ IsSuccess = log.IsSuccess,
+ ErrorMessage = log.ErrorMessage,
+ ElapsedMs = log.ElapsedMs,
+ CreateDate = DateTime.Now,
+ Creator = log.Creator
+ };
+
+ var result = await _db.Insertable(entity).ExecuteCommandAsync();
+ return result > 0;
+ }
+ catch (Exception ex)
+ {
+ // 璁板綍鏃ュ織澶辫触涓嶅奖鍝嶄富娴佺▼
+ Console.WriteLine($"璁板綍MES鏃ュ織澶辫触: {ex.Message}");
+ return false;
+ }
+ }
+
+ /// <summary>
+ /// 鑾峰彇鏈�杩戠殑MES鎺ュ彛璋冪敤璁板綍
+ /// </summary>
+ /// <param name="apiType">鎺ュ彛绫诲瀷</param>
+ /// <param name="count">璁板綍鏁伴噺</param>
+ /// <returns>鏃ュ織鍒楄〃</returns>
+ public async Task<List<MesApiLogDto>> GetRecentLogsAsync(string apiType, int count = 50)
+ {
+ try
+ {
+ var entities = await _db.Queryable<Dt_MesApiLog>()
+ .Where(x => x.ApiType == apiType)
+ .OrderByDescending(x => x.CreateDate)
+ .Take(count)
+ .ToListAsync();
+
+ return entities.Select(e => new MesApiLogDto
+ {
+ ApiType = e.ApiType,
+ RequestJson = e.RequestJson,
+ ResponseJson = e.ResponseJson,
+ IsSuccess = e.IsSuccess,
+ ErrorMessage = e.ErrorMessage,
+ ElapsedMs = e.ElapsedMs,
+ Creator = e.Creator
+ }).ToList();
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine($"鑾峰彇MES鏃ュ織澶辫触: {ex.Message}");
+ return new List<MesApiLogDto>();
+ }
+ }
+ }
+}
--
Gitblit v1.9.3