Commit 576de3be by xmh

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

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