<?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="org.jeecg.modules.stm.audit.mapper.AuditTaskReportMapper">

    <select id="findAllTaskReport" resultType="java.util.Map">
        SELECT A.name AS prjName,B.name AS prjItemName,B.id AS prjItemId,
        A.id as projectid,C.checkid,C.check_item_tp AS checkItemTp,C.situation,C.issues,C.score,
        F.item,G.content AS checkContent,H.file_name AS fileName,H.id AS fileId
        FROM  audit_project A
        INNER JOIN audit_project_item B ON A.id=B.pid
        INNER JOIN audit_task_report C ON B.id = C.check_item_id
        LEFT JOIN audit_item_rel_check D ON C.checkid = D.checkid
        LEFT JOIN audit_act_rel_others E ON D.checkid = E.tid AND E.tp =5
        LEFT JOIN audit_compliane_item F ON D.citemid=F.id
        LEFT JOIN audit_check_method G ON D.checkid=G.id
        LEFT JOIN doc_files H ON F.file_id=H.id
        <where>
            <if test="query.projectid != null">
                C.projectid = #{query.projectid}
            </if>
            <if test="query.checkid != null">
                and C.checkid = #{query.checkid}
            </if>
            <if test="fileId != null">
                and F.fileId = #{fileId}
            </if>
        </where>
        order by A.id,C.checkid,B.id
    </select>

</mapper>