diff --git a/zc-business/src/main/java/com/zc/business/controller/DcDeviceOnlineController.java b/zc-business/src/main/java/com/zc/business/controller/DcDeviceOnlineController.java index 52e08c39..a3c4a701 100644 --- a/zc-business/src/main/java/com/zc/business/controller/DcDeviceOnlineController.java +++ b/zc-business/src/main/java/com/zc/business/controller/DcDeviceOnlineController.java @@ -367,9 +367,15 @@ public class DcDeviceOnlineController extends BaseController { String FAIL_RATE = "failRate";//离线率 String SUM_USE_STATE = "sumUseState";//在用数 String SUM = "sum";//总数 - Map returnMap = new HashMap<>(); + Map returnMap = new LinkedHashMap<>(); List dcDeviceList = dcDeviceService.list(); List dcRoadSections = dcRoadSectionService.selectDcRoadSectionList(new DcRoadSection()); + + // 创建一个映射存储roadId到sectionName + Map roadIdToSectionNameMap = new HashMap<>(); + for (DcRoadSection dcRoadSection : dcRoadSections) { + roadIdToSectionNameMap.put(dcRoadSection.getId().toString(), dcRoadSection.getSectionName()); + } /* // 去重设备列表 dcDeviceList = dcDeviceList.stream() .distinct() @@ -417,6 +423,7 @@ public class DcDeviceOnlineController extends BaseController { devicesInRoad.forEach(device -> System.out.println("Device ID: " + device.getId() + ", Stake Mark: " + device.getStakeMark())); }*/ } + List> sortedEntries = new ArrayList<>(); for (DcRoadSection dcRoadSection : dcRoadSections) { Map itemMap = new HashMap<>(); String roadId = dcRoadSection.getId().toString(); @@ -445,8 +452,15 @@ public class DcDeviceOnlineController extends BaseController { // 丢包率暂时设置为空 itemMap.put(LOST_RATE, ""); + // 添加到列表中 + sortedEntries.add(new AbstractMap.SimpleEntry<>(roadId, itemMap)); + // 将排序后的条目添加到returnMap中,使用sectionName作为键 + for (Map.Entry entry : sortedEntries) { + String Id = entry.getKey(); + String sectionName = roadIdToSectionNameMap.get(Id); + returnMap.put(sectionName, entry.getValue()); + } - returnMap.put(dcRoadSection.getSectionName(), itemMap); } return AjaxResult.success(returnMap); diff --git a/zc-business/src/main/java/com/zc/business/domain/DcDeviceOfflineRecord.java b/zc-business/src/main/java/com/zc/business/domain/DcDeviceOfflineRecord.java index ae0528ec..035091ce 100644 --- a/zc-business/src/main/java/com/zc/business/domain/DcDeviceOfflineRecord.java +++ b/zc-business/src/main/java/com/zc/business/domain/DcDeviceOfflineRecord.java @@ -1,5 +1,6 @@ package com.zc.business.domain; +import com.baomidou.mybatisplus.annotation.TableField; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import org.apache.commons.lang3.builder.ToStringBuilder; @@ -62,6 +63,9 @@ public class DcDeviceOfflineRecord extends BaseEntity @Excel(name = "所在桩号") @ApiModelProperty(value="所在桩号") private String stakeMark; + @TableField(exist = false) + private String endStakeMark; + /** 方向1-上行,2-中,3-下行 */ @ApiModelProperty(value="方向") @@ -126,6 +130,13 @@ public class DcDeviceOfflineRecord extends BaseEntity @Excel(name = "诊断结果") private String diagnostics; + public String getEndStakeMark() { + return endStakeMark; + } + + public void setEndStakeMark(String endStakeMark) { + this.endStakeMark = endStakeMark; + } public void setId(Long id) { this.id = id; diff --git a/zc-business/src/main/resources/mapper/business/DcDeviceOfflineRecordMapper.xml b/zc-business/src/main/resources/mapper/business/DcDeviceOfflineRecordMapper.xml index 93655567..b2d8d853 100644 --- a/zc-business/src/main/resources/mapper/business/DcDeviceOfflineRecordMapper.xml +++ b/zc-business/src/main/resources/mapper/business/DcDeviceOfflineRecordMapper.xml @@ -36,7 +36,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and iot_device_id = #{iotDeviceId} and device_name like concat('%', #{deviceName}, '%') and device_type = #{deviceType} - and stake_mark = #{stakeMark} + and stake_mark BETWEEN #{stakeMark} and #{endStakeMark} and direction = #{direction} and installation_site = #{installationSite} and device_ip = #{deviceIp}