Commit a42e6bb4 by xmh

<feat> d_flow_event 添加 channel_Unid 字段. 修改相关写入和查询代码.

<feat> 添加 vaServer 资源概览接口
1 parent 5d2fc4f0
Showing 17 changed files with 297 additions and 20 deletions
...@@ -17,8 +17,8 @@ public enum ChannelType { ...@@ -17,8 +17,8 @@ public enum ChannelType {
STREAM_RTSP(0), STREAM_RTSP(0),
/** stream type file */ /** stream type file */
STREAM_FILE(1), STREAM_FILE(1),
/** sip28181 */ /** 视频云 */
STREAM_SIP(2), STREAM_VIDEO_CLOUD(2),
; ;
public int value; public int value;
......
...@@ -28,6 +28,8 @@ public class FlowEvent extends BaseModel { ...@@ -28,6 +28,8 @@ public class FlowEvent extends BaseModel {
private String videoName; private String videoName;
private String channelUnid;
private String jsonData; private String jsonData;
public Long getId() { public Long getId() {
...@@ -126,6 +128,14 @@ public class FlowEvent extends BaseModel { ...@@ -126,6 +128,14 @@ public class FlowEvent extends BaseModel {
this.videoName = videoName == null ? null : videoName.trim(); this.videoName = videoName == null ? null : videoName.trim();
} }
public String getChannelUnid() {
return channelUnid;
}
public void setChannelUnid(String channelUnid) {
this.channelUnid = channelUnid == null ? null : channelUnid.trim();
}
public String getJsonData() { public String getJsonData() {
return jsonData; return jsonData;
} }
......
...@@ -898,6 +898,76 @@ public class FlowEventExample extends BaseExample { ...@@ -898,6 +898,76 @@ public class FlowEventExample extends BaseExample {
addCriterion("`flowEvent`.video_name not between", value1, value2, "videoName"); addCriterion("`flowEvent`.video_name not between", value1, value2, "videoName");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andChannelUnidIsNull() {
addCriterion("`flowEvent`.channel_unid is null");
return (Criteria) this;
}
public Criteria andChannelUnidIsNotNull() {
addCriterion("`flowEvent`.channel_unid is not null");
return (Criteria) this;
}
public Criteria andChannelUnidEqualTo(String value) {
addCriterion("`flowEvent`.channel_unid =", value, "channelUnid");
return (Criteria) this;
}
public Criteria andChannelUnidNotEqualTo(String value) {
addCriterion("`flowEvent`.channel_unid <>", value, "channelUnid");
return (Criteria) this;
}
public Criteria andChannelUnidGreaterThan(String value) {
addCriterion("`flowEvent`.channel_unid >", value, "channelUnid");
return (Criteria) this;
}
public Criteria andChannelUnidGreaterThanOrEqualTo(String value) {
addCriterion("`flowEvent`.channel_unid >=", value, "channelUnid");
return (Criteria) this;
}
public Criteria andChannelUnidLessThan(String value) {
addCriterion("`flowEvent`.channel_unid <", value, "channelUnid");
return (Criteria) this;
}
public Criteria andChannelUnidLessThanOrEqualTo(String value) {
addCriterion("`flowEvent`.channel_unid <=", value, "channelUnid");
return (Criteria) this;
}
public Criteria andChannelUnidLike(String value) {
addCriterion("`flowEvent`.channel_unid like", value, "channelUnid");
return (Criteria) this;
}
public Criteria andChannelUnidNotLike(String value) {
addCriterion("`flowEvent`.channel_unid not like", value, "channelUnid");
return (Criteria) this;
}
public Criteria andChannelUnidIn(List<String> values) {
addCriterion("`flowEvent`.channel_unid in", values, "channelUnid");
return (Criteria) this;
}
public Criteria andChannelUnidNotIn(List<String> values) {
addCriterion("`flowEvent`.channel_unid not in", values, "channelUnid");
return (Criteria) this;
}
public Criteria andChannelUnidBetween(String value1, String value2) {
addCriterion("`flowEvent`.channel_unid between", value1, value2, "channelUnid");
return (Criteria) this;
}
public Criteria andChannelUnidNotBetween(String value1, String value2) {
addCriterion("`flowEvent`.channel_unid not between", value1, value2, "channelUnid");
return (Criteria) this;
}
} }
public static class ColumnContainer extends ColumnContainerBase { public static class ColumnContainer extends ColumnContainerBase {
...@@ -965,5 +1035,10 @@ public class FlowEventExample extends BaseExample { ...@@ -965,5 +1035,10 @@ public class FlowEventExample extends BaseExample {
addColumnStr("`flowEvent`.video_name as flowEvent_video_name "); addColumnStr("`flowEvent`.video_name as flowEvent_video_name ");
return (ColumnContainer) this; return (ColumnContainer) this;
} }
public ColumnContainer hasChannelUnidColumn() {
addColumnStr("`flowEvent`.channel_unid as flowEvent_channel_unid ");
return (ColumnContainer) this;
}
} }
} }
\ No newline at end of file \ No newline at end of file
...@@ -136,6 +136,15 @@ public class FlowEventVoBase extends FlowEvent implements VoInterface<FlowEvent> ...@@ -136,6 +136,15 @@ public class FlowEventVoBase extends FlowEvent implements VoInterface<FlowEvent>
private String videoName_like; private String videoName_like;
@JsonIgnore @JsonIgnore
private Boolean channelUnid_null;
@JsonIgnore
private ArrayList<String> channelUnid_arr;
@JsonIgnore
private String channelUnid_like;
@JsonIgnore
private Boolean jsonData_null; private Boolean jsonData_null;
@JsonIgnore @JsonIgnore
...@@ -668,6 +677,44 @@ public class FlowEventVoBase extends FlowEvent implements VoInterface<FlowEvent> ...@@ -668,6 +677,44 @@ public class FlowEventVoBase extends FlowEvent implements VoInterface<FlowEvent>
this.getModel().setVideoName(videoName); this.getModel().setVideoName(videoName);
} }
public Boolean getChannelUnid_null() {
return channelUnid_null;
}
public void setChannelUnid_null(Boolean channelUnid_null) {
this.channelUnid_null = channelUnid_null;
}
public ArrayList<String> getChannelUnid_arr() {
return channelUnid_arr;
}
public void setChannelUnid_arr(ArrayList<String> channelUnid_arr) {
this.channelUnid_arr = channelUnid_arr;
}
public String getChannelUnid_like() {
return channelUnid_like;
}
public void setChannelUnid_like(String channelUnid_like) {
this.channelUnid_like = channelUnid_like;
}
public String getChannelUnid() {
if(getModel() == null ){
throw new RuntimeException("model is null");
}
return this.getModel().getChannelUnid();
}
public void setChannelUnid(String channelUnid) {
if(getModel() == null ){
throw new RuntimeException("model is null");
}
this.getModel().setChannelUnid(channelUnid);
}
public Boolean getJsonData_null() { public Boolean getJsonData_null() {
return jsonData_null; return jsonData_null;
} }
......
...@@ -50,6 +50,7 @@ public class TrafficFlowProcessor implements ItemProcessor<JSONObject, TrafficFl ...@@ -50,6 +50,7 @@ public class TrafficFlowProcessor implements ItemProcessor<JSONObject, TrafficFl
content.setFlowData(flowDataList); content.setFlowData(flowDataList);
Long taskId = item.getLong("taskId"); Long taskId = item.getLong("taskId");
String channelUnid = item.getString("vchan_refid");
String eventType = item.getString("event_type"); String eventType = item.getString("event_type");
String eventDt = item.getString("event_dt"); String eventDt = item.getString("event_dt");
String picArray = item.getString("pic_path_array"); String picArray = item.getString("pic_path_array");
...@@ -61,6 +62,7 @@ public class TrafficFlowProcessor implements ItemProcessor<JSONObject, TrafficFl ...@@ -61,6 +62,7 @@ public class TrafficFlowProcessor implements ItemProcessor<JSONObject, TrafficFl
flowEvent.setEventTime(eventTime); flowEvent.setEventTime(eventTime);
flowEvent.setPics(picArray); flowEvent.setPics(picArray);
flowEvent.setTaskId(taskId); flowEvent.setTaskId(taskId);
flowEvent.setChannelUnid(channelUnid);
String videoName = item.getString("video_name"); String videoName = item.getString("video_name");
flowEvent.setVideoName(videoName); flowEvent.setVideoName(videoName);
......
...@@ -24,8 +24,8 @@ import java.util.List; ...@@ -24,8 +24,8 @@ import java.util.List;
public class TrafficFlowWriter implements ItemWriter<TrafficFlowContent> { public class TrafficFlowWriter implements ItemWriter<TrafficFlowContent> {
private final static String INSERT_FLOW_EVENT = "insert into d_flow_event (" + private final static String INSERT_FLOW_EVENT = "insert into d_flow_event (" +
"task_id,event_type,event_time,event_id,device_code,device_name,location_code,location_name,json_data,pics,video_name) values(" + "task_id,event_type,event_time,event_id,device_code,device_name,location_code,location_name,json_data,pics,video_name,channel_unid) values(" +
":taskId,:eventType,:eventTime,:eventId,:deviceCode,:deviceName,:locationCode,:locationName,:jsonData,:pics,:videoName)"; ":taskId,:eventType,:eventTime,:eventId,:deviceCode,:deviceName,:locationCode,:locationName,:jsonData,:pics,:videoName,:channelUnid)";
private final static String INSERT_FLOW_DATA = "insert into d_flow_data (" + private final static String INSERT_FLOW_DATA = "insert into d_flow_data (" +
"flow_event_id,task_id,detection_type,road_code,direction_code,sample_dura,sample_num,velocity,velocity_unit,occupy,distance,queue_length,region_id,region_name,position_content,head_content,area,density,sample_num_in,sample_num_out,event_time,dist_time,time_occupy) values (" + "flow_event_id,task_id,detection_type,road_code,direction_code,sample_dura,sample_num,velocity,velocity_unit,occupy,distance,queue_length,region_id,region_name,position_content,head_content,area,density,sample_num_in,sample_num_out,event_time,dist_time,time_occupy) values (" +
":flowEventId,:taskId,:detectionType,:roadCode,:directionCode,:sampleDura,:sampleNum,:velocity,:velocityUnit,:occupy,:distance,:queueLength,:regionId,:regionName,:positionContent,:headContent,:area,:density,:sampleNumIn,:sampleNumOut,:eventTime,:distTime,:timeOccupy)"; ":flowEventId,:taskId,:detectionType,:roadCode,:directionCode,:sampleDura,:sampleNum,:velocity,:velocityUnit,:occupy,:distance,:queueLength,:regionId,:regionName,:positionContent,:headContent,:area,:density,:sampleNumIn,:sampleNumOut,:eventTime,:distTime,:timeOccupy)";
......
...@@ -26,8 +26,8 @@ import java.util.stream.Collectors; ...@@ -26,8 +26,8 @@ import java.util.stream.Collectors;
public class TrafficWriter implements ItemWriter<TrafficContent> { public class TrafficWriter implements ItemWriter<TrafficContent> {
private final static String INSERT_TRAFFIC = "insert into d_traffic (" + private final static String INSERT_TRAFFIC = "insert into d_traffic (" +
"task_id,event_cate,event_type,event_time,channel_unid,plate_color,plate_number,location_code,location_name,lane_code,direction_code,vehicle_type,vehicle_color,vehicle_logo,illegal_code,illegal_state,feature_annual_inspection_mark,feature_pendant,feature_decoration,feature_sun_shield,xcycle_type,event_id,special_type,with_helmet,json_data,pics,video_name) values(" + "task_id,event_cate,event_type,event_time,channel_unid,plate_color,plate_number,location_code,location_name,lane_code,direction_code,vehicle_type,vehicle_color,vehicle_logo,illegal_code,illegal_state,feature_annual_inspection_mark,feature_pendant,feature_decoration,feature_sun_shield,xcycle_type,event_id,special_type,with_helmet,json_data,pics,video_name,company) values(" +
":taskId,:eventCate,:eventType,:eventTime,:channelUnid,:plateColor,:plateNumber,:locationCode,:locationName,:laneCode,:directionCode,:vehicleType,:vehicleColor,:vehicleLogo,:illegalCode,:illegalState,:featureAnnualInspectionMark,:featurePendant,:featureDecoration,:featureSunShield,:xcycleType,:eventId,:specialType,:withHelmet,:jsonData,:pics,:videoName)"; ":taskId,:eventCate,:eventType,:eventTime,:channelUnid,:plateColor,:plateNumber,:locationCode,:locationName,:laneCode,:directionCode,:vehicleType,:vehicleColor,:vehicleLogo,:illegalCode,:illegalState,:featureAnnualInspectionMark,:featurePendant,:featureDecoration,:featureSunShield,:xcycleType,:eventId,:specialType,:withHelmet,:jsonData,:pics,:videoName,:company)";
private final static String INSERT_TRAFFIC_FACE = "insert into d_traffic_face (" + private final static String INSERT_TRAFFIC_FACE = "insert into d_traffic_face (" +
"traffic_id,state,sex,upper_color,lower_color,event_time) values (:trafficId,:state,:sex,:upperColor,:lowerColor,:eventTime)"; "traffic_id,state,sex,upper_color,lower_color,event_time) values (:trafficId,:state,:sex,:upperColor,:lowerColor,:eventTime)";
......
...@@ -326,7 +326,7 @@ public class ChannelServiceImpl extends BaseServiceImpl<Channel> implements Chan ...@@ -326,7 +326,7 @@ public class ChannelServiceImpl extends BaseServiceImpl<Channel> implements Chan
String channelName = channelJson.getString("channelName"); String channelName = channelJson.getString("channelName");
String channelId = channelJson.getString("channelId"); String channelId = channelJson.getString("channelId");
Integer hasPtz = channelJson.getInteger("hasPtz"); Integer hasPtz = channelJson.getInteger("hasPtz");
saveAndGet(channelName, deviceId, channelId, ChannelType.THIRD_PART.value, ChannelType.STREAM_SIP.value, null, parent.getUnid()); saveAndGet(channelName, deviceId, channelId, ChannelType.THIRD_PART.value, ChannelType.STREAM_VIDEO_CLOUD.value, null, parent.getUnid());
} }
} }
} }
......
...@@ -217,6 +217,22 @@ public abstract class FlowEventBaseController extends BaseController<FlowEvent, ...@@ -217,6 +217,22 @@ public abstract class FlowEventBaseController extends BaseController<FlowEvent,
if(flowEventVo.getVideoName_like() != null) { if(flowEventVo.getVideoName_like() != null) {
criteria.andVideoNameLike(flowEventVo.getVideoName_like()); criteria.andVideoNameLike(flowEventVo.getVideoName_like());
} }
if(flowEventVo.getChannelUnid() != null) {
criteria.andChannelUnidEqualTo(flowEventVo.getChannelUnid());
}
if(flowEventVo.getChannelUnid_null() != null) {
if(flowEventVo.getChannelUnid_null().booleanValue()) {
criteria.andChannelUnidIsNull();
} else {
criteria.andChannelUnidIsNotNull();
}
}
if(flowEventVo.getChannelUnid_arr() != null) {
criteria.andChannelUnidIn(flowEventVo.getChannelUnid_arr());
}
if(flowEventVo.getChannelUnid_like() != null) {
criteria.andChannelUnidLike(flowEventVo.getChannelUnid_like());
}
return flowEventExample; return flowEventExample;
} }
......
...@@ -10,6 +10,7 @@ import com.viontech.fanxing.commons.model.TrafficExample; ...@@ -10,6 +10,7 @@ import com.viontech.fanxing.commons.model.TrafficExample;
import com.viontech.fanxing.commons.vo.TrafficVo; import com.viontech.fanxing.commons.vo.TrafficVo;
import com.viontech.fanxing.query.controller.base.TrafficBaseController; import com.viontech.fanxing.query.controller.base.TrafficBaseController;
import com.viontech.fanxing.query.service.main.OpsClientService; import com.viontech.fanxing.query.service.main.OpsClientService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -39,12 +40,15 @@ public class TrafficController extends TrafficBaseController { ...@@ -39,12 +40,15 @@ public class TrafficController extends TrafficBaseController {
@RequestMapping(value = "", method = RequestMethod.GET) @RequestMapping(value = "", method = RequestMethod.GET)
@ResponseBody @ResponseBody
public Object page(TrafficVo trafficVo, @RequestParam(value = "page", defaultValue = "1") int page, @RequestParam(value = "pageSize", defaultValue = "30") int pageSize, String sortName, String sortOrder) { public Object page(TrafficVo trafficVo, @RequestParam(value = "page", defaultValue = "1") int page, @RequestParam(value = "pageSize", defaultValue = "30") int pageSize, String sortName, String sortOrder) {
Assert.hasLength(trafficVo.getEventType(), "数据类型不能为空");
Assert.notNull(trafficVo.getEventTime_gte(), "起始时间不能为空"); Assert.notNull(trafficVo.getEventTime_gte(), "起始时间不能为空");
Assert.notNull(trafficVo.getEventTime_lte(), "结束时间不能为空"); Assert.notNull(trafficVo.getEventTime_lte(), "结束时间不能为空");
Assert.isTrue(pageSize > 0, "页面大小不正确"); Assert.isTrue(pageSize > 0, "页面大小不正确");
Assert.isTrue(page > 0, "页面参数不正确"); Assert.isTrue(page > 0, "页面参数不正确");
if (StringUtils.isEmpty(trafficVo.getEventCate())) {
trafficVo.setEventCate("traffic");
}
SimplePropertyPreFilter simplePropertyPreFilter = new SimplePropertyPreFilter(); SimplePropertyPreFilter simplePropertyPreFilter = new SimplePropertyPreFilter();
simplePropertyPreFilter.getExcludes().add("model"); simplePropertyPreFilter.getExcludes().add("model");
opsClientService.addLog("检索分析结果,条件:" + JSON.toJSONString(trafficVo, SerializeConfig.globalInstance, new SerializeFilter[]{simplePropertyPreFilter}, "yyyy-MM-dd HH:mm:ss", JSON.DEFAULT_GENERATE_FEATURE)); opsClientService.addLog("检索分析结果,条件:" + JSON.toJSONString(trafficVo, SerializeConfig.globalInstance, new SerializeFilter[]{simplePropertyPreFilter}, "yyyy-MM-dd HH:mm:ss", JSON.DEFAULT_GENERATE_FEATURE));
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
<result column="flowEvent_location_name" property="locationName" /> <result column="flowEvent_location_name" property="locationName" />
<result column="flowEvent_pics" property="pics" /> <result column="flowEvent_pics" property="pics" />
<result column="flowEvent_video_name" property="videoName" /> <result column="flowEvent_video_name" property="videoName" />
<result column="flowEvent_channel_unid" property="channelUnid" />
</resultMap> </resultMap>
<resultMap id="BaseResultMap" type="com.viontech.fanxing.commons.model.FlowEvent" extends="BaseResultMapRoot" /> <resultMap id="BaseResultMap" type="com.viontech.fanxing.commons.model.FlowEvent" extends="BaseResultMapRoot" />
<resultMap id="ResultMapWithBLOBs" type="com.viontech.fanxing.commons.model.FlowEvent" extends="BaseResultMap" > <resultMap id="ResultMapWithBLOBs" type="com.viontech.fanxing.commons.model.FlowEvent" extends="BaseResultMap" >
...@@ -83,7 +84,7 @@ ...@@ -83,7 +84,7 @@
`flowEvent`.event_id as flowEvent_event_id, `flowEvent`.device_code as flowEvent_device_code, `flowEvent`.event_id as flowEvent_event_id, `flowEvent`.device_code as flowEvent_device_code,
`flowEvent`.device_name as flowEvent_device_name, `flowEvent`.location_code as flowEvent_location_code, `flowEvent`.device_name as flowEvent_device_name, `flowEvent`.location_code as flowEvent_location_code,
`flowEvent`.location_name as flowEvent_location_name, `flowEvent`.pics as flowEvent_pics, `flowEvent`.location_name as flowEvent_location_name, `flowEvent`.pics as flowEvent_pics,
`flowEvent`.video_name as flowEvent_video_name `flowEvent`.video_name as flowEvent_video_name, `flowEvent`.channel_unid as flowEvent_channel_unid
</sql> </sql>
<sql id="Base_Column_List" > <sql id="Base_Column_List" >
<if test="!(_parameter.getClass().getSimpleName() == 'FlowEventExample')" > <if test="!(_parameter.getClass().getSimpleName() == 'FlowEventExample')" >
...@@ -167,13 +168,13 @@ ...@@ -167,13 +168,13 @@
insert into `d_flow_event` (event_time, unid, task_id, insert into `d_flow_event` (event_time, unid, task_id,
event_type, event_id, device_code, event_type, event_id, device_code,
device_name, location_code, location_name, device_name, location_code, location_name,
pics, video_name, json_data pics, video_name, channel_unid,
) json_data)
values (#{eventTime,jdbcType=TIMESTAMP}, #{unid,jdbcType=VARCHAR}, #{taskId,jdbcType=BIGINT}, values (#{eventTime,jdbcType=TIMESTAMP}, #{unid,jdbcType=VARCHAR}, #{taskId,jdbcType=BIGINT},
#{eventType,jdbcType=VARCHAR}, #{eventId,jdbcType=VARCHAR}, #{deviceCode,jdbcType=VARCHAR}, #{eventType,jdbcType=VARCHAR}, #{eventId,jdbcType=VARCHAR}, #{deviceCode,jdbcType=VARCHAR},
#{deviceName,jdbcType=VARCHAR}, #{locationCode,jdbcType=VARCHAR}, #{locationName,jdbcType=VARCHAR}, #{deviceName,jdbcType=VARCHAR}, #{locationCode,jdbcType=VARCHAR}, #{locationName,jdbcType=VARCHAR},
#{pics,jdbcType=VARCHAR}, #{videoName,jdbcType=VARCHAR}, #{jsonData,jdbcType=LONGVARCHAR} #{pics,jdbcType=VARCHAR}, #{videoName,jdbcType=VARCHAR}, #{channelUnid,jdbcType=VARCHAR},
) #{jsonData,jdbcType=LONGVARCHAR})
</insert> </insert>
<insert id="insertSelective" parameterType="com.viontech.fanxing.commons.model.FlowEvent" useGeneratedKeys="true" keyProperty="id" keyColumn="id" > <insert id="insertSelective" parameterType="com.viontech.fanxing.commons.model.FlowEvent" useGeneratedKeys="true" keyProperty="id" keyColumn="id" >
insert into `d_flow_event` insert into `d_flow_event`
...@@ -211,6 +212,9 @@ ...@@ -211,6 +212,9 @@
<if test="videoName != null" > <if test="videoName != null" >
video_name, video_name,
</if> </if>
<if test="channelUnid != null" >
channel_unid,
</if>
<if test="jsonData != null" > <if test="jsonData != null" >
json_data, json_data,
</if> </if>
...@@ -249,6 +253,9 @@ ...@@ -249,6 +253,9 @@
<if test="videoName != null" > <if test="videoName != null" >
#{videoName,jdbcType=VARCHAR}, #{videoName,jdbcType=VARCHAR},
</if> </if>
<if test="channelUnid != null" >
#{channelUnid,jdbcType=VARCHAR},
</if>
<if test="jsonData != null" > <if test="jsonData != null" >
#{jsonData,jdbcType=LONGVARCHAR}, #{jsonData,jdbcType=LONGVARCHAR},
</if> </if>
...@@ -299,6 +306,9 @@ ...@@ -299,6 +306,9 @@
<if test="record.videoName != null" > <if test="record.videoName != null" >
video_name = #{record.videoName,jdbcType=VARCHAR}, video_name = #{record.videoName,jdbcType=VARCHAR},
</if> </if>
<if test="record.channelUnid != null" >
channel_unid = #{record.channelUnid,jdbcType=VARCHAR},
</if>
<if test="record.jsonData != null" > <if test="record.jsonData != null" >
json_data = #{record.jsonData,jdbcType=LONGVARCHAR}, json_data = #{record.jsonData,jdbcType=LONGVARCHAR},
</if> </if>
...@@ -321,6 +331,7 @@ ...@@ -321,6 +331,7 @@
`flowEvent`.location_name = #{record.locationName,jdbcType=VARCHAR}, `flowEvent`.location_name = #{record.locationName,jdbcType=VARCHAR},
`flowEvent`.pics = #{record.pics,jdbcType=VARCHAR}, `flowEvent`.pics = #{record.pics,jdbcType=VARCHAR},
`flowEvent`.video_name = #{record.videoName,jdbcType=VARCHAR}, `flowEvent`.video_name = #{record.videoName,jdbcType=VARCHAR},
`flowEvent`.channel_unid = #{record.channelUnid,jdbcType=VARCHAR},
`flowEvent`.json_data = #{record.jsonData,jdbcType=LONGVARCHAR} `flowEvent`.json_data = #{record.jsonData,jdbcType=LONGVARCHAR}
<if test="_parameter != null" > <if test="_parameter != null" >
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
...@@ -339,7 +350,8 @@ ...@@ -339,7 +350,8 @@
location_code = #{record.locationCode,jdbcType=VARCHAR}, location_code = #{record.locationCode,jdbcType=VARCHAR},
location_name = #{record.locationName,jdbcType=VARCHAR}, location_name = #{record.locationName,jdbcType=VARCHAR},
pics = #{record.pics,jdbcType=VARCHAR}, pics = #{record.pics,jdbcType=VARCHAR},
video_name = #{record.videoName,jdbcType=VARCHAR} video_name = #{record.videoName,jdbcType=VARCHAR},
channel_unid = #{record.channelUnid,jdbcType=VARCHAR}
<if test="_parameter != null" > <if test="_parameter != null" >
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
</if> </if>
...@@ -377,6 +389,9 @@ ...@@ -377,6 +389,9 @@
<if test="videoName != null" > <if test="videoName != null" >
video_name = #{videoName,jdbcType=VARCHAR}, video_name = #{videoName,jdbcType=VARCHAR},
</if> </if>
<if test="channelUnid != null" >
channel_unid = #{channelUnid,jdbcType=VARCHAR},
</if>
<if test="jsonData != null" > <if test="jsonData != null" >
json_data = #{jsonData,jdbcType=LONGVARCHAR}, json_data = #{jsonData,jdbcType=LONGVARCHAR},
</if> </if>
...@@ -396,6 +411,7 @@ ...@@ -396,6 +411,7 @@
location_name = #{locationName,jdbcType=VARCHAR}, location_name = #{locationName,jdbcType=VARCHAR},
pics = #{pics,jdbcType=VARCHAR}, pics = #{pics,jdbcType=VARCHAR},
video_name = #{videoName,jdbcType=VARCHAR}, video_name = #{videoName,jdbcType=VARCHAR},
channel_unid = #{channelUnid,jdbcType=VARCHAR},
json_data = #{jsonData,jdbcType=LONGVARCHAR} json_data = #{jsonData,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=BIGINT} where id = #{id,jdbcType=BIGINT}
and event_time = #{eventTime,jdbcType=TIMESTAMP} and event_time = #{eventTime,jdbcType=TIMESTAMP}
...@@ -411,7 +427,8 @@ ...@@ -411,7 +427,8 @@
location_code = #{locationCode,jdbcType=VARCHAR}, location_code = #{locationCode,jdbcType=VARCHAR},
location_name = #{locationName,jdbcType=VARCHAR}, location_name = #{locationName,jdbcType=VARCHAR},
pics = #{pics,jdbcType=VARCHAR}, pics = #{pics,jdbcType=VARCHAR},
video_name = #{videoName,jdbcType=VARCHAR} video_name = #{videoName,jdbcType=VARCHAR},
channel_unid = #{channelUnid,jdbcType=VARCHAR}
where id = #{id,jdbcType=BIGINT} where id = #{id,jdbcType=BIGINT}
and event_time = #{eventTime,jdbcType=TIMESTAMP} and event_time = #{eventTime,jdbcType=TIMESTAMP}
</update> </update>
......
...@@ -35,6 +35,9 @@ ...@@ -35,6 +35,9 @@
<if test="task_id != null and task_id != ''"> <if test="task_id != null and task_id != ''">
and te.task_id = #{task_id} and te.task_id = #{task_id}
</if> </if>
<if test="vchan_refid != null and vchan_refid != ''">
and te.channel_unid = #{vchan_refid}
</if>
<if test="event_dt__gte != null and event_dt__lt != null"> <if test="event_dt__gte != null and event_dt__lt != null">
and te.event_time <![CDATA[>=]]> #{event_dt__gte} and te.event_time <![CDATA[>=]]> #{event_dt__gte}
and te.event_time <![CDATA[<=]]> #{event_dt__lt} and te.event_time <![CDATA[<=]]> #{event_dt__lt}
...@@ -62,6 +65,9 @@ ...@@ -62,6 +65,9 @@
<if test="task_id != null and task_id != ''"> <if test="task_id != null and task_id != ''">
and te.task_id = #{task_id} and te.task_id = #{task_id}
</if> </if>
<if test="vchan_refid != null and vchan_refid != ''">
and te.channel_unid = #{vchan_refid}
</if>
<if test="event_dt__gte != null and event_dt__lt != null"> <if test="event_dt__gte != null and event_dt__lt != null">
and te.event_time <![CDATA[>=]]> #{event_dt__gte} and te.event_time <![CDATA[>=]]> #{event_dt__gte}
and te.event_time <![CDATA[<=]]> #{event_dt__lt} and te.event_time <![CDATA[<=]]> #{event_dt__lt}
...@@ -87,6 +93,9 @@ ...@@ -87,6 +93,9 @@
<if test="task_id != null"> <if test="task_id != null">
and td.task_id = #{task_id} and td.task_id = #{task_id}
</if> </if>
<if test="vchan_refid != null and vchan_refid != ''">
and te.channel_unid = #{vchan_refid}
</if>
<if test="detection_type != null and detection_type.size > 0"> <if test="detection_type != null and detection_type.size > 0">
and detection_type in and detection_type in
<foreach item="item" index="index" collection="detection_type" open="(" separator="," close=")"> <foreach item="item" index="index" collection="detection_type" open="(" separator="," close=")">
......
...@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON; ...@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.viontech.fanxing.commons.config.VionConfig; import com.viontech.fanxing.commons.config.VionConfig;
import com.viontech.fanxing.task.model.vaserver.VaServerInfo; import com.viontech.fanxing.task.model.vaserver.VaServerInfo;
import com.viontech.fanxing.task.model.vaserver.VaServerOverViewModel;
import com.viontech.fanxing.task.service.VAServerService; import com.viontech.fanxing.task.service.VAServerService;
import com.viontech.keliu.util.JsonMessageUtil; import com.viontech.keliu.util.JsonMessageUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -11,6 +12,7 @@ import org.redisson.api.RMap; ...@@ -11,6 +12,7 @@ import org.redisson.api.RMap;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
/** /**
...@@ -126,4 +128,10 @@ public class VAServerController { ...@@ -126,4 +128,10 @@ public class VAServerController {
return vaServerService.getDefaultAlgorithmConfig(type); return vaServerService.getDefaultAlgorithmConfig(type);
} }
@GetMapping("/vaServer/overview")
public Object vaServerOverview() {
Collection<VaServerOverViewModel> result = vaServerService.vaServerOverview();
return JsonMessageUtil.getSuccessJsonMsg(result);
}
} }
package com.viontech.fanxing.task.model.vaserver;
import com.alibaba.fastjson.JSONObject;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import java.util.ArrayList;
import java.util.List;
/**
* .
*
* @author 谢明辉
* @date 2021/11/22
*/
@Getter
@Setter
@Accessors(chain = true)
public class VaServerOverViewModel {
private String ip;
private Float totalResource;
private Float usedResource;
private List<JSONObject> vaServerInfo = new ArrayList<>();
public VaServerOverViewModel addTotal(Float total) {
if (totalResource == null) {
totalResource = total;
} else {
totalResource += total;
}
return this;
}
public VaServerOverViewModel addUsed(Float used) {
if (usedResource == null) {
usedResource = used;
} else {
usedResource += used;
}
return this;
}
public VaServerOverViewModel addInfo(JSONObject item) {
vaServerInfo.add(item);
return this;
}
}
...@@ -39,7 +39,7 @@ public class VAServerHttpService { ...@@ -39,7 +39,7 @@ public class VAServerHttpService {
*/ */
public JSONObject addTask(TaskData taskData, VaServerInfo vaServerInfo) { public JSONObject addTask(TaskData taskData, VaServerInfo vaServerInfo) {
VATask vaTask = new VATask(taskData); VATask vaTask = new VATask(taskData);
if (vaTask.getStream_type().equals(ChannelType.STREAM_SIP.value)) { if (vaTask.getStream_type().equals(ChannelType.STREAM_VIDEO_CLOUD.value)) {
Channel channel = opsClientService.getChannelByChannelUnid(vaTask.getChannel_unid()); Channel channel = opsClientService.getChannelByChannelUnid(vaTask.getChannel_unid());
String deviceUnid = channel.getDeviceUnid(); String deviceUnid = channel.getDeviceUnid();
vaTask.setDevice_unid(deviceUnid); vaTask.setDevice_unid(deviceUnid);
...@@ -63,7 +63,7 @@ public class VAServerHttpService { ...@@ -63,7 +63,7 @@ public class VAServerHttpService {
public JSONObject updateTask(TaskData taskData, VaServerInfo vaServerInfo) { public JSONObject updateTask(TaskData taskData, VaServerInfo vaServerInfo) {
String path = "/api/vaserver/v1/task"; String path = "/api/vaserver/v1/task";
VATask vaTask = new VATask(taskData); VATask vaTask = new VATask(taskData);
if (vaTask.getStream_type().equals(ChannelType.STREAM_SIP.value)) { if (vaTask.getStream_type().equals(ChannelType.STREAM_VIDEO_CLOUD.value)) {
Channel channel = opsClientService.getChannelByChannelUnid(vaTask.getChannel_unid()); Channel channel = opsClientService.getChannelByChannelUnid(vaTask.getChannel_unid());
String deviceUnid = channel.getDeviceUnid(); String deviceUnid = channel.getDeviceUnid();
vaTask.setDevice_unid(deviceUnid); vaTask.setDevice_unid(deviceUnid);
......
package com.viontech.fanxing.task.service; package com.viontech.fanxing.task.service;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.viontech.fanxing.commons.base.LocalCache;
import com.viontech.fanxing.commons.config.VionConfig; import com.viontech.fanxing.commons.config.VionConfig;
import com.viontech.fanxing.commons.constant.RedisKeys; import com.viontech.fanxing.commons.constant.RedisKeys;
import com.viontech.fanxing.commons.exception.FanXingException; import com.viontech.fanxing.commons.exception.FanXingException;
...@@ -8,6 +9,7 @@ import com.viontech.fanxing.commons.model.Task; ...@@ -8,6 +9,7 @@ import com.viontech.fanxing.commons.model.Task;
import com.viontech.fanxing.commons.service.RedisService; import com.viontech.fanxing.commons.service.RedisService;
import com.viontech.fanxing.task.model.TaskData; import com.viontech.fanxing.task.model.TaskData;
import com.viontech.fanxing.task.model.vaserver.VaServerInfo; import com.viontech.fanxing.task.model.vaserver.VaServerInfo;
import com.viontech.fanxing.task.model.vaserver.VaServerOverViewModel;
import com.viontech.fanxing.task.repository.VAServerRedisRepository; import com.viontech.fanxing.task.repository.VAServerRedisRepository;
import org.redisson.api.RBucket; import org.redisson.api.RBucket;
import org.redisson.api.RLock; import org.redisson.api.RLock;
...@@ -15,8 +17,12 @@ import org.redisson.api.RMap; ...@@ -15,8 +17,12 @@ import org.redisson.api.RMap;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Collection;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/** /**
* 与 视频分析服务 交互的 service * 与 视频分析服务 交互的 service
...@@ -27,6 +33,8 @@ import java.util.concurrent.TimeUnit; ...@@ -27,6 +33,8 @@ import java.util.concurrent.TimeUnit;
@Service @Service
public class VAServerService { public class VAServerService {
protected final static Pattern IP_PATTERN = Pattern.compile("((?:1[0-9][0-9]\\.|2[0-4][0-9]\\.|25[0-5]\\.|[1-9][0-9]\\.|[0-9]\\.){3}(?:1[0-9][0-9]|2[0-4][0-9]|25[0-5]|[1-9][0-9]|[0-9]))");
@Resource @Resource
private RedisService redisService; private RedisService redisService;
...@@ -65,7 +73,6 @@ public class VAServerService { ...@@ -65,7 +73,6 @@ public class VAServerService {
bucket.expire(2, TimeUnit.MINUTES); bucket.expire(2, TimeUnit.MINUTES);
} }
/** /**
* 下发任务,关联任务和vaServer,修改vaServer可用资源数 * 下发任务,关联任务和vaServer,修改vaServer可用资源数
*/ */
...@@ -191,7 +198,6 @@ public class VAServerService { ...@@ -191,7 +198,6 @@ public class VAServerService {
} }
} }
/** /**
* 录像上传 * 录像上传
*/ */
...@@ -283,6 +289,38 @@ public class VAServerService { ...@@ -283,6 +289,38 @@ public class VAServerService {
return vaServerHttpService.getDefaultAlgorithmConfig(temp, taskAlgType); return vaServerHttpService.getDefaultAlgorithmConfig(temp, taskAlgType);
} }
/**
* 获取所有vaServer信息
*/
@LocalCache(value = "vaServerOverview", duration = 10, timeunit = TimeUnit.SECONDS)
public Collection<VaServerOverViewModel> vaServerOverview() {
HashMap<String, VaServerOverViewModel> map = new HashMap<>();
Collection<VaServerInfo> vaServerInfos = vaServerRedisRepository.getVaServerInfoMap().readAllValues();
for (VaServerInfo vaServer : vaServerInfos) {
String serviceBaseUrl = vaServer.getServiceBaseUrl();
Matcher matcher = IP_PATTERN.matcher(serviceBaseUrl);
String ip = "无法获取";
if (matcher.find()) {
ip = matcher.group();
}
JSONObject status = vaServerHttpService.status(vaServer);
JSONObject brief = status.getJSONObject("resource").getJSONObject("brief");
status.remove("resource");
status.put("devId", vaServer.getDevID());
status.put("status", vaServer.getStatus());
status.put("platType", vaServer.getPlatType());
status.put("softVersion", vaServer.getSoftVersion());
status.put("algoVersion", vaServer.getAlgoVersion());
VaServerOverViewModel model = map.computeIfAbsent(ip, x -> new VaServerOverViewModel());
model.setIp(ip).addTotal(brief.getFloat("video_total")).addUsed(brief.getFloat("video_busy")).addInfo(status);
}
return map.values();
}
public VAServerRedisRepository getVaServerRedisRepository() { public VAServerRedisRepository getVaServerRedisRepository() {
return vaServerRedisRepository; return vaServerRedisRepository;
} }
......
...@@ -167,6 +167,7 @@ CREATE TABLE IF NOT EXISTS d_flow_event ...@@ -167,6 +167,7 @@ CREATE TABLE IF NOT EXISTS d_flow_event
id BIGINT NOT NULL AUTO_INCREMENT, id BIGINT NOT NULL AUTO_INCREMENT,
unid VARCHAR(36) NOT NULL DEFAULT (UUID()), unid VARCHAR(36) NOT NULL DEFAULT (UUID()),
task_id BIGINT COMMENT '任务id', task_id BIGINT COMMENT '任务id',
channel_unid VARCHAR(64) COMMENT '设备通道unid',
event_type VARCHAR(36), event_type VARCHAR(36),
event_time TIMESTAMP COMMENT '事件时间', event_time TIMESTAMP COMMENT '事件时间',
event_id VARCHAR(64) COMMENT '事件唯一id', event_id VARCHAR(64) COMMENT '事件唯一id',
...@@ -178,7 +179,7 @@ CREATE TABLE IF NOT EXISTS d_flow_event ...@@ -178,7 +179,7 @@ CREATE TABLE IF NOT EXISTS d_flow_event
pics VARCHAR(2048), pics VARCHAR(2048),
video_name VARCHAR(256), video_name VARCHAR(256),
PRIMARY KEY (id, event_time), PRIMARY KEY (id, event_time),
INDEX flow_event_select_idx (event_time, event_type) INDEX flow_event_select_idx (event_time, event_type, channel_unid, task_id)
); );
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!