<?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.AuditProjectMapper">
    <select id="getProjectAllTask" resultType="java.util.Map">
        SELECT DISTINCT B.is_public as isPublic,B.content,B.des,C.citemid,
        D.item,D.file_id as fileId,D.cgrp,D.cgrp_path as cgrpPath,D.content as complineContent,
        E.file_name AS fileName,E.file_path as filePath,E.file_Tp as fileTp,
        G.realname,A.userid,A.checkid,A.projectid,A.id,A.come_from as comeFrom,
        GROUP_CONCAT(K.ca_name SEPARATOR ',') AS actNames,GROUP_CONCAT(K.id SEPARATOR ',') AS actIds
        FROM  audit_task A
        INNER JOIN audit_check_method B on A.checkid=B.id and A.come_from=2
        Left JOIN audit_item_rel_check C ON B.id = C.checkid
        Left JOIN audit_compliane_item D ON C.citemid = D.id
        LEFT JOIN doc_files E ON D.file_id = E.id
        LEFT JOIN sys_user G on A.userid=G.id
        left JOIN audit_act_rel_others H ON A.checkid = H.tid AND H.tp = 5
        left JOIN audit_act K ON H.act_id = K.id
        <where>
            <if test="projectid!= null">
                A.projectid = #{projectid}
            </if>
            <if test="userid != null">
                and A.userid = #{userid}
            </if>
        </where>
        GROUP BY A.projectid,A.id,A.userid,A.checkid, B.is_public,B.content,B.des,
            C.citemid,D.item,D.file_id ,E.file_name,D.content,G.realname
        order by E.id,D.id,B.id
    </select>

    <select id="getProjectAllTaskForInnerOrder" resultType="java.util.Map">
        SELECT DISTINCT B.is_public as isPublic,B.content,B.des,C.citemid,
        D.item,D.file_id as fileId,D.cgrp,D.cgrp_path as cgrpPath,D.content as complineContent,
        E.file_name AS fileName,E.file_path as filePath,E.file_Tp as fileTp,
        G.realname,A.userid,A.checkid,A.projectid,A.id,A.come_from as comeFrom,
        GROUP_CONCAT(K.ca_name SEPARATOR ',') AS actNames,GROUP_CONCAT(K.id SEPARATOR ',') AS actIds
        FROM  audit_task A
        INNER JOIN audit_inner_order_checkmethod B on A.checkid=B.id and A.come_from=3
        Left JOIN  audit_inner_order_rel_check C ON B.id = C.checkid
        Left JOIN  audit_inner_order D ON C.citemid = D.id
        LEFT JOIN doc_files E ON D.file_id = E.id
        LEFT JOIN sys_user G on A.userid=G.id
        left JOIN audit_act_rel_others H ON A.checkid = H.tid AND H.tp = 5
        left JOIN audit_act K ON H.act_id = K.id
        <where>
            <if test="projectid!= null">
                A.projectid = #{projectid}
            </if>
            <if test="userid != null">
                and A.userid = #{userid}
            </if>
        </where>
        GROUP BY A.projectid,A.id,A.userid,A.checkid, B.is_public,B.content,B.des,
        C.citemid,D.item,D.file_id ,E.file_name,D.content,G.realname
        order by E.id,D.id,B.id
    </select>
</mapper>