Commit 26c0226c authored by zhuangzhuang's avatar zhuangzhuang

12.20-修复ABB首页不显示经纬度bug,修复ABB线路数据下载的bug

parent 36a8c21c
......@@ -18,6 +18,7 @@ import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
import org.springframework.util.StringUtils;
import redis.clients.jedis.JedisPoolConfig;
import java.lang.reflect.Method;
......@@ -41,6 +42,38 @@ public class RedisConfig extends CachingConfigurerSupport{
private int poolmaxidle;
private int poolminidle;
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public int getPort() {
return port;
}
public void setPort(int port) {
this.port = port;
}
public int getTimeout() {
return timeout;
}
public void setTimeout(int timeout) {
this.timeout = timeout;
}
public int getIndex() {
return index;
}
......@@ -81,38 +114,6 @@ public class RedisConfig extends CachingConfigurerSupport{
this.poolminidle = poolminidle;
}
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public int getPort() {
return port;
}
public void setPort(int port) {
this.port = port;
}
public int getTimeout() {
return timeout;
}
public void setTimeout(int timeout) {
this.timeout = timeout;
}
/**
* 生产key的策略
*
......@@ -162,6 +163,9 @@ public class RedisConfig extends CachingConfigurerSupport{
setIndex(dbIndex);
factory.setHostName(host);
factory.setPort(Integer.valueOf(port));
if(!StringUtils.isEmpty(password)){
factory.setPassword(password);
}
factory.setDatabase(index);
factory.setTimeout(10000); // 设置连接超时时间
factory.setPoolConfig(poolConfig());
......
package com.example.tdl.interceptor;
import com.example.tdl.service.redis.TokenRedisService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -16,7 +15,7 @@ public class LoginInterceptor implements HandlerInterceptor {
private static Logger logger = LoggerFactory.getLogger(LoginInterceptor.class);
@Autowired
private TokenRedisService redisService;
private TokenRedisService tokenRedisService;
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
......@@ -33,7 +32,7 @@ public class LoginInterceptor implements HandlerInterceptor {
ps.write("{\"code\":0,\"message\":\"用户未登录,请先登录\"}".getBytes("UTF-8"));
return false;
}
String data = redisService.get("TOKEN_" +token);
String data = tokenRedisService.get("TOKEN_" +token);
if(data == null){
response.setContentType("application/json");
response.setStatus(200);
......@@ -42,7 +41,7 @@ public class LoginInterceptor implements HandlerInterceptor {
ps.write("{\"code\":2,\"message\":\"用户登录过期,请重新登录\"}".getBytes("UTF-8"));
return false;
}
redisService.refeshTimeOut("TOKEN_" +token,60 * 60 *24);
tokenRedisService.refeshTimeOut("TOKEN_" +token,60 * 30);
return true;
}
......
......@@ -38,7 +38,6 @@ public class PermissionInterceptor implements HandlerInterceptor {
if(URL.contains("swagger") || URL.contains("/v2/api-docs")){
return true;
}
logger.info("==============执行顺序: 1、preHandle================");
String requestUri = request.getRequestURI();
String contextPath = request.getContextPath();
String url = requestUri.substring(contextPath.length());
......
......@@ -59,7 +59,6 @@ public class DataUtil {
fb.setMessage(i18n.getMessage(request, "noCircuit"));
return gson.toJson(fb);
}
// Long t2 = System.currentTimeMillis();
List<HistoryDataVo> historyDataVoList = new ArrayList<>();
for (int i = 0; i < devList.size(); i++) {
HistoryDataVo historyDataVo = new HistoryDataVo();
......@@ -92,7 +91,6 @@ public class DataUtil {
historyDataVoList.add(historyDataVo);
continue;
}
// logger.info(field+":"+count+"------");
String sql = "";
if (count > 500) {
if (resultCircuitVo.getEndTime() != null && resultCircuitVo.getEndTime() != 0) {
......@@ -124,14 +122,15 @@ public class DataUtil {
if (queryResult.getResults().get(0).getSeries() != null) {
//解析数据
historyData = getHistoryData(queryResult, field);
String sql3 = "Select " + field + " From \"tdl_policy\".\"" + device + "\" where " + "\"tdl\"='" + devList.get(i) + "' " +" ORDER BY time DESC limit 1";
QueryResult queryResult2 = influxDBTemplate.query(new Query(sql3, database));
if(queryResult2.getResults().get(0).getSeries() != null){
HistoryData data = new HistoryData();
data.setValue(queryResult2.getResults().get(0).getSeries().get(0).getValues().get(0).get(1).toString());
data.setTime(UTCToCST(queryResult2.getResults().get(0).getSeries().get(0).getValues().get(0).get(0).toString(),"0"));
historyData.add(data);
}
//获取最后一条数据
// String sql3 = "Select " + field + " From \"tdl_policy\".\"" + device + "\" where " + "\"tdl\"='" + devList.get(i) + "' " +" ORDER BY time DESC limit 1";
// QueryResult queryResult2 = influxDBTemplate.query(new Query(sql3, database));
// if(queryResult2.getResults().get(0).getSeries() != null){
// HistoryData data = new HistoryData();
// data.setValue(queryResult2.getResults().get(0).getSeries().get(0).getValues().get(0).get(1).toString());
// data.setTime(UTCToCST(queryResult2.getResults().get(0).getSeries().get(0).getValues().get(0).get(0).toString(),"0"));
// historyData.add(data);
// }
}
historyDataVo.setDataList(historyData);
historyDataVoList.add(historyDataVo);
......@@ -143,7 +142,6 @@ public class DataUtil {
public static String getSQL(String SN,String field, String device, String tdl,String event, Long startTime, Long endTime) {
String sql = "";
long times = (endTime - startTime) / 500;
logger.info(field +"---"+ times + "-----"+ startTime +"----" +endTime+"----" + tdl);
for (int i = 0; i < 500; i++) {
Long maxTime = startTime + times;
sql = sql + "Select " + field + " From \"tdl_policy\".\"" + device + "\" where " +
......
......@@ -60,7 +60,19 @@ public class MapUtils {
}
public static void main(String[] args) {
System.out.println(MapUtils.getDistance(29.490295,106.486654,29.615467,106.581515));
double f = 44300*(1-(Math.pow((1016/1013.25), (float)1/5.256)));
double h = 44300*(1-(Math.pow((1012/1013.25), (float)1/5.256)));
double f1 = 44300*(1-(Math.pow((795/1013.25), (float)1/5.256)));
double f2 = 44300*(1-(Math.pow((616/1013.25), (float)1/5.256)));
double f3 = 44300*(1-(Math.pow((1013/1013.25), (float)1/5.256)));
double f4 = 44300*(1-(Math.pow((1013/1013.25), (float)1/5.256)));
double f5 = 44300*(1-(Math.pow((1013/1013.25), (float)1/5.256)));
System.out.println(f);
System.out.println(f1);
System.out.println(h);
}
}
......@@ -317,7 +317,7 @@ public class AlarmLogController {
sql = "SELECT \"lng\",\"lat\" FROM \"tdl_policy\".\""+device+"\" where time >= "+ alarmMessageVo.getAlarmTime()*1000000l +" ORDER BY time limit 1;SELECT \"lng\",\"lat\" FROM \"tdl_policy\".\""+device+"\" where time <= "+ alarmMessageVo.getAlarmTime()*1000000l +" ORDER BY time desc limit 1;";
}
QueryResult queryResult =influxDBTemplate.query(new Query(sql,database));
if(queryResult.getResults().get(0).getSeries() != null){
if(queryResult.getResults() != null){
//获取最精确的经纬度
circuitAlarmDataVo = parseLocation(queryResult,alarmMessageVo.getAlarmTime());
}else{
......
......@@ -374,9 +374,9 @@ public class CircuitABBController {
return gson.toJson(fb);
}
//获取gateway的场景
if(resultGatewayVo.getUseScene()== 2){
if(resultGatewayVo.getUseScene()!= 0){
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"gatewayConsistent"));
fb.setMessage(i18n.getMessage(request,"usedgateway"));
return gson.toJson(fb);
}
String alarmTypeVar="";
......
......@@ -822,9 +822,14 @@ public class CircuitController {
return gson.toJson(fb);
}
//获取gateway的场景
if(resultGatewayVo.getUseScene()== 2){
// if(resultGatewayVo.getUseScene()== 2){
// fb.setCode(0);
// fb.setMessage(i18n.getMessage(request,"gatewayConsistent"));
// return gson.toJson(fb);
// }
if(resultGatewayVo.getUseScene() != 0){
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"gatewayConsistent"));
fb.setMessage(i18n.getMessage(request,"usedgateway"));
return gson.toJson(fb);
}
String alarmTypeVar="";
......
......@@ -627,6 +627,7 @@ public class DataController {
if(value.get(1) == null || value.get(1).toString().equals(devList.get(i))){
String[] objs = new String[rowsName.length];
for (int j = 0; j < objs.length; j++) {
logger.info(j+"=-----"+ rowsName[j]);
if(j==0){
try {
objs[j] =timeStamp2Date(new Long(DataUtil.UTCToCST(String.valueOf(value.get(j)),transportationNo.getOffset())));
......@@ -636,10 +637,10 @@ public class DataController {
continue;
}
}else if(j ==1) {
String pressure = value.get(j+1) == null ? "-" :value.get(j+1).toString();
objs[j] =pressure;
Double altitude = value.get(j+1) == null ? null : 44300*(1-(Math.pow((Double.parseDouble(df.format(Float.valueOf(pressure)))/1013.25), (float)1/5.256)));
objs[j+1] =altitude == null ? "-" : altitude.toString();
objs[j] =value.get(j+1) == null ? "-" :value.get(j+1).toString();
}else if(j ==2){
Double altitude = value.get(2) == null ? null : 44300*(1-(Math.pow((Double.parseDouble(df.format(Float.valueOf(value.get(2).toString())))/1013.25), (float)1/5.256)));
objs[j] = altitude == null ? "-" : altitude.toString();
}else{
objs[j] =value.get(j) == null ? "-" :value.get(j).toString();
}
......
......@@ -259,7 +259,7 @@ public class HomePageController {
}
if(gatewayVo!=null&&circuitVos.get(i).getBindTime()!=null){
Long startTime = circuitVos.get(i).getBindTime() * 1000000l;
String sql = "SELECT \"lng\",\"lat\" FROM \"tdl_policy\".\"" + device + "\" where time >= " + startTime + " ORDER BY time desc limit 1";
String sql = "SELECT \"bdlng\",\"bdlat\" FROM \"tdl_policy\".\"" + device + "\" where \"data_type\" = 'location' and time >= " + startTime + " ORDER BY time desc limit 1";
QueryResult queryResult = influxDBTemplate.query(new Query(sql, database));
if (queryResult.getResults().get(0).getSeries() != null) {
circuitVos.get(i).setTime(parseTime(queryResult.getResults().get(0).getSeries().get(0).getValues().get(0).get(0).toString()));
......
#spring.datasource.url=jdbc:mysql://housetest-mysql:3306/tdlCloud?useUnicode=true&characterEncoding=utf-8&useSSL=false
spring.datasource.url=jdbc:mysql://witcloud-mariadb:3306/tdlCloud?useUnicode=true&characterEncoding=utf-8&useSSL=false
spring.datasource.username=root
spring.datasource.password=37774020
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
server.port=8092
#spring.datasource.url=jdbc:mysql://witcloud-mysql:3306/tdlCloud?useUnicode=true&characterEncoding=utf-8&useSSL=false
#spring.datasource.username=root
#spring.datasource.password=37774020
#spring.datasource.driver-class-name=com.mysql.jdbc.Driver
#
#
#tdl.redis.host=housetest-redis
#
#server.port=8092
#
## InfluxDB
#spring.influxdb.url=http://housetest-influxdb:8086
server.port=8092
spring.datasource.url=jdbc:mysql://witcloud-mysql:3306/tdlCloud?useUnicode=true&characterEncoding=utf-8&useSSL=false
spring.datasource.username=root
spring.datasource.password=37774020
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
tdl.redis.host = witcloud-redis
#tdl.redis.password=witium
tdl.redis.host=witcloud-redis
# InfluxDB
spring.influxdb.url=http://witcloud-influxdb:8086
......@@ -28,8 +22,10 @@ tdl.mqtt.port = 8883
tdl.mqtt.username = logistics
tdl.mqtt.password = logistics37774020
tdl.core.add =http://logisticscore-java:8079/witium/addMount
tdl.core.delete =http://logisticscore-java:8079/witium/delMount
#tdl.core.add =http://logisticscore-java:8079/witium/addMount
#tdl.core.delete =http://logisticscore-java:8079/witium/delMount
tdl.core.add =http://abb-herocore:8079/witium/addMount
tdl.core.delete =http://abb-herocore:8079/witium/delMount
mqtt.userName = wtlogistics
mqtt.password = wtlogistics
\ No newline at end of file
spring.datasource.url=jdbc:mysql://47.110.153.44:3306/tdlcloud?useUnicode=true&characterEncoding=utf-8&useSSL=false
#spring.datasource.url=jdbc:mysql://192.168.1.14:3306/tdlcloud?useUnicode=true&characterEncoding=utf-8&useSSL=false
spring.datasource.username=root
spring.datasource.password=37774020
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
......@@ -21,10 +22,12 @@ spring.messages.cache-seconds= 3600
spring.messages.encoding=UTF-8
tdl.redis.host=127.0.0.1
#tdl.redis.host=127.0.0.1
tdl.redis.host=47.110.153.44
tdl.redis.index=0
tdl.redis.port=6379
tdl.redis.password=
#tdl.redis.password=
tdl.redis.password=witium
tdl.redis.poolmaxactive=8
tdl.redis.poolmaxwait=-1
tdl.redis.poolmaxidle=8
......@@ -37,10 +40,14 @@ logging.config=classpath:logback.xml
# Mqtt
tdl.mqtt.url = ssl://192.168.1.11
#tdl.mqtt.url = ssl://192.168.1.11
#tdl.mqtt.port = 8883
#tdl.mqtt.username = ugen
#tdl.mqtt.password = ugen
tdl.mqtt.url = ssl://47.96.128.181
tdl.mqtt.port = 8883
tdl.mqtt.username = ugen
tdl.mqtt.password = ugen
tdl.mqtt.username = logistics
tdl.mqtt.password = logistics37774020
tdl.mqtt.qos = 1
tdl.mqtt.timeout = 20
# SSL Keys
......@@ -52,7 +59,8 @@ tdl.mqtt.clientcrt = witcd.crt
# InfluxDB
spring.influxdb.username=admin
spring.influxdb.password=37774020
spring.influxdb.url=http://47.97.184.225:8086
spring.influxdb.url=http://47.110.153.44:8086
#spring.influxdb.url=http://47.97.184.225:8086
spring.influxdb.database=original
spring.influxdb.retentionPolicy = tdl_policy
spring.influxdb.connent-timeout=10
......
......@@ -375,4 +375,5 @@ SensorQuery=Sensor Query
AddSensor=Add Sensor
ModifySensor=Modify Sensor
DeleteSensor=Delete Sensor
SensorAssignment=Sensor Assignment
\ No newline at end of file
SensorAssignment=Sensor Assignment
usedgateway=The gateway has been used.
\ No newline at end of file
......@@ -70,6 +70,7 @@ gateway = \u7F51\u5173\u5E8F\u5217\u53F7\u4E0D\u80FD\u4E3A\u7A7A
gatewayExist = \u8BE5\u7F51\u5173\u5E8F\u5217\u53F7\u4E0D\u5B58\u5728
gatewayMounted = \u8BE5\u7F51\u5173\u672A\u6302\u8F7D
gatewayConsistent = \u8BE5\u7F51\u5173\u7684\u4F7F\u7528\u573A\u666F\u4E0E\u5F53\u524D\u4E0D\u7B26
usedgateway = \u8BE5\u7F51\u5173\u5DF2\u7ECF\u88AB\u4F7F\u7528\u4E86
tdl = \u4F20\u611F\u5668\u5E8F\u5217\u53F7\u4E0D\u80FD\u4E3A\u7A7A
tdlExist={0}\u4F20\u611F\u5668\u4E0D\u5B58\u5728
tdlUsed={0}\u7684\u4F20\u611F\u5668\u5DF2\u7ECF\u88AB\u4F7F\u7528
......@@ -336,15 +337,15 @@ TransportationState=\u8FD0\u8F93\u72B6\u6001
WarehouseStatus=\u4ED3\u5E93\u72B6\u6001
SystemSetup=\u7CFB\u7EDF\u8BBE\u7F6E
InformationManagement=\u4FE1\u606F\u7BA1\u7406
Devicemanagement=\u8BBE\u5907\u7BA1\u7406
DeviceManagement=\u8BBE\u5907\u7BA1\u7406
DataOverviewDetails=\u6570\u636E\u6982\u89C8\u8BE6\u60C5
TransportationList=\u8FD0\u8F93\u5217\u8868
WarehouseList=\u4ED3\u5E93\u5217\u8868
Usermanagement=\u7528\u6237\u7BA1\u7406
Commonaddress=\u5E38\u7528\u5730\u5740
UserManagement=\u7528\u6237\u7BA1\u7406
CommonAddress=\u5E38\u7528\u5730\u5740
CompanyManagement=\u516C\u53F8\u7BA1\u7406
Warningmanagement=\u9884\u8B66\u7BA1\u7406
WarningManagement=\u9884\u8B66\u7BA1\u7406
AlarmManagement=\u62A5\u8B66\u7BA1\u7406
AccountManagement=\u89D2\u8272\u7BA1\u7406
WarehouseManagement=\u4ED3\u5E93\u7BA1\u7406
......
......@@ -25,4 +25,11 @@
<appender-ref ref="file" />
</root>
<!--<springProfile name="test,dev">-->
<!--<logger name="com.example.tdl" level="info" />-->
<!--</springProfile>-->
<!--&lt;!&ndash; 生产环境. &ndash;&gt;-->
<!--<springProfile name="docker">-->
<!--<logger name="com.example.tdl" level="ERROR" />-->
<!--</springProfile>-->
</configuration>
\ No newline at end of file
......@@ -158,7 +158,7 @@
</select>
<select id="getForHomePage" parameterType="java.lang.String" resultType="com.example.tdl.domain.vo.CircuitABBVo">
SELECT c.transportationNo,t.gatewaySN,t.TDLSN,cargoNo,cargoName,circuitState,IF(a.num>0,1,0) isAlarm,c.startTime
SELECT c.transportationNo,t.gatewaySN,t.TDLSN,cargoNo,cargoName,circuitState,IF(a.num>0,1,0) isAlarm,c.startTime bindTime
from circuit c LEFT JOIN (SELECT DISTINCT TDLSN,gatewaySN,gatewayType,transportationNo FROM tdl_gateway_log) t
ON c.transportationNo=t.transportationNo LEFT JOIN (SELECT COUNT(id) num,transportationNo FROM alarm_log) a
ON a.transportationNo=c.transportationNo
......
......@@ -71,6 +71,7 @@
where c.state = 1
and circuitState !=2
and c.transportationNo=#{transportationNo,jdbcType=VARCHAR}
limit 1
</select>
......
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