添加事件接口
This commit is contained in:
parent
0cacf6c8fa
commit
6fa7ffdda2
|
@ -2,11 +2,16 @@ package com.hisense.monitormanage.controller;
|
||||||
|
|
||||||
import cn.hutool.http.HttpRequest;
|
import cn.hutool.http.HttpRequest;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.hisense.monitormanage.entity.CameraChannel;
|
||||||
|
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.service.ShangTangService;
|
import com.hisense.monitormanage.service.ShangTangService;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.omg.CORBA.Request;
|
import org.omg.CORBA.Request;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
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.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;
|
||||||
|
@ -14,6 +19,8 @@ import org.springframework.web.bind.annotation.RestController;
|
||||||
import javax.servlet.ServletInputStream;
|
import javax.servlet.ServletInputStream;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -25,6 +32,9 @@ public class ShangTangController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private ShangTangService shangTangService;
|
private ShangTangService shangTangService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EventMapper eventMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 订阅任务下发接口
|
* 订阅任务下发接口
|
||||||
* @return
|
* @return
|
||||||
|
@ -52,6 +62,68 @@ public class ShangTangController {
|
||||||
}
|
}
|
||||||
String strcont = content.toString();// 内容
|
String strcont = content.toString();// 内容
|
||||||
|
|
||||||
|
JSONObject jsonObject = JSONObject.parseObject(strcont);
|
||||||
|
Event event = new Event();
|
||||||
|
event.setEventCnName(jsonObject.getString("eventAlias"));
|
||||||
|
event.setEventSerial(jsonObject.getString("eventSerial"));
|
||||||
|
JSONObject attributes = jsonObject.getJSONObject("attributes");
|
||||||
|
if (attributes==null){
|
||||||
|
}else {
|
||||||
|
JSONObject text = attributes.getJSONObject("text");
|
||||||
|
if (text == null){
|
||||||
|
}else {
|
||||||
|
event.setVehicle(text.getString("valueDescription"));
|
||||||
|
}
|
||||||
|
JSONObject color = attributes.getJSONObject("color");
|
||||||
|
if (color == null) {
|
||||||
|
} else {
|
||||||
|
event.setColor(color.getString("valueDescription"));
|
||||||
|
}
|
||||||
|
JSONObject largeVehicle = attributes.getJSONObject("large_vehicle");
|
||||||
|
if (largeVehicle == null) {
|
||||||
|
} else {
|
||||||
|
event.setVehicle(largeVehicle.getString("valueDescription"));
|
||||||
|
}
|
||||||
|
JSONObject trainingVehicle = attributes.getJSONObject("training_vehicle");
|
||||||
|
if (trainingVehicle == null) {
|
||||||
|
} else {
|
||||||
|
event.setVehicle(trainingVehicle.getString("valueDescription"));
|
||||||
|
}
|
||||||
|
JSONObject smallVehicle = attributes.getJSONObject("small_vehicle");
|
||||||
|
if (smallVehicle == null) {
|
||||||
|
} else {
|
||||||
|
event.setVehicle(smallVehicle.getString("valueDescription"));
|
||||||
|
}
|
||||||
|
JSONObject aClass = attributes.getJSONObject("class");
|
||||||
|
if (aClass == null) {
|
||||||
|
} else {
|
||||||
|
event.setClasses(aClass.getString("valueDescription"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
try {
|
||||||
|
date = sdf.parse(sdf.format(jsonObject.get("captureTime")));
|
||||||
|
event.setCaptureTime(sdf.format(date));
|
||||||
|
}catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
eventMapper.insert(event);
|
||||||
System.out.println(strcont);
|
System.out.println(strcont);
|
||||||
return Result.success(strcont);
|
return Result.success(strcont);
|
||||||
}
|
}
|
||||||
|
@ -68,4 +140,13 @@ public class ShangTangController {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("selectEvent")
|
||||||
|
public Result selectEvent(){
|
||||||
|
List<Event> events = eventMapper.selectEvent();
|
||||||
|
|
||||||
|
Result success = Result.success(events);
|
||||||
|
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
package com.hisense.monitormanage.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@TableName("t_event")
|
||||||
|
public class Event {
|
||||||
|
@TableId
|
||||||
|
private String id;
|
||||||
|
private String eventCnName;
|
||||||
|
private String eventSerial;
|
||||||
|
private String color;
|
||||||
|
private String vehicle;
|
||||||
|
private String classes;
|
||||||
|
private String cameraName;
|
||||||
|
private String district;
|
||||||
|
private BigDecimal latitude;
|
||||||
|
private BigDecimal longitude;
|
||||||
|
private String imageUrl;
|
||||||
|
private String taskId;
|
||||||
|
private String captureTime;
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
package com.hisense.monitormanage.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.hisense.monitormanage.entity.Event;
|
||||||
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface EventMapper extends BaseMapper<Event> {
|
||||||
|
@Select("SELECT * FROM t_event")
|
||||||
|
List<Event> selectEvent();
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.hisense.monitormanage.mapper.EventMapper">
|
||||||
|
|
||||||
|
</mapper>
|
Loading…
Reference in New Issue