<?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 2024 . All rights reserved. -->
<!--  Mybatis数据库持久层（业务层映射文件）：任务执行记录表 -->
<!--  version: 1.0  -->
<!--  author:  maven-cctp-plugin    -->
<!--  date:  2024-10-16 17:02:48  -->
<mapper namespace="net.northking.cctp.executePlan.db.dao.AtuPlanTaskRecordDao">


  <!-- 请在本文件内添加自定义SQL语句 -->

  <select id="queryTotalTake" parameterType="java.util.List" resultType="net.northking.cctp.executePlan.dto.planTask.PlanTaskRecordDto">
    SELECT task_id AS taskId, sum(take) AS totalTake FROM
    (
    SELECT id, task_id, (end_time - start_time) AS take
    FROM <include refid="Table_Name" />
    WHERE
    task_id IN
    <foreach collection="taskIds" item="id" open="(" separator="," close=")">
      #{id, jdbcType=VARCHAR}
    </foreach>
    AND end_time IS NOT NULL
    ) AS temp
    GROUP BY task_id
  </select>
</mapper>