260320_01_ENH: 추출 조정 구현

This commit is contained in:
2026-03-20 14:05:44 +09:00
parent 8c0b02233e
commit bbdf40c5e3
2 changed files with 18 additions and 6 deletions

View File

@@ -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<AdjustmentRow>)_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);
}
}

View File

@@ -22,7 +22,7 @@ namespace Keps.WinForms.Services
/// <param name="areaName">시도명.</param>
/// <param name="clusterRows">군집 요약 행 목록(모드 시트 등에 사용).</param>
/// <param name="result">실 추출 결과 DTO.</param>
public void ExportRealExtractionWorkbook(string filePath, string electionName, string areaName, List<ClusterSummaryRow> clusterRows, RealExtractionResult result)
public void ExportRealExtractionWorkbook(string filePath, string electionName, string areaName, List<ClusterSummaryRow> clusterRows, RealExtractionResult result, List<AdjustmentRow> 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<ExtractionRow>(), result.PopulationRows ?? new List<ExtractionRow>(), result);
WriteVerificationSummarySheet(package.Workbook.Worksheets.Add(areaName + "-자가 검증-요약분석"), electionName, areaName, candidateNames, result.VerificationRows ?? new List<VerificationSummaryRow>(), result.ClusterMax);
WriteVerificationDetailSheet(package.Workbook.Worksheets.Add(areaName + "-자가 검증-세부분석"), electionName, areaName, candidateNames, candidateVoteKeys, result.ExtractedRows ?? new List<ExtractionRow>(), result.VerificationRows ?? new List<VerificationSummaryRow>(), result.ClusterMax);
WriteFinalStatusSheet(package.Workbook.Worksheets.Add(areaName + "-최종 투표소 추출현황"), electionName, areaName, candidateNames, candidateVoteKeys, result.PopulationRows ?? new List<ExtractionRow>(), result.ClusterMax);
WriteFinalStatusSheet(package.Workbook.Worksheets.Add(areaName + "-최종 투표소 추출현황"), electionName, areaName, candidateNames, candidateVoteKeys, result.PopulationRows ?? new List<ExtractionRow>(), result.ClusterMax, adjustList);
WriteClusterListSheet(package.Workbook.Worksheets.Add(areaName + "-층별 시군구 리스트"), electionName, areaName, result.PopulationRows ?? new List<ExtractionRow>());
WriteModeSheet(package.Workbook.Worksheets.Add(areaName + "-기준설정 Mode"), electionName, clusterRows ?? new List<ClusterSummaryRow>(), result.PopulationRows ?? new List<ExtractionRow>());
WriteModeTargetSheet(package.Workbook.Worksheets.Add(areaName + "-기준설정 Mode Target"), clusterRows ?? new List<ClusterSummaryRow>(), result.PopulationRows ?? new List<ExtractionRow>());
@@ -377,7 +377,7 @@ namespace Keps.WinForms.Services
/// <param name="candidateVoteKeys">후보자 득표 키 목록.</param>
/// <param name="rows">모집단 행 목록.</param>
/// <param name="clusterMax">군집(층) 최대 개수.</param>
private static void WriteFinalStatusSheet(ExcelWorksheet ws, string electionName, string areaName, List<string> candidateNames, List<string> candidateVoteKeys, List<ExtractionRow> rows, int clusterMax)
private static void WriteFinalStatusSheet(ExcelWorksheet ws, string electionName, string areaName, List<string> candidateNames, List<string> candidateVoteKeys, List<ExtractionRow> rows, int clusterMax, List<AdjustmentRow> 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]);