<?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.cecep.talroad.mapper.BMainThreeSupervisionEnforcMapper">

    <resultMap type="cn.cecep.talroad.domain.BMainThreeSupervisionEnforc" id="BMainThreeSupervisionEnforcResult">
        <result property="taskId"    column="task_id"    />
        <result property="taskName"    column="task_name"    />
        <result property="factoryId"    column="factory_id"    />
        <result property="factoryName"    column="factory_name"    />
        <result property="districtName"    column="district_name"    />
        <result property="districtCode"    column="district_code"    />
        <result property="industryCategoryName"    column="industry_category_name"    />
        <result property="industryCategoryCode"    column="industry_category_code"    />
        <result property="manType"    column="man_type"    />
        <result property="industryCategory"    column="industry_category"    />
        <result property="closingTime"    column="closing_time"    />
        <result property="archiveTime"    column="archive_time"    />
        <result property="taskStatus"    column="task_status"    />
        <result property="initiatingTime"    column="initiating_time"    />
        <result property="initiatingDeptId"    column="initiating_dept_id"    />
        <result property="initiatingDeptName"    column="initiating_dept_name"    />
        <result property="emergencyLevel"    column="emergency_level"    />
        <result property="estimatedCompletionTime"    column="estimated_completion_time"    />
        <result property="factoryAddress"    column="factory_address"    />
        <result property="specificIssues"    column="specific_issues"    />
        <result property="taskDetails"    column="task_details"    />
        <result property="questionAttachment"    column="question_attachment"    />
        <result property="receivingDeptIds"    column="receiving_dept_ids"    />
        <result property="receivingDeptNames"    column="receiving_dept_names"    />
        <result property="updateTime"    column="update_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="createBy"    column="create_by"    />
    </resultMap>

    <resultMap type="cn.cecep.talroad.vo.BMainThreeSupervisionEnforcVo" id="BMainThreeSupervisionEnforcResultVo">
        <result property="taskId"    column="task_id"    />
        <result property="taskName"    column="task_name"    />
        <result property="factoryId"    column="factory_id"    />
        <result property="factoryName"    column="factory_name"    />
        <result property="districtName"    column="district_name"    />
        <result property="districtCode"    column="district_code"    />
        <result property="industryCategoryName"    column="industry_category_name"    />
        <result property="industryCategoryCode"    column="industry_category_code"    />
        <result property="manType"    column="man_type"    />
        <result property="industryCategory"    column="industry_category"    />
        <result property="closingTime"    column="closing_time"    />
        <result property="archiveTime"    column="archive_time"    />
        <result property="taskStatus"    column="task_status"    />
        <result property="initiatingTime"    column="initiating_time"    />
        <result property="initiatingDeptId"    column="initiating_dept_id"    />
        <result property="initiatingDeptName"    column="initiating_dept_name"    />
        <result property="emergencyLevel"    column="emergency_level"    />
        <result property="estimatedCompletionTime"    column="estimated_completion_time"    />
        <result property="factoryAddress"    column="factory_address"    />
        <result property="specificIssues"    column="specific_issues"    />
        <result property="taskDetails"    column="task_details"    />
        <result property="questionAttachment"    column="question_attachment"    />
        <result property="receivingDeptIds"    column="receiving_dept_ids"    />
        <result property="receivingDeptNames"    column="receiving_dept_names"    />
        <result property="createTime"    column="create_time"    />

        <collection property="recordList" ofType="cn.cecep.talroad.domain.BMainThreeSupervisionEnforcRecord">
            <id property="recordId"    column="record_id"    />
            <result property="taskId"    column="task_id"    />
            <result property="handleDeptId"    column="handle_dept_id"    />
            <result property="handleDeptName"    column="handle_dept_name"    />
            <result property="handlePerson"    column="handle_person"    />
            <result property="handleTime"    column="handle_time"    />
            <result property="conclusion"    column="conclusion"    />
            <result property="specificConclusion"    column="specific_conclusion"    />
            <result property="questionAttachment"    column="question_attachment"    />
            <result property="createBy"    column="create_by"    />
            <result property="createTime"    column="create_time"    />
            <result property="updateBy"    column="update_by"    />
            <result property="updateTime"    column="update_time"    />
        </collection>
    </resultMap>


    <sql id="selectBMainThreeSupervisionEnforcVo">
        select task_id, task_name, factory_id, factory_name, district_name, district_code, industry_category_name, industry_category_code, man_type, industry_category, closing_time, archive_time, task_status, initiating_time, initiating_dept_id, initiating_dept_name, emergency_level, estimated_completion_time, factory_address, specific_issues, task_details, question_attachment, receiving_dept_ids, receiving_dept_names, update_time, update_by, create_time, create_by from b_main_three_supervision_enforc
    </sql>

    <select id="selectBMainThreeSupervisionEnforcList" parameterType="cn.cecep.talroad.domain.BMainThreeSupervisionEnforc" resultMap="BMainThreeSupervisionEnforcResult">
        <include refid="selectBMainThreeSupervisionEnforcVo"/>
        <where>
            <if test="taskName != null  and taskName != ''"> and task_name like concat('%', #{taskName}, '%')</if>
            <if test="factoryId != null  and factoryId != ''"> and factory_id = #{factoryId}</if>
            <if test="factoryName != null  and factoryName != ''"> and factory_name like concat('%', #{factoryName}, '%')</if>
            <if test="districtName != null  and districtName != ''"> and district_name like concat('%', #{districtName}, '%')</if>
            <if test="districtCode != null  and districtCode != ''"> and district_code = #{districtCode}</if>
            <if test="industryCategoryName != null  and industryCategoryName != ''"> and industry_category_name like concat('%', #{industryCategoryName}, '%')</if>
            <if test="industryCategoryCode != null  and industryCategoryCode != ''"> and industry_category_code = #{industryCategoryCode}</if>
            <if test="manType != null  and manType != ''"> and man_type = #{manType}</if>
            <if test="industryCategory != null  and industryCategory != ''"> and industry_category = #{industryCategory}</if>
            <if test="closingTime != null  and closingTime != ''"> and closing_time = #{closingTime}</if>
            <if test="archiveTime != null  and archiveTime != ''"> and archive_time = #{archiveTime}</if>
            <if test="taskStatus != null  and taskStatus != ''"> and task_status = #{taskStatus}</if>
            <if test="initiatingDeptId != null  and initiatingDeptId != ''"> and initiating_dept_id = #{initiatingDeptId}</if>
            <if test="initiatingDeptName != null  and initiatingDeptName != ''"> and initiating_dept_name like concat('%', #{initiatingDeptName}, '%')</if>
            <if test="emergencyLevel != null  and emergencyLevel != ''"> and emergency_level = #{emergencyLevel}</if>
            <if test="estimatedCompletionTime != null  and estimatedCompletionTime != ''"> and estimated_completion_time = #{estimatedCompletionTime}</if>
            <if test="factoryAddress != null  and factoryAddress != ''"> and factory_address = #{factoryAddress}</if>
            <if test="specificIssues != null  and specificIssues != ''"> and specific_issues = #{specificIssues}</if>
            <if test="taskDetails != null  and taskDetails != ''"> and task_details = #{taskDetails}</if>
            <if test="questionAttachment != null  and questionAttachment != ''"> and question_attachment = #{questionAttachment}</if>
            <if test="receivingDeptIds != null  and receivingDeptIds != ''"> and receiving_dept_ids = #{receivingDeptIds}</if>
            <if test="receivingDeptNames != null  and receivingDeptNames != ''"> and receiving_dept_names like concat('%', #{receivingDeptNames}, '%')</if>
        </where>
    </select>

    <select id="selectTaskById" resultMap="BMainThreeSupervisionEnforcResultVo">
        SELECT
            bmtse.task_id,bmtse.task_name,bmtse.factory_id,bmtse.factory_name,bmtse.district_name,bmtse.district_code,bmtse.industry_category_name,
            bmtse.industry_category_code,bmtse.man_type,bmtse.industry_category,bmtse.closing_time,bmtse.archive_time,
            bmtse.task_status,initiating_time,bmtse.initiating_dept_id,bmtse.initiating_dept_name,bmtse.emergency_level,bmtse.estimated_completion_time,
            bmtse.factory_address,bmtse.specific_issues,bmtse.task_details,bmtse.question_attachment,bmtse.receiving_dept_ids,
            bmtse.receiving_dept_names,bmtse.update_time,bmtse.update_by,bmtse.create_time,bmtse.create_by,
            bmtser.record_id,bmtser.task_id,bmtser.handle_dept_id,bmtser.handle_dept_name,bmtser.handle_person,bmtser.handle_time,
            bmtser.conclusion,bmtser.specific_conclusion,bmtser.question_attachment,bmtser.create_by,bmtser.create_time,
            bmtser.update_by,bmtser.update_time
        FROM b_main_three_supervision_enforc bmtse
            LEFT JOIN b_main_three_supervision_enforc_record bmtser ON bmtse.task_id = bmtser.task_id
        WHERE bmtse.task_id = #{taskId}
        ORDER BY bmtser.create_time
    </select>
</mapper>
