增加武汉中南院推送
This commit is contained in:
parent
abc39fd436
commit
d2ccdab6ab
@ -0,0 +1,77 @@
|
|||||||
|
package com.imdroid.beidou_fwd.task;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.imdroid.beidou_fwd.entity.DefoData;
|
||||||
|
import com.imdroid.common.util.GsonUtil;
|
||||||
|
import com.imdroid.common.util.HttpUtils;
|
||||||
|
import com.imdroid.common.util.NumberUtils;
|
||||||
|
import com.imdroid.secapi.dto.GnssCalcData;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Configuration
|
||||||
|
@EnableScheduling
|
||||||
|
public class ZNYForwarder extends Forwarder{
|
||||||
|
private final Logger logger = LoggerFactory.getLogger(ZNYForwarder.class);
|
||||||
|
|
||||||
|
static final String FORWARDER_NAME = "武汉中南设计院";
|
||||||
|
|
||||||
|
@Value("${zny.server.host}")
|
||||||
|
private String data_host;
|
||||||
|
final DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||||
|
|
||||||
|
@PostConstruct
|
||||||
|
void registerMe(){
|
||||||
|
init(FORWARDER_NAME, data_host,4,true);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 每半小时转发GNSS解算结果
|
||||||
|
*/
|
||||||
|
@Scheduled(cron = "0 0/30 * * * ?") // 每30分钟执行一次
|
||||||
|
private void forwardGnss() {
|
||||||
|
logger.info("zny forwardGnss");
|
||||||
|
forwardCurrentGnss(FORWARDER_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Scheduled(cron = "0 40 * * * ?") // 每小时的40分钟执行一次
|
||||||
|
//@Scheduled(cron = "0 0/20 * * * ?") // 每20分钟执行一次
|
||||||
|
private void forwardHistoryGnss() {
|
||||||
|
forwardHistoryGnss(FORWARDER_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
int send(String projectId, List<GnssCalcData> records){
|
||||||
|
int sendNum = 0;
|
||||||
|
// 单位:米
|
||||||
|
DefoData defoData = new DefoData(projectId, LocalDateTime.now().format(dateFormatter), records.size());
|
||||||
|
for(GnssCalcData locationRecord:records) {
|
||||||
|
double n = NumberUtils.scale(locationRecord.getRposn() * 0.001, 5);
|
||||||
|
double e = NumberUtils.scale(locationRecord.getRpose() * 0.001, 5);
|
||||||
|
double d = NumberUtils.scale(locationRecord.getRposd() * 0.001, 5);
|
||||||
|
DefoData.Data data = new DefoData.Data(locationRecord.getDeviceid(), String.format("%.5f", n),
|
||||||
|
String.format("%.5f", e), String.format("%.5f", d));
|
||||||
|
defoData.getData().add(data);
|
||||||
|
sendNum++;
|
||||||
|
}
|
||||||
|
String json = GsonUtil.toJson(defoData);
|
||||||
|
logger.info("发送数据到武汉中南设计院平台:{}", json);
|
||||||
|
String result = HttpUtils.postJson(data_host,json);
|
||||||
|
logger.info("发送数据到武汉中南设计院平台返回结果:{}", result);
|
||||||
|
JSONObject obj = (JSONObject) JSONObject.parse(result);
|
||||||
|
String msg = obj.getString("message");
|
||||||
|
if(msg.contains("成功")) return sendNum;
|
||||||
|
else return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user