1、增加英卓推送组
This commit is contained in:
parent
2f45c45ca7
commit
bd52c6df20
@ -0,0 +1,160 @@
|
|||||||
|
package com.imdroid.beidou_fwd.task;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||||
|
import com.imdroid.beidou_fwd.entity.XFZData;
|
||||||
|
import com.imdroid.beidou_fwd.service.TCPClient;
|
||||||
|
import com.imdroid.common.util.GsonUtil;
|
||||||
|
import com.imdroid.common.util.NumberUtils;
|
||||||
|
import com.imdroid.secapi.dto.GnssCalcData;
|
||||||
|
import com.imdroid.secapi.dto.ResendRecord;
|
||||||
|
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.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Configuration
|
||||||
|
@EnableScheduling
|
||||||
|
public class GZYZForwarder extends GXXfzForwarder{
|
||||||
|
private final String FORWARDER_NAME = "广州英卓";
|
||||||
|
@Value("${gzyz.server.host}")
|
||||||
|
private String host;
|
||||||
|
|
||||||
|
@Value("${gzyz.server.port}")
|
||||||
|
private int port;
|
||||||
|
private boolean enabled=true;
|
||||||
|
|
||||||
|
@PostConstruct
|
||||||
|
void registerMe(){
|
||||||
|
init(FORWARDER_NAME, "TCP "+host+":"+port,14,FWD_DEVICE_ID,30);
|
||||||
|
xfzTcpClient = new TCPClient();
|
||||||
|
xfzTcpClient.init(host, port,listener);
|
||||||
|
if(!enabled) return;
|
||||||
|
|
||||||
|
xfzTcpClient.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 每半小时转发GNSS解算结果
|
||||||
|
*/
|
||||||
|
@Scheduled(cron = "0 0/30 * * * ?") // 每30分钟执行一次
|
||||||
|
private void forwardGnss() {
|
||||||
|
if(!enabled) return;
|
||||||
|
logger.debug("gzyz forwardGnss");
|
||||||
|
forwardCurrentGnss();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
int send(String projectId, List<GnssCalcData> records, LocalDateTime sentTime){
|
||||||
|
int batchNum = 0;
|
||||||
|
int sendNum = 0;
|
||||||
|
if(records.size() == 0) return 0;
|
||||||
|
|
||||||
|
XFZData xfzTcpMessage = new XFZData();
|
||||||
|
xfzTcpMessage.setProjectID(projectId);
|
||||||
|
xfzTcpMessage.setWorkPointID(projectId);
|
||||||
|
|
||||||
|
List<XFZData.Data> dataList = new ArrayList<>(records.size());
|
||||||
|
xfzTcpMessage.setData(dataList);
|
||||||
|
|
||||||
|
for(GnssCalcData locationRecord: records) {
|
||||||
|
XFZData.Data data = new XFZData.Data();
|
||||||
|
dataList.add(data);
|
||||||
|
data.setDataTime(locationRecord.getCreatetime().format(formatter));
|
||||||
|
data.setDevNum(locationRecord.getDeviceid());
|
||||||
|
data.setDevtype("GNSS");
|
||||||
|
// 单位由mm转化为m
|
||||||
|
data.setX(NumberUtils.scale(locationRecord.getRpose() * 0.001, 5));
|
||||||
|
data.setY(NumberUtils.scale(locationRecord.getRposn() * 0.001, 5));
|
||||||
|
data.setZ(NumberUtils.scale(locationRecord.getRposd() * 0.001, 5));
|
||||||
|
// 经纬度
|
||||||
|
data.setDevLng(locationRecord.getR9250e());
|
||||||
|
data.setDevLat(locationRecord.getR9250n());
|
||||||
|
|
||||||
|
//倾角
|
||||||
|
XFZData.Data data2 = new XFZData.Data();
|
||||||
|
dataList.add(data2);
|
||||||
|
data2.setDataTime(locationRecord.getCreatetime().format(formatter));
|
||||||
|
data2.setDevNum(locationRecord.getDeviceid() + "_qj");
|
||||||
|
data2.setDevtype("InclinoMeter");
|
||||||
|
// 角度
|
||||||
|
data2.setX(NumberUtils.scale(locationRecord.getAuxe(), 3));
|
||||||
|
data2.setY(NumberUtils.scale(locationRecord.getAuxn(), 3));
|
||||||
|
data2.setZ(NumberUtils.scale(locationRecord.getAuxd(), 3));
|
||||||
|
// 经纬度
|
||||||
|
data2.setDevLng(locationRecord.getR9250e());
|
||||||
|
data2.setDevLat(locationRecord.getR9250n());
|
||||||
|
|
||||||
|
// 发送
|
||||||
|
batchNum++;
|
||||||
|
|
||||||
|
if(batchNum==20){
|
||||||
|
String json = "#" + GsonUtil.toJson(xfzTcpMessage) + "!";
|
||||||
|
//logger.debug("project {}: forwad {} gnss records to {}",projectId, dataList.size(),fwdGroupId);
|
||||||
|
//logger.debug(json);
|
||||||
|
try {
|
||||||
|
listener.clear();
|
||||||
|
xfzTcpClient.writeAndFlush(json);
|
||||||
|
//等待应答
|
||||||
|
if(checkResult()) sendNum += batchNum;
|
||||||
|
} catch (Exception e1) {
|
||||||
|
logger.error(e1.toString());
|
||||||
|
}
|
||||||
|
batchNum = 0;
|
||||||
|
dataList.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if(batchNum>0){
|
||||||
|
String json = "#" + GsonUtil.toJson(xfzTcpMessage) + "!";
|
||||||
|
logger.debug("project {}: forwad {} gnss records to {}",projectId, dataList.size(),fwdGroupId);
|
||||||
|
logger.debug(json);
|
||||||
|
try {
|
||||||
|
listener.clear();
|
||||||
|
xfzTcpClient.writeAndFlush(json);
|
||||||
|
//等待应答
|
||||||
|
if(checkResult()) sendNum += batchNum;
|
||||||
|
} catch (Exception e1) {
|
||||||
|
logger.error(e1.toString());
|
||||||
|
}
|
||||||
|
dataList.clear();
|
||||||
|
}
|
||||||
|
return sendNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void forwardHistoryGnss(){
|
||||||
|
// 1.从转发记录表里检索待补传记录时间表,含设备Id,时间段
|
||||||
|
QueryWrapper<ResendRecord> queryWrapper = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("fwd_group_id",fwdGroupId);
|
||||||
|
queryWrapper.eq("state",ResendRecord.STATE_BREAK_POINT);
|
||||||
|
queryWrapper.ge("createtime", LocalDateTime.now().minusDays(30));
|
||||||
|
List<ResendRecord> resendRecordsList = resendRecordMapper.selectList(queryWrapper);
|
||||||
|
|
||||||
|
if(resendRecordsList!=null && resendRecordsList.size()>0){
|
||||||
|
//修改状态
|
||||||
|
UpdateWrapper<ResendRecord> updateWrapper = new UpdateWrapper<>();
|
||||||
|
updateWrapper.eq("fwd_group_id",fwdGroupId);
|
||||||
|
updateWrapper.eq("state",ResendRecord.STATE_BREAK_POINT);
|
||||||
|
updateWrapper.ge("createtime", LocalDateTime.now().minusDays(30));
|
||||||
|
updateWrapper.set("state",ResendRecord.STATE_FWDING);
|
||||||
|
int updateNum = resendRecordMapper.update(null, updateWrapper);
|
||||||
|
logger.debug("{} forward history records: {}, update {}",fwdGroupId, resendRecordsList.size(),updateNum);
|
||||||
|
// 2.检索这个这个时间段的解算结果,如果有数据则单个终端转发,标志记录为已补传
|
||||||
|
for(ResendRecord record:resendRecordsList){
|
||||||
|
if(record.getProjectid()!=null)
|
||||||
|
logger.debug("{} forward history {}",fwdGroupId, record.getProjectid());
|
||||||
|
forwardBatchGnssRecords(record);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user