Commit f4a76c00 authored by zhuangzhuang's avatar zhuangzhuang

3.19--tdl与gateway的绑定、解绑接口;获取历史数据以及实时数据的接口,修改角色的返回值

parent 5a4afdd8
package com.example.tdl.config;
import org.influxdb.dto.Point;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.influxdb.DefaultInfluxDBTemplate;
import org.springframework.data.influxdb.InfluxDBConnectionFactory;
import org.springframework.data.influxdb.InfluxDBProperties;
import org.springframework.data.influxdb.InfluxDBTemplate;
import org.springframework.data.influxdb.converter.PointConverter;
@Configuration
@EnableConfigurationProperties(value = InfluxDBProperties.class)
public class InfluxDBConfiguration {
@Bean
public InfluxDBConnectionFactory connectionFactory(final InfluxDBProperties properties)
{
return new InfluxDBConnectionFactory(properties);
}
@Bean
public InfluxDBTemplate<Point> influxDBTemplate(final InfluxDBConnectionFactory connectionFactory)
{
/*
* You can use your own 'PointCollectionConverter' implementation, e.g. in case
* you want to use your own custom measurement object.
*/
return new InfluxDBTemplate<>(connectionFactory, new PointConverter());
}
@Bean
public DefaultInfluxDBTemplate defaultTemplate(final InfluxDBConnectionFactory connectionFactory)
{
/* * If you are just dealing with Point objects from 'influxdb-java' you could
* also use an instance of class DefaultInfluxDBTemplate.*/
return new DefaultInfluxDBTemplate(connectionFactory);
}
}
package com.example.tdl.config;
import org.influxdb.InfluxDB;
import org.influxdb.InfluxDBFactory;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
@ConfigurationProperties(prefix = "tdl.influxdb")
public class Influxdbconfig {
private String user;
private String password;
private String host;
private String database;
public String getUser() {
return user;
}
public void setUser(String user) {
this.user = user;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
}
public String getDatabase() {
return database;
}
public void setDatabase(String database) {
this.database = database;
}
@Bean
public InfluxDB influxDB() {
return InfluxDBFactory.connect(host, user, password);
}
}
......@@ -202,19 +202,26 @@ public class RedisConfig extends CachingConfigurerSupport{
* @param
* @return
*/
//@SuppressWarnings({"rawtypes", "unchecked"})
@Bean
public RedisTemplate<String, String> tokenRedisTemplate() {
StringRedisTemplate template = new StringRedisTemplate(redisConnectionFactory(15));
JsonRedisSerializer(template, false);
public RedisTemplate<String, String> redisTemplate() {
StringRedisTemplate template = new StringRedisTemplate(redisConnectionFactory(0));
JsonRedisSerializer(template, true);
return template;
}
@Bean
public RedisTemplate<String, String> redisTemplate() {
public RedisTemplate<String, String> realRedisTemplate() {
StringRedisTemplate template = new StringRedisTemplate(redisConnectionFactory(1));
JsonRedisSerializer(template, true);
return template;
}
@Bean
public RedisTemplate<String, String> tokenRedisTemplate() {
StringRedisTemplate template = new StringRedisTemplate(redisConnectionFactory(15));
JsonRedisSerializer(template, false);
return template;
}
}
......@@ -2,7 +2,7 @@ package com.example.tdl.domain.vo;
public class AddAlarmLogVo {
private String routeNumber;
private String transportationNo;
private String routeName;
......@@ -15,20 +15,20 @@ public class AddAlarmLogVo {
public AddAlarmLogVo() {
}
public AddAlarmLogVo(String routeNumber, String routeName, String description, Float data, Long alarmTime) {
this.routeNumber = routeNumber;
public AddAlarmLogVo(String transportationNo, String routeName, String description, Float data, Long alarmTime) {
this.transportationNo = transportationNo;
this.routeName = routeName;
this.description = description;
this.data = data;
this.alarmTime = alarmTime;
}
public String getRouteNumber() {
return routeNumber;
public String getTransportationNo() {
return transportationNo;
}
public void setRouteNumber(String routeNumber) {
this.routeNumber = routeNumber;
public void setTransportationNo(String transportationNo) {
this.transportationNo = transportationNo;
}
public String getRouteName() {
......
package com.example.tdl.domain.vo;
public class BindingVo {
private String SN;
private String type;
private Integer mode;
private String TDLSN;
private String transportationNo;
private String warehouseNo;
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 getMode() {
return mode;
}
public void setMode(Integer mode) {
this.mode = mode;
}
public String getTDLSN() {
return TDLSN;
}
public void setTDLSN(String TDLSN) {
this.TDLSN = TDLSN;
}
public String getTransportationNo() {
return transportationNo;
}
public void setTransportationNo(String transportationNo) {
this.transportationNo = transportationNo;
}
public String getWarehouseNo() {
return warehouseNo;
}
public void setWarehouseNo(String warehouseNo) {
this.warehouseNo = warehouseNo;
}
}
......@@ -16,6 +16,26 @@ public class ConfigCMDVo {
private Long t;//配置时的时间戳
public ConfigCMDVo() {
}
public ConfigCMDVo(String action, Integer gpsPeriod, Integer gprsPeriod, List<String> devList, Integer mode) {
this.action = action;
this.gpsPeriod = gpsPeriod;
this.gprsPeriod = gprsPeriod;
this.devList = devList;
this.mode = mode;
}
public ConfigCMDVo(String action, Integer gpsPeriod, Integer gprsPeriod, List<String> devList, Integer mode, Long t) {
this.action = action;
this.gpsPeriod = gpsPeriod;
this.gprsPeriod = gprsPeriod;
this.devList = devList;
this.mode = mode;
this.t = t;
}
public String getAction() {
return action;
}
......
package com.example.tdl.domain.vo;
public class DeviceDataVo {
private String time;
private String temperature;
private String humidity;
private String pressure;
private String shockEnergy;
private String tiltAngle;
public String getTime() {
return time;
}
public void setTime(String time) {
this.time = time;
}
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 getPressure() {
return pressure;
}
public void setPressure(String pressure) {
this.pressure = pressure;
}
public String getShockEnergy() {
return shockEnergy;
}
public void setShockEnergy(String shockEnergy) {
this.shockEnergy = shockEnergy;
}
public String getTiltAngle() {
return tiltAngle;
}
public void setTiltAngle(String tiltAngle) {
this.tiltAngle = tiltAngle;
}
}
package com.example.tdl.domain.vo;
import java.util.List;
public class Humidity {
private String TDLSN;
private List<HumidityDataVo> humidityDataVoList;
public String getTDLSN() {
return TDLSN;
}
public void setTDLSN(String TDLSN) {
this.TDLSN = TDLSN;
}
public List<HumidityDataVo> getHumidityDataVoList() {
return humidityDataVoList;
}
public void setHumidityDataVoList(List<HumidityDataVo> humidityDataVoList) {
this.humidityDataVoList = humidityDataVoList;
}
}
package com.example.tdl.domain.vo;
public class HumidityDataVo {
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;
}
}
package com.example.tdl.domain.vo;
import java.util.List;
public class LiveDataVo {
private String key;
private List<ProbesVo> probesVoList;
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public List<ProbesVo> getProbesVoList() {
return probesVoList;
}
public void setProbesVoList(List<ProbesVo> probesVoList) {
this.probesVoList = probesVoList;
}
}
package com.example.tdl.domain.vo;
public class LocationDataVo {
private String time;
private Double lng;
private Double lat;
private Integer error;//0 没有预警//1 发生预警
public String getTime() {
return time;
}
public void setTime(String time) {
this.time = time;
}
public Double getLng() {
return lng;
}
public void setLng(Double lng) {
this.lng = lng;
}
public Double getLat() {
return lat;
}
public void setLat(Double lat) {
this.lat = lat;
}
public Integer getError() {
return error;
}
public void setError(Integer error) {
this.error = error;
}
}
package com.example.tdl.domain.vo;
import java.util.List;
public class LocationMessageVo {
private String transportationNo;//运输编号
private List<String> TDLSN;
private String gatewaySN;
private String startCity;
private String endCity;
private String startTime;
private String endTime;
private Long alarmTime;
private String alarmType;
private String alarmValue;
private String lng;
private String lat;
public String getTransportationNo() {
return transportationNo;
}
public void setTransportationNo(String transportationNo) {
this.transportationNo = transportationNo;
}
public List<String> getTDLSN() {
return TDLSN;
}
public void setTDLSN(List<String> TDLSN) {
this.TDLSN = TDLSN;
}
public String getGatewaySN() {
return gatewaySN;
}
public void setGatewaySN(String gatewaySN) {
this.gatewaySN = gatewaySN;
}
public String getStartCity() {
return startCity;
}
public void setStartCity(String startCity) {
this.startCity = startCity;
}
public String getEndCity() {
return endCity;
}
public void setEndCity(String endCity) {
this.endCity = endCity;
}
public String getStartTime() {
return startTime;
}
public void setStartTime(String startTime) {
this.startTime = startTime;
}
public String getEndTime() {
return endTime;
}
public void setEndTime(String endTime) {
this.endTime = endTime;
}
public Long getAlarmTime() {
return alarmTime;
}
public void setAlarmTime(Long alarmTime) {
this.alarmTime = alarmTime;
}
public String getAlarmType() {
return alarmType;
}
public void setAlarmType(String alarmType) {
this.alarmType = alarmType;
}
public String getAlarmValue() {
return alarmValue;
}
public void setAlarmValue(String alarmValue) {
this.alarmValue = alarmValue;
}
public String getLng() {
return lng;
}
public void setLng(String lng) {
this.lng = lng;
}
public String getLat() {
return lat;
}
public void setLat(String lat) {
this.lat = lat;
}
}
package com.example.tdl.domain.vo;
public class LocationVo {
private Long time;
private String transportationNo;
private String alarmType;
private String vlaue;
public Long getTime() {
return time;
}
public void setTime(Long time) {
this.time = time;
}
public String getTransportationNo() {
return transportationNo;
}
public void setTransportationNo(String transportationNo) {
this.transportationNo = transportationNo;
}
public String getAlarmType() {
return alarmType;
}
public void setAlarmType(String alarmType) {
this.alarmType = alarmType;
}
public String getVlaue() {
return vlaue;
}
public void setVlaue(String vlaue) {
this.vlaue = vlaue;
}
}
package com.example.tdl.domain.vo;
public class NumberVo {
private String transportationNo;
private String warehouseNo;
public String getTransportationNo() {
return transportationNo;
}
public void setTransportationNo(String transportationNo) {
this.transportationNo = transportationNo;
}
public String getWarehouseNo() {
return warehouseNo;
}
public void setWarehouseNo(String warehouseNo) {
this.warehouseNo = warehouseNo;
}
}
package com.example.tdl.domain.vo;
public class ProbesVo {
private Integer port;
private String unit;
private String description;
private String alias;
private String type;
private Integer alarmUp;
private Integer alarmDown;
private String value;
public Integer getPort() {
return port;
}
public void setPort(Integer port) {
this.port = port;
}
public String getUnit() {
return unit;
}
public void setUnit(String unit) {
this.unit = unit;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getAlias() {
return alias;
}
public void setAlias(String alias) {
this.alias = alias;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public Integer getAlarmUp() {
return alarmUp;
}
public void setAlarmUp(Integer alarmUp) {
this.alarmUp = alarmUp;
}
public Integer getAlarmDown() {
return alarmDown;
}
public void setAlarmDown(Integer alarmDown) {
this.alarmDown = alarmDown;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
package com.example.tdl.domain.vo;
public class RoleNameVo {
private String roleName;
public String getRoleName() {
return roleName;
}
public void setRoleName(String roleName) {
this.roleName = roleName;
}
}
package com.example.tdl.domain.vo;
import java.util.List;
public class ShockEnergy {
private String TDLSN;
private List<ShockEnergyVo> shockEnergyVoList;
public String getTDLSN() {
return TDLSN;
}
public void setTDLSN(String TDLSN) {
this.TDLSN = TDLSN;
}
public List<ShockEnergyVo> getShockEnergyVoList() {
return shockEnergyVoList;
}
public void setShockEnergyVoList(List<ShockEnergyVo> shockEnergyVoList) {
this.shockEnergyVoList = shockEnergyVoList;
}
}
package com.example.tdl.domain.vo;
public class ShockEnergyVo {
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;
}
}
package com.example.tdl.domain.vo;
import java.util.List;
public class Temperature {
private String TDLSN;
private List<TemperatureDataVo> temperatureDataVos;
public String getTDLSN() {
return TDLSN;
}
public void setTDLSN(String TDLSN) {
this.TDLSN = TDLSN;
}
public List<TemperatureDataVo> getTemperatureDataVos() {
return temperatureDataVos;
}
public void setTemperatureDataVos(List<TemperatureDataVo> temperatureDataVos) {
this.temperatureDataVos = temperatureDataVos;
}
}
package com.example.tdl.domain.vo;
public class TemperatureDataVo {
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;
}
}
package com.example.tdl.domain.vo;
import java.util.List;
public class TiltAngle {
private String TDLSN;
private List<TiltAngleVo> shockEnergyVoList;
public String getTDLSN() {
return TDLSN;
}
public void setTDLSN(String TDLSN) {
this.TDLSN = TDLSN;
}
public List<TiltAngleVo> getShockEnergyVoList() {
return shockEnergyVoList;
}
public void setShockEnergyVoList(List<TiltAngleVo> shockEnergyVoList) {
this.shockEnergyVoList = shockEnergyVoList;
}
}
package com.example.tdl.domain.vo;
public class TiltAngleVo {
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;
}
}
......@@ -4,7 +4,7 @@ public class AlarmLog {
private Integer id;
private String routeNumber;
private String transportationNo;
private String routeName;
......@@ -23,12 +23,12 @@ public class AlarmLog {
this.id = id;
}
public String getRouteNumber() {
return routeNumber;
public String getTransportationNo() {
return transportationNo;
}
public void setRouteNumber(String routeNumber) {
this.routeNumber = routeNumber;
public void setTransportationNo(String transportationNo) {
this.transportationNo = transportationNo;
}
public String getRouteName() {
......
......@@ -32,8 +32,6 @@ public class PermissionInterceptor implements HandlerInterceptor {
String contextPath = request.getContextPath();
String url = requestUri.substring(contextPath.length());
logger.info("requestUri:"+requestUri);
logger.info("contextPath:"+contextPath);
logger.info("url:"+url);
//获取用户信息以及对应的权限信息
UserVo user = gson.fromJson(redisService.get("TOKEN_" +request.getHeader("Account_token")),UserVo.class);
......
......@@ -17,4 +17,5 @@ public interface AlarmLogMapper {
//新增报警数据
int addAlarmLog(AddAlarmLogVo addAlarmLogVo);
List<AlarmLogVo> getByTransportationNo(String transportationNo);
}
package com.example.tdl.mapper;
import com.example.tdl.domain.vo.CircuitTermVo;
import com.example.tdl.domain.vo.ResultCircuitVo;
import com.example.tdl.domain.vo.ResultRouteVo;
import com.example.tdl.domain.vo.UpdateCircuitVo;
import com.example.tdl.domain.vo.*;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
......@@ -24,4 +21,6 @@ public interface CircuitMapper {
int delCircuit(String transportationNo);
ResultCircuitVo getByTransportationNo(String transportation);
ResultGatewayVo getByNo(String transportationNo);
}
......@@ -4,10 +4,14 @@ import com.example.tdl.domain.vo.ConfigVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.Map;
@Mapper
public interface ConfigMapper {
int addConfig(ConfigVo configVo);
// int addConfig(ConfigVo configVo);
int addConfig(Map<Object,Object> map);
ConfigVo getConfig(@Param("gSN") String gSN, @Param("gType") String gType);
......@@ -15,5 +19,6 @@ public interface ConfigMapper {
int bindiSuccess(@Param("gSN") String gSN,@Param("gType") String gType,@Param("resp") Integer resp);
int updateConfig(@Param("gSN") String gSN,@Param("gType") String gType,@Param("untie") Boolean untie);
//int updateConfig(@Param("gSN") String gSN,@Param("gType") String gType,@Param("untie") Boolean untie);
int updateConfig(Map<Object,Object> map);
}
package com.example.tdl.mapper;
import com.example.tdl.domain.vo.ProbesVo;
import com.example.tdl.domain.vo.ResultProbesVo;
import com.example.tdl.domain.vo.UpdateProbesVo;
import org.apache.ibatis.annotations.Mapper;
......@@ -26,6 +27,8 @@ public interface ProbesMapper {
List<String> getNameByAliasList(@Param("SN") String SN, @Param("type") String type, @Param("aliasList") List<String> aliasList);
List<ProbesVo> getByAliasList(@Param("SN") String SN, @Param("type") String type, @Param("aliasList") List<String> aliasList);
Integer getCountByGateway(@Param("SN") String SN, @Param("type") String type);
int addProbes(Map<String, Object> map);
......
package com.example.tdl.mapper;
import com.example.tdl.domain.vo.RoleNameVo;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface RoleMapper {
List<String> getAllRoleName();
List<RoleNameVo> getAllRoleName();
Integer getByRoleName(String roleName);
}
......@@ -6,6 +6,7 @@ import com.example.tdl.domain.vo.ResultTDLDeviceVo;
import com.example.tdl.domain.vo.TDLDeviceTermVo;
import com.example.tdl.domain.vo.UpdateTDLDeviceVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
......@@ -22,4 +23,6 @@ public interface TDLDeviceMapper {
int delTDLDevice(String TDLSN);
ResultTDLDeviceVo getByTDLSN(String TDLSN);
List<String> getByGatewaySN(@Param("SN") String SN, @Param("type") String type);
}
......@@ -9,7 +9,7 @@ import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class AlarmLogServcie {
public class AlarmLogService {
@Autowired
private AlarmLogMapper alarmLogMapper;
......@@ -26,5 +26,9 @@ public class AlarmLogServcie {
return alarmLogMapper.addAlarmLog(addAlarmLogVo);
}
public List<AlarmLogVo> getByTransportationNo(String transportationNo){
return alarmLogMapper.getByTransportationNo(transportationNo);
}
}
package com.example.tdl.service;
import com.example.tdl.domain.vo.AddCircuitVo;
import com.example.tdl.domain.vo.CircuitTermVo;
import com.example.tdl.domain.vo.ResultCircuitVo;
import com.example.tdl.domain.vo.UpdateCircuitVo;
import com.example.tdl.domain.vo.*;
import com.example.tdl.mapper.CircuitMapper;
import com.example.tdl.mapper.RoleMapper;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -46,4 +43,8 @@ public class CircuitService {
return circuitMapper.getByTransportationNo(transportationNo);
}
public ResultGatewayVo getByNo(String transportationNo){
return circuitMapper.getByNo(transportationNo);
}
}
......@@ -5,6 +5,8 @@ import com.example.tdl.mapper.ConfigMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Map;
@Service
public class ConfigService {
......@@ -12,8 +14,12 @@ public class ConfigService {
private ConfigMapper configMapper;
//绑定getway和tdl
public int addConfig(ConfigVo configVo){
/* public int addConfig(ConfigVo configVo){
return configMapper.addConfig(configVo);
}*/
public int addConfig(Map<Object,Object> map){
return configMapper.addConfig(map);
}
......@@ -28,8 +34,12 @@ public class ConfigService {
}
//解绑getWay和tdl
public int updateConfig(String gSN,String gType,Boolean untie ){
return configMapper.updateConfig(gSN,gType,untie);
// public int updateConfig(String gSN,String gType,Boolean untie ){
// return configMapper.updateConfig(gSN,gType,untie);
// }
public int updateConfig(Map<Object,Object> map ){
return configMapper.updateConfig(map);
}
//解绑成功
......
package com.example.tdl.service;
import com.example.tdl.config.Influxdbconfig;
import org.influxdb.InfluxDB;
import org.influxdb.dto.BatchPoints;
import org.influxdb.dto.Point;
import org.influxdb.dto.Query;
import org.influxdb.dto.QueryResult;
import org.influxdb.dto.QueryResult.Result;
import org.influxdb.dto.QueryResult.Series;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
@Service("influxdbService")
public class InfluxDBService {
@Autowired
Influxdbconfig influxdbconfig;
@Autowired
private InfluxDB influxDB;
public final static String DEFAULT_DATABASE = "original";
public final static String DEFAULT_POLICY = "witium_policy";
private final static String DEFAULT_DURATION = "0d";
private final static String DEFAULT_SHARD_DURATION = "90d";
private String mPolicyName = DEFAULT_POLICY;
private String mDBName = DEFAULT_DATABASE;
public void connectDatabase(String dbname) {
if(!dbname.isEmpty() && dbname != null)
{
useDatabase(dbname);
useRetentionPolicy(mPolicyName);
}
}
/* Create the database if it is not exist. */
private void createDatabase(String database) {
if (database != null && !database.isEmpty()) {
if (!influxDB.databaseExists(database)) {
influxDB.createDatabase(database);
}
}
}
public void useDatabase(String database) {
if (!influxDB.databaseExists(database)) {
createDatabase(database);
}
influxdbconfig.setDatabase(database);
mDBName = database;
}
public List<String> showRetentionPolicys() {
String command = String.format("SHOW RETENTION POLICIES ON \"%s\"",
mDBName);
QueryResult results = this.query(command);
List<String> policys = new ArrayList<String>();
for (Result result : results.getResults()) {
List<Series> series = result.getSeries();
for (Series serie : series) {
List<List<Object>> values = serie.getValues();
for (List<Object> value : values) {
policys.add(0, (String)value.get(0));
}
}
}
return policys;
}
/* Judge whether policy is exist. */
public boolean isRetentionPolicyExist(String policyname) {
boolean isExist = false;
List<String> policys;
policys = showRetentionPolicys();
for (String policy : policys) {
if (policy.equals(policyname)) {
isExist = true;
break;
}
}
return isExist;
}
public void useRetentionPolicy(String policy) {
mPolicyName = policy;
if (!isRetentionPolicyExist(policy)) {
createRetentionPolicy(DEFAULT_DURATION, DEFAULT_SHARD_DURATION, 1, true);
}
}
/**
* 创建保存策略 <br/>
* CREATE RETENTION POLICY "default" ON "database" DURATION 30d REPLICATION 1 DEFAULT
*
* @param duration 存放时间
* @param replicationNum 备份数量
*/
public void createRetentionPolicy(String duration, Integer replicationNum, Boolean isDefault) {
if (mPolicyName != null && !mPolicyName.isEmpty()
&& mDBName != null && !mDBName.isEmpty()) {
String command = String.format("CREATE RETENTION POLICY \"%s\" ON \"%s\" DURATION %s REPLICATION %s %s",
mPolicyName, mDBName, duration, replicationNum, isDefault ? "DEFAULT" : "");
this.query(command);
}
}
/**
* 创建保存策略 <br/>
* CREATE RETENTION POLICY "default" ON "database" DURATION 30d SHARD DURATION %s REPLICATION 1 DEFAULT
*
* @param duration 存放时间
* @param shardGroupDuration 存放快速读取组时间
* @param replicationNum 备份数量
*/
public void createRetentionPolicy(String duration, String shardGroupDuration, Integer replicationNum,
Boolean isDefault) {
if (mPolicyName != null && !mPolicyName.isEmpty()
&& mDBName != null && !mDBName.isEmpty()) {
String command = String.format("CREATE RETENTION POLICY \"%s\" ON \"%s\" DURATION %s SHARD DURATION %s REPLICATION %s %s",
mPolicyName, mDBName, duration, shardGroupDuration, replicationNum, isDefault ? "DEFAULT" : "");
this.query(command);
}
}
/**
* 插入数据
*
* @param measurement a Point in a fluent manner
* @param tagsToAdd the Map of tags to add
* @param fields the fields to add
*/
public void insert(String measurement, Long timestamp, Map<String, String> tagsToAdd, Map<String, Object> fields) {
if (measurement != null && !measurement.isEmpty()
&& tagsToAdd != null && !tagsToAdd.isEmpty()
&& fields != null && !fields.isEmpty()) {
Point.Builder builder = Point.measurement(measurement)
.time(timestamp, TimeUnit.MILLISECONDS)
.tag(tagsToAdd)
.fields(fields);
try {
influxDB.write(mDBName, mPolicyName, builder.build());
} catch (RuntimeException e) {
// TODO: handle exception
e.printStackTrace();
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
}
public void insertBatchWithMultiTags(String dbname, String measurement, Long[] timestamp,
List<Map<String, String>> tagsToAdd, List<Map<String, Object>> fields)
{
if (measurement != null && !measurement.isEmpty()
&& tagsToAdd != null && !tagsToAdd.isEmpty()
&& fields != null && !fields.isEmpty()) {
BatchPoints batchPoints = BatchPoints.database(dbname)
.retentionPolicy(mPolicyName)
.consistency(InfluxDB.ConsistencyLevel.ALL)
.build();
for (int i = 0; i < tagsToAdd.size(); i++)
{
Point pointdata = Point.measurement(measurement)
.time(timestamp[i], TimeUnit.MILLISECONDS)
.tag(tagsToAdd.get(i))
.fields(fields.get(i))
.build();
batchPoints.point(pointdata);
}
try {
influxDB.write(batchPoints);
} catch (RuntimeException e) {
// TODO: handle exception
e.printStackTrace();
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
}
public void insertBatchWithSameTags(String dbname, String measurement, Long[] timestamp,
Map<String, String> tagsToAdd, List<Map<String, Object>> fields)
{
if (measurement != null && !measurement.isEmpty()
&& tagsToAdd != null && !tagsToAdd.isEmpty()
&& fields != null && !fields.isEmpty()) {
BatchPoints batchPoints = BatchPoints.database(dbname)
.retentionPolicy(mPolicyName)
.consistency(InfluxDB.ConsistencyLevel.ALL)
.build();
for (int i = 0; i < fields.size(); i++)
{
Point pointdata = Point.measurement(measurement)
.time(timestamp[i], TimeUnit.MILLISECONDS)
.tag(tagsToAdd)
.fields(fields.get(i))
.build();
if(pointdata != null)
{
batchPoints.point(pointdata);
}
}
try {
influxDB.write(batchPoints);
} catch (RuntimeException e) {
// TODO: handle exception
e.printStackTrace();
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
}
/**
* 查询数据
*
* @param command
* @return QueryResult
*/
public QueryResult query(String command) {
return influxDB.query(new Query(command, mDBName));
}
}
package com.example.tdl.service;
import com.example.tdl.domain.vo.ProbesVo;
import com.example.tdl.domain.vo.ResultProbesVo;
import com.example.tdl.domain.vo.UpdateProbesVo;
import com.example.tdl.mapper.ProbesMapper;
......@@ -47,6 +48,10 @@ public class ProbesService {
return probesMapper.getNameByAliasList(SN, type,aliasList);
}
public List<ProbesVo> getByAliasList(String SN, String type, List<String> aliasList){
return probesMapper.getByAliasList(SN, type,aliasList);
}
public Integer getCountByGateway(String SN, String type){
return probesMapper.getCountByGateway(SN,type);
}
......
package com.example.tdl.service;
import com.example.tdl.domain.vo.RoleNameVo;
import com.example.tdl.mapper.RoleMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -12,7 +13,7 @@ public class RoleService {
@Autowired
private RoleMapper roleMapper;
public List<String> getAllRoleName(){
public List<RoleNameVo> getAllRoleName(){
return roleMapper.getAllRoleName();
}
......
......@@ -38,4 +38,8 @@ public class TDLDeviceService {
public ResultTDLDeviceVo getByTDLSN(String TDLSN){
return tdlDeviceMapper.getByTDLSN(TDLSN);
}
public List<String> getByGatewaySN(String SN,String type){
return tdlDeviceMapper.getByGatewaySN(SN,type);
}
}
package com.example.tdl.service.redis;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
@Service
public class RealRedisService extends RedisService {
@SuppressWarnings({ "unchecked", "rawtypes" })
@Autowired
public RealRedisService(RedisTemplate realRedisTemplate) {
super(realRedisTemplate);
}
}
......@@ -123,10 +123,6 @@ public class RedisService {
return result;
}
/**
* 获取此数据库所有的Keys表
* @return
*/
public Object getAllKeys() {
Object ret = null;
try {
......@@ -137,55 +133,28 @@ public class RedisService {
return ret;
}
/**
* 批量删除对应的value
*
* @param keys
*/
public void remove(final String... keys) {
for (String key : keys) {
remove(key);
}
}
/**
* 批量删除key
*
* @param pattern
*/
public void removePattern(final String pattern) {
Set<Serializable> keys = redisTemplate.keys(pattern);
if (keys.size() > 0)
redisTemplate.delete(keys);
}
/**
* 删除对应的value
*
* @param key
*/
public void remove(final String key) {
if (exists(key)) {
redisTemplate.delete(key);
}
}
/**
* 判断缓存中是否有对应的value
*
* @param key
* @return
*/
public boolean exists(final String key) {
return redisTemplate.hasKey(key);
}
/**
* 读取缓存
*
* @param key
* @return
*/
public String get(final String key) {
String result = null;
try {
......@@ -198,13 +167,6 @@ public class RedisService {
return result;
}
/**
* 写入缓存
*
* @param key
* @param value
* @return
*/
public boolean set(final String key, Object value) {
boolean result = false;
try {
......@@ -218,19 +180,11 @@ public class RedisService {
return result;
}
/**
* 写入缓存
*
* @param key
* @param value
* @return
*/
public boolean set(final String key, Object value, long expireTime) {
boolean result = false;
try {
ValueOperations<Serializable, Object> operations = redisTemplate.opsForValue();
operations.set(key, value);
//logger.info("[key:" + key + "],[value:" + value + "]");
redisTemplate.expire(key, expireTime, TimeUnit.SECONDS);
result = true;
} catch (Exception e) {
......@@ -240,12 +194,6 @@ public class RedisService {
return result;
}
/**
* 更新过期时间
*
* @param key
* @return
*/
public boolean refeshTimeOut(String key, long expireTime) {
boolean f = false;
try {
......@@ -258,7 +206,6 @@ public class RedisService {
return f;
}
//删除key
public void delKey(final String... key){
if(key!=null && key.length > 0){
if(key.length == 1){
......@@ -268,4 +215,5 @@ public class RedisService {
}
}
}
}
......@@ -2,7 +2,7 @@ package com.example.tdl.web;
import com.example.tdl.domain.dto.CommFeedback;
import com.example.tdl.domain.vo.AddAlarmLogVo;
import com.example.tdl.service.AlarmLogServcie;
import com.example.tdl.service.AlarmLogService;
import com.google.gson.Gson;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
......@@ -23,7 +23,7 @@ public class AlarmLogController {
CommFeedback fb=new CommFeedback();
@Autowired
private AlarmLogServcie alarmLogServcie;
private AlarmLogService alarmLogServcie;
//获取所有的报警数据
@GetMapping("/getAll")
......@@ -40,9 +40,9 @@ public class AlarmLogController {
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
})
public Object addAlarmLog(@RequestBody AddAlarmLogVo addAlarmLogVo){
if(StringUtils.isEmpty(addAlarmLogVo.getRouteNumber())){
if(StringUtils.isEmpty(addAlarmLogVo.getTransportationNo())){
fb.setCode(0);
fb.setMessage("路由编号不能为空");
fb.setMessage("运输编号不能为空");
return gson.toJson(fb);
}
if(StringUtils.isEmpty(addAlarmLogVo.getRouteName())){
......
......@@ -2,15 +2,28 @@ package com.example.tdl.web;
import com.example.tdl.domain.dto.CommFeedback;
import com.example.tdl.service.GatewayService;
import com.example.tdl.service.InfluxDBService;
import com.example.tdl.service.redis.RedisService;
import com.example.tdl.domain.vo.*;
import com.example.tdl.service.*;
import com.example.tdl.service.redis.RealRedisService;
import com.google.gson.Gson;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.influxdb.dto.Query;
import org.influxdb.dto.QueryResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.data.influxdb.InfluxDBTemplate;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
@RestController
public class DataController {
private Logger logger = LoggerFactory.getLogger(DataController.class);
......@@ -23,12 +36,482 @@ public class DataController {
private GatewayService gatewayService;
@Autowired
private RedisService redisService;
private TDLDeviceService tdlDeviceService;
@Autowired
private ProbesService probesService;
@Autowired
private RealRedisService realRedisService;
@Autowired
private InfluxDBTemplate influxDBTemplate;
@Autowired
private AlarmLogService alarmLogService;
@Autowired
private InfluxDBService influxDBService;
private CircuitService circuitService;
private String database ="original";
//获取实时数据
@ApiOperation(value = "获取实时数据",notes = "获取实时数据")
@ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
})
@PostMapping("/getRealTimeData")
public Object getRealTimeData(@RequestBody String transportationNo){
//获取gateway的信息
ResultGatewayVo gatewayVo = circuitService.getByNo(transportationNo);
//获取tdl信息
List<String> devList = tdlDeviceService.getByGatewaySN(gatewayVo.getSN(),gatewayVo.getType());
// String gSN = "20180314";
// String gType = "WTD93LG";
//根据gateWay获取tdl信息
List<String> key = new ArrayList<>();
key.add(gatewayVo.getSN()+"_"+gatewayVo.getType() +":"+gatewayVo.getSN()+"_"+gatewayVo.getType());
for (int i = 0;i<devList.size();i++){
key.add(gatewayVo.getSN()+"_"+gatewayVo.getType()+":"+devList.get(i));
}
List<LiveDataVo> liveDataVos = new ArrayList<>();
for(int j=0;j<key.size();j++){
Map<Object,Object> ret = realRedisService.getHashAll(key.get(j));
if(ret == null){
continue;
}else{
Iterator entries = ret.entrySet().iterator();
List<String> aliasList = new ArrayList<>();
List<String> valueList = new ArrayList<>();
while(entries.hasNext()){
Map.Entry entry = (Map.Entry) entries.next();
aliasList.add((String) entry.getKey());
valueList.add((String) entry.getValue());
}
//根据通道别名获取通道信息
List<ProbesVo> probesVoList = probesService.getByAliasList(gatewayVo.getSN(),gatewayVo.getType(),aliasList);
for(int m = 0;m<probesVoList.size();m++){
probesVoList.get(m).setValue(valueList.get(m));
}
LiveDataVo liveDataVo = new LiveDataVo();
liveDataVo.setKey(key.get(j).substring(key.get(j).indexOf(":"),key.get(j).length()));
liveDataVo.setProbesVoList(probesVoList);
liveDataVos.add(liveDataVo);
}
}
return gson.toJson(liveDataVos);
}
//获取坐标数据数据
@ApiOperation(value = "获取坐标数据数据",notes = "获取坐标数据数据" +
"time:时间" +
"lng:经度" +
"lat: 纬度")
@PostMapping("/getLocation")
@ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
})
public Object getLocation(@RequestBody String transportationNo){
//获取gateway的信息
ResultGatewayVo gatewayVo = circuitService.getByNo(transportationNo);
String device = gatewayVo.getType() +"_" +gatewayVo.getSN();
//获取tdl信息
// List<String> devList = tdlDeviceService.getByGatewaySN(gatewayVo.getSN(),gatewayVo.getType());
String sql = "SELECT \"lng\",\"lat\" FROM \"tdl_policy\".\""+device+"\"ORDER BY time ";
QueryResult queryResult = influxDBTemplate.query(new Query(sql,database));
//解析经纬度数据
List<LocationDataVo> locationDataVos = new ArrayList<>();
if(queryResult.getResults().get(0).getSeries() != null){
locationDataVos=getLocation(queryResult);
}
return gson.toJson(locationDataVos);
}
//根据运输编号获取路线以及设备信息
@PostMapping("/getCircuit")
@ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
})
public Object getCircuit(@RequestBody String transportationNo){
//根据运输编号获取线路信息,设备信息
//获取gateway的信息
ResultGatewayVo gatewayVo = circuitService.getByNo(transportationNo);
String device = gatewayVo.getType() +"_" +gatewayVo.getSN();
//获取tdl信息
// List<String> devList = tdlDeviceService.getByGatewaySN(gatewayVo.getSN(),gatewayVo.getType());
String key=gatewayVo.getSN()+"_"+gatewayVo.getType() +":"+gatewayVo.getSN()+"_"+gatewayVo.getType() ;
//获取网关以及TDL的电量
return gson.toJson(fb);
}
//获取温度数据
@ApiOperation(value = "获取温度数据",notes = "获取温度数据")
@PostMapping("/getTemperature")
@ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
})
public Object getTemperature(@RequestBody String transportationNo){
ResultGatewayVo gatewayVo = circuitService.getByNo(transportationNo);
String device = gatewayVo.getType() +"_" +gatewayVo.getSN();
//获取tdl信息
List<String> devList = tdlDeviceService.getByGatewaySN(gatewayVo.getSN(),gatewayVo.getType());
String devcie=gatewayVo.getType()+"_"+gatewayVo.getSN() ;
//SELECT "h" FROM "tdl_policy"."WTD93LG_20180314" WHERE "tdl" = 'tdl-0A0B0C0D0F' ORDER BY time DESC
if(devList.size() == 0){
fb.setCode(0);
fb.setMessage("没有数据");
return gson.toJson(fb);
}
List<Temperature> temperatures = new ArrayList<>();
for( int i =0;i<devList.size();i++){
Temperature temperature = new Temperature();
temperature.setTDLSN(devList.get(i));
String sql = "SELECT \"t\" FROM \"tdl_policy\".\""+devcie+"\" where \"tdl\"=\'"+devList.get(i)+"\' ORDER BY time ";
QueryResult queryResult = influxDBTemplate.query(new Query(sql,database));
List<TemperatureDataVo> temperatureDataVos = new ArrayList<>();
if(queryResult.getResults().get(0).getSeries() != null){
//解析数据
temperatureDataVos = getTemperature(queryResult);
}
temperature.setTemperatureDataVos(temperatureDataVos);
temperatures.add(temperature);
}
/*String sql = "SELECT \"t\" FROM \"tdl_policy\".\""+devcie+"\" ORDER BY time ";
QueryResult queryResult = influxDBTemplate.query(new Query(sql,database));
List<TemperatureDataVo> temperatureDataVos = new ArrayList<>();
if(queryResult.getResults().get(0).getSeries() != null){
//解析数据
temperatureDataVos = getTemperature(queryResult);
}*/
return gson.toJson(temperatures);
}
//获取湿度数据
@ApiOperation(value = "获取湿度数据",notes = "获取湿度数据")
@PostMapping("/getHumidity")
@ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
})
public Object getHumidity(@RequestBody String transportationNo){
ResultGatewayVo gatewayVo = circuitService.getByNo(transportationNo);
String device = gatewayVo.getType() +"_" +gatewayVo.getSN();
//获取tdl信息
List<String> devList = tdlDeviceService.getByGatewaySN(gatewayVo.getSN(),gatewayVo.getType());
String devcie=gatewayVo.getType()+"_"+gatewayVo.getSN() ;
if(devList.size() == 0){
fb.setCode(0);
fb.setMessage("没有数据");
return gson.toJson(fb);
}
List<Humidity> humidities = new ArrayList<>();
for( int i =0;i<devList.size();i++){
Humidity humidity = new Humidity();
humidity.setTDLSN(devList.get(i));
String sql = "SELECT \"h\" FROM \"tdl_policy\".\""+devcie+"\" where \"tdl\"=\'"+devList.get(i)+"\' ORDER BY time ";
QueryResult queryResult = influxDBTemplate.query(new Query(sql,database));
List<HumidityDataVo> humidityDataVos = new ArrayList<>();
if(queryResult.getResults().get(0).getSeries() != null){
//解析数据
humidityDataVos = getHumidity(queryResult);
}
humidity.setHumidityDataVoList(humidityDataVos);
humidities.add(humidity);
}
// //SELECT "h" FROM "tdl_policy"."WTD93LG_20180314" WHERE "tdl" = 'tdl-0A0B0C0D0F' ORDER BY time DESC
// String sql = "SELECT \"h\" FROM \"tdl_policy\".\""+devcie+"\" ORDER BY time ";
// QueryResult queryResult = influxDBTemplate.query(new Query(sql,database));
// List<HumidityDataVo> humidityDataVos = new ArrayList<>();
// if(queryResult.getResults().get(0).getSeries() != null){
// //解析数据
// humidityDataVos = getHumidity(queryResult);
// }
return gson.toJson(humidities);
}
//获取倾斜度数据
@ApiOperation(value = "获取倾斜度数据",notes = "获取倾斜度数据")
@PostMapping("/getTiltAngle")
@ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
})
public Object getTiltAngle(@RequestBody String transportationNo){
ResultGatewayVo gatewayVo = circuitService.getByNo(transportationNo);
String device = gatewayVo.getType() +"_" +gatewayVo.getSN();
//获取tdl信息
List<String> devList = tdlDeviceService.getByGatewaySN(gatewayVo.getSN(),gatewayVo.getType());
String devcie=gatewayVo.getType()+"_"+gatewayVo.getSN() ;
if(devList.size() == 0){
fb.setCode(0);
fb.setMessage("没有数据");
return gson.toJson(fb);
}
List<TiltAngle> tiltAngles = new ArrayList<>();
for( int i =0;i<devList.size();i++){
TiltAngle tiltAngle = new TiltAngle();
tiltAngle.setTDLSN(devList.get(i));
String sql = "SELECT \"ta\" FROM \"tdl_policy\".\""+devcie+"\" where \"tdl\"=\'"+devList.get(i)+"\' ORDER BY time ";
QueryResult queryResult = influxDBTemplate.query(new Query(sql,database));
List<TiltAngleVo> tiltAngleVos = new ArrayList<>();
if(queryResult.getResults().get(0).getSeries() != null){
//解析数据
tiltAngleVos = getTiltAngle(queryResult);
}
tiltAngle.setShockEnergyVoList(tiltAngleVos);
tiltAngles.add(tiltAngle);
}
// String sql = "SELECT \"ta\" FROM \"tdl_policy\".\""+devcie+"\" ORDER BY time ";
// QueryResult queryResult = influxDBTemplate.query(new Query(sql,database));
// List<TiltAngleVo> tiltAngleVos = new ArrayList<>();
// if(queryResult.getResults().get(0).getSeries() != null){
// //解析数据
// tiltAngleVos = getTiltAngle(queryResult);
// }
return gson.toJson(tiltAngles);
}
//获取震动能量
@ApiOperation(value = "获取震动能量",notes = "获取震动能量")
@PostMapping("/getShockEnergy")
@ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
})
public Object getShockEnergy(@RequestBody String transportationNo){
ResultGatewayVo gatewayVo = circuitService.getByNo(transportationNo);
String device = gatewayVo.getType() +"_" +gatewayVo.getSN();
//获取tdl信息
List<String> devList = tdlDeviceService.getByGatewaySN(gatewayVo.getSN(),gatewayVo.getType());
String devcie=gatewayVo.getType()+"_"+gatewayVo.getSN() ;
if(devList.size() == 0){
fb.setCode(0);
fb.setMessage("没有数据");
return gson.toJson(fb);
}
List<ShockEnergy> shockEnergies = new ArrayList<>();
for( int i =0;i<devList.size();i++){
ShockEnergy shockEnergy = new ShockEnergy();
shockEnergy.setTDLSN(devList.get(i));
String sql = "SELECT \"a0\" FROM \"tdl_policy\".\""+devcie+"\" where \"tdl\"=\'"+devList.get(i)+"\' ORDER BY time ";
QueryResult queryResult = influxDBTemplate.query(new Query(sql,database));
List<ShockEnergyVo> shockEnergyVos = new ArrayList<>();
if(queryResult.getResults().get(0).getSeries() != null){
//解析数据
shockEnergyVos = getShockEnergy(queryResult);
}
shockEnergy.setShockEnergyVoList(shockEnergyVos);
shockEnergies.add(shockEnergy);
}
// String sql = "SELECT \"a0\" FROM \"tdl_policy\".\""+devcie+"\" ORDER BY time ";
// QueryResult queryResult = influxDBTemplate.query(new Query(sql,database));
// List<ShockEnergyVo> shockEnergyVos = new ArrayList<>();
// if(queryResult.getResults().get(0).getSeries() != null){
// //解析数据
// shockEnergyVos = getShockEnergy(queryResult);
// }
return gson.toJson(shockEnergies);
}
//根据运输编号获取所有的报警数据
@ApiOperation(value = "根据运输编号获取所有的报警数据????",notes = "根据运输编号获取所有的报警数据")
@PostMapping("/getAlarmData")
@ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
})
public Object getAlarmData(@RequestBody String transportationNo){
//根据运输编号获取报警信息
List<AlarmLogVo> alarmLogVoList = alarmLogService.getByTransportationNo(transportationNo);
return gson.toJson(alarmLogVoList);
}
//根据时间获取经纬度信息
@ApiOperation(value = "获取震动能量",notes = "获取震动能量")
@PostMapping("/getLocationByTime")
@ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
})
public Object getLocationByTime(@RequestBody LocationVo locationVo ){
//获取线路信息
//获取网关以及tdl信息
ResultGatewayVo gatewayVo = circuitService.getByNo(locationVo.getTransportationNo());
ResultCircuitVo resultCircuitVo = circuitService.getByTransportationNo(locationVo.getTransportationNo());
String device = gatewayVo.getType() +"_" +gatewayVo.getSN();
//获取tdl信息
List<String> devList = tdlDeviceService.getByGatewaySN(gatewayVo.getSN(),gatewayVo.getType());
String devcie=gatewayVo.getType()+"_"+gatewayVo.getSN() ;
//根据时间获取坐标信息
String sql ="SELECT \"lng\",\"lat\" FROM \"tdl_policy\".\""+devcie+"\" where time = "+locationVo.getTime() *1000000l;
QueryResult queryResult = influxDBTemplate.query(new Query(sql,database));
List<LocationMessageVo> locationDataVos = new ArrayList<>();
if(queryResult.getResults().get(0).getSeries() != null){
List<List<Object>> values = getValues(queryResult);
for(List<Object> value:values){
LocationMessageVo messageVo = new LocationMessageVo();
messageVo.setTransportationNo(locationVo.getTransportationNo());
messageVo.setGatewaySN(gatewayVo.getSN());
messageVo.setTDLSN(devList);
messageVo.setStartCity(resultCircuitVo.getStartCity());
messageVo.setEndCity(resultCircuitVo.getEndCity());
messageVo.setStartTime(resultCircuitVo.getStartTime());
messageVo.setEndTime(resultCircuitVo.getEndTime());
messageVo.setAlarmTime(Long.valueOf(parseTime(value.get(0).toString())));
messageVo.setAlarmType(locationVo.getAlarmType());
messageVo.setAlarmValue(locationVo.getVlaue());
messageVo.setLng(value.get(1)==null ? value.get(1).toString() : "");
messageVo.setLat(value.get(2)==null ? value.get(2).toString() : "");
locationDataVos.add(messageVo);
}
}
return gson.toJson(locationDataVos);
}
//获取温度、湿度、震动强度、震动能量、倾斜度
@PostMapping("/getDeviceData")
@ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
})
public Object getDeviceData(@RequestBody String transportationNo){
//获取网关以及tdl信息
ResultGatewayVo gatewayVo = circuitService.getByNo(transportationNo);
String device = gatewayVo.getType() +"_" +gatewayVo.getSN();
//获取tdl信息
List<String> devList = tdlDeviceService.getByGatewaySN(gatewayVo.getSN(),gatewayVo.getType());
String devcie=gatewayVo.getType()+"_"+gatewayVo.getSN() ;
//SELECT "h" FROM "tdl_policy"."WTD93LG_20180314" WHERE "tdl" = 'tdl-0A0B0C0D0F' ORDER BY time DESC
String sql = "SELECT \"t\",\"h\",\"p\",\"a0\",\"ta\" FROM \"tdl_policy\".\""+devcie+"\" where \"tdl\" = \'"+devList.get(0)+"\' ORDER BY time ";
QueryResult queryResult = influxDBTemplate.query(new Query(sql,database));
//解析经纬度数据
List<DeviceDataVo> deviceDataVos = new ArrayList<>();
if(queryResult.getResults().get(0).getSeries() != null){
deviceDataVos= getDeviceData(queryResult);
}
return gson.toJson(deviceDataVos);
}
//解析数据
public List<LocationDataVo> getLocation(QueryResult queryResult){
List<List<Object>> values = getValues(queryResult);
List<LocationDataVo> historyDataList = new ArrayList<>();
for(List<Object> value:values){
LocationDataVo historyData = new LocationDataVo();
historyData.setTime(parseTime(value.get(0).toString()));
historyData.setLng(Double.parseDouble(value.get(1).toString()));
historyData.setLat(Double.parseDouble(value.get(2).toString()));
historyData.setError(0);//没有预警
historyDataList.add(historyData);
}
return historyDataList;
}
public List<DeviceDataVo> getDeviceData(QueryResult queryResult){
List<List<Object>> values = getValues(queryResult);
List<DeviceDataVo> historyDataList = new ArrayList<>();
for(List<Object> value:values){
DeviceDataVo historyData = new DeviceDataVo();
historyData.setTime(parseTime(value.get(0).toString()));
historyData.setTemperature(value.get(1)==null ? "" :value.get(1).toString());
historyData.setHumidity(value.get(2)==null ? "" :value.get(2).toString());
historyData.setPressure(value.get(3)==null ? "" :value.get(3).toString());
historyData.setShockEnergy(value.get(4)==null ? "" :value.get(4).toString());
historyData.setTiltAngle(value.get(5)==null ? "" :value.get(5).toString());
historyDataList.add(historyData);
}
return historyDataList;
}
public List<TemperatureDataVo> getTemperature(QueryResult queryResult){
List<List<Object>> values = getValues(queryResult);
List<TemperatureDataVo> historyDataList = new ArrayList<>();
for(List<Object> value:values){
TemperatureDataVo historyData = new TemperatureDataVo();
historyData.setTime(parseTime(value.get(0).toString()));
historyData.setValue(value.get(1)==null ? "" :value.get(1).toString());
historyDataList.add(historyData);
}
return historyDataList;
}
public List<TiltAngleVo> getTiltAngle(QueryResult queryResult){
List<List<Object>> values = getValues(queryResult);
List<TiltAngleVo> historyDataList = new ArrayList<>();
for(List<Object> value:values){
TiltAngleVo historyData = new TiltAngleVo();
historyData.setTime(parseTime(value.get(0).toString()));
historyData.setValue(value.get(1)==null ? "" :value.get(1).toString());
historyDataList.add(historyData);
}
return historyDataList;
}
public List<ShockEnergyVo> getShockEnergy(QueryResult queryResult){
List<List<Object>> values = getValues(queryResult);
List<ShockEnergyVo> historyDataList = new ArrayList<>();
for(List<Object> value:values){
ShockEnergyVo historyData = new ShockEnergyVo();
historyData.setTime(parseTime(value.get(0).toString()));
historyData.setValue(value.get(1)==null ? "" :value.get(1).toString());
historyDataList.add(historyData);
}
return historyDataList;
}
public List<HumidityDataVo> getHumidity(QueryResult queryResult){
List<List<Object>> values = getValues(queryResult);
List<HumidityDataVo> historyDataList = new ArrayList<>();
for(List<Object> value:values){
HumidityDataVo historyData = new HumidityDataVo();
historyData.setTime(parseTime(value.get(0).toString()));
historyData.setValue(value.get(1)==null ? "" :value.get(1).toString());
historyDataList.add(historyData);
}
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;
}
//将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());
}
//解析时间
public String parseTime(String time){
String dateResult =null;
try {
dateResult = dateToStamp(time);
} catch (Exception e) {
e.printStackTrace();
logger.info(e.toString());
fb.setCode(0);
fb.setMessage("解析时间异常");
}
return dateResult;
}
}
\ No newline at end of file
package com.example.tdl.web;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.FloatArraySerializer;
import com.example.tdl.domain.dto.CommFeedback;
import com.example.tdl.domain.vo.*;
import com.example.tdl.service.ConfigService;
import com.example.tdl.service.GatewayService;
import com.example.tdl.service.TDLDeviceService;
import com.google.gson.Gson;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/equipmentBinding")
public class EquipmentBindingController {
private Logger logger = LoggerFactory.getLogger(this.getClass());
CommFeedback fb = new CommFeedback();
Gson gson = new Gson();
@Autowired
private ConfigService configService;
@Autowired
private GatewayService gatewayService;
@Autowired
private TDLDeviceService tdlDeviceService;
@ApiOperation(value = "绑定gateWay和tdl",notes = "绑定gateWay和tdl" +
" SN:gateWay编号," +
" type:gateWay类型," +
" mode:1--运输/2--仓库," +
" TDLSN:tdl编号," +
" transportationNo:运输编号," +
" warehouseNo:仓库编号" )
@ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
})
@PostMapping("/binding")
public Object binding(@RequestBody BindingVo bindingVo){
//获取gateWay的信息
ResultGatewayVo resultGatewayVo = gatewayService.getBySNAndType(bindingVo.getSN(),bindingVo.getType());
if(resultGatewayVo.getUseScene() !=0 && resultGatewayVo.getUseScene() !=bindingVo.getMode()){
fb.setCode(0);
fb.setMessage("该网关所属环境与当前不符");
return gson.toJson(fb);
}
//判断当前tdl是否有网关在使用
ResultTDLDeviceVo resultTDLDeviceVo = tdlDeviceService.getByTDLSN(bindingVo.getTDLSN());
if(!StringUtils.isEmpty(resultTDLDeviceVo.getGatewaySN())){
fb.setCode(0);
fb.setMessage("该TDL已经被使用");
return gson.toJson(fb);
}
if(StringUtils.isEmpty(bindingVo.getTransportationNo()) && !StringUtils.isEmpty(bindingVo.getWarehouseNo())){
bindingVo.setTransportationNo("");
}else if(StringUtils.isEmpty(bindingVo.getWarehouseNo()) && !StringUtils.isEmpty(bindingVo.getTransportationNo())){
bindingVo.setWarehouseNo("");
}
//开始绑定
//获取gateway下的所有tdl的编号
List<String> devList = tdlDeviceService.getByGatewaySN(bindingVo.getSN(),bindingVo.getType());
devList.add(bindingVo.getTDLSN());
ConfigCMDVo configCMDVo = new ConfigCMDVo("config",5,15,devList,bindingVo.getMode(),System.currentTimeMillis()/1000l);
Map<Object,Object> map=new HashMap<>();
map.put("transportationNo",bindingVo.getTransportationNo());
map.put("warehouseNo",bindingVo.getWarehouseNo());
map.put("useScene",bindingVo.getMode());
map.put("gSN",bindingVo.getSN());
map.put("gType",bindingVo.getType());
map.put("message",gson.toJson(configCMDVo));
map.put("flag",false);
map.put("resp",null);
map.put("state",1);
map.put("untie",false);
map.put("TDLSN",bindingVo.getTDLSN());
map.put("createTime",System.currentTimeMillis());
configService.addConfig(map);
Map<Object,Object> msg=new HashMap<>();
msg.put("msg",map.get("msg"));
if (msg.get("msg").equals("配置网关成功")){
fb.setCode(1);
fb.setMessage(msg.get("msg").toString());
}else{
fb.setCode(0);
fb.setMessage(msg.get("msg").toString());
}
return gson.toJson(fb);
}
@ApiOperation(value = "重置tdl",notes = "重置tdl")
@ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
})
@PostMapping("/untie")
public Object untie(@RequestBody String TDLSN){
JSONObject jsonObject= JSON.parseObject(TDLSN);
TDLSN=(String)jsonObject.get("TDLSN");
//判断当前tdl是否有网关在使用
ResultTDLDeviceVo resultTDLDeviceVo = tdlDeviceService.getByTDLSN(TDLSN);
List<String> devList = tdlDeviceService.getByGatewaySN(resultTDLDeviceVo.getGatewaySN(),resultTDLDeviceVo.getGatewayType());
ConfigVo configVo =configService.getConfig(resultTDLDeviceVo.getGatewaySN(),resultTDLDeviceVo.getGatewayType());
ConfigCMDVo config = gson.fromJson(configVo.getMessage(),ConfigCMDVo.class);
ConfigCMDVo configCMDVo ;
Boolean untie = false;
if(devList.size()>1){
devList.remove(TDLSN);
configCMDVo = new ConfigCMDVo("config",config.getGpsPeriod(),config.getGprsPeriod(),devList,config.getMode(),System.currentTimeMillis()/1000l);
}else{
configCMDVo = config;
untie = true;
}
Map<Object,Object> map=new HashMap<>();
map.put("gSN",resultTDLDeviceVo.getGatewaySN());
map.put("gType",resultTDLDeviceVo.getGatewayType());
map.put("message",gson.toJson(configCMDVo));
map.put("untie",untie);
map.put("TDLSN",TDLSN);
configService.updateConfig(map);
Map<Object,Object> msg=new HashMap<>();
msg.put("msg",map.get("msg"));
if (msg.get("msg").equals("解除网关成功")){
fb.setCode(1);
fb.setMessage(msg.get("msg").toString());
}else{
fb.setCode(0);
fb.setMessage(msg.get("msg").toString());
}
return gson.toJson(fb);
}
}
......@@ -18,7 +18,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RestController
......
......@@ -5,7 +5,7 @@ import com.example.tdl.domain.vo.AlarmLogVo;
import com.example.tdl.domain.vo.HomePageDataVo;
import com.example.tdl.domain.vo.ResultRouteVo;
import com.example.tdl.domain.vo.TermVo;
import com.example.tdl.service.AlarmLogServcie;
import com.example.tdl.service.AlarmLogService;
import com.example.tdl.service.RouteService;
import com.google.gson.Gson;
import io.swagger.annotations.ApiImplicitParam;
......@@ -31,7 +31,7 @@ public class HomePageController {
private RouteService routeService;
@Autowired
private AlarmLogServcie alarmLogServcie;
private AlarmLogService alarmLogServcie;
//获取当天所有的设备数据
@ApiOperation(value = "获取所有的运输数据",notes = "获取运输设备数据:" +
......@@ -70,14 +70,14 @@ public class HomePageController {
public Object getAll(){
HomePageDataVo dataVo = new HomePageDataVo();
//获取所有的路线
List<ResultRouteVo> routeVos = routeService.getAll();//所有的路线
// List<ResultRouteVo> routeVos = routeService.getAll();//所有的路线
//List<ResultRouteVo> routeVoList = routeService.getAllRoute();//当天的数量
//获取所有的报警
List<AlarmLogVo> alarmLogVos = alarmLogServcie.getAll();
// 获取所有的路线数量
dataVo.setRouteVoList(routeVos);//路线列表
// dataVo.setRouteVoList(routeVos);//路线列表
dataVo.setAlarmLogVoList(alarmLogVos);//报警列表
dataVo.setSum(routeVos.size());//总数量
// dataVo.setSum(routeVos.size());//总数量
dataVo.setOnRoute(0);//在途数量
dataVo.setComplted(0);//已完成数量
dataVo.setAlarmed(0);//报警数量
......
......@@ -5,8 +5,6 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.example.tdl.domain.dto.CommFeedback;
import com.example.tdl.domain.vo.*;
import com.example.tdl.entity.Route;
import com.example.tdl.service.RouteService;
import com.example.tdl.service.TDLDeviceService;
import com.example.tdl.service.redis.TokenRedisService;
import com.google.gson.Gson;
......@@ -14,7 +12,6 @@ import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -23,9 +20,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.text.SimpleDateFormat;
import java.util.Date;
@RestController
@RequestMapping("/tdlDevice")
......@@ -43,7 +37,6 @@ public class TDLDeviceController {
@Autowired
private TokenRedisService tokenRedisService;
//查询TDL信息
@ApiOperation(value = "查询TDL信息",notes = "查询TDL信息,返回值说明:" +
" TDLName:TDL名字," +
......
......@@ -15,7 +15,7 @@ mybatis.config-location=classpath:mybatis-config.xml
# Redis服务器地址
tdl.redis.host=127.0.0.1
tdl.redis.host=192.168.1.16
# Redis数据库索引(默认为0)
tdl.redis.index=0
# Redis服务器连接端口
......@@ -51,9 +51,14 @@ tdl.mqtt.clientcrt = witcd.crt
# InfluxDB
tdl.influxdb.user = admin
tdl.influxdb.password = Witium37774020
tdl.influxdb.host = http://192.168.1.11:8086
tdl.influxdb.database = original
spring.influxdb.username=admin
spring.influxdb.password=37774020
spring.influxdb.url=http://192.168.1.16:8086
spring.influxdb.database=original
spring.influxdb.retentionPolicy = tdl_policy
spring.influxdb.connent-timeout=10
spring.influxdb.read-timeout=30
spring.influxdb.write-timeout=10
spring.influxdb.gzip=true
......@@ -18,7 +18,7 @@
insert into alarm_log
values(
null,
#{routeNumber,jdbcType=VARCHAR},
#{transportationNo,jdbcType=VARCHAR},
#{routeName,jdbcType=VARCHAR},
#{description,jdbcType=VARCHAR},
#{data,jdbcType=FLOAT},
......
......@@ -133,4 +133,11 @@
boxNo,containerNo,deliveryAddress,transportationType,circuitState,c.remark
from circuit c,route r WHERE c.route_id=r.id AND r.state=1 AND c.state=1 AND transportationNo=#{transportationNo,jdbcType=VARCHAR}
</select>
<select id="getByNo" parameterType="String" resultType="com.example.tdl.domain.vo.ResultGatewayVo">
SELECT SN,`name`,type,state,bConfig,useScene,from_unixtime((createTime/1000),'%Y-%m-%d %T') createTime,from_unixtime((updateTime/1000),'%Y-%m-%d %T') updateTime
from gateway
WHERE id=(SELECT gateway_id from tdldevice where circuit_id =(SELECT id from circuit WHERE transportationNo=#{transportationNo,jdbcType=VARCHAR}))
</select>
</mapper>
\ No newline at end of file
......@@ -2,18 +2,26 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.tdl.mapper.ConfigMapper">
<!--绑定getway和tdl-->
<insert id="addConfig" parameterType="com.example.tdl.domain.vo.ConfigVo">
insert into config
values(
null,
#{gSN,jdbcType=VARCHAR},
#{gType,jdbcType=VARCHAR},
#{message,jdbcType=VARCHAR},
#{flag,jdbcType=INTEGER},
#{resp,jdbcType=INTEGER},
#{state,jdbcType=INTEGER},
#{untie,jdbcType=INTEGER}
<insert id="addConfig" parameterType="java.util.Map" statementType="CALLABLE">
<![CDATA[
{
call pro_addTDLGatewayLog(
#{transportationNo,mode=IN,jdbcType=VARCHAR},
#{warehouseNo,mode=IN,jdbcType=VARCHAR},
#{useScene,mode=IN,jdbcType=INTEGER},
#{gSN,mode=IN,jdbcType=VARCHAR},
#{gType,mode=IN,jdbcType=VARCHAR},
#{message,mode=IN,jdbcType=VARCHAR},
#{flag,mode=IN,jdbcType=INTEGER},
#{resp,mode=IN,jdbcType=INTEGER},
#{state,mode=IN,jdbcType=INTEGER},
#{untie,mode=IN,jdbcType=INTEGER},
#{TDLSN,mode=IN,jdbcType=VARCHAR},
#{createTime,mode=IN,jdbcType=BIGINT},
#{msg,mode=OUT,jdbcType=VARCHAR}
)
}
]]>
</insert>
<!--获取绑定消息-->
......@@ -29,16 +37,44 @@
and state = 1;
</update>
<update id="updateConfig">
update config set untie=#{untie,jdbcType=INTEGER}
where gSN= #{gSN,jdbcType=VARCHAR}
and gType=#{gType,jdbcType=VARCHAR}
and state = 1;
<!--重置tdl-->
<update id="updateConfig" parameterType="java.util.Map" statementType="CALLABLE">
<![CDATA[
{
call pro_updateTDLGatewayLog(
#{gSN,mode=IN,jdbcType=VARCHAR},
#{gType,mode=IN,jdbcType=VARCHAR},
#{message,mode=IN,jdbcType=VARCHAR},
#{untie,mode=IN,jdbcType=INTEGER},
#{TDLSN,mode=IN,jdbcType=VARCHAR},
#{msg,mode=OUT,jdbcType=VARCHAR}
)
}
]]>
</update>
<!--解绑成功-->
<update id="delConfig" parameterType="String">
update config set state = 0 where gSN= #{gSN,jdbcType=VARCHAR} and gType=#{gType,jdbcType=VARCHAR} and state = 1;
</update>
<!-- <insert id="addConfig" parameterType="com.example.tdl.domain.vo.ConfigVo">
insert into config
values(
null,
#{gSN,jdbcType=VARCHAR},
#{gType,jdbcType=VARCHAR},
#{message,jdbcType=VARCHAR},
#{flag,jdbcType=INTEGER},
#{resp,jdbcType=INTEGER},
#{state,jdbcType=INTEGER},
#{untie,jdbcType=INTEGER}
)
</insert>-->
<!--<update id="updateConfig">
update config set untie=#{untie,jdbcType=INTEGER}
where gSN= #{gSN,jdbcType=VARCHAR}
and gType=#{gType,jdbcType=VARCHAR}
and state = 1;
</update>-->
</mapper>
\ No newline at end of file
......@@ -61,6 +61,19 @@
</foreach>)
</select>
<select id="getByAliasList" resultType="com.example.tdl.domain.vo.ProbesVo" parameterType="String" >
select port,unit,description,alias,type alarmUp alarmDown from probes where gateway_id =(
select id from gateway where SN=#{SN,jdbcType=VARCHAR} and type= #{type,jdbcType=VARCHAR})
and alias in
<foreach collection="aliasList" item="alias" open="(" close=")" separator=",">
#{alias,jdbcType=VARCHAR}
</foreach>
ORDER BY FIELD(alias,
<foreach collection="aliasList" item="alias" separator=",">
#{alias,jdbcType=VARCHAR}
</foreach>)
</select>
<select id="getCountByGateway" parameterType="String" resultType="java.lang.Integer">
select COUNT(*) from probes where gateway_id =(
SELECT id FROM gateway WHERE SN = #{SN,jdbcType=VARCHAR} AND type = #{type,jdbcType=VARCHAR})
......
......@@ -2,7 +2,7 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.tdl.mapper.RoleMapper">
<!--查询所有角色名-->
<select id="getAllRoleName" resultType="String">
<select id="getAllRoleName" resultType="com.example.tdl.domain.vo.RoleNameVo">
SELECT roleName from role;
</select>
......
......@@ -55,4 +55,8 @@
from tdldevice t
WHERE TDLSN=#{TDLSN,jdbcType=VARCHAR}
</select>
<select id="getByGatewaySN" parameterType="String" resultType="String">
select TDLSN from tdldevice t,gateway g where t.gateway_id = g.id and g.SN =#{SN,jdbcType=VARCHAR} and g.type=#{type,jdbcType=VARCHAR}
</select>
</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