Commit 2e4c3dd1 authored by Carit Zhu's avatar Carit Zhu 🎱

Add gatewayName and tdlname for getWarehouseData interface in WarehouseController.

parent cf4edc86
Pipeline #493 passed with stage
in 0 seconds
......@@ -6,6 +6,8 @@ public class WarehouseDataVo {
private String TDLSN;
private String TDLName;
private String batteryVoltage;
private String temperature;
......@@ -24,6 +26,14 @@ public class WarehouseDataVo {
this.TDLSN = TDLSN;
}
public String getTDLName() {
return TDLName;
}
public void setTDLName(String TDLName) {
this.TDLName = TDLName;
}
public String getBatteryVoltage() {
return batteryVoltage;
}
......
......@@ -7,43 +7,52 @@ public class WarehouseGatewayDateVo {
private String type;
private String name;
private String battery;
private int state;
private List<WarehouseDataVo> warehouseDataVos;
public String getgSN() {
return gSN;
}
public String getBattery() {
return battery;
public void setgSN(String gSN) {
this.gSN = gSN;
}
public void setBattery(String battery) {
this.battery = battery;
public String getType() {
return type;
}
public int getState() {
return state;
public void setType(String type) {
this.type = type;
}
public void setState(int state) {
this.state = state;
public String getName() {
return name;
}
public String getgSN() {
return gSN;
public void setName(String name) {
this.name = name;
}
public void setgSN(String gSN) {
this.gSN = gSN;
public String getBattery() {
return battery;
}
public String getType() {
return type;
public void setBattery(String battery) {
this.battery = battery;
}
public void setType(String type) {
this.type = type;
public int getState() {
return state;
}
public void setState(int state) {
this.state = state;
}
public List<WarehouseDataVo> getWarehouseDataVos() {
......
......@@ -975,6 +975,7 @@ public class WarehouseController {
" {" +
" gSN: 网关编号," +
" type: 网关类型," +
" name: 网关名称," +
" warehouseDataVos: [" +
" {" +
" warehouseTDLDetailVos: [" +
......@@ -987,6 +988,7 @@ public class WarehouseController {
" }" +
" ]," +
" tdlsn: TDL-201802271711" +
" tdlname: tdl名称" +
" }" +
" ]" +
" }" +
......@@ -1012,6 +1014,7 @@ public class WarehouseController {
WarehouseGatewayDateVo warehouseGatewayDateVo=new WarehouseGatewayDateVo();
warehouseGatewayDateVo.setgSN(gatewayOnLineVos.get(a).getgSN());
warehouseGatewayDateVo.setType(gatewayOnLineVos.get(a).getType());
warehouseGatewayDateVo.setName(gatewayOnLineVos.get(a).getName());
String device = gatewayOnLineVos.get(a).getType() + "_" + gatewayOnLineVos.get(a).getgSN();
String sql ="SELECT \"battery\" FROM \"tdl_policy\".\""+device +"\" where time >="+ gatewayOnLineVos.get(a).getStartTime()*1000000l+" ORDER BY time DESC LIMIT 1";
QueryResult queryResult = influxDBTemplate.query(new Query(sql, database));
......@@ -1035,15 +1038,19 @@ public class WarehouseController {
}else{
warehouseGatewayDateVo.setState(6);
}
List<String> tdls=tdlDeviceService.getByGatewaySN(gatewayOnLineVos.get(a).getgSN(),gatewayOnLineVos.get(a).getType());
//List<String> tdls=tdlDeviceService.getByGatewaySN(gatewayOnLineVos.get(a).getgSN(),gatewayOnLineVos.get(a).getType());
List<TDLDeviceVo> tdlDeviceVoList = tdlDeviceService.getTdlByGatewaySN(
gatewayOnLineVos.get(a).getgSN(),gatewayOnLineVos.get(a).getType());
List<WarehouseDataVo> warehouseDataVos=new ArrayList<>();
for (int b=0;b<tdls.size();b++){
for (TDLDeviceVo tdlDeviceVo : tdlDeviceVoList){
List<WarehouseTDLDetailVo> warehouseTDLDetailVos=new ArrayList<>();
WarehouseDataVo warehouseDataVo=new WarehouseDataVo();
warehouseDataVo.setTDLSN(tdls.get(b).replace("TDL-","").trim());
String sqls ="SELECT \"tdl\",\"b\",\"T\",\"h\" FROM \"tdl_policy\".\""+device+"\" WHERE \"tdl\" = '"+tdls.get(b)+"' AND time >="+ gatewayOnLineVos.get(a).getStartTime()*1000000l+" and time <="+ endTime*1000000l+" ORDER BY time desc limit 1 ";
String rawTDLSN = tdlDeviceVo.getTDLSN().replace("TDL-","").trim();
warehouseDataVo.setTDLSN(rawTDLSN);
warehouseDataVo.setTDLName(tdlDeviceVo.getTDLName());
String sqls ="SELECT \"tdl\",\"b\",\"T\",\"h\" FROM \"tdl_policy\".\""+device+"\" WHERE \"tdl\" = '"+tdlDeviceVo.getTDLSN()+"' AND time >="+ gatewayOnLineVos.get(a).getStartTime()*1000000l+" and time <="+ endTime*1000000l+" ORDER BY time desc limit 1 ";
QueryResult queryResults = influxDBTemplate.query(new Query(sqls, database));
ResultAlarmVo resultAlarmVo=alarmService.getAlarmByWarehouseNo(warehouseVo.getWarehouseNo(),gatewayOnLineVos.get(a).getgSN(),tdls.get(b).replace("TDL-","").trim());
ResultAlarmVo resultAlarmVo=alarmService.getAlarmByWarehouseNo(warehouseVo.getWarehouseNo(),gatewayOnLineVos.get(a).getgSN(),rawTDLSN);
if (queryResults.getResults().get(0).getSeries() != null) {
warehouseDataVo.setTime(UTCToCST(queryResults.getResults().get(0).getSeries().get(0).getValues().get(0).get(0).toString(),warehouseVo.getOffset()==null ? "+8" : warehouseVo.getOffset()));
warehouseDataVo.setBatteryVoltage(df.format(new BigDecimal(queryResults.getResults().get(0).getSeries().get(0).getValues().get(0).get(2).toString())));
......@@ -1055,7 +1062,7 @@ public class WarehouseController {
warehouseDataVo.setTemperature("NA");
warehouseDataVo.setHumidity("NA");
}
String sql3 ="SELECT \"tdl\",\"T\",\"h\" FROM \"tdl_policy\".\""+device+"\" WHERE \"tdl\" = '"+tdls.get(b)+"' AND time >="+ gatewayOnLineVos.get(a).getStartTime()*1000000l+" and time <="+ endTime*1000000l+" ORDER BY time ";
String sql3 ="SELECT \"tdl\",\"T\",\"h\" FROM \"tdl_policy\".\""+device+"\" WHERE \"tdl\" = '"+tdlDeviceVo.getTDLSN()+"' AND time >="+ gatewayOnLineVos.get(a).getStartTime()*1000000l+" and time <="+ endTime*1000000l+" ORDER BY time ";
QueryResult queryResult3 = influxDBTemplate.query(new Query(sql3, database));
if(queryResult3.getResults().get(0).getSeries() != null){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment