增加按名称查询事件接口

This commit is contained in:
wuweida 2022-05-19 09:38:42 +08:00
parent a765bc764e
commit 595d7e9c16
3 changed files with 33 additions and 21 deletions

View File

@ -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"));
}
JSONObject image = jsonObject.getJSONObject("image");
if (image == null){
}else {
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<Event> byName = eventMapper.selectByName(eventCnName);
Result success = Result.success(byName);
return success;
}
}

View File

@ -13,4 +13,7 @@ public interface EventMapper extends BaseMapper<Event> {
@Select("SELECT * FROM t_event where TO_DAYS(capture_time) = TO_DAYS(NOW()) AND track_event = 'START'")
List<Event> selectByTime();
@Select("select * from t_event where event_cn_name = #{eventCnName} and track_event = 'START'")
List<Event> selectByName(@Param("eventCnName") String eventCnName);
}

View File

@ -12,7 +12,7 @@ import java.util.Map;
@Service
@Log4j2
public class ShangTangService {
public class EventService {
@Autowired
private RestTemplate restTemplate;