add comment

This commit is contained in:
updsv7
2026-04-16 19:13:22 +09:00
parent db6a971473
commit 32420f8503
14 changed files with 200 additions and 33 deletions

View File

@@ -1,34 +1,38 @@
' ============================================================
' Modele Name: Global_Cache
' Modele Desc: Global Cache Module, Shared caches across all worksheets
' Module Name: Global_Cache
' Module Desc: Global Cache Module, Shared caches across all worksheets
' Module Methods:
' - RefreshM1Cache / ClearM1Cache
' - RefreshM1KukanDCache / ClearM1KukanDCache
' - RefreshM2Cache / ClearM2Cache
' - RefreshZ1Cache / ClearZ1Cache
' - RefreshZ2Cache / ClearZ2Cache
' - RefreshZ3Cache / ClearZ3Cache
' - RefreshO1Cache / ClearO1Cache
' - RefreshO2Cache / ClearO2Cache
' ============================================================
' M1 cache - used by M2_Kukan_detail, Tukin_C1
' Cache Variables
Public m1Cache As Object
' M1_KukanD cache - nested dict {D: {F: [G]}}
Public m1KukanDCache As Object
' Z1 cache - used by M1_Kukan
Public z1Cache As Object
' Z2 cache
Public z2Cache As Object
' Z3 cache
Public z3Cache As Object
' O1 cache - used by Tukin_C1
Public o1Cache As Object
' O2 cache
Public o2Cache As Object
' M2 cache - nested dictionary for Tukin_C1
Public m2Cache As Object
' m1Cache - used by M2_Kukan_detail, Tukin_C1
' m1KukanDCache - nested dict {D: {F: [G]}}
' z1Cache - used by M1_Kukan, Tukin_C1
' z2Cache
' z3Cache
' o1Cache - used by Tukin_C1
' o2Cache
' m2Cache - nested dictionary for Tukin_C1
' ============================================================
' M1 Cache
' M1 Cache - { 区間コード[C]: [value1-7] }
' ============================================================
Public Sub RefreshM1Cache()
Set m1Cache = Nothing
@@ -230,19 +234,51 @@ End Sub
' ============================================================
Public Sub RefreshO1Cache()
Set o1Cache = Nothing
Set o1Cache = CreateObject("Scripting.Dictionary")
On Error GoTo RefreshError
Set o1Cache = LoadLookup("O1", keyCol:=3, valueCols:=Array(5, 6), startRow:=7)
Dim wsO1 As Worksheet
On Error Resume Next
Set wsO1 = ThisWorkbook.Worksheets("O1")
If wsO1 Is Nothing Then Exit Sub
On Error GoTo 0
If o1Cache Is Nothing Or o1Cache.Count = 0 Then
Err.Raise 1001, "RefreshO1Cache", "O1 reference data is empty"
End If
Exit Sub
RefreshError:
Err.Raise 1002, "RefreshO1Cache", "Failed to load O1 lookup cache: " & Err.Description
Dim lastRow As Long
lastRow = wsO1.Cells(wsO1.Rows.Count, 3).End(xlUp).Row
If lastRow < 7 Then Exit Sub
Dim r As Long
For r = 7 To lastRow
Dim cVal As String
cVal = Trim(wsO1.Cells(r, 3).Value) ' C column
Dim eVal As String
eVal = Trim(wsO1.Cells(r, 5).Value) ' E column
Dim fVal As String
fVal = Trim(wsO1.Cells(r, 6).Value) ' F column
If cVal = "" Or eVal = "" Then GoTo NextO1
' Outer: C column
If Not o1Cache.Exists(cVal) Then
Dim innerDict As Object
Set innerDict = CreateObject("Scripting.Dictionary")
o1Cache.Add cVal, innerDict
End If
' Inner: E column -> array of F values
Set innerDict = o1Cache(cVal)
If Not innerDict.Exists(eVal) Then
Dim arr As Object
Set arr = CreateObject("Scripting.Dictionary")
innerDict.Add eVal, arr
End If
Set arr = innerDict(eVal)
If fVal <> "" And Not arr.Exists(fVal) Then
arr.Add fVal, True
End If
NextO1:
Next r
End Sub
Public Sub ClearO1Cache()