<?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="com.ruoyi.system.mapper.SqmyInfoMapper">

    <resultMap type="SqmyInfo" id="SqmyInfoResult">
        <result property="sqmyId"    column="sqmy_id"    />
        <result property="sqmyUserId"    column="sqmy_user_id"    />
        <result property="sqmyNumber"    column="sqmy_number"    />
        <result property="title"    column="title"    />
        <result property="topicType"    column="topic_type"    />
        <result property="lxrName"    column="lxr_name"    />
        <result property="lxrPhone"    column="lxr_phone"    />
        <result property="sqmyName"    column="sqmy_name"    />
        <result property="sqmyPhone"    column="sqmy_phone"    />
        <result property="sqmyContent"    column="sqmy_content"    />
        <result property="isPublicity"    column="is_publicity"    />
        <result property="isSecret"    column="is_secret"    />
        <result property="unit"    column="unit"    />
        <result property="isRecord"    column="is_record"    />
        <result property="sqmyProgress"    column="sqmy_progress"    />
        <result property="backReason"    column="back_reason"    />
        <result property="rollingProcess"    column="rolling_process"    />
        <result property="complexType"    column="complex_type"    />
        <result property="isCasesTogether"    column="is_cases_together"    />
        <result property="uniteSqmyId"    column="unite_sqmy_id"    />
        <result property="cbdwdfwy"    column="cbdwdfwy"    />
        <result property="satisfaction"    column="satisfaction"    />
        <result property="membersOpinion"    column="members_opinion"    />
        <result property="zxSatisfaction"    column="zx_satisfaction"    />
        <result property="zxOpinion"    column="zx_opinion"    />
        <result property="isKeyPoint"    column="is_key_point"    />
        <result property="keyPointArgument"    column="key_point_argument"    />
        <result property="isOutstanding"    column="is_outstanding"    />
        <result property="outstandingArgument"    column="outstanding_argument"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />

        <result property="deptId"    column="deptId"    />
        <result property="dwType"    column="dwType"    />
    </resultMap>

    <sql id="selectSqmyInfoVo">
        select sqmy_id, sqmy_user_id, sqmy_number, title,topic_type, lxr_name, lxr_phone, sqmy_name, sqmy_phone, sqmy_content, is_publicity, is_secret, unit, is_record, sqmy_progress,back_reason, rolling_process, complex_type, is_cases_together, unite_sqmy_id, cbdwdfwy, satisfaction, members_opinion, zx_satisfaction, zx_opinion, is_key_point, key_point_argument, is_outstanding, outstanding_argument, create_by, create_time, update_by, update_time, remark from sqmy_info
    </sql>

    <select id="selectSqmyInfoList" parameterType="SqmyInfo" resultMap="SqmyInfoResult">
        <include refid="selectSqmyInfoVo"/>
        <where>
            <if test="sqmyUserId != null "> and sqmy_user_id = #{sqmyUserId}</if>
            <if test="sqmyNumber != null  and sqmyNumber != ''"> and sqmy_number = #{sqmyNumber}</if>
            <if test="title != null  and title != ''"> and title = #{title}</if>
            <if test="topicType != null  and topicType != ''"> and topic_type = #{topicType}</if>
            <if test="lxrName != null  and lxrName != ''"> and lxr_name like concat('%', #{lxrName}, '%')</if>
            <if test="lxrPhone != null  and lxrPhone != ''"> and lxr_phone = #{lxrPhone}</if>
            <if test="sqmyName != null  and sqmyName != ''"> and sqmy_name like concat('%', #{sqmyName}, '%')</if>
            <if test="sqmyPhone != null  and sqmyPhone != ''"> and sqmy_phone = #{sqmyPhone}</if>
            <if test="sqmyContent != null  and sqmyContent != ''"> and sqmy_content = #{sqmyContent}</if>
            <if test="isPublicity != null  and isPublicity != ''"> and is_publicity = #{isPublicity}</if>
            <if test="isSecret != null  and isSecret != ''"> and is_secret = #{isSecret}</if>
            <if test="unit != null  and unit != ''"> and unit = #{unit}</if>
            <if test="isRecord != null  and isRecord != ''"> and is_record = #{isRecord}</if>
            <if test="sqmyProgress != null  and sqmyProgress != ''"> and sqmy_progress = #{sqmyProgress}</if>
            <if test="rollingProcess != null  and rollingProcess != ''"> and rolling_process = #{rollingProcess}</if>
            <if test="complexType != null  and complexType != ''"> and complex_type = #{complexType}</if>
            <if test="isCasesTogether != null  and isCasesTogether != ''"> and is_cases_together = #{isCasesTogether}</if>
            <if test="uniteSqmyId != null "> and unite_sqmy_id = #{uniteSqmyId}</if>
            <if test="cbdwdfwy != null  and cbdwdfwy != ''"> and cbdwdfwy = #{cbdwdfwy}</if>
            <if test="satisfaction != null  and satisfaction != ''"> and satisfaction = #{satisfaction}</if>
            <if test="membersOpinion != null  and membersOpinion != ''"> and members_opinion = #{membersOpinion}</if>
            <if test="zxSatisfaction != null  and zxSatisfaction != ''"> and zx_satisfaction = #{zxSatisfaction}</if>
            <if test="zxOpinion != null  and zxOpinion != ''"> and zx_opinion = #{zxOpinion}</if>
            <if test="isKeyPoint != null  and isKeyPoint != ''"> and is_key_point = #{isKeyPoint}</if>
            <if test="keyPointArgument != null  and keyPointArgument != ''"> and key_point_argument = #{keyPointArgument}</if>
            <if test="isOutstanding != null  and isOutstanding != ''"> and is_outstanding = #{isOutstanding}</if>
            <if test="outstandingArgument != null  and outstandingArgument != ''"> and outstanding_argument = #{outstandingArgument}</if>
        </where>
        order by update_time desc
    </select>

    <select id="selectSqmyInfoBySqmyId" parameterType="Long" resultMap="SqmyInfoResult">
        <include refid="selectSqmyInfoVo"/>
        where sqmy_id = #{sqmyId}
    </select>

    <select id="selectSqmyInfoListByUnit" resultMap="SqmyInfoResult">
        select s.sqmy_id, s.sqmy_user_id, s.sqmy_number, s.title, s.lxr_name, s.lxr_phone, s.sqmy_name, s.sqmy_phone,
               s.sqmy_content, s.is_publicity, s.is_secret, s.unit, s.is_record, s.sqmy_progress,p.back_reason, s.rolling_process,
               s.complex_type, s.is_cases_together, s.unite_sqmy_id, s.cbdwdfwy, s.satisfaction, s.members_opinion,
               s.zx_satisfaction, s.zx_opinion, s.is_key_point, s.key_point_argument, s.is_outstanding, s.outstanding_argument,
               s.create_by, s.create_time, s.update_by, s.update_time, s.remark,s.topic_type,u.type as dwType
        from sqmy_info s
        left join sqmy_unit_reply u on p.sqmy_id = u.sqmy_id
        where u.dept_id = #{deptId}
        <if test="dwType != null  and dwType != ''"> and u.type = #{dwType}</if>
        <if test="topicType != null  and topicType != ''"> and topic_type = #{topicType}</if>
        <if test="sqmyUserId != null "> and s.sqmy_user_id = #{sqmyUserId}</if>
        <if test="sqmyNumber != null  and sqmyNumber != ''"> and s.sqmy_number = #{sqmyNumber}</if>
        <if test="title != null  and title != ''"> and s.title = #{title}</if>
        <if test="lxrName != null  and lxrName != ''"> and s.lxr_name like concat('%', #{lxrName}, '%')</if>
        <if test="lxrPhone != null  and lxrPhone != ''"> and s.lxr_phone = #{lxrPhone}</if>
        <if test="sqmyName != null  and sqmyName != ''"> and s.sqmy_name like concat('%', #{sqmyName}, '%')</if>
        <if test="sqmyPhone != null  and sqmyPhone != ''"> and s.sqmy_phone = #{sqmyPhone}</if>
        <if test="sqmyContent != null  and sqmyContent != ''"> and s.sqmy_content = #{sqmyContent}</if>
        <if test="isPublicity != null  and isPublicity != ''"> and s.is_publicity = #{isPublicity}</if>
        <if test="isSecret != null  and isSecret != ''"> and s.is_secret = #{isSecret}</if>
        <if test="unit != null  and unit != ''"> and s.unit = #{unit}</if>
        <if test="isRecord != null  and isRecord != ''"> and s.is_record = #{isRecord}</if>
        <if test="sqmyProgress != null  and sqmyProgress != ''"> and s.sqmy_progress = #{sqmyProgress}</if>
        <if test="rollingProcess != null  and rollingProcess != ''"> and s.rolling_process = #{rollingProcess}</if>
        <if test="complexType != null  and complexType != ''"> and s.complex_type = #{complexType}</if>
        <if test="isCasesTogether != null  and isCasesTogether != ''"> and s.is_cases_together = #{isCasesTogether}</if>
        <if test="uniteSqmyId != null "> and s.unite_sqmy_id = #{uniteSqmyId}</if>
        <if test="cbdwdfwy != null  and cbdwdfwy != ''"> and s.cbdwdfwy = #{cbdwdfwy}</if>
        <if test="satisfaction != null  and satisfaction != ''"> and s.satisfaction = #{satisfaction}</if>
        <if test="membersOpinion != null  and membersOpinion != ''"> and s.members_opinion = #{membersOpinion}</if>
        <if test="zxSatisfaction != null  and zxSatisfaction != ''"> and s.zx_satisfaction = #{zxSatisfaction}</if>
        <if test="zxOpinion != null  and zxOpinion != ''"> and s.zx_opinion = #{zxOpinion}</if>
        <if test="isKeyPoint != null  and isKeyPoint != ''"> and s.is_key_point = #{isKeyPoint}</if>
        <if test="keyPointArgument != null  and keyPointArgument != ''"> and s.key_point_argument = #{keyPointArgument}</if>
        <if test="isOutstanding != null  and isOutstanding != ''"> and s.is_outstanding = #{isOutstanding}</if>
        <if test="outstandingArgument != null  and outstandingArgument != ''"> and s.outstanding_argument = #{outstandingArgument}</if>
        order by s.update_time desc
    </select>

    <insert id="insertSqmyInfo" parameterType="SqmyInfo" useGeneratedKeys="true" keyProperty="sqmyId">
        insert into sqmy_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="sqmyUserId != null">sqmy_user_id,</if>
            <if test="sqmyNumber != null">sqmy_number,</if>
            <if test="title != null and title != ''">title,</if>
            <if test="topicType != null  and topicType != ''"> topic_type,</if>
            <if test="lxrName != null and lxrName != ''">lxr_name,</if>
            <if test="lxrPhone != null and lxrPhone != ''">lxr_phone,</if>
            <if test="sqmyName != null and sqmyName != ''">sqmy_name,</if>
            <if test="sqmyPhone != null and sqmyPhone != ''">sqmy_phone,</if>
            <if test="sqmyContent != null">sqmy_content,</if>
            <if test="isPublicity != null">is_publicity,</if>
            <if test="isSecret != null">is_secret,</if>
            <if test="unit != null">unit,</if>
            <if test="isRecord != null">is_record,</if>
            <if test="sqmyProgress != null">sqmy_progress,</if>
            <if test="backReason != null">back_reason,</if>
            <if test="rollingProcess != null">rolling_process,</if>
            <if test="complexType != null">complex_type,</if>
            <if test="isCasesTogether != null">is_cases_together,</if>
            <if test="uniteSqmyId != null">unite_sqmy_id,</if>
            <if test="cbdwdfwy != null">cbdwdfwy,</if>
            <if test="satisfaction != null">satisfaction,</if>
            <if test="membersOpinion != null">members_opinion,</if>
            <if test="zxSatisfaction != null">zx_satisfaction,</if>
            <if test="zxOpinion != null">zx_opinion,</if>
            <if test="isKeyPoint != null">is_key_point,</if>
            <if test="keyPointArgument != null">key_point_argument,</if>
            <if test="isOutstanding != null">is_outstanding,</if>
            <if test="outstandingArgument != null">outstanding_argument,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="sqmyUserId != null">#{sqmyUserId},</if>
            <if test="sqmyNumber != null">#{sqmyNumber},</if>
            <if test="title != null and title != ''">#{title},</if>
            <if test="topicType != null  and topicType != ''"> #{topicType},</if>
            <if test="lxrName != null and lxrName != ''">#{lxrName},</if>
            <if test="lxrPhone != null and lxrPhone != ''">#{lxrPhone},</if>
            <if test="sqmyName != null and sqmyName != ''">#{sqmyName},</if>
            <if test="sqmyPhone != null and sqmyPhone != ''">#{sqmyPhone},</if>
            <if test="sqmyContent != null">#{sqmyContent},</if>
            <if test="isPublicity != null">#{isPublicity},</if>
            <if test="isSecret != null">#{isSecret},</if>
            <if test="unit != null">#{unit},</if>
            <if test="isRecord != null">#{isRecord},</if>
            <if test="sqmyProgress != null">#{sqmyProgress},</if>
            <if test="backReason != null">#{backReason},</if>
            <if test="rollingProcess != null">#{rollingProcess},</if>
            <if test="complexType != null">#{complexType},</if>
            <if test="isCasesTogether != null">#{isCasesTogether},</if>
            <if test="uniteSqmyId != null">#{uniteSqmyId},</if>
            <if test="cbdwdfwy != null">#{cbdwdfwy},</if>
            <if test="satisfaction != null">#{satisfaction},</if>
            <if test="membersOpinion != null">#{membersOpinion},</if>
            <if test="zxSatisfaction != null">#{zxSatisfaction},</if>
            <if test="zxOpinion != null">#{zxOpinion},</if>
            <if test="isKeyPoint != null">#{isKeyPoint},</if>
            <if test="keyPointArgument != null">#{keyPointArgument},</if>
            <if test="isOutstanding != null">#{isOutstanding},</if>
            <if test="outstandingArgument != null">#{outstandingArgument},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
        </trim>
    </insert>

    <update id="updateSqmyInfo" parameterType="SqmyInfo">
        update sqmy_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="sqmyUserId != null">sqmy_user_id = #{sqmyUserId},</if>
            <if test="sqmyNumber != null">sqmy_number = #{sqmyNumber},</if>
            <if test="title != null and title != ''">title = #{title},</if>
            <if test="topicType != null  and topicType != ''">topic_type = #{topicType},</if>
            <if test="lxrName != null and lxrName != ''">lxr_name = #{lxrName},</if>
            <if test="lxrPhone != null and lxrPhone != ''">lxr_phone = #{lxrPhone},</if>
            <if test="sqmyName != null and sqmyName != ''">sqmy_name = #{sqmyName},</if>
            <if test="sqmyPhone != null and sqmyPhone != ''">sqmy_phone = #{sqmyPhone},</if>
            <if test="sqmyContent != null">sqmy_content = #{sqmyContent},</if>
            <if test="isPublicity != null">is_publicity = #{isPublicity},</if>
            <if test="isSecret != null">is_secret = #{isSecret},</if>
            <if test="unit != null">unit = #{unit},</if>
            <if test="isRecord != null">is_record = #{isRecord},</if>
            <if test="sqmyProgress != null">sqmy_progress = #{sqmyProgress},</if>
            <if test="backReason != null">back_reason = #{backReason},</if>
            <if test="rollingProcess != null">rolling_process = #{rollingProcess},</if>
            <if test="complexType != null">complex_type = #{complexType},</if>
            <if test="isCasesTogether != null">is_cases_together = #{isCasesTogether},</if>
            <if test="uniteSqmyId != null">unite_sqmy_id = #{uniteSqmyId},</if>
            <if test="cbdwdfwy != null">cbdwdfwy = #{cbdwdfwy},</if>
            <if test="satisfaction != null">satisfaction = #{satisfaction},</if>
            <if test="membersOpinion != null">members_opinion = #{membersOpinion},</if>
            <if test="zxSatisfaction != null">zx_satisfaction = #{zxSatisfaction},</if>
            <if test="zxOpinion != null">zx_opinion = #{zxOpinion},</if>
            <if test="isKeyPoint != null">is_key_point = #{isKeyPoint},</if>
            <if test="keyPointArgument != null">key_point_argument = #{keyPointArgument},</if>
            <if test="isOutstanding != null">is_outstanding = #{isOutstanding},</if>
            <if test="outstandingArgument != null">outstanding_argument = #{outstandingArgument},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where sqmy_id = #{sqmyId}
    </update>

    <delete id="deleteSqmyInfoBySqmyId" parameterType="Long">
        delete from sqmy_info where sqmy_id = #{sqmyId}
    </delete>

    <delete id="deleteSqmyInfoBySqmyIds" parameterType="String">
        delete from sqmy_info where sqmy_id in
        <foreach item="sqmyId" collection="array" open="(" separator="," close=")">
            #{sqmyId}
        </foreach>
    </delete>
</mapper>