Files
XRLib/Assets/Scripts/SHI/modal/GanttChartData.cs
2025-11-17 19:30:05 +09:00

109 lines
4.7 KiB
C#

#nullable enable
using System;
using System.Collections.Generic;
namespace SHI.modal
{
/// <summary>
/// 간트 차트의 한 구간(세그먼트) 정보를 나타냅니다.
/// </summary>
public class ScheduleSegment
{
/// <summary>외부 연동용 안정 키(권장).</summary>
public string ItemKey { get; set; } = string.Empty;
/// <summary>호환용 GUID(선택적).</summary>
public Guid ItemId { get; set; }
/// <summary>시작 시각(UTC 권장).</summary>
public DateTime Start { get; set; }
/// <summary>종료 시각(UTC 권장).</summary>
public DateTime End { get; set; }
/// <summary>진행률 값([0..1] 또는 [0..100] 등 상위 시스템 규약 따름).</summary>
public float Progress { get; set; }
/// <summary>유형/카테고리 등 사용자 지정 문자열.</summary>
public string Type { get; set; } = string.Empty;
}
/// <summary>
/// 기간/마커 정보(Structured 행 모드용).
/// </summary>
public class DateRange
{
public DateTime? Start { get; set; }
public DateTime? End { get; set; }
public int? Duration { get; set; }
public bool IsMarker => Start.HasValue && !End.HasValue;
}
/// <summary>
/// 블록/행 단위 일정 레코드.
/// </summary>
public class BlockScheduleRow
{
public string? ProjNo { get; set; }
public string? BlockNo { get; set; }
public string? L1 { get; set; }
public string? L2 { get; set; }
public string? L3 { get; set; }
public string? L4 { get; set; }
public string? L5 { get; set; }
public string? L6 { get; set; }
public string? L7 { get; set; }
public string? L8 { get; set; }
/// <summary>코드(예:43,4B 등)별 기간/마커.</summary>
public Dictionary<string, DateRange> Periods { get; } = new Dictionary<string, DateRange>();
// 추가 메타 정보(JSON 컬럼 매핑)
public string? BlkDsc { get; set; } // BLK_DSC
public string? ShipType { get; set; } // SHIP_TYPE
public string? ShrGb { get; set; } // SHR_GB
public float? Lth { get; set; } // LTH
public float? Bth { get; set; } // BTH
public float? Hgt { get; set; } // HGT
public float? NetWgt { get; set; } // NET_WGT
public float? EqupWgt { get; set; } // EQUP_WGT
public float? LftWgt { get; set; } // LFT_WGT
public string? WkType { get; set; } // WK_TYPE
public string? Wc31 { get; set; } // WC31
// 편의 접근자: 자주 쓰는 코드 맵핑
/// <summary>STDT01: 파란색 @ 표시 일(yyyymmdd)</summary>
public DateTime? STDT01 { get => GetStart("01"); set => SetStart("01", value); }
/// <summary>STDT21: 파란색 막대 시작일(yyyymmdd)</summary>
public DateTime? STDT21 { get => GetStart("21"); set => SetStart("21", value); }
/// <summary>FNDT21: 파란색 막대 종료일(yyyymmdd)</summary>
public DateTime? FNDT21 { get => GetEnd("21"); set => SetEnd("21", value); }
/// <summary>STDT23: 연두색 막대 시작일(yyyymmdd)</summary>
public DateTime? STDT23 { get => GetStart("23"); set => SetStart("23", value); }
/// <summary>FNDT23: 연두색 막대 종료일(yyyymmdd)</summary>
public DateTime? FNDT23 { get => GetEnd("23"); set => SetEnd("23", value); }
private DateRange GetOrCreateRange(string code)
{
if (!Periods.TryGetValue(code, out var dr) || dr == null)
{
dr = new DateRange();
Periods[code] = dr;
}
return dr;
}
private DateTime? GetStart(string code) => Periods.TryGetValue(code, out var dr) ? dr.Start : null;
private DateTime? GetEnd(string code) => Periods.TryGetValue(code, out var dr) ? dr.End : null;
private void SetStart(string code, DateTime? v) { var dr = GetOrCreateRange(code); dr.Start = v; }
private void SetEnd(string code, DateTime? v) { var dr = GetOrCreateRange(code); dr.End = v; }
}
/// <summary>
/// 간단한 간트 차트 데이터셋입니다.
/// 기존 Segments 기반(Flat) + Rows 기반(Structured) 동시 지원.
/// </summary>
public class GanttChartData
{
/// <summary>표시 순서대로의 세그먼트 컬렉션 (Flat 모드).</summary>
public List<ScheduleSegment> Segments { get; set; } = new List<ScheduleSegment>();
/// <summary>Structured 행 모드 컬렉션.</summary>
public List<BlockScheduleRow> Rows { get; set; } = new List<BlockScheduleRow>();
public DateTime? MinDate { get; set; }
public DateTime? MaxDate { get; set; }
}
}