<?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">
<!--  Copyright (c) 京北方信息技术股份有限公司 Corporation 2022 . All rights reserved. -->
<!--  Mybatis数据库持久层（业务层映射文件）：计划批次设备关联表 -->
<!--  version: 1.0  -->
<!--  author:  maven-cctp-plugin    -->
<!--  date:  2022-12-12 16:22:12  -->
<mapper namespace="net.northking.cctp.executePlan.db.dao.AtuPlanBatchDeviceLinkDao">

  <select id="queryByOfflineDeviceId" resultMap="BaseResultMap">
    select l.id, l.batch_id, l.device_id, l.is_offline, l.offline_time
    from <include refid="Table_Name"/> l left join atu_plan_batch b on b.id = l.batch_id
    where l.device_id = #{deviceId} and b.status in ("0","1")
  </select>

  <select id="countOnlineDeviceByBatchId" resultType="java.lang.Integer">
    SELECT 1 FROM atu_plan_batch_device_link WHERE batch_id = #{batchId} AND
    is_offline = 0 LIMIT 1
  </select>

</mapper>