<?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.rongwei.bscommon.sys.dao.QuestionCommonSqlDao">
    <select id="getDictValueByDictType" resultType="com.rongwei.rwadmincommon.system.domain.SysDictDo">
        select *
        from sys_dict
        where DELETED = '0'
        AND PID != '-1'
        AND DICTTYPE IN
        <foreach collection="types" item="type" separator="," open="(" close=")">
            #{type,jdbcType=VARCHAR}
        </foreach>
    </select>
    <select id="getListByMainId" resultType="com.rongwei.bsentity.domin.SrmIssuesFiveWhyDo">
        select *
        from srm_issues_five_why
        where DELETED = '0'
          AND MAINID = #{mainId}
        order by field(WHY, 'WHAT(什么问题)', 'WHERE(具体地点)', 'WHO(谁)', 'WHEN(什么时候)', 'WHY(为什么)', 'HOW(怎么处理)')
    </select>
    <select id="getOrgInfo" resultType="com.rongwei.rwadmincommon.system.domain.SysOrganizationDo">
        select *
        from sys_organization
        where DELETED = '0'
        <if test="orgIds != null and orgIds.size() >0">
            AND ID IN
            <foreach collection="orgIds" item="orgId" separator="," open="(" close=")">
                #{orgId,jdbcType=VARCHAR}
            </foreach>
        </if>
    </select>
    <select id="getAllOrg" resultType="com.rongwei.rwadmincommon.system.domain.SysOrganizationDo">
        select *
        from sys_organization
        where DELETED = '0'
    </select>
    <select id="getRunTaskByProcessinsIdAndTaskCode" resultType="com.rongwei.wfentity.sys.RunTaskDo">
        select * from wf_run_task
        <where>
            DELETED ='0'
            AND PROCESSINSTID=#{processinstId ,jdbcType=VARCHAR}
            AND TASKCODE = #{taskCode,jdbcType=VARCHAR}
        </where>
    </select>
    <select id="getAlluser" resultType="com.rongwei.rwadmincommon.system.domain.SysUserDo">
        select *
        from sys_user
        where DELETED = '0'
    </select>
    <select id="getUserByRoleCodeAndOrgId"  resultType="com.rongwei.rwadmincommon.system.domain.SysUserDo">
        SELECT
        su.*
        FROM
        sys_user su
        LEFT JOIN sys_user_role sur ON su.ID = sur.USERID
        LEFT JOIN sys_user_org suo ON su.ID = suo.USERID
        LEFT JOIN sys_role sr ON sur.ROLEID = sr.ID
        WHERE
        <if test="orgIds != null and orgIds.size() >0">
            suo.ORGID IN
            <foreach collection="orgIds" item="orgId" separator="," open="(" close=")">
                #{orgId,jdbcType=VARCHAR}
            </foreach>
        </if>
          AND sr.CODE =#{roleCode,jdbcType=VARCHAR}
          AND su.DELETED = '0'
          AND sur.DELETED = '0'
          AND suo.DELETED = '0'
          AND sr.DELETED = '0'
    </select>
</mapper>
