<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
	namespace="cn.com.countrygarden.bi.main.dao.review.ReviewQuestionnaireProblemClassificationMapper">
	<!-- 通用查询映射结果 -->
	<resultMap id="BaseResultMap"
		type="cn.com.countrygarden.bi.main.model.review.ReviewQuestionnaireProblemClassification">
		<id column="id" property="id" />
		<result column="name" property="name" />
		<result column="flag" property="flag" />
		<result column="create_by" property="createBy" />
		<result column="create_time" property="createTime" />
		<result column="update_by" property="updateBy" />
		<result column="update_time" property="updateTime" />
	</resultMap>
	
	
	<select id="queryQuestionnaireProblemClassificationVo"
		resultType="cn.com.countrygarden.bi.main.dto.ReviewQuestionnaireProblemClassificationVo" parameterType="int">
		 select rqpc.id as id,rqpc.name as label,rqpc.flag flag from
		review_questionnaire_problem_classification rqpc
         where rqpc.investigationmanagement_id=#{investigationmanagementId}
	</select>



	<delete id="deleteNotClassificationIds" parameterType="int">
		delete from `review_questionnaire_problem_classification` where flag=1
		and id not in

		<foreach collection="classificationId" index="index"
			item="classificationId" open="(" separator="," close=")">
			#{classificationId}
		</foreach>

	</delete>

	<select id="findClassificationFlagTwo" parameterType="int"
		resultType="int">
		select id from review_questionnaire_problem_classification where flag=2
	</select>




	<select id="findProblemClassificationIds" parameterType="int"
		resultType="int">
		select distinct(p.questionnaire_problem_classification_id) from
		review_questionnaire_problem
		p,review_questionnaire_problem_classification c where p.flag=1
		and p.questionnaire_problem_classification_id=c.id and c.flag !=2 and
		p.questionnaire_id=#{questionnaireId}

	</select>
	  <select id="pqpclist" resultType="cn.com.countrygarden.bi.main.dto.ReviewQuestioClassificationDTO" parameterType="java.lang.Integer">
            select rqpc.id as id,rqpc.name as `name` from review_questionnaire_problem rqp,review_questionnaire_problem_classification rqpc
            where rqpc.id=rqp.questionnaire_problem_classification_id and rqp.questionnaire_id=#{questionnaireId}
            group by `name`
	 </select>


</mapper>