AiSparringTaskMapper.xml 7.61 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.AiSparringTaskMapper">
    <resultMap id="BaseResultMap" type="cn.com.glsx.dj.mindworkplate.model.AiSparringTask">
        <!--
          WARNING - @mbg.generated
        -->
        <id column="id" property="id" jdbcType="INTEGER"/>
        <result column="task_name" property="taskName" jdbcType="VARCHAR"/>
        <result column="task_state" property="taskState" jdbcType="INTEGER"/>
        <result column="business_scenario" property="businessScenario" jdbcType="INTEGER"/>
        <result column="task_type" property="taskType" jdbcType="INTEGER"/>
        <result column="ai_type" property="aiType" jdbcType="INTEGER"/>
        <result column="prompt_on_off" property="promptOnOff" jdbcType="INTEGER"/>
        <result column="start_time" property="startTime" jdbcType="TIMESTAMP"/>
        <result column="end_time" property="endTime" jdbcType="TIMESTAMP"/>
        <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="DTOResultMap" extends="BaseResultMap" type="cn.com.glsx.dj.mindworkplate.dto.AiSparringTaskDTO">
    </resultMap>
    <resultMap id="staffTaskDTOResultMap" type="cn.com.glsx.dj.mindworkplate.dto.AiSparringStaffTaskDTO">
        <association property="task" resultMap="DTOResultMap" columnPrefix="task_"/>
        <association property="staff"
                     resultMap="cn.com.glsx.dj.mindworkplate.mapper.AiSparringTaskStaffRefMapper.DTOResultMap"
                     columnPrefix="staff_"/>
    </resultMap>
    <sql id="Base_Column_List">
        <!--
          WARNING - @mbg.generated
        -->
        id, task_name, task_state, business_scenario, task_type, ai_type, prompt_on_off, start_time, end_time,
        created_by, created_date, updated_by, updated_date, deleted_flag
    </sql>

    <select id="page"
            parameterType="cn.com.glsx.dj.mindworkplate.dto.AiSparringTaskRequestDTO"
            resultMap="DTOResultMap">
        select * from ai_sparring_task ast
        <where>
            ast.deleted_flag = 'N'
            <if test="id != null">
                and ast.id = #{id}
            </if>
            <if test="taskName != null and taskName != ''">
                and ast.task_name like concat('%', #{taskName}, '%')
            </if>
            <if test="taskState != null">
                and ast.task_state = #{taskState}
            </if>
            <if test="businessScenario != null">
                and ast.business_scenario = #{businessScenario}
            </if>
            <if test="startTime != null">
                and ast.start_time &gt;= #{startTime}
            </if>
            <if test="endTime != null">
                and ast.end_time &lt;= #{endTime}
            </if>
            <if test="createTimeStart != null">
                and ast.created_date &gt;= #{createTimeStart}
            </if>
            <if test="createTimeEnd != null">
                and ast.created_date &lt;= #{createTimeEnd}
            </if>
        </where>
        order by
        <if test="orderBy != null and orderBy != ''">
            ast.#{orderBy}
            <if test="sortord != null and sortord != ''">
                #{sortord}
            </if>
            ,
        </if>
        ast.created_date desc
    </select>

    <select id="findByIds" resultMap="BaseResultMap">
        select * from ai_sparring_task
        <where>
            deleted_flag = 'N'
            and id in
            <foreach collection="ids" item="id" close=")" open="(" separator=",">
                #{id}
            </foreach>
        </where>
    </select>

    <select id="pageStaffTask"
            parameterType="cn.com.glsx.dj.mindworkplate.dto.AiSparringTaskStaffRequestDTO"
            resultMap="staffTaskDTOResultMap">
        select
        ast.id as task_id,
        ast.task_name as task_task_name,
        ast.business_scenario as task_business_scenario,
        ast.task_type as task_task_type,
        ast.ai_type as task_ai_type,
        ast.prompt_on_off as task_prompt_on_off,
        ast.start_time as task_start_time,
        ast.end_time as task_end_time,
        ast.created_by as task_created_by,
        ast.created_date as task_created_date,
        ast.updated_by as task_updated_by,
        ast.updated_date as task_updated_date,
        ast.deleted_flag as task_deleted_flag,
        astsr.id as staff_id,
        astsr.task_id as staff_task_id,
        astsr.yq_merchant_id as staff_yq_merchant_id,
        astsr.yq_merchant_name as staff_yq_merchant_name,
        astsr.staff_uuid as staff_staff_uuid,
        astsr.staff_name as staff_staff_name,
        astsr.staff_phone as staff_staff_phone,
        astsr.try_count as staff_try_count,
        astsr.sparring_status as staff_sparring_status,
        astsr.estimated_result as staff_estimated_result,
        astsr.score as staff_score,
        astsr.completion_time as staff_completion_time,
        astsr.created_by as staff_created_by,
        astsr.created_date as staff_created_date,
        astsr.updated_by as staff_updated_by,
        astsr.updated_date as staff_updated_date,
        astsr.deleted_flag as staff_deleted_flag
        from ai_sparring_task ast
        inner join ai_sparring_task_staff_ref astsr on astsr.task_id = ast.id
        <where>
            ast.deleted_flag = 'N'
            and astsr.deleted_flag = 'N'
            <if test="id != null">
                and astsr.id = #{id}
            </if>
            <if test="taskName != null and taskName != ''">
                and ast.task_name like concat('%', #{taskName}, '%')
            </if>
            <if test="taskState != null">
                and ast.task_state &lt;= #{taskState}
            </if>
            <if test="staffUuid != null and staffUuid != ''">
                and astsr.staff_uuid = #{staffUuid}
            </if>
            <if test="yqMerchantId != null">
                and astsr.yq_merchant_id = #{yqMerchantId}
            </if>
            <if test="sparringStatus != null">
                and astsr.sparring_status = #{sparringStatus}
            </if>
            <if test="tryCount != null">
                and astsr.try_count &lt;= #{tryCount}
            </if>
        </where>
        order by ast.task_state asc, ast.created_date desc
    </select>

    <update id="updateDeadlineStatus">
        update ai_sparring_task set task_state = 2
        where deleted_flag = 'N' and task_state != 2 and end_time &lt;= current_timestamp()
    </update>

    <select id="findTaskIdByStaff"
            resultType="java.lang.Integer">
        select ast.id from ai_sparring_staff_info info
        left join ai_sparring_task_staff_ref astsr on info.staff_uuid = astsr.staff_uuid and astsr.deleted_flag = 'N'
        left join ai_sparring_task ast on astsr.task_id = ast.id and ast.deleted_flag = 'N'
        <where>
            ast.task_state = 1 and NOW() BETWEEN ast.start_time AND ast.end_time
            <if test="staffUuid != null and staffUuid != ''">
                and info.staff_uuid = #{staffUuid}
            </if>
            <if test="yqMerchantId != null">
                and astsr.yq_merchant_id = #{yqMerchantId}
            </if>
            order by ast.created_date desc limit 1
        </where>
    </select>
</mapper>