#增加路径返回cell
This commit is contained in:
@@ -7,6 +7,8 @@ public class LatAndLngEntity {
|
||||
private double lat;
|
||||
private double lng;
|
||||
|
||||
private int cell;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "{" + lat + "," + lng + '}';
|
||||
|
||||
@@ -17,11 +17,22 @@ import com.maibu.mybatis.mapper.BaseMapperX;
|
||||
@Repository
|
||||
public interface DevicePlanTaskMapper extends BaseMapperX<DevicePlanTask> {
|
||||
|
||||
@Select("SELECT t.*, iwr.work_name,d.device_alias " +
|
||||
// @Select("SELECT t.*, iwr.work_name,d.device_alias " +
|
||||
// "FROM iot_device_task t " +
|
||||
// "LEFT JOIN iot_device d ON d.serial_number = t.device_id " +
|
||||
// "left join iot_work_record iwr on t.route_id = iwr.id " +
|
||||
// "${ew.customSqlSegment}")
|
||||
// List<DevicePlanTask> selectTaskHistoryWithDeviceAlias(
|
||||
// @Param(Constants.WRAPPER) Wrapper<DevicePlanTask> wrapper);
|
||||
|
||||
@Select("SELECT t.*, iwr.work_name, d.device_alias " +
|
||||
"FROM iot_device_task t " +
|
||||
"LEFT JOIN iot_device d ON d.serial_number = t.device_id " +
|
||||
"left join iot_work_record iwr on t.route_id = iwr.id " +
|
||||
"${ew.customSqlSegment}")
|
||||
"LEFT JOIN iot_work_record iwr ON t.route_id = iwr.id " +
|
||||
"${ew.customSqlSegment} " +
|
||||
"ORDER BY " +
|
||||
"t.create_time IS NULL ASC, t.create_time DESC, " +
|
||||
"t.finish_time IS NULL ASC, t.finish_time DESC")
|
||||
List<DevicePlanTask> selectTaskHistoryWithDeviceAlias(
|
||||
@Param(Constants.WRAPPER) Wrapper<DevicePlanTask> wrapper);
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ public class GlobalMemory {
|
||||
// key:orgId - siteId
|
||||
public static ConcurrentHashMap<Long, Map<Long, SiteMemory>> orgAttrs = new ConcurrentHashMap<>();
|
||||
|
||||
public static ConcurrentHashMap<Long, List<LatAndLngEntity>> taskPathMap = new ConcurrentHashMap<>();
|
||||
public static ConcurrentHashMap<Long, List<List<LatAndLngEntity>>> taskPathMap = new ConcurrentHashMap<>();
|
||||
|
||||
public static InfluxDBUtil influxDBUtil;
|
||||
|
||||
|
||||
@@ -518,11 +518,11 @@ public class DeviceTaskService {
|
||||
DeviceTaskStaus taskStaus = x.getTaskStaus();
|
||||
x.setTaskStausTranslate(taskStaus.getDescription());
|
||||
});
|
||||
list.sort(
|
||||
Comparator.comparing(DevicePlanTask::getCreateTime,
|
||||
Comparator.nullsLast(Comparator.reverseOrder()))
|
||||
.thenComparing(DevicePlanTask::getFinishTime,
|
||||
Comparator.nullsLast(Comparator.reverseOrder())));
|
||||
// list.sort(
|
||||
// Comparator.comparing(DevicePlanTask::getCreateTime,
|
||||
// Comparator.nullsLast(Comparator.reverseOrder()))
|
||||
// .thenComparing(DevicePlanTask::getFinishTime,
|
||||
// Comparator.nullsLast(Comparator.reverseOrder())));
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,11 @@ import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -149,7 +153,7 @@ public class HostComputerController extends BaseController {
|
||||
log.info("csv 解析完成: taskId={}, 共 {} 个轨迹点, 分 {} 批处理", taskId, allPath.size(), batchIndex);
|
||||
|
||||
if (pathId == null) {
|
||||
GlobalMemory.taskPathMap.put(taskId, allPath);
|
||||
GlobalMemory.taskPathMap.put(taskId, groupByCell(allPath));
|
||||
sendMessage(taskId, allPath);
|
||||
} else {
|
||||
// 上传到 MinIO
|
||||
@@ -174,6 +178,20 @@ public class HostComputerController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
public List<List<LatAndLngEntity>> groupByCell(List<LatAndLngEntity> points) {
|
||||
if (points == null || points.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
Map<Integer, List<LatAndLngEntity>> groupedMap = points.stream()
|
||||
.collect(Collectors.groupingBy(
|
||||
LatAndLngEntity::getCell,
|
||||
TreeMap::new,
|
||||
Collectors.toList()));
|
||||
|
||||
return new ArrayList<>(groupedMap.values());
|
||||
}
|
||||
|
||||
/**
|
||||
* 定位信息 经纬度
|
||||
*/
|
||||
@@ -228,6 +246,8 @@ public class HostComputerController extends BaseController {
|
||||
String xStr = values[2].trim();
|
||||
String yStr = values[3].trim();
|
||||
|
||||
String cellStr = values[0].trim();
|
||||
|
||||
if (xStr.isEmpty() || yStr.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
@@ -235,6 +255,8 @@ public class HostComputerController extends BaseController {
|
||||
LatAndLngEntity entity = new LatAndLngEntity();
|
||||
entity.setLat(Double.parseDouble(xStr));
|
||||
entity.setLng(Double.parseDouble(yStr));
|
||||
|
||||
entity.setCell(Integer.parseInt(cellStr));
|
||||
return entity;
|
||||
} catch (NumberFormatException e) {
|
||||
log.warn("解析轨迹点失败: values={}, error={}", Arrays.toString(values), e.getMessage());
|
||||
|
||||
Reference in New Issue
Block a user