|
|
@@ -17,6 +17,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<result property="relatedBusinessType" column="related_business_type"/>
|
|
|
<result property="relatedRegion" column="related_region"/>
|
|
|
<result property="questionCount" column="question_count"/>
|
|
|
+ <result property="answerFlag" column="answerFlag"/>
|
|
|
+ <result property="fcMemberName" column="fc_member_name"/>
|
|
|
+ <result property="answerStatus" column="answer_status"/>
|
|
|
+ <result property="answerTime" column="answer_time"/>
|
|
|
+ <result property="totalQuestions" column="total_questions"/>
|
|
|
+ <result property="answeredQuestions" column="answered_questions"/>
|
|
|
+ <result property="unansweredQuestions" column="unanswered_questions"/>
|
|
|
+ <result property="completionRate" column="completion_rate"/>
|
|
|
</resultMap>
|
|
|
|
|
|
<sql id="selectYmdfSurveyVo">
|
|
|
@@ -34,7 +42,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
GROUP_CONCAT(DISTINCT fc_dict.dict_label ORDER BY fc_dict.dict_sort SEPARATOR '/') AS related_fc,
|
|
|
GROUP_CONCAT(DISTINCT bt_dict.dict_label ORDER BY bt_dict.dict_sort SEPARATOR '/') AS related_business_type,
|
|
|
GROUP_CONCAT(DISTINCT parent_region.region_name ORDER BY parent_region.sort_order SEPARATOR '/') AS related_region,
|
|
|
- COUNT(DISTINCT q.question_id) AS question_count
|
|
|
+ COUNT(DISTINCT q.question_id) AS question_count,
|
|
|
+ CASE
|
|
|
+ WHEN EXISTS (
|
|
|
+ SELECT 1
|
|
|
+ FROM ymdf_survey_answer a
|
|
|
+ WHERE a.survey_id = s.survey_id
|
|
|
+ AND a.del_flag = 0
|
|
|
+ ) THEN 1
|
|
|
+ ELSE 0
|
|
|
+ END AS answerFlag
|
|
|
FROM
|
|
|
ymdf_survey s
|
|
|
LEFT JOIN ymdf_survey_brand b ON s.survey_id = b.survey_id AND b.del_flag = 0
|
|
|
@@ -53,6 +70,47 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
s.create_time DESC
|
|
|
</sql>
|
|
|
|
|
|
+ <sql id="selectYmdfSurveyAnswerListVo">
|
|
|
+ SELECT
|
|
|
+ s.survey_code AS survey_code,
|
|
|
+ s.title AS title,
|
|
|
+ m.fc_member_name AS fc_member_name,
|
|
|
+ dict.dict_label AS answer_status,
|
|
|
+ MAX(a.answer_time) AS answer_time,
|
|
|
+ COUNT(DISTINCT q.question_id) AS total_questions,
|
|
|
+ COUNT(DISTINCT CASE WHEN a.question_id IS NOT NULL THEN a.question_id END) AS answered_questions,
|
|
|
+ COUNT(DISTINCT q.question_id) - COUNT(DISTINCT CASE WHEN a.question_id IS NOT NULL THEN a.question_id END) AS unanswered_questions,
|
|
|
+ CASE
|
|
|
+ WHEN COUNT(DISTINCT q.question_id) = 0 THEN 0.00
|
|
|
+ ELSE ROUND(
|
|
|
+ (COUNT(DISTINCT CASE WHEN a.question_id IS NOT NULL THEN a.question_id END)
|
|
|
+ / COUNT(DISTINCT q.question_id)) * 100,
|
|
|
+ 2
|
|
|
+ )
|
|
|
+ END AS completion_rate
|
|
|
+ FROM
|
|
|
+ ymdf_survey s
|
|
|
+ LEFT JOIN ymdf_survey_question q
|
|
|
+ ON s.survey_id = q.survey_id
|
|
|
+ AND q.del_flag = 0
|
|
|
+ LEFT JOIN ymdf_survey_answer a
|
|
|
+ ON s.survey_id = a.survey_id
|
|
|
+ AND a.del_flag = 0
|
|
|
+ LEFT JOIN ymdf_fc_member m
|
|
|
+ ON a.fc_member_id = m.fc_member_id
|
|
|
+ AND m.del_flag = 0
|
|
|
+ LEFT JOIN sys_dict_data dict
|
|
|
+ ON a.answer_status = dict.dict_value
|
|
|
+ AND dict.dict_type = 'answer_status'
|
|
|
+ WHERE
|
|
|
+ s.del_flag = 0
|
|
|
+ GROUP BY
|
|
|
+ s.survey_id, s.survey_code, s.title, m.fc_member_name, a.answer_status, dict.dict_label
|
|
|
+ ORDER BY
|
|
|
+ s.create_time DESC,
|
|
|
+ completion_rate DESC
|
|
|
+ </sql>
|
|
|
+
|
|
|
<select id="selectYmdfSurveyList" parameterType="YmdfSurvey" resultMap="YmdfSurveyResult">
|
|
|
SELECT * FROM (
|
|
|
<include refid="selectYmdfSurveyListVo"/>
|
|
|
@@ -65,14 +123,33 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
AND t.survey_code = #{surveyCode}
|
|
|
</if>
|
|
|
<if test="publicStartTime != null">
|
|
|
- AND t.public_start_time = #{publicStartTime}
|
|
|
+ <![CDATA[ AND t.public_start_time >= #{publicStartTime} ]]>
|
|
|
</if>
|
|
|
<if test="publicEndTime != null">
|
|
|
- AND t.public_end_time = #{publicEndTime}
|
|
|
+ <![CDATA[ AND t.public_end_time <= #{publicEndTime} ]]>
|
|
|
</if>
|
|
|
</where>
|
|
|
</select>
|
|
|
|
|
|
+ <select id="selectYmdfSurveyDetailsList" parameterType="YmdfSurvey" resultMap="YmdfSurveyResult">
|
|
|
+ SELECT * FROM (
|
|
|
+ <include refid="selectYmdfSurveyAnswerListVo"/>
|
|
|
+ ) t
|
|
|
+ <where>
|
|
|
+ <if test="fcMemberName != null and fcMemberName != ''">
|
|
|
+ AND t.fc_member_name LIKE CONCAT('%', #{fcMemberName}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="surveyCode != null and surveyCode != ''">
|
|
|
+ AND t.survey_code = #{surveyCode}
|
|
|
+ </if>
|
|
|
+ <if test="publicStartTime != null">
|
|
|
+ <![CDATA[ AND DATE(t.answer_time) >= DATE(#{publicStartTime}) ]]>
|
|
|
+ </if>
|
|
|
+ <if test="publicEndTime != null">
|
|
|
+ <![CDATA[ AND DATE(t.answer_time) <= DATE(#{publicEndTime}) ]]>
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ </select>
|
|
|
<select id="selectRegionTree" resultType="map">
|
|
|
SELECT
|
|
|
JSON_OBJECT(
|