Commit ed4db104 authored by chenying's avatar chenying

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	src/main/resources/application.properties
parents 6edba52f 729f983b
# java
# Version: 0.0.1
# Version: 1.8.191
FROM registry.cn-hangzhou.aliyuncs.com/witcloud/docker-java:0.0.1
FROM registry.cn-hangzhou.aliyuncs.com/witcloud/docker-cjava:1.8.191
# Maintainers
MAINTAINER Carit Zhu "carit.zhu@witium.com"
COPY tdlcloud.jar /root/tdlcloud.jar
COPY ca.crt /root/ca.crt
COPY witcd.pem /root/witcd.pem
COPY witcd.crt /root/witcd.crt
ARG WITIUM_INFLUXDB_HOST
ENV WITIUM_INFLUXDB_HOST ${WITIUM_INFLUXDB_HOST:-http://witcloud-influxdb:8086}
ARG WITIUM_MQTT_URL
ENV WITIUM_MQTT_URL ${WITIUM_MQTT_URL:-tcp://witcloud-emq}
ARG WITIUM_MQTT_PORT
ENV WITIUM_MQTT_PORT ${WITIUM_MQTT_PORT:-1883}
ARG WITIUM_MQTT_CACRT
ENV WITIUM_MQTT_CACRT ${WITIUM_MQTT_CACRT:-/root/ca.crt}
ARG WITIUM_MQTT_CLIENTKEY
ENV WITIUM_MQTT_CLIENTKEY ${WITIUM_MQTT_CLIENTKEY:-/root/witcd.pem}
ARG WITIUM_MQTT_CLIENTCRT
ENV WITIUM_MQTT_CLIENTCRT ${WITIUM_MQTT_CLIENTCRT:-/root/witcd.crt}
COPY app.jar /root/jar/app.jar
COPY ca.crt /root/jar/ca.crt
COPY witcd.pem /root/jar/witcd.pem
COPY witcd.crt /root/jar/witcd.crt
EXPOSE 8092
ENTRYPOINT [ "java", "-jar","/root/tdlcloud.jar" ]
CMD ["--witium.influxdb.host ${WITIUM_INFLUXDB_HOST}","--witium.mqtt.url ${WITIUM_MQTT_URL}","--witium.mqtt.port ${WITIUM_MQTT_PORT}","--witium.mqtt.cacrt ${WITIUM_MQTT_CACRT}","--witium.mqtt.clientkey ${WITIUM_MQTT_CLIENTKEY}","--witium.mqtt.clientcrt ${WITIUM_MQTT_CLIENTCRT}"]
\ No newline at end of file
ENTRYPOINT [ "/bin/bash", "/root/start-jar.sh" ]
......@@ -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 " +
......
package com.example.tdl.util;
import java.text.DecimalFormat;
public class MapUtils {
private static double EARTH_RADIUS = 6371.393;
......@@ -60,7 +62,13 @@ public class MapUtils {
}
public static void main(String[] args) {
System.out.println(MapUtils.getDistance(29.490295,106.486654,29.615467,106.581515));
DecimalFormat df = new DecimalFormat("0.0000");
double d = (double)37/44300;
System.out.println("d:" + df.format(d));
double p=1013.25* Math.pow((1 - Double.valueOf(df.format(d))),5.256);
System.out.println("pressure: "+ p);
}
}
......@@ -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="";
......
......@@ -395,6 +395,7 @@ public class DataController {
if (queryResults.getResults().get(0).getSeries() != null) {
count = Double.valueOf(queryResults.getResults().get(0).getSeries().get(0).getValues().get(0).get(1).toString()).intValue();
} else {
historyDataVo.setTDLSN(TDLSN);
historyDataVoList.add(historyDataVo);
continue;
}
......@@ -627,6 +628,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 +638,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();
}
......@@ -928,7 +930,8 @@ public class DataController {
HistoryData altitudeData = new HistoryData();
altitudeData.setTime(time);
//大气压力(kPa A) =101.325*(1-0.02257*海拔)^5.256
Double height = 44300*(1-(Math.pow((Double.parseDouble(df.format(Float.valueOf(press)))/1013.25), (float)1/5.256)));
// Double height = 44300*(1-(Math.pow((Double.parseDouble(df.format(Float.valueOf(press)))/1013.25), (float)1/5.256)));
Double height = 44300*(1-(Math.pow((Double.parseDouble(df.format(Float.valueOf(press)-10f))/1013.25), (float)1/5.256))); //气压临时减去10
altitudeData.setValue(df.format(height).toString());
pressureDataList.add(pressureData);
altitudeDataList.add(altitudeData);
......
......@@ -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
......@@ -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