diff --git a/src/main/java/com/hisense/monitormanage/controller/Controller.java b/src/main/java/com/hisense/monitormanage/controller/Controller.java index 6a9d856..a888afa 100644 --- a/src/main/java/com/hisense/monitormanage/controller/Controller.java +++ b/src/main/java/com/hisense/monitormanage/controller/Controller.java @@ -350,17 +350,19 @@ public class Controller { } @RequestMapping("passengerFlow") - //测试 + //测试获取最新的客流列表,从接口获取 public List passengerFlow(){ List list = passengerFlowService.passengerFlow(); return list; } - //从提供方获取最新的实时客流列表 + //获取最新的实时客流列表,从表获取 @RequestMapping("listPassengerFlow") - public List listPassengerFlow(){ - List list = passengerFlowService.passengerFlow(); + public List listPassengerFlow(){ + List list = passengerFlowService.listPassengerFlow(); return list; } + + //获取实时客流并保存到表t_passenger_flow @RequestMapping("savePassengerFlow") public Result savePassengerFlow(){ diff --git a/src/main/java/com/hisense/monitormanage/mapper/PassengerFlowlMapper.java b/src/main/java/com/hisense/monitormanage/mapper/PassengerFlowlMapper.java index 9daa332..f272f44 100644 --- a/src/main/java/com/hisense/monitormanage/mapper/PassengerFlowlMapper.java +++ b/src/main/java/com/hisense/monitormanage/mapper/PassengerFlowlMapper.java @@ -9,4 +9,5 @@ import java.util.Map; public interface PassengerFlowlMapper extends BaseMapper { void batchSave(List list); + PassengerFlow getByMaxId(); } diff --git a/src/main/java/com/hisense/monitormanage/service/PassengerFlowService.java b/src/main/java/com/hisense/monitormanage/service/PassengerFlowService.java index fc4a10c..e870503 100644 --- a/src/main/java/com/hisense/monitormanage/service/PassengerFlowService.java +++ b/src/main/java/com/hisense/monitormanage/service/PassengerFlowService.java @@ -104,6 +104,16 @@ public class PassengerFlowService { } return list; } + //从表中获取最新的实时客流 + public List listPassengerFlow(){ + PassengerFlow passengerFlow = passengerFlowMapper.getByMaxId(); + String timeId = passengerFlow.getTimeId(); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("time_id",timeId); + List lists = passengerFlowMapper.selectList(wrapper); + return lists; + } @Scheduled(cron = "0 31 10-22/1 * * ? ") //提供的接口能查到当前时间2个小时之前的数据,每隔15分钟一次,我们只取整点从早8点到晚8点的整点数据 //10:31 到晚上10:31,每小时的31分执行一次 diff --git a/src/main/resources/mapper/PassengerFlowlMapper.xml b/src/main/resources/mapper/PassengerFlowlMapper.xml index dfe3d36..c798073 100644 --- a/src/main/resources/mapper/PassengerFlowlMapper.xml +++ b/src/main/resources/mapper/PassengerFlowlMapper.xml @@ -14,4 +14,8 @@ + + \ No newline at end of file