Commit ffb8719b authored by chenying's avatar chenying

6.7修改仓库获取实时数据接口,修改下载仓库数据接口

parent d85a8053
package com.example.tdl.common;
import com.example.tdl.domain.vo.DownloadWarehouseVo;
import com.example.tdl.domain.vo.TDLDeviceDetailVo;
import com.example.tdl.domain.vo.WarehouseDetailVo;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.hssf.util.HSSFColor;
......@@ -14,6 +16,7 @@ import javax.servlet.http.HttpServletResponse;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
public class WarehouseExcel {
private Logger logger = LoggerFactory.getLogger(WarehouseExcel.class);
......@@ -25,13 +28,13 @@ public class WarehouseExcel {
private HttpServletResponse response;
private WarehouseDetailVo warehouseDetailVo;
private List<DownloadWarehouseVo> downloadWarehouseVos;
public WarehouseExcel(String fileName, WarehouseDetailVo warehouseDetailVo ,String userName, HttpServletResponse response) {
public WarehouseExcel(String fileName, List<DownloadWarehouseVo> downloadWarehouseVos , String userName, HttpServletResponse response) {
this.userName = userName;
this.fileName = fileName;
this.response = response;
this.warehouseDetailVo=warehouseDetailVo;
this.downloadWarehouseVos=downloadWarehouseVos;
}
/*
......@@ -52,7 +55,7 @@ public class WarehouseExcel {
//设置单元格格式
HSSFCellStyle rowStyle1 = getTitleStyle(workbook);
//循环创建列
for (int n = 0; n < 6; n++) {
for (int n = 0; n < 7; n++) {
cell1 = row1.createCell(n);
//设置列的格式
cell1.setCellStyle(rowStyle1);
......@@ -62,7 +65,7 @@ public class WarehouseExcel {
//设置行高
row1.setHeight((short) (30 * 20));
//合并单元格(参数1:起始行,参数2:截至行,参数3:起始列,参数4:截至列)
sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 5));
sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 6));
/*
......@@ -83,9 +86,9 @@ public class WarehouseExcel {
cell2.setCellStyle(rowStyle2);
//将标题添加到列中
cell2.setCellValue("库房适宜温度为xx℃-xx℃,湿度保持xx%-xx%,超标要做必要调节。");
sheet.addMergedRegion(new CellRangeAddress(1, 1, 2, 4));
sheet.addMergedRegion(new CellRangeAddress(1, 1, 2, 5));
}
cell2 = row2.createCell(5);
cell2 = row2.createCell(6);
cell2.setCellValue("记录人:"+userName);
cell2.setCellStyle(rowStyle2);
row2.setHeight((short) (26 * 20));
......@@ -100,17 +103,20 @@ public class WarehouseExcel {
cell3 = row3.createCell(n);
cell3.setCellStyle(rowStyle3);
//将标题添加到列中
cell3.setCellValue("测定时间");
cell3.setCellValue("采样时间");
sheet.addMergedRegion(new CellRangeAddress(2, 2, 0, 2));
}
cell3 = row3.createCell(3);
cell3.setCellValue("天气情况");
cell3.setCellValue("天气");
cell3.setCellStyle(rowStyle3);
cell3 = row3.createCell(4);
cell3.setCellValue("温度");
cell3.setCellStyle(rowStyle3);
cell3 = row3.createCell(5);
cell3.setCellValue("相对湿度");
cell3.setCellValue("湿度");
cell3.setCellStyle(rowStyle3);
cell3 = row3.createCell(6);
cell3.setCellValue("是否预警");
cell3.setCellStyle(rowStyle3);
row3.setHeight((short) (26 * 20));
......@@ -130,54 +136,59 @@ public class WarehouseExcel {
cell4.setCellValue("时分");
cell4.setCellStyle(rowStyle4);
cell4 = row4.createCell(3);
cell4.setCellValue("天气情况");
cell4.setCellValue("天气");
cell4.setCellStyle(rowStyle4);
cell4 = row4.createCell(4);
cell4.setCellValue("温度");
cell4.setCellStyle(rowStyle4);
cell4 = row4.createCell(5);
cell4.setCellValue("相对湿度");
cell4.setCellValue("湿度");
cell4.setCellStyle(rowStyle4);
cell4 = row4.createCell(6);
cell4.setCellValue("是否预警");
cell4.setCellStyle(rowStyle4);
sheet.addMergedRegion(new CellRangeAddress(2, 3, 3, 3));
sheet.addMergedRegion(new CellRangeAddress(2, 3, 4, 4));
sheet.addMergedRegion(new CellRangeAddress(2, 3, 5, 5));
sheet.addMergedRegion(new CellRangeAddress(2, 3, 6, 6));
row4.setHeight((short) (26 * 20));
/** 循环创建维修表的更换部件
/** 循环创建仓库数据行数
* */
HSSFCellStyle rowStyle = getStyle(workbook);
int a=0;
for(int i = 0;i<warehouseDetailVo.getGatewayOnLineVos().size();i++) {
for (int j = 0; j < warehouseDetailVo.getGatewayOnLineVos().get(i).getTdlDeviceDetailVos().size(); j++) {
HSSFRow row = sheet.createRow((short) 4 + i);
HSSFCell cell = null;
Long time=Long.valueOf(warehouseDetailVo.getGatewayOnLineVos().get(i).getTdlDeviceDetailVos().get(j).getTime());
for(int i = 0;i<downloadWarehouseVos.size();i++) {
HSSFRow row = sheet.createRow((short) 4 + i);
HSSFCell cell = null;
Long time=Long.valueOf(downloadWarehouseVos.get(i).getTime());
// SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date=new Date(time);
cell2 = row2.createCell(1);
cell2.setCellValue(date.getYear());
cell2.setCellStyle(rowStyle);
Date date=new Date(time);
cell2 = row2.createCell(1);
cell2.setCellValue(date.getYear());
cell2.setCellStyle(rowStyle);
cell = row.createCell(0);
cell.setCellValue(date.getMonth());
cell.setCellStyle(rowStyle);
cell = row.createCell(1);
cell.setCellValue(date.getDay());
cell.setCellStyle(rowStyle);
cell = row.createCell(2);
cell.setCellValue(date.getHours()+":"+date.getMinutes());
cell.setCellStyle(rowStyle);
cell = row.createCell(3);
cell.setCellValue("-");
cell.setCellStyle(rowStyle);
cell = row.createCell(4);
cell.setCellValue(warehouseDetailVo.getGatewayOnLineVos().get(i).getTdlDeviceDetailVos().get(j).getTemperature());
cell.setCellStyle(rowStyle);
cell = row.createCell(5);
cell.setCellValue(warehouseDetailVo.getGatewayOnLineVos().get(i).getTdlDeviceDetailVos().get(j).getHumidity());
cell.setCellStyle(rowStyle);
row.setHeight((short) (26 * 20));
}
cell = row.createCell(0);
cell.setCellValue(date.getMonth());
cell.setCellStyle(rowStyle);
cell = row.createCell(1);
cell.setCellValue(date.getDay());
cell.setCellStyle(rowStyle);
cell = row.createCell(2);
cell.setCellValue(date.getHours()+":"+date.getMinutes());
cell.setCellStyle(rowStyle);
cell = row.createCell(3);
cell.setCellValue("-");
cell.setCellStyle(rowStyle);
cell = row.createCell(4);
cell.setCellValue(downloadWarehouseVos.get(i).getTemperature());
cell.setCellStyle(rowStyle);
cell = row.createCell(5);
cell.setCellValue(downloadWarehouseVos.get(i).getHumidity());
cell.setCellStyle(rowStyle);
cell = row.createCell(6);
cell.setCellValue("是");
cell.setCellStyle(rowStyle);
row.setHeight((short) (26 * 20));
}
sheet.setColumnWidth(0, 10 * 256);
sheet.setColumnWidth(1, 10 * 256);
......@@ -185,6 +196,7 @@ public class WarehouseExcel {
sheet.setColumnWidth(3, 27 * 256);
sheet.setColumnWidth(4, 27 * 256);
sheet.setColumnWidth(5, 27 * 256);
sheet.setColumnWidth(6, 27 * 256);
return workbook;
}catch (Exception e) {
e.printStackTrace();
......
package com.example.tdl.domain.vo;
public class DownloadForWarehouseVo {
private String warehouseNo;
private String TDLSN;
public String getWarehouseNo() {
return warehouseNo;
}
public void setWarehouseNo(String warehouseNo) {
this.warehouseNo = warehouseNo;
}
public String getTDLSN() {
return TDLSN;
}
public void setTDLSN(String TDLSN) {
this.TDLSN = TDLSN;
}
}
package com.example.tdl.domain.vo;
public class DownloadWarehouseVo {
private String TDLSN;
private String pressure;
private String temperature;
private String humidity;
private String time;
private String alarm;
public String getTDLSN() {
return TDLSN;
}
public void setTDLSN(String TDLSN) {
this.TDLSN = TDLSN;
}
public String getPressure() {
return pressure;
}
public void setPressure(String pressure) {
this.pressure = pressure;
}
public String getTemperature() {
return temperature;
}
public void setTemperature(String temperature) {
this.temperature = temperature;
}
public String getHumidity() {
return humidity;
}
public void setHumidity(String humidity) {
this.humidity = humidity;
}
public String getTime() {
return time;
}
public void setTime(String time) {
this.time = time;
}
public String getAlarm() {
return alarm;
}
public void setAlarm(String alarm) {
this.alarm = alarm;
}
}
......@@ -6,8 +6,18 @@ public class WarehouseDataVo {
private String TDLSN;
private List<TDLDeviceDetailVo> tdlDeviceDetailVos;
private List<WarehouseTDLDetailVo> warehouseTDLDetailVos;
public List<TDLDeviceDetailVo> getTdlDeviceDetailVos() {
return tdlDeviceDetailVos;
}
public void setTdlDeviceDetailVos(List<TDLDeviceDetailVo> tdlDeviceDetailVos) {
this.tdlDeviceDetailVos = tdlDeviceDetailVos;
}
public String getTDLSN() {
return TDLSN;
}
......
......@@ -7,8 +7,29 @@ public class WarehouseGatewayDateVo {
private String type;
private String battery;
private int state;
private List<WarehouseDataVo> warehouseDataVos;
public String getBattery() {
return battery;
}
public void setBattery(String battery) {
this.battery = battery;
}
public int getState() {
return state;
}
public void setState(int state) {
this.state = state;
}
public String getgSN() {
return gSN;
}
......
......@@ -21,6 +21,8 @@ public interface TDLLogMapper {
ResultAlarmVo getByTdl(@Param("transportationNo") String transportationNo, @Param("TDLSN") String TDLSN);
ResultAlarmVo getWarehouseByTdl(@Param("warehouseNo") String warehouseNo, @Param("TDLSN") String TDLSN);
List<WarehouseLogVo> getByWarehouse(String warehouseNo);
}
......@@ -39,6 +39,10 @@ public class TDLLogService {
return tdlLogMapper.getByTdl(transportationNo,TdlSN);
}
public ResultAlarmVo getWarehouseByTdl(String warehouseNo,String TdlSN){
return tdlLogMapper.getWarehouseByTdl(warehouseNo,TdlSN);
}
public List<WarehouseLogVo> getByWarehouse(String warehouseNo){
return tdlLogMapper.getByWarehouse(warehouseNo);
}
......
......@@ -75,87 +75,42 @@ public class DownloadController {
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
})
@RequestMapping(value = "/download",method = RequestMethod.POST)
public String downLoad(HttpServletResponse response,HttpServletRequest request,@RequestBody String warehouseNo) {
public String downLoad(HttpServletResponse response,HttpServletRequest request,@RequestBody DownloadForWarehouseVo downloadForWarehouseVo) {
String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
JSONObject jsonObject= JSON.parseObject(warehouseNo);
warehouseNo=(String)jsonObject.get("warehouseNo");
if (StringUtils.isEmpty(warehouseNo)){
if (StringUtils.isEmpty(downloadForWarehouseVo.getWarehouseNo())){
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"warehouseNo"));
return gson.toJson(fb);
}
if(warehouseService.getWarehouseNo(warehouseNo) ==0){
if (StringUtils.isEmpty(downloadForWarehouseVo.getTDLSN())){
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"TDLSN"));
return gson.toJson(fb);
}
if(warehouseService.getWarehouseNo(downloadForWarehouseVo.getWarehouseNo()) ==0){
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"Nonexistent"));
return gson.toJson(fb);
}
WarehouseDetailVo warehouseDetailVo=warehouseService.getWarehouseDetailByNo(warehouseNo);
//获取
List<WarehouseLogVo> list =tdlLogService.getByWarehouse(warehouseNo);
List<GatewayOnLineVo> gatewayOnLineVos=new ArrayList<>();
for (int a=0;a<list.size();a++){
if(list.get(a) == null){
continue;
}
if(list.get(a).getEndTime()!=null){
continue;
}
GatewayOnLineVo gatewayOnLineVo = new GatewayOnLineVo();
gatewayOnLineVo.setSN(list.get(a).getSN());
gatewayOnLineVo.setType(list.get(a).getType());
Object data = infoRedisService.getHash("DeviceOnline", list.get(a).getDevice() );
if(data !=null){
OnlineVo onlineVo = gson.fromJson(data.toString(),OnlineVo.class);
if(onlineVo.getOnline() == 1){
gatewayOnLineVo.setState(7);
}else {
gatewayOnLineVo.setState(6);
}
//获取该tdl对应的网关信息
ResultTDLDeviceVo resultTDLDeviceVo=tdlDeviceService.getByTDLSN(downloadForWarehouseVo.getTDLSN());
//获取该tdl的报警信息
ResultAlarmVo resultAlarmVo=tdlLogService.getWarehouseByTdl(downloadForWarehouseVo.getWarehouseNo(),downloadForWarehouseVo.getTDLSN());
String sqls ="SELECT \"b\", \"T\", \"h\" FROM \"tdl_policy\".\""+resultTDLDeviceVo.getGatewayType()+"_"+resultTDLDeviceVo.getGatewaySN()+"\" WHERE (\"tdl\" = '"+downloadForWarehouseVo.getTDLSN()+"') ORDER BY time DESC LIMIT 1";
QueryResult queryResults = influxDBTemplate.query(new Query(sqls, database));
List<DownloadWarehouseVo> downloadWarehouseVos=getWarehouseData(queryResults);
for (int i=0;i<downloadWarehouseVos.size();i++){
if (Integer.valueOf(downloadWarehouseVos.get(i).getTemperature()) > resultAlarmVo.getTemMax()||Integer.valueOf(downloadWarehouseVos.get(i).getTemperature())<resultAlarmVo.getTemMin()){
downloadWarehouseVos.get(i).setAlarm("报警");
}else{
gatewayOnLineVo.setState(6);
}
String sql ="SELECT \"battery\" FROM \"tdl_policy\".\""+list.get(a).getDevice() +"\" ORDER BY time DESC LIMIT 1";
QueryResult queryResult = influxDBTemplate.query(new Query(sql, database));
if (queryResult.getResults().get(0).getSeries() != null) {
if(Double.valueOf(queryResult.getResults().get(0).getSeries().get(0).getValues().get(0).get(1).toString())>0){
gatewayOnLineVo.setBattery(queryResult.getResults().get(0).getSeries().get(0).getValues().get(0).get(1)==null ? "NA" :queryResult.getResults().get(0).getSeries().get(0).getValues().get(0).get(1).toString());
}else{
gatewayOnLineVo.setBattery("NA");
}
}else {
gatewayOnLineVo.setBattery("NA");
}
List<String> tdls=tdlDeviceService.getByGatewaySN(list.get(a).getSN(),list.get(a).getType());
List<TDLDeviceDetailVo> tdlDeviceDetailVos=new ArrayList<>();
for (int b=0;b<tdls.size();b++){
TDLDeviceDetailVo tdlDeviceDetailVo=new TDLDeviceDetailVo();
tdlDeviceDetailVo.setGatewaySN(list.get(a).getSN());
String sqls ="SELECT \"b\", \"T\", \"h\" FROM \"tdl_policy\".\""+list.get(a).getDevice() +"\" WHERE (\"tdl\" = '"+tdls.get(b)+"') ORDER BY time DESC LIMIT 1";
QueryResult queryResults = influxDBTemplate.query(new Query(sqls, database));
if (queryResults.getResults().get(0).getSeries() != null) {
tdlDeviceDetailVo.setTime(parseTime(queryResults.getResults().get(0).getSeries().get(0).getValues().get(0).get(0).toString()));
tdlDeviceDetailVo.setPressure(queryResults.getResults().get(0).getSeries().get(0).getValues().get(0).get(1).toString());
tdlDeviceDetailVo.setTemperature(queryResults.getResults().get(0).getSeries().get(0).getValues().get(0).get(2).toString());
tdlDeviceDetailVo.setHumidity(queryResults.getResults().get(0).getSeries().get(0).getValues().get(0).get(3).toString());
}else{
tdlDeviceDetailVo.setTime("0");
tdlDeviceDetailVo.setPressure("0");
tdlDeviceDetailVo.setTemperature("0");
tdlDeviceDetailVo.setHumidity("0");
}
tdlDeviceDetailVo.setTDLSN(tdls.get(b).replace("TDL-","").trim());
tdlDeviceDetailVos.add(tdlDeviceDetailVo);
downloadWarehouseVos.get(i).setAlarm("正常");
}
gatewayOnLineVo.setTdlDeviceDetailVos(tdlDeviceDetailVos);
gatewayOnLineVos.add(gatewayOnLineVo);
}
warehouseDetailVo.setGatewayOnLineVos(gatewayOnLineVos);
try {
String fileName = warehouseNo+"仓库温湿度观测记录表-" +System.currentTimeMillis();
WarehouseExcel warehouseExcel = new WarehouseExcel(fileName,warehouseDetailVo,user.getUserName(),response);
String fileName = downloadForWarehouseVo.getWarehouseNo()+"仓库温湿度观测记录表-" +System.currentTimeMillis();
WarehouseExcel warehouseExcel = new WarehouseExcel(fileName,downloadWarehouseVos,user.getUserName(),response);
File file=new File("E:"+File.separator+fileName);
if(!file.exists()){
file.mkdir();
......@@ -208,6 +163,35 @@ public class DownloadController {
return gson.toJson(fb);
}
public List<DownloadWarehouseVo> getWarehouseData(QueryResult queryResult){
List<List<Object>> values = getValues(queryResult);
List<DownloadWarehouseVo> downloadWarehouseVos = new ArrayList<>();
for(List<Object> value:values){
DownloadWarehouseVo downloadWarehouseVo = new DownloadWarehouseVo();
downloadWarehouseVo.setTime(parseTime(value.get(0).toString()));
downloadWarehouseVo.setPressure(value.get(1)==null ? "" :value.get(1).toString());
downloadWarehouseVo.setTemperature(value.get(2)==null ? "" :value.get(2).toString());
downloadWarehouseVo.setHumidity(value.get(3)==null ? "" :value.get(3).toString());
downloadWarehouseVos.add(downloadWarehouseVo);
}
return downloadWarehouseVos;
}
//解析数据格式
public List<List<Object>> getValues(QueryResult queryResult){
List<List<Object>> values = new ArrayList<>();
for(QueryResult.Result result : queryResult.getResults()){
if(result.getSeries() !=null){
for (QueryResult.Series series : result.getSeries()) {
if(series !=null){
values= series.getValues();
}
}
}
}
return values;
}
public String parseTime(String time){
String dateResult =null;
try {
......
......@@ -58,7 +58,6 @@ public class HomePageController {
private final static String database ="original";
@Autowired
private I18nController i18n;
......@@ -107,7 +106,7 @@ public class HomePageController {
dataVo.setSum(circuitService.getCount(time,System.currentTimeMillis()/1000l,user.getCompanyName()));//总数量
//获取近几天的线路信息
dataVo.setOnRoute(circuitService.getOnRoute(user.getCompanyName()));//在途数量
Integer delay = circuitService.getDelayCount(System.currentTimeMillis(),time,user.getCompanyName());
Integer delay = circuitService.getDelayCount(System.currentTimeMillis(),time,user.getCompanyName());
dataVo.setDelay(delay);//延误数量
dataVo.setAlarmed( alarmLogServcie.getCount(time,user.getCompanyName()));//报警数量
dataVo.setBump(alarmLogServcie.getBumpCount(time,user.getCompanyName())); //获取颠簸数量
......
......@@ -834,8 +834,6 @@ public class WarehouseController {
return gson.toJson(fb);
}
@ApiOperation(value="添加网关",notes = "添加网关,传值:" +
"warehouseNo:仓库编号" +
"SN:网关编号")
......@@ -886,7 +884,6 @@ public class WarehouseController {
return gson.toJson(fb);
}
//绑定报警联系人
@ApiOperation(value="绑定报警联系人",notes = "绑定报警联系人,传值:" +
"warehouseNo:仓库编号" +
......@@ -981,16 +978,59 @@ public class WarehouseController {
warehouseGatewayDateVo.setType(gatewayOnLineVos.get(a).getType());
String device = gatewayOnLineVos.get(a).getType() + "_" + gatewayOnLineVos.get(a).getSN();
String sql ="SELECT \"battery\" FROM \"tdl_policy\".\""+device +"\" ORDER BY time DESC LIMIT 1";
QueryResult queryResult = influxDBTemplate.query(new Query(sql, database));
if (queryResult.getResults().get(0).getSeries() != null) {
if(Double.valueOf(queryResult.getResults().get(0).getSeries().get(0).getValues().get(0).get(1).toString())>0){
warehouseGatewayDateVo.setBattery(queryResult.getResults().get(0).getSeries().get(0).getValues().get(0).get(1)==null ? "NA" :queryResult.getResults().get(0).getSeries().get(0).getValues().get(0).get(1).toString());
}else{
warehouseGatewayDateVo.setBattery("NA");
}
}else {
warehouseGatewayDateVo.setBattery("NA");
}
Object data = infoRedisService.getHash("DeviceOnline", device );
if(data !=null){
OnlineVo onlineVo = gson.fromJson(data.toString(),OnlineVo.class);
if(onlineVo.getOnline() == 1){
warehouseGatewayDateVo.setState(7);
}else {
warehouseGatewayDateVo.setState(6);
}
}else{
warehouseGatewayDateVo.setState(6);
}
List<String> tdls=tdlDeviceService.getByGatewaySN(gatewayOnLineVos.get(a).getSN(),gatewayOnLineVos.get(a).getType());
List<WarehouseDataVo> warehouseDataVos=new ArrayList<>();
List<TDLDeviceDetailVo> tdlDeviceDetailVos=new ArrayList<>();
for (int b=0;b<tdls.size();b++){
String sqls ="SELECT \"tdl\",\"T\", \"h\" FROM \"tdl_policy\".\""+device+"\" WHERE (\"tdl\" = '"+tdls.get(b)+"') ORDER BY time ";
String sqls ="SELECT \"tdl\",\"b\",\"T\",\"h\" FROM \"tdl_policy\".\""+device+"\" WHERE (\"tdl\" = '"+tdls.get(b)+"') ORDER BY time ";
QueryResult queryResults = influxDBTemplate.query(new Query(sqls, database));
WarehouseDataVo warehouseDataVo=new WarehouseDataVo();
ResultAlarmVo resultAlarmVo=alarmService.getAlarmByWarehouseNo(warehouseNo,gatewayOnLineVos.get(a).getSN(),tdls.get(b).replace("TDL-","").trim());
TDLDeviceDetailVo tdlDeviceDetailVo=new TDLDeviceDetailVo();
tdlDeviceDetailVo.setGatewaySN(gatewayOnLineVos.get(a).getSN());
tdlDeviceDetailVo.setTDLSN(tdls.get(b).replace("TDL-","").trim());
if (queryResults.getResults().get(0).getSeries() != null) {
tdlDeviceDetailVo.setTime(parseTime(queryResults.getResults().get(0).getSeries().get(0).getValues().get(0).get(0).toString()));
tdlDeviceDetailVo.setPressure(queryResults.getResults().get(0).getSeries().get(0).getValues().get(0).get(2).toString());
tdlDeviceDetailVo.setTemperature(queryResults.getResults().get(0).getSeries().get(0).getValues().get(0).get(3).toString());
tdlDeviceDetailVo.setHumidity(queryResults.getResults().get(0).getSeries().get(0).getValues().get(0).get(4).toString());
}else{
tdlDeviceDetailVo.setTime("NA");
tdlDeviceDetailVo.setPressure("NA");
tdlDeviceDetailVo.setTemperature("NA");
tdlDeviceDetailVo.setHumidity("NA");
}
tdlDeviceDetailVos.add(tdlDeviceDetailVo);
List<WarehouseTDLDetailVo> warehouseTDLDetailVos=new ArrayList<>();
List<WarehouseTimeAndDataVo> warehouseTimeAndDataVos = new ArrayList<>();
List<WarehouseTimeAndDataVo> warehouseTimeAndDataVos1 = new ArrayList<>();
warehouseDataVo.setTDLSN(tdls.get(b).replace("TDL-","").trim());
if(queryResults.getResults().get(0).getSeries() != null){
//解析数据
WarehouseTDLDetailVo warehouseTDLDetailVo=new WarehouseTDLDetailVo();
......@@ -999,7 +1039,6 @@ public class WarehouseController {
warehouseTDLDetailVo.setTimeAndValuesVos(warehouseTimeAndDataVos);
warehouseTDLDetailVo.setMax(resultAlarmVo.getTemMax());
warehouseTDLDetailVo.setMin(resultAlarmVo.getTemMin());
warehouseTDLDetailVos.add(warehouseTDLDetailVo);
WarehouseTDLDetailVo warehouseTDLDetailVo1=new WarehouseTDLDetailVo();
......@@ -1010,7 +1049,7 @@ public class WarehouseController {
warehouseTDLDetailVo1.setMin(resultAlarmVo.getHumidityMin());
warehouseTDLDetailVos.add(warehouseTDLDetailVo1);
}
warehouseDataVo.setTDLSN(tdls.get(b));
warehouseDataVo.setTdlDeviceDetailVos(tdlDeviceDetailVos);
warehouseDataVo.setWarehouseTDLDetailVos(warehouseTDLDetailVos);
warehouseDataVos.add(warehouseDataVo);
}
......
......@@ -67,5 +67,6 @@
where warehouseNo=#{warehouseNo,jdbcType=VARCHAR}
AND gatewaySN=#{gatewaySN,jdbcType=VARCHAR}
AND TDLSN=#{TDLSN,jdbcType=VARCHAR}
AND endTime is null
</select>
</mapper>
\ No newline at end of file
......@@ -110,7 +110,9 @@
<!--根据仓库编号查询网关信息-->
<select id="getByWarehouseNo" parameterType="String" resultType="com.example.tdl.domain.vo.GatewayOnLineVo">
SELECT DISTINCT gatewaySN SN, gatewayType type from tdl_gateway_log where warehouseNo=#{warehouseNo,jdbcType=VARCHAR}
SELECT DISTINCT gatewaySN SN, gatewayType type from tdl_gateway_log
where warehouseNo=#{warehouseNo,jdbcType=VARCHAR}
AND endTime is null
</select>
......
......@@ -42,6 +42,15 @@
and TDLSN = #{TDLSN,jdbcType=VARCHAR}
</select>
<select id="getWarehouseByTdl" parameterType="String" resultType="com.example.tdl.domain.vo.ResultAlarmVo">
select alarmType,alarmScene,temMax,temMin,humidityMax,humidityMin,tilt,shock,remark
from alarm a,tdl_gateway_log t
where a.id = t.alarm_id
and warehouseNo = #{warehouseNo,jdbcType=VARCHAR}
and TDLSN = #{TDLSN,jdbcType=VARCHAR}
AND endTime is not null
</select>
<select id="getByWarehouse" parameterType="String" resultType="com.example.tdl.domain.vo.WarehouseLogVo">
select DISTINCT CONCAT( gatewaytype,"_",gatewaySN) device, tgl.gatewaySN SN,gatewaytype type,w.warehouseNo
......
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