<?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.chinaweal.aiccs.aiccs.punishment.mapper.EntlockMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.chinaweal.aiccs.aiccs.punishment.entity.EntLock">
        <id column="ELID" property="elid" />
        <result column="PRIPID" property="pripid" />
        <result column="ENTNAME" property="entname" />
        <result column="REGNO" property="regno" />
        <result column="UNISCID" property="uniscid" />
        <result column="LOCKREASON" property="lockreason" />
        <result column="LOCKUSERNAME" property="lockusername" />
        <result column="LOCKUSERID" property="lockuserid" />
        <result column="LOCKUSERDEPTID" property="lockuserdeptid" />
        <result column="LOCKUSERUNITID" property="lockuserunitid" />
        <result column="LOCKSTARTDATE" property="lockstartdate" />
        <result column="LOCKTIME" property="lockTime" />
        <result column="UNLOCKTIME" property="unlockTime" />
        <result column="LOCKENDDATE" property="lockenddate" />
        <result column="UNLUSERNAME" property="unlusername" />
        <result column="UNLUSERID" property="unluserid" />
        <result column="ULDEPTID" property="uldeptid" />
        <result column="ULUNITID" property="ulunitid" />
        <result column="UNLDATE" property="unldate" />
        <result column="LOCKTYPE" property="locktype" />
        <result column="MEASURE" property="measure" />
        <result column="LOCKSTATE" property="lockstate" />
        <result column="INPUTDATE" property="inputdate" />
        <result column="ULOCKREASON" property="unlockreason" />
        <result column="LAUPTIME" property="laupTime" />
        <result column="state" property="state" />
        <result column="FILEPATH" property="filepath" />
        <result column="FILENAME" property="filename" />
        <result column="punishFrom" property="punishFrom" />
        <result column="tflockid" property="tflockid" />
        <result column="warningcontent" property="warningcontent" />
    </resultMap>

    <resultMap id="EntLockExcel" type="com.chinaweal.aiccs.aiccs.punishment.entity.excel.EntLockExcel">
        <id column="uniscid" property="uniscid" />
        <result column="entname" property="entname" />
        <result column="regno" property="regno" />
        <result column="locktype" property="locktype" />
        <result column="lockreason" property="lockreason" />
        <result column="lockTime" property="lockTime" />
        <result column="unlockTime" property="unlockTime" />
        <result column="ulockspecificreason" property="ulockspecificreason" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        ELID, PRIPID, ENTNAME, MEASURE, UNISCID, REGNO, LOCKREASON, LOCKUSERNAME, LOCKUSERID, LOCKUSERDEPTID, LOCKTIME, UNLOCKTIME, LOCKUSERUNITID, LOCKSTARTDATE, LOCKENDDATE, UNLUSERNAME, UNLUSERID, ULDEPTID, ULUNITID, UNLDATE, LOCKTYPE, LOCKSTATE, INPUTDATE,  LAUPTIME, state, FILEPATH, FILENAME, punishFrom
    </sql>

    <select id="queryAll" resultMap="BaseResultMap">
        SELECT
            '1' AS punishFrom,
            e.PRIPID,
            e.UNISCID,
            e.ENTNAME,
            e.REGNO,
            '001' AS LOCKTYPE,
            e.regorg,
            e.Cerno,
            e.Certype,
            e.lerep as representative,
            '根据国家38部委关于《失信企业协同监管和联合惩戒合作备忘录》（发改财金[2015]2045号）的要求，我局从公共信用信息平台获取到安监部门联合惩戒相关数据，你公司被安监部门列为安全生产黑名单，要求进行联合惩戒，我局在注册登记系统进行警示限制。（如企业已完成安监部门的整改要求或未有违反《生产经营单位安全生产不良记录“黑名单”管理暂行规定》提出异议的可申请解除联合惩戒警示）（如有疑问咨询85592417）' AS LOCKREASON
        FROM
            crgs.ex_xxzx_09_aqschmd_aj ex
            LEFT JOIN e_baseinfo e ON ex.dwmc = e.ENTNAME
        WHERE
            e.ENTNAME is not null and
            e.REGSTATE IN ( '1', '003001', '003' )
          AND ex.dwmc NOT IN ( SELECT ENTNAME FROM entlock ) UNION ALL
        SELECT
            '3' AS punishFrom,
            e.PRIPID,
            e.UNISCID,
            e.ENTNAME,
            e.REGNO,
            '001' AS LOCKTYPE,
            e.regorg,
            e.Cerno,
            e.Certype,
            e.lerep as representative,
            '根据国家38部委关于《失信企业协同监管和联合惩戒合作备忘录》（发改财金[2015]2045号）的要求，我局从公共信用信息平台获取到海关部门联合惩戒相关数据，你公司被海关部门列为海关失信认证企业名单，要求进行联合惩戒，我局在注册登记系统进行警示限制。（如企业没有违反《中华人民共和国海关企业信用管理暂行办法》，可以申请解除联合惩戒警示）（如有疑问咨询85592417）' AS LOCKREASON
        FROM
            crgs.ex_xxzx_11_hgsxrzqymd ex
                LEFT JOIN e_baseinfo e ON ex.qyzwmc = e.ENTNAME
        WHERE
            e.ENTNAME is not null and
            e.REGSTATE IN ( '1', '003001', '003' )
          AND ex.qyzwmc NOT IN ( SELECT ENTNAME FROM entlock ) UNION ALL
        SELECT
            '5' AS punishFrom,
            e.PRIPID,
            e.UNISCID,
            e.ENTNAME,
            e.REGNO,
            '001' AS LOCKTYPE,
            e.regorg,
            e.Cerno,
            e.Certype,
            e.lerep as representative,
            '1、统计上严重失信企业汇总表（国家统计局）联合惩戒要求进行限制；2、根据《失信企业协同监管和联合惩戒合作备忘录》（发改财金〔2015〕2045号）。 （可办理：一、企业因地址原因列入经营异常名录办理的地址变更，二、企业办理清算小组备案，办理注销）' AS LOCKREASON
        FROM
            crgs.ex_xxzx_13_tjsyzsxqyh ex
                LEFT JOIN e_baseinfo e ON ex.xzxdrmc = e.ENTNAME
        WHERE
            e.ENTNAME is not null and
            e.REGSTATE IN ( '1', '003001', '003' )
          AND ex.xzxdrmc NOT IN ( SELECT ENTNAME FROM entlock ) UNION ALL
        SELECT
            '7' AS punishFrom,
            e.PRIPID,
            e.UNISCID,
            e.ENTNAME,
            e.REGNO,
            '001' AS LOCKTYPE,
            e.regorg,
            e.Cerno,
            e.Certype,
            e.lerep as representative,
            '1、2016年度出入境检验检疫严重失信企业名单（质检总局）联合惩戒要求进行限制；2、根据《失信企业协同监管和联合惩戒合作备忘录》（发改财金〔2015〕2045号）。 （可办理：一、企业因地址原因列入经营异常名录办理的地址变更，二、企业办理清算小组备案，办理注销）' AS LOCKREASON
        FROM
            crgs.ex_xxzx_14_2016ndcrjj ex
            LEFT JOIN e_baseinfo e ON ex.jyjysysxqymd = e.ENTNAME
        WHERE
            e.ENTNAME is not null and
            e.REGSTATE IN ( '1', '003001', '003' )
          AND ex.jyjysysxqymd NOT IN ( SELECT ENTNAME FROM entlock ) UNION ALL
        SELECT
            '8' AS punishFrom,
            e.PRIPID,
            e.UNISCID,
            e.ENTNAME,
            e.REGNO,
            '001' AS LOCKTYPE,
            e.regorg,
            e.Cerno,
            e.Certype,
            e.lerep as representative,
            '1、严重质量失信企业名单（质检总局）联合惩戒要求进行限制；2、根据《失信企业协同监管和联合惩戒合作备忘录》（发改财金〔2015〕2045号）。 （可办理：一、企业因地址原因列入经营异常名录办理的地址变更，二、企业办理清算小组备案，办理注销）' AS LOCKREASON
        FROM
            crgs.ex_xxzx_15_yzzlsxqymd ex
                LEFT JOIN e_baseinfo e ON ex.yzzlsxqymc = e.ENTNAME
        WHERE
            e.ENTNAME is not null and
            e.REGSTATE IN ( '1', '003001', '003' )
          AND ex.yzzlsxqymc NOT IN ( SELECT ENTNAME FROM entlock ) UNION ALL
        SELECT
            '11' AS punishFrom,
            e.PRIPID,
            e.UNISCID,
            e.ENTNAME,
            e.REGNO,
            '001' AS LOCKTYPE,
            e.regorg,
            e.Cerno,
            e.Certype,
            e.lerep as representative,
            '1、电子商务失信问题专项治理黑名单汇总表（发改委）联合惩戒要求进行限制；2、根据《失信企业协同监管和联合惩戒合作备忘录》（发改财金〔2015〕2045号）。 （可办理：一、企业因地址原因列入经营异常名录办理的地址变更，二、企业办理清算小组备案，办理注销）' AS LOCKREASON
        FROM
            crgs.ex_xxzx_19_dzswsxwtzx ex
                LEFT JOIN e_baseinfo e ON ex.qymc = e.ENTNAME
        WHERE
            e.ENTNAME is not null and
            e.REGSTATE IN ( '1', '003001', '003' )
          AND ex.qymc NOT IN ( SELECT ENTNAME FROM entlock ) UNION ALL
        SELECT
            '12' AS punishFrom,
            e.PRIPID,
            e.UNISCID,
            e.ENTNAME,
            e.REGNO,
            '001' AS LOCKTYPE,
            e.regorg,
            e.Cerno,
            e.Certype,
            e.lerep as representative,
            '1、涉金融黑名单（发改委）联合惩戒要求进行限制；2、根据《失信企业协同监管和联合惩戒合作备忘录》（发改财金〔2015〕2045号）。 （可办理：一、企业因地址原因列入经营异常名录办理的地址变更，二、企业办理清算小组备案，办理注销）。' AS LOCKREASON
        FROM
            crgs.ex_xxzx_20_sjrhmd ex
                LEFT JOIN e_baseinfo e ON ex.sxzt = e.ENTNAME
        WHERE
            e.ENTNAME is not null and
            e.REGSTATE IN ( '1', '003001', '003' )
          AND ex.sxzt NOT IN ( SELECT ENTNAME FROM entlock ) UNION ALL
        SELECT
            '13' AS punishFrom,
            e.PRIPID,
            e.UNISCID,
            e.ENTNAME,
            e.REGNO,
            '001' AS LOCKTYPE,
            e.regorg,
            e.Cerno,
            e.Certype,
            e.lerep as representative,
            '1、2018年第一批拖欠农民工工资“黑名单”信息表联合惩戒要求进行限制；2、根据《失信企业协同监管和联合惩戒合作备忘录》（发改财金〔2015〕2045号）。 （可办理：一、企业因地址原因列入经营异常名录办理的地址变更，二、企业办理清算小组备案，办理注销）。' AS LOCKREASON
        FROM
            crgs.ex_xxzx_21_2018tqnmggz ex
                LEFT JOIN e_baseinfo e ON ex.dxmc = e.ENTNAME
        WHERE
            e.ENTNAME is not null and
            e.REGSTATE IN ( '1', '003001', '003' )
          AND ex.dxmc NOT IN ( SELECT ENTNAME FROM entlock )
    </select>

    <select id="unlocked" resultMap="BaseResultMap">
        SELECT
            '1' AS punishFrom,
            e.PRIPID,
            e.UNISCID,
            e.ENTNAME,
            e.REGNO,
            '001' AS LOCKTYPE,
            '根据国家38部委关于《失信企业协同监管和联合惩戒合作备忘录》（发改财金[2015]2045号）的要求，我局从公共信用信息平台获取到安监部门联合惩戒相关数据，你公司被安监部门列为安全生产黑名单，要求进行联合惩戒，我局在注册登记系统进行警示限制。（如企业已完成安监部门的整改要求或未有违反《生产经营单位安全生产不良记录“黑名单”管理暂行规定》提出异议的可申请解除联合惩戒警示）（如有疑问咨询85592417）' AS LOCKREASON
        FROM
            crgs.ex_xxzx_09_aqschmd_aj ex
            LEFT JOIN e_baseinfo e ON ex.dwmc = e.ENTNAME
        WHERE
            e.REGSTATE IN ( '1', '003001', '003' )
          AND ex.dwmc IN ( SELECT
                               ENTNAME
                           FROM
                               (
                                   SELECT
                                       *
                                   FROM
                                       ( SELECT DISTINCT ( ENTNAME ) ename, entlock.* FROM entlock ORDER BY laupTime DESC ) e
                                   GROUP BY
                                       e.ENTNAME
                                   HAVING
                                        e.state = '3'  and e.LOCKUSERNAME='信用风险监管处'
                               ) rs ) UNION ALL
        SELECT
            '3' AS punishFrom,
            e.PRIPID,
            e.UNISCID,
            e.ENTNAME,
            e.REGNO,
            '001' AS LOCKTYPE,
            '根据国家38部委关于《失信企业协同监管和联合惩戒合作备忘录》（发改财金[2015]2045号）的要求，我局从公共信用信息平台获取到海关部门联合惩戒相关数据，你公司被海关部门列为海关失信认证企业名单，要求进行联合惩戒，我局在注册登记系统进行警示限制。（如企业没有违反《中华人民共和国海关企业信用管理暂行办法》，可以申请解除联合惩戒警示）（如有疑问咨询85592417）' AS LOCKREASON
        FROM
            crgs.ex_xxzx_11_hgsxrzqymd ex
                LEFT JOIN e_baseinfo e ON ex.qyzwmc = e.ENTNAME
        WHERE
            e.REGSTATE IN ( '1', '003001', '003' )
          AND ex.qyzwmc IN ( SELECT
                                 ENTNAME
                             FROM
                                 (
                                     SELECT
                                         *
                                     FROM
                                         ( SELECT DISTINCT ( ENTNAME ) ename, entlock.* FROM entlock ORDER BY laupTime DESC ) e
                                     GROUP BY
                                         e.ENTNAME
                                     HAVING
                                         e.state = '3' and e.LOCKUSERNAME='信用风险监管处'
                                 ) rs ) UNION ALL
        SELECT
            '5' AS punishFrom,
            e.PRIPID,
            e.UNISCID,
            e.ENTNAME,
            e.REGNO,
            '001' AS LOCKTYPE,
            '1、统计上严重失信企业汇总表（国家统计局）联合惩戒要求进行限制；2、根据《失信企业协同监管和联合惩戒合作备忘录》（发改财金〔2015〕2045号）。 （可办理：一、企业因地址原因列入经营异常名录办理的地址变更，二、企业办理清算小组备案，办理注销）' AS LOCKREASON
        FROM
            crgs.ex_xxzx_13_tjsyzsxqyh ex
                LEFT JOIN e_baseinfo e ON ex.xzxdrmc = e.ENTNAME
        WHERE
            e.REGSTATE IN ( '1', '003001', '003' )
          AND ex.xzxdrmc IN ( SELECT
                                  ENTNAME
                              FROM
                                  (
                                      SELECT
                                          *
                                      FROM
                                          ( SELECT DISTINCT ( ENTNAME ) ename, entlock.* FROM entlock ORDER BY laupTime DESC ) e
                                      GROUP BY
                                          e.ENTNAME
                                      HAVING
                                          e.state = '3'  and e.LOCKUSERNAME='信用风险监管处'
                                  ) rs ) UNION ALL
        SELECT
            '7' AS punishFrom,
            e.PRIPID,
            e.UNISCID,
            e.ENTNAME,
            e.REGNO,
            '001' AS LOCKTYPE,
            '1、2016年度出入境检验检疫严重失信企业名单（质检总局）联合惩戒要求进行限制；2、根据《失信企业协同监管和联合惩戒合作备忘录》（发改财金〔2015〕2045号）。 （可办理：一、企业因地址原因列入经营异常名录办理的地址变更，二、企业办理清算小组备案，办理注销）' AS LOCKREASON
        FROM
            crgs.ex_xxzx_14_2016ndcrjj ex
                LEFT JOIN e_baseinfo e ON ex.jyjysysxqymd = e.ENTNAME
        WHERE
            e.REGSTATE IN ( '1', '003001', '003' )
          AND ex.jyjysysxqymd IN ( SELECT
                                       ENTNAME
                                   FROM
                                       (
                                           SELECT
                                               *
                                           FROM
                                               ( SELECT DISTINCT ( ENTNAME ) ename, entlock.* FROM entlock ORDER BY laupTime DESC ) e
                                           GROUP BY
                                               e.ENTNAME
                                           HAVING
                                               e.state = '3'  and e.LOCKUSERNAME='信用风险监管处'
                                       ) rs ) UNION ALL
        SELECT
            '8' AS punishFrom,
            e.PRIPID,
            e.UNISCID,
            e.ENTNAME,
            e.REGNO,
            '001' AS LOCKTYPE,
            '1、严重质量失信企业名单（质检总局）联合惩戒要求进行限制；2、根据《失信企业协同监管和联合惩戒合作备忘录》（发改财金〔2015〕2045号）。 （可办理：一、企业因地址原因列入经营异常名录办理的地址变更，二、企业办理清算小组备案，办理注销）' AS LOCKREASON
        FROM
            crgs.ex_xxzx_15_yzzlsxqymd ex
                LEFT JOIN e_baseinfo e ON ex.yzzlsxqymc = e.ENTNAME
        WHERE
            e.REGSTATE IN ( '1', '003001', '003' )
          AND ex.yzzlsxqymc IN ( SELECT
                                     ENTNAME
                                 FROM
                                     (
                                         SELECT
                                             *
                                         FROM
                                             ( SELECT DISTINCT ( ENTNAME ) ename, entlock.* FROM entlock ORDER BY laupTime DESC ) e
                                         GROUP BY
                                             e.ENTNAME
                                         HAVING
                                             e.state = '3'  and e.LOCKUSERNAME='信用风险监管处'
                                     ) rs ) UNION ALL
        SELECT
            '11' AS punishFrom,
            e.PRIPID,
            e.UNISCID,
            e.ENTNAME,
            e.REGNO,
            '001' AS LOCKTYPE,
            '1、电子商务失信问题专项治理黑名单汇总表（发改委）联合惩戒要求进行限制；2、根据《失信企业协同监管和联合惩戒合作备忘录》（发改财金〔2015〕2045号）。 （可办理：一、企业因地址原因列入经营异常名录办理的地址变更，二、企业办理清算小组备案，办理注销）' AS LOCKREASON
        FROM
            crgs.ex_xxzx_19_dzswsxwtzx ex
                LEFT JOIN e_baseinfo e ON ex.qymc = e.ENTNAME
        WHERE
            e.REGSTATE IN ( '1', '003001', '003' )
          AND ex.qymc IN ( SELECT
                               ENTNAME
                           FROM
                               (
                                   SELECT
                                       *
                                   FROM
                                       ( SELECT DISTINCT ( ENTNAME ) ename, entlock.* FROM entlock ORDER BY laupTime DESC ) e
                                   GROUP BY
                                       e.ENTNAME
                                   HAVING
                                       e.state = '3' and e.LOCKUSERNAME='信用风险监管处'
                               ) rs ) UNION ALL
        SELECT
            '12' AS punishFrom,
            e.PRIPID,
            e.UNISCID,
            e.ENTNAME,
            e.REGNO,
            '001' AS LOCKTYPE,
            '1、涉金融黑名单（发改委）联合惩戒要求进行限制；2、根据《失信企业协同监管和联合惩戒合作备忘录》（发改财金〔2015〕2045号）。 （可办理：一、企业因地址原因列入经营异常名录办理的地址变更，二、企业办理清算小组备案，办理注销）。' AS LOCKREASON
        FROM
            crgs.ex_xxzx_20_sjrhmd ex
                LEFT JOIN e_baseinfo e ON ex.sxzt = e.ENTNAME
        WHERE
            e.REGSTATE IN ( '1', '003001', '003' )
          AND ex.sxzt IN ( SELECT
                               ENTNAME
                           FROM
                               (
                                   SELECT
                                       *
                                   FROM
                                       ( SELECT DISTINCT ( ENTNAME ) ename, entlock.* FROM entlock ORDER BY laupTime DESC ) e
                                   GROUP BY
                                       e.ENTNAME
                                   HAVING
                                       e.state = '3' and e.LOCKUSERNAME='信用风险监管处'
                               ) rs ) union all
        SELECT
            '13' AS punishFrom,
            e.PRIPID,
            e.UNISCID,
            e.ENTNAME,
            e.REGNO,
            '001' AS LOCKTYPE,
            '1、2018年第一批拖欠农民工工资“黑名单”信息表联合惩戒要求进行限制；2、根据《失信企业协同监管和联合惩戒合作备忘录》（发改财金〔2015〕2045号）。 （可办理：一、企业因地址原因列入经营异常名录办理的地址变更，二、企业办理清算小组备案，办理注销）。' AS LOCKREASON
        FROM
            crgs.ex_xxzx_21_2018tqnmggz ex
            LEFT JOIN e_baseinfo e ON ex.dxmc = e.ENTNAME
        WHERE
            e.REGSTATE IN ( '1', '003001', '003' )
          AND ex.dxmc IN ( SELECT
                               ENTNAME
                           FROM
                               (
                                   SELECT
                                       *
                                   FROM
                                       ( SELECT DISTINCT ( ENTNAME ) ename, entlock.* FROM entlock ORDER BY laupTime DESC ) e
                                   GROUP BY
                                       e.ENTNAME
                                   HAVING
                                       e.state = '3' and e.LOCKUSERNAME='信用风险监管处'
                               ) rs )
    </select>

    <select id="selectEntLockList" resultMap="BaseResultMap">
        select * from entlock where state = '0'
    </select>

    <select id="queryByPripid" resultMap="BaseResultMap">
        select * from entlock e where PRIPID = #{pripid} order by INPUTDATE desc
    </select>

    <select id="queryForExcel" resultMap="EntLockExcel">
        select uniscid, regno, entname, locktype,
        lockreason,DATE_FORMAT(locktime, '%Y-%m-%d %H:%i:%s') as locktime,
        DATE_FORMAT(unlocktime, '%Y-%m-%d %H:%i:%s') as unlocktime,
        ulockspecificreason from entlock e where 1=1
        <if test="customParamMap.uniscid != null and customParamMap.uniscid neq ''">
            and uniscid = #{customParamMap.uniscid}
        </if>
        <if test="customParamMap.regno != null and customParamMap.regno neq ''">
            and regno = #{customParamMap.regno}
        </if>
        <if test="customParamMap.searchEntName != null and customParamMap.searchEntName neq ''">
            and entname = #{customParamMap.searchEntName}
        </if>
        <if test="customParamMap.measure != null and customParamMap.measure neq ''">
            and measure = #{customParamMap.measure}
        </if>
        <if test="customParamMap.representative != null and customParamMap.representative neq ''">
            and representative = #{customParamMap.representative}
        </if>
        <if test="customParamMap.uLSRCode != null and customParamMap.uLSRCode neq ''">
            and ulsrcode = #{customParamMap.uLSRCode}
        </if>
        <if test="customParamMap.beginLockDate != null and customParamMap.beginLockDate neq '' and customParamMap.endLockDate != null and customParamMap.endLockDate neq ''">
            and locktime &gt;= #{customParamMap.beginLockDate}
            and locktime &lt;= #{customParamMap.endLockDate}
        </if>
        <if test="customParamMap.beginUnlockDate != null and customParamMap.beginUnlockDate neq '' and customParamMap.endUnlockDate != null and customParamMap.endUnlockDate neq ''">
            and locktime &gt;= #{customParamMap.beginUnlockDate}
            and locktime &lt;= #{customParamMap.endUnlockDate}
        </if>
        <if test="customParamMap.regorg1 != null and customParamMap.regorg1 neq ''">
            and regorg like concat(#{customParamMap.regorg1} ,'%')
        </if>
        <if test="customParamMap.regorg2 != null and customParamMap.regorg2 neq ''">
            and regorg = #{customParamMap.regorg2}
        </if>
    </select>

    <select id="queryByState" parameterType="String" resultMap="BaseResultMap">
        select * from entlock e where PRIPID = #{pripid} and punishFrom = #{punishFrom} and state != '3'
    </select>

    <select id="selectLockEntity" parameterType="String" resultMap="BaseResultMap">
        select * from entlock e where entname= #{entName} order by laupTime desc
    </select>

    <select id="selectlocktime" resultType="map">
        select entname,count(*) as count from entlock where department = #{department} group by entname
    </select>


    <select id="check" resultMap="BaseResultMap">
        select * from entlock where pripid=#{pripid} order by laupTime desc limit 1
    </select>

    <select id="checkUnlock" resultMap="BaseResultMap">
        select * from entlock where pripid=#{pripid} order by laupTime desc limit 1
    </select>

    <select id="lockList" resultMap="BaseResultMap">
        SELECT
        e.ELID,
        e.PRIPID,
        e.UNISCID,
        e.ENTNAME,
        e.REGNO,
        e.LOCKREASON,
        e.LOCKUSERNAME,
        e.LOCKUSERID,
        e.LOCKUSERDEPTID,
        e.LOCKUSERUNITID,
        e.LOCKSTARTDATE,
        e.UNLUSERNAME,
        e.LOCKENDDATE,
        e.UNLUSERID,
        e.ULDEPTID,
        e.ULUNITID,
        e.UNLDATE,
        e.LOCKTIME,
        e.LOCKTYPE,
        e.LOCKSTATE,
        e.INPUTDATE,
        e.laupTime,
        e.FILEPATH,
        e.FILENAME,
        e.ULOCKREASON,
        e.punishFrom,
        e.state,
        e.MEASURE,
        e.UNLOCKTIME,
        e.ulockspecificreason,
        e.ulsrcode,
        e.representative,
        e.regorg,
        e.cerno,
        e.certype,
        e.isdelete,
        e.department,
        e.tflockid,
        e.warningcontent
        FROM
        (
        SELECT DISTINCT
        ENTNAME AS ename,
        entlock.*
        FROM
        entlock
        GROUP BY
        ENTNAME
        ORDER BY
        LAUPTIME desc
        ) AS e
        GROUP BY
        ENTNAME
        HAVING
        e.STATE = '0' and  e.LOCKUSERNAME='信用风险监管处'
    </select>


</mapper>
