sql="SELECT \"battery\" FROM \"tdl_policy\".\""+gatewayVo.getgType()+"_"+gatewayVo.getgSN()+"\" where time >="+circuitVo.getStartTime()+" and time<="+circuitVo.getEndTime()*1000000l+" ORDER BY time desc limit 1";
}else{
sql="SELECT \"battery\" FROM \"tdl_policy\".\""+gatewayVo.getgType()+"_"+gatewayVo.getgSN()+"\" where time >="+circuitVo.getStartTime()+" ORDER BY time desc limit 1";
sql1="SELECT \"b\" FROM \"tdl_policy\".\""+gatewayVo.getgType()+"_"+gatewayVo.getgSN()+"\" where \"tdl\"='"+TDL.get(i)+"' and time >="+circuitVo.getStartTime()+" and time<="+circuitVo.getEndTime()*1000000l+" ORDER BY time desc limit 1";
}else{
sql1="SELECT \"b\" FROM \"tdl_policy\".\""+gatewayVo.getgType()+"_"+gatewayVo.getgSN()+"\" where \"tdl\"='"+TDL.get(i)+"' and time >="+circuitVo.getStartTime()+" ORDER BY time desc limit 1";
sql="SELECT \"b\" FROM \"tdl_policy\".\""+gatewayVo.getgType()+"_"+gatewayVo.getgSN()+"\" where \"tdl\"='"+TDL.get(i)+"' and time >="+circuitVo.getStartTime()+" and time<="+circuitVo.getEndTime()*1000000l+" ORDER BY time desc limit 1";
}else{
sql="SELECT \"b\" FROM \"tdl_policy\".\""+gatewayVo.getgType()+"_"+gatewayVo.getgSN()+"\" where \"tdl\"='"+TDL.get(i)+"' and time >="+circuitVo.getStartTime()+" ORDER BY time desc limit 1";
SELECT ifnull(classify,"5") classify,count(description) count FROM alarm_log WHERE classify = "5"
and transportationNo in (select transportationNo from circuit where company_id =(select id from company where companyName =#{companyName,jdbcType=VARCHAR}))
AND DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) <= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s'))
UNION ALL
SELECT ifnull(classify,"6") classify,count(description) count FROM alarm_log WHERE classify = "6"
and transportationNo in (select transportationNo from circuit where company_id =(select id from company where companyName =#{companyName,jdbcType=VARCHAR}))
AND DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) <= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s'))
SELECT c.transportationNo,cargoNo,cargoName,(SELECT city from city WHERE id =(SELECT city_id from circuit_transfer WHERE circuit_id=c.id ORDER BY sequence LIMIT 1)) startCity,startTime,
(SELECT city from city WHERE id =(SELECT city_id from circuit_transfer WHERE circuit_id=c.id ORDER BY sequence DESC LIMIT 1)) endCity,endTime,circuitState,
(SELECT alarmType FROM alarm WHERE id IN (SELECT alarm_id from tdl_gateway_log WHERE transportationNo=c.transportationNo)) alarmType,
(select GROUP_CONCAT( DISTINCT classify) from alarm_log al where al.transportationNo = c.transportationNo) alarm,evaluate,transportation
from circuit c where c.state=1
(select GROUP_CONCAT( DISTINCT classify) from alarm_log al where al.transportationNo = c.transportationNo) alarm,evaluate,transportation,plateNo,
(select DISTINCT gatewaySN from tdl_gateway_log WHERE transportationNo=c.transportationNo) gSN,(select DISTINCT gatewayType from tdl_gateway_log WHERE transportationNo=c.transportationNo) gType
from circuit c
where c.state=1
AND company_id=(SELECT id from company where companyName=#{companyName,jdbcType=VARCHAR})