Commit 2737dc87 by xmh

Channel 增加字段 deviceType

ChannelTag 修改 tag 为字符串类型
转发服务提高线程池大小
gateway 添加路由配置

运维服务
1. 删除录像文件记录时同时删除文件
2. 录像文件大小由 expand 来记录
3. 上传录像文件时先写库再写入文件再更新库
4. 不能删除带有任务的Channel
5. 不能上传同名或同编号的录像文件和视频设备

任务服务整体调整
1 parent f7e3280c
Showing 31 changed files with 986 additions and 577 deletions
...@@ -46,13 +46,15 @@ public class Channel extends BaseModel { ...@@ -46,13 +46,15 @@ public class Channel extends BaseModel {
private Date createTime; private Date createTime;
private List<Long> tags; private String deviceType;
public List<Long> getTags() { private List<String> tags;
public List<String> getTags() {
return tags; return tags;
} }
public Channel setTags(List<Long> tags) { public Channel setTags(List<String> tags) {
this.tags = tags; this.tags = tags;
return this; return this;
} }
...@@ -216,4 +218,12 @@ public class Channel extends BaseModel { ...@@ -216,4 +218,12 @@ public class Channel extends BaseModel {
public void setCreateTime(Date createTime) { public void setCreateTime(Date createTime) {
this.createTime = createTime; this.createTime = createTime;
} }
public String getDeviceType() {
return deviceType;
}
public void setDeviceType(String deviceType) {
this.deviceType = deviceType;
}
} }
\ No newline at end of file \ No newline at end of file
...@@ -1408,6 +1408,76 @@ public class ChannelExample extends BaseExample { ...@@ -1408,6 +1408,76 @@ public class ChannelExample extends BaseExample {
addCriterion("`channel`.create_time not between", value1, value2, "createTime"); addCriterion("`channel`.create_time not between", value1, value2, "createTime");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andDeviceTypeIsNull() {
addCriterion("`channel`.device_type is null");
return (Criteria) this;
}
public Criteria andDeviceTypeIsNotNull() {
addCriterion("`channel`.device_type is not null");
return (Criteria) this;
}
public Criteria andDeviceTypeEqualTo(String value) {
addCriterion("`channel`.device_type =", value, "deviceType");
return (Criteria) this;
}
public Criteria andDeviceTypeNotEqualTo(String value) {
addCriterion("`channel`.device_type <>", value, "deviceType");
return (Criteria) this;
}
public Criteria andDeviceTypeGreaterThan(String value) {
addCriterion("`channel`.device_type >", value, "deviceType");
return (Criteria) this;
}
public Criteria andDeviceTypeGreaterThanOrEqualTo(String value) {
addCriterion("`channel`.device_type >=", value, "deviceType");
return (Criteria) this;
}
public Criteria andDeviceTypeLessThan(String value) {
addCriterion("`channel`.device_type <", value, "deviceType");
return (Criteria) this;
}
public Criteria andDeviceTypeLessThanOrEqualTo(String value) {
addCriterion("`channel`.device_type <=", value, "deviceType");
return (Criteria) this;
}
public Criteria andDeviceTypeLike(String value) {
addCriterion("`channel`.device_type like", value, "deviceType");
return (Criteria) this;
}
public Criteria andDeviceTypeNotLike(String value) {
addCriterion("`channel`.device_type not like", value, "deviceType");
return (Criteria) this;
}
public Criteria andDeviceTypeIn(List<String> values) {
addCriterion("`channel`.device_type in", values, "deviceType");
return (Criteria) this;
}
public Criteria andDeviceTypeNotIn(List<String> values) {
addCriterion("`channel`.device_type not in", values, "deviceType");
return (Criteria) this;
}
public Criteria andDeviceTypeBetween(String value1, String value2) {
addCriterion("`channel`.device_type between", value1, value2, "deviceType");
return (Criteria) this;
}
public Criteria andDeviceTypeNotBetween(String value1, String value2) {
addCriterion("`channel`.device_type not between", value1, value2, "deviceType");
return (Criteria) this;
}
} }
public static class ColumnContainer extends ColumnContainerBase { public static class ColumnContainer extends ColumnContainerBase {
...@@ -1515,5 +1585,10 @@ public class ChannelExample extends BaseExample { ...@@ -1515,5 +1585,10 @@ public class ChannelExample extends BaseExample {
addColumnStr("`channel`.create_time as channel_create_time "); addColumnStr("`channel`.create_time as channel_create_time ");
return (ColumnContainer) this; return (ColumnContainer) this;
} }
public ColumnContainer hasDeviceTypeColumn() {
addColumnStr("`channel`.device_type as channel_device_type ");
return (ColumnContainer) this;
}
} }
} }
\ No newline at end of file \ No newline at end of file
...@@ -7,7 +7,7 @@ public class ChannelTag extends BaseModel { ...@@ -7,7 +7,7 @@ public class ChannelTag extends BaseModel {
private Long channelId; private Long channelId;
private Long tagId; private String tag;
private Channel channel; private Channel channel;
...@@ -27,12 +27,12 @@ public class ChannelTag extends BaseModel { ...@@ -27,12 +27,12 @@ public class ChannelTag extends BaseModel {
this.channelId = channelId; this.channelId = channelId;
} }
public Long getTagId() { public String getTag() {
return tagId; return tag;
} }
public void setTagId(Long tagId) { public void setTag(String tag) {
this.tagId = tagId; this.tag = tag == null ? null : tag.trim();
} }
public Channel getChannel() { public Channel getChannel() {
......
...@@ -250,63 +250,73 @@ public class ChannelTagExample extends BaseExample { ...@@ -250,63 +250,73 @@ public class ChannelTagExample extends BaseExample {
return (Criteria) this; return (Criteria) this;
} }
public Criteria andTagIdIsNull() { public Criteria andTagIsNull() {
addCriterion("`channel_tag`.tag_id is null"); addCriterion("`channel_tag`.tag is null");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andTagIdIsNotNull() { public Criteria andTagIsNotNull() {
addCriterion("`channel_tag`.tag_id is not null"); addCriterion("`channel_tag`.tag is not null");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andTagIdEqualTo(Long value) { public Criteria andTagEqualTo(String value) {
addCriterion("`channel_tag`.tag_id =", value, "tagId"); addCriterion("`channel_tag`.tag =", value, "tag");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andTagIdNotEqualTo(Long value) { public Criteria andTagNotEqualTo(String value) {
addCriterion("`channel_tag`.tag_id <>", value, "tagId"); addCriterion("`channel_tag`.tag <>", value, "tag");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andTagIdGreaterThan(Long value) { public Criteria andTagGreaterThan(String value) {
addCriterion("`channel_tag`.tag_id >", value, "tagId"); addCriterion("`channel_tag`.tag >", value, "tag");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andTagIdGreaterThanOrEqualTo(Long value) { public Criteria andTagGreaterThanOrEqualTo(String value) {
addCriterion("`channel_tag`.tag_id >=", value, "tagId"); addCriterion("`channel_tag`.tag >=", value, "tag");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andTagIdLessThan(Long value) { public Criteria andTagLessThan(String value) {
addCriterion("`channel_tag`.tag_id <", value, "tagId"); addCriterion("`channel_tag`.tag <", value, "tag");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andTagIdLessThanOrEqualTo(Long value) { public Criteria andTagLessThanOrEqualTo(String value) {
addCriterion("`channel_tag`.tag_id <=", value, "tagId"); addCriterion("`channel_tag`.tag <=", value, "tag");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andTagIdIn(List<Long> values) { public Criteria andTagLike(String value) {
addCriterion("`channel_tag`.tag_id in", values, "tagId"); addCriterion("`channel_tag`.tag like", value, "tag");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andTagIdNotIn(List<Long> values) { public Criteria andTagNotLike(String value) {
addCriterion("`channel_tag`.tag_id not in", values, "tagId"); addCriterion("`channel_tag`.tag not like", value, "tag");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andTagIdBetween(Long value1, Long value2) { public Criteria andTagIn(List<String> values) {
addCriterion("`channel_tag`.tag_id between", value1, value2, "tagId"); addCriterion("`channel_tag`.tag in", values, "tag");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andTagIdNotBetween(Long value1, Long value2) { public Criteria andTagNotIn(List<String> values) {
addCriterion("`channel_tag`.tag_id not between", value1, value2, "tagId"); addCriterion("`channel_tag`.tag not in", values, "tag");
return (Criteria) this;
}
public Criteria andTagBetween(String value1, String value2) {
addCriterion("`channel_tag`.tag between", value1, value2, "tag");
return (Criteria) this;
}
public Criteria andTagNotBetween(String value1, String value2) {
addCriterion("`channel_tag`.tag not between", value1, value2, "tag");
return (Criteria) this; return (Criteria) this;
} }
} }
...@@ -327,8 +337,8 @@ public class ChannelTagExample extends BaseExample { ...@@ -327,8 +337,8 @@ public class ChannelTagExample extends BaseExample {
return (ColumnContainer) this; return (ColumnContainer) this;
} }
public ColumnContainer hasTagIdColumn() { public ColumnContainer hasTagColumn() {
addColumnStr("`channel_tag`.tag_id as channel_tag_tag_id "); addColumnStr("`channel_tag`.tag as channel_tag_tag ");
return (ColumnContainer) this; return (ColumnContainer) this;
} }
} }
......
...@@ -40,19 +40,10 @@ public class ChannelTagVoBase extends ChannelTag implements VoInterface<ChannelT ...@@ -40,19 +40,10 @@ public class ChannelTagVoBase extends ChannelTag implements VoInterface<ChannelT
private Long channelId_lte; private Long channelId_lte;
@JsonIgnore @JsonIgnore
private ArrayList<Long> tagId_arr; private ArrayList<String> tag_arr;
@JsonIgnore @JsonIgnore
private Long tagId_gt; private String tag_like;
@JsonIgnore
private Long tagId_lt;
@JsonIgnore
private Long tagId_gte;
@JsonIgnore
private Long tagId_lte;
public ChannelTagVoBase() { public ChannelTagVoBase() {
this(null); this(null);
...@@ -176,64 +167,40 @@ public class ChannelTagVoBase extends ChannelTag implements VoInterface<ChannelT ...@@ -176,64 +167,40 @@ public class ChannelTagVoBase extends ChannelTag implements VoInterface<ChannelT
} }
public void setChannelId(Long channelId) { public void setChannelId(Long channelId) {
if(getModel() == null ){ if (getModel() == null) {
throw new RuntimeException("model is null"); throw new RuntimeException("model is null");
} }
this.getModel().setChannelId(channelId); this.getModel().setChannelId(channelId);
} }
public ArrayList<Long> getTagId_arr() { public ArrayList<String> getTag_arr() {
return tagId_arr; return tag_arr;
}
public void setTagId_arr(ArrayList<Long> tagId_arr) {
this.tagId_arr = tagId_arr;
}
public Long getTagId_gt() {
return tagId_gt;
} }
public void setTagId_gt(Long tagId_gt) { public void setTag_arr(ArrayList<String> tag_arr) {
this.tagId_gt = tagId_gt; this.tag_arr = tag_arr;
} }
public Long getTagId_lt() { public String getTag_like() {
return tagId_lt; return tag_like;
} }
public void setTagId_lt(Long tagId_lt) { public void setTag_like(String tag_like) {
this.tagId_lt = tagId_lt; this.tag_like = tag_like;
} }
public Long getTagId_gte() { public String getTag() {
return tagId_gte; if (getModel() == null) {
}
public void setTagId_gte(Long tagId_gte) {
this.tagId_gte = tagId_gte;
}
public Long getTagId_lte() {
return tagId_lte;
}
public void setTagId_lte(Long tagId_lte) {
this.tagId_lte = tagId_lte;
}
public Long getTagId() {
if(getModel() == null ){
throw new RuntimeException("model is null"); throw new RuntimeException("model is null");
} }
return this.getModel().getTagId(); return this.getModel().getTag();
} }
public void setTagId(Long tagId) { public void setTag(String tag) {
if(getModel() == null ){ if (getModel() == null) {
throw new RuntimeException("model is null"); throw new RuntimeException("model is null");
} }
this.getModel().setTagId(tagId); this.getModel().setTag(tag);
} }
public Channel getChannel() { public Channel getChannel() {
......
...@@ -243,12 +243,21 @@ public class ChannelVoBase extends Channel implements VoInterface<Channel> { ...@@ -243,12 +243,21 @@ public class ChannelVoBase extends Channel implements VoInterface<Channel> {
@JsonIgnore @JsonIgnore
private Date createTime_lte; private Date createTime_lte;
@JsonIgnore
private Boolean deviceType_null;
@JsonIgnore
private ArrayList<String> deviceType_arr;
@JsonIgnore
private String deviceType_like;
public ChannelVoBase() { public ChannelVoBase() {
this(null); this(null);
} }
public ChannelVoBase(Channel channel) { public ChannelVoBase(Channel channel) {
if(channel == null) { if (channel == null) {
channel = new Channel(); channel = new Channel();
} }
this.channel = channel; this.channel = channel;
...@@ -1161,9 +1170,47 @@ public class ChannelVoBase extends Channel implements VoInterface<Channel> { ...@@ -1161,9 +1170,47 @@ public class ChannelVoBase extends Channel implements VoInterface<Channel> {
} }
public void setCreateTime(Date createTime) { public void setCreateTime(Date createTime) {
if(getModel() == null ){ if (getModel() == null) {
throw new RuntimeException("model is null"); throw new RuntimeException("model is null");
} }
this.getModel().setCreateTime(createTime); this.getModel().setCreateTime(createTime);
} }
public Boolean getDeviceType_null() {
return deviceType_null;
}
public void setDeviceType_null(Boolean deviceType_null) {
this.deviceType_null = deviceType_null;
}
public ArrayList<String> getDeviceType_arr() {
return deviceType_arr;
}
public void setDeviceType_arr(ArrayList<String> deviceType_arr) {
this.deviceType_arr = deviceType_arr;
}
public String getDeviceType_like() {
return deviceType_like;
}
public void setDeviceType_like(String deviceType_like) {
this.deviceType_like = deviceType_like;
}
public String getDeviceType() {
if (getModel() == null) {
throw new RuntimeException("model is null");
}
return this.getModel().getDeviceType();
}
public void setDeviceType(String deviceType) {
if (getModel() == null) {
throw new RuntimeException("model is null");
}
this.getModel().setDeviceType(deviceType);
}
} }
\ No newline at end of file \ No newline at end of file
...@@ -44,8 +44,8 @@ public class ForwardApp { ...@@ -44,8 +44,8 @@ public class ForwardApp {
@Bean @Bean
public TaskExecutor taskExecutor() { public TaskExecutor taskExecutor() {
ThreadPoolTaskExecutor threadPoolTaskExecutor = new ThreadPoolTaskExecutor(); ThreadPoolTaskExecutor threadPoolTaskExecutor = new ThreadPoolTaskExecutor();
threadPoolTaskExecutor.setMaxPoolSize(30); threadPoolTaskExecutor.setMaxPoolSize(50);
threadPoolTaskExecutor.setCorePoolSize(10); threadPoolTaskExecutor.setCorePoolSize(20);
threadPoolTaskExecutor.setThreadNamePrefix("fanxing-forward-process-"); threadPoolTaskExecutor.setThreadNamePrefix("fanxing-forward-process-");
return threadPoolTaskExecutor; return threadPoolTaskExecutor;
} }
......
...@@ -25,6 +25,16 @@ spring: ...@@ -25,6 +25,16 @@ spring:
- Path=/auth-serv/** - Path=/auth-serv/**
filters: filters:
- RewritePath=/auth-serv/?(?<segment>.*),/auth_serv/$\{segment} - RewritePath=/auth-serv/?(?<segment>.*),/auth_serv/$\{segment}
- id: images
uri: http://192.168.9.233:30007/
predicates:
- Path=/images/**
- id: videoService
uri: http://192.168.9.233:10350/
predicates:
- Path=/video-server/**
filters:
- RewritePath=/video-server/?(?<segment>.*),/$\{segment}
consul: consul:
# 服务发现配置 # 服务发现配置
discovery: discovery:
......
...@@ -2,12 +2,13 @@ package com.viontech.fanxing.ops.controller.base; ...@@ -2,12 +2,13 @@ package com.viontech.fanxing.ops.controller.base;
import com.viontech.fanxing.commons.base.BaseController; import com.viontech.fanxing.commons.base.BaseController;
import com.viontech.fanxing.commons.base.BaseExample; import com.viontech.fanxing.commons.base.BaseExample;
import com.viontech.fanxing.commons.base.BaseMapper;
import com.viontech.fanxing.commons.base.BaseService; import com.viontech.fanxing.commons.base.BaseService;
import com.viontech.fanxing.commons.model.Channel; import com.viontech.fanxing.commons.model.Channel;
import com.viontech.fanxing.commons.model.ChannelExample; import com.viontech.fanxing.commons.model.ChannelExample;
import com.viontech.fanxing.commons.vo.ChannelVo; import com.viontech.fanxing.commons.vo.ChannelVo;
import com.viontech.fanxing.ops.mapper.ChannelMapper;
import com.viontech.fanxing.ops.service.adapter.ChannelService; import com.viontech.fanxing.ops.service.adapter.ChannelService;
import javax.annotation.Resource; import javax.annotation.Resource;
public abstract class ChannelBaseController extends BaseController<Channel, ChannelVo> { public abstract class ChannelBaseController extends BaseController<Channel, ChannelVo> {
...@@ -368,6 +369,22 @@ public abstract class ChannelBaseController extends BaseController<Channel, Chan ...@@ -368,6 +369,22 @@ public abstract class ChannelBaseController extends BaseController<Channel, Chan
if (channelVo.getCreateTime_lte() != null) { if (channelVo.getCreateTime_lte() != null) {
criteria.andCreateTimeLessThanOrEqualTo(channelVo.getCreateTime_lte()); criteria.andCreateTimeLessThanOrEqualTo(channelVo.getCreateTime_lte());
} }
if (channelVo.getDeviceType() != null) {
criteria.andDeviceTypeEqualTo(channelVo.getDeviceType());
}
if (channelVo.getDeviceType_null() != null) {
if (channelVo.getDeviceType_null().booleanValue()) {
criteria.andDeviceTypeIsNull();
} else {
criteria.andDeviceTypeIsNotNull();
}
}
if (channelVo.getDeviceType_arr() != null) {
criteria.andDeviceTypeIn(channelVo.getDeviceType_arr());
}
if (channelVo.getDeviceType_like() != null) {
criteria.andDeviceTypeLike(channelVo.getDeviceType_like());
}
return channelExample; return channelExample;
} }
......
...@@ -46,32 +46,23 @@ public abstract class ChannelTagBaseController extends BaseController<ChannelTag ...@@ -46,32 +46,23 @@ public abstract class ChannelTagBaseController extends BaseController<ChannelTag
if(channelTagVo.getChannelId_gt() != null) { if(channelTagVo.getChannelId_gt() != null) {
criteria.andChannelIdGreaterThan(channelTagVo.getChannelId_gt()); criteria.andChannelIdGreaterThan(channelTagVo.getChannelId_gt());
} }
if(channelTagVo.getChannelId_lt() != null) { if (channelTagVo.getChannelId_lt() != null) {
criteria.andChannelIdLessThan(channelTagVo.getChannelId_lt()); criteria.andChannelIdLessThan(channelTagVo.getChannelId_lt());
} }
if(channelTagVo.getChannelId_gte() != null) { if (channelTagVo.getChannelId_gte() != null) {
criteria.andChannelIdGreaterThanOrEqualTo(channelTagVo.getChannelId_gte()); criteria.andChannelIdGreaterThanOrEqualTo(channelTagVo.getChannelId_gte());
} }
if(channelTagVo.getChannelId_lte() != null) { if (channelTagVo.getChannelId_lte() != null) {
criteria.andChannelIdLessThanOrEqualTo(channelTagVo.getChannelId_lte()); criteria.andChannelIdLessThanOrEqualTo(channelTagVo.getChannelId_lte());
} }
if(channelTagVo.getTagId() != null) { if (channelTagVo.getTag() != null) {
criteria.andTagIdEqualTo(channelTagVo.getTagId()); criteria.andTagEqualTo(channelTagVo.getTag());
} }
if(channelTagVo.getTagId_arr() != null) { if (channelTagVo.getTag_arr() != null) {
criteria.andTagIdIn(channelTagVo.getTagId_arr()); criteria.andTagIn(channelTagVo.getTag_arr());
} }
if(channelTagVo.getTagId_gt() != null) { if (channelTagVo.getTag_like() != null) {
criteria.andTagIdGreaterThan(channelTagVo.getTagId_gt()); criteria.andTagLike(channelTagVo.getTag_like());
}
if(channelTagVo.getTagId_lt() != null) {
criteria.andTagIdLessThan(channelTagVo.getTagId_lt());
}
if(channelTagVo.getTagId_gte() != null) {
criteria.andTagIdGreaterThanOrEqualTo(channelTagVo.getTagId_gte());
}
if(channelTagVo.getTagId_lte() != null) {
criteria.andTagIdLessThanOrEqualTo(channelTagVo.getTagId_lte());
} }
return channelTagExample; return channelTagExample;
} }
......
...@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject; ...@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import com.viontech.fanxing.ops.service.main.VideoService; import com.viontech.fanxing.ops.service.main.VideoService;
import com.viontech.keliu.util.JsonMessageUtil; import com.viontech.keliu.util.JsonMessageUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
...@@ -26,8 +27,12 @@ public class VideoController { ...@@ -26,8 +27,12 @@ public class VideoController {
private VideoService videoService; private VideoService videoService;
@PostMapping("/upload") @PostMapping("/upload")
public Object uploadVideo(@RequestParam List<MultipartFile> files, @RequestParam(required = false) List<Long> tags) { public Object uploadVideo(@RequestParam List<MultipartFile> files, @RequestParam(required = false) List<String> tags) {
videoService.uploadVideo(files, tags); try {
videoService.uploadVideo(files, tags);
} catch (DuplicateKeyException e) {
return JsonMessageUtil.getErrorJsonMsg("设备编号或名称重复");
}
return JsonMessageUtil.getSuccessJsonMsg("success"); return JsonMessageUtil.getSuccessJsonMsg("success");
} }
......
...@@ -14,8 +14,9 @@ import com.viontech.fanxing.ops.controller.base.ChannelBaseController; ...@@ -14,8 +14,9 @@ import com.viontech.fanxing.ops.controller.base.ChannelBaseController;
import com.viontech.fanxing.ops.service.adapter.ChannelTagService; import com.viontech.fanxing.ops.service.adapter.ChannelTagService;
import com.viontech.keliu.util.JsonMessageUtil; import com.viontech.keliu.util.JsonMessageUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List; import java.util.List;
...@@ -71,9 +72,9 @@ public class ChannelController extends ChannelBaseController { ...@@ -71,9 +72,9 @@ public class ChannelController extends ChannelBaseController {
ChannelTagExample channelTagExample = new ChannelTagExample(); ChannelTagExample channelTagExample = new ChannelTagExample();
channelTagExample.createCriteria().andChannelIdIn(channelIdList); channelTagExample.createCriteria().andChannelIdIn(channelIdList);
List<ChannelTag> channelTags = channelTagService.selectByExample(channelTagExample); List<ChannelTag> channelTags = channelTagService.selectByExample(channelTagExample);
Map<Long, List<Long>> channel_tag_map = channelTags.stream().collect(Collectors.groupingBy(ChannelTag::getChannelId, Collectors.mapping(ChannelTag::getTagId, Collectors.toList()))); Map<Long, List<String>> channel_tag_map = channelTags.stream().collect(Collectors.groupingBy(ChannelTag::getChannelId, Collectors.mapping(ChannelTag::getTag, Collectors.toList())));
for (Channel channel : channels) { for (Channel channel : channels) {
List<Long> tags = channel_tag_map.get(channel.getId()); List<String> tags = channel_tag_map.get(channel.getId());
channel.setTags(tags); channel.setTags(tags);
} }
} }
...@@ -87,4 +88,26 @@ public class ChannelController extends ChannelBaseController { ...@@ -87,4 +88,26 @@ public class ChannelController extends ChannelBaseController {
return JsonMessageUtil.getSuccessJsonMsg(result); return JsonMessageUtil.getSuccessJsonMsg(result);
} }
@RequestMapping(value = "", method = RequestMethod.POST)
@ResponseBody
@Override
public Object add(@RequestBody ChannelVo channelVo) {
Assert.notNull(channelVo.getChannelUnid(), "设备编号不能为空");
Assert.notNull(channelVo.getName(), "设备名称不能为空");
Assert.notNull(channelVo.getBrand(), "厂家不能为空");
Assert.notNull(channelVo.getIp(), "IP不能为空");
Assert.notNull(channelVo.getPort(), "端口不能为空");
Assert.notNull(channelVo.getStreamType(), "视频流类型不能为空");
Assert.notNull(channelVo.getUsername(), "用户名不能为空");
Assert.notNull(channelVo.getPassword(), "密码不能为空");
Assert.notNull(channelVo.getStreamPath(), "视频流地址不能为空");
Assert.notNull(channelVo.getType(), "类型不能为空");
try {
return super.add(channelVo);
} catch (DuplicateKeyException e) {
log.error("", e);
return JsonMessageUtil.getErrorJsonMsg("设备编号或名称重复");
}
}
} }
\ No newline at end of file \ No newline at end of file
...@@ -5,6 +5,7 @@ import com.viontech.keliu.util.JsonMessageUtil; ...@@ -5,6 +5,7 @@ import com.viontech.keliu.util.JsonMessageUtil;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List; import java.util.List;
...@@ -22,4 +23,7 @@ public interface TaskFeignClient { ...@@ -22,4 +23,7 @@ public interface TaskFeignClient {
@GetMapping("/tasks") @GetMapping("/tasks")
JsonMessageUtil.JsonMessage<List<Task>> getAllTask(); JsonMessageUtil.JsonMessage<List<Task>> getAllTask();
@GetMapping("/tasks")
JsonMessageUtil.JsonMessage<List<Task>> getTaskByChannelUnid(@RequestParam("channelUnid") String channelUnid);
} }
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
<result column="channel_latitude" property="latitude" /> <result column="channel_latitude" property="latitude" />
<result column="channel_status" property="status" /> <result column="channel_status" property="status" />
<result column="channel_create_time" property="createTime" /> <result column="channel_create_time" property="createTime" />
<result column="channel_device_type" property="deviceType"/>
</resultMap> </resultMap>
<resultMap id="BaseResultMap" type="com.viontech.fanxing.commons.model.Channel" extends="BaseResultMapRoot" /> <resultMap id="BaseResultMap" type="com.viontech.fanxing.commons.model.Channel" extends="BaseResultMapRoot" />
<sql id="Example_Where_Clause" > <sql id="Example_Where_Clause" >
...@@ -83,14 +84,18 @@ ...@@ -83,14 +84,18 @@
</where> </where>
</sql> </sql>
<sql id="Base_Column_List_Root" > <sql id="Base_Column_List_Root" >
`channel`.id as channel_id, `channel`.unid as channel_unid, `channel`.channel_unid as channel_channel_unid, ` channel `.id as channel_id,
`channel`.device_unid as channel_device_unid, `channel`.`type` as `channel_type`, ` channel `.unid as channel_unid,
` channel `.channel_unid as channel_channel_unid,
` channel `.device_unid as channel_device_unid,
` channel `.`type` as `channel_type`,
`channel`.stream_type as channel_stream_type, `channel`.stream_path as channel_stream_path, `channel`.stream_type as channel_stream_type, `channel`.stream_path as channel_stream_path,
`channel`.username as channel_username, `channel`.`password` as `channel_password`, `channel`.username as channel_username, `channel`.`password` as `channel_password`,
`channel`.brand as channel_brand, `channel`.direction as channel_direction, `channel`.address_unid as channel_address_unid, `channel`.brand as channel_brand, `channel`.direction as channel_direction, `channel`.address_unid as channel_address_unid,
`channel`.`name` as `channel_name`, `channel`.ip as channel_ip, `channel`.port as channel_port, `channel`.`name` as `channel_name`, `channel`.ip as channel_ip, `channel`.port as channel_port,
`channel`.expand as channel_expand, `channel`.longitude as channel_longitude, `channel`.latitude as channel_latitude, `channel`.expand as channel_expand, `channel`.longitude as channel_longitude, `channel`.latitude as channel_latitude,
`channel`.`status` as `channel_status`, `channel`.create_time as channel_create_time `channel`.`status` as `channel_status`, `channel`.create_time as channel_create_time,
`channel`.device_type as channel_device_type
</sql> </sql>
<sql id="Base_Column_List" > <sql id="Base_Column_List" >
<if test="!(_parameter.getClass().getSimpleName() == 'ChannelExample')" > <if test="!(_parameter.getClass().getSimpleName() == 'ChannelExample')" >
...@@ -145,20 +150,20 @@ ...@@ -145,20 +150,20 @@
</if> </if>
</delete> </delete>
<insert id="insert" parameterType="com.viontech.fanxing.commons.model.Channel" useGeneratedKeys="true" keyProperty="id" keyColumn="id" > <insert id="insert" parameterType="com.viontech.fanxing.commons.model.Channel" useGeneratedKeys="true" keyProperty="id" keyColumn="id" >
insert into `s_channel` (unid, channel_unid, device_unid, insert into `s_channel` (unid, channel_unid, device_unid,
`type`, stream_type, stream_path, `type`, stream_type, stream_path,
username, `password`, brand, username, `password`, brand,
direction, address_unid, `name`, direction, address_unid, `name`,
ip, port, expand, longitude, ip, port, expand, longitude,
latitude, `status`, create_time latitude, `status`, create_time,
) device_type)
values (#{unid,jdbcType=VARCHAR}, #{channelUnid,jdbcType=VARCHAR}, #{deviceUnid,jdbcType=VARCHAR}, values (#{unid,jdbcType=VARCHAR}, #{channelUnid,jdbcType=VARCHAR}, #{deviceUnid,jdbcType=VARCHAR},
#{type,jdbcType=INTEGER}, #{streamType,jdbcType=INTEGER}, #{streamPath,jdbcType=VARCHAR}, #{type,jdbcType=INTEGER}, #{streamType,jdbcType=INTEGER}, #{streamPath,jdbcType=VARCHAR},
#{username,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR}, #{brand,jdbcType=VARCHAR}, #{username,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR}, #{brand,jdbcType=VARCHAR},
#{direction,jdbcType=VARCHAR}, #{addressUnid,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{direction,jdbcType=VARCHAR}, #{addressUnid,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
#{ip,jdbcType=VARCHAR}, #{port,jdbcType=INTEGER}, #{expand,jdbcType=VARCHAR}, #{longitude,jdbcType=REAL}, #{ip,jdbcType=VARCHAR}, #{port,jdbcType=INTEGER}, #{expand,jdbcType=VARCHAR}, #{longitude,jdbcType=REAL},
#{latitude,jdbcType=REAL}, #{status,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP} #{latitude,jdbcType=REAL}, #{status,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP},
) #{deviceType,jdbcType=VARCHAR})
</insert> </insert>
<insert id="insertSelective" parameterType="com.viontech.fanxing.commons.model.Channel" useGeneratedKeys="true" keyProperty="id" keyColumn="id" > <insert id="insertSelective" parameterType="com.viontech.fanxing.commons.model.Channel" useGeneratedKeys="true" keyProperty="id" keyColumn="id" >
insert into `s_channel` insert into `s_channel`
...@@ -209,17 +214,20 @@ ...@@ -209,17 +214,20 @@
expand, expand,
</if> </if>
<if test="longitude != null" > <if test="longitude != null" >
longitude, longitude,
</if>
<if test="latitude != null" >
latitude,
</if>
<if test="status != null" >
`status`,
</if>
<if test="createTime != null" >
create_time,
</if> </if>
<if test="latitude != null">
latitude,
</if>
<if test="status != null">
`status`,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="deviceType != null">
device_type,
</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides="," > <trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="unid != null" > <if test="unid != null" >
...@@ -270,15 +278,18 @@ ...@@ -270,15 +278,18 @@
<if test="longitude != null" > <if test="longitude != null" >
#{longitude,jdbcType=REAL}, #{longitude,jdbcType=REAL},
</if> </if>
<if test="latitude != null" > <if test="latitude != null">
#{latitude,jdbcType=REAL}, #{latitude,jdbcType=REAL},
</if> </if>
<if test="status != null" > <if test="status != null">
#{status,jdbcType=INTEGER}, #{status,jdbcType=INTEGER},
</if> </if>
<if test="createTime != null" > <if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP}, #{createTime,jdbcType=TIMESTAMP},
</if> </if>
<if test="deviceType != null">
#{deviceType,jdbcType=VARCHAR},
</if>
</trim> </trim>
</insert> </insert>
<select id="countByExample" parameterType="com.viontech.fanxing.commons.model.ChannelExample" resultType="java.lang.Integer" > <select id="countByExample" parameterType="com.viontech.fanxing.commons.model.ChannelExample" resultType="java.lang.Integer" >
...@@ -339,17 +350,20 @@ ...@@ -339,17 +350,20 @@
expand = #{record.expand,jdbcType=VARCHAR}, expand = #{record.expand,jdbcType=VARCHAR},
</if> </if>
<if test="record.longitude != null" > <if test="record.longitude != null" >
longitude = #{record.longitude,jdbcType=REAL}, longitude = #{record.longitude,jdbcType=REAL},
</if>
<if test="record.latitude != null" >
latitude = #{record.latitude,jdbcType=REAL},
</if>
<if test="record.status != null" >
`status` = #{record.status,jdbcType=INTEGER},
</if>
<if test="record.createTime != null" >
create_time = #{record.createTime,jdbcType=TIMESTAMP},
</if> </if>
<if test="record.latitude != null">
latitude = #{record.latitude,jdbcType=REAL},
</if>
<if test="record.status != null">
`status` = #{record.status,jdbcType=INTEGER},
</if>
<if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=TIMESTAMP},
</if>
<if test="record.deviceType != null">
device_type = #{record.deviceType,jdbcType=VARCHAR},
</if>
</set> </set>
<if test="_parameter != null" > <if test="_parameter != null" >
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
...@@ -376,8 +390,9 @@ ...@@ -376,8 +390,9 @@
longitude = #{record.longitude,jdbcType=REAL}, longitude = #{record.longitude,jdbcType=REAL},
latitude = #{record.latitude,jdbcType=REAL}, latitude = #{record.latitude,jdbcType=REAL},
`status` = #{record.status,jdbcType=INTEGER}, `status` = #{record.status,jdbcType=INTEGER},
create_time = #{record.createTime,jdbcType=TIMESTAMP} create_time = #{record.createTime,jdbcType=TIMESTAMP},
<if test="_parameter != null" > device_type = #{record.deviceType,jdbcType=VARCHAR}
<if test="_parameter != null" >
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
</if> </if>
</update> </update>
...@@ -432,15 +447,18 @@ ...@@ -432,15 +447,18 @@
<if test="longitude != null" > <if test="longitude != null" >
longitude = #{longitude,jdbcType=REAL}, longitude = #{longitude,jdbcType=REAL},
</if> </if>
<if test="latitude != null" > <if test="latitude != null">
latitude = #{latitude,jdbcType=REAL}, latitude = #{latitude,jdbcType=REAL},
</if> </if>
<if test="status != null" > <if test="status != null">
`status` = #{status,jdbcType=INTEGER}, `status` = #{status,jdbcType=INTEGER},
</if> </if>
<if test="createTime != null" > <if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP}, create_time = #{createTime,jdbcType=TIMESTAMP},
</if> </if>
<if test="deviceType != null">
device_type = #{deviceType,jdbcType=VARCHAR},
</if>
</set> </set>
where id = #{id,jdbcType=BIGINT} where id = #{id,jdbcType=BIGINT}
</update> </update>
...@@ -464,7 +482,8 @@ ...@@ -464,7 +482,8 @@
longitude = #{longitude,jdbcType=REAL}, longitude = #{longitude,jdbcType=REAL},
latitude = #{latitude,jdbcType=REAL}, latitude = #{latitude,jdbcType=REAL},
`status` = #{status,jdbcType=INTEGER}, `status` = #{status,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=TIMESTAMP} create_time = #{createTime,jdbcType=TIMESTAMP},
where id = #{id,jdbcType=BIGINT} device_type = #{deviceType,jdbcType=VARCHAR}
where id = #{id,jdbcType=BIGINT}
</update> </update>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
...@@ -4,28 +4,30 @@ ...@@ -4,28 +4,30 @@
<resultMap id="BaseResultMapRoot" type="com.viontech.fanxing.commons.model.ChannelTag" > <resultMap id="BaseResultMapRoot" type="com.viontech.fanxing.commons.model.ChannelTag" >
<id column="channel_tag_id" property="id" /> <id column="channel_tag_id" property="id" />
<result column="channel_tag_channel_id" property="channelId" /> <result column="channel_tag_channel_id" property="channelId" />
<result column="channel_tag_tag_id" property="tagId" /> <result column="channel_tag_tag" property="tag"/>
</resultMap>
<resultMap id="BaseResultMap" type="com.viontech.fanxing.commons.model.ChannelTag" extends="BaseResultMapRoot" >
<result column="channel_id" property="channel.id" />
<result column="channel_unid" property="channel.unid" />
<result column="channel_channel_unid" property="channel.channelUnid" />
<result column="channel_device_unid" property="channel.deviceUnid" />
<result column="channel_type" property="channel.type" />
<result column="channel_stream_type" property="channel.streamType" />
<result column="channel_stream_path" property="channel.streamPath" />
<result column="channel_username" property="channel.username" />
<result column="channel_password" property="channel.password" />
<result column="channel_address_unid" property="channel.addressUnid" />
<result column="channel_name" property="channel.name" />
<result column="channel_ip" property="channel.ip" />
<result column="channel_port" property="channel.port" />
<result column="channel_expand" property="channel.expand" />
<result column="channel_longitude" property="channel.longitude" />
<result column="channel_latitude" property="channel.latitude" />
<result column="channel_status" property="channel.status" />
<result column="channel_create_time" property="channel.createTime" />
</resultMap> </resultMap>
<resultMap id="BaseResultMap" type="com.viontech.fanxing.commons.model.ChannelTag" extends="BaseResultMapRoot">
<result column="channel_id" property="channel.id"/>
<result column="channel_unid" property="channel.unid"/>
<result column="channel_channel_unid" property="channel.channelUnid"/>
<result column="channel_device_unid" property="channel.deviceUnid"/>
<result column="channel_type" property="channel.type"/>
<result column="channel_stream_type" property="channel.streamType"/>
<result column="channel_stream_path" property="channel.streamPath"/>
<result column="channel_username" property="channel.username"/>
<result column="channel_password" property="channel.password"/>
<result column="channel_brand" property="channel.brand"/>
<result column="channel_direction" property="channel.direction"/>
<result column="channel_address_unid" property="channel.addressUnid"/>
<result column="channel_name" property="channel.name"/>
<result column="channel_ip" property="channel.ip"/>
<result column="channel_port" property="channel.port"/>
<result column="channel_expand" property="channel.expand"/>
<result column="channel_longitude" property="channel.longitude"/>
<result column="channel_latitude" property="channel.latitude"/>
<result column="channel_status" property="channel.status"/>
<result column="channel_create_time" property="channel.createTime"/>
</resultMap>
<sql id="Left_Join_List" > <sql id="Left_Join_List" >
<foreach collection="leftJoinTableSet" item="leftJoinTable" > <foreach collection="leftJoinTableSet" item="leftJoinTable" >
<choose > <choose >
...@@ -94,8 +96,9 @@ ...@@ -94,8 +96,9 @@
</where> </where>
</sql> </sql>
<sql id="Base_Column_List_Root" > <sql id="Base_Column_List_Root" >
`channel_tag`.id as channel_tag_id, `channel_tag`.channel_id as channel_tag_channel_id, ` channel_tag `.id as channel_tag_id,
`channel_tag`.tag_id as channel_tag_tag_id ` channel_tag `.channel_id as channel_tag_channel_id,
` channel_tag `.tag as channel_tag_tag
</sql> </sql>
<sql id="Base_Column_List" > <sql id="Base_Column_List" >
<if test="!(_parameter.getClass().getSimpleName() == 'ChannelTagExample')" > <if test="!(_parameter.getClass().getSimpleName() == 'ChannelTagExample')" >
...@@ -159,27 +162,27 @@ ...@@ -159,27 +162,27 @@
</if> </if>
</delete> </delete>
<insert id="insert" parameterType="com.viontech.fanxing.commons.model.ChannelTag" useGeneratedKeys="true" keyProperty="id" keyColumn="id" > <insert id="insert" parameterType="com.viontech.fanxing.commons.model.ChannelTag" useGeneratedKeys="true" keyProperty="id" keyColumn="id" >
insert into `r_channel_tag` (channel_id, tag_id) insert into `r_channel_tag` (channel_id, tag)
values (#{channelId,jdbcType=BIGINT}, #{tagId,jdbcType=BIGINT}) values (#{channelId,jdbcType=BIGINT}, #{tag,jdbcType=VARCHAR})
</insert> </insert>
<insert id="insertSelective" parameterType="com.viontech.fanxing.commons.model.ChannelTag" useGeneratedKeys="true" keyProperty="id" keyColumn="id" > <insert id="insertSelective" parameterType="com.viontech.fanxing.commons.model.ChannelTag" useGeneratedKeys="true" keyProperty="id" keyColumn="id" >
insert into `r_channel_tag` insert into `r_channel_tag`
<trim prefix="(" suffix=")" suffixOverrides="," > <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="channelId != null" > <if test="channelId != null">
channel_id, channel_id,
</if> </if>
<if test="tagId != null" > <if test="tag != null">
tag_id, tag,
</if> </if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides="," > <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="channelId != null" > <if test="channelId != null">
#{channelId,jdbcType=BIGINT}, #{channelId,jdbcType=BIGINT},
</if> </if>
<if test="tagId != null" > <if test="tag != null">
#{tagId,jdbcType=BIGINT}, #{tag,jdbcType=VARCHAR},
</if> </if>
</trim> </trim>
</insert> </insert>
<select id="countByExample" parameterType="com.viontech.fanxing.commons.model.ChannelTagExample" resultType="java.lang.Integer" > <select id="countByExample" parameterType="com.viontech.fanxing.commons.model.ChannelTagExample" resultType="java.lang.Integer" >
select count(*) from `r_channel_tag` `channel_tag` select count(*) from `r_channel_tag` `channel_tag`
...@@ -190,46 +193,46 @@ ...@@ -190,46 +193,46 @@
</select> </select>
<update id="updateByExampleSelective" parameterType="map" > <update id="updateByExampleSelective" parameterType="map" >
update `r_channel_tag` `channel_tag` update `r_channel_tag` `channel_tag`
<set > <set>
<if test="record.id != null" > <if test="record.id != null">
id = #{record.id,jdbcType=BIGINT}, id = #{record.id,jdbcType=BIGINT},
</if> </if>
<if test="record.channelId != null" > <if test="record.channelId != null">
channel_id = #{record.channelId,jdbcType=BIGINT}, channel_id = #{record.channelId,jdbcType=BIGINT},
</if> </if>
<if test="record.tagId != null" > <if test="record.tag != null">
tag_id = #{record.tagId,jdbcType=BIGINT}, tag = #{record.tag,jdbcType=VARCHAR},
</if> </if>
</set> </set>
<if test="_parameter != null" > <if test="_parameter != null" >
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
</if> </if>
</update> </update>
<update id="updateByExample" parameterType="map" > <update id="updateByExample" parameterType="map" >
update `r_channel_tag` `channel_tag` update `r_channel_tag` `channel_tag`
set id = #{record.id,jdbcType=BIGINT}, set id = #{record.id,jdbcType=BIGINT},
channel_id = #{record.channelId,jdbcType=BIGINT}, channel_id = #{record.channelId,jdbcType=BIGINT},
tag_id = #{record.tagId,jdbcType=BIGINT} tag = #{record.tag,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>
</update> </update>
<update id="updateByPrimaryKeySelective" parameterType="com.viontech.fanxing.commons.model.ChannelTag" > <update id="updateByPrimaryKeySelective" parameterType="com.viontech.fanxing.commons.model.ChannelTag" >
update `r_channel_tag` update `r_channel_tag`
<set > <set>
<if test="channelId != null" > <if test="channelId != null">
channel_id = #{channelId,jdbcType=BIGINT}, channel_id = #{channelId,jdbcType=BIGINT},
</if> </if>
<if test="tagId != null" > <if test="tag != null">
tag_id = #{tagId,jdbcType=BIGINT}, tag = #{tag,jdbcType=VARCHAR},
</if> </if>
</set> </set>
where id = #{id,jdbcType=BIGINT} where id = #{id,jdbcType=BIGINT}
</update> </update>
<update id="updateByPrimaryKey" parameterType="com.viontech.fanxing.commons.model.ChannelTag" > <update id="updateByPrimaryKey" parameterType="com.viontech.fanxing.commons.model.ChannelTag" >
update `r_channel_tag` update `r_channel_tag`
set channel_id = #{channelId,jdbcType=BIGINT}, set channel_id = #{channelId,jdbcType=BIGINT},
tag_id = #{tagId,jdbcType=BIGINT} tag = #{tag,jdbcType=VARCHAR}
where id = #{id,jdbcType=BIGINT} where id = #{id,jdbcType=BIGINT}
</update> </update>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
...@@ -7,14 +7,17 @@ import com.viontech.fanxing.commons.base.BaseMapper; ...@@ -7,14 +7,17 @@ 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.config.VionConfig; import com.viontech.fanxing.commons.config.VionConfig;
import com.viontech.fanxing.commons.constant.ChannelType; import com.viontech.fanxing.commons.constant.ChannelType;
import com.viontech.fanxing.commons.exception.FanXingException;
import com.viontech.fanxing.commons.model.*; import com.viontech.fanxing.commons.model.*;
import com.viontech.fanxing.commons.vo.ChannelVo; import com.viontech.fanxing.commons.vo.ChannelVo;
import com.viontech.fanxing.commons.vo.DictCodeVo; import com.viontech.fanxing.commons.vo.DictCodeVo;
import com.viontech.fanxing.ops.feign.TaskFeignClient;
import com.viontech.fanxing.ops.mapper.ChannelMapper; import com.viontech.fanxing.ops.mapper.ChannelMapper;
import com.viontech.fanxing.ops.service.adapter.ChannelService; import com.viontech.fanxing.ops.service.adapter.ChannelService;
import com.viontech.fanxing.ops.service.adapter.ChannelTagService; import com.viontech.fanxing.ops.service.adapter.ChannelTagService;
import com.viontech.fanxing.ops.service.adapter.DictCateService; import com.viontech.fanxing.ops.service.adapter.DictCateService;
import com.viontech.fanxing.ops.service.adapter.DictCodeService; import com.viontech.fanxing.ops.service.adapter.DictCodeService;
import com.viontech.keliu.util.JsonMessageUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.ImmutablePair;
...@@ -22,6 +25,7 @@ import org.springframework.stereotype.Service; ...@@ -22,6 +25,7 @@ import org.springframework.stereotype.Service;
import org.springframework.web.reactive.function.client.WebClient; import org.springframework.web.reactive.function.client.WebClient;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.File;
import java.time.Duration; import java.time.Duration;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -39,8 +43,11 @@ public class ChannelServiceImpl extends BaseServiceImpl<Channel> implements Chan ...@@ -39,8 +43,11 @@ public class ChannelServiceImpl extends BaseServiceImpl<Channel> implements Chan
private ChannelTagService channelTagService; private ChannelTagService channelTagService;
@Resource @Resource
private VionConfig vionConfig; private VionConfig vionConfig;
@Resource
private TaskFeignClient taskFeignClient;
@Override @Override
public BaseMapper<Channel> getMapper() { public BaseMapper<Channel> getMapper() {
return channelMapper; return channelMapper;
} }
...@@ -49,7 +56,7 @@ public class ChannelServiceImpl extends BaseServiceImpl<Channel> implements Chan ...@@ -49,7 +56,7 @@ public class ChannelServiceImpl extends BaseServiceImpl<Channel> implements Chan
public List<Channel> selectByExample(BaseExample example) { public List<Channel> selectByExample(BaseExample example) {
List<Channel> channels = getMapper().selectByExample(example); List<Channel> channels = getMapper().selectByExample(example);
for (Channel channel : channels) { for (Channel channel : channels) {
if (ChannelType.FILE.value == channel.getType()) { if (channel.getType() != null && ChannelType.FILE.value == channel.getType()) {
channel.setStreamPath(vionConfig.getImage().getUrlPrefix() + channel.getStreamPath()); channel.setStreamPath(vionConfig.getImage().getUrlPrefix() + channel.getStreamPath());
} }
} }
...@@ -65,6 +72,22 @@ public class ChannelServiceImpl extends BaseServiceImpl<Channel> implements Chan ...@@ -65,6 +72,22 @@ public class ChannelServiceImpl extends BaseServiceImpl<Channel> implements Chan
return channel; return channel;
} }
@Override
public int deleteByPrimaryKey(Object id) {
Channel channel = super.selectByPrimaryKey(id);
JsonMessageUtil.JsonMessage<List<Task>> res = taskFeignClient.getTaskByChannelUnid(channel.getChannelUnid());
if (res.getData().size() > 0) {
throw new FanXingException("设备或文件使用中");
}
if (channel.getType().equals(ChannelType.FILE.value)) {
File file = new File(vionConfig.getImage().getPath() + channel.getStreamPath());
file.delete();
file.deleteOnExit();
}
return super.deleteByPrimaryKey(id);
}
/** /**
* 以树状结构获取所有的组织关系和视频资源 * 以树状结构获取所有的组织关系和视频资源
*/ */
......
...@@ -21,9 +21,10 @@ import org.springframework.web.multipart.MultipartFile; ...@@ -21,9 +21,10 @@ import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.IntSummaryStatistics; import java.util.DoubleSummaryStatistics;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -47,7 +48,7 @@ public class VideoService { ...@@ -47,7 +48,7 @@ public class VideoService {
* 上传存储视频文件 * 上传存储视频文件
*/ */
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void uploadVideo(List<MultipartFile> files, List<Long> tags) { public void uploadVideo(List<MultipartFile> files, List<String> tags) {
for (MultipartFile file : files) { for (MultipartFile file : files) {
String originalFilename = file.getOriginalFilename(); String originalFilename = file.getOriginalFilename();
String basePath = vionConfig.getImage().getPath() + File.separator + "uploadVideo" + File.separator; String basePath = vionConfig.getImage().getPath() + File.separator + "uploadVideo" + File.separator;
...@@ -57,16 +58,8 @@ public class VideoService { ...@@ -57,16 +58,8 @@ public class VideoService {
} }
String unid = UUID.randomUUID().toString(); String unid = UUID.randomUUID().toString();
String filename = unid + "." + extension; String filename = unid + "." + extension;
File video = new File(basePath + filename);
video.getParentFile().mkdirs();
try {
FileUtils.copyToFile(file.getInputStream(), video);
} catch (IOException e) {
throw new RuntimeException(e);
}
long videoLength = video.length(); // 先写库
long mbSize = videoLength / 1024 / 1024;
Channel channel = new Channel(); Channel channel = new Channel();
channel.setUnid(unid); channel.setUnid(unid);
channel.setChannelUnid(unid); channel.setChannelUnid(unid);
...@@ -75,14 +68,28 @@ public class VideoService { ...@@ -75,14 +68,28 @@ public class VideoService {
channel.setStreamPath("/uploadVideo/" + filename); channel.setStreamPath("/uploadVideo/" + filename);
channel.setType(ChannelType.FILE.value); channel.setType(ChannelType.FILE.value);
channel.setStreamType(ChannelType.STREAM_FILE.value); channel.setStreamType(ChannelType.STREAM_FILE.value);
channel.setPort(Math.toIntExact(mbSize));
channel = channelService.insertSelective(channel); channel = channelService.insertSelective(channel);
// 再上文件
File video = new File(basePath + filename);
video.getParentFile().mkdirs();
try {
FileUtils.copyToFile(file.getInputStream(), video);
} catch (IOException e) {
throw new RuntimeException(e);
}
double videoLength = (double) video.length();
double mbSize = videoLength / 1024 / 1024;
// 再更新
channel.setExpand(String.valueOf(mbSize));
channelService.updateByPrimaryKeySelective(channel);
if (tags != null && tags.size() > 0) { if (tags != null && tags.size() > 0) {
for (Long tagId : tags) { for (String tagId : tags) {
ChannelTag channelTag = new ChannelTag(); ChannelTag channelTag = new ChannelTag();
channelTag.setChannelId(channel.getId()); channelTag.setChannelId(channel.getId());
channelTag.setTagId(tagId); channelTag.setTag(tagId);
channelTagService.insertSelective(channelTag); channelTagService.insertSelective(channelTag);
} }
} }
...@@ -91,19 +98,20 @@ public class VideoService { ...@@ -91,19 +98,20 @@ public class VideoService {
/** /**
* 获取录像文件头部概览 * 获取录像文件头部概览
*
* @return
*/ */
@LocalCache(value = "video_overView", duration = 5) @LocalCache(value = "video_overView", duration = 20, timeunit = TimeUnit.SECONDS)
public JSONObject overview() { public JSONObject overview() {
ChannelExample channelExample = new ChannelExample(); ChannelExample channelExample = new ChannelExample();
channelExample.createCriteria().andTypeEqualTo(ChannelType.FILE.value); channelExample.createCriteria().andTypeEqualTo(ChannelType.FILE.value);
channelExample.createColumns().hasPortColumn(); channelExample.createColumns().hasExpandColumn();
List<Channel> channels = channelService.selectByExample(channelExample); List<Channel> channels = channelService.selectByExample(channelExample);
IntSummaryStatistics summary = channels.stream().map(Channel::getPort).collect(Collectors.summarizingInt(x -> x)); DoubleSummaryStatistics summary = channels.stream()
.map(x -> Double.valueOf(StringUtils.isBlank(x.getExpand()) ? "0" : x.getExpand()))
.collect(Collectors.summarizingDouble(x -> x));
JSONObject res = new JSONObject(); JSONObject res = new JSONObject();
res.put("fileCount", summary.getCount()); res.put("fileCount", summary.getCount());
res.put("size", summary.getSum()); res.put("size", summary.getSum());
res.put("unit", "MB");
return res; return res;
} }
} }
...@@ -3,9 +3,12 @@ package com.viontech.fanxing.ops; ...@@ -3,9 +3,12 @@ package com.viontech.fanxing.ops;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.viontech.fanxing.commons.model.DictCode; import com.viontech.fanxing.commons.model.DictCode;
import com.viontech.fanxing.commons.model.Task;
import com.viontech.fanxing.commons.vo.ChannelVo; import com.viontech.fanxing.commons.vo.ChannelVo;
import com.viontech.fanxing.ops.feign.TaskFeignClient;
import com.viontech.fanxing.ops.service.adapter.ChannelService; import com.viontech.fanxing.ops.service.adapter.ChannelService;
import com.viontech.fanxing.ops.service.adapter.DictCodeService; import com.viontech.fanxing.ops.service.adapter.DictCodeService;
import com.viontech.keliu.util.JsonMessageUtil;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
...@@ -29,6 +32,8 @@ public class MainTest { ...@@ -29,6 +32,8 @@ public class MainTest {
@Resource @Resource
private ChannelService channelService; private ChannelService channelService;
@Resource
private TaskFeignClient taskFeignClient;
@Test @Test
public void nvs3000CodeTest() { public void nvs3000CodeTest() {
...@@ -42,4 +47,11 @@ public class MainTest { ...@@ -42,4 +47,11 @@ public class MainTest {
} }
@Test
public void getTaskByChannelTest() {
JsonMessageUtil.JsonMessage<List<Task>> taskByChannelUnid =
taskFeignClient.getTaskByChannelUnid("5e19f4e3-ee71-44d9-82ad-99391b1031b5");
System.out.println(taskByChannelUnid.toString());
}
} }
...@@ -115,6 +115,11 @@ public class VAServerController { ...@@ -115,6 +115,11 @@ public class VAServerController {
return vaServerService.getRotationStatus(taskUnid); return vaServerService.getRotationStatus(taskUnid);
} }
@GetMapping("/getCurrentScene")
public Object getCurrentScene(@RequestParam String taskUnid) {
return vaServerService.getCurrentScene(taskUnid);
}
/** /**
* @param type 任务的类型 0 交通, 1 客流, 2 安防, 3 违停, 4 人脸 * @param type 任务的类型 0 交通, 1 客流, 2 安防, 3 违停, 4 人脸
*/ */
......
package com.viontech.fanxing.task.controller.web; package com.viontech.fanxing.task.controller.web;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
import com.viontech.fanxing.commons.base.BaseExample; import com.viontech.fanxing.commons.base.BaseExample;
import com.viontech.fanxing.commons.base.BaseModel; import com.viontech.fanxing.commons.base.BaseModel;
import com.viontech.fanxing.commons.model.Task; import com.viontech.fanxing.commons.model.Task;
...@@ -15,6 +16,8 @@ import java.util.List; ...@@ -15,6 +16,8 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.viontech.keliu.util.JsonMessageUtil.getSuccessJsonMsg;
@RestController @RestController
@RequestMapping("/tasks") @RequestMapping("/tasks")
@Slf4j @Slf4j
...@@ -27,6 +30,24 @@ public class TaskController extends TaskBaseController { ...@@ -27,6 +30,24 @@ public class TaskController extends TaskBaseController {
return taskExample; return taskExample;
} }
@Override
@RequestMapping(value = "", method = RequestMethod.GET)
@ResponseBody
public Object page(TaskVo taskVo, @RequestParam(value = "page", defaultValue = "-1") int page, @RequestParam(value = "pageSize", defaultValue = "100") int pageSize, String sortName, String sortOrder) {
BaseExample baseExample = getExample(taskVo, EXAMPLE_TYPE_PAGE);
if (isNotNull(sortOrder) && isNotNull(sortName)) {
baseExample.setOrderByClause(baseExample.getTableAlias() + "." + sortName + " " + sortOrder);
} else if (isNotNull(sortName) && !isNotNull(sortOrder)) {
baseExample.setOrderByClause(sortName);
}
if (page <= 0) {
List result = taskService.selectByExample(baseExample);
return getSuccessJsonMsg(MESSAGE_SELECT_SUCCESS, result);
} else {
PageInfo pageInfo = getService().pagedQuery(baseExample, page, pageSize);
return getSuccessJsonMsg(MESSAGE_PAGE_SUCCESS, pageInfo);
}
}
@PostMapping @PostMapping
@Override @Override
......
...@@ -17,14 +17,14 @@ import java.util.UUID; ...@@ -17,14 +17,14 @@ import java.util.UUID;
@Setter @Setter
@Accessors(chain = true) @Accessors(chain = true)
public class Scene { public class Scene {
private String algo_type; private Integer algo_type;
/** 标定,后端不需要关心 */ /** 标定,后端不需要关心 */
private Calibration calibration; private Calibration calibration;
/** 配置信息 */ /** 配置信息 */
private Config config; private Config config;
private String position_name; private String position_name;
private String position_num; private String position_num;
private String scene_unid = UUID.randomUUID().toString(); private String scene_unid;
private String vchan_refid; private String vchan_refid;
private Integer runtime = -1; private Integer runtime = -1;
private PlayUrls play_urls; private PlayUrls play_urls;
......
...@@ -24,7 +24,7 @@ public class VATask { ...@@ -24,7 +24,7 @@ public class VATask {
private String task_unid; private String task_unid;
private String task_name; private String task_name;
private String alg_type; private Integer alg_type;
private String store_config; private String store_config;
private String channel_unid; private String channel_unid;
private String stream_path; private String stream_path;
...@@ -35,7 +35,7 @@ public class VATask { ...@@ -35,7 +35,7 @@ public class VATask {
Task task = taskData.getTask(); Task task = taskData.getTask();
this.task_unid = task.getUnid(); this.task_unid = task.getUnid();
this.task_name = task.getName(); this.task_name = task.getName();
this.alg_type = task.getAlgType(); this.alg_type = Integer.parseInt(task.getAlgType());
this.store_config = taskData.getStoreConfig(); this.store_config = taskData.getStoreConfig();
this.channel_unid = task.getChannelUnid(); this.channel_unid = task.getChannelUnid();
this.stream_path = task.getStreamPath(); this.stream_path = task.getStreamPath();
......
package com.viontech.fanxing.task.repository; package com.viontech.fanxing.task.repository;
import com.viontech.fanxing.commons.constant.RedisKeys; import com.viontech.fanxing.commons.constant.RedisKeys;
import com.viontech.fanxing.task.model.vaserver.VaServerInfo;
import com.viontech.fanxing.commons.service.RedisService; import com.viontech.fanxing.commons.service.RedisService;
import com.viontech.fanxing.task.model.vaserver.VaServerInfo;
import org.redisson.api.RBucket; import org.redisson.api.RBucket;
import org.redisson.api.RLock;
import org.redisson.api.RMap; import org.redisson.api.RMap;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
...@@ -62,5 +63,9 @@ public class VAServerRedisRepository { ...@@ -62,5 +63,9 @@ public class VAServerRedisRepository {
return bucket.isExists(); return bucket.isExists();
} }
public RLock getDevLock(String devId) {
return redisService.getLockMust("lock:vaserver:" + devId);
}
} }
package com.viontech.fanxing.task.runner; package com.viontech.fanxing.task.runner;
import com.viontech.fanxing.commons.constant.TaskStatus;
import com.viontech.fanxing.commons.model.Task; import com.viontech.fanxing.commons.model.Task;
import com.viontech.fanxing.commons.model.TaskExample; import com.viontech.fanxing.commons.model.TaskExample;
import com.viontech.fanxing.task.mapper.TaskMapper; import com.viontech.fanxing.task.mapper.TaskMapper;
...@@ -38,7 +39,7 @@ public class TaskInitRunner implements CommandLineRunner { ...@@ -38,7 +39,7 @@ public class TaskInitRunner implements CommandLineRunner {
List<Task> tasks = taskMapper.selectByExampleWithBLOBs(new TaskExample()); List<Task> tasks = taskMapper.selectByExampleWithBLOBs(new TaskExample());
for (Task task : tasks) { for (Task task : tasks) {
if (StringUtils.isNotBlank(task.getScene()) && task.getStoreConfigId() != null) { if (StringUtils.isNotBlank(task.getScene()) && task.getStoreConfigId() != null && !TaskStatus.PAUSE.valEqual(task.getStatus())) {
try { try {
TaskData taskData = taskDataService.getRepository().getTaskDataByUnid(task.getUnid()); TaskData taskData = taskDataService.getRepository().getTaskDataByUnid(task.getUnid());
if (taskData == null) { if (taskData == null) {
......
...@@ -10,6 +10,7 @@ import com.viontech.fanxing.task.service.TaskDataService; ...@@ -10,6 +10,7 @@ import com.viontech.fanxing.task.service.TaskDataService;
import com.viontech.fanxing.task.service.VAServerService; import com.viontech.fanxing.task.service.VAServerService;
import com.viontech.fanxing.task.service.adapter.TaskService; import com.viontech.fanxing.task.service.adapter.TaskService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.redisson.api.RLock; import org.redisson.api.RLock;
import org.redisson.api.RMap; import org.redisson.api.RMap;
import org.redisson.api.RScoredSortedSet; import org.redisson.api.RScoredSortedSet;
...@@ -71,8 +72,14 @@ public class TaskRunner { ...@@ -71,8 +72,14 @@ public class TaskRunner {
if (temp.getStatus() == 0) { if (temp.getStatus() == 0) {
continue; continue;
} }
// 指定了VAServer
if (StringUtils.isNotBlank(taskVaType)) {
if (!taskVaType.equals(temp.getServiceName())) {
continue;
}
}
if (temp.getAvailableResources() > resourceNeed) { if (temp.getAvailableResources() > resourceNeed) {
devLock = redisService.getLockMust("lock:vaserver:" + devId); devLock = vaServerService.getVaServerRedisRepository().getDevLock(devId);
temp = vaServerMap.get(devId); temp = vaServerMap.get(devId);
if (temp.getAvailableResources() > resourceNeed) { if (temp.getAvailableResources() > resourceNeed) {
server = temp; server = temp;
......
package com.viontech.fanxing.task.runner;
import com.alibaba.fastjson.JSONObject;
import com.viontech.fanxing.task.model.vaserver.VaServerInfo;
import com.viontech.fanxing.task.service.VAServerService;
import lombok.extern.slf4j.Slf4j;
import org.redisson.api.RLock;
import org.redisson.api.RMap;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.Map;
import java.util.Set;
/**
* .
*
* @author 谢明辉
* @date 2021/10/19
*/
@Component
@Slf4j
public class VaServerCheckRunner {
@Resource
private VAServerService vaServerService;
@Scheduled(cron = "3 0/5 * * * ? ")
public void check() {
try {
RMap<String, VaServerInfo> vaServerInfoMap = vaServerService.getVaServerRedisRepository().getVaServerInfoMap();
Set<Map.Entry<String, VaServerInfo>> entries = vaServerInfoMap.readAllEntrySet();
for (Map.Entry<String, VaServerInfo> entry : entries) {
RLock devLock = null;
try {
String devId = entry.getKey();
VaServerInfo vaServerInfo = entry.getValue();
if (vaServerInfo.getStatus() == 1) {
devLock = vaServerService.getVaServerRedisRepository().getDevLock(devId);
JSONObject status = vaServerService.getStatus(devId);
JSONObject resource = status.getJSONObject("resource");
JSONObject brief = resource.getJSONObject("brief");
float videoResource = brief.getFloatValue("video_total");
float availableResource = brief.getFloatValue("video_free");
vaServerInfo.setAvailableResources(availableResource);
vaServerInfo.setVideoResource(videoResource);
vaServerService.getVaServerRedisRepository().addOrUpdate(devId, vaServerInfo);
} else {
log.info("设备处于离线状态:{}", devId);
}
} catch (Exception e) {
log.info("", e);
if (devLock != null) {
devLock.forceUnlock();
}
}
}
} catch (Exception e) {
log.error("", e);
}
}
}
...@@ -119,12 +119,14 @@ public class TaskDataService { ...@@ -119,12 +119,14 @@ public class TaskDataService {
public void updateTask(Task task) { public void updateTask(Task task) {
String taskUnid = task.getUnid(); String taskUnid = task.getUnid();
VaServerInfo vaServerInfo = taskRunOn(taskUnid); VaServerInfo vaServerInfo = taskRunOn(taskUnid);
// vaServerId 为空说明任务未执行可以先删除再建立新任务 // vaServerId 为空说明任务未执行可以先删除再建立新任务
if (vaServerInfo == null) { if (vaServerInfo == null) {
deleteTask(taskUnid); deleteTask(taskUnid);
addTask(task); addTask(task);
} else if (vaServerInfo.getStatus() == 0) {
throw new FanXingException("设备离线");
} else { } else {
TaskData taskData = new TaskData(task); TaskData taskData = new TaskData(task);
// 需要更新taskData,并且向vaServer更新任务信息 // 需要更新taskData,并且向vaServer更新任务信息
taskDataRedisRepository.addOrUpdateTaskData(taskData); taskDataRedisRepository.addOrUpdateTaskData(taskData);
......
...@@ -28,7 +28,7 @@ public class VAServerHttpService { ...@@ -28,7 +28,7 @@ public class VAServerHttpService {
/** /**
* 下发任务 * 下发任务
*/ */
public Object addTask(TaskData taskData, VaServerInfo vaServerInfo) { public JSONObject addTask(TaskData taskData, VaServerInfo vaServerInfo) {
VATask vaTask = new VATask(taskData); VATask vaTask = new VATask(taskData);
String path = "/api/vaserver/v1/task"; String path = "/api/vaserver/v1/task";
Mono<String> stringMono = WebClient.create(vaServerInfo.getServiceBaseUrl()) Mono<String> stringMono = WebClient.create(vaServerInfo.getServiceBaseUrl())
...@@ -45,7 +45,7 @@ public class VAServerHttpService { ...@@ -45,7 +45,7 @@ public class VAServerHttpService {
/** /**
* 编辑任务 * 编辑任务
*/ */
public Object 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);
...@@ -63,7 +63,7 @@ public class VAServerHttpService { ...@@ -63,7 +63,7 @@ public class VAServerHttpService {
/** /**
* 删除任务 * 删除任务
*/ */
public Object rmTask(String taskUnid, VaServerInfo vaServerInfo) { public JSONObject rmTask(String taskUnid, VaServerInfo vaServerInfo) {
String path = "/api/vaserver/v1/deleteTask"; String path = "/api/vaserver/v1/deleteTask";
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
...@@ -83,7 +83,7 @@ public class VAServerHttpService { ...@@ -83,7 +83,7 @@ public class VAServerHttpService {
/** /**
* 截图 * 截图
*/ */
public Object snapshot(String taskUnid, VaServerInfo vaServerInfo) { public JSONObject snapshot(String taskUnid, VaServerInfo vaServerInfo) {
String path = "/api/vaserver/v1/snapshot"; String path = "/api/vaserver/v1/snapshot";
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
...@@ -103,7 +103,7 @@ public class VAServerHttpService { ...@@ -103,7 +103,7 @@ public class VAServerHttpService {
/** /**
* 获取点播地址 * 获取点播地址
*/ */
public Object getAnalyzeStream(String taskUnid, VaServerInfo vaServerInfo) { public JSONObject getAnalyzeStream(String taskUnid, VaServerInfo vaServerInfo) {
String path = "/api/vaserver/v1/get_analyze_stream"; String path = "/api/vaserver/v1/get_analyze_stream";
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
...@@ -124,7 +124,7 @@ public class VAServerHttpService { ...@@ -124,7 +124,7 @@ public class VAServerHttpService {
/** /**
* 开始输出分析流 * 开始输出分析流
*/ */
public Object startAnalyzeStream(String taskUnid, VaServerInfo vaServerInfo, String url) { public JSONObject startAnalyzeStream(String taskUnid, VaServerInfo vaServerInfo, String url) {
String path = "/api/vaserver/v1/start_analyze_stream"; String path = "/api/vaserver/v1/start_analyze_stream";
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
...@@ -147,7 +147,7 @@ public class VAServerHttpService { ...@@ -147,7 +147,7 @@ public class VAServerHttpService {
/** /**
* 切换预置位 * 切换预置位
*/ */
public Object switchScene(String taskUnid, VaServerInfo vaServerInfo, String sceneId) { public JSONObject switchScene(String taskUnid, VaServerInfo vaServerInfo, String sceneId) {
String path = "/api/vaserver/v1/switch_scene"; String path = "/api/vaserver/v1/switch_scene";
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
...@@ -169,7 +169,7 @@ public class VAServerHttpService { ...@@ -169,7 +169,7 @@ public class VAServerHttpService {
/** /**
* 任务轮训状态切换 * 任务轮训状态切换
*/ */
public Object updateRotationStatus(String taskUnid, Integer rotationStatus, VaServerInfo vaServerInfo) { public JSONObject updateRotationStatus(String taskUnid, Integer rotationStatus, VaServerInfo vaServerInfo) {
String path = "/api/vaserver/v1/alternate"; String path = "/api/vaserver/v1/alternate";
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
...@@ -191,7 +191,7 @@ public class VAServerHttpService { ...@@ -191,7 +191,7 @@ public class VAServerHttpService {
/** /**
* 任务轮训状态查询 * 任务轮训状态查询
*/ */
public Object getRotationStatus(String taskUnid, VaServerInfo vaServerInfo) { public JSONObject getRotationStatus(String taskUnid, VaServerInfo vaServerInfo) {
String path = "/api/vaserver/v1/getAlternate"; String path = "/api/vaserver/v1/getAlternate";
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
...@@ -212,7 +212,7 @@ public class VAServerHttpService { ...@@ -212,7 +212,7 @@ public class VAServerHttpService {
/** /**
* 运行状态查询 * 运行状态查询
*/ */
public Object status(VaServerInfo vaServerInfo) { public JSONObject status(VaServerInfo vaServerInfo) {
String path = "/api/vaserver/v1/status"; String path = "/api/vaserver/v1/status";
Mono<String> stringMono = WebClient.create(vaServerInfo.getServiceBaseUrl()) Mono<String> stringMono = WebClient.create(vaServerInfo.getServiceBaseUrl())
...@@ -231,7 +231,7 @@ public class VAServerHttpService { ...@@ -231,7 +231,7 @@ public class VAServerHttpService {
/** /**
* 获取默认算法配置 * 获取默认算法配置
*/ */
public Object getDefaultAlgorithmConfig(VaServerInfo vaServerInfo, String taskAlgType) { public JSONObject getDefaultAlgorithmConfig(VaServerInfo vaServerInfo, String taskAlgType) {
String path = "/api/vaserver/v1/get_algo_param_template"; String path = "/api/vaserver/v1/get_algo_param_template";
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("task_algo_type", taskAlgType); jsonObject.put("task_algo_type", taskAlgType);
...@@ -249,4 +249,24 @@ public class VAServerHttpService { ...@@ -249,4 +249,24 @@ public class VAServerHttpService {
} }
/**
* 获取任务当前预置位
*/
public JSONObject getCurrentScene(String taskUnid, VaServerInfo vaServerInfo) {
String path = "/api/vaserver/v1/get_current_scene";
JSONObject obj = new JSONObject();
obj.put("task_unid", taskUnid);
Mono<String> mono = WebClient.create(vaServerInfo.getServiceBaseUrl())
.post()
.uri(path)
.header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE)
.bodyValue(obj)
.retrieve()
.bodyToMono(String.class);
String block = mono.block(Duration.ofSeconds(20));
log.info("获取当前预置位:{}", block);
return JSON.parseObject(block);
}
} }
package com.viontech.fanxing.task.service; package com.viontech.fanxing.task.service;
import com.alibaba.fastjson.JSONObject;
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;
import com.viontech.fanxing.commons.model.Task; 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.repository.VAServerRedisRepository;
import com.viontech.fanxing.task.model.vaserver.VaServerInfo; import com.viontech.fanxing.task.model.vaserver.VaServerInfo;
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;
import org.redisson.api.RMap; import org.redisson.api.RMap;
...@@ -40,23 +41,25 @@ public class VAServerService { ...@@ -40,23 +41,25 @@ public class VAServerService {
*/ */
public void registerVAServer(VaServerInfo vaServerInfo) { public void registerVAServer(VaServerInfo vaServerInfo) {
String devId = vaServerInfo.getDevID(); String devId = vaServerInfo.getDevID();
keepalive(devId);
vaServerRedisRepository.addOrUpdate(devId, vaServerInfo); vaServerRedisRepository.addOrUpdate(devId, vaServerInfo);
keepalive(devId);
} }
/** /**
* 设备心跳 * 设备心跳
*/ */
public void keepalive(String devId) { public void keepalive(String devId) {
RBucket<Date> bucket = redisService.getValue(RedisKeys.getVAServerKeepAliveKey(devId));
bucket.set(new Date());
bucket.expire(2, TimeUnit.MINUTES);
VaServerInfo vaserverInfo = vaServerRedisRepository.getVAServerInfoById(devId); VaServerInfo vaserverInfo = vaServerRedisRepository.getVAServerInfoById(devId);
if (vaserverInfo != null) { if (vaserverInfo != null) {
vaserverInfo.setStatus(1); vaserverInfo.setStatus(1);
vaServerRedisRepository.addOrUpdate(devId, vaserverInfo); vaServerRedisRepository.addOrUpdate(devId, vaserverInfo);
} else {
throw new FanXingException("设备未注册");
} }
RBucket<Date> bucket = redisService.getValue(RedisKeys.getVAServerKeepAliveKey(devId));
bucket.set(new Date());
bucket.expire(2, TimeUnit.MINUTES);
} }
...@@ -86,7 +89,7 @@ public class VAServerService { ...@@ -86,7 +89,7 @@ public class VAServerService {
public boolean terminateTask(String taskUnid) { public boolean terminateTask(String taskUnid) {
TaskData taskData = taskDataService.getRepository().getTaskDataByUnid(taskUnid); TaskData taskData = taskDataService.getRepository().getTaskDataByUnid(taskUnid);
if (taskData == null) { if (taskData == null) {
return false; return true;
} }
Task task = taskData.getTask(); Task task = taskData.getTask();
...@@ -180,7 +183,7 @@ public class VAServerService { ...@@ -180,7 +183,7 @@ public class VAServerService {
/** /**
* 获取 VAServer 运行状态配置参数等 * 获取 VAServer 运行状态配置参数等
*/ */
public Object getStatus(String devId) { public JSONObject getStatus(String devId) {
VaServerInfo vaServerInfo = vaServerRedisRepository.getVAServerInfoById(devId); VaServerInfo vaServerInfo = vaServerRedisRepository.getVAServerInfoById(devId);
if (vaServerInfo != null) { if (vaServerInfo != null) {
return vaServerHttpService.status(vaServerInfo); return vaServerHttpService.status(vaServerInfo);
...@@ -225,6 +228,15 @@ public class VAServerService { ...@@ -225,6 +228,15 @@ public class VAServerService {
} }
} }
public JSONObject getCurrentScene(String taskUnid) {
VaServerInfo vaServerInfo = taskDataService.taskRunOn(taskUnid);
if (vaServerInfo != null) {
return vaServerHttpService.getCurrentScene(taskUnid, vaServerInfo);
} else {
throw new FanXingException("任务不在运行状态", taskUnid);
}
}
public Object getDefaultAlgorithmConfig(String taskAlgType) { public Object getDefaultAlgorithmConfig(String taskAlgType) {
RMap<String, VaServerInfo> map = vaServerRedisRepository.getVaServerInfoMap(); RMap<String, VaServerInfo> map = vaServerRedisRepository.getVaServerInfoMap();
VaServerInfo temp = null; VaServerInfo temp = null;
......
...@@ -2,6 +2,10 @@ package com.viontech.fanxing.task.service.impl; ...@@ -2,6 +2,10 @@ package com.viontech.fanxing.task.service.impl;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
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.commons.base.LocalCache; import com.viontech.fanxing.commons.base.LocalCache;
...@@ -27,6 +31,8 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -27,6 +31,8 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
@Service @Service
public class TaskServiceImpl extends BaseServiceImpl<Task> implements TaskService { public class TaskServiceImpl extends BaseServiceImpl<Task> implements TaskService {
...@@ -46,6 +52,28 @@ public class TaskServiceImpl extends BaseServiceImpl<Task> implements TaskServic ...@@ -46,6 +52,28 @@ public class TaskServiceImpl extends BaseServiceImpl<Task> implements TaskServic
return taskMapper; return taskMapper;
} }
@Override
public List<Task> selectByExample(BaseExample example) {
return taskMapper.selectByExampleWithBLOBs((TaskExample) example);
}
@Override
public PageInfo<Task> pagedQuery(BaseExample example, int pageNum, int pageSize) {
if (pageSize > 0) {
PageHelper.startPage(pageNum, pageSize);
Page<Task> result = (Page<Task>) taskMapper.selectByExampleWithBLOBs((TaskExample) example);
PageInfo<Task> pageInfo = new PageInfo<Task>(result);
return pageInfo;
} else {
List<Task> result = taskMapper.selectByExampleWithBLOBs((TaskExample) example);
Page<Task> p = new Page<>();
p.addAll(result);
PageInfo<Task> pageInfo = new PageInfo<>(p);
return pageInfo;
}
}
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Override @Override
public TaskVo addTask(Task task) { public TaskVo addTask(Task task) {
...@@ -100,7 +128,8 @@ public class TaskServiceImpl extends BaseServiceImpl<Task> implements TaskServic ...@@ -100,7 +128,8 @@ public class TaskServiceImpl extends BaseServiceImpl<Task> implements TaskServic
.setPosition_num(String.valueOf(i)) .setPosition_num(String.valueOf(i))
.setPosition_name(String.valueOf(i)) .setPosition_name(String.valueOf(i))
.setVchan_refid(channelUnid) .setVchan_refid(channelUnid)
.setAlgo_type(algType) .setScene_unid(UUID.randomUUID().toString())
.setAlgo_type(Integer.parseInt(algType))
.setConfig(config) .setConfig(config)
.setPlay_urls(playUrls); .setPlay_urls(playUrls);
if (streamPath.contains("http")) { if (streamPath.contains("http")) {
...@@ -181,7 +210,7 @@ public class TaskServiceImpl extends BaseServiceImpl<Task> implements TaskServic ...@@ -181,7 +210,7 @@ public class TaskServiceImpl extends BaseServiceImpl<Task> implements TaskServic
} }
@Override @Override
@LocalCache(value = "task_overview", duration = 3) @LocalCache(value = "task_overview", duration = 30, timeunit = TimeUnit.SECONDS)
public JSONObject overview() { public JSONObject overview() {
List<Task> tasks = selectByExample(new TaskExample()); List<Task> tasks = selectByExample(new TaskExample());
int resourceCount = 0; int resourceCount = 0;
......
-- s_task 任务信息表 -- s_task 任务信息表
CREATE TABLE IF NOT EXISTS s_task( CREATE TABLE IF NOT EXISTS s_task
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT, (
unid VARCHAR(36) NOT NULL DEFAULT (UUID()), id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(128) NOT NULL COMMENT '任务名称', unid VARCHAR(36) NOT NULL DEFAULT (UUID()),
alg_type VARCHAR(36) NOT NULL COMMENT '算法类型', name VARCHAR(128) NOT NULL COMMENT '任务名称',
alg_enabled VARCHAR(32) COMMENT '已启用的算法类型', alg_type VARCHAR(36) NOT NULL COMMENT '算法类型',
resource_need FLOAT NOT NULL COMMENT '任务所需资源数量', alg_enabled VARCHAR(128) COMMENT '已启用的算法类型',
priority INT NOT NULL DEFAULT 0 COMMENT '任务优先级', resource_need FLOAT NOT NULL COMMENT '任务所需资源数量',
store_config_id BIGINT NOT NULL COMMENT '存储配置id', priority INT NOT NULL DEFAULT 0 COMMENT '任务优先级',
va_type VARCHAR(36) COMMENT '算法分析设备类型', store_config_id BIGINT NOT NULL COMMENT '存储配置id',
runtime_type INT NOT NULL DEFAULT 0 COMMENT '任务执行时间类型,全天分时段等', va_type VARCHAR(36) COMMENT '算法分析设备类型',
runtime_conf TEXT COMMENT '任务执行时间段的配置', runtime_type INT NOT NULL DEFAULT 0 COMMENT '任务执行时间类型,全天分时段等',
device_unid VARCHAR(36) COMMENT '相机设备unid', runtime_conf TEXT COMMENT '任务执行时间段的配置',
channel_unid VARCHAR(36) COMMENT '相机通道unid', device_unid VARCHAR(36) COMMENT '相机设备unid',
stream_path VARCHAR(1024) COMMENT '视频流地址', channel_unid VARCHAR(36) COMMENT '相机通道unid',
stream_type INT COMMENT '视频流类型', stream_path VARCHAR(1024) COMMENT '视频流地址',
scene TEXT COMMENT '场景配置,包含画线预置位等', stream_type INT COMMENT '视频流类型',
create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', scene TEXT COMMENT '场景配置,包含画线预置位等',
status INT NOT NULL DEFAULT 0 COMMENT '任务状态', create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
INDEX s_task_unid_idx(unid) status INT NOT NULL DEFAULT 0 COMMENT '任务状态',
INDEX s_task_unid_idx (unid)
); );
-- s_store_config 存储配置表 -- s_store_config 存储配置表
CREATE TABLE IF NOT EXISTS s_store_config( CREATE TABLE IF NOT EXISTS s_store_config
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT, (
unid VARCHAR(36) NOT NULL DEFAULT (UUID()), id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(256) NOT NULL COMMENT '存储配置名称', unid VARCHAR(36) NOT NULL DEFAULT (UUID()),
content_format INT NOT NULL COMMENT '配置内容格式,如xml', name VARCHAR(256) NOT NULL COMMENT '存储配置名称',
content TEXT NOT NULL COMMENT '配置内容', content_format INT NOT NULL COMMENT '配置内容格式,如xml',
create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', content TEXT NOT NULL COMMENT '配置内容',
status INT NOT NULL DEFAULT 0 COMMENT '状态', create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
INDEX s_store_config_unid_idx(unid) status INT NOT NULL DEFAULT 0 COMMENT '状态',
INDEX s_store_config_unid_idx (unid)
); );
-- s_forward 转发信息表 -- s_forward 转发信息表
CREATE TABLE IF NOT EXISTS s_forward( CREATE TABLE IF NOT EXISTS s_forward
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT, (
unid VARCHAR(36) NOT NULL DEFAULT (UUID()), id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(256) NOT NULL COMMENT '转发名称', unid VARCHAR(36) NOT NULL DEFAULT (UUID()),
url VARCHAR(1024) NOT NULL COMMENT '转发地址', name VARCHAR(256) NOT NULL COMMENT '转发名称',
total BIGINT NOT NULL DEFAULT 0 COMMENT '转发数据总量', url VARCHAR(1024) NOT NULL COMMENT '转发地址',
failed BIGINT NOT NULL DEFAULT 0 COMMENT '失败数量', total BIGINT NOT NULL DEFAULT 0 COMMENT '转发数据总量',
last_send_time TIMESTAMP COMMENT '最后发送时间', failed BIGINT NOT NULL DEFAULT 0 COMMENT '失败数量',
create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', last_send_time TIMESTAMP COMMENT '最后发送时间',
status INT NOT NULL DEFAULT 0 COMMENT '状态' create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
status INT NOT NULL DEFAULT 0 COMMENT '状态'
); );
-- s_forward_config 转发配置表 -- s_forward_config 转发配置表
CREATE TABLE IF NOT EXISTS s_forward_config( CREATE TABLE IF NOT EXISTS s_forward_config
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT, (
unid VARCHAR(36) NOT NULL DEFAULT (UUID()), id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
forward_id BIGINT NOT NULL COMMENT '转发信息id', unid VARCHAR(36) NOT NULL DEFAULT (UUID()),
event_cate VARCHAR(36) NOT NULL, forward_id BIGINT NOT NULL COMMENT '转发信息id',
event_type VARCHAR(36) NOT NULL, event_cate VARCHAR(36) NOT NULL,
INDEX s_forward_config_forward_id_idx(forward_id) event_type VARCHAR(36) NOT NULL,
INDEX s_forward_config_forward_id_idx (forward_id)
); );
-- d_traffic -- d_traffic
CREATE TABLE IF NOT EXISTS d_traffic( CREATE TABLE IF NOT EXISTS d_traffic
id BIGINT NOT NULL AUTO_INCREMENT, (
unid VARCHAR(36) NOT NULL DEFAULT (UUID()), id BIGINT NOT NULL AUTO_INCREMENT,
task_id BIGINT COMMENT '任务id', unid VARCHAR(36) NOT NULL DEFAULT (UUID()),
event_cate VARCHAR(36), task_id BIGINT COMMENT '任务id',
event_type VARCHAR(36), event_cate VARCHAR(36),
event_time TIMESTAMP NOT NULL COMMENT '事件时间', event_type VARCHAR(36),
channel_unid VARCHAR(36) COMMENT '通道unid', event_time TIMESTAMP NOT NULL COMMENT '事件时间',
plate_color VARCHAR(36) COMMENT '车牌颜色', channel_unid VARCHAR(36) COMMENT '通道unid',
plate_number VARCHAR(36) COMMENT '车牌号码', plate_color VARCHAR(36) COMMENT '车牌颜色',
location_code VARCHAR(36) COMMENT '位置编码', plate_number VARCHAR(36) COMMENT '车牌号码',
location_name VARCHAR(500) COMMENT '位置名称', location_code VARCHAR(36) COMMENT '位置编码',
lane_code VARCHAR(36) COMMENT '车道编码', location_name VARCHAR(500) COMMENT '位置名称',
direction_code VARCHAR(36) COMMENT '卡口方向', lane_code VARCHAR(36) COMMENT '车道编码',
vehicle_type VARCHAR(36) COMMENT '车辆类型', direction_code VARCHAR(36) COMMENT '卡口方向',
vehicle_color VARCHAR(36) COMMENT '车身颜色', vehicle_type VARCHAR(36) COMMENT '车辆类型',
vehicle_logo VARCHAR(36) COMMENT '车标编码', vehicle_color VARCHAR(36) COMMENT '车身颜色',
illegal_code VARCHAR(36) COMMENT '违法行为', vehicle_logo VARCHAR(36) COMMENT '车标编码',
illegal_state INT COMMENT '违法行为是否可用', illegal_code VARCHAR(36) COMMENT '违法行为',
feature_annual_inspection_mark SMALLINT DEFAULT 0 COMMENT '年检标', illegal_state INT COMMENT '违法行为是否可用',
feature_pendant SMALLINT DEFAULT 0 COMMENT '吊坠', feature_annual_inspection_mark SMALLINT DEFAULT 0 COMMENT '年检标',
feature_decoration SMALLINT DEFAULT 0 COMMENT '摆件', feature_pendant SMALLINT DEFAULT 0 COMMENT '吊坠',
feature_sun_shield SMALLINT DEFAULT 0 COMMENT '遮阳板', feature_decoration SMALLINT DEFAULT 0 COMMENT '摆件',
xcycle_type VARCHAR(36) COMMENT '非机动车类型', feature_sun_shield SMALLINT DEFAULT 0 COMMENT '遮阳板',
event_id VARCHAR(64) COMMENT '事件唯一id' , xcycle_type VARCHAR(36) COMMENT '非机动车类型',
special_type VARCHAR(36), event_id VARCHAR(64) COMMENT '事件唯一id',
with_helmet INT COMMENT '是否戴头盔0不带', special_type VARCHAR(36),
json_data TEXT COMMENT '原始数据', with_helmet INT COMMENT '是否戴头盔0不带',
pics VARCHAR(2048), json_data TEXT COMMENT '原始数据',
video_name VARCHAR(256), pics VARCHAR(2048),
status INT NOT NULL DEFAULT 0 COMMENT '状态', video_name VARCHAR(256),
PRIMARY KEY(id,event_time), status INT NOT NULL DEFAULT 0 COMMENT '状态',
INDEX d_traffic_unid_idx(unid), PRIMARY KEY (id, event_time),
INDEX d_traffic_select_idx(event_time,event_type,vehicle_type) INDEX d_traffic_unid_idx (unid),
INDEX d_traffic_select_idx (event_time, event_type, vehicle_type)
); );
-- d_traffic_face -- d_traffic_face
CREATE TABLE IF NOT EXISTS d_traffic_face( CREATE TABLE IF NOT EXISTS d_traffic_face
id BIGINT NOT NULL AUTO_INCREMENT, (
unid VARCHAR(36) NOT NULL DEFAULT (UUID()), id BIGINT NOT NULL AUTO_INCREMENT,
traffic_id BIGINT NOT NULL COMMENT 'trafficId', unid VARCHAR(36) NOT NULL DEFAULT (UUID()),
event_time TIMESTAMP NOT NULL COMMENT '事件时间', traffic_id BIGINT NOT NULL COMMENT 'trafficId',
state SMALLINT NOT NULL DEFAULT 1, event_time TIMESTAMP NOT NULL COMMENT '事件时间',
sex SMALLINT NOT NULL DEFAULT 0, state SMALLINT NOT NULL DEFAULT 1,
upper_color VARCHAR(36), sex SMALLINT NOT NULL DEFAULT 0,
lower_color VARCHAR(36), upper_color VARCHAR(36),
INDEX traffic_face_traffic_id_idx(traffic_id), lower_color VARCHAR(36),
PRIMARY KEY(id,event_time) INDEX traffic_face_traffic_id_idx (traffic_id),
PRIMARY KEY (id, event_time)
); );
-- d_flow_data -- d_flow_data
CREATE TABLE IF NOT EXISTS d_flow_data( CREATE TABLE IF NOT EXISTS d_flow_data
id BIGINT NOT NULL AUTO_INCREMENT, (
unid VARCHAR(36) NOT NULL DEFAULT (UUID()), id BIGINT NOT NULL AUTO_INCREMENT,
flow_event_id BIGINT COMMENT 'eventId', unid VARCHAR(36) NOT NULL DEFAULT (UUID()),
task_id BIGINT, flow_event_id BIGINT COMMENT 'eventId',
detection_type VARCHAR(36) COMMENT '检测类型(bus,big_vehicle,xcycle等)', task_id BIGINT,
road_code VARCHAR(36) COMMENT '道路编码', detection_type VARCHAR(36) COMMENT '检测类型(bus,big_vehicle,xcycle等)',
direction_code VARCHAR(36) COMMENT '方向编码', road_code VARCHAR(36) COMMENT '道路编码',
sample_dura BIGINT, direction_code VARCHAR(36) COMMENT '方向编码',
sample_num FLOAT, sample_dura BIGINT,
velocity FLOAT COMMENT '速率', sample_num FLOAT,
velocity_unit VARCHAR(16) COMMENT '速率单位', velocity FLOAT COMMENT '速率',
occupy FLOAT COMMENT '车道占有率', velocity_unit VARCHAR(16) COMMENT '速率单位',
distance FLOAT COMMENT '车头间距', occupy FLOAT COMMENT '车道占有率',
queue_length FLOAT COMMENT '车辆排队长度', distance FLOAT COMMENT '车头间距',
region_id VARCHAR(36), queue_length FLOAT COMMENT '车辆排队长度',
region_name VARCHAR(128), region_id VARCHAR(36),
position_content TEXT, region_name VARCHAR(128),
head_content TEXT, position_content TEXT,
area FLOAT, head_content TEXT,
density FLOAT, area FLOAT,
sample_num_in FLOAT, density FLOAT,
sample_num_out FLOAT, sample_num_in FLOAT,
event_time TIMESTAMP, sample_num_out FLOAT,
dist_time FLOAT, event_time TIMESTAMP,
time_occupy FLOAT, dist_time FLOAT,
status INT NOT NULL DEFAULT 0 COMMENT '状态', time_occupy FLOAT,
PRIMARY KEY(id,event_time), status INT NOT NULL DEFAULT 0 COMMENT '状态',
INDEX flow_data_select_idx(flow_event_id) PRIMARY KEY (id, event_time),
INDEX flow_data_select_idx (flow_event_id)
); );
-- d_flow_event -- d_flow_event
CREATE TABLE IF NOT EXISTS d_flow_event( CREATE TABLE IF NOT EXISTS d_flow_event
id BIGINT NOT NULL AUTO_INCREMENT, (
unid VARCHAR(36) NOT NULL DEFAULT (UUID()), id BIGINT NOT NULL AUTO_INCREMENT,
task_id BIGINT COMMENT '任务id', unid VARCHAR(36) NOT NULL DEFAULT (UUID()),
event_type VARCHAR(36), task_id BIGINT COMMENT '任务id',
event_time TIMESTAMP COMMENT '事件时间', event_type VARCHAR(36),
event_id VARCHAR(64) COMMENT '事件唯一id', event_time TIMESTAMP COMMENT '事件时间',
device_code VARCHAR(36), event_id VARCHAR(64) COMMENT '事件唯一id',
device_name VARCHAR(64), device_code VARCHAR(36),
location_code VARCHAR(36), device_name VARCHAR(64),
location_name VARCHAR(64), location_code VARCHAR(36),
json_data TEXT, location_name VARCHAR(64),
pics VARCHAR(2048), json_data TEXT,
video_name VARCHAR(256), pics VARCHAR(2048),
PRIMARY KEY(id,event_time), video_name VARCHAR(256),
INDEX flow_event_select_idx(event_time,event_type) PRIMARY KEY (id, event_time),
INDEX flow_event_select_idx (event_time, event_type)
); );
-- d_behavior -- d_behavior
CREATE TABLE IF NOT EXISTS d_behavior( CREATE TABLE IF NOT EXISTS d_behavior
id BIGINT NOT NULL AUTO_INCREMENT, (
unid VARCHAR(36) NOT NULL DEFAULT (UUID()), id BIGINT NOT NULL AUTO_INCREMENT,
task_id BIGINT, unid VARCHAR(36) NOT NULL DEFAULT (UUID()),
event_type VARCHAR(36), task_id BIGINT,
event_cate VARCHAR(36), event_type VARCHAR(36),
event_refid VARCHAR(64), event_cate VARCHAR(36),
event_time TIMESTAMP, event_refid VARCHAR(64),
event_data TEXT, event_time TIMESTAMP,
pics VARCHAR(2048), event_data TEXT,
video TEXT, pics VARCHAR(2048),
channel_unid VARCHAR(36), video TEXT,
task_name VARCHAR(128), channel_unid VARCHAR(36),
event_data_num VARCHAR(36), task_name VARCHAR(128),
PRIMARY KEY(id,event_time), event_data_num VARCHAR(36),
INDEX behavior_select_idx(event_time,event_type,event_cate) PRIMARY KEY (id, event_time),
INDEX behavior_select_idx (event_time, event_type, event_cate)
); );
-- s_dict_cate -- s_dict_cate
CREATE TABLE IF NOT EXISTS s_dict_cate( CREATE TABLE IF NOT EXISTS s_dict_cate
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT, (
unid VARCHAR(36) NOT NULL DEFAULT (UUID()), id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
type VARCHAR(36) COMMENT '分类', unid VARCHAR(36) NOT NULL DEFAULT (UUID()),
code VARCHAR(36) COMMENT 'cate编码', type VARCHAR(36) COMMENT '分类',
name VARCHAR(36) NOT NULL COMMENT 'cate名称', code VARCHAR(36) COMMENT 'cate编码',
note VARCHAR(36) COMMENT '注释', name VARCHAR(36) NOT NULL COMMENT 'cate名称',
INDEX s_dict_cate_type_idx(type) note VARCHAR(36) COMMENT '注释',
INDEX s_dict_cate_type_idx (type)
); );
-- s_dict_code -- s_dict_code
CREATE TABLE IF NOT EXISTS s_dict_code( CREATE TABLE IF NOT EXISTS s_dict_code
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT, (
unid VARCHAR(36) NOT NULL DEFAULT (UUID()), id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
cate_id BIGINT NOT NULL, unid VARCHAR(36) NOT NULL DEFAULT (UUID()),
parent_id BIGINT COMMENT '上级code的id', cate_id BIGINT NOT NULL,
code VARCHAR(36) COMMENT 'code编码', parent_id BIGINT COMMENT '上级code的id',
name VARCHAR(36) NOT NULL COMMENT 'code名称', code VARCHAR(36) COMMENT 'code编码',
note VARCHAR(36) COMMENT '注释', name VARCHAR(36) NOT NULL COMMENT 'code名称',
CONSTRAINT `s_dict_code_cate_id_frk` FOREIGN KEY (`cate_id`) REFERENCES `fanxing3`.`s_dict_cate` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, note VARCHAR(36) COMMENT '注释',
INDEX s_dict_code_idx(cate_id) CONSTRAINT `s_dict_code_cate_id_frk` FOREIGN KEY (`cate_id`) REFERENCES `fanxing3`.`s_dict_cate` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
INDEX s_dict_code_idx (cate_id)
); );
-- s_channel -- s_channel
CREATE TABLE IF NOT EXISTS s_channel( CREATE TABLE IF NOT EXISTS s_channel
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT, (
unid VARCHAR(36) NOT NULL DEFAULT (UUID()), id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
channel_unid VARCHAR(64) NOT NULL COMMENT '设备中每一路视频通道本身的编码', unid VARCHAR(36) NOT NULL DEFAULT (UUID()),
device_unid VARCHAR(64) COMMENT '设备自身的编码', channel_unid VARCHAR(64) NOT NULL UNIQUE COMMENT '设备中每一路视频通道本身的编码',
type INT NOT NULL default 0 COMMENT '设备信息来源类型,0手动添加,1平台拉取,2视频资源上传', device_unid VARCHAR(64) COMMENT '设备自身的编码',
stream_type INT COMMENT '视频流类型,例如rtsp,http,rtmp等', type INT NOT NULL default 0 COMMENT '设备信息来源类型,0手动添加,1平台拉取,2视频资源上传',
stream_path VARCHAR(1024) COMMENT '视频流地址', device_type VARCHAR(36) COMMENT '设备类型,对应字典表中device_type',
username VARCHAR(36) COMMENT '获取视频流所需的用户名', stream_type INT COMMENT '视频流类型,例如rtsp,http,rtmp等',
password VARCHAR(64) COMMENT '获取视频流所需的密码', stream_path VARCHAR(1024) COMMENT '视频流地址',
brand varchar(64) COMMENT '品牌/厂家', username VARCHAR(36) COMMENT '获取视频流所需的用户名',
direction varchar(64) COMMENT '方向', password VARCHAR(64) COMMENT '获取视频流所需的密码',
address_unid VARCHAR(36) COMMENT '绑定的组织结构,组织结构在字典表中', brand varchar(64) COMMENT '品牌/厂家',
name VARCHAR(128) COMMENT '名称', direction varchar(64) COMMENT '方向',
ip VARCHAR(36) COMMENT 'ip地址', address_unid VARCHAR(36) COMMENT '绑定的组织结构,组织结构在字典表中',
port INT COMMENT '端口号', name VARCHAR(128) UNIQUE COMMENT '名称',
expand VARCHAR(128) COMMENT '扩展字段,保存一些不重要的信息', ip VARCHAR(36) COMMENT 'ip地址',
longitude FLOAT, port INT COMMENT '端口号',
latitude FLOAT, expand VARCHAR(128) COMMENT '扩展字段,保存一些不重要的信息',
status INT NOT NULL DEFAULT 0, longitude FLOAT,
create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', latitude FLOAT,
INDEX s_channel_channel_unid_idx(channel_unid), status INT NOT NULL DEFAULT 0,
INDEX s_cahnnel_unid_idx(unid) create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
INDEX s_channel_unid_idx (unid)
); );
-- r_channel_tag -- r_channel_tag
CREATE TABLE IF NOT EXISTS r_channel_tag ( CREATE TABLE IF NOT EXISTS r_channel_tag
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT, (
channel_id BIGINT NOT NULL COMMENT '对应channel表的id', id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
tag_id BIGINT NOT NULL COMMENT 'tag也在字典表中', channel_id BIGINT NOT NULL COMMENT '对应channel表的id',
tag VARCHAR(36) NOT NULL COMMENT 'tag也在字典表中',
CONSTRAINT `r_channel_tag_channel_id_frk` FOREIGN KEY (`channel_id`) REFERENCES `fanxing3`.`s_channel` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
INDEX r_channel_tag_channel_id_idx(channel_id), CONSTRAINT `r_channel_tag_channel_id_frk` FOREIGN KEY (`channel_id`) REFERENCES `fanxing3`.`s_channel` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
INDEX r_channel_tag_tag_id_idx(tag_id) INDEX r_channel_tag_channel_id_idx (channel_id),
INDEX r_channel_tag_tag_id_idx (tag)
); );
-- s_content -- s_content
CREATE TABLE IF NOT EXISTS s_content ( CREATE TABLE IF NOT EXISTS s_content
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT, (
unid VARCHAR(36) NOT NULL DEFAULT (UUID()), id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(64) NOT NULL COMMENT '名称', unid VARCHAR(36) NOT NULL DEFAULT (UUID()),
type VARCHAR(32) COMMENT '分组', name VARCHAR(64) NOT NULL COMMENT '名称',
content TEXT COMMENT '内容' type VARCHAR(32) COMMENT '分组',
content TEXT COMMENT '内容'
); );
insert into s_content(name, content ,type) insert into s_content(name, content, type)
values ('defaultConfig', values ('defaultConfig',
'<?xml version="1.0" encoding="GBK"?><root><算法参数设置><车牌识别><车牌缩放比率>0.8000</车牌缩放比率><本地车牌首字母>1</本地车牌首字母><车牌最小宽度>60</车牌最小宽度><车牌最大宽度>180</车牌最大宽度><本地汉字>20</本地汉字><是否识别新能源车牌>0</是否识别新能源车牌></车牌识别><是否启用高速模式>0</是否启用高速模式><调试信息><字体大小>20</字体大小><是否显示Scale>0</是否显示Scale><是否显示耗时>0</是否显示耗时><是否显示版本>0</是否显示版本></调试信息><车牌宽度范围设定方法>1</车牌宽度范围设定方法></算法参数设置><短时录像设置><启用>1</启用><是否画框>1</是否画框><向前录像时间>10</向前录像时间><向后录像时间>10</向后录像时间><录像最大缓存时间>100</录像最大缓存时间></短时录像设置><功能配置><抓拍参数配置><路口电警><卡口><输出卡口图片>1</输出卡口图片><卡口抓两张图>0</卡口抓两张图><上行物体不输出卡口结果>0</上行物体不输出卡口结果><下行物体不输出卡口结果>0</下行物体不输出卡口结果><无牌车辆不输出卡口结果>0</无牌车辆不输出卡口结果><行人非机动车不输出卡口结果>0</行人非机动车不输出卡口结果></卡口></路口电警></抓拍参数配置></功能配置><车辆属性识别><识别车辆类型>1</识别车辆类型><识别车标>1</识别车标><识别车身颜色>1</识别车身颜色><识别驾驶员>1</识别驾驶员><识别危险品标识>1</识别危险品标识></车辆属性识别></root>', '<?xml version="1.0" encoding="GBK"?><root><算法参数设置><车牌识别><车牌缩放比率>0.8000</车牌缩放比率><本地车牌首字母>1</本地车牌首字母><车牌最小宽度>60</车牌最小宽度><车牌最大宽度>180</车牌最大宽度><本地汉字>20</本地汉字><是否识别新能源车牌>0</是否识别新能源车牌></车牌识别><是否启用高速模式>0</是否启用高速模式><调试信息><字体大小>20</字体大小><是否显示Scale>0</是否显示Scale><是否显示耗时>0</是否显示耗时><是否显示版本>0</是否显示版本></调试信息><车牌宽度范围设定方法>1</车牌宽度范围设定方法></算法参数设置><短时录像设置><启用>1</启用><是否画框>1</是否画框><向前录像时间>10</向前录像时间><向后录像时间>10</向后录像时间><录像最大缓存时间>100</录像最大缓存时间></短时录像设置><功能配置><抓拍参数配置><路口电警><卡口><输出卡口图片>1</输出卡口图片><卡口抓两张图>0</卡口抓两张图><上行物体不输出卡口结果>0</上行物体不输出卡口结果><下行物体不输出卡口结果>0</下行物体不输出卡口结果><无牌车辆不输出卡口结果>0</无牌车辆不输出卡口结果><行人非机动车不输出卡口结果>0</行人非机动车不输出卡口结果></卡口></路口电警></抓拍参数配置></功能配置><车辆属性识别><识别车辆类型>1</识别车辆类型><识别车标>1</识别车标><识别车身颜色>1</识别车身颜色><识别驾驶员>1</识别驾驶员><识别危险品标识>1</识别危险品标识></车辆属性识别></root>',
'defaultConfig'); 'defaultConfig');
insert into s_content(name, content ,type) insert into s_content(name, content, type)
values ('defaultConfigTemplate', values ('defaultConfigTemplate',
'<?xml version="1.0" encoding="GBK"?><root><短时录像设置><启用><AttribType>4</AttribType><AttribInfo>是否开启录像</AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></启用><是否画框><AttribType>4</AttribType><AttribInfo>是否画框</AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></是否画框><向前录像时间><AttribType>0</AttribType><AttribInfo>秒</AttribInfo><AttribDefault>5</AttribDefault><AttribRange>0-1000</AttribRange></向前录像时间><向后录像时间><AttribType>0</AttribType><AttribInfo>秒</AttribInfo><AttribDefault>5</AttribDefault><AttribRange>0-1000</AttribRange></向后录像时间><录像最大缓存时间><AttribType>0</AttribType><AttribInfo>秒</AttribInfo><AttribDefault>60</AttribDefault><AttribRange>0-1000</AttribRange></录像最大缓存时间></短时录像设置><车辆属性识别><识别车辆类型><AttribType>4</AttribType><AttribInfo>识别车辆类型</AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></识别车辆类型><识别车标><AttribType>4</AttribType><AttribInfo>识别车标</AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></识别车标><识别车身颜色><AttribType>4</AttribType><AttribInfo>识别车身颜色</AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></识别车身颜色><识别驾驶员><AttribType>4</AttribType><AttribInfo>识别驾驶员</AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></识别驾驶员><识别危险品标识><AttribType>4</AttribType><AttribInfo>识别危险品标识</AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></识别危险品标识></车辆属性识别><功能配置><抓拍参数配置><路口电警><卡口><输出卡口图片><AttribType>4</AttribType><AttribInfo/><AttribDefault>1</AttribDefault><AttribRange /></输出卡口图片><卡口抓两张图><AttribType>4</AttribType><AttribInfo/><AttribDefault>0</AttribDefault><AttribRange /></卡口抓两张图><上行物体不输出卡口结果><AttribType>4</AttribType><AttribInfo/><AttribDefault>0</AttribDefault><AttribRange /></上行物体不输出卡口结果><下行物体不输出卡口结果><AttribType>4</AttribType><AttribInfo/><AttribDefault>0</AttribDefault><AttribRange /></下行物体不输出卡口结果><无牌车辆不输出卡口结果><AttribType>4</AttribType><AttribInfo/><AttribDefault>0</AttribDefault><AttribRange /></无牌车辆不输出卡口结果><行人非机动车不输出卡口结果><AttribType>4</AttribType><AttribInfo/><AttribDefault>0</AttribDefault><AttribRange /></行人非机动车不输出卡口结果></卡口></路口电警></抓拍参数配置></功能配置><算法参数设置><是否启用高速模式><AttribType>4</AttribType><AttribInfo>应用于车辆通常速度较高且视频卡顿场景</AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></是否启用高速模式><车牌识别><车牌缩放比率><AttribType>1</AttribType><AttribInfo>适用非机动车和摩托车,车牌宽目标40-80像素</AttribInfo><AttribDefault>0.800000</AttribDefault><AttribRange>0.300000-3.000000</AttribRange></车牌缩放比率><本地车牌首字母><AttribType>3</AttribType><AttribInfo>只摩托车</AttribInfo><AttribDefault>0</AttribDefault><AttribRange>26:0-A&amp;1-B&amp;2-C&amp;3-D&amp;4-E&amp;5-F&amp;6-G&amp;7-H&amp;8-I&amp;9-J&amp;10-K&amp;11-L&amp;12-M&amp;13-N&amp;14-O&amp;15-P&amp;16-Q&amp;17-R&amp;18-S&amp;19-T&amp;20-U&amp;21-V&amp;22-W&amp;23-X&amp;24-Y&amp;25-Z</AttribRange></本地车牌首字母><车牌最小宽度><AttribType>0</AttribType><AttribInfo/><AttribDefault>90</AttribDefault><AttribRange>60-230</AttribRange></车牌最小宽度><车牌最大宽度><AttribType>0</AttribType><AttribInfo/><AttribDefault>130</AttribDefault><AttribRange>60-230</AttribRange></车牌最大宽度><本地汉字><AttribType>3</AttribType><AttribInfo/><AttribDefault>0</AttribDefault><AttribRange>31:0-京&amp;1-沪&amp;2-津&amp;3-渝&amp;4-冀&amp;5-晋&amp;6-蒙&amp;7-辽&amp;8-吉&amp;9-黑&amp;10-苏&amp;11-浙&amp;12-皖&amp;13-闽&amp;14-赣&amp;15-鲁&amp;16-豫&amp;17-鄂&amp;18-湘&amp;19-粤&amp;20-桂&amp;21-琼&amp;22-川&amp;23-贵&amp;24-云&amp;25-藏&amp;26-陕&amp;27-甘&amp;28-青&amp;29-宁&amp;30-新</AttribRange></本地汉字><是否识别新能源车牌><AttribType>4</AttribType><AttribInfo/><AttribDefault>1</AttribDefault><AttribRange /></是否识别新能源车牌></车牌识别><调试信息><字体大小><AttribType>0</AttribType><AttribInfo>root\算法参数设置\调试信息\字体大小</AttribInfo><AttribDefault>20</AttribDefault><AttribRange>10-100</AttribRange></字体大小><是否显示Scale><AttribType>4</AttribType><AttribInfo/><AttribDefault>0</AttribDefault><AttribRange /></是否显示Scale><是否显示耗时><AttribType>4</AttribType><AttribInfo/><AttribDefault>0</AttribDefault><AttribRange /></是否显示耗时><是否显示版本><AttribType>4</AttribType><AttribInfo/><AttribDefault>0</AttribDefault><AttribRange /></是否显示版本></调试信息></算法参数设置><车牌宽度范围设定方法><AttribType>3</AttribType><AttribInfo/><AttribDefault>1</AttribDefault><AttribRange>2:0-手动设置&amp;1-自动计算</AttribRange></车牌宽度范围设定方法></root>', '<?xml version="1.0" encoding="GBK"?><root><短时录像设置><启用><AttribType>4</AttribType><AttribInfo>是否开启录像</AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></启用><是否画框><AttribType>4</AttribType><AttribInfo>是否画框</AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></是否画框><向前录像时间><AttribType>0</AttribType><AttribInfo>秒</AttribInfo><AttribDefault>5</AttribDefault><AttribRange>0-1000</AttribRange></向前录像时间><向后录像时间><AttribType>0</AttribType><AttribInfo>秒</AttribInfo><AttribDefault>5</AttribDefault><AttribRange>0-1000</AttribRange></向后录像时间><录像最大缓存时间><AttribType>0</AttribType><AttribInfo>秒</AttribInfo><AttribDefault>60</AttribDefault><AttribRange>0-1000</AttribRange></录像最大缓存时间></短时录像设置><车辆属性识别><识别车辆类型><AttribType>4</AttribType><AttribInfo>识别车辆类型</AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></识别车辆类型><识别车标><AttribType>4</AttribType><AttribInfo>识别车标</AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></识别车标><识别车身颜色><AttribType>4</AttribType><AttribInfo>识别车身颜色</AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></识别车身颜色><识别驾驶员><AttribType>4</AttribType><AttribInfo>识别驾驶员</AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></识别驾驶员><识别危险品标识><AttribType>4</AttribType><AttribInfo>识别危险品标识</AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></识别危险品标识></车辆属性识别><功能配置><抓拍参数配置><路口电警><卡口><输出卡口图片><AttribType>4</AttribType><AttribInfo/><AttribDefault>1</AttribDefault><AttribRange /></输出卡口图片><卡口抓两张图><AttribType>4</AttribType><AttribInfo/><AttribDefault>0</AttribDefault><AttribRange /></卡口抓两张图><上行物体不输出卡口结果><AttribType>4</AttribType><AttribInfo/><AttribDefault>0</AttribDefault><AttribRange /></上行物体不输出卡口结果><下行物体不输出卡口结果><AttribType>4</AttribType><AttribInfo/><AttribDefault>0</AttribDefault><AttribRange /></下行物体不输出卡口结果><无牌车辆不输出卡口结果><AttribType>4</AttribType><AttribInfo/><AttribDefault>0</AttribDefault><AttribRange /></无牌车辆不输出卡口结果><行人非机动车不输出卡口结果><AttribType>4</AttribType><AttribInfo/><AttribDefault>0</AttribDefault><AttribRange /></行人非机动车不输出卡口结果></卡口></路口电警></抓拍参数配置></功能配置><算法参数设置><是否启用高速模式><AttribType>4</AttribType><AttribInfo>应用于车辆通常速度较高且视频卡顿场景</AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></是否启用高速模式><车牌识别><车牌缩放比率><AttribType>1</AttribType><AttribInfo>适用非机动车和摩托车,车牌宽目标40-80像素</AttribInfo><AttribDefault>0.800000</AttribDefault><AttribRange>0.300000-3.000000</AttribRange></车牌缩放比率><本地车牌首字母><AttribType>3</AttribType><AttribInfo>只摩托车</AttribInfo><AttribDefault>0</AttribDefault><AttribRange>26:0-A&amp;1-B&amp;2-C&amp;3-D&amp;4-E&amp;5-F&amp;6-G&amp;7-H&amp;8-I&amp;9-J&amp;10-K&amp;11-L&amp;12-M&amp;13-N&amp;14-O&amp;15-P&amp;16-Q&amp;17-R&amp;18-S&amp;19-T&amp;20-U&amp;21-V&amp;22-W&amp;23-X&amp;24-Y&amp;25-Z</AttribRange></本地车牌首字母><车牌最小宽度><AttribType>0</AttribType><AttribInfo/><AttribDefault>90</AttribDefault><AttribRange>60-230</AttribRange></车牌最小宽度><车牌最大宽度><AttribType>0</AttribType><AttribInfo/><AttribDefault>130</AttribDefault><AttribRange>60-230</AttribRange></车牌最大宽度><本地汉字><AttribType>3</AttribType><AttribInfo/><AttribDefault>0</AttribDefault><AttribRange>31:0-京&amp;1-沪&amp;2-津&amp;3-渝&amp;4-冀&amp;5-晋&amp;6-蒙&amp;7-辽&amp;8-吉&amp;9-黑&amp;10-苏&amp;11-浙&amp;12-皖&amp;13-闽&amp;14-赣&amp;15-鲁&amp;16-豫&amp;17-鄂&amp;18-湘&amp;19-粤&amp;20-桂&amp;21-琼&amp;22-川&amp;23-贵&amp;24-云&amp;25-藏&amp;26-陕&amp;27-甘&amp;28-青&amp;29-宁&amp;30-新</AttribRange></本地汉字><是否识别新能源车牌><AttribType>4</AttribType><AttribInfo/><AttribDefault>1</AttribDefault><AttribRange /></是否识别新能源车牌></车牌识别><调试信息><字体大小><AttribType>0</AttribType><AttribInfo>root\算法参数设置\调试信息\字体大小</AttribInfo><AttribDefault>20</AttribDefault><AttribRange>10-100</AttribRange></字体大小><是否显示Scale><AttribType>4</AttribType><AttribInfo/><AttribDefault>0</AttribDefault><AttribRange /></是否显示Scale><是否显示耗时><AttribType>4</AttribType><AttribInfo/><AttribDefault>0</AttribDefault><AttribRange /></是否显示耗时><是否显示版本><AttribType>4</AttribType><AttribInfo/><AttribDefault>0</AttribDefault><AttribRange /></是否显示版本></调试信息></算法参数设置><车牌宽度范围设定方法><AttribType>3</AttribType><AttribInfo/><AttribDefault>1</AttribDefault><AttribRange>2:0-手动设置&amp;1-自动计算</AttribRange></车牌宽度范围设定方法></root>',
'defaultConfig'); 'defaultConfig');
insert into s_content(name, content ,type) insert into s_content(name, content, type)
values ('illegalStopDefaultConfig', values ('illegalStopDefaultConfig',
'<?xml version="1.0" encoding="GBK"?><root><短时录像设置><录像最大缓存时间>200</录像最大缓存时间><向前录像时间>180</向前录像时间><向后录像时间>20</向后录像时间><启用>0</启用><是否画框>0</是否画框></短时录像设置><算法参数设置><是否输出无牌结果>1</是否输出无牌结果><车牌识别><本地汉字>0</本地汉字><车牌最小宽度>60</车牌最小宽度><车牌最大宽度>150</车牌最大宽度><是否识别新能源车牌>0</是否识别新能源车牌></车牌识别><车头检测分数阈值>50</车头检测分数阈值><车尾检测分数阈值>50</车尾检测分数阈值><是否画检测区域>0</是否画检测区域><同时计时抓拍>0</同时计时抓拍><违法图片间隔时间-秒><时间1>10</时间1><时间2>160</时间2><时间3>10</时间3></违法图片间隔时间-秒></算法参数设置><动态跟踪参数><使用球机3D定位-重启生效>0</使用球机3D定位-重启生效></动态跟踪参数><车辆属性识别><识别车辆类型>0</识别车辆类型><识别车标>0</识别车标><识别车身颜色>0</识别车身颜色><识别驾驶员>0</识别驾驶员><识别危险品标识>0</识别危险品标识></车辆属性识别></root>', '<?xml version="1.0" encoding="GBK"?><root><短时录像设置><录像最大缓存时间>200</录像最大缓存时间><向前录像时间>180</向前录像时间><向后录像时间>20</向后录像时间><启用>0</启用><是否画框>0</是否画框></短时录像设置><算法参数设置><是否输出无牌结果>1</是否输出无牌结果><车牌识别><本地汉字>0</本地汉字><车牌最小宽度>60</车牌最小宽度><车牌最大宽度>150</车牌最大宽度><是否识别新能源车牌>0</是否识别新能源车牌></车牌识别><车头检测分数阈值>50</车头检测分数阈值><车尾检测分数阈值>50</车尾检测分数阈值><是否画检测区域>0</是否画检测区域><同时计时抓拍>0</同时计时抓拍><违法图片间隔时间-秒><时间1>10</时间1><时间2>160</时间2><时间3>10</时间3></违法图片间隔时间-秒></算法参数设置><动态跟踪参数><使用球机3D定位-重启生效>0</使用球机3D定位-重启生效></动态跟踪参数><车辆属性识别><识别车辆类型>0</识别车辆类型><识别车标>0</识别车标><识别车身颜色>0</识别车身颜色><识别驾驶员>0</识别驾驶员><识别危险品标识>0</识别危险品标识></车辆属性识别></root>',
'defaultConfig'); 'defaultConfig');
insert into s_content(name, content ,type) insert into s_content(name, content, type)
values ('illegalStopDefaultConfigTemplate', values ('illegalStopDefaultConfigTemplate',
'<?xml version="1.0" encoding="GBK"?><root><短时录像设置><启用><AttribType>4</AttribType><AttribInfo>是否开启录像</AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></启用><是否画框><AttribType>4</AttribType><AttribInfo>是否画框</AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></是否画框><向前录像时间><AttribType>0</AttribType><AttribInfo>秒</AttribInfo><AttribDefault>5</AttribDefault><AttribRange>0-1000</AttribRange></向前录像时间><向后录像时间><AttribType>0</AttribType><AttribInfo>秒</AttribInfo><AttribDefault>5</AttribDefault><AttribRange>0-1000</AttribRange></向后录像时间><录像最大缓存时间><AttribType>0</AttribType><AttribInfo>秒</AttribInfo><AttribDefault>60</AttribDefault><AttribRange>0-1000</AttribRange></录像最大缓存时间></短时录像设置><车辆属性识别><识别车辆类型><AttribType>4</AttribType><AttribInfo>识别车辆类型</AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></识别车辆类型><识别车标><AttribType>4</AttribType><AttribInfo>识别车标</AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></识别车标><识别车身颜色><AttribType>4</AttribType><AttribInfo>识别车身颜色</AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></识别车身颜色><识别驾驶员><AttribType>4</AttribType><AttribInfo>识别驾驶员</AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></识别驾驶员><识别危险品标识><AttribType>4</AttribType><AttribInfo>识别危险品标识</AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></识别危险品标识></车辆属性识别><算法功能><是否开启车牌验证同一辆车><AttribType>4</AttribType><AttribInfo>是否开启车牌验证同一辆车</AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></是否开启车牌验证同一辆车></算法功能><算法参数设置><抓拍前等待时间-秒><AttribType>0</AttribType><AttribInfo>抓拍前等待时间</AttribInfo><AttribDefault>2</AttribDefault><AttribRange>0-600</AttribRange></抓拍前等待时间-秒><违法图片间隔时间-秒><时间1><AttribType>0</AttribType><AttribInfo>图1图2间隔时间</AttribInfo><AttribDefault>10</AttribDefault><AttribRange>0-1000</AttribRange></时间1><时间2><AttribType>0</AttribType><AttribInfo>图2图3间隔时间</AttribInfo><AttribDefault>10</AttribDefault><AttribRange>0-1000</AttribRange></时间2><时间3><AttribType>0</AttribType><AttribInfo>图3图4间隔时间</AttribInfo><AttribDefault>10</AttribDefault><AttribRange>0-1000</AttribRange></时间3></违法图片间隔时间-秒><同时计时抓拍><AttribType>4</AttribType><AttribInfo>同时计时抓拍</AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></同时计时抓拍><车头检测分数阈值><AttribType>0</AttribType><AttribInfo>车检分数阈值</AttribInfo><AttribDefault>50</AttribDefault><AttribRange>10-100</AttribRange></车头检测分数阈值><车尾检测分数阈值><AttribType>0</AttribType><AttribInfo>车检分数阈值</AttribInfo><AttribDefault>50</AttribDefault><AttribRange>10-100</AttribRange></车尾检测分数阈值><是否画检测区域><AttribType>4</AttribType><AttribInfo>是否画检测区域</AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></是否画检测区域><是否输出无牌结果><AttribType>4</AttribType><AttribInfo>是否输出无牌结果</AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></是否输出无牌结果><调试信息><字体大小><AttribType>0</AttribType><AttribInfo/><AttribDefault>20</AttribDefault><AttribRange>10-100</AttribRange></字体大小><是否显示Scale><AttribType>4</AttribType><AttribInfo/><AttribDefault>0</AttribDefault><AttribRange /></是否显示Scale><是否显示耗时><AttribType>4</AttribType><AttribInfo/><AttribDefault>0</AttribDefault><AttribRange /></是否显示耗时><是否显示版本><AttribType>4</AttribType><AttribInfo/><AttribDefault>0</AttribDefault><AttribRange /></是否显示版本></调试信息><车牌识别><本地汉字><AttribType>3</AttribType><AttribInfo/><AttribDefault>0</AttribDefault><AttribRange>31:0-京&amp;1-沪&amp;2-津&amp;3-渝&amp;4-冀&amp;5-晋&amp;6-蒙&amp;7-辽&amp;8-吉&amp;9-黑&amp;10-苏&amp;11-浙&amp;12-皖&amp;13-闽&amp;14-赣&amp;15-鲁&amp;16-豫&amp;17-鄂&amp;18-湘&amp;19-粤&amp;20-桂&amp;21-琼&amp;22-川&amp;23-贵&amp;24-云&amp;25-藏&amp;26-陕&amp;27-甘&amp;28-青&amp;29-宁&amp;30-新</AttribRange></本地汉字><车牌最小宽度><AttribType>0</AttribType><AttribInfo/><AttribDefault>90</AttribDefault><AttribRange>60-230</AttribRange></车牌最小宽度><车牌最大宽度><AttribType>0</AttribType><AttribInfo/><AttribDefault>130</AttribDefault><AttribRange>60-230</AttribRange></车牌最大宽度><是否识别新能源车牌><AttribType>4</AttribType><AttribInfo/><AttribDefault>1</AttribDefault><AttribRange /></是否识别新能源车牌></车牌识别></算法参数设置><动态跟踪参数><使用球机3D定位-重启生效><AttribType>4</AttribType><AttribInfo>使用球机3D定位</AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></使用球机3D定位-重启生效></动态跟踪参数></root>', '<?xml version="1.0" encoding="GBK"?><root><短时录像设置><启用><AttribType>4</AttribType><AttribInfo>是否开启录像</AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></启用><是否画框><AttribType>4</AttribType><AttribInfo>是否画框</AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></是否画框><向前录像时间><AttribType>0</AttribType><AttribInfo>秒</AttribInfo><AttribDefault>5</AttribDefault><AttribRange>0-1000</AttribRange></向前录像时间><向后录像时间><AttribType>0</AttribType><AttribInfo>秒</AttribInfo><AttribDefault>5</AttribDefault><AttribRange>0-1000</AttribRange></向后录像时间><录像最大缓存时间><AttribType>0</AttribType><AttribInfo>秒</AttribInfo><AttribDefault>60</AttribDefault><AttribRange>0-1000</AttribRange></录像最大缓存时间></短时录像设置><车辆属性识别><识别车辆类型><AttribType>4</AttribType><AttribInfo>识别车辆类型</AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></识别车辆类型><识别车标><AttribType>4</AttribType><AttribInfo>识别车标</AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></识别车标><识别车身颜色><AttribType>4</AttribType><AttribInfo>识别车身颜色</AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></识别车身颜色><识别驾驶员><AttribType>4</AttribType><AttribInfo>识别驾驶员</AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></识别驾驶员><识别危险品标识><AttribType>4</AttribType><AttribInfo>识别危险品标识</AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></识别危险品标识></车辆属性识别><算法功能><是否开启车牌验证同一辆车><AttribType>4</AttribType><AttribInfo>是否开启车牌验证同一辆车</AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></是否开启车牌验证同一辆车></算法功能><算法参数设置><抓拍前等待时间-秒><AttribType>0</AttribType><AttribInfo>抓拍前等待时间</AttribInfo><AttribDefault>2</AttribDefault><AttribRange>0-600</AttribRange></抓拍前等待时间-秒><违法图片间隔时间-秒><时间1><AttribType>0</AttribType><AttribInfo>图1图2间隔时间</AttribInfo><AttribDefault>10</AttribDefault><AttribRange>0-1000</AttribRange></时间1><时间2><AttribType>0</AttribType><AttribInfo>图2图3间隔时间</AttribInfo><AttribDefault>10</AttribDefault><AttribRange>0-1000</AttribRange></时间2><时间3><AttribType>0</AttribType><AttribInfo>图3图4间隔时间</AttribInfo><AttribDefault>10</AttribDefault><AttribRange>0-1000</AttribRange></时间3></违法图片间隔时间-秒><同时计时抓拍><AttribType>4</AttribType><AttribInfo>同时计时抓拍</AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></同时计时抓拍><车头检测分数阈值><AttribType>0</AttribType><AttribInfo>车检分数阈值</AttribInfo><AttribDefault>50</AttribDefault><AttribRange>10-100</AttribRange></车头检测分数阈值><车尾检测分数阈值><AttribType>0</AttribType><AttribInfo>车检分数阈值</AttribInfo><AttribDefault>50</AttribDefault><AttribRange>10-100</AttribRange></车尾检测分数阈值><是否画检测区域><AttribType>4</AttribType><AttribInfo>是否画检测区域</AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></是否画检测区域><是否输出无牌结果><AttribType>4</AttribType><AttribInfo>是否输出无牌结果</AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></是否输出无牌结果><调试信息><字体大小><AttribType>0</AttribType><AttribInfo/><AttribDefault>20</AttribDefault><AttribRange>10-100</AttribRange></字体大小><是否显示Scale><AttribType>4</AttribType><AttribInfo/><AttribDefault>0</AttribDefault><AttribRange /></是否显示Scale><是否显示耗时><AttribType>4</AttribType><AttribInfo/><AttribDefault>0</AttribDefault><AttribRange /></是否显示耗时><是否显示版本><AttribType>4</AttribType><AttribInfo/><AttribDefault>0</AttribDefault><AttribRange /></是否显示版本></调试信息><车牌识别><本地汉字><AttribType>3</AttribType><AttribInfo/><AttribDefault>0</AttribDefault><AttribRange>31:0-京&amp;1-沪&amp;2-津&amp;3-渝&amp;4-冀&amp;5-晋&amp;6-蒙&amp;7-辽&amp;8-吉&amp;9-黑&amp;10-苏&amp;11-浙&amp;12-皖&amp;13-闽&amp;14-赣&amp;15-鲁&amp;16-豫&amp;17-鄂&amp;18-湘&amp;19-粤&amp;20-桂&amp;21-琼&amp;22-川&amp;23-贵&amp;24-云&amp;25-藏&amp;26-陕&amp;27-甘&amp;28-青&amp;29-宁&amp;30-新</AttribRange></本地汉字><车牌最小宽度><AttribType>0</AttribType><AttribInfo/><AttribDefault>90</AttribDefault><AttribRange>60-230</AttribRange></车牌最小宽度><车牌最大宽度><AttribType>0</AttribType><AttribInfo/><AttribDefault>130</AttribDefault><AttribRange>60-230</AttribRange></车牌最大宽度><是否识别新能源车牌><AttribType>4</AttribType><AttribInfo/><AttribDefault>1</AttribDefault><AttribRange /></是否识别新能源车牌></车牌识别></算法参数设置><动态跟踪参数><使用球机3D定位-重启生效><AttribType>4</AttribType><AttribInfo>使用球机3D定位</AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></使用球机3D定位-重启生效></动态跟踪参数></root>',
'defaultConfig'); 'defaultConfig');
-- 分表 -- 分表
alter TABLE d_traffic PARTITION by RANGE(UNIX_TIMESTAMP(event_time))( alter TABLE d_traffic PARTITION by RANGE (UNIX_TIMESTAMP(event_time))(
PARTITION d_traffic20210701 VALUES less than (UNIX_TIMESTAMP('2021-07-02')) PARTITION d_traffic20210701 VALUES less than (UNIX_TIMESTAMP('2021-07-02'))
); );
alter TABLE d_traffic_face PARTITION by RANGE(UNIX_TIMESTAMP(event_time))( alter TABLE d_traffic_face PARTITION by RANGE (UNIX_TIMESTAMP(event_time))(
PARTITION d_traffic_face20210701 VALUES less than (UNIX_TIMESTAMP('2021-07-02')) PARTITION d_traffic_face20210701 VALUES less than (UNIX_TIMESTAMP('2021-07-02'))
); );
alter TABLE d_flow_event PARTITION by RANGE(UNIX_TIMESTAMP(event_time))( alter TABLE d_flow_event PARTITION by RANGE (UNIX_TIMESTAMP(event_time))(
PARTITION d_flow_event20210701 VALUES less than (UNIX_TIMESTAMP('2021-07-02')) PARTITION d_flow_event20210701 VALUES less than (UNIX_TIMESTAMP('2021-07-02'))
); );
alter TABLE d_flow_data PARTITION by RANGE(UNIX_TIMESTAMP(event_time))( alter TABLE d_flow_data PARTITION by RANGE (UNIX_TIMESTAMP(event_time))(
PARTITION d_flow_data20210701 VALUES less than (UNIX_TIMESTAMP('2021-07-02')) PARTITION d_flow_data20210701 VALUES less than (UNIX_TIMESTAMP('2021-07-02'))
); );
alter TABLE d_behavior PARTITION by RANGE(UNIX_TIMESTAMP(event_time))( alter TABLE d_behavior PARTITION by RANGE (UNIX_TIMESTAMP(event_time))(
PARTITION d_behavior20210701 VALUES less than (UNIX_TIMESTAMP('2021-07-02')) PARTITION d_behavior20210701 VALUES less than (UNIX_TIMESTAMP('2021-07-02'))
); );
delimiter $$ delimiter $$
DROP PROCEDURE IF EXISTS timestamp_partition DROP PROCEDURE IF EXISTS timestamp_partition
$$ $$
CREATE PROCEDURE timestamp_partition(v_table_name VARCHAR(128),v_schema VARCHAR(128)) CREATE PROCEDURE timestamp_partition(v_table_name VARCHAR(128), v_schema VARCHAR(128))
BEGIN BEGIN
DECLARE v_sysdate date; # 声明 当前时间 DECLARE v_sysdate date; # 声明 当前时间
DECLARE v_mindate date; # 声明 目前分区的最小值 DECLARE v_mindate date; # 声明 目前分区的最小值
DECLARE v_maxdate date; # 声明 目前分区值中的最大值 DECLARE v_maxdate date; # 声明 目前分区值中的最大值
DECLARE v_pt varchar(20); # 声明 分区名称 数字部分 DECLARE v_pt varchar(20); # 声明 分区名称 数字部分
DECLARE v_maxval varchar(20); # 声明 最大值 DECLARE v_maxval varchar(20);
DECLARE i int; # 声明 ?? # 声明 最大值
-- 增加新分区 -- 增加新分区
SELECT max(CAST(FROM_UNIXTIME(partition_description) as date)) AS val SELECT max(CAST(FROM_UNIXTIME(partition_description) as date)) AS val
INTO v_maxdate INTO v_maxdate
FROM INFORMATION_SCHEMA.PARTITIONS FROM INFORMATION_SCHEMA.PARTITIONS
WHERE TABLE_NAME = v_table_name AND TABLE_SCHEMA = v_schema; WHERE TABLE_NAME = v_table_name
AND TABLE_SCHEMA = v_schema;
set v_sysdate = sysdate(); # 赋值v_sysdate为当前时间
set v_sysdate = sysdate();
-- INTERVAL 时间计算的关键字 # 赋值v_sysdate为当前时间
WHILE v_maxdate <= (v_sysdate + INTERVAL 7 DAY) DO
SET v_pt = date_format(v_maxdate ,'%Y%m%d'); -- INTERVAL 时间计算的关键字
SET v_maxval = date_format(v_maxdate + INTERVAL 1 DAY, '%Y-%m-%d'); WHILE v_maxdate <= (v_sysdate + INTERVAL 7 DAY)
SET @sql = concat('alter table ',v_table_name,' add partition (partition ',v_table_name, v_pt, ' values less than(UNIX_TIMESTAMP(''', v_maxval , ''')))'); DO
PREPARE stmt FROM @sql; SET v_pt = date_format(v_maxdate, '%Y%m%d');
EXECUTE stmt; SET v_maxval = date_format(v_maxdate + INTERVAL 1 DAY, '%Y-%m-%d');
-- 删除预处理 SET @sql = concat('alter table ', v_table_name, ' add partition (partition ', v_table_name, v_pt,
DEALLOCATE PREPARE stmt; ' values less than(UNIX_TIMESTAMP(''', v_maxval, ''')))');
SET v_maxdate = v_maxdate + INTERVAL 1 DAY; # 最大值 加一操作 PREPARE stmt FROM @sql;
END WHILE; EXECUTE stmt;
-- 删除预处理
DEALLOCATE PREPARE stmt;
-- 删除旧分区 SET v_maxdate = v_maxdate + INTERVAL 1 DAY; # 最大值 加一操作
SELECT min(CAST(FROM_UNIXTIME(partition_description) as date)) AS val END WHILE;
INTO v_mindate
FROM INFORMATION_SCHEMA.PARTITIONS
WHERE TABLE_NAME = v_table_name AND TABLE_SCHEMA = v_schema; -- 删除旧分区
SELECT min(CAST(FROM_UNIXTIME(partition_description) as date)) AS val
-- 删除7天前的旧分区 INTO v_mindate
WHILE v_mindate <= (v_sysdate - INTERVAL 7 DAY) DO FROM INFORMATION_SCHEMA.PARTITIONS
SET v_pt = date_format(v_mindate - INTERVAL 1 DAY,'%Y%m%d'); WHERE TABLE_NAME = v_table_name
SET @sql = concat('alter table ',v_table_name,' drop partition ',v_table_name, v_pt); AND TABLE_SCHEMA = v_schema;
PREPARE stmt FROM @sql;
EXECUTE stmt; -- 删除7天前的旧分区
DEALLOCATE PREPARE stmt; WHILE v_mindate <= (v_sysdate - INTERVAL 7 DAY)
SET v_mindate = v_mindate + INTERVAL 1 DAY; DO
END WHILE; SET v_pt = date_format(v_mindate - INTERVAL 1 DAY, '%Y%m%d');
SET @sql = concat('alter table ', v_table_name, ' drop partition ', v_table_name, v_pt);
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
SET v_mindate = v_mindate + INTERVAL 1 DAY;
END WHILE;
END$$ END$$
delimiter ; delimiter ;
...@@ -363,14 +381,14 @@ delimiter ; ...@@ -363,14 +381,14 @@ delimiter ;
delimiter $$ delimiter $$
drop event if exists auto_pt $$ drop event if exists auto_pt $$
create event auto_pt create event auto_pt
on schedule on schedule
every 1 day every 1 day
do do
BEGIN BEGIN
call timestamp_partition('d_traffic','{schema}'); call timestamp_partition('d_traffic', '{schema}');
call timestamp_partition('d_behavior','{schema}'); call timestamp_partition('d_behavior', '{schema}');
call timestamp_partition('d_flow_event','{schema}'); call timestamp_partition('d_flow_event', '{schema}');
call timestamp_partition('d_flow_data','{schema}'); call timestamp_partition('d_flow_data', '{schema}');
call timestamp_partition('d_traffic_face','{schema}'); call timestamp_partition('d_traffic_face', '{schema}');
END$$ END$$
delimiter ; delimiter ;
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!