Commit 576de3be by xmh

<feat> 分析流播放地址适配ip,去掉配置

<fix> 事件检索重构
1 parent 8bfb5d5e
......@@ -16,12 +16,12 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
public abstract class BaseServiceImpl <T extends BaseModel> implements BaseService<T> {
public abstract class BaseServiceImpl<T extends BaseModel> implements BaseService<T> {
/**
* slf4j 日志对象 用来记录log
*/
protected Logger logger = LoggerFactory.getLogger(getClass());
private Map<String,String> columnNamePropertyMap = null;
private Map<String, String> columnNamePropertyMap = null;
public T selectByPrimaryKey(Object id) {
......@@ -42,7 +42,6 @@ public abstract class BaseServiceImpl <T extends BaseModel> implements BaseServi
}
@Override
public int deleteByPrimaryKey(Object b) {
return getMapper().deleteByPrimaryKey(b);
......@@ -60,17 +59,15 @@ public abstract class BaseServiceImpl <T extends BaseModel> implements BaseServi
@Override
public PageInfo<T> pagedQuery(BaseExample example, int pageNum, int pageSize) {
if(pageSize>0){
if (pageSize > 0) {
PageHelper.startPage(pageNum, pageSize);
Page<T> result = (Page<T>) getMapper().selectByExample(example);
PageInfo<T> pageInfo = new PageInfo<T>(result);
return pageInfo;
}else{
List<T> result = (List<T>) getMapper().selectByExample(example);
return new PageInfo<T>(result);
} else {
List<T> result = getMapper().selectByExample(example);
Page<T> p = new Page<T>();
p.addAll(result);
PageInfo<T> pageInfo = new PageInfo<T>(p);
return pageInfo;
return new PageInfo<T>(p);
}
}
......@@ -102,11 +99,11 @@ public abstract class BaseServiceImpl <T extends BaseModel> implements BaseServi
@Override
public List<Object> getIdsByByExample(BaseExample example) {
List<T> list= selectByExample(example);
List<T> list = selectByExample(example);
List<Object> result = new ArrayList<Object>();
for(T t : list){
for (T t : list) {
Object pk = getPKByModel(t);
if(pk!=null){
if (pk != null) {
result.add(pk);
}
}
......@@ -118,18 +115,18 @@ public abstract class BaseServiceImpl <T extends BaseModel> implements BaseServi
throw new UnsupportedOperationException();
}
public String getColumnNameByProperty(String property){
if(columnNamePropertyMap == null){
public String getColumnNameByProperty(String property) {
if (columnNamePropertyMap == null) {
columnNamePropertyMap = getColumnNamePropertyMap();
}
return columnNamePropertyMap.get(property);
}
public Map getColumnNamePropertyMap(){
public Map getColumnNamePropertyMap() {
Map<String, String> result = new HashMap<String, String>();
try {
SqlSession sqlSession = getSqlSessionByMapper(getMapper());
ResultMap resultMap = sqlSession.getConfiguration().getResultMap(getMapperClassByMapper(getMapper()).getName()+".BaseResultMapRoot");
ResultMap resultMap = sqlSession.getConfiguration().getResultMap(getMapperClassByMapper(getMapper()).getName() + ".BaseResultMapRoot");
List<ResultMapping> propertyResultMappings = resultMap.getPropertyResultMappings();
for (ResultMapping resultMapping : propertyResultMappings) {
result.put(resultMapping.getProperty(), resultMapping.getColumn());
......@@ -140,6 +137,7 @@ public abstract class BaseServiceImpl <T extends BaseModel> implements BaseServi
return result;
}
private SqlSession getSqlSessionByMapper(BaseMapper mapper) throws Exception {
Object mapperProxy = ((Proxy) mapper).getInvocationHandler(mapper);
Field sqlSession = mapperProxy.getClass().getDeclaredField("sqlSession");
......@@ -147,6 +145,7 @@ public abstract class BaseServiceImpl <T extends BaseModel> implements BaseServi
return (SqlSession) sqlSession.get(mapperProxy);
}
private Class getMapperClassByMapper(BaseMapper mapper) throws Exception {
Object mapperProxy = ((Proxy) mapper).getInvocationHandler(mapper);
Field mapperInterface = mapperProxy.getClass().getDeclaredField("mapperInterface");
......
......@@ -55,21 +55,12 @@ public class VionConfig {
static class Srs {
private String ip;
private String rtmpPort = "1935";
private String httpPort = "8080";
public String getRtmpUrl(String taskUnid) {
String url = "rtmp://" + ip + ":" + rtmpPort + "/live/" + taskUnid;
log.debug(url);
return url;
}
public String getHttpUrl(String taskUnid) {
// todo
String url = "http://36.112.68.214:30010/srs/live/" + taskUnid + ".flv";
// String url = "http://" + ip + ":" + httpPort + "/srs/live/" + taskUnid + ".flv";
log.debug(url);
return url;
}
}
public @Getter
......
......@@ -11,9 +11,16 @@ import com.viontech.fanxing.query.controller.base.BehaviorBaseController;
import com.viontech.fanxing.query.service.main.OpsClientService;
import org.springframework.stereotype.Controller;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
@Controller
@RequestMapping("/behaviors")
......@@ -25,11 +32,12 @@ public class BehaviorController extends BehaviorBaseController {
@Override
protected BaseExample getExample(BehaviorVo behaviorVo, int type) {
BehaviorExample behaviorExample = (BehaviorExample) super.getExample(behaviorVo, type);
behaviorExample.createColumns().hasIdColumn().hasEventTimeColumn().hasPicsColumn();
return behaviorExample;
}
@Override
public Object page(BehaviorVo behaviorVo, int page, int pageSize, String sortName, String sortOrder) {
public Object page(BehaviorVo behaviorVo, @RequestParam(value = "page", defaultValue = "-1") int page, @RequestParam(value = "pageSize", defaultValue = "100") int pageSize, String sortName, String sortOrder) {
Assert.notNull(behaviorVo.getEventTime_gte(), "起始时间不能为空");
Assert.notNull(behaviorVo.getEventTime_lte(), "结束时间不能为空");
SimplePropertyPreFilter simplePropertyPreFilter = new SimplePropertyPreFilter();
......
......@@ -32,7 +32,7 @@ public class TrafficController extends TrafficBaseController {
@Override
protected BaseExample getExample(TrafficVo trafficVo, int type) {
TrafficExample trafficExample = (TrafficExample) super.getExample(trafficVo, type);
trafficExample.createColumns().hasIdColumn().hasEventTimeColumn();
trafficExample.createColumns().hasIdColumn().hasEventTimeColumn().hasVideoNameColumn().hasPicsColumn();
return trafficExample;
}
......
package com.viontech.fanxing.query.service.impl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.viontech.fanxing.commons.base.BaseExample;
import com.viontech.fanxing.commons.base.BaseMapper;
import com.viontech.fanxing.commons.base.BaseServiceImpl;
import com.viontech.fanxing.query.mapper.BehaviorMapper;
import com.viontech.fanxing.commons.model.Behavior;
import com.viontech.fanxing.commons.model.BehaviorExample;
import com.viontech.fanxing.query.mapper.BehaviorMapper;
import com.viontech.fanxing.query.service.adapter.BehaviorService;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
@Service
public class BehaviorServiceImpl extends BaseServiceImpl<Behavior> implements BehaviorService {
@Resource
......@@ -17,4 +24,24 @@ public class BehaviorServiceImpl extends BaseServiceImpl<Behavior> implements Be
public BaseMapper<Behavior> getMapper() {
return behaviorMapper;
}
@Override
public PageInfo<Behavior> pagedQuery(BaseExample example, int pageNum, int pageSize) {
if (pageSize > 0) {
PageHelper.startPage(pageNum, pageSize);
Page<Behavior> result = (Page<Behavior>) behaviorMapper.selectByExampleWithBLOBs((BehaviorExample) example);
return new PageInfo<>(result);
} else {
List<Behavior> result = behaviorMapper.selectByExampleWithBLOBs((BehaviorExample) example);
Page<Behavior> p = new Page<>();
p.addAll(result);
return new PageInfo<>(p);
}
}
@Override
public List<Behavior> selectByExample(BaseExample example) {
return behaviorMapper.selectByExampleWithBLOBs(((BehaviorExample) example));
}
}
\ No newline at end of file
......@@ -183,7 +183,7 @@ public class VAServerService {
throw new FanXingException("设备离线");
}
String rtmpUrl = vionConfig.getSrs().getRtmpUrl(taskUnid);
String httpUrl = vionConfig.getSrs().getHttpUrl(taskUnid);
String httpUrl = "/srs/live/" + taskUnid + ".flv";
vaServerHttpService.startAnalyzeStream(taskUnid, vaServerInfo, rtmpUrl);
return httpUrl;
} else {
......
......@@ -57,5 +57,4 @@ vion:
srs:
ip: 192.168.9.233
rtmp-port: 1935
http-port: 30010
receive-result-prefix-path: http://192.168.9.116:30010/api
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!