增加电压、温度等推送
This commit is contained in:
parent
e651f0ed12
commit
e7cdb46ff2
@ -35,12 +35,20 @@ public class KingMaData {
|
||||
Data data1;
|
||||
Data data2;
|
||||
Data data3;
|
||||
Data data4;
|
||||
Data data5;
|
||||
Data data6;
|
||||
|
||||
public Phys(Double e, Double n, Double d){
|
||||
data1 = new Data("data1","mm",e);
|
||||
data2 = new Data("data2","mm",n);
|
||||
data3 = new Data("data3","mm",d);
|
||||
}
|
||||
public void setSensorData(Double voltage, Double rssi, Double temperature){
|
||||
data4 = new Data("data4","V",voltage);
|
||||
data5 = new Data("data5","dB",rssi);
|
||||
data6 = new Data("data6","°C",temperature);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -25,7 +25,7 @@ public class Forwarder {
|
||||
int totalSendNum = 0;
|
||||
|
||||
int fwdCycleMinutes = 30;
|
||||
static boolean isFwdTableInit = false;
|
||||
static boolean isFwdTableInit = true;//false;
|
||||
|
||||
@Autowired
|
||||
private GnssDeviceMapper deviceMapper;
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
package com.imdroid.beidou_fwd.task;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.imdroid.beidou_fwd.entity.KingMaData;
|
||||
import com.imdroid.common.util.GsonUtil;
|
||||
import com.imdroid.common.util.HttpUtils;
|
||||
import com.imdroid.common.util.NumberUtils;
|
||||
import com.imdroid.secapi.dto.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
@ -40,6 +40,9 @@ public class KingMaForwarder extends Forwarder{
|
||||
Map<String, String> header;
|
||||
LocalDateTime lastTokenTime = LocalDateTime.now();
|
||||
|
||||
@Autowired
|
||||
GnssStatusMsgMapper statusMsgMapper;
|
||||
|
||||
@PostConstruct
|
||||
void registerMe(){
|
||||
init(FORWARDER_NAME, data_host,3,true,60);
|
||||
@ -47,7 +50,8 @@ public class KingMaForwarder extends Forwarder{
|
||||
/**
|
||||
* 每半小时转发GNSS解算结果
|
||||
*/
|
||||
@Scheduled(cron = "0 0 0/1 * * ?") // 每小时执行一次
|
||||
//@Scheduled(cron = "0 0 0/1 * * ?") // 每小时执行一次
|
||||
@Scheduled(cron = "0 0/5 * * * ?") // 每30分钟执行一次
|
||||
private void forwardGnss() {
|
||||
logger.info("kingma forwardGnss");
|
||||
forwardCurrentGnss();
|
||||
@ -93,6 +97,15 @@ public class KingMaForwarder extends Forwarder{
|
||||
lastTokenTime = nowTime;
|
||||
}
|
||||
|
||||
// 获取最近一小时的状态消息
|
||||
// 获取温湿度
|
||||
QueryWrapper<GnssStatusMsg> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("tenantid",tenantId);
|
||||
queryWrapper.le("createtime",sentTime);
|
||||
queryWrapper.ge("createtime",sentTime.minusMinutes(fwdCycleMinutes));
|
||||
queryWrapper.orderByDesc("createtime");
|
||||
List<GnssStatusMsg> statusMsgs = statusMsgMapper.selectList(queryWrapper);
|
||||
|
||||
List<KingMaData> dataList = new ArrayList<>(records.size());
|
||||
|
||||
for(GnssCalcData locationRecord: records) {
|
||||
@ -105,18 +118,30 @@ public class KingMaForwarder extends Forwarder{
|
||||
NumberUtils.scale(locationRecord.getRpose(), 2),
|
||||
NumberUtils.scale(locationRecord.getRposn(), 2),
|
||||
NumberUtils.scale(locationRecord.getRposd(), 2)));
|
||||
for(GnssStatusMsg msg:statusMsgs){
|
||||
if(msg.getDeviceid().equals(locationRecord.getDeviceid())){
|
||||
if(msg.getVoltage()!=null && msg.getRssi()!=null && msg.getTemperature()!=null) {
|
||||
data.getPhys().setSensorData(
|
||||
NumberUtils.scale((double) (msg.getVoltage() / 1000), 1),
|
||||
NumberUtils.scale((double) (msg.getRssi()), 0),
|
||||
NumberUtils.scale((double) (msg.getTemperature()), 1));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
dataList.add(data);
|
||||
sendNum++;
|
||||
}
|
||||
String json = GsonUtil.toJson(dataList);
|
||||
logger.info(json);
|
||||
String result = HttpUtils.postJson(data_host,header,json);
|
||||
logger.info("project " + projectId + ": push calculation result to Kingma");
|
||||
logger.info(json);
|
||||
logger.info("result: "+result);
|
||||
JSONObject obj = (JSONObject) JSONObject.parse(result);
|
||||
String msg = obj.getString("message");
|
||||
if(msg.equals("Success")) return sendNum;
|
||||
else return 0;
|
||||
//return sendNum;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user