wanglizhong
2025-05-08 783686ff99c571dd41fc86cc7d93c92173fe86a0
fix:电子地图显示问题
4个文件已修改
114 ■■■■■ 已修改文件
ruoyi-system/src/main/java/com/ruoyi/system/domain/VehicleGps.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/resources/mapper/system/VehicleGpsMapper.xml 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-ui/src/views/system/gps/map.vue 45 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-ui/src/views/system/gps/mapNeed.vue 44 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/domain/VehicleGps.java
@@ -58,6 +58,12 @@
    @Excel(name = "GPS平台处理时间")
    private String platformProcessTime;
    /** 开始时间 */
    private String beginTime;
    /** 结束时间 */
    private String endTime;
    public void setGpsId(Long gpsId) {
        this.gpsId = gpsId;
    }
@@ -154,6 +160,22 @@
        return platformProcessTime;
    }
    public String getBeginTime() {
        return beginTime;
    }
    public void setBeginTime(String beginTime) {
        this.beginTime = beginTime;
    }
    public String getEndTime() {
        return endTime;
    }
    public void setEndTime(String endTime) {
        this.endTime = endTime;
    }
    @Override
    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
ruoyi-system/src/main/resources/mapper/system/VehicleGpsMapper.xml
@@ -37,7 +37,8 @@
            <if test="altitude != null "> and g.altitude = #{altitude}</if>
            <if test="speed != null "> and g.speed = #{speed}</if>
            <if test="direction != null "> and g.direction = #{direction}</if>
            <if test="collectTime != null  and collectTime != ''"> and g.collect_time = #{collectTime}</if>
            <if test="beginTime != null and beginTime != ''"> and g.collect_time &gt;= #{beginTime}</if>
            <if test="endTime != null and endTime != ''"> and g.collect_time &lt;= #{endTime}</if>
        </where>
    </select>
    
ruoyi-ui/src/views/system/gps/map.vue
@@ -169,10 +169,18 @@
    if (query.timestamp) {
      this.queryParams.timestamp = query.timestamp;
    }
    // 设置时间范围
    // 设置默认时间范围
    const today = new Date();
    const startTime = new Date(today.getFullYear(), today.getMonth(), today.getDate(), 0, 0, 0);
    const endTime = new Date(today.getFullYear(), today.getMonth(), today.getDate(), 23, 59, 59);
    this.dateRange = [this.parseTime(startTime), this.parseTime(endTime)];
    // 如果URL中有时间参数,则使用URL中的时间
    if (query.beginTime && query.endTime) {
      this.dateRange = [query.beginTime, query.endTime];
    }
    this.getList();
  },
  mounted() {
@@ -220,10 +228,37 @@
        };
      });
    },
    /** 格式化时间 */
    parseTime(time) {
      const year = time.getFullYear();
      const month = String(time.getMonth() + 1).padStart(2, '0');
      const day = String(time.getDate()).padStart(2, '0');
      const hours = String(time.getHours()).padStart(2, '0');
      const minutes = String(time.getMinutes()).padStart(2, '0');
      const seconds = String(time.getSeconds()).padStart(2, '0');
      return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
    },
    /** 查询GPS列表 */
    getList() {
      this.loading = true;      
      anonymousList(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
      // 构建查询参数
      const params = {
        ...this.queryParams
      };
      // 如果没有选择时间范围,则默认使用当天
      if (!this.dateRange || this.dateRange.length === 0) {
        const today = new Date();
        const startTime = new Date(today.getFullYear(), today.getMonth(), today.getDate(), 0, 0, 0);
        const endTime = new Date(today.getFullYear(), today.getMonth(), today.getDate(), 23, 59, 59);
        params.beginTime = this.parseTime(startTime);
        params.endTime = this.parseTime(endTime);
      } else {
        params.beginTime = this.dateRange[0];
        params.endTime = this.dateRange[1];
      }
      anonymousList(params).then(response => {
        this.gpsList = response.rows;
        this.total = response.total;
        this.loading = false;
@@ -252,7 +287,11 @@
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      // 重置为当天时间范围
      const today = new Date();
      const startTime = new Date(today.getFullYear(), today.getMonth(), today.getDate(), 0, 0, 0);
      const endTime = new Date(today.getFullYear(), today.getMonth(), today.getDate(), 23, 59, 59);
      this.dateRange = [this.parseTime(startTime), this.parseTime(endTime)];
      this.resetForm("queryForm");
      this.handleQuery();
    },
ruoyi-ui/src/views/system/gps/mapNeed.vue
@@ -160,10 +160,17 @@
      this.queryParams.vehicleNo = query.vehicleNo;
    }
    
    // 设置时间范围
    // 设置默认时间范围
    const today = new Date();
    const startTime = new Date(today.getFullYear(), today.getMonth(), today.getDate(), 0, 0, 0);
    const endTime = new Date(today.getFullYear(), today.getMonth(), today.getDate(), 23, 59, 59);
    this.dateRange = [this.parseTime(startTime), this.parseTime(endTime)];
    // 如果URL中有时间参数,则使用URL中的时间
    if (query.beginTime && query.endTime) {
      this.dateRange = [query.beginTime, query.endTime];
    }
    this.getList();
  },
  mounted() {
@@ -214,7 +221,24 @@
    /** 查询GPS列表 */
    getList() {
      this.loading = true;      
      listGps(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
      // 构建查询参数
      const params = {
        ...this.queryParams
      };
      // 如果没有选择时间范围,则默认使用当天
      if (!this.dateRange || this.dateRange.length === 0) {
        const today = new Date();
        const startTime = new Date(today.getFullYear(), today.getMonth(), today.getDate(), 0, 0, 0);
        const endTime = new Date(today.getFullYear(), today.getMonth(), today.getDate(), 23, 59, 59);
        params.beginTime = this.parseTime(startTime);
        params.endTime = this.parseTime(endTime);
      } else {
        params.beginTime = this.dateRange[0];
        params.endTime = this.dateRange[1];
      }
      listGps(params).then(response => {
        this.gpsList = response.rows;
        this.total = response.total;
        this.loading = false;
@@ -223,6 +247,16 @@
          this.drawTrack();
        }
      });
    },
    /** 格式化时间 */
    parseTime(time) {
      const year = time.getFullYear();
      const month = String(time.getMonth() + 1).padStart(2, '0');
      const day = String(time.getDate()).padStart(2, '0');
      const hours = String(time.getHours()).padStart(2, '0');
      const minutes = String(time.getMinutes()).padStart(2, '0');
      const seconds = String(time.getSeconds()).padStart(2, '0');
      return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
    },
    async translatePoints(points) {
      // 将WGS84坐标转换为百度坐标
@@ -243,7 +277,11 @@
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      // 重置为当天时间范围
      const today = new Date();
      const startTime = new Date(today.getFullYear(), today.getMonth(), today.getDate(), 0, 0, 0);
      const endTime = new Date(today.getFullYear(), today.getMonth(), today.getDate(), 23, 59, 59);
      this.dateRange = [this.parseTime(startTime), this.parseTime(endTime)];
      this.resetForm("queryForm");
      this.handleQuery();
    },