1. 定时任务调整
This commit is contained in:
parent
c115f0ef62
commit
1b4833fde2
|
@ -505,6 +505,8 @@ public class EtTask {
|
|||
*/
|
||||
public void updateLocation10(){
|
||||
log.info("-------------------【定时任务10秒一次】更新设备的定位和电压-----开始--------------");
|
||||
// 记录开始时间
|
||||
long startTime = System.nanoTime();
|
||||
Collection<String> keys = redisCache.keys(CacheConstants.CACHE_DEVICE_KEY + "*");
|
||||
log.info("redis缓存中的数据:" + JSON.toJSONString(keys));
|
||||
for(String key:keys){
|
||||
|
@ -514,11 +516,14 @@ public class EtTask {
|
|||
log.info("logEntry转换后的对象: logEntry---【{}】" , JSON.toJSONString(logEntry));
|
||||
LogEntry.LocationValue value = logEntry.getValue();
|
||||
AsDevice device = asDeviceMapper.selectAsDeviceByMac(logEntry.getDevName());
|
||||
if(ServiceConstants.LOCK_STATUS_OPEN.equals(device.getLockStatus())){
|
||||
log.info("device: sn={},【{}】",device.getSn() , JSON.toJSONString(device));
|
||||
if(ServiceConstants.LOCK_STATUS_OPEN.equals(device.getLockStatus()) && device.getStatus().equals(ServiceConstants.VEHICLE_STATUS_IN_USING)){
|
||||
updateLocationHandle(msg, logEntry, value, device);
|
||||
}
|
||||
}
|
||||
log.info("-------------------【定时任务10秒一次】更新设备的定位和电压----结束---------------");
|
||||
// 计算执行时间(以毫秒为单位)
|
||||
long duration = (System.nanoTime() - startTime) / 1_000_000;
|
||||
log.info("-------------------【定时任务10秒一次】更新设备的定位和电压----结束---------------"+duration+ " 毫秒");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -527,6 +532,8 @@ public class EtTask {
|
|||
*/
|
||||
public void updateLocation300(){
|
||||
log.info("-------------------【定时任务5分钟一次】更新设备的定位和电压-----开始--------------");
|
||||
// 记录开始时间
|
||||
long startTime = System.nanoTime();
|
||||
Collection<String> keys = redisCache.keys(CacheConstants.CACHE_DEVICE_KEY + "*");
|
||||
log.info("redis缓存中的数据:" + JSON.toJSONString(keys));
|
||||
for(String key:keys){
|
||||
|
@ -540,16 +547,18 @@ public class EtTask {
|
|||
updateLocationHandle(msg, logEntry, value, device);
|
||||
}
|
||||
}
|
||||
log.info("-------------------【定时任务5分钟一次】更新设备的定位和电压----结束---------------");
|
||||
// 计算执行时间(以毫秒为单位)
|
||||
long duration = (System.nanoTime() - startTime) / 1_000_000;
|
||||
log.info("-------------------【定时任务5分钟一次】更新设备的定位和电压----结束---------------"+duration+ " 毫秒");
|
||||
}
|
||||
|
||||
private void updateLocationHandle(String msg, LogEntry logEntry, LogEntry.LocationValue value, AsDevice device) {
|
||||
// 坐标转换 WGS84 转 GCJ02
|
||||
double[] doubles = coordinateConvert(value);
|
||||
BigDecimal lat = new BigDecimal(doubles[0]).setScale(8, RoundingMode.HALF_UP);
|
||||
BigDecimal lon = new BigDecimal(doubles[1]).setScale(8, RoundingMode.HALF_UP);
|
||||
BigDecimal lat = new BigDecimal(doubles[0]).setScale(8, RoundingMode.HALF_UP);
|
||||
|
||||
asynchronousSaveLog(msg, logEntry.getAt(), logEntry.getDevName(), lat, lon, device);
|
||||
asynchronousSaveLog(msg, logEntry.getAt(), logEntry.getDevName(), lon, lat, device);
|
||||
|
||||
BigDecimal divide = new BigDecimal(value.getBat()).divide(new BigDecimal(10));
|
||||
device.setVoltage(divide.toString());//电压
|
||||
|
|
Loading…
Reference in New Issue
Block a user