Commit dec9362c authored by zhuangzhuang's avatar zhuangzhuang

12.18-增加获取海拔和压力的接口,增加获取定位间隔的接口,增加修改定位间隔的接口

parent 12ab1b6d
Pipeline #13 canceled with stages
......@@ -46,10 +46,10 @@ dependencies {
compile('org.springframework.boot:spring-boot-starter-data-redis')
compile ('org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.1.0')
compile ('org.influxdb:influxdb-java:2.7')
F
compile('com.aliyun.oss:aliyun-sdk-oss:2.5.0')
compile('org.apache.poi:poi:3.9')
compile files('libs/javacsv-2.0.jar')
compile ('com.github.miwurster:spring-data-influxdb:1.6')
compile('org.springframework.boot:spring-boot-starter-mail')
}
jar {
......
package com.example.tdl.domain.vo;
import java.util.List;
public class AltitudeDataVo {
private String alias;
private List<HistoryData> historyData;
public String getAlias() {
return alias;
}
public void setAlias(String alias) {
this.alias = alias;
}
public List<HistoryData> getHistoryData() {
return historyData;
}
public void setHistoryData(List<HistoryData> historyData) {
this.historyData = historyData;
}
}
package com.example.tdl.domain.vo;
import java.util.List;
public class AltitudeResultDataVo {
private String TDLSN;
private String min;
private String max;
private List<HistoryData> alarmList;
private List<HistoryData> pressure;
private List<HistoryData> altitude;
public String getTDLSN() {
return TDLSN;
}
public void setTDLSN(String TDLSN) {
this.TDLSN = TDLSN;
}
public String getMin() {
return min;
}
public void setMin(String min) {
this.min = min;
}
public String getMax() {
return max;
}
public void setMax(String max) {
this.max = max;
}
public List<HistoryData> getAlarmList() {
return alarmList;
}
public void setAlarmList(List<HistoryData> alarmList) {
this.alarmList = alarmList;
}
public List<HistoryData> getPressure() {
return pressure;
}
public void setPressure(List<HistoryData> pressure) {
this.pressure = pressure;
}
public List<HistoryData> getAltitude() {
return altitude;
}
public void setAltitude(List<HistoryData> altitude) {
this.altitude = altitude;
}
}
package com.example.tdl.domain.vo;
public class ConfigResultVo {
private String transportationNo;
private String gatewaySN;
private String gatewayType;
private String message;
public String getTransportationNo() {
return transportationNo;
}
public void setTransportationNo(String transportationNo) {
this.transportationNo = transportationNo;
}
public String getGatewaySN() {
return gatewaySN;
}
public void setGatewaySN(String gatewaySN) {
this.gatewaySN = gatewaySN;
}
public String getGatewayType() {
return gatewayType;
}
public void setGatewayType(String gatewayType) {
this.gatewayType = gatewayType;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
package com.example.tdl.domain.vo;
public class GPSVo {
private String transportationNo;
private Integer gps;
private Integer gprs;
public GPSVo() {
}
public GPSVo(String transportationNo, Integer gps, Integer gprs) {
this.transportationNo = transportationNo;
this.gps = gps;
this.gprs = gprs;
}
public String getTransportationNo() {
return transportationNo;
}
public void setTransportationNo(String transportationNo) {
this.transportationNo = transportationNo;
}
public Integer getGps() {
return gps;
}
public void setGps(Integer gps) {
this.gps = gps;
}
public Integer getGprs() {
return gprs;
}
public void setGprs(Integer gprs) {
this.gprs = gprs;
}
}
package com.example.tdl.mapper;
import com.example.tdl.domain.vo.ConfigResultVo;
import com.example.tdl.domain.vo.ConfigVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
......@@ -22,4 +23,8 @@ public interface ConfigMapper {
//int updateConfig(@Param("gSN") String gSN,@Param("gType") String gType,@Param("untie") Boolean untie);
int updateConfig(Map<Object,Object> map);
ConfigResultVo getByTransportationNo(@Param("transportationNo") String transportationNo);
Integer updateGPS(ConfigResultVo configResultVo);
}
package com.example.tdl.service;
import com.example.tdl.domain.vo.ConfigResultVo;
import com.example.tdl.domain.vo.ConfigVo;
import com.example.tdl.mapper.ConfigMapper;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -46,4 +47,12 @@ public class ConfigService {
public int delConfig(String gSN,String gType){
return configMapper.delConfig(gSN,gType);
}
public ConfigResultVo getByTransportationNo(String transportationNo){
return configMapper.getByTransportationNo(transportationNo);
}
public Integer updateGPS( ConfigResultVo configResultVo ){
return configMapper.updateGPS(configResultVo);
}
}
......@@ -102,7 +102,7 @@ public class DataUtil {
}
QueryResult queryResult = influxDBTemplate.query(new Query(sql, database,false));
if (queryResult.getResults() != null) {
historyData = getHistoryDatas(queryResult, field);
historyData = getHistoryDatas(queryResult);
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){
......@@ -150,7 +150,7 @@ public class DataUtil {
" \"event\" = '"+event+"' " +
" AND \"tdl\"='" + tdl + "' " +
" and time >= "+startTime +" and time <" + maxTime + " limit 1;";
startTime = maxTime;
startTime = maxTime;
}
return sql;
}
......@@ -194,11 +194,6 @@ public class DataUtil {
return values;
}
public static String parseTime(String time) {
String dateResult = null;
try {
......@@ -221,7 +216,7 @@ public class DataUtil {
return String.valueOf(date.getTime());
}
public static List<HistoryData> getHistoryDatas(QueryResult queryResult, String alias) {
public static List<HistoryData> getHistoryDatas(QueryResult queryResult) {
String dateResult = null;
List<List<Object>> value = getValues(queryResult);
List<HistoryData> historyDataList = new ArrayList<>();
......
......@@ -1574,6 +1574,109 @@ public class CircuitController {
return gson.toJson(bindVo);
}
//获取正在未结束的线路时间配置
@ApiOperation(value = "获取未结束的线路配置间隔时间",notes = "获取未结束的线路配置间隔时间" +
"transportationNo:运输编号" +
"返回值:" +
"gps:定位间隔" +
"gprs:发送间隔")
@ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
@ApiImplicitParam(paramType="header", name = "AccountLanguage", value = "language", required = false, dataType = "String"),
})
@PostMapping("/queryConfig")
public Object queryConfig(@RequestBody String transportationNo,HttpServletRequest request){
UserRedisVo user = gson.fromJson(tokenRedisService.get("TOKEN_" +request.getHeader("Account_token")),UserRedisVo.class);
if (StringUtils.isEmpty(transportationNo)){
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"transportationNo"));
return gson.toJson(fb);
}
JSONObject jsonObject= JSON.parseObject(transportationNo);
transportationNo=(String)jsonObject.get("transportationNo");
ResultCircuitVo resultCircuitVo = circuitService.getByTransportationNo(transportationNo,user.getCompanyNo());
if (resultCircuitVo==null){
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"noCircuit"));
return gson.toJson(fb);
}
if(resultCircuitVo.getCircuitState()==2){
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"endCircuit"));
return gson.toJson(fb);
}
//获取相关网关数据已经配置数据
ConfigResultVo configResultVo = configService.getByTransportationNo(transportationNo);
if(configResultVo == null){
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"endCircuit"));
return gson.toJson(fb);
}
CheckInVo checkInVo = new Gson().fromJson(configResultVo.getMessage(),CheckInVo.class);
return gson.toJson(new GPSVo(transportationNo,checkInVo.getGpsPeriod(),checkInVo.getGprsPeriod()));
}
//修改某一个条线路的定位间隔和时间间隔
@ApiOperation(value = "修改某一个条线路的定位间隔和时间间隔",notes = "修改某一个条线路的定位间隔和时间间隔" +
"transportationNo:运输编号" +
"gps:定位间隔" +
"gprs:发送间隔")
@ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
@ApiImplicitParam(paramType="header", name = "AccountLanguage", value = "language", required = false, dataType = "String"),
})
@PostMapping("/updateConfig")
public Object updateConfig(@RequestBody GPSVo gpsVo,HttpServletRequest request){
UserRedisVo user = gson.fromJson(tokenRedisService.get("TOKEN_" +request.getHeader("Account_token")),UserRedisVo.class);
if (StringUtils.isEmpty(gpsVo.getTransportationNo())){
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"transportationNo"));
return gson.toJson(fb);
}
if (gpsVo.getGps() == null){
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"gpsPeriod"));
return gson.toJson(fb);
}
if (gpsVo.getGprs() == null){
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"gprsPeriod"));
return gson.toJson(fb);
}
ResultCircuitVo resultCircuitVo = circuitService.getByTransportationNo(gpsVo.getTransportationNo(),user.getCompanyNo());
if (resultCircuitVo==null){
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"noCircuit"));
return gson.toJson(fb);
}
if(resultCircuitVo.getCircuitState()==2){
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"endCircuit"));
return gson.toJson(fb);
}
ConfigResultVo configResultVo = configService.getByTransportationNo(gpsVo.getTransportationNo());
if(configResultVo == null){
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"endCircuit"));
return gson.toJson(fb);
}
CheckInVo checkInVo = new Gson().fromJson(configResultVo.getMessage(),CheckInVo.class);
checkInVo.setGprsPeriod(gpsVo.getGprs());
checkInVo.setGpsPeriod(gpsVo.getGps());
configResultVo.setMessage(gson.toJson(checkInVo));
Integer a = configService.updateGPS(configResultVo);
if(a == 1){
fb.setCode(1);
fb.setMessage(i18n.getMessage(request,"updateconfigSuccess"));
}else{
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"updateconfigFailure"));
}
return gson.toJson(fb);
}
//生成运输编号
......
......@@ -37,6 +37,7 @@ import org.springframework.data.influxdb.InfluxDBTemplate;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.nio.charset.Charset;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
......@@ -338,6 +339,96 @@ public class DataController {
}
@ApiOperation(value = "获取压力和海拔数据", notes = "获取压力和海拔数据")
@PostMapping("/getABBPressure")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "header", name = "Account_token", value = "token", required = true, dataType = "String"),
})
public Object getABBPressure(@RequestBody String transportationNo, HttpServletRequest request) {
UserRedisVo user = gson.fromJson(tokenRedisService.get("TOKEN_" + request.getHeader("Account_token")), UserRedisVo.class);
if (StringUtils.isEmpty(transportationNo)) {
fb.setCode(0);
fb.setMessage(i18n.getMessage(request, "transportationNo"));
return gson.toJson(fb);
}
JSONObject jsonObject = JSON.parseObject(transportationNo);
transportationNo = jsonObject.getString("transportationNo");
ResultCircuitVo resultCircuitVo = circuitService.getByTransportationNo(transportationNo, user.getCompanyNo());
if (resultCircuitVo == null) {
fb.setCode(0);
fb.setMessage(i18n.getMessage(request, "noCircuit"));
return gson.toJson(fb);
}
if (resultCircuitVo.getStartTime() == null || resultCircuitVo.getStartTime() == 0) {
fb.setCode(0);
fb.setMessage(i18n.getMessage(request, "notStarted"));
return gson.toJson(fb);
}
Long startTime = resultCircuitVo.getStartTime() * 1000000l;
TDLLogVo gatewayVo = tdlLogService.getByTransportationNo(transportationNo);
if (gatewayVo == null) {
fb.setCode(0);
fb.setMessage(i18n.getMessage(request, "noCircuit"));
return gson.toJson(fb);
}
String device = gatewayVo.getgType() + "_" + gatewayVo.getgSN();
//获取tdl信息
List<String> devList = tdlLogService.getTdlSN(transportationNo);
if (devList.size() == 0) {
fb.setCode(0);
fb.setMessage(i18n.getMessage(request, "noCircuit"));
return gson.toJson(fb);
}
List<AltitudeResultDataVo> historyDataVoList = new ArrayList<>();
for (int i = 0; i < devList.size(); i++) {
AltitudeResultDataVo historyDataVo = new AltitudeResultDataVo();
String TDLSN = devList.get(i).replace("TDL-", "").trim();
String sqls = "";
if (resultCircuitVo.getEndTime() != null && resultCircuitVo.getEndTime() != 0) {
sqls = "SELECT count(\"p\") FROM \"tdl_policy\".\"" + device + "\" WHERE \"event\" = 'Regular measurement' and \"tdl\"='" + devList.get(i) + "' and time>=" + startTime + " and time <=" + resultCircuitVo.getEndTime() * 1000000l;
} else {
sqls = "SELECT count(\"p\") FROM \"tdl_policy\".\"" + device + "\" WHERE \"event\" = 'Regular measurement' and \"tdl\"='" + devList.get(i) + "' and time>=" + startTime ;
}
QueryResult queryResults = influxDBTemplate.query(new Query(sqls, database));
Integer count;
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 {
historyDataVoList.add(historyDataVo);
continue;
}
String sql = "";
if (count > 500) {
if (resultCircuitVo.getEndTime() != null && resultCircuitVo.getEndTime() != 0) {
sql = DataUtil.getSQL( gatewayVo.getgSN(),"p", device, devList.get(i), "Regular measurement",startTime, resultCircuitVo.getEndTime() * 1000000l);
} else {
sql = DataUtil.getSQL(gatewayVo.getgSN(), "p", device, devList.get(i),"Regular measurement", startTime, System.currentTimeMillis() * 1000000l);
}
QueryResult queryResult = influxDBTemplate.query(new Query(sql, database,false));
if (queryResult.getResults() != null) {
historyDataVo = getHistoryDatas(queryResult);
}
historyDataVo.setTDLSN(TDLSN);
historyDataVoList.add(historyDataVo);
} else {
if (resultCircuitVo.getEndTime() != null && resultCircuitVo.getEndTime() != 0) {
sql = "SELECT \"p\" FROM \"tdl_policy\".\"" + device + "\" where \"data_type\" = 'data' AND \"tdl\"='" + devList.get(i) + "' and time >=" + startTime + " and time<=" + resultCircuitVo.getEndTime() * 1000000l ;
} else {
sql = "SELECT \"p\" FROM \"tdl_policy\".\"" + device + "\" where \"data_type\" = 'data' AND \"tdl\"='" + devList.get(i) + "' and time >=" + startTime ;
}
QueryResult queryResult = influxDBTemplate.query(new Query(sql, database, true));
if (queryResult.getResults().get(0).getSeries() != null) {
historyDataVo = getHistoryDatas(queryResult);
}
historyDataVo.setTDLSN(TDLSN);
historyDataVoList.add(historyDataVo);
}
}
return historyDataVoList;
}
//下载数据
@ApiOperation(value = "下载线路数据", notes = "下载线路数据")
@PostMapping("/downLoad")
......@@ -690,6 +781,33 @@ public class DataController {
return values;
}
public static AltitudeResultDataVo getHistoryDatas(QueryResult queryResult) {
String dateResult = null;
List<List<Object>> value = DataUtil.getValues(queryResult);
AltitudeResultDataVo altitudeResultDataVo = new AltitudeResultDataVo();
List<HistoryData> pressureDataList = new ArrayList<>();
List<HistoryData> altitudeDataList = new ArrayList<>();
DecimalFormat df = new DecimalFormat("0.00");
df.getRoundingMode();
for (int i = 0; i < value.size(); i++) {
HistoryData pressureData = new HistoryData();
String time= DataUtil.parseTime(value.get(i).get(0).toString());
pressureData.setTime(time);
String press = value.get(i).get(1).toString();
pressureData.setValue(press);
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)));
altitudeData.setValue(df.format(height).toString());
pressureDataList.add(pressureData);
altitudeDataList.add(altitudeData);
}
altitudeResultDataVo.setPressure(pressureDataList);
altitudeResultDataVo.setAltitude(altitudeDataList);
return altitudeResultDataVo;
}
//判断两个时间相差多少
public static String getDistanceTime(Long time1, Long time2) {
//获取当前时区,将时间戳转化成日期时间格式
......
spring.datasource.url=jdbc:mysql://47.97.184.225:3306/tdlcloud?useUnicode=true&characterEncoding=utf-8&useSSL=false
#spring.datasource.url=jdbc:mysql://47.97.184.225: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
......
......@@ -321,6 +321,12 @@ EnableAllert = \u662F\u5426\u9884\u8B66
suitable = \u5E93\u623F\u9002\u5B9C\u6E29\u5EA6\u4E3A{0}\u2103-{1}\u2103\uFF0C\u6E7F\u5EA6\u4FDD\u6301{2}%-{3}%,\u8D85\u6807\u8981\u505A\u5FC5\u8981\u8C03\u8282\u3002
NoData = \u8BE5\u65F6\u95F4\u6BB5\u6CA1\u6709\u6570\u636E
endCircuit = \u4E0D\u80FD\u4FEE\u6539\u5DF2\u7ECF\u7ED3\u675F\u7684\u7EBF\u8DEF
gprsPeriod = \u5B9A\u4F4D\u95F4\u9694\u4E0D\u80FD\u4E3A\u7A7A
gpsPeriod = \u53D1\u9001\u95F4\u9694\u4E0D\u80FD\u4E3A\u7A7A
updateconfigSuccess = \u4FEE\u6539\u6210\u529F
updateconfigFailure = \u4FEE\u6539\u5931\u8D25
DataOverview=\u6570\u636E\u6982\u89C8
TransportationState=\u8FD0\u8F93\u72B6\u6001
......
......@@ -13,7 +13,7 @@
<appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>logback.%d{yyyy-MM-dd}.log</fileNamePattern>
<fileNamePattern>log/logback.%d{yyyy-MM-dd}.log</fileNamePattern>
</rollingPolicy>
<encoder>
<pattern>%d{HH:mm:ss.SSS} %contextName [%thread] %-5level %logger{36} - %msg%n</pattern>
......@@ -25,7 +25,4 @@
<appender-ref ref="file" />
</root>
<!--<logger name="com.adc.disasterforecast" level="INFO" additivity="false">-->
<!--<appender-ref ref="console"/>-->
<!--</logger>-->
</configuration>
\ No newline at end of file
......@@ -64,6 +64,23 @@
and state = 1;
</update>
<select id="getByTransportationNo" parameterType="java.lang.String" resultType="com.example.tdl.domain.vo.ConfigResultVo">
select c.transportationNo,gatewaySN,gatewayType,message from circuit c
inner join tdl_gateway_log tl on tl.transportationNo = c.transportationNo
INNER JOIN config cf on cf.gSN = tl.gatewaySN
where c.state = 1
and circuitState !=2
and c.transportationNo=#{transportationNo,jdbcType=VARCHAR}
</select>
<update id="updateGPS" parameterType="com.example.tdl.domain.vo.ConfigResultVo">
update config set message =#{message,jdbcType=VARCHAR}
where gSN= #{gatewaySN,jdbcType=VARCHAR}
and gType=#{gatewayType,jdbcType=VARCHAR}
</update>
<!--<insert id="addConfig" parameterType="com.example.tdl.domain.vo.ConfigVo">-->
<!--insert into config-->
<!--values(-->
......
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