sql="SELECT \"bdlng\",\"bdlat\" FROM \"tdl_policy\".\""+device+"\" where time >= "+alarmMessageVo.getAlarmTime()*1000000l+" ORDER BY time limit 1;SELECT \"bdlng\",\"bdlat\" FROM \"tdl_policy\".\""+device+"\" where time <= "+alarmMessageVo.getAlarmTime()*1000000l+" ORDER BY time desc limit 1";
}else{
sql="SELECT \"lng\",\"lat\" FROM \"tdl_policy\".\""+device+"\" where time >= "+alarmMessageVo.getAlarmTime()*1000000l+" ORDER BY time limit 1;SELECT \"lng\",\"lat\" FROM \"tdl_policy\".\""+device+"\" where time <= "+alarmMessageVo.getAlarmTime()*1000000l+" ORDER BY time desc limit 1;";
sqls="SELECT count("+list.get(j)+") FROM \"tdl_policy\".\""+device+"\" WHERE \"tdl\"='"+devList.get(i)+"' and time>="+startTime+" and time <="+resultCircuitVo.getEndTime()*1000000l;
}else{
sqls="SELECT count("+list.get(j)+") FROM \"tdl_policy\".\""+device+"\" WHERE \"tdl\"='"+devList.get(i)+"' and time>="+startTime+" and time <="+System.currentTimeMillis()*1000000l;
sql="SELECT "+list.get(j)+" FROM \"tdl_policy\".\""+device+"\" where \"tdl\"='"+devList.get(i)+"' and time >="+startTime+" and time<="+resultCircuitVo.getEndTime()*1000000l+" ORDER BY time ";
// sql = "SELECT "+list.get(j)+" FROM \"tdl_policy\".\""+device+"\" where \"tdl\"='"+devList.get(i)+"' and time >="+startTime + " and time<="+resultCircuitVo.getEndTime() *1000000l+" ORDER BY time ";
}else{
sql="SELECT "+list.get(j)+" FROM \"tdl_policy\".\""+device+"\" where \"tdl\"='"+devList.get(i)+"' and time >="+startTime+" ORDER BY time ";
sql="SELECT "+list.get(j)+" FROM \"tdl_policy\".\""+device+"\" where \"tdl\"='"+devList.get(i)+"' and time >="+startTime+" and time<="+resultCircuitVo.getEndTime()*1000000l+" ORDER BY time ";
}else{
sql="SELECT "+list.get(j)+" FROM \"tdl_policy\".\""+device+"\" where \"tdl\"='"+devList.get(i)+"' and time >="+startTime+" ORDER BY time";
sql=sql+String.format("Select %s From \"tdl_policy\".\"%s\" where \"tdl\"='%s' and time >= %d and time <= %d order by time limit 1;",field,device,tdl,startTime,maxTime);
// sql = "SELECT "+list.get(j)+" FROM \"tdl_policy\".\""+device+"\" where \"tdl\"='"+devList.get(i)+"' and time >="+startTime + " and time<="+resultCircuitVo.getEndTime() *1000000l+" ORDER BY time ";
// }else{
// sql = "SELECT "+list.get(j)+" FROM \"tdl_policy\".\""+device+"\" where \"tdl\"='"+devList.get(i)+"' and time >="+startTime + " ORDER BY time ";
Stringtdl=list.get(j).getTdl().replace(",","\' or \"tdl\" = \'");
// sql = "SELECT \"T\",\"h\" FROM \"tdl_policy\".\"WTD93LG_17110194\" where \"tdl\" = \'TDL-1706190193608\' or \"tdl\" = \'TDL-1701110082608\' GROUP BY \"tdl\" order by time desc limit 1";
sql="SELECT \"T\",\"h\" FROM \"tdl_policy\".\""+list.get(i).getDevice()+"\" where \"tdl\" = \'"+t+"\' GROUP BY \"tdl\" order by time desc limit 1";
sql="SELECT \"T\",\"h\" FROM \"tdl_policy\".\""+list.get(j).getDevice()+"\" where \"tdl\" = \'"+tdl+"\' GROUP BY \"tdl\" order by time desc limit 1";
}
if(StringUtils.isEmpty(sql)){
simpleWarehouseVos.get(i).setTemp("~");
...
...
@@ -396,12 +388,9 @@ public class WarehouseController {
select transportationNo,TDLSN,description,ifnull(data,"") data,alarmTime,classify from alarm_log
where transportationNo in (select transportationNo from circuit where company_id =(select id from company where companyName =#{companyName,jdbcType=VARCHAR}))
where transportationNo in (select transportationNo from circuit where company_id =(select id from company where companyNo =#{companyNo,jdbcType=VARCHAR}))
where transportationNo in (select transportationNo from circuit where company_id =(select id from company where companyName =#{companyName,jdbcType=VARCHAR}))
where transportationNo in (select transportationNo from circuit where company_id =(select id from company where companyNo =#{companyNo,jdbcType=VARCHAR}))
and DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) <= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s'))
select count(DISTINCT transportationNo) from alarm_log
where transportationNo in (select transportationNo from circuit where company_id =(select id from company where companyName =#{companyName,jdbcType=VARCHAR}))
where transportationNo in (select transportationNo from circuit where company_id =(select id from company where companyNo =#{companyNo,jdbcType=VARCHAR}))
and DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) <= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s'))
select count(DISTINCT transportationNo) from alarm_log
where classify = "3"
and transportationNo in (select transportationNo from circuit where company_id =(select id from company where companyName =#{companyName,jdbcType=VARCHAR}))
and transportationNo in (select transportationNo from circuit where company_id =(select id from company where companyNo =#{companyNo,jdbcType=VARCHAR}))
and DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) <= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s'))
SELECT ifnull(classify,"1") classify,count(description) count FROM alarm_log WHERE classify = "1"
and transportationNo in (select transportationNo from circuit where company_id =(select id from company where companyName =#{companyName,jdbcType=VARCHAR}))
and transportationNo in (select transportationNo from circuit where company_id =(select id from company where companyNo =#{companyNo,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,"2") classify,count(description) count FROM alarm_log WHERE classify = "2"
and transportationNo in (select transportationNo from circuit where company_id =(select id from company where companyName =#{companyName,jdbcType=VARCHAR}))
and transportationNo in (select transportationNo from circuit where company_id =(select id from company where companyNo =#{companyNo,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,"3") classify,count(description) count FROM alarm_log WHERE classify = "3"
and transportationNo in (select transportationNo from circuit where company_id =(select id from company where companyName =#{companyName,jdbcType=VARCHAR}))
and transportationNo in (select transportationNo from circuit where company_id =(select id from company where companyNo =#{companyNo,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,"4") classify,count(description) count FROM alarm_log WHERE classify = "4"
and transportationNo in (select transportationNo from circuit where company_id =(select id from company where companyName =#{companyName,jdbcType=VARCHAR}))
and transportationNo in (select transportationNo from circuit where company_id =(select id from company where companyNo =#{companyNo,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,"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 transportationNo in (select transportationNo from circuit where company_id =(select id from company where companyNo =#{companyNo,jdbcType=VARCHAR}))
AND DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) <= date(FROM_UNIXTIME(alarmTime/1000,'%Y-%m-%d %H:%i:%s'))
where transportationNo in (select transportationNo from circuit where company_id =(select id from company where companyName =#{companyName,jdbcType=VARCHAR}))
where transportationNo in (select transportationNo from circuit where company_id =(select id from company where companyNo =#{companyNo,jdbcType=VARCHAR}))
and DATE_SUB(CURDATE(), INTERVAL 1 HOUR ) <= 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 GROUP_CONCAT(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,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
(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})
AND company_id=(SELECT id from company where companyNo=#{companyNo,jdbcType=VARCHAR})
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
(SELECT GROUP_CONCAT(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,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})
AND company_id=(SELECT id from company where companyNo=#{companyNo,jdbcType=VARCHAR})
<iftest="time !=null">
AND DATE_SUB(CURDATE(), INTERVAL #{time,jdbcType=VARCHAR} DAY) <= date(FROM_UNIXTIME(createTime/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(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,ifnull(evaluate,"") evaluate,transportation,
(select DISTINCT gatewaySN FROM tdl_gateway_log WHERE transportationNo= #{transportationNo,jdbcType=VARCHAR} ) SN,(SELECT GROUP_CONCAT(TDLSN) FROM tdl_gateway_log WHERE transportationNo= #{transportationNo,jdbcType=VARCHAR}) TDLSN
from circuit c
where c.state=1
AND c.transportationNo=#{transportationNo,jdbcType=VARCHAR}
AND company_id=(SELECT id from company where companyName=#{companyName,jdbcType=VARCHAR})
AND company_id=(SELECT id from company where companyNo=#{companyNo,jdbcType=VARCHAR})
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(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,ifnull(evaluate,"") evaluate,transportation,
(select DISTINCT gatewaySN FROM tdl_gateway_log WHERE transportationNo= #{transportationNo,jdbcType=VARCHAR} ) SN,(SELECT GROUP_CONCAT(TDLSN) FROM tdl_gateway_log WHERE transportationNo= #{transportationNo,jdbcType=VARCHAR}) TDLSN
from circuit c
...
...
@@ -249,14 +253,14 @@
from circuit c,(SELECT GROUP_CONCAT(sequence) sequence from circuit_transfer where circuit_id=(SELECT id from circuit where transportationNo=#{transportationNo,jdbcType=VARCHAR})) s
where c.state=1
AND c.transportationNo=#{transportationNo,jdbcType=VARCHAR}
AND company_id=(SELECT id from company where companyName=#{companyName,jdbcType=VARCHAR})
AND company_id=(SELECT id from company where companyNo=#{companyNo,jdbcType=VARCHAR})
SELECT c.transportationNo,cargoNo,cargoName,expTime,compTime,(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(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 AND plateNo=#{plateNo,jdbcType=VARCHAR}
AND company_id=(SELECT id from company where companyName=#{companyName,jdbcType=VARCHAR})
AND company_id=(SELECT id from company where companyNo=#{companyNo,jdbcType=VARCHAR})
SELECT c.transportationNo,cargoNo,cargoName,expTime,compTime,(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(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 AND circuitState=#{circuitState,jdbcType=INTEGER}
AND company_id=(SELECT id from company where companyName=#{companyName,jdbcType=VARCHAR})
AND company_id=(SELECT id from company where companyNo=#{companyNo,jdbcType=VARCHAR})
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(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
and c.circuitState = 1
AND company_id=(SELECT id from company where companyName=#{companyName,jdbcType=VARCHAR})
AND company_id=(SELECT id from company where companyNo=#{companyNo,jdbcType=VARCHAR})
and company_id = (SELECT id from company where companyName=#{companyName,jdbcType=VARCHAR})
and company_id = (SELECT id from company where companyNo=#{companyNo,jdbcType=VARCHAR})
and circuitState = 1
</select>
...
...
@@ -345,7 +349,7 @@
select c.transportationNo,CONCAT_WS("-",(SELECT city from city WHERE id =(SELECT city_id from circuit_transfer WHERE circuit_id=c.id AND sequence =LEFT(s.sequence,1))),
(SELECT city from city WHERE id =(SELECT city_id from circuit_transfer WHERE circuit_id=c.id AND sequence=RIGHT(s.sequence,1)))) routeName,
(SELECT alarmType FROM alarm WHERE id IN (SELECT alarm_id from tdl_gateway_log WHERE transportationNo=c.transportationNo)) alarmType
(SELECT GROUP_CONCAT(alarmType) FROM alarm WHERE id IN (SELECT alarm_id from tdl_gateway_log WHERE transportationNo=c.transportationNo)) alarmType
from circuit c,(SELECT GROUP_CONCAT(sequence) sequence from circuit_transfer where circuit_id=(SELECT id from circuit where transportationNo=#{transportationNo,jdbcType=VARCHAR})) s
where c.state = 1
and c.transportationNo=#{transportationNo,jdbcType=VARCHAR}
SELECT warehouseNo,w.img,warehouseName,ct.country,ct.city,CONCAT_WS("-",ct.country,ct.city) regions ,w.addressDetail,r.regionName,lng,lat,a.alarmType,property,
select warehouseNo, warehouseName,CONCAT_WS("-",ct.country,ct.city) regions,ct.country,ct.city, (select count(id) from tdldevice t where t.warehouse_id = w.id ) count,property,type,hardwareLevel,areaPlanIndoor
from warehouse w ,company c ,city ct
where c.id=w.company_id
and ct.id = w.city_id
and c.companyName = #{companyName,jdbcType=VARCHAR}
and c.companyNo=#{companyNo,jdbcType=VARCHAR}
<iftest="warehouseName!=null">
AND warehouseName like CONCAT(CONCAT('%',#{warehouseName,jdbcType=VARCHAR}), '%')
</if>
...
...
@@ -217,6 +219,7 @@
<iftest="city!=null">
AND ct.city like CONCAT(CONCAT('%',#{city,jdbcType=VARCHAR}), '%')
SELECT warehouseNo,warehouseName,c.country,c.city,addressDetail,(SELECT COUNT(DISTINCT gatewaySN) from tdl_gateway_log WHERE warehouseNo=w.warehouseNo) gatewayCounts,
(SELECT COUNT(TDLSN) from tdl_gateway_log WHERE warehouseNo=w.warehouseNo) tdlCounts,property,type,hardwareLevel,areaPlanIndoor
SELECT warehouseNo,warehouseName,c.country,c.city,addressDetail,(SELECT COUNT(DISTINCT gatewaySN) from tdl_gateway_log WHERE warehouseNo=w.warehouseNo and ISNULL(endTime)) gatewayCounts,
(SELECT COUNT(TDLSN) from tdl_gateway_log WHERE warehouseNo=w.warehouseNo and ISNULL(endTime)) tdlCounts,property,type,hardwareLevel,areaPlanIndoor
from warehouse w INNER JOIN city c ON w.city_id=c.id