quyx@nextosd.com 5 ヶ月 前
コミット
1ba884d023

+ 5 - 0
yamada-common/src/main/java/jp/yamada/common/utils/poi/ExcelUtil.java

@@ -1958,6 +1958,11 @@ public class ExcelUtil<T> {
                         f.setAccessible(true);
                         Object value = f.get(obj);
 
+                        // 値がnullの場合は、空の文字列を直接返します
+                        if (value == null) {
+                            return "";
+                        }
+
                         // 日付型のフィールドは指定されたフォーマットに変換
                         if (value instanceof Date) {
                             return DATE_FORMAT.format(value);

+ 39 - 26
yamada-fcbi/src/main/java/jp/yamada/fcbi/service/impl/YmdfSurveyServiceImpl.java

@@ -7,6 +7,7 @@ import java.util.Map;
 
 import com.fasterxml.jackson.databind.ObjectMapper;
 import jp.yamada.common.utils.MessageUtils;
+import jp.yamada.common.utils.StringUtils;
 import jp.yamada.common.utils.ValidatorUtils;
 import jp.yamada.common.utils.bean.BeanUtils;
 import jp.yamada.fcbi.constants.Constants;
@@ -137,7 +138,7 @@ public class YmdfSurveyServiceImpl implements IYmdfSurveyService
 
             // ブランド関連データの処理
             List<String> brandCodes = ymdfSurveyParam.getBrandCodes();
-            if (brandCodes != null && !brandCodes.isEmpty()) {
+            if (StringUtils.isNotEmpty(brandCodes)) {
                 for (String brandCode : brandCodes) {
                     YmdfSurveyBrand surveyBrand = new YmdfSurveyBrand();
                     // マスターテーブルIDの設定
@@ -150,7 +151,7 @@ public class YmdfSurveyServiceImpl implements IYmdfSurveyService
 
             // 業種関連データの処理
             List<String> businessTypeCodes = ymdfSurveyParam.getBusinessTypeCodes();
-            if (businessTypeCodes != null && !businessTypeCodes.isEmpty()) {
+            if (StringUtils.isNotEmpty(businessTypeCodes)) {
                 for (String businessTypeCode : businessTypeCodes) {
                     YmdfSurveyBusinessType surveyBusinessType = new YmdfSurveyBusinessType();
                     // マスターテーブルIDの設定
@@ -163,7 +164,7 @@ public class YmdfSurveyServiceImpl implements IYmdfSurveyService
 
             // ゾーン関連データの処理
             List<RegionInfoVo> regions = ymdfSurveyParam.getRegions();
-            if (regions != null && !regions.isEmpty()) {
+            if (StringUtils.isNotEmpty(regions)) {
                 for (RegionInfoVo regionInfo : regions) {
                     YmdfSurveyRegion surveyRegion = new YmdfSurveyRegion();
                     // マスターテーブルIDの設定
@@ -177,7 +178,7 @@ public class YmdfSurveyServiceImpl implements IYmdfSurveyService
 
             // アンケート質問処理
             List<QuestionInfoVo> questions = ymdfSurveyParam.getQuestions();
-            if (questions != null && !questions.isEmpty()) {
+            if (StringUtils.isNotEmpty(questions)) {
                 for (QuestionInfoVo questionInfo : questions) {
                     YmdfSurveyQuestion surveyQuestion = new YmdfSurveyQuestion();
                     // マスターテーブルIDの設定
@@ -195,7 +196,7 @@ public class YmdfSurveyServiceImpl implements IYmdfSurveyService
 
                     if (Constants.CHECK_BOX.equals(questionInfo.getQuestionType())) {
                         List<CheckboxInfoVo> checkboxItems = questionInfo.getCheckboxItems();
-                        if (checkboxItems != null && !checkboxItems.isEmpty()) {
+                        if (StringUtils.isNotEmpty(checkboxItems)) {
                             for (CheckboxInfoVo checkboxInfo : checkboxItems) {
                                 YmdfSurveyOption surveyOption = new YmdfSurveyOption();
                                 surveyOption.setQuestionId(questionId);
@@ -207,7 +208,7 @@ public class YmdfSurveyServiceImpl implements IYmdfSurveyService
                         }
                     } else if (Constants.RADIO_BUTTON.equals(questionInfo.getQuestionType())) {
                         List<RadioInfoVo> radioItems = questionInfo.getRadioItems();
-                        if (radioItems != null && !radioItems.isEmpty()) {
+                        if (StringUtils.isNotEmpty(radioItems)) {
                             for (RadioInfoVo radioInfo : radioItems) {
                                 YmdfSurveyOption surveyOption = new YmdfSurveyOption();
                                 surveyOption.setQuestionId(questionId);
@@ -219,7 +220,7 @@ public class YmdfSurveyServiceImpl implements IYmdfSurveyService
                         }
                     } else if (Constants.NUMBER_SELECT.equals(questionInfo.getQuestionType())) {
                         List<SelectInfoVo> selectOptions = questionInfo.getSelectOptions();
-                        if (selectOptions != null && !selectOptions.isEmpty()) {
+                        if (StringUtils.isNotEmpty(selectOptions)) {
                             for (SelectInfoVo selectInfoVo : selectOptions) {
                                 YmdfSurveyOption surveyOption = new YmdfSurveyOption();
                                 surveyOption.setQuestionId(questionId);
@@ -291,16 +292,28 @@ public class YmdfSurveyServiceImpl implements IYmdfSurveyService
         List<String> errors = new ArrayList<>();
 
         // タイトルの検証
-        if (ymdfSurveyParam.getTitle() == null || ymdfSurveyParam.getTitle().trim().isEmpty()) {
+        if (StringUtils.isEmpty(ymdfSurveyParam.getTitle())) {
             errors.add(MessageUtils.message("E0003", MessageUtils.message("title")));
         } else if (ymdfSurveyParam.getTitle().length() > Constants.NUMBER_100) {
             errors.add(MessageUtils.message("EM005", MessageUtils.message("title"), Constants.NUMBER_100));
         }
 
         // 説明文の検証
-        if (ymdfSurveyParam.getDescription() != null && ymdfSurveyParam.getDescription().length() > Constants.NUMBER_255) {
+        if (StringUtils.isNotEmpty(ymdfSurveyParam.getDescription()) && ymdfSurveyParam.getDescription().length() > Constants.NUMBER_255) {
             errors.add(MessageUtils.message("EM005", MessageUtils.message("description"), Constants.NUMBER_255));
         }
+        // FCの検証
+        if (StringUtils.isEmpty(ymdfSurveyParam.getBrandCodes())) {
+            errors.add(MessageUtils.message("EM017", MessageUtils.message("brandCode")));
+        }
+        // 業種の検証
+        if (StringUtils.isEmpty(ymdfSurveyParam.getBusinessTypeCodes())) {
+            errors.add(MessageUtils.message("EM017", MessageUtils.message("businessTypeCode")));
+        }
+        // エリアの検証
+        if (StringUtils.isEmpty(ymdfSurveyParam.getRegions())) {
+            errors.add(MessageUtils.message("EM017", MessageUtils.message("regions")));
+        }
         Date publicStartTime = ymdfSurveyParam.getPublicStartTime();
         Date publicEndTime = ymdfSurveyParam.getPublicEndTime();
         if (publicStartTime != null && publicEndTime != null) {
@@ -313,18 +326,18 @@ public class YmdfSurveyServiceImpl implements IYmdfSurveyService
 
 
         // 質問文及び入力ボックスの検証
-        if (ymdfSurveyParam.getQuestions() != null) {
+        if (StringUtils.isNotEmpty(ymdfSurveyParam.getQuestions())) {
             for (int i = 0; i < ymdfSurveyParam.getQuestions().size(); i++) {
                 QuestionInfoVo question = ymdfSurveyParam.getQuestions().get(i);
                 int questionIndex = i + 1;
 
                 // 質問文(questionText)の長さ検証
                 String questionText = question.getQuestionText();
-                if (questionText != null && questionText.length() > Constants.NUMBER_255) {
+                if (StringUtils.isNotEmpty(questionText) && questionText.length() > Constants.NUMBER_255) {
                     errors.add(MessageUtils.message("EM009",questionIndex,MessageUtils.message("questionText"),Constants.NUMBER_255 ));
                 }
 
-                if (questionText == null || questionText.trim().isEmpty()) {
+                if (StringUtils.isEmpty(questionText)) {
                     errors.add(MessageUtils.message("E0062",questionIndex,MessageUtils.message("questionText")));
                 }
 
@@ -332,17 +345,17 @@ public class YmdfSurveyServiceImpl implements IYmdfSurveyService
                 // CHECK_BOX类型の選択肢数検証
                 if ("CHECK_BOX".equals(questionType)) {
                     List<CheckboxInfoVo> checkboxItems = question.getCheckboxItems();
-                    if (checkboxItems == null || checkboxItems.size() < 3) {
+                    if (StringUtils.isEmpty(checkboxItems) || checkboxItems.size() < 3) {
                         errors.add(MessageUtils.message("EM007",questionIndex));
                     }
-                    if (checkboxItems != null) {
+                    if (StringUtils.isNotEmpty(checkboxItems)) {
                         for (int j = 0; j < checkboxItems.size(); j++) {
                             CheckboxInfoVo item = checkboxItems.get(j);
                             String optionText = item.getOptionText();
-                            if (optionText == null || optionText.trim().isEmpty()) {
+                            if (StringUtils.isEmpty(optionText)) {
                                 errors.add(MessageUtils.message("E0061",questionIndex,j+1));
                             }
-                            if (optionText != null && optionText.length() > Constants.NUMBER_20) {
+                            if (StringUtils.isNotEmpty(optionText) && optionText.length() > Constants.NUMBER_20) {
                                 errors.add(MessageUtils.message("EM016",questionIndex,j+1,Constants.NUMBER_20 ));
                             }
                         }
@@ -351,17 +364,17 @@ public class YmdfSurveyServiceImpl implements IYmdfSurveyService
                 // RADIO_BUTTON类型の選択肢数検証
                 else if ("RADIO_BUTTON".equals(questionType)) {
                     List<RadioInfoVo> radioItems = question.getRadioItems();
-                    if (radioItems == null || radioItems.size() < 3) {
+                    if (StringUtils.isEmpty(radioItems) || radioItems.size() < 3) {
                         errors.add(MessageUtils.message("EM007",questionIndex));
                     }
-                    if (radioItems != null) {
+                    if (StringUtils.isNotEmpty(radioItems)) {
                         for (int a = 0; a < radioItems.size(); a++) {
                             RadioInfoVo item = radioItems.get(a);
                             String optionText = item.getOptionText();
-                            if (optionText == null || optionText.trim().isEmpty()) {
+                            if (StringUtils.isEmpty(optionText)) {
                                 errors.add(MessageUtils.message("E0061",questionIndex,a+1));
                             }
-                            if (optionText != null && optionText.length() > Constants.NUMBER_20) {
+                            if (StringUtils.isNotEmpty(optionText) && optionText.length() > Constants.NUMBER_20) {
                                 errors.add(MessageUtils.message("EM016",questionIndex,a+1,Constants.NUMBER_20 ));
                             }
                         }
@@ -381,19 +394,19 @@ public class YmdfSurveyServiceImpl implements IYmdfSurveyService
                     if (!ValidatorUtils.isNumber(numberSelectEnd)) {
                         errors.add(MessageUtils.message("EM011",questionIndex,MessageUtils.message("halfNumeric")));
                     }
-                    if (numberSelectStart == null || numberSelectStart.trim().isEmpty()) {
+                    if (StringUtils.isEmpty(numberSelectStart)) {
                         errors.add(MessageUtils.message("E0061",questionIndex,1));
                     }
-                    if (numberSelectEnd == null || numberSelectEnd.trim().isEmpty()) {
+                    if (StringUtils.isEmpty(numberSelectEnd)) {
                         errors.add(MessageUtils.message("E0061",questionIndex,2));
                     }
 
                     double start = 0;
-                    if (numberSelectStart != null) {
+                    if (StringUtils.isNotEmpty(numberSelectStart)) {
                         start = Double.parseDouble(numberSelectStart);
                     }
                     double end = 0;
-                    if (numberSelectEnd != null) {
+                    if (StringUtils.isNotEmpty(numberSelectEnd)) {
                         end = Double.parseDouble(numberSelectEnd);
                     }
                     if (start > end) {
@@ -406,10 +419,10 @@ public class YmdfSurveyServiceImpl implements IYmdfSurveyService
                         errors.add(MessageUtils.message("EM014", questionIndex));
                     }
                     // 単位文字数検証
-                    if (questionUnit != null && questionUnit.length() > Constants.NUMBER_20) {
+                    if (StringUtils.isNotEmpty(questionUnit) && questionUnit.length() > Constants.NUMBER_20) {
                         errors.add(MessageUtils.message("EM009",questionIndex,MessageUtils.message("questionUnit"),Constants.NUMBER_20 ));
                     }
-                    if ("true".equalsIgnoreCase(unitHas) && (questionUnit == null || questionUnit.trim().isEmpty())) {
+                    if ("true".equalsIgnoreCase(unitHas) && (StringUtils.isEmpty(questionUnit))) {
                         errors.add(MessageUtils.message("E0062", questionIndex,MessageUtils.message("questionUnit")));
                     }
                 }