From bbdf40c5e3b70bb8c30bab1cc83861c50c0ee570 Mon Sep 17 00:00:00 2001 From: kric_jspark Date: Fri, 20 Mar 2026 14:05:44 +0900 Subject: [PATCH] =?UTF-8?q?260320=5F01=5FENH:=20=EC=B6=94=EC=B6=9C=20?= =?UTF-8?q?=EC=A1=B0=EC=A0=95=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Keps.WinForms/Forms/RealExtractionForm.cs | 4 +++- Keps.WinForms/Services/ExcelReportService.cs | 20 +++++++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/Keps.WinForms/Forms/RealExtractionForm.cs b/Keps.WinForms/Forms/RealExtractionForm.cs index f58b71c..eaa06bc 100644 --- a/Keps.WinForms/Forms/RealExtractionForm.cs +++ b/Keps.WinForms/Forms/RealExtractionForm.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.ComponentModel; +using System.Data; using System.IO; using System.Linq; using System.Windows.Forms; @@ -247,7 +248,8 @@ namespace Keps.WinForms.Forms dialog.FileName = string.Format("층화_후_득표율_기준_{0}-{1}_최종_{2:yyyyMMdd_HHmmss}.xlsx", _cmbElection.SelectedItem, _cmbArea.SelectedItem, DateTime.Now); if (dialog.ShowDialog(this) == DialogResult.OK) { - _excelReportService.ExportRealExtractionWorkbook(dialog.FileName, _cmbElection.SelectedItem.ToString(), _cmbArea.SelectedItem.ToString(), GetWorkingRows(), _lastResult); + var adjustList = ((BindingList)_gridAdjustment.DataSource).ToList(); + _excelReportService.ExportRealExtractionWorkbook(dialog.FileName, _cmbElection.SelectedItem.ToString(), _cmbArea.SelectedItem.ToString(), GetWorkingRows(), _lastResult, adjustList); MessageBox.Show(this, "엑셀 저장 완료" + Environment.NewLine + dialog.FileName, "완료", MessageBoxButtons.OK, MessageBoxIcon.Information); } } diff --git a/Keps.WinForms/Services/ExcelReportService.cs b/Keps.WinForms/Services/ExcelReportService.cs index 5f4b737..de68cf2 100644 --- a/Keps.WinForms/Services/ExcelReportService.cs +++ b/Keps.WinForms/Services/ExcelReportService.cs @@ -22,7 +22,7 @@ namespace Keps.WinForms.Services /// 시도명. /// 군집 요약 행 목록(모드 시트 등에 사용). /// 실 추출 결과 DTO. - public void ExportRealExtractionWorkbook(string filePath, string electionName, string areaName, List clusterRows, RealExtractionResult result) + public void ExportRealExtractionWorkbook(string filePath, string electionName, string areaName, List clusterRows, RealExtractionResult result, List adjustList) { if (result == null) { @@ -45,7 +45,7 @@ namespace Keps.WinForms.Services WriteExtractedSheet(package.Workbook.Worksheets.Add(areaName + "-추출결과"), electionName, areaName, candidateNames, candidateVoteKeys, result.ExtractedRows ?? new List(), result.PopulationRows ?? new List(), result); WriteVerificationSummarySheet(package.Workbook.Worksheets.Add(areaName + "-자가 검증-요약분석"), electionName, areaName, candidateNames, result.VerificationRows ?? new List(), result.ClusterMax); WriteVerificationDetailSheet(package.Workbook.Worksheets.Add(areaName + "-자가 검증-세부분석"), electionName, areaName, candidateNames, candidateVoteKeys, result.ExtractedRows ?? new List(), result.VerificationRows ?? new List(), result.ClusterMax); - WriteFinalStatusSheet(package.Workbook.Worksheets.Add(areaName + "-최종 투표소 추출현황"), electionName, areaName, candidateNames, candidateVoteKeys, result.PopulationRows ?? new List(), result.ClusterMax); + WriteFinalStatusSheet(package.Workbook.Worksheets.Add(areaName + "-최종 투표소 추출현황"), electionName, areaName, candidateNames, candidateVoteKeys, result.PopulationRows ?? new List(), result.ClusterMax, adjustList); WriteClusterListSheet(package.Workbook.Worksheets.Add(areaName + "-층별 시군구 리스트"), electionName, areaName, result.PopulationRows ?? new List()); WriteModeSheet(package.Workbook.Worksheets.Add(areaName + "-기준설정 Mode"), electionName, clusterRows ?? new List(), result.PopulationRows ?? new List()); WriteModeTargetSheet(package.Workbook.Worksheets.Add(areaName + "-기준설정 Mode Target"), clusterRows ?? new List(), result.PopulationRows ?? new List()); @@ -377,7 +377,7 @@ namespace Keps.WinForms.Services /// 후보자 득표 키 목록. /// 모집단 행 목록. /// 군집(층) 최대 개수. - private static void WriteFinalStatusSheet(ExcelWorksheet ws, string electionName, string areaName, List candidateNames, List candidateVoteKeys, List rows, int clusterMax) + private static void WriteFinalStatusSheet(ExcelWorksheet ws, string electionName, string areaName, List candidateNames, List candidateVoteKeys, List rows, int clusterMax, List adjustList) { ws.Cells[1, 1].Value = areaName; ws.Cells[3, 1].Value = clusterMax + "개층"; @@ -432,6 +432,16 @@ namespace Keps.WinForms.Services foreach (ExtractionRow row in group.OrderBy(x => x.OriginalOrder)) { + bool isAdjust = adjustList.Any(a => a.ClusterNo == row.ClusterNo && a.AdjustId == row.OriginalOrder); + bool isAdjusted = adjustList.Any(a => a.ClusterNo == row.ClusterNo && a.ExtractId == row.OriginalOrder && a.AdjustId != null); + + string autoSelected = (row.IsAutoSelected || row.IsAdjustedSelected) ? "★" : null; + string adjustedSelected = isAdjust ? "★" : autoSelected; + if (isAdjusted) + { + adjustedSelected = null; + } + ws.Cells[rowIndex, 1].Value = row.ClusterNo; ws.Cells[rowIndex, 2].Value = row.OriginalOrder; ws.Cells[rowIndex, 3].Value = row.DistrictName; @@ -439,8 +449,8 @@ namespace Keps.WinForms.Services ws.Cells[rowIndex, 5].Value = row.EligibleVoterCount; ws.Cells[rowIndex, 6].Value = row.BuildingName; ws.Cells[rowIndex, 7].Value = row.Address1; - ws.Cells[rowIndex, 8].Value = (row.IsAutoSelected || row.IsAdjustedSelected) ? "★" : null; - ws.Cells[rowIndex, 9].Value = row.IsAdjustedSelected ? "★" : (row.IsAutoSelected ? "★" : null); + ws.Cells[rowIndex, 8].Value = autoSelected; + ws.Cells[rowIndex, 9].Value = adjustedSelected; ws.Cells[rowIndex, 10].Value = row.TotalCandidateVoteCount; ws.Cells[rowIndex, 11].Value = ComputeDisplayedRowRatio(row, candidateVoteKeys[0]); ws.Cells[rowIndex, 12].Value = ComputeDisplayedRowRatio(row, candidateVoteKeys[1]);