补齐产量报表2个端点(adjustment-history/export占位)+修复前端API路径参数 + 新增DTO + Repository方法

main
haoliang 1 week ago
parent 1168b3c4ac
commit 126cecfa09

@ -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

@ -0,0 +1,26 @@
namespace CncModels.Dto.Production
{
/// <summary>
/// 产量修正历史记录项
/// </summary>
public class AdjustmentHistoryItem
{
/// <summary>修正记录ID</summary>
public int Id { get; set; }
/// <summary>修正前值</summary>
public string OldValue { get; set; }
/// <summary>修正后值</summary>
public string NewValue { get; set; }
/// <summary>修正原因</summary>
public string Reason { get; set; }
/// <summary>操作人IP</summary>
public string OperatorIp { get; set; }
/// <summary>修正时间</summary>
public string CreatedAt { get; set; }
}
}

@ -45,5 +45,16 @@ namespace CncRepository.Impl
return new PagedResult<ProductionAdjustment> { Items = items, Total = total, Page = page, PageSize = pageSize };
}
}
/// <inheritdoc/>
public List<ProductionAdjustment> GetByTargetId(int targetId)
{
using (var conn = CreateConnection())
{
return conn.Query<ProductionAdjustment>(
"SELECT * FROM cnc_production_adjustment WHERE target_id = @TargetId ORDER BY created_at DESC",
new { TargetId = targetId }).AsList();
}
}
}
}

@ -12,5 +12,6 @@ namespace CncRepository.Interface
{
int Create(ProductionAdjustment entity);
PagedResult<ProductionAdjustment> GetList(string targetTable, DateTime? startDate, DateTime? endDate, string keyword, int page, int pageSize);
List<ProductionAdjustment> GetByTargetId(int targetId);
}
}

@ -75,5 +75,25 @@ namespace CncService.Impl
_productionAdjustmentRepository.Create(entity);
return true;
}
/// <inheritdoc/>
public List<AdjustmentHistoryItem> GetAdjustmentHistory(int recordId)
{
var records = _productionAdjustmentRepository.GetByTargetId(recordId);
var result = new List<AdjustmentHistoryItem>();
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;
}
}
}

@ -21,5 +21,10 @@ namespace CncService.Interface
/// <summary>产量修正</summary>
bool Adjust(ProductionAdjustRequest request);
/// <summary>
/// 获取某条产量记录的修正历史
/// </summary>
List<AdjustmentHistoryItem> GetAdjustmentHistory(int recordId);
}
}

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

Loading…
Cancel
Save