Sfoglia il codice sorgente

任务提交 小车位置和状态加入时间范围 停泊点自动增加策略编号

秦国才 1 anno fa
parent
commit
6b60b15543

+ 3 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/CarPosition.java

@@ -2,6 +2,8 @@ package com.ruoyi.system.domain;
 
 import java.util.Date;
 import java.io.Serializable;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
 
 /**
@@ -24,6 +26,7 @@ public class CarPosition implements Serializable {
 /**
      * 创建时间
      */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private Date createTime;
 /**
      * 站点ID

+ 3 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/HeartBeat.java

@@ -2,6 +2,8 @@ package com.ruoyi.system.domain;
 
 import java.util.Date;
 import java.io.Serializable;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
 
 /**
@@ -52,6 +54,7 @@ public class HeartBeat implements Serializable {
 /**
      * 创建时间
      */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private Date createTime;
 /**
      * 站点ID

+ 4 - 4
ruoyi-system/src/main/java/com/ruoyi/system/dto/BerthingPointConfigDTO.java

@@ -26,10 +26,10 @@ public class BerthingPointConfigDTO implements Serializable {
 /**
      * 策略编号
      */
-    @DecimalMax(value = "20", message = "策略编号1-20之间")
-    @DecimalMin(value = "1", message = "策略编号1-20之间")
-    @NotNull(message = "策略编号不能为空")
-    private Long planid;
+//    @DecimalMax(value = "20", message = "策略编号1-20之间")
+//    @DecimalMin(value = "1", message = "策略编号1-20之间")
+//    @NotNull(message = "策略编号不能为空")
+//    private Long planid;
 
 /**
      * 停泊点位json list字符串 例子:[{“x”:54.3,"y":44.2}]

+ 8 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/CarPositionMapper.java

@@ -30,6 +30,14 @@ public interface CarPositionMapper {
      */
     CarPosition queryBysiteId(Long siteId);
 
+
+    /**
+     * 通过时间查询
+     *
+     * @param siteId 主键
+     * @return 实例对象
+     */
+    List<CarPosition> queryBysiteIdTime(@Param("pageable")Long siteId, @Param("startTime")String startTime, @Param("endTime")String endTime);
     /**
      * 查询指定行数据
      *

+ 9 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/HeartBeatMapper.java

@@ -30,6 +30,15 @@ public interface HeartBeatMapper {
      */
     HeartBeat queryBysiteId(Long siteId);
 
+
+    /**
+     * 通过ID查询单条数据
+     *
+     * @param siteId 主键
+     * @return 实例对象
+     */
+    List<HeartBeat> queryBysiteIdTime(@Param( "siteId")Long siteId, @Param( "startTime") String startTime, @Param( "endTime") String endTime);
+
     /**
      * 查询指定行数据
      *

+ 2 - 2
ruoyi-system/src/main/java/com/ruoyi/system/service/ReportDataService.java

@@ -12,9 +12,9 @@ import java.util.Map;
 
 public interface ReportDataService {
 
-    CarPosition carLocation(Long siteId);
+    List<CarPosition> carLocation(Long siteId, String startTime, String endTime);
 
-    HeartBeat carInfo(Long siteId);
+    List<HeartBeat> carInfo(Long siteId,String startTime, String endTime);
 
     SiteRealTimeDTO siteRealTime(Long siteId);
 

+ 2 - 9
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/BerthingServiceImpl.java

@@ -238,18 +238,11 @@ public class BerthingServiceImpl implements BerthingService {
                 if (count > 0){
                     throw new BaseException("起测水位已存在");
                 }
-                //有无重复策略号
-                berthingPointConfig.setPlanid(berthingPointConfigDTO.getPlanid());
-                berthingPointConfig.setWlevel(null);
-                count = berthingPointConfigMapper.count(berthingPointConfig);
-                if (count > 0){
-                    throw new BaseException("策略编号已存在");
-                }
                 berthingPointConfig.setStopId(0L);
                 berthingPointConfig.setSiteId(siteInfo.getSiteId());
                 berthingPointConfig.setBerthingId(berthingPoint.getBerthingId());
                 berthingPointConfig.setPositions(JSONUtil.toJsonStr(positions));
-                berthingPointConfig.setPlanid(berthingPointConfigDTO.getPlanid());
+                berthingPointConfig.setPlanid(0L);
                 berthingPointConfig.setWlevel(berthingPointConfigDTO.getWlevel());
                 berthingPointConfig.setFactors(JSONUtil.toJsonStr(berthingPointConfigDTO.getFactors()));
                 berthingPointConfig.setCreateTime(new Date());
@@ -263,7 +256,7 @@ public class BerthingServiceImpl implements BerthingService {
                 berthingPointConfigMapper.update(berthingPointConfig);
                 berthingPointConfig.setStopId(0L);
                 berthingPointConfig.setPositions(JSONUtil.toJsonStr(positions));
-                berthingPointConfig.setPlanid(berthingPointConfigDTO.getPlanid());
+                berthingPointConfig.setPlanid(0L);
                 berthingPointConfig.setWlevel(berthingPointConfigDTO.getWlevel());
                 berthingPointConfig.setFactors(JSONUtil.toJsonStr(berthingPointConfigDTO.getFactors()));
                 res =  berthingPointConfigMapper.insert(berthingPointConfig) > 0;

+ 11 - 4
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ReportDataServiceImpl.java

@@ -16,6 +16,7 @@ import org.springframework.stereotype.Service;
 import javax.annotation.Resource;
 import java.time.LocalTime;
 import java.time.format.DateTimeFormatter;
+import java.util.Collections;
 import java.util.Date;
 import java.util.List;
 
@@ -59,13 +60,19 @@ public class ReportDataServiceImpl implements ReportDataService {
     private BerthingPointConfigMapper berthingPointConfigMapper;
 
     @Override
-    public CarPosition carLocation(Long siteId){
-        return carPositionMapper.queryBysiteId(siteId);
+    public List<CarPosition> carLocation(Long siteId, String startTime, String endTime){
+        if (Strings.isNotBlank(startTime) && Strings.isNotBlank(endTime)){
+            return carPositionMapper.queryBysiteIdTime(siteId,startTime,endTime);
+        }
+        return Collections.singletonList(carPositionMapper.queryBysiteId(siteId));
     }
 
     @Override
-    public HeartBeat carInfo(Long siteId){
-        return heartBeatMapper.queryBysiteId(siteId);
+    public List<HeartBeat> carInfo(Long siteId,String startTime, String endTime){
+        if (Strings.isNotBlank(startTime) && Strings.isNotBlank(endTime)){
+            return heartBeatMapper.queryBysiteIdTime(siteId,startTime,endTime);
+        }
+        return Collections.singletonList(heartBeatMapper.queryBysiteId(siteId));
     }
 
 

+ 1 - 1
ruoyi-system/src/main/resources/mapper/BerthingPointConfigMapper.xml

@@ -94,7 +94,7 @@
 
     <!--新增所有列-->
     <insert id="insert" keyProperty="stopId" useGeneratedKeys="true">
-        insert into berthing_point_config(id, site_id, planid, berthing_id, positions, create_time, status, is_del, wlevel, factors)
+        insert into berthing_point_config (id, site_id, planid, berthing_id, positions, create_time, status, is_del, wlevel, factors)
         values (#{id}, #{siteId}, #{planid}, #{berthingId}, #{positions}, #{createTime}, #{status}, #{isDel}, #{wlevel}, #{factors})
     </insert>
 

+ 9 - 0
ruoyi-system/src/main/resources/mapper/CarPositionMapper.xml

@@ -29,6 +29,15 @@
         limit 1
     </select>
 
+    <!--查询多个-->
+    <select id="queryBysiteIdTime" resultMap="CarPositionMap">
+        select
+            car_id, position, create_time, site_id, status, id
+        from car_position
+        where site_id = #{siteId} and create_time between #{startTime} and #{endTime}
+    </select>
+
+
     <!--查询指定行数据-->
     <select id="queryAllByLimit" resultMap="CarPositionMap">
         select

+ 9 - 0
ruoyi-system/src/main/resources/mapper/HeartBeatMapper.xml

@@ -34,6 +34,15 @@ heart_id, type, id, status, eq, current, voltage, signalstrength, temperature, c
         limit 1
     </select>
 
+
+    <!--查询单个-->
+    <select id="queryBysiteIdTime" resultMap="HeartBeatMap">
+        select
+            heart_id, type, id, status, eq, current, voltage, signalstrength, temperature, create_time, site_id
+        from heart_beat
+        where site_id = #{siteId} and create_time between #{startTime} and #{endTime}
+    </select>
+
     <!--查询指定行数据-->
     <select id="queryAllByLimit" resultMap="HeartBeatMap">
         select

+ 4 - 4
waterAffairs-admin/src/main/java/com/ruoyi/web/controller/tool/ReportDataController.java

@@ -34,15 +34,15 @@ public class ReportDataController {
     //小车位置
     @GetMapping(value = "/carLocation")
     @ApiOperation("获取小车实时位置")
-    public R<CarPosition> carLocation(Long siteId)  {
-        return R.ok(reportDataService.carLocation(siteId));
+    public R<List<CarPosition>> carLocation(Long siteId , String startTime, String endTime)  {
+        return R.ok(reportDataService.carLocation(siteId, startTime, endTime ));
     }
 
     //小车信息
     @GetMapping(value = "/carInfo")
     @ApiOperation("获取小车实时信息")
-    public R<HeartBeat> carInfo(Long siteId)  {
-        return R.ok(reportDataService.carInfo(siteId));
+    public R<List<HeartBeat>> carInfo(Long siteId, String startTime, String endTime)  {
+        return R.ok(reportDataService.carInfo(siteId, startTime, endTime));
     }
 
     //站点实时信息