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.Success(null)); } + + /// + /// 修正历史 + /// GET /api/admin/production/{recordId}/adjustment-history + /// + [HttpGet] + [Route("{recordId:int}/adjustment-history")] + public IHttpActionResult GetAdjustmentHistory(int recordId) + { + var result = _productionService.GetAdjustmentHistory(recordId); + return Ok(ApiResponse.Success(new { items = result })); + } + + /// + /// 导出报表(占位,暂返回空结果) + /// GET /api/admin/production/export + /// + [HttpGet] + [Route("export")] + public IHttpActionResult Export(DateTime? startDate = null, DateTime? endDate = null, int? workshopId = null) + { + // 导出功能暂不实现,返回提示 + return Ok(ApiResponse.Fail(40001, "导出功能尚未实现")); + } } }