Files
AutoBOM/VBA_BOMConverter/ClassModules/clsErrorLogger.cls
Misaka_Company 7fea574531
All checks were successful
NTFY Notification / notify (push) Successful in 12s
refactor: replace row index with production order number in error reports
Replace "原表行号" (original row number) field with "生产订单号" (production order number) in BOM Extraction System error reporting to improve traceability.

Changes:
- clsErrorLogger: Update Record/RecordWarning signatures to accept OrderNo (String) instead of RowIndex (Long)
- M09_BOMExtractor: Propagate productionOrderNo through validation chain for context-aware error reporting
- M06/M07/M08: Use empty string for system-level errors without production order context
- Error report header: Change column B from "原表行号" to "生产订单号"

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-26 10:12:59 +08:00

105 lines
3.4 KiB
OpenEdge ABL
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
' ==============================================================================
' 类模块: clsErrorLogger
' 职责: 错误日志记录器 (修正版移除UDT使用数组存储)
' ==============================================================================
Option Explicit
Private pErrors As Collection
Private pWarnings As Collection
Private Sub Class_Initialize()
Set pErrors = New Collection
Set pWarnings = New Collection
End Sub
' 记录错误
Public Sub Record(OrderNo As String, SourceFunc As String, ErrorType As String, Desc As String, Context As String)
' 使用数组存储单条错误信息:生产订单号, 来源, 类型, 描述, 上下文
pErrors.Add Array(OrderNo, SourceFunc, ErrorType, Desc, Context)
End Sub
' 是否有错误
Public Property Get HasErrors() As Boolean
HasErrors = (pErrors.count > 0)
End Property
' 是否有警告
Public Property Get HasWarnings() As Boolean
HasWarnings = (pWarnings.count > 0)
End Property
' 是否有问题(错误或警告)
Public Property Get HasIssues() As Boolean
HasIssues = (pErrors.count > 0 Or pWarnings.count > 0)
End Property
' 记录警告
Public Sub RecordWarning(OrderNo As String, SourceFunc As String, WarningType As String, Desc As String, Context As String)
pWarnings.Add Array(OrderNo, SourceFunc, WarningType, Desc, Context)
End Sub
'
Public Sub PrintReport(targetWb As Workbook)
If pErrors.count = 0 And pWarnings.count = 0 Then Exit Sub
Dim ws As Worksheet
Set ws = targetWb.Worksheets.Add(After:=targetWb.Worksheets(targetWb.Worksheets.count))
ws.Name = "错误报告_" & Format(Now, "hhmmss")
' ("类型")
ws.Range("A1:F1").Value = Array("类型", "生产订单号", "来源模块", "错误类型", "详细描述", "原始数据")
ws.Range("A1:F1").Font.Bold = True
ws.Range("A1:F1").Interior.Color = RGB(217, 217, 217)
' 准备输出数组
Dim totalIssues As Long
totalIssues = pErrors.count + pWarnings.count
Dim arrOutput() As Variant
ReDim arrOutput(1 To totalIssues, 1 To 6)
Dim i As Long
Dim vItem As Variant
'
For i = 1 To pErrors.count
vItem = pErrors(i)
arrOutput(i, 1) = "错误"
arrOutput(i, 2) = vItem(0)
arrOutput(i, 3) = vItem(1)
arrOutput(i, 4) = vItem(2)
arrOutput(i, 5) = vItem(3)
arrOutput(i, 6) = vItem(4)
Next i
'
For i = 1 To pWarnings.count
vItem = pWarnings(i)
arrOutput(pErrors.count + i, 1) = "警告"
arrOutput(pErrors.count + i, 2) = vItem(0)
arrOutput(pErrors.count + i, 3) = vItem(1)
arrOutput(pErrors.count + i, 4) = vItem(2)
arrOutput(pErrors.count + i, 5) = vItem(3)
arrOutput(pErrors.count + i, 6) = vItem(4)
Next i
ws.Range("A2").Resize(totalIssues, 6).Value = arrOutput
'
If totalIssues > 0 Then
Dim rngErrors As Range
Dim rngWarnings As Range
If pErrors.count > 0 Then
Set rngErrors = ws.Range("A2").Resize(pErrors.count, 6)
rngErrors.Interior.Color = RGB(255, 200, 200)
End If
If pWarnings.count > 0 Then
Set rngWarnings = ws.Range("A" & (pErrors.count + 2)).Resize(pWarnings.count, 6)
rngWarnings.Interior.Color = RGB(255, 255, 200)
End If
End If
ws.Columns.AutoFit
End Sub