From 595d7e9c16b86c43049e168fe94e073972a19c25 Mon Sep 17 00:00:00 2001 From: wuweida <2918581207@qq.com> Date: Thu, 19 May 2022 09:38:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=8C=89=E5=90=8D=E7=A7=B0?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E4=BA=8B=E4=BB=B6=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ngController.java => EventController.java} | 49 +++++++++++-------- .../monitormanage/mapper/EventMapper.java | 3 ++ ...hangTangService.java => EventService.java} | 2 +- 3 files changed, 33 insertions(+), 21 deletions(-) rename src/main/java/com/hisense/monitormanage/controller/{ShangTangController.java => EventController.java} (81%) rename src/main/java/com/hisense/monitormanage/service/{ShangTangService.java => EventService.java} (98%) diff --git a/src/main/java/com/hisense/monitormanage/controller/ShangTangController.java b/src/main/java/com/hisense/monitormanage/controller/EventController.java similarity index 81% rename from src/main/java/com/hisense/monitormanage/controller/ShangTangController.java rename to src/main/java/com/hisense/monitormanage/controller/EventController.java index 63a43f7..671dd05 100644 --- a/src/main/java/com/hisense/monitormanage/controller/ShangTangController.java +++ b/src/main/java/com/hisense/monitormanage/controller/EventController.java @@ -1,16 +1,17 @@ package com.hisense.monitormanage.controller; import com.alibaba.fastjson.JSONObject; -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 com.hisense.monitormanage.mapper.SedimentTrailMapper; +import com.hisense.monitormanage.service.EventService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.log4j.Log4j2; import org.springframework.beans.factory.annotation.Autowired; 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; @@ -25,10 +26,10 @@ import java.util.List; @RequestMapping("STapi/project") @Api(tags = "事件") @Log4j2 -public class ShangTangController { +public class EventController { @Autowired - private ShangTangService shangTangService; + private EventService eventService; @Autowired private EventMapper eventMapper; @@ -39,7 +40,7 @@ public class ShangTangController { */ @RequestMapping("subscribe") public JSONObject subscribe(){ - return shangTangService.subscribe(); + return eventService.subscribe(); } @@ -49,7 +50,7 @@ public class ShangTangController { * @return * @throws IOException */ - @RequestMapping("receive") + @PostMapping("receive") @ApiOperation("订阅任务下发接口") public Result receive(HttpServletRequest request) throws IOException { ServletInputStream ris = request.getInputStream(); @@ -100,19 +101,12 @@ public class ShangTangController { } } JSONObject camera = jsonObject.getJSONObject("camera"); - if (camera == null){ - }else { - event.setCameraName(camera.getString("cameraName")); - event.setDistrict(camera.getString("district")); - event.setLatitude(camera.getBigDecimal("latitude")); - event.setLongitude(camera.getBigDecimal("longitude")); - } + event.setCameraName(camera.getString("cameraName")); + event.setDistrict(camera.getString("district")); + event.setLatitude(camera.getBigDecimal("latitude")); + event.setLongitude(camera.getBigDecimal("longitude")); JSONObject image = jsonObject.getJSONObject("image"); - if (image == null){ - - }else { - event.setImageUrl(image.getString("imageUrl")); - } + event.setImageUrl(image.getString("imageUrl")); event.setTaskId(jsonObject.getString("taskId")); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//要转换的时间格式 Date date; @@ -133,10 +127,10 @@ public class ShangTangController { * 事件模板分页查询接口 * @return */ - @RequestMapping("tamplate") + @GetMapping("tamplate") @ApiOperation("事件模板分页查询接口") public JSONObject tamplate(){ - return shangTangService.template(); + return eventService.template(); } @@ -169,4 +163,19 @@ public class ShangTangController { } + /** + * 根据事件名称查询事件 + * @param eventCnName + * @return + */ + @GetMapping("selectByName") + @ApiOperation("根据事件名称查询事件") + public Result selectByName(String eventCnName){ + List byName = eventMapper.selectByName(eventCnName); + + Result success = Result.success(byName); + + return success; + } + } diff --git a/src/main/java/com/hisense/monitormanage/mapper/EventMapper.java b/src/main/java/com/hisense/monitormanage/mapper/EventMapper.java index a2bad4f..cbb1d2d 100644 --- a/src/main/java/com/hisense/monitormanage/mapper/EventMapper.java +++ b/src/main/java/com/hisense/monitormanage/mapper/EventMapper.java @@ -13,4 +13,7 @@ public interface EventMapper extends BaseMapper { @Select("SELECT * FROM t_event where TO_DAYS(capture_time) = TO_DAYS(NOW()) AND track_event = 'START'") List selectByTime(); + + @Select("select * from t_event where event_cn_name = #{eventCnName} and track_event = 'START'") + List selectByName(@Param("eventCnName") String eventCnName); } diff --git a/src/main/java/com/hisense/monitormanage/service/ShangTangService.java b/src/main/java/com/hisense/monitormanage/service/EventService.java similarity index 98% rename from src/main/java/com/hisense/monitormanage/service/ShangTangService.java rename to src/main/java/com/hisense/monitormanage/service/EventService.java index de9a873..248474b 100644 --- a/src/main/java/com/hisense/monitormanage/service/ShangTangService.java +++ b/src/main/java/com/hisense/monitormanage/service/EventService.java @@ -12,7 +12,7 @@ import java.util.Map; @Service @Log4j2 -public class ShangTangService { +public class EventService { @Autowired private RestTemplate restTemplate;