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

@@ -15,7 +15,7 @@
- Keep user and file data outside the Excel bulk-import scope. Import the remaining project data from one Excel workbook containing multiple sheets.
- The Excel workbook has eleven required table-named sheets: `t_wave`, `t_wave_info`, `t_survey`, `t_survey_item`, `t_part`, `t_part_item`, `t_part_item_sub`, `t_part_item_base`, `t_part_item_chart`, `t_part_item_chart_highlight`, and `t_part_item_data`. Headers use database names and constrained headers list every allowed value in parentheses. The workbook must contain all referenced logical parents.
- Omit every auto-increment `_idx` column from Excel. Replacement imports regenerate identities.
- Reject duplicate workbook logical keys: `(wave_cd, wave_info_order)` for Wave info; `(wave_cd, survey_cd, survey_item_order)` for survey items; `(wave_cd, part_cd, part_item_cd, survey_cd, part_item_sub_cd)` for base, chart, and highlight rows; and that result-series key plus `part_item_data_order` for data rows.
- Reject duplicate Excel keys: Wave info `(wave_cd,wave_info_order)`; survey item `(wave_cd,survey_cd,survey_item_order)`; base `(wave_cd,part_cd,part_item_cd,survey_cd,part_item_sub_cd)`; chart/highlight omit `survey_cd`; data adds `part_item_data_order` to base.
- Define the Excel import/export schema once with KriCommon `ExcelColumn` DTOs. Use KriCommon `ExcelMapper` for workbook mapping and keep only project-specific type, value, and cross-sheet relationship rules in a consumer-local validator; do not duplicate a general-purpose Excel parser.
- Excel endpoints are `POST /api/v1/excel/import`, `GET /api/v1/excel/template`, `GET /api/v1/excel/waves/{waveCd}/export`, and `DELETE /api/v1/excel/waves/{waveCd}`. Downloads use the same eleven sheets, order, and headers; a missing Wave exports an empty workbook.
- Imports atomically replace every included Wave: validate first, delete all eleven managed tables, then insert. Failures restore prior data. Standalone reset uses the same child-to-root deletion and retains `t_file` metadata and physical files, allowing temporary orphans until that `wave_cd` is reimported.
@@ -34,14 +34,15 @@
- A normal item has no `t_part_item_sub` rows, and both base and data rows must use `part_item_sub_cd = NULL`. Never use `0` as a substitute for this `NULL` value.
- An item with sub-items has one or more `t_part_item_sub` rows. Every non-null `part_item_sub_cd` in its base and data rows must reference a sub-item belonging to the same `(wave_cd, part_cd, part_item_cd)`.
- Every survey code used by `t_part_item_base` or `t_part_item_data` must belong to the same Wave. Survey items must likewise belong to an existing `(wave_cd, survey_cd)`.
- Treat `t_survey.survey_color` as a required `VARCHAR(8)` value. Include it as the `survey_color` column in the Excel template/import contract and persist it with each survey.
- Store four `VARCHAR(8)` survey palette colors: required `survey_color` plus nullable highlight, negative, and negative-highlight colors. Include all in Excel/API; fall back to default, default, and negative/highlight/default respectively.
- Use `t_part_item_base` as the preferred source for determining which survey audiences apply to an item. Display the single matching `survey_alias` when only one audience applies; display `공통` when all defined audiences apply.
- Store an optional display string in `t_part_item_base.base_text` (`VARCHAR(128)`). Do not reconstruct it from `base_count`, and do not retain the removed `base_pre_text` or `base_post_text` fields in entities, Excel contracts, or query assembly.
- Use the corresponding `*_order` column for API and screen ordering: `wave_info_order`, `survey_order`, `survey_item_order`, `file_order`, `part_order`, `part_item_order`, and `part_item_data_order`. Use `part_item_sub_cd` as the default sub-item order because the schema has no separate sub-item order column.
- Use the same `t_part_item_data` rows for both chart and statistical-table views. `is_chart_visible` is a required Boolean column with database default `1`; statistical tables use every row, while charts omit categories and matching values whose flag is false. Do not introduce a separate table-data source that could diverge from chart values.
- Resolve `chart_type`, `chart_color`, and `chart_gap_mode` per `(wave_cd, part_cd, part_item_cd, survey_cd, part_item_sub_cd)` from `t_part_item_chart`, not `t_part_item`. Defaults are `BAR`, `t_survey.survey_color`, and `NONE`; normalize null or unknown gap modes to `NONE`. Allowed gap modes are `NONE`, `ALL`, and `LAST_VISIBLE`.
- Resolve `t_part_item_chart_highlight` independently from `t_part_item_chart`; a highlight may exist without a chart-setting row. Return `chart_highlight_mode`, `chart_highlight_value`, and `chart_highlight_color` to the frontend without calculating highlighted categories in the backend. Supported modes are `MAX_VALUE`, `LAST_VISIBLE`, and `SPECIFIED`; only `SPECIFIED` accepts a non-null, comma-separated integer value with no spaces.
- Treat null `part_item_sub_cd` values as equal when matching normal-item chart and highlight settings. Validate at Excel import that chart and highlight logical keys are unique, normal items use null sub codes, and colors use `#RRGGBB` format.
- Chart/highlight key is `(wave_cd,part_cd,part_item_cd,part_item_sub_cd)`; one config applies to all survey series in its group. Chart type/gap default to `BAR`/`NONE`; colors come from survey palettes.
- Resolve chart highlights independently and return mode/value without calculating highlighted categories. Supported modes are `MAX_VALUE`, `LAST_VISIBLE`, and `SPECIFIED`; only `SPECIFIED` accepts a non-null comma-separated integer list. Highlight colors come only from the survey palette.
- Store item and sub-item negative mode/order independently (`DEFAULT`, `NEGATIVE`, `SPECIFIED`); sub settings never inherit parent settings. Only `SPECIFIED` accepts an order list. Return these settings and survey palette colors so the frontend classifies rows and applies final colors.
- Treat null `part_item_sub_cd` values as equal when matching normal-item chart/highlight settings. Validate Excel logical-key uniqueness, null sub codes for normal items, negative/highlight order syntax, and palette colors as `#RRGGBB`.
- Avoid N+1 query patterns when assembling a Wave dashboard. Fetch the required Part, Item, Sub, Base, and Data ranges in batches and assemble the response hierarchy in the backend.
## Frontend API Contract
@@ -51,7 +52,7 @@
- Revalidate Wave access on both Wave-detail and Part-detail requests. Throw a KriCommon `BusinessException` with forbidden status when a restricted user requests a closed Wave; frontend visibility is not an authorization boundary.
- Assemble normal and sub-item results through one `resultGroups` response shape. A normal item has one group with `subItem = null`; an item with sub-items has one group per Sub in `part_item_sub_cd` order.
- Return categories as objects containing `order`, `label`, and `chartVisible`, alongside complete survey value series. The frontend uses all category/value indexes for statistical tables and filters matching indexes only for chart rendering. Reject Excel imports when category labels, display orders, or chart-visibility flags differ between survey series in the same Item/Sub result group.
- Expose each survey's stored color as `color` in both Wave-detail survey objects and Part-detail series objects so the frontend uses one server-managed color mapping.
- Expose effective `color`, `highlightColor`, `negativeColor`, and `negativeHighlightColor` in both Wave-detail surveys and Part-detail series. Return item/sub-item `negativeMode` and nullable `negativeOrder`; the frontend classifies and colors chart rows.
- Return the stored nullable `t_part_item_base.base_text` value unchanged as Part-detail `series[].baseText`; `baseCount` remains a separate numeric field.
- Return `series[].chartGapMode`; the frontend applies `NONE`, `ALL`, or `LAST_VISIBLE`, where the last mode uses the greatest visible `part_item_data_order`.
- When importing `part_item_data_value`, round to scale 10 with `RoundingMode.HALF_UP` before validating and storing it as `DECIMAL(14,10)`. Reject only values that still exceed precision 14 after rounding.

View File

@@ -277,7 +277,7 @@ When implementation is complete, report in Korean:
- Keep user and file data outside the Excel bulk-import scope. Import the remaining project data from one Excel workbook containing multiple sheets.
- The Excel workbook has eleven required table-named sheets: `t_wave`, `t_wave_info`, `t_survey`, `t_survey_item`, `t_part`, `t_part_item`, `t_part_item_sub`, `t_part_item_base`, `t_part_item_chart`, `t_part_item_chart_highlight`, and `t_part_item_data`. Headers use database names and constrained headers list every allowed value in parentheses. The workbook must contain all referenced logical parents.
- Omit every auto-increment `_idx` column from Excel. Replacement imports regenerate identities.
- Reject duplicate workbook logical keys: `(wave_cd, wave_info_order)` for Wave info; `(wave_cd, survey_cd, survey_item_order)` for survey items; `(wave_cd, part_cd, part_item_cd, survey_cd, part_item_sub_cd)` for base, chart, and highlight rows; and that result-series key plus `part_item_data_order` for data rows.
- Reject duplicate Excel keys: Wave info `(wave_cd,wave_info_order)`; survey item `(wave_cd,survey_cd,survey_item_order)`; base `(wave_cd,part_cd,part_item_cd,survey_cd,part_item_sub_cd)`; chart/highlight omit `survey_cd`; data adds `part_item_data_order` to base.
- Define the Excel import/export schema once with KriCommon `ExcelColumn` DTOs. Use KriCommon `ExcelMapper` for workbook mapping and keep only project-specific type, value, and cross-sheet relationship rules in a consumer-local validator; do not duplicate a general-purpose Excel parser.
- Excel endpoints are `POST /api/v1/excel/import`, `GET /api/v1/excel/template`, `GET /api/v1/excel/waves/{waveCd}/export`, and `DELETE /api/v1/excel/waves/{waveCd}`. Downloads use the same eleven sheets, order, and headers; a missing Wave exports an empty workbook.
- Imports atomically replace every included Wave: validate first, delete all eleven managed tables, then insert. Failures restore prior data. Standalone reset uses the same child-to-root deletion and retains `t_file` metadata and physical files, allowing temporary orphans until that `wave_cd` is reimported.
@@ -296,14 +296,15 @@ When implementation is complete, report in Korean:
- A normal item has no `t_part_item_sub` rows, and both base and data rows must use `part_item_sub_cd = NULL`. Never use `0` as a substitute for this `NULL` value.
- An item with sub-items has one or more `t_part_item_sub` rows. Every non-null `part_item_sub_cd` in its base and data rows must reference a sub-item belonging to the same `(wave_cd, part_cd, part_item_cd)`.
- Every survey code used by `t_part_item_base` or `t_part_item_data` must belong to the same Wave. Survey items must likewise belong to an existing `(wave_cd, survey_cd)`.
- Treat `t_survey.survey_color` as a required `VARCHAR(8)` value. Include it as the `survey_color` column in the Excel template/import contract and persist it with each survey.
- Store four `VARCHAR(8)` survey palette colors: required `survey_color` plus nullable highlight, negative, and negative-highlight colors. Include all in Excel/API; fall back to default, default, and negative/highlight/default respectively.
- Use `t_part_item_base` as the preferred source for determining which survey audiences apply to an item. Display the single matching `survey_alias` when only one audience applies; display `공통` when all defined audiences apply.
- Store an optional display string in `t_part_item_base.base_text` (`VARCHAR(128)`). Do not reconstruct it from `base_count`, and do not retain the removed `base_pre_text` or `base_post_text` fields in entities, Excel contracts, or query assembly.
- Use the corresponding `*_order` column for API and screen ordering: `wave_info_order`, `survey_order`, `survey_item_order`, `file_order`, `part_order`, `part_item_order`, and `part_item_data_order`. Use `part_item_sub_cd` as the default sub-item order because the schema has no separate sub-item order column.
- Use the same `t_part_item_data` rows for both chart and statistical-table views. `is_chart_visible` is a required Boolean column with database default `1`; statistical tables use every row, while charts omit categories and matching values whose flag is false. Do not introduce a separate table-data source that could diverge from chart values.
- Resolve `chart_type`, `chart_color`, and `chart_gap_mode` per `(wave_cd, part_cd, part_item_cd, survey_cd, part_item_sub_cd)` from `t_part_item_chart`, not `t_part_item`. Defaults are `BAR`, `t_survey.survey_color`, and `NONE`; normalize null or unknown gap modes to `NONE`. Allowed gap modes are `NONE`, `ALL`, and `LAST_VISIBLE`.
- Resolve `t_part_item_chart_highlight` independently from `t_part_item_chart`; a highlight may exist without a chart-setting row. Return `chart_highlight_mode`, `chart_highlight_value`, and `chart_highlight_color` to the frontend without calculating highlighted categories in the backend. Supported modes are `MAX_VALUE`, `LAST_VISIBLE`, and `SPECIFIED`; only `SPECIFIED` accepts a non-null, comma-separated integer value with no spaces.
- Treat null `part_item_sub_cd` values as equal when matching normal-item chart and highlight settings. Validate at Excel import that chart and highlight logical keys are unique, normal items use null sub codes, and colors use `#RRGGBB` format.
- Chart/highlight key is `(wave_cd,part_cd,part_item_cd,part_item_sub_cd)`; one config applies to all survey series in its group. Chart type/gap default to `BAR`/`NONE`; colors come from survey palettes.
- Resolve chart highlights independently and return mode/value without calculating highlighted categories. Supported modes are `MAX_VALUE`, `LAST_VISIBLE`, and `SPECIFIED`; only `SPECIFIED` accepts a non-null comma-separated integer list. Highlight colors come only from the survey palette.
- Store item and sub-item negative mode/order independently (`DEFAULT`, `NEGATIVE`, `SPECIFIED`); sub settings never inherit parent settings. Only `SPECIFIED` accepts an order list. Return these settings and survey palette colors so the frontend classifies rows and applies final colors.
- Treat null `part_item_sub_cd` values as equal when matching normal-item chart/highlight settings. Validate Excel logical-key uniqueness, null sub codes for normal items, negative/highlight order syntax, and palette colors as `#RRGGBB`.
- Avoid N+1 query patterns when assembling a Wave dashboard. Fetch the required Part, Item, Sub, Base, and Data ranges in batches and assemble the response hierarchy in the backend.
## Frontend API Contract
@@ -313,7 +314,7 @@ When implementation is complete, report in Korean:
- Revalidate Wave access on both Wave-detail and Part-detail requests. Throw a KriCommon `BusinessException` with forbidden status when a restricted user requests a closed Wave; frontend visibility is not an authorization boundary.
- Assemble normal and sub-item results through one `resultGroups` response shape. A normal item has one group with `subItem = null`; an item with sub-items has one group per Sub in `part_item_sub_cd` order.
- Return categories as objects containing `order`, `label`, and `chartVisible`, alongside complete survey value series. The frontend uses all category/value indexes for statistical tables and filters matching indexes only for chart rendering. Reject Excel imports when category labels, display orders, or chart-visibility flags differ between survey series in the same Item/Sub result group.
- Expose each survey's stored color as `color` in both Wave-detail survey objects and Part-detail series objects so the frontend uses one server-managed color mapping.
- Expose effective `color`, `highlightColor`, `negativeColor`, and `negativeHighlightColor` in both Wave-detail surveys and Part-detail series. Return item/sub-item `negativeMode` and nullable `negativeOrder`; the frontend classifies and colors chart rows.
- Return the stored nullable `t_part_item_base.base_text` value unchanged as Part-detail `series[].baseText`; `baseCount` remains a separate numeric field.
- Return `series[].chartGapMode`; the frontend applies `NONE`, `ALL`, or `LAST_VISIBLE`, where the last mode uses the greatest visible `part_item_data_order`.
- When importing `part_item_data_value`, round to scale 10 with `RoundingMode.HALF_UP` before validating and storing it as `DECIMAL(14,10)`. Reject only values that still exceed precision 14 after rounding.

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,