Commit 713483d7 by xmh

<feat> 设备注册添加算法版本和软件版本

<feat> 数据检索接口重新组织数据
<feat> 过车数据解析字段 special_type
1 parent 576de3be
package com.viontech.fanxing.commons.vo; package com.viontech.fanxing.commons.vo;
import com.alibaba.fastjson.JSONObject;
import com.viontech.fanxing.commons.model.Behavior; import com.viontech.fanxing.commons.model.Behavior;
import com.viontech.fanxing.commons.vobase.BehaviorVoBase; import com.viontech.fanxing.commons.vobase.BehaviorVoBase;
public class BehaviorVo extends BehaviorVoBase { public class BehaviorVo extends BehaviorVoBase {
private JSONObject data;
public BehaviorVo() { public BehaviorVo() {
super(); super();
} }
...@@ -12,4 +15,13 @@ public class BehaviorVo extends BehaviorVoBase { ...@@ -12,4 +15,13 @@ public class BehaviorVo extends BehaviorVoBase {
public BehaviorVo(Behavior behavior) { public BehaviorVo(Behavior behavior) {
super(behavior); super(behavior);
} }
public JSONObject getData() {
return data;
}
public BehaviorVo setData(JSONObject data) {
this.data = data;
return this;
}
} }
\ No newline at end of file \ No newline at end of file
package com.viontech.fanxing.commons.vo; package com.viontech.fanxing.commons.vo;
import com.alibaba.fastjson.JSONObject;
import com.viontech.fanxing.commons.model.Traffic; import com.viontech.fanxing.commons.model.Traffic;
import com.viontech.fanxing.commons.vobase.TrafficVoBase; import com.viontech.fanxing.commons.vobase.TrafficVoBase;
public class TrafficVo extends TrafficVoBase { public class TrafficVo extends TrafficVoBase {
private JSONObject data;
public TrafficVo() { public TrafficVo() {
super(); super();
} }
...@@ -12,4 +15,13 @@ public class TrafficVo extends TrafficVoBase { ...@@ -12,4 +15,13 @@ public class TrafficVo extends TrafficVoBase {
public TrafficVo(Traffic traffic) { public TrafficVo(Traffic traffic) {
super(traffic); super(traffic);
} }
public JSONObject getData() {
return data;
}
public TrafficVo setData(JSONObject data) {
this.data = data;
return this;
}
} }
\ No newline at end of file \ No newline at end of file
...@@ -108,6 +108,8 @@ public class TrafficProcessor implements ItemProcessor<JSONObject, TrafficConten ...@@ -108,6 +108,8 @@ public class TrafficProcessor implements ItemProcessor<JSONObject, TrafficConten
JSONObject bodyType = body.getJSONObject("type"); JSONObject bodyType = body.getJSONObject("type");
if (bodyType != null) { if (bodyType != null) {
String vehicleType = bodyType.getString("code"); String vehicleType = bodyType.getString("code");
Long specialType = bodyType.getLong("special_type");
traffic.setSpecialType(String.valueOf(specialType));
traffic.setVehicleType(vehicleType); traffic.setVehicleType(vehicleType);
} }
JSONObject bodyColor = body.getJSONObject("color"); JSONObject bodyColor = body.getJSONObject("color");
......
...@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON; ...@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializeConfig; import com.alibaba.fastjson.serializer.SerializeConfig;
import com.alibaba.fastjson.serializer.SerializeFilter; import com.alibaba.fastjson.serializer.SerializeFilter;
import com.alibaba.fastjson.serializer.SimplePropertyPreFilter; import com.alibaba.fastjson.serializer.SimplePropertyPreFilter;
import com.github.pagehelper.PageInfo;
import com.viontech.fanxing.commons.base.BaseExample; import com.viontech.fanxing.commons.base.BaseExample;
import com.viontech.fanxing.commons.model.BehaviorExample; import com.viontech.fanxing.commons.model.BehaviorExample;
import com.viontech.fanxing.commons.vo.BehaviorVo; import com.viontech.fanxing.commons.vo.BehaviorVo;
...@@ -11,16 +12,12 @@ import com.viontech.fanxing.query.controller.base.BehaviorBaseController; ...@@ -11,16 +12,12 @@ 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.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;
import static com.viontech.keliu.util.JsonMessageUtil.getSuccessJsonMsg;
@Controller @Controller
@RequestMapping("/behaviors") @RequestMapping("/behaviors")
...@@ -44,6 +41,13 @@ public class BehaviorController extends BehaviorBaseController { ...@@ -44,6 +41,13 @@ public class BehaviorController extends BehaviorBaseController {
simplePropertyPreFilter.getExcludes().add("model"); simplePropertyPreFilter.getExcludes().add("model");
opsClientService.addLog("检索分析结果,条件:" + JSON.toJSONString(behaviorVo, SerializeConfig.globalInstance, new SerializeFilter[]{simplePropertyPreFilter}, "yyyy-MM-dd HH:mm:ss", JSON.DEFAULT_GENERATE_FEATURE)); opsClientService.addLog("检索分析结果,条件:" + JSON.toJSONString(behaviorVo, SerializeConfig.globalInstance, new SerializeFilter[]{simplePropertyPreFilter}, "yyyy-MM-dd HH:mm:ss", JSON.DEFAULT_GENERATE_FEATURE));
return super.page(behaviorVo, page, pageSize, sortName, sortOrder); BaseExample baseExample = getExample(behaviorVo, EXAMPLE_TYPE_PAGE);
if (isNotNull(sortOrder) && isNotNull(sortName)) {
baseExample.setOrderByClause(baseExample.getTableAlias() + "." + sortName + " " + sortOrder);
} else if (isNotNull(sortName) && !isNotNull(sortOrder)) {
baseExample.setOrderByClause(sortName);
}
PageInfo<BehaviorVo> pageInfo = behaviorService.getJsonData(baseExample, page, pageSize);
return getSuccessJsonMsg(MESSAGE_PAGE_SUCCESS, pageInfo);
} }
} }
\ No newline at end of file \ No newline at end of file
...@@ -18,7 +18,6 @@ import org.springframework.web.bind.annotation.RequestParam; ...@@ -18,7 +18,6 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List;
import static com.viontech.keliu.util.JsonMessageUtil.getSuccessJsonMsg; import static com.viontech.keliu.util.JsonMessageUtil.getSuccessJsonMsg;
...@@ -39,10 +38,13 @@ public class TrafficController extends TrafficBaseController { ...@@ -39,10 +38,13 @@ public class TrafficController extends TrafficBaseController {
@Override @Override
@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.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(page > 0, "页面参数不正确");
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));
...@@ -53,12 +55,7 @@ public class TrafficController extends TrafficBaseController { ...@@ -53,12 +55,7 @@ public class TrafficController extends TrafficBaseController {
} else if (isNotNull(sortName) && !isNotNull(sortOrder)) { } else if (isNotNull(sortName) && !isNotNull(sortOrder)) {
baseExample.setOrderByClause(sortName); baseExample.setOrderByClause(sortName);
} }
if (page <= 0) { PageInfo<TrafficVo> pageInfo = trafficService.getJsonData(baseExample, page, pageSize);
List result = getService().selectByExample(baseExample); return getSuccessJsonMsg(MESSAGE_PAGE_SUCCESS, pageInfo);
return getSuccessJsonMsg(MESSAGE_SELECT_SUCCESS, result);
} else {
PageInfo pageInfo = getService().pagedQuery(baseExample, page, pageSize);
return getSuccessJsonMsg(MESSAGE_PAGE_SUCCESS, pageInfo);
}
} }
} }
\ No newline at end of file \ No newline at end of file
package com.viontech.fanxing.query.service.adapter; package com.viontech.fanxing.query.service.adapter;
import com.github.pagehelper.PageInfo;
import com.viontech.fanxing.commons.base.BaseExample;
import com.viontech.fanxing.commons.base.BaseService; import com.viontech.fanxing.commons.base.BaseService;
import com.viontech.fanxing.commons.model.Behavior; import com.viontech.fanxing.commons.model.Behavior;
import com.viontech.fanxing.commons.vo.BehaviorVo;
public interface BehaviorService extends BaseService<Behavior> { public interface BehaviorService extends BaseService<Behavior> {
PageInfo<BehaviorVo> getJsonData(BaseExample example, int pageNum, int pageSize);
} }
\ No newline at end of file \ No newline at end of file
package com.viontech.fanxing.query.service.adapter; package com.viontech.fanxing.query.service.adapter;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
import com.viontech.fanxing.commons.base.BaseExample;
import com.viontech.fanxing.commons.base.BaseService; import com.viontech.fanxing.commons.base.BaseService;
import com.viontech.fanxing.commons.model.Traffic; import com.viontech.fanxing.commons.model.Traffic;
import com.viontech.fanxing.commons.vo.TrafficVo;
public interface TrafficService extends BaseService<Traffic> { public interface TrafficService extends BaseService<Traffic> {
PageInfo<TrafficVo> getJsonData(BaseExample example, int pageNum, int pageSize);
} }
\ No newline at end of file \ No newline at end of file
package com.viontech.fanxing.query.service.impl; package com.viontech.fanxing.query.service.impl;
import com.alibaba.fastjson.JSON;
import com.github.pagehelper.Page; import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
...@@ -8,12 +9,14 @@ import com.viontech.fanxing.commons.base.BaseMapper; ...@@ -8,12 +9,14 @@ 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.commons.model.Behavior; import com.viontech.fanxing.commons.model.Behavior;
import com.viontech.fanxing.commons.model.BehaviorExample; import com.viontech.fanxing.commons.model.BehaviorExample;
import com.viontech.fanxing.commons.vo.BehaviorVo;
import com.viontech.fanxing.query.mapper.BehaviorMapper; import com.viontech.fanxing.query.mapper.BehaviorMapper;
import com.viontech.fanxing.query.service.adapter.BehaviorService; import com.viontech.fanxing.query.service.adapter.BehaviorService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
@Service @Service
public class BehaviorServiceImpl extends BaseServiceImpl<Behavior> implements BehaviorService { public class BehaviorServiceImpl extends BaseServiceImpl<Behavior> implements BehaviorService {
...@@ -27,17 +30,20 @@ public class BehaviorServiceImpl extends BaseServiceImpl<Behavior> implements Be ...@@ -27,17 +30,20 @@ public class BehaviorServiceImpl extends BaseServiceImpl<Behavior> implements Be
@Override @Override
public PageInfo<Behavior> pagedQuery(BaseExample example, int pageNum, int pageSize) { public PageInfo<BehaviorVo> getJsonData(BaseExample example, int pageNum, int pageSize) {
if (pageSize > 0) { PageHelper.startPage(pageNum, pageSize);
PageHelper.startPage(pageNum, pageSize); Page<Behavior> behaviors = (Page<Behavior>) behaviorMapper.selectByExampleWithBLOBs((BehaviorExample) example);
Page<Behavior> result = (Page<Behavior>) behaviorMapper.selectByExampleWithBLOBs((BehaviorExample) example); Page<BehaviorVo> page = new Page<>(pageNum, pageSize, true);
return new PageInfo<>(result); page.setTotal(behaviors.getTotal());
} else {
List<Behavior> result = behaviorMapper.selectByExampleWithBLOBs((BehaviorExample) example); List<BehaviorVo> collect = behaviors.stream().map(x -> {
Page<Behavior> p = new Page<>(); BehaviorVo trafficVo = new BehaviorVo(x);
p.addAll(result); trafficVo.setData(JSON.parseObject(x.getEventData()));
return new PageInfo<>(p); trafficVo.setEventData(null);
} return trafficVo;
}).collect(Collectors.toList());
page.addAll(collect);
return new PageInfo<>(page);
} }
@Override @Override
......
package com.viontech.fanxing.query.service.impl; package com.viontech.fanxing.query.service.impl;
import com.alibaba.fastjson.JSON;
import com.github.pagehelper.Page; import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
...@@ -8,12 +9,14 @@ import com.viontech.fanxing.commons.base.BaseMapper; ...@@ -8,12 +9,14 @@ 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.commons.model.Traffic; import com.viontech.fanxing.commons.model.Traffic;
import com.viontech.fanxing.commons.model.TrafficExample; import com.viontech.fanxing.commons.model.TrafficExample;
import com.viontech.fanxing.commons.vo.TrafficVo;
import com.viontech.fanxing.query.mapper.TrafficMapper; import com.viontech.fanxing.query.mapper.TrafficMapper;
import com.viontech.fanxing.query.service.adapter.TrafficService; import com.viontech.fanxing.query.service.adapter.TrafficService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
@Service @Service
public class TrafficServiceImpl extends BaseServiceImpl<Traffic> implements TrafficService { public class TrafficServiceImpl extends BaseServiceImpl<Traffic> implements TrafficService {
...@@ -32,16 +35,19 @@ public class TrafficServiceImpl extends BaseServiceImpl<Traffic> implements Traf ...@@ -32,16 +35,19 @@ public class TrafficServiceImpl extends BaseServiceImpl<Traffic> implements Traf
} }
@Override @Override
public PageInfo<Traffic> pagedQuery(BaseExample example, int pageNum, int pageSize) { public PageInfo<TrafficVo> getJsonData(BaseExample example, int pageNum, int pageSize) {
if (pageSize > 0) { PageHelper.startPage(pageNum, pageSize);
PageHelper.startPage(pageNum, pageSize); Page<Traffic> traffic = (Page<Traffic>) trafficMapper.selectByExampleWithBLOBs((TrafficExample) example);
Page<Traffic> result = (Page<Traffic>) trafficMapper.selectByExampleWithBLOBs((TrafficExample) example); Page<TrafficVo> page = new Page<>(pageNum, pageSize, true);
return new PageInfo<>(result); page.setTotal(traffic.getTotal());
} else {
List<Traffic> result = trafficMapper.selectByExampleWithBLOBs((TrafficExample) example); List<TrafficVo> collect = traffic.stream().map(x -> {
Page<Traffic> p = new Page<>(); TrafficVo trafficVo = new TrafficVo(x);
p.addAll(result); trafficVo.setData(JSON.parseObject(x.getJsonData()));
return new PageInfo<>(p); trafficVo.setJsonData(null);
} return trafficVo;
}).collect(Collectors.toList());
page.addAll(collect);
return new PageInfo<>(page);
} }
} }
\ No newline at end of file \ No newline at end of file
...@@ -25,6 +25,10 @@ public class VaServerInfo implements Serializable { ...@@ -25,6 +25,10 @@ public class VaServerInfo implements Serializable {
private Float availableResources; private Float availableResources;
/** 设备类型 */ /** 设备类型 */
private String platType; private String platType;
/** 软件版本 */
private String softVersion;
/** 算法版本 */
private String algoVersion;
/** 状态 1在线,0离线 */ /** 状态 1在线,0离线 */
private int status = 1; private int status = 1;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!