도곽 변수 tag mapping 소스 추가
This commit is contained in:
@@ -160,8 +160,6 @@ namespace DwgExtractorManual.Models
|
||||
titleBlockSheet.Cells[titleBlockCurrentRow, 1] = attDef.GetType().Name;
|
||||
titleBlockSheet.Cells[titleBlockCurrentRow, 2] = attDef.BlockName;
|
||||
titleBlockSheet.Cells[titleBlockCurrentRow, 3] = attDef.Tag;
|
||||
|
||||
|
||||
titleBlockSheet.Cells[titleBlockCurrentRow, 4] = attDef.Prompt;
|
||||
titleBlockSheet.Cells[titleBlockCurrentRow, 5] = attDef.TextString;
|
||||
titleBlockSheet.Cells[titleBlockCurrentRow, 6] = database.Filename;
|
||||
|
||||
242
csharp_mapping_usage.cs
Normal file
242
csharp_mapping_usage.cs
Normal file
@@ -0,0 +1,242 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
// 매핑 테이블 데이터 구조 정의
|
||||
public class MappingTableData
|
||||
{
|
||||
[JsonPropertyName("mapping_table")]
|
||||
public MappingTable MappingTable { get; set; }
|
||||
}
|
||||
|
||||
public class MappingTable
|
||||
{
|
||||
[JsonPropertyName("ailabel_to_systems")]
|
||||
public Dictionary<string, SystemFields> AilabelToSystems { get; set; }
|
||||
|
||||
[JsonPropertyName("system_mappings")]
|
||||
public SystemMappings SystemMappings { get; set; }
|
||||
}
|
||||
|
||||
public class SystemFields
|
||||
{
|
||||
[JsonPropertyName("molit")]
|
||||
public string Molit { get; set; }
|
||||
|
||||
[JsonPropertyName("expressway")]
|
||||
public string Expressway { get; set; }
|
||||
|
||||
[JsonPropertyName("railway")]
|
||||
public string Railway { get; set; }
|
||||
|
||||
[JsonPropertyName("docaikey")]
|
||||
public string DocAiKey { get; set; }
|
||||
}
|
||||
|
||||
public class SystemMappings
|
||||
{
|
||||
[JsonPropertyName("expressway_to_transportation")]
|
||||
public Dictionary<string, string> ExpresswayToTransportation { get; set; }
|
||||
}
|
||||
|
||||
// 필드 매퍼 클래스
|
||||
public class FieldMapper
|
||||
{
|
||||
private readonly MappingTableData _mappingData;
|
||||
|
||||
public FieldMapper(MappingTableData mappingData)
|
||||
{
|
||||
_mappingData = mappingData;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// JSON 파일에서 매핑 테이블을 로드합니다.
|
||||
/// </summary>
|
||||
public static FieldMapper LoadFromFile(string jsonFilePath)
|
||||
{
|
||||
string jsonContent = File.ReadAllText(jsonFilePath);
|
||||
var options = new JsonSerializerOptions
|
||||
{
|
||||
PropertyNameCaseInsensitive = true,
|
||||
Encoder = System.Text.Encodings.Web.JavaScriptEncoder.UnsafeRelaxedJsonEscaping
|
||||
};
|
||||
|
||||
var mappingData = JsonSerializer.Deserialize<MappingTableData>(jsonContent, options);
|
||||
return new FieldMapper(mappingData);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// AI 라벨을 고속도로공사 필드명으로 변환
|
||||
/// </summary>
|
||||
public string AilabelToExpressway(string ailabel)
|
||||
{
|
||||
if (_mappingData.MappingTable.AilabelToSystems.TryGetValue(ailabel, out var systemFields))
|
||||
{
|
||||
return systemFields.Expressway;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 고속도로공사 필드명을 교통부 필드명으로 변환
|
||||
/// </summary>
|
||||
public string ExpresswayToTransportation(string expresswayField)
|
||||
{
|
||||
if (_mappingData.MappingTable.SystemMappings.ExpresswayToTransportation.TryGetValue(expresswayField, out var transportationField))
|
||||
{
|
||||
return transportationField;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// AI 라벨 → 고속도로공사 → 교통부 순서로 변환
|
||||
/// </summary>
|
||||
public string AilabelToTransportationViaExpressway(string ailabel)
|
||||
{
|
||||
var expresswayField = AilabelToExpressway(ailabel);
|
||||
if (!string.IsNullOrEmpty(expresswayField))
|
||||
{
|
||||
return ExpresswayToTransportation(expresswayField);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// AI 라벨에 해당하는 모든 시스템의 필드명을 반환
|
||||
/// </summary>
|
||||
public SystemFields GetAllSystemFields(string ailabel)
|
||||
{
|
||||
if (_mappingData.MappingTable.AilabelToSystems.TryGetValue(ailabel, out var systemFields))
|
||||
{
|
||||
return systemFields;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 여러 AI 라벨을 한번에 고속도로공사 필드명으로 변환
|
||||
/// </summary>
|
||||
public Dictionary<string, string> BatchConvertAilabelToExpressway(IEnumerable<string> ailabels)
|
||||
{
|
||||
var results = new Dictionary<string, string>();
|
||||
foreach (var label in ailabels)
|
||||
{
|
||||
results[label] = AilabelToExpressway(label);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 여러 고속도로공사 필드를 한번에 교통부 필드명으로 변환
|
||||
/// </summary>
|
||||
public Dictionary<string, string> BatchConvertExpresswayToTransportation(IEnumerable<string> expresswayFields)
|
||||
{
|
||||
var results = new Dictionary<string, string>();
|
||||
foreach (var field in expresswayFields)
|
||||
{
|
||||
results[field] = ExpresswayToTransportation(field);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
}
|
||||
|
||||
// 사용 예제 프로그램
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 매핑 테이블 로드
|
||||
var mapper = FieldMapper.LoadFromFile("mapping_table.json");
|
||||
|
||||
Console.WriteLine("=== AI 라벨 → 고속도로공사 필드명 변환 ===");
|
||||
var testLabels = new[] { "도면명", "편철번호", "도면번호", "Main Title", "계정번호" };
|
||||
|
||||
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" };
|
||||
|
||||
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 라벨의 모든 시스템 필드명 ===");
|
||||
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}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 확장 메서드 (선택사항)
|
||||
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;
|
||||
}
|
||||
}
|
||||
169
mapping_table_json.json
Normal file
169
mapping_table_json.json
Normal file
@@ -0,0 +1,169 @@
|
||||
{
|
||||
"mapping_table": {
|
||||
"ailabel_to_systems": {
|
||||
"도면명": {
|
||||
"molit": "DI_TITLE",
|
||||
"expressway": "TD_DNAME_MAIN",
|
||||
"railway": "TD_DNAME_MAIN",
|
||||
"docaikey": "DNAME_MAIN"
|
||||
},
|
||||
"편철번호": {
|
||||
"molit": "DI_SUBTITLE",
|
||||
"expressway": "TD_DNAME_BOT",
|
||||
"railway": "TD_DNAME_BOT",
|
||||
"docaikey": "DNAME_BOT"
|
||||
},
|
||||
"도면번호": {
|
||||
"molit": "DA_PAGENO",
|
||||
"expressway": "TD_DWGNO",
|
||||
"railway": "TD_DWGNO",
|
||||
"docaikey": "DWGNO"
|
||||
},
|
||||
"Main Title": {
|
||||
"molit": "DI_DRWNO",
|
||||
"expressway": "TD_DWGCODE",
|
||||
"railway": "TD_DWGCODE",
|
||||
"docaikey": "DWGCODE"
|
||||
},
|
||||
"Sub Title": {
|
||||
"molit": "UD_TITLE",
|
||||
"expressway": "TB_MTITIL",
|
||||
"railway": "TB_MTITIL",
|
||||
"docaikey": "MTITIL"
|
||||
},
|
||||
"수평축척": {
|
||||
"molit": "UD_SUBTITLE",
|
||||
"expressway": "TB_STITL",
|
||||
"railway": "TB_STITL",
|
||||
"docaikey": "STITL"
|
||||
},
|
||||
"수직축척": {
|
||||
"molit": "",
|
||||
"expressway": "TD_DWGCODE_PREV",
|
||||
"railway": "",
|
||||
"docaikey": "DWGCODE_PREV"
|
||||
},
|
||||
"도면축척": {
|
||||
"molit": "DA_HSCALE",
|
||||
"expressway": "TD_HSCAL",
|
||||
"railway": "",
|
||||
"docaikey": "HSCAL"
|
||||
},
|
||||
"적용표준버전": {
|
||||
"molit": "DA_STDNAME",
|
||||
"expressway": "STDNAME",
|
||||
"railway": "",
|
||||
"docaikey": ""
|
||||
},
|
||||
"사업명": {
|
||||
"molit": "DA_STDVER",
|
||||
"expressway": "TD_VERSION",
|
||||
"railway": "TD_VERSION",
|
||||
"docaikey": "VERSION"
|
||||
},
|
||||
"시설_공구": {
|
||||
"molit": "PI_CNAME",
|
||||
"expressway": "TB_CNAME",
|
||||
"railway": "",
|
||||
"docaikey": "TBCNAME"
|
||||
},
|
||||
"설계공구_Station": {
|
||||
"molit": "UD_CDNAME",
|
||||
"expressway": "TB_CSCOP",
|
||||
"railway": "",
|
||||
"docaikey": "CSCOP"
|
||||
},
|
||||
"건설분야": {
|
||||
"molit": "PA_CCLASS",
|
||||
"expressway": "TD_FIELD",
|
||||
"railway": "TD_FIELD",
|
||||
"docaikey": "FIELD"
|
||||
},
|
||||
"건설단계": {
|
||||
"molit": "PI_STAGE",
|
||||
"expressway": "TD_CSTEP",
|
||||
"railway": "TD_CSTEP",
|
||||
"docaikey": "CSTEP"
|
||||
},
|
||||
"설계사": {
|
||||
"molit": "TD_DCOMP",
|
||||
"expressway": "TD_DCOMP",
|
||||
"railway": "",
|
||||
"docaikey": "DCOMP"
|
||||
},
|
||||
"시공사": {
|
||||
"molit": "TD_CCOMP",
|
||||
"expressway": "TD_CCOMP",
|
||||
"railway": "",
|
||||
"docaikey": "CCOMP"
|
||||
},
|
||||
"노선이정": {
|
||||
"molit": "TD_LNDST",
|
||||
"expressway": "",
|
||||
"railway": "",
|
||||
"docaikey": "LNDST"
|
||||
},
|
||||
"계정번호": {
|
||||
"molit": "DC_RNUM1",
|
||||
"expressway": "TR_RNUM1",
|
||||
"railway": "TR_RNUM1",
|
||||
"docaikey": "RNUM1"
|
||||
},
|
||||
"계정날짜": {
|
||||
"molit": "DC_RDATE1",
|
||||
"expressway": "TR_RDAT1",
|
||||
"railway": "TR_RDAT1",
|
||||
"docaikey": "RDAT1"
|
||||
},
|
||||
"개정내용": {
|
||||
"molit": "DC_RDES1",
|
||||
"expressway": "TR_RCON1",
|
||||
"railway": "TR_RCON1",
|
||||
"docaikey": "RCON1"
|
||||
},
|
||||
"작성자": {
|
||||
"molit": "DC_RDGN1",
|
||||
"expressway": "TR_DGN1",
|
||||
"railway": "TR_DGN1",
|
||||
"docaikey": "DGN1"
|
||||
},
|
||||
"검토자": {
|
||||
"molit": "DC_RCHK1",
|
||||
"expressway": "TR_CHK1",
|
||||
"railway": "TR_CHK1",
|
||||
"docaikey": "CHK1"
|
||||
},
|
||||
"확인자": {
|
||||
"molit": "DC_RAPP1",
|
||||
"expressway": "TR_APP1",
|
||||
"railway": "TR_APP1",
|
||||
"docaikey": "APP1"
|
||||
}
|
||||
},
|
||||
"system_mappings": {
|
||||
"expressway_to_transportation": {
|
||||
"TD_DNAME_MAIN": "DNAME_MAIN",
|
||||
"TD_DNAME_BOT": "DNAME_BOT",
|
||||
"TD_DWGNO": "DWGNO",
|
||||
"TD_DWGCODE": "DWGCODE",
|
||||
"TB_MTITIL": "MTITIL",
|
||||
"TB_STITL": "STITL",
|
||||
"TD_DWGCODE_PREV": "DWGCODE_PREV",
|
||||
"TD_HSCAL": "HSCAL",
|
||||
"TD_VERSION": "VERSION",
|
||||
"TB_CNAME": "TBCNAME",
|
||||
"TB_CSCOP": "CSCOP",
|
||||
"TD_FIELD": "FIELD",
|
||||
"TD_CSTEP": "CSTEP",
|
||||
"TD_DCOMP": "DCOMP",
|
||||
"TD_CCOMP": "CCOMP",
|
||||
"TR_RNUM1": "RNUM1",
|
||||
"TR_RDAT1": "RDAT1",
|
||||
"TR_RCON1": "RCON1",
|
||||
"TR_DGN1": "DGN1",
|
||||
"TR_CHK1": "CHK1",
|
||||
"TR_APP1": "APP1"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user