260825_03_ENH: 차트 색상을 t_survey 종속적으로 변경 및 후속처리

This commit is contained in:
2026-08-25 16:43:13 +09:00
parent fefdf17139
commit d6520a97c5
16 changed files with 281 additions and 116 deletions

View File

@@ -0,0 +1,19 @@
package com.kri.epolicy.dash.back.common.enums;
import java.util.Arrays;
public enum NegativeMode {
DEFAULT,
NEGATIVE,
SPECIFIED;
public static NegativeMode fromCodeOrDefault(String code) {
if (code == null) {
return DEFAULT;
}
return Arrays.stream(values())
.filter(mode -> mode.name().equalsIgnoreCase(code.trim()))
.findFirst()
.orElse(DEFAULT);
}
}

View File

@@ -53,6 +53,10 @@ public final class ExcelTemplateRows {
@ExcelColumn(header = "survey_title", order = 3) private String surveyTitle;
@ExcelColumn(header = "survey_alias", order = 4) private String surveyAlias;
@ExcelColumn(header = "survey_color", order = 5) private String surveyColor;
@ExcelColumn(header = "survey_highlight_color", order = 6) private String surveyHighlightColor;
@ExcelColumn(header = "survey_negative_color", order = 7) private String surveyNegativeColor;
@ExcelColumn(header = "survey_negative_highlight_color", order = 8)
private String surveyNegativeHighlightColor;
}
@Getter
@@ -86,6 +90,10 @@ public final class ExcelTemplateRows {
@ExcelColumn(header = "part_item_order", order = 3) private String partItemOrder;
@ExcelColumn(header = "part_item_title", order = 4) private String partItemTitle;
@ExcelColumn(header = "part_item_comment", order = 5) private String partItemComment;
@ExcelColumn(header = "part_item_negative_mode (DEFAULT, NEGATIVE, SPECIFIED)", order = 6)
private String partItemNegativeMode;
@ExcelColumn(header = "part_item_negative_order", order = 7)
private String partItemNegativeOrder;
}
@Getter
@@ -98,6 +106,11 @@ public final class ExcelTemplateRows {
@ExcelColumn(header = "part_item_sub_cd", order = 3) private String partItemSubCd;
@ExcelColumn(header = "part_item_sub_title", order = 4) private String partItemSubTitle;
@ExcelColumn(header = "part_item_sub_comment", order = 5) private String partItemSubComment;
@ExcelColumn(
header = "part_item_sub_negative_mode (DEFAULT, NEGATIVE, SPECIFIED)", order = 6)
private String partItemSubNegativeMode;
@ExcelColumn(header = "part_item_sub_negative_order", order = 7)
private String partItemSubNegativeOrder;
}
@Getter
@@ -135,11 +148,9 @@ public final class ExcelTemplateRows {
@ExcelColumn(header = "wave_cd", order = 0) private String waveCd;
@ExcelColumn(header = "part_cd", order = 1) private String partCd;
@ExcelColumn(header = "part_item_cd", order = 2) private String partItemCd;
@ExcelColumn(header = "survey_cd", order = 3) private String surveyCd;
@ExcelColumn(header = "part_item_sub_cd", order = 4) private String partItemSubCd;
@ExcelColumn(header = "chart_type (bar)", order = 5) private String chartType;
@ExcelColumn(header = "chart_color", order = 6) private String chartColor;
@ExcelColumn(header = "chart_gap_mode (NONE, ALL, LAST_VISIBLE)", order = 7)
@ExcelColumn(header = "part_item_sub_cd", order = 3) private String partItemSubCd;
@ExcelColumn(header = "chart_type (bar)", order = 4) private String chartType;
@ExcelColumn(header = "chart_gap_mode (NONE, ALL, LAST_VISIBLE)", order = 5)
private String chartGapMode;
}
@@ -150,14 +161,11 @@ public final class ExcelTemplateRows {
@ExcelColumn(header = "wave_cd", order = 0) private String waveCd;
@ExcelColumn(header = "part_cd", order = 1) private String partCd;
@ExcelColumn(header = "part_item_cd", order = 2) private String partItemCd;
@ExcelColumn(header = "survey_cd", order = 3) private String surveyCd;
@ExcelColumn(header = "part_item_sub_cd", order = 4) private String partItemSubCd;
@ExcelColumn(header = "part_item_sub_cd", order = 3) private String partItemSubCd;
@ExcelColumn(
header = "chart_highlight_mode (MAX_VALUE, LAST_VISIBLE, SPECIFIED)", order = 5)
header = "chart_highlight_mode (MAX_VALUE, LAST_VISIBLE, SPECIFIED)", order = 4)
private String chartHighlightMode;
@ExcelColumn(header = "chart_highlight_value", order = 6)
@ExcelColumn(header = "chart_highlight_value", order = 5)
private String chartHighlightValue;
@ExcelColumn(header = "chart_highlight_color", order = 7)
private String chartHighlightColor;
}
}

View File

@@ -2,6 +2,7 @@ package com.kri.epolicy.dash.back.dto.request;
import com.kri.epolicy.dash.back.common.enums.ChartType;
import com.kri.epolicy.dash.back.common.enums.ChartGapMode;
import com.kri.epolicy.dash.back.common.enums.NegativeMode;
import java.math.BigDecimal;
import java.util.List;
@@ -42,7 +43,10 @@ public record ExcelData(
Short surveyOrder,
String surveyTitle,
String surveyAlias,
String surveyColor
String surveyColor,
String surveyHighlightColor,
String surveyNegativeColor,
String surveyNegativeHighlightColor
) {
}
@@ -69,7 +73,9 @@ public record ExcelData(
Short partItemCd,
Short partItemOrder,
String partItemTitle,
String partItemComment
String partItemComment,
NegativeMode partItemNegativeMode,
String partItemNegativeOrder
) {
}
@@ -79,7 +85,9 @@ public record ExcelData(
Short partItemCd,
Short partItemSubCd,
String partItemSubTitle,
String partItemSubComment
String partItemSubComment,
NegativeMode partItemSubNegativeMode,
String partItemSubNegativeOrder
) {
}
@@ -111,10 +119,8 @@ public record ExcelData(
Short waveCd,
Short partCd,
Short partItemCd,
Short surveyCd,
Short partItemSubCd,
ChartType chartType,
String chartColor,
ChartGapMode chartGapMode
) {
}
@@ -123,11 +129,9 @@ public record ExcelData(
Short waveCd,
Short partCd,
Short partItemCd,
Short surveyCd,
Short partItemSubCd,
String chartHighlightMode,
String chartHighlightValue,
String chartHighlightColor
String chartHighlightValue
) {
}
}

View File

@@ -15,6 +15,8 @@ public record PartDetailResponse(
Short order,
String title,
String comment,
String negativeMode,
String negativeOrder,
Audience audience,
List<ResultGroup> resultGroups
) {
@@ -40,7 +42,9 @@ public record PartDetailResponse(
public record SubItem(
Short partItemSubCd,
String title,
String partItemSubComment
String partItemSubComment,
String negativeMode,
String negativeOrder
) {
}
@@ -49,10 +53,12 @@ public record PartDetailResponse(
String label,
String chartType,
String color,
String highlightColor,
String negativeColor,
String negativeHighlightColor,
String chartGapMode,
String chartHighlightMode,
String chartHighlightValue,
String chartHighlightColor,
Integer baseCount,
String baseText,
List<BigDecimal> values

View File

@@ -18,6 +18,9 @@ public record WaveDetailResponse(
String title,
String alias,
String color,
String highlightColor,
String negativeColor,
String negativeHighlightColor,
List<SurveyItem> items
) {
}

View File

@@ -35,10 +35,6 @@ public class TPartItemChartEntity {
@Column(name = "part_item_cd", nullable = false)
private Short partItemCd;
@NotNull
@Column(name = "survey_cd", nullable = false)
private Short surveyCd;
@Column(name = "part_item_sub_cd")
private Short partItemSubCd;
@@ -48,10 +44,6 @@ public class TPartItemChartEntity {
@Column(name = "chart_type", nullable = false, length = 32)
private String chartType;
@Size(max = 8)
@Column(name = "chart_color", length = 8)
private String chartColor;
@Size(max = 32)
@NotNull
@ColumnDefault("'NONE'")

View File

@@ -34,10 +34,6 @@ public class TPartItemChartHighlightEntity {
@Column(name = "part_item_cd", nullable = false)
private Short partItemCd;
@NotNull
@Column(name = "survey_cd", nullable = false)
private Short surveyCd;
@Column(name = "part_item_sub_cd")
private Short partItemSubCd;
@@ -50,10 +46,4 @@ public class TPartItemChartHighlightEntity {
@Column(name = "chart_highlight_value", length = 32)
private String chartHighlightValue;
@Size(max = 8)
@NotNull
@Column(name = "chart_highlight_color", nullable = false, length = 8)
private String chartHighlightColor;
}
}

View File

@@ -10,6 +10,7 @@ import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.ColumnDefault;
@Getter
@Setter
@@ -34,5 +35,14 @@ public class TPartItemEntity {
@Column(name = "part_item_comment", nullable = false)
private String partItemComment;
@Size(max = 32)
@NotNull
@ColumnDefault("'DEFAULT'")
@Column(name = "part_item_negative_mode", nullable = false, length = 32)
private String partItemNegativeMode;
@Size(max = 32)
@Column(name = "part_item_negative_order", length = 32)
private String partItemNegativeOrder;
}

View File

@@ -10,6 +10,7 @@ import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.ColumnDefault;
@Getter
@Setter
@@ -29,5 +30,14 @@ public class TPartItemSubEntity {
@Column(name = "part_item_sub_comment")
private String partItemSubComment;
@Size(max = 32)
@NotNull
@ColumnDefault("'DEFAULT'")
@Column(name = "part_item_sub_negative_mode", nullable = false, length = 32)
private String partItemSubNegativeMode;
@Size(max = 32)
@Column(name = "part_item_sub_negative_order", length = 32)
private String partItemSubNegativeOrder;
}

View File

@@ -38,5 +38,16 @@ public class TSurveyEntity {
@Column(name = "survey_color", nullable = false, length = 8)
private String surveyColor;
@Size(max = 8)
@Column(name = "survey_highlight_color", length = 8)
private String surveyHighlightColor;
}
@Size(max = 8)
@Column(name = "survey_negative_color", length = 8)
private String surveyNegativeColor;
@Size(max = 8)
@Column(name = "survey_negative_highlight_color", length = 8)
private String surveyNegativeHighlightColor;
}

View File

@@ -81,7 +81,8 @@ public class ExcelExportService {
.map(survey -> new ExcelTemplateRows.Survey(
value(survey.getId().getWaveCd()), value(survey.getId().getSurveyCd()),
value(survey.getSurveyOrder()), survey.getSurveyTitle(), survey.getSurveyAlias(),
survey.getSurveyColor()))
survey.getSurveyColor(), survey.getSurveyHighlightColor(),
survey.getSurveyNegativeColor(), survey.getSurveyNegativeHighlightColor()))
.toList(),
surveyItemRepository.findByWaveCdOrderBySurveyItemOrderAsc(waveCd).stream()
.sorted(Comparator.comparing(
@@ -107,7 +108,8 @@ public class ExcelExportService {
.map(item -> new ExcelTemplateRows.PartItem(
value(item.getId().getWaveCd()), value(item.getId().getPartCd()),
value(item.getId().getPartItemCd()), value(item.getPartItemOrder()),
item.getPartItemTitle(), item.getPartItemComment()))
item.getPartItemTitle(), item.getPartItemComment(),
item.getPartItemNegativeMode(), item.getPartItemNegativeOrder()))
.toList(),
partItemSubRepository.findByIdWaveCd(waveCd).stream()
.sorted(Comparator.comparing(
@@ -118,7 +120,8 @@ public class ExcelExportService {
.map(sub -> new ExcelTemplateRows.PartItemSub(
value(sub.getId().getWaveCd()), value(sub.getId().getPartCd()),
value(sub.getId().getPartItemCd()), value(sub.getId().getPartItemSubCd()),
sub.getPartItemSubTitle(), sub.getPartItemSubComment()))
sub.getPartItemSubTitle(), sub.getPartItemSubComment(),
sub.getPartItemSubNegativeMode(), sub.getPartItemSubNegativeOrder()))
.toList(),
bases.stream().map(base -> new ExcelTemplateRows.PartItemBase(
value(base.getWaveCd()), value(base.getPartCd()), value(base.getPartItemCd()),
@@ -126,14 +129,13 @@ public class ExcelExportService {
value(base.getBaseCount()), base.getBaseText())).toList(),
charts.stream().map(chart -> new ExcelTemplateRows.PartItemChart(
value(chart.getWaveCd()), value(chart.getPartCd()), value(chart.getPartItemCd()),
value(chart.getSurveyCd()), value(chart.getPartItemSubCd()),
chartTypeLabel(chart.getChartType()), chart.getChartColor(),
value(chart.getPartItemSubCd()), chartTypeLabel(chart.getChartType()),
ChartGapMode.fromCodeOrDefault(chart.getChartGapMode()).name())).toList(),
highlights.stream().map(highlight -> new ExcelTemplateRows.PartItemChartHighlight(
value(highlight.getWaveCd()), value(highlight.getPartCd()),
value(highlight.getPartItemCd()), value(highlight.getSurveyCd()),
value(highlight.getPartItemSubCd()), highlight.getChartHighlightMode(),
highlight.getChartHighlightValue(), highlight.getChartHighlightColor())).toList(),
value(highlight.getPartItemCd()), value(highlight.getPartItemSubCd()),
highlight.getChartHighlightMode(),
highlight.getChartHighlightValue())).toList(),
itemData.stream().map(item -> new ExcelTemplateRows.PartItemData(
value(item.getWaveCd()), value(item.getPartCd()), value(item.getPartItemCd()),
value(item.getSurveyCd()), value(item.getPartItemSubCd()),
@@ -154,14 +156,12 @@ public class ExcelExportService {
private Comparator<TPartItemChartEntity> resultSeriesComparatorForChart() {
return Comparator.comparing(TPartItemChartEntity::getPartCd)
.thenComparing(TPartItemChartEntity::getPartItemCd)
.thenComparing(TPartItemChartEntity::getSurveyCd)
.thenComparing(TPartItemChartEntity::getPartItemSubCd, NULLABLE_SHORT);
}
private Comparator<TPartItemChartHighlightEntity> resultSeriesComparatorForHighlight() {
return Comparator.comparing(TPartItemChartHighlightEntity::getPartCd)
.thenComparing(TPartItemChartHighlightEntity::getPartItemCd)
.thenComparing(TPartItemChartHighlightEntity::getSurveyCd)
.thenComparing(TPartItemChartHighlightEntity::getPartItemSubCd, NULLABLE_SHORT);
}

View File

@@ -87,6 +87,9 @@ public class ExcelImportService {
entity.setSurveyTitle(row.surveyTitle());
entity.setSurveyAlias(row.surveyAlias());
entity.setSurveyColor(row.surveyColor());
entity.setSurveyHighlightColor(row.surveyHighlightColor());
entity.setSurveyNegativeColor(row.surveyNegativeColor());
entity.setSurveyNegativeHighlightColor(row.surveyNegativeHighlightColor());
return entity;
}).toList());
@@ -114,6 +117,8 @@ public class ExcelImportService {
entity.setPartItemOrder(row.partItemOrder());
entity.setPartItemTitle(row.partItemTitle());
entity.setPartItemComment(row.partItemComment());
entity.setPartItemNegativeMode(row.partItemNegativeMode().name());
entity.setPartItemNegativeOrder(row.partItemNegativeOrder());
return entity;
}).toList());
@@ -123,6 +128,8 @@ public class ExcelImportService {
row.waveCd(), row.partCd(), row.partItemCd(), row.partItemSubCd()));
entity.setPartItemSubTitle(row.partItemSubTitle());
entity.setPartItemSubComment(row.partItemSubComment());
entity.setPartItemSubNegativeMode(row.partItemSubNegativeMode().name());
entity.setPartItemSubNegativeOrder(row.partItemSubNegativeOrder());
return entity;
}).toList());
@@ -143,10 +150,8 @@ public class ExcelImportService {
entity.setWaveCd(row.waveCd());
entity.setPartCd(row.partCd());
entity.setPartItemCd(row.partItemCd());
entity.setSurveyCd(row.surveyCd());
entity.setPartItemSubCd(row.partItemSubCd());
entity.setChartType(row.chartType().getCode());
entity.setChartColor(row.chartColor());
entity.setChartGapMode(row.chartGapMode().name());
return entity;
}).toList());
@@ -156,11 +161,9 @@ public class ExcelImportService {
entity.setWaveCd(row.waveCd());
entity.setPartCd(row.partCd());
entity.setPartItemCd(row.partItemCd());
entity.setSurveyCd(row.surveyCd());
entity.setPartItemSubCd(row.partItemSubCd());
entity.setChartHighlightMode(row.chartHighlightMode());
entity.setChartHighlightValue(row.chartHighlightValue());
entity.setChartHighlightColor(row.chartHighlightColor());
return entity;
}).toList());

View File

@@ -6,6 +6,7 @@ import com.kri.common.feature.web.BusinessException;
import com.kri.epolicy.dash.back.common.enums.ChartType;
import com.kri.epolicy.dash.back.common.enums.ChartHighlightMode;
import com.kri.epolicy.dash.back.common.enums.ChartGapMode;
import com.kri.epolicy.dash.back.common.enums.NegativeMode;
import com.kri.epolicy.dash.back.dto.excel.ExcelTemplateRows;
import com.kri.epolicy.dash.back.dto.request.ExcelData;
import com.kri.epolicy.dash.back.dto.request.ExcelData.PartItemBaseRow;
@@ -67,7 +68,9 @@ public class ExcelImportValidator {
row.getWaveInfoContent()), this::toWaveInfoRow),
readRows(workbook, ExcelTemplateRows.SURVEY_SHEET, ExcelTemplateRows.Survey.class,
row -> allBlank(row.getWaveCd(), row.getSurveyCd(), row.getSurveyOrder(),
row.getSurveyTitle(), row.getSurveyAlias(), row.getSurveyColor()),
row.getSurveyTitle(), row.getSurveyAlias(), row.getSurveyColor(),
row.getSurveyHighlightColor(), row.getSurveyNegativeColor(),
row.getSurveyNegativeHighlightColor()),
this::toSurveyRow),
readRows(workbook, ExcelTemplateRows.SURVEY_ITEM_SHEET,
ExcelTemplateRows.SurveyItem.class,
@@ -78,13 +81,15 @@ public class ExcelImportValidator {
row.getPartTitle()), this::toPartRow),
readRows(workbook, ExcelTemplateRows.PART_ITEM_SHEET, ExcelTemplateRows.PartItem.class,
row -> allBlank(row.getWaveCd(), row.getPartCd(), row.getPartItemCd(),
row.getPartItemOrder(), row.getPartItemTitle(), row.getPartItemComment()),
row.getPartItemOrder(), row.getPartItemTitle(), row.getPartItemComment(),
row.getPartItemNegativeMode(), row.getPartItemNegativeOrder()),
this::toPartItemRow),
readRows(workbook, ExcelTemplateRows.PART_ITEM_SUB_SHEET,
ExcelTemplateRows.PartItemSub.class,
row -> allBlank(row.getWaveCd(), row.getPartCd(), row.getPartItemCd(),
row.getPartItemSubCd(), row.getPartItemSubTitle(),
row.getPartItemSubComment()), this::toPartItemSubRow),
row.getPartItemSubComment(), row.getPartItemSubNegativeMode(),
row.getPartItemSubNegativeOrder()), this::toPartItemSubRow),
readRows(workbook, ExcelTemplateRows.PART_ITEM_BASE_SHEET,
ExcelTemplateRows.PartItemBase.class,
row -> allBlank(row.getWaveCd(), row.getPartCd(), row.getPartItemCd(),
@@ -93,13 +98,13 @@ public class ExcelImportValidator {
readRows(workbook, ExcelTemplateRows.PART_ITEM_CHART_SHEET,
ExcelTemplateRows.PartItemChart.class,
row -> allBlank(row.getWaveCd(), row.getPartCd(), row.getPartItemCd(),
row.getSurveyCd(), row.getPartItemSubCd(), row.getChartType(),
row.getChartColor(), row.getChartGapMode()), this::toPartItemChartRow),
row.getPartItemSubCd(), row.getChartType(),
row.getChartGapMode()), this::toPartItemChartRow),
readRows(workbook, ExcelTemplateRows.PART_ITEM_CHART_HIGHLIGHT_SHEET,
ExcelTemplateRows.PartItemChartHighlight.class,
row -> allBlank(row.getWaveCd(), row.getPartCd(), row.getPartItemCd(),
row.getSurveyCd(), row.getPartItemSubCd(), row.getChartHighlightMode(),
row.getChartHighlightValue(), row.getChartHighlightColor()),
row.getPartItemSubCd(), row.getChartHighlightMode(),
row.getChartHighlightValue()),
this::toPartItemChartHighlightRow),
readRows(workbook, ExcelTemplateRows.PART_ITEM_DATA_SHEET,
ExcelTemplateRows.PartItemData.class,
@@ -209,7 +214,11 @@ public class ExcelImportValidator {
requiredShort(row.getSurveyOrder(), "survey_order", context),
requiredString(row.getSurveyTitle(), "survey_title", 128, context),
requiredString(row.getSurveyAlias(), "survey_alias", 32, context),
requiredColor(row.getSurveyColor(), "survey_color", context)
requiredColor(row.getSurveyColor(), "survey_color", context),
optionalColor(row.getSurveyHighlightColor(), "survey_highlight_color", context),
optionalColor(row.getSurveyNegativeColor(), "survey_negative_color", context),
optionalColor(
row.getSurveyNegativeHighlightColor(), "survey_negative_highlight_color", context)
);
}
@@ -236,6 +245,10 @@ public class ExcelImportValidator {
}
private PartItemRow toPartItemRow(ExcelTemplateRows.PartItem row, RowContext context) {
NegativeMode mode = NegativeMode.fromCodeOrDefault(normalized(row.getPartItemNegativeMode()));
String order = optionalString(
row.getPartItemNegativeOrder(), "part_item_negative_order", 32, context);
validateNegativeValue(mode, order, "part_item_negative_order", context);
return new PartItemRow(
requiredShort(row.getWaveCd(), "wave_cd", context),
requiredShort(row.getPartCd(), "part_cd", context),
@@ -243,7 +256,9 @@ public class ExcelImportValidator {
requiredShort(row.getPartItemOrder(), "part_item_order", context),
requiredString(row.getPartItemTitle(), "part_item_title", 128, context),
Objects.requireNonNullElse(
optionalString(row.getPartItemComment(), "part_item_comment", null, context), "")
optionalString(row.getPartItemComment(), "part_item_comment", null, context), ""),
mode,
order
);
}
@@ -251,13 +266,20 @@ public class ExcelImportValidator {
ExcelTemplateRows.PartItemSub row,
RowContext context
) {
NegativeMode mode = NegativeMode.fromCodeOrDefault(
normalized(row.getPartItemSubNegativeMode()));
String order = optionalString(
row.getPartItemSubNegativeOrder(), "part_item_sub_negative_order", 32, context);
validateNegativeValue(mode, order, "part_item_sub_negative_order", context);
return new PartItemSubRow(
requiredShort(row.getWaveCd(), "wave_cd", context),
requiredShort(row.getPartCd(), "part_cd", context),
requiredShort(row.getPartItemCd(), "part_item_cd", context),
requiredShort(row.getPartItemSubCd(), "part_item_sub_cd", context),
requiredString(row.getPartItemSubTitle(), "part_item_sub_title", 128, context),
optionalString(row.getPartItemSubComment(), "part_item_sub_comment", null, context)
optionalString(row.getPartItemSubComment(), "part_item_sub_comment", null, context),
mode,
order
);
}
@@ -301,10 +323,8 @@ public class ExcelImportValidator {
requiredShort(row.getWaveCd(), "wave_cd", context),
requiredShort(row.getPartCd(), "part_cd", context),
requiredShort(row.getPartItemCd(), "part_item_cd", context),
requiredShort(row.getSurveyCd(), "survey_cd", context),
optionalShort(row.getPartItemSubCd(), "part_item_sub_cd", context),
requiredChartType(row.getChartType(), "chart_type", context),
optionalColor(row.getChartColor(), "chart_color", context),
ChartGapMode.fromCodeOrDefault(normalized(row.getChartGapMode()))
);
}
@@ -322,11 +342,9 @@ public class ExcelImportValidator {
requiredShort(row.getWaveCd(), "wave_cd", context),
requiredShort(row.getPartCd(), "part_cd", context),
requiredShort(row.getPartItemCd(), "part_item_cd", context),
requiredShort(row.getSurveyCd(), "survey_cd", context),
optionalShort(row.getPartItemSubCd(), "part_item_sub_cd", context),
mode.name(),
value,
requiredColor(row.getChartHighlightColor(), "chart_highlight_color", context)
value
);
}
@@ -349,9 +367,9 @@ public class ExcelImportValidator {
Set<SubKey> subKeys = uniqueKeys(data.partItemSubs(),
row -> new SubKey(row.waveCd(), row.partCd(), row.partItemCd(), row.partItemSubCd()),
ExcelTemplateRows.PART_ITEM_SUB_SHEET);
uniqueKeys(data.partItemCharts(), this::resultSeriesKey,
uniqueKeys(data.partItemCharts(), this::chartConfigKey,
ExcelTemplateRows.PART_ITEM_CHART_SHEET);
uniqueKeys(data.partItemChartHighlights(), this::resultSeriesKey,
uniqueKeys(data.partItemChartHighlights(), this::chartConfigKey,
ExcelTemplateRows.PART_ITEM_CHART_HIGHLIGHT_SHEET);
requireParents(data.waveInfos(), WaveInfoRow::waveCd, waveKeys,
@@ -384,27 +402,27 @@ public class ExcelImportValidator {
ExcelTemplateRows.PART_ITEM_DATA_SHEET);
}
for (PartItemChartRow row : data.partItemCharts()) {
validateResultRelationship(row.waveCd(), row.partCd(), row.partItemCd(), row.surveyCd(),
row.partItemSubCd(), itemKeys, surveyKeys, subKeys, itemsWithSubs,
validateItemSubRelationship(row.waveCd(), row.partCd(), row.partItemCd(),
row.partItemSubCd(), itemKeys, subKeys, itemsWithSubs,
ExcelTemplateRows.PART_ITEM_CHART_SHEET);
}
for (PartItemChartHighlightRow row : data.partItemChartHighlights()) {
validateResultRelationship(row.waveCd(), row.partCd(), row.partItemCd(), row.surveyCd(),
row.partItemSubCd(), itemKeys, surveyKeys, subKeys, itemsWithSubs,
validateItemSubRelationship(row.waveCd(), row.partCd(), row.partItemCd(),
row.partItemSubCd(), itemKeys, subKeys, itemsWithSubs,
ExcelTemplateRows.PART_ITEM_CHART_HIGHLIGHT_SHEET);
}
validateResultBases(data.partItemBases(), data.partItemData());
validateCategoryConsistency(data.partItemData());
}
private ResultSeriesKey resultSeriesKey(PartItemChartRow row) {
return new ResultSeriesKey(
row.waveCd(), row.partCd(), row.partItemCd(), row.surveyCd(), row.partItemSubCd());
private ResultGroupKey chartConfigKey(PartItemChartRow row) {
return new ResultGroupKey(
row.waveCd(), row.partCd(), row.partItemCd(), row.partItemSubCd());
}
private ResultSeriesKey resultSeriesKey(PartItemChartHighlightRow row) {
return new ResultSeriesKey(
row.waveCd(), row.partCd(), row.partItemCd(), row.surveyCd(), row.partItemSubCd());
private ResultGroupKey chartConfigKey(PartItemChartHighlightRow row) {
return new ResultGroupKey(
row.waveCd(), row.partCd(), row.partItemCd(), row.partItemSubCd());
}
private void validateResultBases(List<PartItemBaseRow> bases, List<PartItemDataRow> data) {
@@ -466,14 +484,29 @@ public class ExcelImportValidator {
Set<ItemKey> itemsWithSubs,
String sheetName
) {
ItemKey itemKey = new ItemKey(waveCd, partCd, partItemCd);
if (!itemKeys.contains(itemKey)) {
throw relationshipError(sheetName, "존재하지 않는 문항을 참조합니다: " + itemKey);
}
validateItemSubRelationship(
waveCd, partCd, partItemCd, partItemSubCd,
itemKeys, subKeys, itemsWithSubs, sheetName);
if (!surveyKeys.contains(new SurveyKey(waveCd, surveyCd))) {
throw relationshipError(sheetName,
"동일 Wave에 존재하지 않는 조사대상을 참조합니다: " + surveyCd);
}
}
private void validateItemSubRelationship(
Short waveCd,
Short partCd,
Short partItemCd,
Short partItemSubCd,
Set<ItemKey> itemKeys,
Set<SubKey> subKeys,
Set<ItemKey> itemsWithSubs,
String sheetName
) {
ItemKey itemKey = new ItemKey(waveCd, partCd, partItemCd);
if (!itemKeys.contains(itemKey)) {
throw relationshipError(sheetName, "존재하지 않는 문항을 참조합니다: " + itemKey);
}
if (itemsWithSubs.contains(itemKey)) {
if (partItemSubCd == null) {
throw relationshipError(sheetName,
@@ -681,6 +714,22 @@ public class ExcelImportValidator {
}
}
private void validateNegativeValue(
NegativeMode mode,
String value,
String column,
RowContext context
) {
if (mode == NegativeMode.SPECIFIED) {
if (value == null || !SPECIFIED_VALUE_PATTERN.matcher(value).matches()) {
throw cellError(context, column,
"SPECIFIED 모드는 공백 없는 정수 목록이어야 합니다. 예: 1,3,5");
}
} else if (value != null) {
throw cellError(context, column, mode.name() + " 모드에서는 NULL이어야 합니다.");
}
}
private String requiredRaw(String rawValue, String column, RowContext context) {
String value = normalized(rawValue);
if (value == null) {

View File

@@ -2,8 +2,10 @@ package com.kri.epolicy.dash.back.service;
import com.kri.common.feature.web.BusinessException;
import com.kri.common.feature.web.RequestUserContext;
import com.kri.epolicy.dash.back.common.enums.ChartType;
import com.kri.epolicy.dash.back.common.enums.ChartGapMode;
import com.kri.epolicy.dash.back.common.enums.ChartHighlightMode;
import com.kri.epolicy.dash.back.common.enums.ChartType;
import com.kri.epolicy.dash.back.common.enums.NegativeMode;
import com.kri.epolicy.dash.back.config.FileStorageProperties;
import com.kri.epolicy.dash.back.dto.response.PartDetailResponse;
import com.kri.epolicy.dash.back.dto.response.PartDetailResponse.Audience;
@@ -103,6 +105,9 @@ public class WaveQueryService {
survey.getSurveyTitle(),
survey.getSurveyAlias(),
survey.getSurveyColor(),
highlightColor(survey),
negativeColor(survey),
negativeHighlightColor(survey),
surveyItems.getOrDefault(survey.getId().getSurveyCd(), List.of()).stream()
.map(item -> new WaveDetailResponse.SurveyItem(
item.getSurveyItemTitle(), item.getSurveyItemContent()))
@@ -197,7 +202,13 @@ public class WaveQueryService {
for (TPartItemSubEntity sub : subs) {
Short subCd = sub.getId().getPartItemSubCd();
groups.add(toResultGroup(
new SubItem(subCd, sub.getPartItemSubTitle(), sub.getPartItemSubComment()),
new SubItem(
subCd,
sub.getPartItemSubTitle(),
sub.getPartItemSubComment(),
negativeMode(sub.getPartItemSubNegativeMode()),
negativeOrder(
sub.getPartItemSubNegativeMode(), sub.getPartItemSubNegativeOrder())),
bases.stream().filter(base -> subCd.equals(base.getPartItemSubCd())).toList(),
charts.stream().filter(chart -> subCd.equals(chart.getPartItemSubCd())).toList(),
highlights.stream()
@@ -215,6 +226,8 @@ public class WaveQueryService {
item.getPartItemOrder(),
item.getPartItemTitle(),
item.getPartItemComment(),
negativeMode(item.getPartItemNegativeMode()),
negativeOrder(item.getPartItemNegativeMode(), item.getPartItemNegativeOrder()),
toAudience(audienceCodes, surveys, surveyByCode),
List.copyOf(groups)
);
@@ -231,13 +244,8 @@ public class WaveQueryService {
Map<Short, TPartItemBaseEntity> baseBySurvey = bases.stream().collect(Collectors.toMap(
TPartItemBaseEntity::getSurveyCd, Function.identity(), (left, right) -> left,
LinkedHashMap::new));
Map<Short, TPartItemChartEntity> chartBySurvey = charts.stream().collect(Collectors.toMap(
TPartItemChartEntity::getSurveyCd, Function.identity(), (left, right) -> left,
LinkedHashMap::new));
Map<Short, TPartItemChartHighlightEntity> highlightBySurvey = highlights.stream()
.collect(Collectors.toMap(
TPartItemChartHighlightEntity::getSurveyCd, Function.identity(),
(left, right) -> left, LinkedHashMap::new));
TPartItemChartEntity chart = charts.stream().findFirst().orElse(null);
TPartItemChartHighlightEntity highlight = highlights.stream().findFirst().orElse(null);
Map<Short, List<TPartItemDataEntity>> dataBySurvey = data.stream().collect(
Collectors.groupingBy(TPartItemDataEntity::getSurveyCd,
LinkedHashMap::new, Collectors.toList()));
@@ -255,20 +263,18 @@ public class WaveQueryService {
List<Series> series = surveyCodes.stream().map(surveyCd -> {
TPartItemBaseEntity base = baseBySurvey.get(surveyCd);
TSurveyEntity survey = surveyByCode.get(surveyCd);
TPartItemChartEntity chart = chartBySurvey.get(surveyCd);
TPartItemChartHighlightEntity highlight = highlightBySurvey.get(surveyCd);
return new Series(
surveyCd,
survey.getSurveyAlias(),
chart == null || chart.getChartType() == null
? ChartType.BAR.getCode() : chart.getChartType(),
chart == null || chart.getChartColor() == null
? survey.getSurveyColor() : chart.getChartColor(),
chartType(chart == null ? null : chart.getChartType()),
survey.getSurveyColor(),
highlightColor(survey),
negativeColor(survey),
negativeHighlightColor(survey),
ChartGapMode.fromCodeOrDefault(
chart == null ? null : chart.getChartGapMode()).name(),
highlight == null ? null : highlight.getChartHighlightMode(),
highlight == null ? null : highlight.getChartHighlightValue(),
highlight == null ? null : highlight.getChartHighlightColor(),
highlightMode(highlight == null ? null : highlight.getChartHighlightMode()),
highlightValue(highlight),
base == null ? null : base.getBaseCount(),
base == null ? null : base.getBaseText(),
dataBySurvey.get(surveyCd).stream()
@@ -280,6 +286,58 @@ public class WaveQueryService {
return new ResultGroup(subItem, categories, series);
}
private String highlightColor(TSurveyEntity survey) {
return survey.getSurveyHighlightColor() == null
? survey.getSurveyColor() : survey.getSurveyHighlightColor();
}
private String negativeColor(TSurveyEntity survey) {
return survey.getSurveyNegativeColor() == null
? survey.getSurveyColor() : survey.getSurveyNegativeColor();
}
private String negativeHighlightColor(TSurveyEntity survey) {
if (survey.getSurveyNegativeHighlightColor() != null) {
return survey.getSurveyNegativeHighlightColor();
}
if (survey.getSurveyNegativeColor() != null) {
return survey.getSurveyNegativeColor();
}
return highlightColor(survey);
}
private String negativeMode(String code) {
return NegativeMode.fromCodeOrDefault(code).name();
}
private String negativeOrder(String modeCode, String order) {
return NegativeMode.fromCodeOrDefault(modeCode) == NegativeMode.SPECIFIED
? order : null;
}
private String chartType(String code) {
try {
return ChartType.fromCode(code).getCode();
} catch (IllegalArgumentException exception) {
return ChartType.BAR.getCode();
}
}
private String highlightMode(String code) {
try {
return ChartHighlightMode.fromCode(code).name();
} catch (IllegalArgumentException exception) {
return null;
}
}
private String highlightValue(TPartItemChartHighlightEntity highlight) {
return highlight != null
&& ChartHighlightMode.SPECIFIED.name()
.equals(highlightMode(highlight.getChartHighlightMode()))
? highlight.getChartHighlightValue() : null;
}
private Audience toAudience(
Set<Short> audienceCodes,
List<TSurveyEntity> surveys,