quyx@nextosd.com 4 ヶ月 前
コミット
6aaf49f3a6

+ 12 - 0
yamada-fcbi/src/main/java/jp/yamada/fcbi/controller/YmdfSurveyController.java

@@ -67,6 +67,18 @@ public class YmdfSurveyController extends BaseController
     }
 
     /**
+     *  アンケート照会結果の取得
+     */
+    @PreAuthorize("@ss.hasPermi('system:survey:list')")
+    @PostMapping("/listDetail")
+    public TableDataInfo detailList(@RequestBody YmdfSurvey ymdfSurvey)
+    {
+        startPage();
+        List<YmdfSurvey> list = ymdfSurveyService.selectYmdfSurveyDetail(ymdfSurvey);
+        return getDataTable(list);
+    }
+
+    /**
      *  アンケート回答詳細の取得
      */
     @PreAuthorize("@ss.hasPermi('system:survey:list')")

+ 5 - 1
yamada-fcbi/src/main/java/jp/yamada/fcbi/domain/YmdfSurvey.java

@@ -76,6 +76,8 @@ public class YmdfSurvey extends BaseEntity
 
     private Integer insertFlag;
 
+    private String questionTypeStr;
+
     private List<String> brandCodes;
 
     private List<String> businessTypeCodes;
@@ -177,7 +179,9 @@ public class YmdfSurvey extends BaseEntity
     private String salesShare;
 
     /** ブランドコード */
-    private Integer brandCode;
+    private String brandCode;
+    private String region;
+    private String question;
 
     /** 上位エリアID */
     private String parentRegionId;

+ 8 - 0
yamada-fcbi/src/main/java/jp/yamada/fcbi/mapper/YmdfSurveyMapper.java

@@ -41,6 +41,14 @@ public interface YmdfSurveyMapper
     List<YmdfSurvey> selectYmdfSurveyDetailsList(YmdfSurvey ymdfSurvey);
 
     /**
+     * アンケート照会結果の取得
+     *
+     * @param ymdfSurvey アンケート照会結果の取得
+     * @return アンケート照会結果の取得
+     */
+    List<YmdfSurvey> selectYmdfSurveyDetail(YmdfSurvey ymdfSurvey);
+
+    /**
      * アンケート回答詳細の取得
      *
      * @param ymdfSurvey アンケート回答詳細の取得

+ 8 - 0
yamada-fcbi/src/main/java/jp/yamada/fcbi/service/IYmdfSurveyService.java

@@ -42,6 +42,14 @@ public interface IYmdfSurveyService
     public List<YmdfSurvey> selectYmdfSurveyDetailsList(YmdfSurvey ymdfSurvey);
 
     /**
+     * アンケート照会結果の取得
+     *
+     * @param ymdfSurvey アンケート照会結果の取得
+     * @return アンケート照会結果の取得
+     */
+    public List<YmdfSurvey> selectYmdfSurveyDetail(YmdfSurvey ymdfSurvey);
+
+    /**
      * アンケート回答詳細の取得
      *
      * @param ymdfSurvey アンケート回答詳細の取得

+ 12 - 0
yamada-fcbi/src/main/java/jp/yamada/fcbi/service/impl/YmdfSurveyServiceImpl.java

@@ -111,6 +111,18 @@ public class YmdfSurveyServiceImpl implements IYmdfSurveyService
     }
 
     /**
+     * アンケート照会結果の取得
+     *
+     * @param ymdfSurvey アンケート照会結果の取得
+     * @return アンケート照会結果の取得
+     */
+    @Override
+    public List<YmdfSurvey> selectYmdfSurveyDetail(YmdfSurvey ymdfSurvey) {
+        return ymdfSurveyMapper.selectYmdfSurveyDetail(ymdfSurvey);
+    }
+
+
+    /**
      * アンケート回答詳細の取得
      *
      * @param ymdfSurvey アンケート回答詳細の取得

+ 106 - 0
yamada-fcbi/src/main/resources/mapper/fcbi/YmdfSurveyMapper.xml

@@ -22,9 +22,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="answerStatus" column="answer_status"/>
         <result property="answerTime" column="answer_time"/>
         <result property="totalQuestions" column="total_questions"/>
+        <result property="question" column="question"/>
         <result property="answeredQuestions" column="answered_questions"/>
         <result property="unansweredQuestions" column="unanswered_questions"/>
         <result property="completionRate" column="completion_rate"/>
+        <result property="questionTypeStr" column="questionTypeStr"/>
         <result property="sortOrder"    column="sort_order"    />
         <result property="questionText"    column="question_text"    />
         <result property="questionType"    column="question_type"    />
@@ -47,6 +49,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="fcBrandName" column="fc_brand_name"/>
         <result property="businessTypeCode" column="business_type_code"/>
         <result property="businessTypeName"    column="business_type_name"    />
+        <result property="businessTypeCode"    column="businessTypeCode"    />
         <result property="regionCode"    column="region_code"    />
         <result property="regionName"    column="region_name"    />
         <result property="parentRegionName"    column="parent_region_name"    />
@@ -64,6 +67,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="parentRegionCode"    column="parent_region_code"    />
         <result property="currentAreaName" column="current_area_name"/>
         <result property="avgTransaction" column="avg_transaction"/>
+        <result property="region" column="region"/>
     </resultMap>
 
     <sql id="selectYmdfSurveyVo">
@@ -269,6 +273,108 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </where>
     </select>
 
+    <select id="selectYmdfSurveyDetail" parameterType="YmdfSurvey" resultMap="YmdfSurveyResult">
+        SELECT
+            s.title,
+            s.description,
+            s.public_mode,
+            s.public_start_time,
+            s.public_end_time,
+            brand.brand_codes AS brand_code,
+            business_type.business_type_codes AS businessTypeCode,
+            region.region_codes AS region_code,
+            region.region_objects AS region,
+            JSON_ARRAYAGG(question_json) AS question
+        FROM
+            ymdf_survey s
+                LEFT JOIN (
+                SELECT
+                    survey_id,
+                    JSON_ARRAYAGG(brand_code) AS brand_codes
+                FROM ymdf_survey_brand
+                GROUP BY survey_id
+            ) brand ON s.survey_id = brand.survey_id
+                LEFT JOIN (
+                SELECT
+                    survey_id,
+                    JSON_ARRAYAGG(business_type_code) AS business_type_codes
+                FROM ymdf_survey_business_type
+                GROUP BY survey_id
+            ) business_type ON s.survey_id = business_type.survey_id
+                LEFT JOIN (
+                SELECT
+                    survey_id,
+                    JSON_ARRAYAGG(region_code) AS region_codes,
+                    JSON_ARRAYAGG(JSON_OBJECT('regionCode', region_code)) AS region_objects
+                FROM ymdf_survey_region
+                GROUP BY survey_id
+            ) region ON s.survey_id = region.survey_id
+                LEFT JOIN (
+                SELECT
+                    q.survey_id,
+                    q.question_id,
+                    JSON_OBJECT(
+                            'questionText', q.question_text,
+                            'questionType', q.question_type,
+                            'questionTypeStr', CASE q.question_type
+                                                   WHEN 1 THEN 'INPUT_BOX_50'
+                                                   WHEN 2 THEN 'INPUT_BOX_100'
+                                                   WHEN 3 THEN 'RADIO_BUTTON'
+                                                   WHEN 4 THEN 'CHECK_BOX'
+                                                   WHEN 5 THEN 'NUMBER_SELECT'
+                                                   ELSE ''
+                                END,
+                            'sortOrder', q.sort_order,
+                            'questionUnit', q.question_unit,
+                        -- 单选框选项
+                            'radioItems', CASE WHEN q.question_type = 3 THEN
+                                                   CONCAT(
+                                                           '[',
+                                                           GROUP_CONCAT(
+                                                                   JSON_OBJECT(
+                                                                           'optionText', o.option_text,
+                                                                           'sortOrder', o.sort_order,
+                                                                           'value', CONCAT('option', o.sort_order)
+                                                                   )
+                                                                       ORDER BY o.sort_order ASC SEPARATOR ','
+                                                           ),
+                                                           ']'
+                                                   )
+                                END,
+                        -- 复选框选项
+                            'checkboxItems', CASE WHEN q.question_type = 4 THEN
+                                                      CONCAT(
+                                                              '[',
+                                                              GROUP_CONCAT(
+                                                                      JSON_OBJECT(
+                                                                              'optionText', o.option_text,
+                                                                              'sortOrder', o.sort_order,
+                                                                              'checked', FALSE
+                                                                      )
+                                                                          ORDER BY o.sort_order ASC SEPARATOR ','
+                                                              ),
+                                                              ']'
+                                                      )
+                                END,
+                            'numberSelectStart', CASE WHEN q.question_type = 5 THEN
+                                                          MIN(CAST(o.option_text AS UNSIGNED))
+                                END,
+                            'numberSelectEnd', CASE WHEN q.question_type = 5 THEN
+                                                        MAX(CAST(o.option_text AS UNSIGNED))
+                                END
+                    ) AS question_json
+                FROM
+                    ymdf_survey_question q
+                        LEFT JOIN ymdf_survey_option o
+                                  ON q.question_id = o.question_id
+                GROUP BY
+                    q.question_id, q.survey_id, q.question_text,
+                    q.question_type, q.sort_order, q.question_unit
+            ) AS sub_question ON s.survey_id = sub_question.survey_id
+        WHERE
+            s.survey_id = #{surveyId}
+    </select>
+
     <select id="selectYmdfSurveyById" parameterType="String" resultMap="YmdfSurveyResult">
         <include refid="selectYmdfSurveyVo"/>
         where id = #{id}