<?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="com.ruoyi.ibs.draw.mapper.DrawLayerMapper">


    <select id="getLayerList" resultType="com.ruoyi.ibs.draw.domain.vo.LayerRuleVO">
        select layer_id,layer_name from draw_layer
         where  delete_flag = 0
         and layer_id in
        (select layer_id from draw_shape where ops_dept = #{opsDept} and delete_flag = 0 and dept_id like concat(#{deptId},'%') group by layer_id)
    </select>

    <select id="getValidDrawLayerList" resultType="DrawLayerVO">
        select dl.layer_id, dl.layer_name, dl.layer_color, ifnull(sum(ds.audit_flag) = 0, 1) as disabled from draw_layer dl
        left join (
            select *, if(audit_status ='1', 1, 0) as audit_flag from draw_shape
            where delete_flag = '0' and ops_dept = #{opsDept} and dept_id = #{deptId} and relate_flag = '0'
        ) ds on ds.layer_id = dl.layer_id
        where dl.delete_flag = '0'
          and dl.dept_id like concat(#{deptHead},'%')
        group by dl.layer_id, dl.layer_name
        order by disabled
    </select>
</mapper>