Commit c4352c26 authored by chenying's avatar chenying

5.28仓库实时数据

parent 43ef55d1
package com.example.tdl.domain.vo;
import java.util.List;
public class GatewayOnLineVo {
private String SN;
private String type;
private Integer state;
private String battery;
private List<TDLDeviceDetailVo> tdlDeviceDetailVos;
public List<TDLDeviceDetailVo> getTdlDeviceDetailVos() {
return tdlDeviceDetailVos;
}
public void setTdlDeviceDetailVos(List<TDLDeviceDetailVo> tdlDeviceDetailVos) {
this.tdlDeviceDetailVos = tdlDeviceDetailVos;
}
public String getBattery() {
return battery;
}
public void setBattery(String battery) {
this.battery = battery;
}
public String getSN() {
return SN;
}
public void setSN(String SN) {
this.SN = SN;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public Integer getState() {
return state;
}
public void setState(Integer state) {
this.state = state;
}
}
package com.example.tdl.domain.vo;
public class TDLDeviceDetailVo {
private String TDLSN;
private String pressure;
private String temperature;
private String humidity;
private String time;
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;
}
}
package com.example.tdl.domain.vo;
import java.util.List;
public class WarehouseDataVo {
private String TDLSN;
private List<WarehouseTDLDetailVo> warehouseTDLDetailVos;
public String getTDLSN() {
return TDLSN;
}
public void setTDLSN(String TDLSN) {
this.TDLSN = TDLSN;
}
public List<WarehouseTDLDetailVo> getWarehouseTDLDetailVos() {
return warehouseTDLDetailVos;
}
public void setWarehouseTDLDetailVos(List<WarehouseTDLDetailVo> warehouseTDLDetailVos) {
this.warehouseTDLDetailVos = warehouseTDLDetailVos;
}
}
package com.example.tdl.domain.vo;
import java.util.List;
public class WarehouseDetailVo {
private String warehouseNo;
private String warehouseName;
private String country;
private String city;
private String addressDetail;
private Integer gatewayCounts;
private Integer tdlCounts;
private List<GatewayOnLineVo> gatewayOnLineVos;
public List<GatewayOnLineVo> getGatewayOnLineVos() {
return gatewayOnLineVos;
}
public void setGatewayOnLineVos(List<GatewayOnLineVo> gatewayOnLineVos) {
this.gatewayOnLineVos = gatewayOnLineVos;
}
public String getWarehouseNo() {
return warehouseNo;
}
public void setWarehouseNo(String warehouseNo) {
this.warehouseNo = warehouseNo;
}
public String getWarehouseName() {
return warehouseName;
}
public void setWarehouseName(String warehouseName) {
this.warehouseName = warehouseName;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getAddressDetail() {
return addressDetail;
}
public void setAddressDetail(String addressDetail) {
this.addressDetail = addressDetail;
}
public Integer getGatewayCounts() {
return gatewayCounts;
}
public void setGatewayCounts(Integer gatewayCounts) {
this.gatewayCounts = gatewayCounts;
}
public Integer getTdlCounts() {
return tdlCounts;
}
public void setTdlCounts(Integer tdlCounts) {
this.tdlCounts = tdlCounts;
}
}
package com.example.tdl.domain.vo;
import java.util.List;
public class WarehouseGatewayDateVo {
private String gSN;
private String type;
private List<WarehouseDataVo> warehouseDataVos;
public String getgSN() {
return gSN;
}
public void setgSN(String gSN) {
this.gSN = gSN;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public List<WarehouseDataVo> getWarehouseDataVos() {
return warehouseDataVos;
}
public void setWarehouseDataVos(List<WarehouseDataVo> warehouseDataVos) {
this.warehouseDataVos = warehouseDataVos;
}
}
package com.example.tdl.domain.vo;
import java.util.List;
public class WarehouseTDLDetailVo {
private String description;
private List<WarehouseTimeAndDataVo> timeAndValuesVos;
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public List<WarehouseTimeAndDataVo> getTimeAndValuesVos() {
return timeAndValuesVos;
}
public void setTimeAndValuesVos(List<WarehouseTimeAndDataVo> timeAndValuesVos) {
this.timeAndValuesVos = timeAndValuesVos;
}
}
package com.example.tdl.domain.vo;
public class WarehouseTimeAndDataVo {
private String time;
private String value;
public String getTime() {
return time;
}
public void setTime(String time) {
this.time = time;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
...@@ -32,4 +32,6 @@ public interface GatewayMapper { ...@@ -32,4 +32,6 @@ public interface GatewayMapper {
List<GatewaySNVo> getUnusedGateway(@Param("SN") String SN,@Param("companyNo") String companyNo); List<GatewaySNVo> getUnusedGateway(@Param("SN") String SN,@Param("companyNo") String companyNo);
int updateCompany(UpdateGatewayCompanyVo updateGatewayCompanyVo); int updateCompany(UpdateGatewayCompanyVo updateGatewayCompanyVo);
List<GatewayOnLineVo> getByWarehouseNo(@Param("warehouseNo") String warehouseNo);
} }
...@@ -32,4 +32,5 @@ public interface TDLDeviceMapper { ...@@ -32,4 +32,5 @@ public interface TDLDeviceMapper {
ResultTDLDeviceVo getByTransportationNo(String transportationNo); ResultTDLDeviceVo getByTransportationNo(String transportationNo);
int updateCompany(@Param("TDLSN") String TDLSN,@Param("companyNo") String companyNo); int updateCompany(@Param("TDLSN") String TDLSN,@Param("companyNo") String companyNo);
} }
...@@ -45,4 +45,5 @@ public interface WarehouseMapper { ...@@ -45,4 +45,5 @@ public interface WarehouseMapper {
Integer updateImg(@Param("warehouseNo")String warehouseNo,@Param("img")String img,@Param("updateTime") Long updateTime); Integer updateImg(@Param("warehouseNo")String warehouseNo,@Param("img")String img,@Param("updateTime") Long updateTime);
WarehouseDetailVo getWarehouseDetailByNo(@Param("warehouseNo") String warehouseNo);
} }
...@@ -62,4 +62,8 @@ public class GatewayService { ...@@ -62,4 +62,8 @@ public class GatewayService {
public int updateCompany(UpdateGatewayCompanyVo updateGatewayCompanyVo){ public int updateCompany(UpdateGatewayCompanyVo updateGatewayCompanyVo){
return gatewayMapper.updateCompany(updateGatewayCompanyVo); return gatewayMapper.updateCompany(updateGatewayCompanyVo);
} }
public List<GatewayOnLineVo> getByWarehouseNo(String warehouseNo){
return gatewayMapper.getByWarehouseNo(warehouseNo);
}
} }
...@@ -60,4 +60,5 @@ public class TDLDeviceService { ...@@ -60,4 +60,5 @@ public class TDLDeviceService {
public int updateCompany(String TDLSN,String companyNo){ public int updateCompany(String TDLSN,String companyNo){
return tdlDeviceMapper.updateCompany(TDLSN,companyNo); return tdlDeviceMapper.updateCompany(TDLSN,companyNo);
} }
} }
...@@ -79,4 +79,8 @@ public class WarehouseService { ...@@ -79,4 +79,8 @@ public class WarehouseService {
public Integer updateImg(String warehouseNo, String img, Long updateTime){ public Integer updateImg(String warehouseNo, String img, Long updateTime){
return warehouseMapper.updateImg(warehouseNo,img,updateTime); return warehouseMapper.updateImg(warehouseNo,img,updateTime);
} }
public WarehouseDetailVo getWarehouseDetailByNo(String warehouseNo){
return warehouseMapper.getWarehouseDetailByNo(warehouseNo);
}
} }
...@@ -179,6 +179,12 @@ public class TDLDeviceController { ...@@ -179,6 +179,12 @@ public class TDLDeviceController {
fb.setMessage(i18n.getMessage(request,"TDLSN")); fb.setMessage(i18n.getMessage(request,"TDLSN"));
return gson.toJson(fb); return gson.toJson(fb);
} }
Object[] o={TDLSN};
if (tdlDeviceService.getByTDLSN(TDLSN).getUseScene()!=0){
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,o,"tdlUsed"));
return gson.toJson(fb);
}
int a = tdlDeviceService.delTDLDevice(TDLSN); int a = tdlDeviceService.delTDLDevice(TDLSN);
if (a>0){ if (a>0){
fb.setCode(1); fb.setCode(1);
......
...@@ -6,21 +6,25 @@ import com.alibaba.fastjson.JSONObject; ...@@ -6,21 +6,25 @@ import com.alibaba.fastjson.JSONObject;
import com.example.tdl.domain.dto.CommFeedback; import com.example.tdl.domain.dto.CommFeedback;
import com.example.tdl.domain.vo.*; import com.example.tdl.domain.vo.*;
import com.example.tdl.service.*; import com.example.tdl.service.*;
import com.example.tdl.service.redis.InfoRedisService;
import com.example.tdl.service.redis.TokenRedisService; import com.example.tdl.service.redis.TokenRedisService;
import com.google.gson.Gson; import com.google.gson.Gson;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.influxdb.dto.Query;
import org.influxdb.dto.QueryResult;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.influxdb.InfluxDBTemplate;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.HashMap; import java.text.ParseException;
import java.util.List; import java.text.SimpleDateFormat;
import java.util.Map; import java.util.*;
@RestController @RestController
@RequestMapping("/warehouse") @RequestMapping("/warehouse")
...@@ -47,9 +51,20 @@ public class WarehouseController { ...@@ -47,9 +51,20 @@ public class WarehouseController {
@Autowired @Autowired
private GatewayService gatewayService; private GatewayService gatewayService;
@Autowired
private TDLDeviceService tdlDeviceService;
@Autowired
private InfoRedisService infoRedisService;
@Autowired @Autowired
private UserService userService; private UserService userService;
@Autowired
private InfluxDBTemplate influxDBTemplate;
private final static String database ="original";
//查询所有仓库信息 //查询所有仓库信息
@ApiOperation(value = "查询所有仓库信息",notes = "查询所有仓库信息,返回值说明:" + @ApiOperation(value = "查询所有仓库信息",notes = "查询所有仓库信息,返回值说明:" +
" warehouseName:仓库名," + " warehouseName:仓库名," +
...@@ -176,7 +191,7 @@ public class WarehouseController { ...@@ -176,7 +191,7 @@ public class WarehouseController {
} }
//根据仓库编号获取仓库信息 //根据仓库编号获取仓库信息
@ApiOperation(value = "根据条件查询仓库信息",notes = "根据条件查询仓库信息,传值说明:") @ApiOperation(value = "根据仓库编号获取仓库信息",notes = "根据仓库编号获取仓库信息,传值说明:")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"), @ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
}) })
...@@ -185,8 +200,54 @@ public class WarehouseController { ...@@ -185,8 +200,54 @@ public class WarehouseController {
String token = request.getHeader("Account_token"); String token = request.getHeader("Account_token");
String datum = tokenRedisService.get("TOKEN_" +token); String datum = tokenRedisService.get("TOKEN_" +token);
UserRedisVo userRedisVo = gson.fromJson(datum,UserRedisVo.class); UserRedisVo userRedisVo = gson.fromJson(datum,UserRedisVo.class);
JSONObject jsonObject=JSON.parseObject(warehouseNo);
return gson.toJson(fb); warehouseNo=(String) jsonObject.get("warehouseNo");
WarehouseDetailVo warehouseDetailVo=warehouseService.getWarehouseDetailByNo(warehouseNo);
List<GatewayOnLineVo> gatewayOnLineVos=gatewayService.getByWarehouseNo(warehouseNo);
for (int a=0;a<gatewayOnLineVos.size();a++){
String device = gatewayOnLineVos.get(a).getType() + "_" + gatewayOnLineVos.get(a).getSN();
Object data = infoRedisService.getHash("DeviceOnline", device );
if(data !=null){
OnlineVo onlineVo = gson.fromJson(data.toString(),OnlineVo.class);
if(onlineVo.getOnline() == 1){
gatewayOnLineVos.get(a).setState(7);
}else {
gatewayOnLineVos.get(a).setState(6);
}
}else{
gatewayOnLineVos.get(a).setState(6);
}
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) {
gatewayOnLineVos.get(a).setBattery(queryResult.getResults().get(0).getSeries().get(0).getValues().get(0).get(1).toString());
}else {
gatewayOnLineVos.get(a).setBattery("");
}
List<String> tdls=tdlDeviceService.getByGatewaySN(gatewayOnLineVos.get(a).getSN(),gatewayOnLineVos.get(a).getType());
List<TDLDeviceDetailVo> tdlDeviceDetailVos=new ArrayList<>();
for (int b=0;b<tdls.size();b++){
TDLDeviceDetailVo tdlDeviceDetailVo=new TDLDeviceDetailVo();
String sqls ="SELECT \"b\", \"T\", \"h\" FROM \"tdl_policy\".\""+device+"\" 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("");
tdlDeviceDetailVo.setPressure("");
tdlDeviceDetailVo.setPressure("");
tdlDeviceDetailVo.setHumidity("");
}
tdlDeviceDetailVo.setTDLSN(tdls.get(b));
tdlDeviceDetailVos.add(tdlDeviceDetailVo);
}
gatewayOnLineVos.get(a).setTdlDeviceDetailVos(tdlDeviceDetailVos);
}
warehouseDetailVo.setGatewayOnLineVos(gatewayOnLineVos);
return warehouseDetailVo;
} }
//获取某个仓库的网关 //获取某个仓库的网关
...@@ -413,8 +474,6 @@ public class WarehouseController { ...@@ -413,8 +474,6 @@ public class WarehouseController {
} }
//根据仓库编号修改仓库信息 //根据仓库编号修改仓库信息
@ApiOperation(value = "根据仓库编号修改仓库信息",notes = "根据仓库编号修改仓库信息,updatTime不用传,传值说明:" + @ApiOperation(value = "根据仓库编号修改仓库信息",notes = "根据仓库编号修改仓库信息,updatTime不用传,传值说明:" +
" warehouseNo:需要修改的仓库编号," + " warehouseNo:需要修改的仓库编号," +
...@@ -608,8 +667,7 @@ public class WarehouseController { ...@@ -608,8 +667,7 @@ public class WarehouseController {
return gson.toJson(fb); return gson.toJson(fb);
} }
//删除仓库信息
// 删除仓库信息
@ApiOperation(value = "删除仓库信息",notes = "删除仓库信息,只用传仓库编号") @ApiOperation(value = "删除仓库信息",notes = "删除仓库信息,只用传仓库编号")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"), @ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
...@@ -648,8 +706,7 @@ public class WarehouseController { ...@@ -648,8 +706,7 @@ public class WarehouseController {
return gson.toJson(fb); return gson.toJson(fb);
} }
//添加网关
@ApiOperation(value="添加网关",notes = "添加网关,传值:" + @ApiOperation(value="添加网关",notes = "添加网关,传值:" +
"warehouseNo:仓库编号" + "warehouseNo:仓库编号" +
"SN:网关编号") "SN:网关编号")
...@@ -700,8 +757,6 @@ public class WarehouseController { ...@@ -700,8 +757,6 @@ public class WarehouseController {
return gson.toJson(fb); return gson.toJson(fb);
} }
//绑定报警联系人 //绑定报警联系人
@ApiOperation(value="绑定报警联系人",notes = "绑定报警联系人,传值:" + @ApiOperation(value="绑定报警联系人",notes = "绑定报警联系人,传值:" +
"warehouseNo:仓库编号" + "warehouseNo:仓库编号" +
...@@ -736,7 +791,7 @@ public class WarehouseController { ...@@ -736,7 +791,7 @@ public class WarehouseController {
fb.setMessage("用户名不存在"); fb.setMessage("用户名不存在");
return gson.toJson(fb); return gson.toJson(fb);
} }
userNameVar = userNameVar +warehouseUserVo.getUserNameList().get(i) +" "; userNameVar = userNameVar +warehouseUserVo.getUserNameList().get(i) +"&";
} }
Map<Object,Object> map=new HashMap<>(); Map<Object,Object> map=new HashMap<>();
map.put("warehouseNo",warehouseUserVo.getWarehouseNo()); map.put("warehouseNo",warehouseUserVo.getWarehouseNo());
...@@ -755,7 +810,110 @@ public class WarehouseController { ...@@ -755,7 +810,110 @@ public class WarehouseController {
return gson.toJson(fb); return gson.toJson(fb);
} }
// String tdl="";
// for (int i=0;i<tdls.size();i++){
// if (i!=tdls.size()-1){
// tdl=tdl+tdls.get(i)+"' or \"tdl\"='";
// }else{
// tdl=tdl+tdls.get(i);
// }
// }
//根据仓库编号获取仓库实时数据
@ApiOperation(value = "根据仓库编号获取仓库信息",notes = "根据仓库编号获取仓库信息,传值说明:")
@ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
})
@PostMapping("/getWarehouseData")
public Object getWarehouseData(@RequestBody String warehouseNo,HttpServletRequest request){
JSONObject jsonObject=JSON.parseObject(warehouseNo);
warehouseNo=(String) jsonObject.get("warehouseNo");
List<WarehouseGatewayDateVo> warehouseGatewayDateVoList=new ArrayList<>();
List<GatewayOnLineVo> gatewayOnLineVos=gatewayService.getByWarehouseNo(warehouseNo);
for (int a=0;a<gatewayOnLineVos.size();a++){
WarehouseGatewayDateVo warehouseGatewayDateVo=new WarehouseGatewayDateVo();
warehouseGatewayDateVo.setgSN(gatewayOnLineVos.get(a).getSN());
warehouseGatewayDateVo.setType(gatewayOnLineVos.get(a).getType());
String device = gatewayOnLineVos.get(a).getType() + "_" + gatewayOnLineVos.get(a).getSN();
List<String> tdls=tdlDeviceService.getByGatewaySN(gatewayOnLineVos.get(a).getSN(),gatewayOnLineVos.get(a).getType());
List<WarehouseTimeAndDataVo> warehouseTimeAndDataVos = new ArrayList<>();
List<WarehouseTimeAndDataVo> warehouseTimeAndDataVos1 = new ArrayList<>();
List<WarehouseTDLDetailVo> warehouseTDLDetailVos=new ArrayList<>();
List<WarehouseDataVo> warehouseDataVos=new ArrayList<>();
for (int b=0;b<tdls.size();b++){
String sqls ="SELECT \"tdl\",\"T\", \"h\" FROM \"tdl_policy\".\""+device+"\" WHERE (\"tdl\" = 'TDL-1701110082608') ORDER BY time DESC ";
QueryResult queryResults = influxDBTemplate.query(new Query(sqls, database));
WarehouseDataVo warehouseDataVo=new WarehouseDataVo();
if(queryResults.getResults().get(0).getSeries() != null){
//解析数据
WarehouseTDLDetailVo warehouseTDLDetailVo=new WarehouseTDLDetailVo();
warehouseTimeAndDataVos = getData(queryResults);
warehouseTDLDetailVo.setDescription("temperature");
warehouseTDLDetailVo.setTimeAndValuesVos(warehouseTimeAndDataVos);
warehouseTDLDetailVos.add(warehouseTDLDetailVo);
WarehouseTDLDetailVo warehouseTDLDetailVo1=new WarehouseTDLDetailVo();
warehouseTimeAndDataVos1 = getDatas(queryResults);
warehouseTDLDetailVo1.setDescription("humidity");
warehouseTDLDetailVo1.setTimeAndValuesVos(warehouseTimeAndDataVos1);
warehouseTDLDetailVos.add(warehouseTDLDetailVo1);
}
warehouseDataVo.setTDLSN(tdls.get(b));
warehouseDataVo.setWarehouseTDLDetailVos(warehouseTDLDetailVos);
warehouseDataVos.add(warehouseDataVo);
}
warehouseGatewayDateVo.setWarehouseDataVos(warehouseDataVos);
warehouseGatewayDateVoList.add(warehouseGatewayDateVo);
}
return warehouseGatewayDateVoList;
}
public List<WarehouseTimeAndDataVo> getData(QueryResult queryResult){
List<List<Object>> values = getValues(queryResult);
List<WarehouseTimeAndDataVo> historyDataList = new ArrayList<>();
for(List<Object> value:values){
WarehouseTimeAndDataVo warehouseTimeAndDataVo = new WarehouseTimeAndDataVo();
warehouseTimeAndDataVo.setTime(parseTime(value.get(0).toString()));
warehouseTimeAndDataVo.setValue(value.get(2)==null ? "" :value.get(2).toString());
historyDataList.add(warehouseTimeAndDataVo);
}
return historyDataList;
}
public List<WarehouseTimeAndDataVo> getDatas(QueryResult queryResult){
List<List<Object>> values = getValues(queryResult);
List<WarehouseTimeAndDataVo> historyDataList = new ArrayList<>();
for(List<Object> value:values){
WarehouseTimeAndDataVo warehouseTimeAndDataVo = new WarehouseTimeAndDataVo();
warehouseTimeAndDataVo.setTime(parseTime(value.get(0).toString()));
warehouseTimeAndDataVo.setValue(value.get(3)==null ? "" :value.get(3).toString());
historyDataList.add(warehouseTimeAndDataVo);
}
return historyDataList;
}
//解析数据格式
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 getWarehouseNo(){ public String getWarehouseNo(){
...@@ -768,4 +926,29 @@ public class WarehouseController { ...@@ -768,4 +926,29 @@ public class WarehouseController {
} }
return warehouseNo; return warehouseNo;
} }
//解析时间
public String parseTime(String time){
String dateResult =null;
try {
dateResult = dateToStamp(time);
} catch (ParseException e) {
e.printStackTrace();
logger.info(e.toString());
fb.setCode(0);
fb.setMessage("解析时间异常");
}
return dateResult;
}
//将utc时间转换成时间戳
public static String dateToStamp(String s) throws ParseException {
Date date =null ;
if(s.length() !=20 ) {
date = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").parse(s);
}else{
date = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'").parse(s);
}
return String.valueOf(date.getTime());
}
} }
...@@ -63,16 +63,16 @@ gateway = \u7F51\u5173\u5E8F\u5217\u53F7\u4E0D\u80FD\u4E3A\u7A7A ...@@ -63,16 +63,16 @@ gateway = \u7F51\u5173\u5E8F\u5217\u53F7\u4E0D\u80FD\u4E3A\u7A7A
gatewayExist = \u8BE5\u7F51\u5173\u5E8F\u5217\u53F7\u4E0D\u5B58\u5728 gatewayExist = \u8BE5\u7F51\u5173\u5E8F\u5217\u53F7\u4E0D\u5B58\u5728
gatewayMounted = \u8BE5\u7F51\u5173\u672A\u6302\u8F7D gatewayMounted = \u8BE5\u7F51\u5173\u672A\u6302\u8F7D
gatewayConsistent = \u8BE5\u7F51\u5173\u7684\u4F7F\u7528\u573A\u666F\u4E0E\u5F53\u524D\u4E0D\u7B26 gatewayConsistent = \u8BE5\u7F51\u5173\u7684\u4F7F\u7528\u573A\u666F\u4E0E\u5F53\u524D\u4E0D\u7B26
tdl = TDL\u5E8F\u5217\u53F7\u4E0D\u80FD\u4E3A\u7A7A tdl = \u4F20\u611F\u5668\u5E8F\u5217\u53F7\u4E0D\u80FD\u4E3A\u7A7A
tdlExist={0}TDL\u4E0D\u5B58\u5728 tdlExist={0}\u4F20\u611F\u5668\u4E0D\u5B58\u5728
tdlUsed={0}\u7684TDL\u5DF2\u7ECF\u88AB\u4F7F\u7528 tdlUsed={0}\u7684\u4F20\u611F\u5668\u5DF2\u7ECF\u88AB\u4F7F\u7528
cargoNo = \u8D27\u7269\u7F16\u53F7\u4E0D\u80FD\u4E3A\u7A7A cargoNo = \u8D27\u7269\u7F16\u53F7\u4E0D\u80FD\u4E3A\u7A7A
plateNo = \u8F66\u724C\u53F7\u4E0D\u80FD\u4E3A\u7A7A plateNo = \u8F66\u724C\u53F7\u4E0D\u80FD\u4E3A\u7A7A
cargoName = \u8D27\u7269\u522B\u540D\u4E0D\u80FD\u4E3A\u7A7A cargoName = \u8D27\u7269\u522B\u540D\u4E0D\u80FD\u4E3A\u7A7A
circuitSuccess = \u6DFB\u52A0\u7EBF\u8DEF\u6210\u529F circuitSuccess = \u6DFB\u52A0\u7EBF\u8DEF\u6210\u529F
circuitFailure = \u6DFB\u52A0\u7EBF\u8DEF\u5931\u8D25 circuitFailure = \u6DFB\u52A0\u7EBF\u8DEF\u5931\u8D25
notStarted = \u7EBF\u8DEF\u672A\u5F00\u59CB\u8FD0\u8F93 notStarted = \u7EBF\u8DEF\u672A\u5F00\u59CB\u8FD0\u8F93
notBound = \u8BE5\u7EBF\u8DEF\u672A\u7ED1\u5B9A\u7F51\u5173\u6216\u8005tdl notBound = \u8BE5\u7EBF\u8DEF\u672A\u7ED1\u5B9A\u7F51\u5173\u6216\u8005\u4F20\u611F\u5668
endCircuitSuccess =\u7EBF\u8DEF\u7ED3\u675F\u6210\u529F endCircuitSuccess =\u7EBF\u8DEF\u7ED3\u675F\u6210\u529F
endCircuitFailure =\u7EBF\u8DEF\u7ED3\u675F\u5931\u8D25 endCircuitFailure =\u7EBF\u8DEF\u7ED3\u675F\u5931\u8D25
transportation = \u8FD0\u8F93\u65B9\u5F0F\u4E0D\u80FD\u4E3A\u7A7A transportation = \u8FD0\u8F93\u65B9\u5F0F\u4E0D\u80FD\u4E3A\u7A7A
...@@ -84,7 +84,7 @@ evaluateSuccess = \u8BC4\u4EF7\u6210\u529F ...@@ -84,7 +84,7 @@ evaluateSuccess = \u8BC4\u4EF7\u6210\u529F
evaluateFailure =\u8BC4\u4EF7\u5931\u8D25 evaluateFailure =\u8BC4\u4EF7\u5931\u8D25
circuitState = \u9700\u8981\u67E5\u8BE2\u7684\u7EBF\u8DEF\u72B6\u6001\u4E0D\u80FD\u4E3A\u7A7A circuitState = \u9700\u8981\u67E5\u8BE2\u7684\u7EBF\u8DEF\u72B6\u6001\u4E0D\u80FD\u4E3A\u7A7A
inTransit = \u8BE5\u7EBF\u8DEF\u6B63\u5728\u8FD0\u8F93\u4E2D\uFF0C\u4E0D\u80FD\u5220\u9664 inTransit = \u8BE5\u7EBF\u8DEF\u6B63\u5728\u8FD0\u8F93\u4E2D\uFF0C\u4E0D\u80FD\u5220\u9664
bindTDL = \u8BE5\u7EBF\u8DEF\u672A\u7ED1\u5B9Atdl bindTDL = \u8BE5\u7EBF\u8DEF\u672A\u7ED1\u5B9A\u4F20\u611F\u5668
bindGateway = \u8BE5\u7EBF\u8DEF\u672A\u7ED1\u5B9A\u7F51\u5173 bindGateway = \u8BE5\u7EBF\u8DEF\u672A\u7ED1\u5B9A\u7F51\u5173
circuitDeleteSuccess = \u7EBF\u8DEF\u5220\u9664\u6210\u529F circuitDeleteSuccess = \u7EBF\u8DEF\u5220\u9664\u6210\u529F
circuitDeleteFailure = \u7EBF\u8DEF\u5220\u9664\u5931\u8D25 circuitDeleteFailure = \u7EBF\u8DEF\u5220\u9664\u5931\u8D25
...@@ -209,8 +209,8 @@ isUseing=\u8BBE\u5907\u5728\u6302\u8F7D ...@@ -209,8 +209,8 @@ isUseing=\u8BBE\u5907\u5728\u6302\u8F7D
updateGatewayCompanySuccess=\u7F51\u5173\u5206\u914D\u516C\u53F8\u6210\u529F updateGatewayCompanySuccess=\u7F51\u5173\u5206\u914D\u516C\u53F8\u6210\u529F
updateGatewayCompanyFailure=\u7F51\u5173\u5206\u914D\u516C\u53F8\u5931\u8D25 updateGatewayCompanyFailure=\u7F51\u5173\u5206\u914D\u516C\u53F8\u5931\u8D25
#TDL #TDL
TDLSN=TDL\u7F16\u53F7\u4E0D\u80FD\u4E3A\u7A7A TDLSN=\u4F20\u611F\u5668\u7F16\u53F7\u4E0D\u80FD\u4E3A\u7A7A
TDLName=TDL\u540D\u5B57\u4E0D\u80FD\u4E3A\u7A7A TDLName=\u4F20\u611F\u5668\u540D\u5B57\u4E0D\u80FD\u4E3A\u7A7A
updateTDLSuccess=\u4FEE\u6539\u7F51\u5173\u6210\u529F updateTDLSuccess=\u4FEE\u6539\u7F51\u5173\u6210\u529F
updateTDLFailure=\u4FEE\u6539\u7F51\u5173\u5931\u8D25 updateTDLFailure=\u4FEE\u6539\u7F51\u5173\u5931\u8D25
deleteTDLSuccess=\u5220\u9664\u7F51\u5173\u6210\u529F deleteTDLSuccess=\u5220\u9664\u7F51\u5173\u6210\u529F
......
...@@ -108,6 +108,13 @@ ...@@ -108,6 +108,13 @@
WHERE SN=#{SN,jdbcType=VARCHAR} AND type=#{type,jdbcType=VARCHAR} WHERE SN=#{SN,jdbcType=VARCHAR} AND type=#{type,jdbcType=VARCHAR}
</update> </update>
<!--根据仓库编号查询网关信息-->
<select id="getByWarehouseNo" parameterType="String" resultType="com.example.tdl.domain.vo.GatewayOnLineVo">
SELECT SN,type from gateway
WHERE id IN (SELECT gateway_id from gateway_warehouse where warehouse_id=(
SELECT id from warehouse WHERE warehouseNo=#{warehouseNo,jdbcType=VARCHAR}))
</select>
<!-- <insert id="addGateway" parameterType="com.example.tdl.domain.vo.AddGatewayVo"> <!-- <insert id="addGateway" parameterType="com.example.tdl.domain.vo.AddGatewayVo">
INSERT into gateway VALUES ( INSERT into gateway VALUES (
......
...@@ -106,4 +106,5 @@ ...@@ -106,4 +106,5 @@
UPDATE tdldevice set company_id=(SELECT id from company where companyNo=#{companyNo,jdbcType=VARCHAR}) UPDATE tdldevice set company_id=(SELECT id from company where companyNo=#{companyNo,jdbcType=VARCHAR})
WHERE TDLSN=#{TDLSN,jdbcType=VARCHAR} WHERE TDLSN=#{TDLSN,jdbcType=VARCHAR}
</update> </update>
</mapper> </mapper>
\ No newline at end of file
...@@ -47,17 +47,16 @@ ...@@ -47,17 +47,16 @@
select count(warehouseNo) from warehouse where warehouseNo=#{warehouseNo,jdbcType=VARCHAR} select count(warehouseNo) from warehouse where warehouseNo=#{warehouseNo,jdbcType=VARCHAR}
</select> </select>
<select id="getByWarehouseName" parameterType="String" resultType="com.example.tdl.domain.vo.ResultWarehouseVo"> <select id="getByWarehouseName" parameterType="String" resultType="com.example.tdl.domain.vo.ResultWarehouseVo">
select warehouseNo,w.img,warehouseName,c.country,c.city,CONCAT_WS("-",c.country,c.city) regions ,w.addressDetail,r.regionName,lng,lat,a.alarmType,property, select warehouseNo,w.img,warehouseName,c.country,c.city,CONCAT_WS("-",c.country,c.city) regions ,w.addressDetail,r.regionName,lng,lat,a.alarmType,property,
type,hardwareLevel,areaIndoor,areaRack,areaOutdoor,areaPlanIndoor,office,timeZone,warehouseInfo,companyName,w.remark type,hardwareLevel,areaIndoor,areaRack,areaOutdoor,areaPlanIndoor,office,timeZone,warehouseInfo,companyName,w.remark
from warehouse w,alarm a,region r,city ct ,company c from warehouse w,alarm a,region r,city ct ,company c
where c.id = w.company_id where c.id = w.company_id
and a.id = w.alarm_id and a.id = w.alarm_id
and r.id = w.region_id and r.id = w.region_id
and ct.id = w.city_id and ct.id = w.city_id
and c.companyName=#{companyName,jdbcType=VARCHAR} and c.companyName=#{companyName,jdbcType=VARCHAR}
AND warehouseName=#{warehouseName,jdbcType=VARCHAR} AND warehouseName=#{warehouseName,jdbcType=VARCHAR}
</select> </select>
<insert id="addWarehouse" parameterType="java.util.Map" statementType="CALLABLE"> <insert id="addWarehouse" parameterType="java.util.Map" statementType="CALLABLE">
...@@ -202,7 +201,7 @@ ...@@ -202,7 +201,7 @@
type,hardwareLevel,areaIndoor,areaRack,areaOutdoor,areaPlanIndoor,office,timeZone,warehouseInfo,w.remark type,hardwareLevel,areaIndoor,areaRack,areaOutdoor,areaPlanIndoor,office,timeZone,warehouseInfo,w.remark
from warehouse w,alarm a ,region r,company c,city ct from warehouse w,alarm a ,region r,company c,city ct
WHERE w.alarm_id=a.id WHERE w.alarm_id=a.id
and w.city_id =ct.id and w.city_id =ct.id
and w.region_id = r.id and w.region_id = r.id
and w.company_id= c.id and w.company_id= c.id
and a.company_id =c.id and a.company_id =c.id
...@@ -248,7 +247,15 @@ ...@@ -248,7 +247,15 @@
</select> </select>
<update id="updateImg"> <update id="updateImg">
UPDATE warehouse set img = #{img,jdbcType=VARCHAR}, updateTime =#{updateTime,mode=IN,jdbcType=BIGINT} where warehouseNo= #{warehouseNo,jdbcType=VARCHAR} UPDATE warehouse set img = #{img,jdbcType=VARCHAR}, updateTime =#{updateTime,mode=IN,jdbcType=BIGINT}
where warehouseNo= #{warehouseNo,jdbcType=VARCHAR}
</update> </update>
<select id="getWarehouseDetailByNo" parameterType="String" resultType="com.example.tdl.domain.vo.WarehouseDetailVo">
SELECT warehouseNo,warehouseName,c.country,c.city,addressDetail,(SELECT COUNT(id) from gateway_warehouse WHERE warehouse_id=w.id) gatewayCounts,
(SELECT COUNT(id) FROM tdldevice WHERE warehouse_id=w.id) tdlCounts
from warehouse w INNER JOIN city c ON w.city_id=c.id
where warehouseNo=#{warehouseNo,jdbcType=VARCHAR}
</select>
</mapper> </mapper>
\ No newline at end of file
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