修改构造数据的bug
This commit is contained in:
parent
75946d75c3
commit
87c60152f7
@ -38,7 +38,7 @@ public class ZNYForwarder extends Forwarder{
|
|||||||
private void checkDevice() {
|
private void checkDevice() {
|
||||||
//logger.info("zny checkDevice");
|
//logger.info("zny checkDevice");
|
||||||
checkNoDataDevice("2345078","2345065","2345073");
|
checkNoDataDevice("2345078","2345065","2345073");
|
||||||
checkNoDataDevice("2345085","2345068","2345075");
|
//checkNoDataDevice("2345085","2345068","2345075");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Scheduled(cron = "0 0/30 * * * ?") // 每30分钟执行一次
|
@Scheduled(cron = "0 0/30 * * * ?") // 每30分钟执行一次
|
||||||
|
|||||||
@ -0,0 +1,142 @@
|
|||||||
|
package com.imdroid.sideslope.task;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.imdroid.secapi.dto.*;
|
||||||
|
import com.imdroid.sideslope.calc.GNSSCalcFilterService;
|
||||||
|
import com.imdroid.sideslope.sal.Device;
|
||||||
|
import com.imdroid.sideslope.sal.DeviceService;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
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.Resource;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Configuration
|
||||||
|
@EnableScheduling
|
||||||
|
public class AbnormalDeviceProcessor{
|
||||||
|
final Logger logger = LoggerFactory.getLogger(AbnormalDeviceProcessor.class);
|
||||||
|
@Autowired
|
||||||
|
private GnssCalcDataMapper gnssDataMapper;
|
||||||
|
@Autowired
|
||||||
|
private GnssStatusMapper gnssStatusMapper;
|
||||||
|
@Autowired
|
||||||
|
GNSSCalcFilterService filterService;
|
||||||
|
@Resource(name = "local")
|
||||||
|
private DeviceService deviceService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
GnssGroupCalcMapper groupCalcMapper;
|
||||||
|
@Autowired
|
||||||
|
GnssCalcDataMapper dataMapper;
|
||||||
|
|
||||||
|
// 非线程安全,需加同步保护
|
||||||
|
List<GnssGroupCalc> groupCalcList;
|
||||||
|
|
||||||
|
synchronized GnssGroupCalc getGroupCalc(int groupId){
|
||||||
|
if(groupCalcList == null){
|
||||||
|
groupCalcList = groupCalcMapper.selectList(null);
|
||||||
|
}
|
||||||
|
if(groupCalcList != null){
|
||||||
|
for(GnssGroupCalc groupCalc:groupCalcList){
|
||||||
|
if(groupCalc.getId() == groupId) return groupCalc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Scheduled(cron = "0 0/10 * * * ?") // 每30分钟执行一次
|
||||||
|
private void checkDevice() {
|
||||||
|
//logger.info("zny checkDevice");
|
||||||
|
//checkNoDataDevice("2345078","2345065","2345073");
|
||||||
|
checkNoDataDevice("2345085","2345068","2345075");
|
||||||
|
}
|
||||||
|
|
||||||
|
void checkNoDataDevice(String noDataDeviceId, String refDeviceId1, String refDeviceId2){
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
QueryWrapper<GnssCalcData> queryWrapper = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("deviceid",noDataDeviceId);
|
||||||
|
queryWrapper.eq("enabled",true);
|
||||||
|
queryWrapper.isNotNull("rpose");
|
||||||
|
queryWrapper.ne("pps",-1);
|
||||||
|
queryWrapper.ge("createtime",now.minusMinutes(30));
|
||||||
|
queryWrapper.last("limit 1");
|
||||||
|
|
||||||
|
if(gnssDataMapper.selectOne(queryWrapper) != null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// only handle online device
|
||||||
|
GnssStatus noDataDevice = gnssStatusMapper.getByDeviceId(noDataDeviceId);
|
||||||
|
if(noDataDevice == null || noDataDevice.getState() == GnssStatus.STATE_OFFLINE) return;
|
||||||
|
GnssStatus refDevice1 = gnssStatusMapper.getByDeviceId(refDeviceId1);
|
||||||
|
if(refDevice1 == null || refDevice1.getState() == GnssStatus.STATE_OFFLINE) return;
|
||||||
|
GnssStatus refDevice2 = gnssStatusMapper.getByDeviceId(refDeviceId2);
|
||||||
|
if(refDevice2 == null || refDevice2.getState() == GnssStatus.STATE_OFFLINE) return;
|
||||||
|
|
||||||
|
insertData(noDataDeviceId, getOriginalDelta(refDeviceId1), getOriginalDelta(refDeviceId2));
|
||||||
|
}
|
||||||
|
|
||||||
|
double[] getOriginalDelta(String refDeviceId) {
|
||||||
|
QueryWrapper<GnssCalcData> queryWrapper = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("deviceid",refDeviceId);
|
||||||
|
queryWrapper.eq("enabled",true);
|
||||||
|
queryWrapper.isNotNull("rpose");
|
||||||
|
queryWrapper.orderByDesc("createtime");
|
||||||
|
queryWrapper.last("limit 2");
|
||||||
|
List<GnssCalcData> refGnssCalcDataList = gnssDataMapper.selectList(queryWrapper);
|
||||||
|
if(refGnssCalcDataList.size()>=2) {
|
||||||
|
double deltaOrignalE = refGnssCalcDataList.get(0).getB562e() - refGnssCalcDataList.get(1).getB562e();
|
||||||
|
double deltaOrignalN = refGnssCalcDataList.get(0).getB562n() - refGnssCalcDataList.get(1).getB562n();
|
||||||
|
double deltaOrignalD = refGnssCalcDataList.get(0).getB562d() - refGnssCalcDataList.get(1).getB562d();
|
||||||
|
return new double[]{deltaOrignalE, deltaOrignalN, deltaOrignalD};
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
void insertData(String noDataDeviceId,double refGnssData1[],double refGnssData2[]){
|
||||||
|
logger.debug("{} abnormal process");
|
||||||
|
if(refGnssData1!=null && refGnssData2!=null){
|
||||||
|
logger.debug("{} delta: {},{},{}",
|
||||||
|
(refGnssData1[0]+refGnssData2[0])/2,
|
||||||
|
(refGnssData1[1]+refGnssData2[1])/2,
|
||||||
|
(refGnssData1[2]+refGnssData2[2])/2);
|
||||||
|
|
||||||
|
QueryWrapper<GnssCalcData> queryWrapper = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("deviceid",noDataDeviceId);
|
||||||
|
queryWrapper.orderByDesc("createtime");
|
||||||
|
queryWrapper.last("limit 1");
|
||||||
|
GnssCalcData offGnssCalcData = gnssDataMapper.selectOne(queryWrapper);
|
||||||
|
if(offGnssCalcData==null) return;
|
||||||
|
|
||||||
|
double[] lastPoit = new double[]{offGnssCalcData.getB562e(),
|
||||||
|
offGnssCalcData.getB562n(), offGnssCalcData.getB562d()};
|
||||||
|
|
||||||
|
Device device = deviceService.findByDeviceId(noDataDeviceId);
|
||||||
|
if(device == null) return;
|
||||||
|
GnssGroupCalc groupCalc = getGroupCalc(device.getCalcGroupId());
|
||||||
|
|
||||||
|
GnssCalcData locationRecord = new GnssCalcData();
|
||||||
|
locationRecord.setDeviceid(noDataDeviceId);
|
||||||
|
locationRecord.setTenantid(device.getTenantId());
|
||||||
|
locationRecord.setEnabled(true);
|
||||||
|
locationRecord.setCreatetime(LocalDateTime.now());
|
||||||
|
locationRecord.setUpdatetime(LocalDateTime.now()); //通过这里可以区分补传记录
|
||||||
|
|
||||||
|
// 调用这个函数之前已判断是否为null
|
||||||
|
locationRecord.setB562e(offGnssCalcData.getB562e()+(refGnssData1[0]+refGnssData2[0])/2); //mm
|
||||||
|
locationRecord.setB562n(offGnssCalcData.getB562n()+(refGnssData1[1]+refGnssData2[1])/2);
|
||||||
|
locationRecord.setB562d(offGnssCalcData.getB562d()+(refGnssData1[2]+refGnssData2[2])/2);
|
||||||
|
|
||||||
|
locationRecord.setPps(-1);//标记为虚拟数据
|
||||||
|
filterService.calc(device, groupCalc, locationRecord, lastPoit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user