liulin
5 天以前 2b5c36b4830adf4227f248d4e10bdb90b1e5f3d8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package com.fengdu.gas.repository.mapper;
 
import com.fengdu.gas.repository.BasicMapper;import com.fengdu.gas.repository.po.FacilityRunTimePO;
import org.apache.ibatis.annotations.Select;
 
import java.util.List;
 
/**
 * 设备运行时长 mapper
 * @author zr
 */
public interface FacilityRunTimeMapper extends BasicMapper<FacilityRunTimePO> {
    @Select("SELECT r.*\n" +
            " FROM facility_run_time r\n" +
            " INNER JOIN (\n" +
            "    SELECT facility_id, MAX(create_time) AS max_timestamp\n" +
            "    FROM facility_run_time WHERE open_time IS NOT NULL AND open_time<>'' AND close_time IS NOT NULL AND close_time <>''\n" +
            "    GROUP BY facility_id\n" +
            " ) AS latest ON r.facility_id = latest.facility_id AND r.create_time = latest.max_timestamp;")
    List<FacilityRunTimePO> getDataTime();
 
    @Select("select * from facility_run_time where is_delete=0 and open_time IS NOT NULL AND open_time<>'' AND close_time IS NOT NULL AND close_time <>'' ")
    List<FacilityRunTimePO>selectByDataTime();
}