增加按名称查询事件接口
This commit is contained in:
parent
a765bc764e
commit
595d7e9c16
|
@ -1,16 +1,17 @@
|
||||||
package com.hisense.monitormanage.controller;
|
package com.hisense.monitormanage.controller;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.baomidou.mybatisplus.extension.api.R;
|
|
||||||
import com.hisense.monitormanage.entity.Event;
|
import com.hisense.monitormanage.entity.Event;
|
||||||
import com.hisense.monitormanage.entity.Result;
|
import com.hisense.monitormanage.entity.Result;
|
||||||
import com.hisense.monitormanage.mapper.EventMapper;
|
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.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
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.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@ -25,10 +26,10 @@ import java.util.List;
|
||||||
@RequestMapping("STapi/project")
|
@RequestMapping("STapi/project")
|
||||||
@Api(tags = "事件")
|
@Api(tags = "事件")
|
||||||
@Log4j2
|
@Log4j2
|
||||||
public class ShangTangController {
|
public class EventController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ShangTangService shangTangService;
|
private EventService eventService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private EventMapper eventMapper;
|
private EventMapper eventMapper;
|
||||||
|
@ -39,7 +40,7 @@ public class ShangTangController {
|
||||||
*/
|
*/
|
||||||
@RequestMapping("subscribe")
|
@RequestMapping("subscribe")
|
||||||
public JSONObject subscribe(){
|
public JSONObject subscribe(){
|
||||||
return shangTangService.subscribe();
|
return eventService.subscribe();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -49,7 +50,7 @@ public class ShangTangController {
|
||||||
* @return
|
* @return
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
@RequestMapping("receive")
|
@PostMapping("receive")
|
||||||
@ApiOperation("订阅任务下发接口")
|
@ApiOperation("订阅任务下发接口")
|
||||||
public Result receive(HttpServletRequest request) throws IOException {
|
public Result receive(HttpServletRequest request) throws IOException {
|
||||||
ServletInputStream ris = request.getInputStream();
|
ServletInputStream ris = request.getInputStream();
|
||||||
|
@ -100,19 +101,12 @@ public class ShangTangController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
JSONObject camera = jsonObject.getJSONObject("camera");
|
JSONObject camera = jsonObject.getJSONObject("camera");
|
||||||
if (camera == null){
|
|
||||||
}else {
|
|
||||||
event.setCameraName(camera.getString("cameraName"));
|
event.setCameraName(camera.getString("cameraName"));
|
||||||
event.setDistrict(camera.getString("district"));
|
event.setDistrict(camera.getString("district"));
|
||||||
event.setLatitude(camera.getBigDecimal("latitude"));
|
event.setLatitude(camera.getBigDecimal("latitude"));
|
||||||
event.setLongitude(camera.getBigDecimal("longitude"));
|
event.setLongitude(camera.getBigDecimal("longitude"));
|
||||||
}
|
|
||||||
JSONObject image = jsonObject.getJSONObject("image");
|
JSONObject image = jsonObject.getJSONObject("image");
|
||||||
if (image == null){
|
|
||||||
|
|
||||||
}else {
|
|
||||||
event.setImageUrl(image.getString("imageUrl"));
|
event.setImageUrl(image.getString("imageUrl"));
|
||||||
}
|
|
||||||
event.setTaskId(jsonObject.getString("taskId"));
|
event.setTaskId(jsonObject.getString("taskId"));
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//要转换的时间格式
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//要转换的时间格式
|
||||||
Date date;
|
Date date;
|
||||||
|
@ -133,10 +127,10 @@ public class ShangTangController {
|
||||||
* 事件模板分页查询接口
|
* 事件模板分页查询接口
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@RequestMapping("tamplate")
|
@GetMapping("tamplate")
|
||||||
@ApiOperation("事件模板分页查询接口")
|
@ApiOperation("事件模板分页查询接口")
|
||||||
public JSONObject tamplate(){
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -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'")
|
@Select("SELECT * FROM t_event where TO_DAYS(capture_time) = TO_DAYS(NOW()) AND track_event = 'START'")
|
||||||
List<Event> selectByTime();
|
List<Event> selectByTime();
|
||||||
|
|
||||||
|
@Select("select * from t_event where event_cn_name = #{eventCnName} and track_event = 'START'")
|
||||||
|
List<Event> selectByName(@Param("eventCnName") String eventCnName);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ import java.util.Map;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@Log4j2
|
@Log4j2
|
||||||
public class ShangTangService {
|
public class EventService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RestTemplate restTemplate;
|
private RestTemplate restTemplate;
|
Loading…
Reference in New Issue