From 9bdaaf350622cde5fa428c0f33f8490d5dc638fb Mon Sep 17 00:00:00 2001 From: wuweida <2918581207@qq.com> Date: Wed, 18 May 2022 15:05:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E6=8E=A5=E5=8F=A3=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ShangTangController.java | 36 ++++++++++++++----- .../hisense/monitormanage/entity/Event.java | 2 +- .../monitormanage/mapper/EventMapper.java | 4 +++ 3 files changed, 33 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/hisense/monitormanage/controller/ShangTangController.java b/src/main/java/com/hisense/monitormanage/controller/ShangTangController.java index 2cbf02c..63a43f7 100644 --- a/src/main/java/com/hisense/monitormanage/controller/ShangTangController.java +++ b/src/main/java/com/hisense/monitormanage/controller/ShangTangController.java @@ -1,18 +1,16 @@ package com.hisense.monitormanage.controller; -import cn.hutool.http.HttpRequest; import com.alibaba.fastjson.JSONObject; -import com.hisense.monitormanage.entity.CameraChannel; +import com.baomidou.mybatisplus.extension.api.R; import com.hisense.monitormanage.entity.Event; import com.hisense.monitormanage.entity.Result; import com.hisense.monitormanage.mapper.EventMapper; import com.hisense.monitormanage.service.ShangTangService; +import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; -import org.omg.CORBA.Request; +import lombok.extern.log4j.Log4j2; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -21,12 +19,12 @@ import javax.servlet.http.HttpServletRequest; import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Date; -import java.util.HashMap; import java.util.List; -import java.util.Map; @RestController @RequestMapping("STapi/project") +@Api(tags = "事件") +@Log4j2 public class ShangTangController { @Autowired @@ -44,6 +42,7 @@ public class ShangTangController { return shangTangService.subscribe(); } + /** * 订阅任务下发接口 * @param request @@ -123,8 +122,9 @@ public class ShangTangController { }catch (Exception e){ e.printStackTrace(); } + event.setTrackEvent(jsonObject.getString("trackEvent")); eventMapper.insert(event); - System.out.println(strcont); + log.info(event); return Result.success(strcont); } @@ -140,7 +140,12 @@ public class ShangTangController { } + /** + * 查询所有事件 + * @return + */ @GetMapping("selectEvent") + @ApiOperation("查询所有事件") public Result selectEvent(){ List events = eventMapper.selectEvent(); @@ -149,4 +154,19 @@ public class ShangTangController { return success; } + /** + * 查询当天事件 + * @return + */ + @GetMapping("selectByTime") + @ApiOperation("查询当天事件") + public Result selectByTime(){ + List byTime = eventMapper.selectByTime(); + + Result success = Result.success(byTime); + + return success; + + } + } diff --git a/src/main/java/com/hisense/monitormanage/entity/Event.java b/src/main/java/com/hisense/monitormanage/entity/Event.java index d8861c5..2cf8c75 100644 --- a/src/main/java/com/hisense/monitormanage/entity/Event.java +++ b/src/main/java/com/hisense/monitormanage/entity/Event.java @@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; import java.math.BigDecimal; -import java.util.Date; @Data @TableName("t_event") @@ -24,4 +23,5 @@ public class Event { private String imageUrl; private String taskId; private String captureTime; + private String trackEvent; } diff --git a/src/main/java/com/hisense/monitormanage/mapper/EventMapper.java b/src/main/java/com/hisense/monitormanage/mapper/EventMapper.java index cdd1e5f..f1c7d01 100644 --- a/src/main/java/com/hisense/monitormanage/mapper/EventMapper.java +++ b/src/main/java/com/hisense/monitormanage/mapper/EventMapper.java @@ -2,6 +2,7 @@ package com.hisense.monitormanage.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.hisense.monitormanage.entity.Event; +import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; import java.util.List; @@ -9,4 +10,7 @@ import java.util.List; public interface EventMapper extends BaseMapper { @Select("SELECT * FROM t_event") List selectEvent(); + + @Select("SELECT * FROM t_event where TO_DAYS(capture_time) = TO_DAYS(NOW())") + List selectByTime(); }