InspectionDefenceMapper.xml 5.33 KB
<?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.glsx.dj.mindworkplate.mapper.InspectionDefenceMapper">
    <resultMap id="BaseResultMap" type="cn.com.glsx.dj.mindworkplate.model.InspectionDefence">
        <!--
          WARNING - @mbg.generated
        -->
        <id column="id" property="id" jdbcType="INTEGER"/>
        <result column="batch_id" property="batchId" jdbcType="INTEGER"/>
        <result column="defence_count" property="defenceCount" jdbcType="INTEGER"/>
        <result column="avg_defence" property="avgDefence" jdbcType="VARCHAR"/>
        <result column="customer_type" property="customerType" jdbcType="VARCHAR"/>
        <result column="failure_reason" property="failureReason" jdbcType="VARCHAR"/>
        <result column="summary" property="summary" jdbcType="VARCHAR"/>
        <result column="created_by" property="createdBy" jdbcType="VARCHAR"/>
        <result column="created_date" property="createdDate" jdbcType="TIMESTAMP"/>
        <result column="updated_by" property="updatedBy" jdbcType="VARCHAR"/>
        <result column="updated_date" property="updatedDate" jdbcType="TIMESTAMP"/>
        <result column="deleted_flag" property="deletedFlag" jdbcType="CHAR"/>
    </resultMap>
    <resultMap id="ResponseMap" type="cn.com.glsx.dj.mindworkplate.dto.DefenceDetailPageDTO">
        <id column="id" property="id" jdbcType="INTEGER"/>
        <result column="batch_id" property="batchId" jdbcType="INTEGER"/>
        <result column="defence_count" property="defenceCount" jdbcType="INTEGER"/>
        <result column="avg_defence" property="avgDefence" jdbcType="VARCHAR"/>
        <result column="customer_type" property="customerType" jdbcType="VARCHAR"/>
        <result column="failure_reason" property="failureReason" jdbcType="VARCHAR"/>
        <result column="summary" property="summary" jdbcType="VARCHAR"/>
        <collection property="detailList" javaType="java.util.List"
                    resultMap="cn.com.glsx.dj.mindworkplate.mapper.DefenceDetailMapper.BaseResultMap"
                    columnPrefix="t1_"/>
    </resultMap>
    <sql id="Base_Column_List">
        <!--
          WARNING - @mbg.generated
        -->
        id, batch_id, defence_count, avg_defence, customer_type, failure_reason, summary,
        standard_question,standard_answer,
        created_by, created_date, updated_by, updated_date, deleted_flag
    </sql>

    <select id="getDefenceDetail" resultMap="ResponseMap">
        select t.id,
               t.batch_id,
               t.defence_count,
               t.avg_defence,
               t.customer_type,
               t.failure_reason,
               t.summary,
               t1.id                          as t1_id,
               t1.defence_id                  as t1_defence_id,
               t1.def_score                   as t1_def_score,
               t1.con_start_time              as t1_con_start_time,
               t1.question                    as t1_question,
               t1.answer                      as t1_answer,
               t1.suggestions_for_improvement as t1_suggestions_for_improvement,
               t1.refine_the_expression       as t1_refine_the_expression,
               t1.highlight                   as t1_highlight,
               t1.standard_question           as t1_standard_question,
               t1.standard_answer             as t1_standard_answer
        from inspection_defence t
                 left join inspection_defence_detail t1 on t.id = t1.defence_id and t1.deleted_flag = 'N'
        where t.batch_id = #{batchId}
          and t.deleted_flag = 'N'
        ORDER BY t1.con_start_time desc
    </select>


    <update id="deleteByIdList">
        update inspection_defence set deleted_flag = 'D' , updated_date = now() where id in
        <foreach collection="list" item="item" separator="," open="(" close=")">
            #{item}
        </foreach>
    </update>

    <select id="getByBatchId" resultType="java.lang.Integer">
        select id
        from inspection_defence
        where batch_id = #{batchId}
          and deleted_flag = 'N'
    </select>

  <select id="getDefenceDetailByBatchIds" resultMap="ResponseMap">
    select
    t.batch_id,
    t.defence_count,
    t.avg_defence,
    t.customer_type,
    t.failure_reason,
    t.summary,
    t1.id                          as t1_id,
    t1.defence_id                  as t1_defence_id,
    t1.def_score                   as t1_def_score,
    t1.con_start_time              as t1_con_start_time,
    t1.question                    as t1_question,
    t1.answer                      as t1_answer,
    t1.suggestions_for_improvement as t1_suggestions_for_improvement,
    t1.refine_the_expression       as t1_refine_the_expression,
    t1.highlight                   as t1_highlight,
    t1.standard_question           as t1_standard_question,
    t1.standard_answer             as t1_standard_answer
    from inspection_defence t
    left join inspection_defence_detail t1 on t.id = t1.defence_id and t1.deleted_flag = 'N'
    where
    <if test="batchIds != null and batchIds.size>0">
      t.batch_id in
      <foreach close=")" collection="batchIds" item="item" open="(" separator=",">
        #{item}
      </foreach>
    </if>
    and t.deleted_flag = 'N'
    ORDER BY t1.con_start_time desc
  </select>
</mapper>