<?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.nantian.cloud.dbcapp.mapper.jly.EnterpriseHaltMapper">

    <select id="getHaltCompany" resultType="com.nantian.cloud.dbcapp.vo.EnterpriseHaltVo">
        select id, epc, start_time startTime, end_time endTime, regain_time regainTime, update_time updateTime, dept_id deptId, state,
        tmp_time tmpTime, case when left(#{statDate},7) between left(start_time,7) and left(tmp_time,7) then concat_ws('至',concat('停产时间为：',start_time),regain_time) else '' end remark
        from (
            select id, epc, start_time, end_time, regain_time, update_time, state,
            dept_id, IFNULL(regain_time, now()) tmp_time
            from `enterprise_halt`  where state in ('3','4','5') and del_flag = '1'
            <if test="epcStr != null and epcStr !=  ''">
                and #{epcStr} like concat("%",epc,"%")
            </if>
        )tmp where (left(#{statDate},7) between left(start_time,7) and left(tmp_time,7))
    </select>
    <select id="getHaltCompanyCode" resultType="java.lang.String">
        select epc
        from (
            select id, epc, start_time, end_time, regain_time, update_time, state,
            dept_id, IFNULL(regain_time, now()) tmp_time
            from `enterprise_halt`  where state in ('3','4','5') and del_flag = '1'
            <if test="epcStr != null and epcStr !=  ''">
                and #{epcStr} like concat("%",epc,"%")
            </if>
        )tmp where (left(#{statDate},7) between left(start_time,7) and left(tmp_time,7))
    </select>
    <select id="getHaltCompanyByCode" resultType="com.nantian.cloud.dbcapp.vo.EnterpriseHaltVo">
        select epc, start_time startTime from `enterprise_halt` where state = '3' and del_flag = '1' and epc = #{enterpriseCode}
    </select>
</mapper>
