This commit is contained in:
2025-07-21 15:32:49 +09:00
parent d24ab69bb1
commit 4a4a0138da
20 changed files with 5506 additions and 170 deletions

View File

@@ -79,6 +79,18 @@ public class FieldMapper
return null;
}
/// <summary>
/// AI 라벨을 DocAiKey 값으로 변환
/// </summary>
public string AilabelToDocAiKey(string ailabel)
{
if (_mappingData.MappingTable.AilabelToSystems.TryGetValue(ailabel, out var systemFields))
{
return systemFields.DocAiKey;
}
return null;
}
/// <summary>
/// 고속도로공사 필드명을 교통부 필드명으로 변환
/// </summary>
@@ -91,6 +103,46 @@ public class FieldMapper
return null;
}
/// <summary>
/// DocAiKey 값으로부터 해당하는 AI 라벨을 반환
/// </summary>
public string DocAiKeyToAilabel(string docAiKey)
{
if (string.IsNullOrEmpty(docAiKey))
{
return null;
}
foreach (var kvp in _mappingData.MappingTable.AilabelToSystems)
{
if (kvp.Value.DocAiKey == docAiKey)
{
return kvp.Key;
}
}
return null;
}
/// <summary>
/// Expressway 필드값으로부터 해당하는 AI 라벨을 반환
/// </summary>
public string ExpresswayToAilabel(string expresswayField)
{
if (string.IsNullOrEmpty(expresswayField))
{
return null;
}
foreach (var kvp in _mappingData.MappingTable.AilabelToSystems)
{
if (kvp.Value.Expressway == expresswayField)
{
return kvp.Key;
}
}
return null;
}
/// <summary>
/// AI 라벨 → 고속도로공사 → 교통부 순서로 변환
/// </summary>
@@ -141,102 +193,121 @@ public class FieldMapper
}
return results;
}
/// <summary>
/// 매핑 테이블에서 모든 DocAiKey 값의 목록을 반환합니다.
/// </summary>
public List<string> GetAllDocAiKeys()
{
var docAiKeys = new List<string>();
foreach (var kvp in _mappingData.MappingTable.AilabelToSystems)
{
var docAiKey = kvp.Value.DocAiKey;
if (!string.IsNullOrEmpty(docAiKey))
{
docAiKeys.Add(docAiKey);
}
}
return docAiKeys;
}
}
// 사용 예제 프로그램
class Program
{
static void Main(string[] args)
{
try
{
// 매핑 테이블 로드
var mapper = FieldMapper.LoadFromFile("mapping_table.json");
//class Program
//{
// static void Main(string[] args)
// {
// try
// {
// // 매핑 테이블 로드
// var mapper = FieldMapper.LoadFromFile("mapping_table.json");
Console.WriteLine("=== AI 라벨 → 고속도로공사 필드명 변환 ===");
var testLabels = new[] { "도면명", "편철번호", "도면번호", "Main Title", "계정번호" };
// Console.WriteLine("=== AI 라벨 → 고속도로공사 필드명 변환 ===");
// var testLabels = new[] { "도면명", "편철번호", "도면번호", "Main Title", "계정번호" };
foreach (var label in testLabels)
{
var expresswayField = mapper.AilabelToExpressway(label);
Console.WriteLine($"{label} → {expresswayField ?? "N/A"}");
}
// foreach (var label in testLabels)
// {
// var expresswayField = mapper.AilabelToExpressway(label);
// Console.WriteLine($"{label} → {expresswayField ?? "N/A"}");
// }
Console.WriteLine("\n=== 고속도로공사 → 교통부 필드명 변환 ===");
var expresswayFields = new[] { "TD_DNAME_MAIN", "TD_DWGNO", "TD_DWGCODE", "TR_RNUM1" };
// Console.WriteLine("\n=== 고속도로공사 → 교통부 필드명 변환 ===");
// var expresswayFields = new[] { "TD_DNAME_MAIN", "TD_DWGNO", "TD_DWGCODE", "TR_RNUM1" };
foreach (var field in expresswayFields)
{
var transportationField = mapper.ExpresswayToTransportation(field);
Console.WriteLine($"{field} → {transportationField ?? "N/A"}");
}
// foreach (var field in expresswayFields)
// {
// var transportationField = mapper.ExpresswayToTransportation(field);
// Console.WriteLine($"{field} → {transportationField ?? "N/A"}");
// }
Console.WriteLine("\n=== AI 라벨 → 고속도로공사 → 교통부 (연속 변환) ===");
foreach (var label in testLabels)
{
var expresswayField = mapper.AilabelToExpressway(label);
var transportationField = mapper.AilabelToTransportationViaExpressway(label);
Console.WriteLine($"{label} → {expresswayField ?? "N/A"} → {transportationField ?? "N/A"}");
}
// Console.WriteLine("\n=== AI 라벨 → 고속도로공사 → 교통부 (연속 변환) ===");
// foreach (var label in testLabels)
// {
// var expresswayField = mapper.AilabelToExpressway(label);
// var transportationField = mapper.AilabelToTransportationViaExpressway(label);
// Console.WriteLine($"{label} → {expresswayField ?? "N/A"} → {transportationField ?? "N/A"}");
// }
Console.WriteLine("\n=== 특정 AI 라벨의 모든 시스템 필드명 ===");
var allFields = mapper.GetAllSystemFields("도면명");
if (allFields != null)
{
Console.WriteLine("도면명에 해당하는 모든 시스템 필드:");
Console.WriteLine($" 국토교통부: {allFields.Molit}");
Console.WriteLine($" 고속도로공사: {allFields.Expressway}");
Console.WriteLine($" 국가철도공단: {allFields.Railway}");
Console.WriteLine($" 문서AI키: {allFields.DocAiKey}");
}
// Console.WriteLine("\n=== 특정 AI 라벨의 모든 시스템 필드명 ===");
// var allFields = mapper.GetAllSystemFields("도면명");
// if (allFields != null)
// {
// Console.WriteLine("도면명에 해당하는 모든 시스템 필드:");
// Console.WriteLine($" 국토교통부: {allFields.Molit}");
// Console.WriteLine($" 고속도로공사: {allFields.Expressway}");
// Console.WriteLine($" 국가철도공단: {allFields.Railway}");
// Console.WriteLine($" 문서AI키: {allFields.DocAiKey}");
// }
Console.WriteLine("\n=== 배치 처리 예제 ===");
var batchResults = mapper.BatchConvertAilabelToExpressway(testLabels);
foreach (var result in batchResults)
{
Console.WriteLine($"배치 변환: {result.Key} → {result.Value ?? "N/A"}");
}
}
catch (Exception ex)
{
Console.WriteLine($"오류 발생: {ex.Message}");
}
}
}
// Console.WriteLine("\n=== 배치 처리 예제 ===");
// var batchResults = mapper.BatchConvertAilabelToExpressway(testLabels);
// foreach (var result in batchResults)
// {
// Console.WriteLine($"배치 변환: {result.Key} → {result.Value ?? "N/A"}");
// }
// }
// catch (Exception ex)
// {
// Console.WriteLine($"오류 발생: {ex.Message}");
// }
// }
// 확장 메서드 (선택사항)
public static class FieldMapperExtensions
{
/// <summary>
/// 특정 시스템의 필드명을 다른 시스템으로 변환
/// </summary>
public static string ConvertBetweenSystems(this FieldMapper mapper, string sourceField, string sourceSystem, string targetSystem)
{
// 역방향 조회를 위한 확장 메서드
foreach (var kvp in mapper._mappingData.MappingTable.AilabelToSystems)
{
var systemFields = kvp.Value;
string sourceFieldValue = sourceSystem switch
{
"molit" => systemFields.Molit,
"expressway" => systemFields.Expressway,
"railway" => systemFields.Railway,
"docaikey" => systemFields.DocAiKey,
_ => null
};
//public static class FieldMapperExtensions
//{
// /// <summary>
// /// 특정 시스템의 필드명을 다른 시스템으로 변환
// /// </summary>
// public static string ConvertBetweenSystems(this FieldMapper mapper, string sourceField, string sourceSystem, string targetSystem)
// {
// // 역방향 조회를 위한 확장 메서드
// foreach (var kvp in mapper._mappingData.MappingTable.AilabelToSystems)
// {
// var systemFields = kvp.Value;
// string sourceFieldValue = sourceSystem switch
// {
// "molit" => systemFields.Molit,
// "expressway" => systemFields.Expressway,
// "railway" => systemFields.Railway,
// "docaikey" => systemFields.DocAiKey,
// _ => null
// };
if (sourceFieldValue == sourceField)
{
return targetSystem switch
{
"molit" => systemFields.Molit,
"expressway" => systemFields.Expressway,
"railway" => systemFields.Railway,
"docaikey" => systemFields.DocAiKey,
_ => null
};
}
}
return null;
}
}
// if (sourceFieldValue == sourceField)LL
// {
// return targetSystem switch
// {
// "molit" => systemFields.Molit,
// "expressway" => systemFields.Expressway,
// "railway" => systemFields.Railway,
// "docaikey" => systemFields.DocAiKey,
// _ => null
// };
// }
// }
// return null;
// }
//}