From 126cecfa09dc4b8945cb08c88512b8996b3f0a07 Mon Sep 17 00:00:00 2001
From: haoliang <821644@qq.com>
Date: Wed, 29 Apr 2026 04:32:22 +0800
Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E9=BD=90=E4=BA=A7=E9=87=8F=E6=8A=A5?=
=?UTF-8?q?=E8=A1=A82=E4=B8=AA=E7=AB=AF=E7=82=B9=EF=BC=88adjustment-histor?=
=?UTF-8?q?y/export=E5=8D=A0=E4=BD=8D=EF=BC=89+=E4=BF=AE=E5=A4=8D=E5=89=8D?=
=?UTF-8?q?=E7=AB=AFAPI=E8=B7=AF=E5=BE=84=E5=8F=82=E6=95=B0=20+=20?=
=?UTF-8?q?=E6=96=B0=E5=A2=9EDTO=20+=20Repository=E6=96=B9=E6=B3=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../src/views/production/ProductionPage.vue | 2 +-
.../Dto/Production/AdjustmentHistoryItem.cs | 26 +++++++++++++++++++
.../Impl/ProductionAdjustmentRepository.cs | 11 ++++++++
.../IProductionAdjustmentRepository.cs | 1 +
src/CncService/Impl/ProductionService.cs | 20 ++++++++++++++
.../Interface/IProductionService.cs | 5 ++++
.../Controllers/ProductionController.cs | 24 +++++++++++++++++
7 files changed, 88 insertions(+), 1 deletion(-)
create mode 100644 src/CncModels/Dto/Production/AdjustmentHistoryItem.cs
diff --git a/frontend/src/views/production/ProductionPage.vue b/frontend/src/views/production/ProductionPage.vue
index 5b86acb..e3b0bcc 100644
--- a/frontend/src/views/production/ProductionPage.vue
+++ b/frontend/src/views/production/ProductionPage.vue
@@ -200,7 +200,7 @@ async function showHistory(row: ProductionRecord) {
historyTitle.value = `修正历史 - ${row.machineName} - ${row.date}`
historyLoading.value = true
try {
- const res = await request.get<{ items: any[] }>('/admin/production/adjustment-history', { params: { recordId: row.id } })
+ const res = await request.get<{ items: any[] }>(`/admin/production/${row.id}/adjustment-history`)
historyRows.value = res.data?.items ?? []
} finally {
historyLoading.value = false
diff --git a/src/CncModels/Dto/Production/AdjustmentHistoryItem.cs b/src/CncModels/Dto/Production/AdjustmentHistoryItem.cs
new file mode 100644
index 0000000..6fe22e2
--- /dev/null
+++ b/src/CncModels/Dto/Production/AdjustmentHistoryItem.cs
@@ -0,0 +1,26 @@
+namespace CncModels.Dto.Production
+{
+ ///
+ /// 产量修正历史记录项
+ ///
+ public class AdjustmentHistoryItem
+ {
+ /// 修正记录ID
+ public int Id { get; set; }
+
+ /// 修正前值
+ public string OldValue { get; set; }
+
+ /// 修正后值
+ public string NewValue { get; set; }
+
+ /// 修正原因
+ public string Reason { get; set; }
+
+ /// 操作人IP
+ public string OperatorIp { get; set; }
+
+ /// 修正时间
+ public string CreatedAt { get; set; }
+ }
+}
diff --git a/src/CncRepository/Impl/ProductionAdjustmentRepository.cs b/src/CncRepository/Impl/ProductionAdjustmentRepository.cs
index 90f1a63..84749cc 100644
--- a/src/CncRepository/Impl/ProductionAdjustmentRepository.cs
+++ b/src/CncRepository/Impl/ProductionAdjustmentRepository.cs
@@ -45,5 +45,16 @@ namespace CncRepository.Impl
return new PagedResult { Items = items, Total = total, Page = page, PageSize = pageSize };
}
}
+
+ ///
+ public List GetByTargetId(int targetId)
+ {
+ using (var conn = CreateConnection())
+ {
+ return conn.Query(
+ "SELECT * FROM cnc_production_adjustment WHERE target_id = @TargetId ORDER BY created_at DESC",
+ new { TargetId = targetId }).AsList();
+ }
+ }
}
}
diff --git a/src/CncRepository/Interface/IProductionAdjustmentRepository.cs b/src/CncRepository/Interface/IProductionAdjustmentRepository.cs
index c7a2fb2..2ac4479 100644
--- a/src/CncRepository/Interface/IProductionAdjustmentRepository.cs
+++ b/src/CncRepository/Interface/IProductionAdjustmentRepository.cs
@@ -12,5 +12,6 @@ namespace CncRepository.Interface
{
int Create(ProductionAdjustment entity);
PagedResult GetList(string targetTable, DateTime? startDate, DateTime? endDate, string keyword, int page, int pageSize);
+ List GetByTargetId(int targetId);
}
}
diff --git a/src/CncService/Impl/ProductionService.cs b/src/CncService/Impl/ProductionService.cs
index 5bcfe62..1fa994d 100644
--- a/src/CncService/Impl/ProductionService.cs
+++ b/src/CncService/Impl/ProductionService.cs
@@ -75,5 +75,25 @@ namespace CncService.Impl
_productionAdjustmentRepository.Create(entity);
return true;
}
+
+ ///
+ public List GetAdjustmentHistory(int recordId)
+ {
+ var records = _productionAdjustmentRepository.GetByTargetId(recordId);
+ var result = new List();
+ foreach (var r in records)
+ {
+ result.Add(new AdjustmentHistoryItem
+ {
+ Id = (int)r.Id,
+ OldValue = r.OldValue?.ToString() ?? "-",
+ NewValue = r.NewValue.ToString(),
+ Reason = r.Reason ?? "",
+ OperatorIp = r.OperatorIp ?? "",
+ CreatedAt = r.CreatedAt.ToString("yyyy-MM-dd HH:mm:ss")
+ });
+ }
+ return result;
+ }
}
}
diff --git a/src/CncService/Interface/IProductionService.cs b/src/CncService/Interface/IProductionService.cs
index 74dcab8..522f395 100644
--- a/src/CncService/Interface/IProductionService.cs
+++ b/src/CncService/Interface/IProductionService.cs
@@ -21,5 +21,10 @@ namespace CncService.Interface
/// 产量修正
bool Adjust(ProductionAdjustRequest request);
+
+ ///
+ /// 获取某条产量记录的修正历史
+ ///
+ List GetAdjustmentHistory(int recordId);
}
}
diff --git a/src/CncWebApi/Controllers/ProductionController.cs b/src/CncWebApi/Controllers/ProductionController.cs
index ce9a7a1..0361a53 100644
--- a/src/CncWebApi/Controllers/ProductionController.cs
+++ b/src/CncWebApi/Controllers/ProductionController.cs
@@ -60,5 +60,29 @@ namespace CncWebApi.Controllers
var result = _productionService.Adjust(request);
return Ok(ApiResponse