Commit 5281b59d by xmh

<feat> VAServerController.vaServerOverview 接口添加字段

<feat> 数据检索日志记录时记录数据类型
<refactor> 流量检索重构
<refactor> 修改部分接口返回时的信息
<feat> 添加对非机动车车牌号码的处理
<doc> 修改数据库初始化语句
1 parent 69a2b4d8
......@@ -141,6 +141,13 @@ public class TrafficProcessor implements ItemProcessor<JSONObject, TrafficConten
.orElse(null);
traffic.setCompany(company);
String plateNumber = Optional.ofNullable(eventData.getJSONObject("xcycle"))
.map(x -> x.getJSONObject("plate"))
.map(x -> x.getString("text"))
.orElse(null);
if (traffic.getPlateNumber() != null && plateNumber != null) {
traffic.setPlateNumber(plateNumber);
}
// todo RefinedFeature
JSONObject refinedFeature = eventData.getJSONObject("RefinedFeature");
......
......@@ -33,7 +33,7 @@ public class VideoController {
} catch (DuplicateKeyException e) {
return JsonMessageUtil.getErrorJsonMsg("设备编号或名称重复");
}
return JsonMessageUtil.getSuccessJsonMsg("success");
return JsonMessageUtil.getSuccessJsonMsg("成功");
}
@GetMapping("/overview")
......
......@@ -147,6 +147,6 @@ public class ChannelController extends ChannelBaseController {
public Object pullFromVideoCloud() {
channelService.pullFromVideoCloud();
return JsonMessageUtil.getSuccessJsonMsg();
return getSuccessJsonMsg(MESSAGE_SELECT_SUCCESS);
}
}
\ No newline at end of file
......@@ -13,7 +13,6 @@ import com.viontech.fanxing.query.controller.base.BehaviorBaseController;
import com.viontech.fanxing.query.model.export.ExportDataTypeEnum;
import com.viontech.fanxing.query.service.adapter.ExportDataService;
import com.viontech.fanxing.query.service.main.OpsClientService;
import com.viontech.keliu.util.JsonMessageUtil;
import org.springframework.stereotype.Controller;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.GetMapping;
......@@ -53,7 +52,7 @@ public class BehaviorController extends BehaviorBaseController {
Assert.notNull(behaviorVo.getEventTime_lte(), "结束时间不能为空");
SimplePropertyPreFilter simplePropertyPreFilter = new SimplePropertyPreFilter();
simplePropertyPreFilter.getExcludes().add("model");
opsClientService.addLog("检索分析结果,条件:" + JSON.toJSONString(behaviorVo, SerializeConfig.globalInstance, new SerializeFilter[]{simplePropertyPreFilter}, "yyyy-MM-dd HH:mm:ss", JSON.DEFAULT_GENERATE_FEATURE));
opsClientService.addLog("事件数据检索,条件:" + JSON.toJSONString(behaviorVo, SerializeConfig.globalInstance, new SerializeFilter[]{simplePropertyPreFilter}, "yyyy-MM-dd HH:mm:ss", JSON.DEFAULT_GENERATE_FEATURE));
BaseExample baseExample = getExample(behaviorVo, EXAMPLE_TYPE_PAGE);
if (isNotNull(sortOrder) && isNotNull(sortName)) {
......@@ -80,6 +79,6 @@ public class BehaviorController extends BehaviorBaseController {
exportData.setWithVideo(withVideo);
exportDataService.insertSelective(exportData);
return JsonMessageUtil.getSuccessJsonMsg();
return getSuccessJsonMsg(MESSAGE_SELECT_SUCCESS);
}
}
\ No newline at end of file
......@@ -12,6 +12,7 @@ import com.viontech.fanxing.commons.model.ExportData;
import com.viontech.fanxing.commons.model.TrafficExample;
import com.viontech.fanxing.commons.vo.TrafficVo;
import com.viontech.fanxing.query.controller.base.TrafficBaseController;
import com.viontech.fanxing.query.model.DataOverViewModel;
import com.viontech.fanxing.query.model.export.ExportDataTypeEnum;
import com.viontech.fanxing.query.service.adapter.ExportDataService;
import com.viontech.fanxing.query.service.main.OpsClientService;
......@@ -21,6 +22,7 @@ import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import static com.viontech.keliu.util.JsonMessageUtil.getSuccessJsonMsg;
......@@ -48,13 +50,27 @@ public class TrafficController extends TrafficBaseController {
Assert.isTrue(pageSize > 0, "页面大小不正确");
Assert.isTrue(page > 0, "页面参数不正确");
String eventType = trafficVo.getEventType();
String dataType;
if ("xcycle".equals(eventType)) {
dataType = "非机动车";
} else if ("pedestrian".equals(eventType)) {
dataType = "行人";
} else if (trafficVo.getIllegalState() != null && trafficVo.getIllegalState() == 1) {
dataType = "违法";
} else if ("vehicle".equals(eventType)) {
dataType = "过车";
} else {
throw new FanXingException("参数有误");
}
if (StringUtils.isEmpty(trafficVo.getEventCate())) {
trafficVo.setEventCate("traffic");
}
SimplePropertyPreFilter simplePropertyPreFilter = new SimplePropertyPreFilter();
simplePropertyPreFilter.getExcludes().add("model");
opsClientService.addLog("检索分析结果,条件:" + JSON.toJSONString(trafficVo, SerializeConfig.globalInstance, new SerializeFilter[]{simplePropertyPreFilter}, "yyyy-MM-dd HH:mm:ss", JSON.DEFAULT_GENERATE_FEATURE));
opsClientService.addLog(dataType + "数据检索,条件:" + JSON.toJSONString(trafficVo, SerializeConfig.globalInstance, new SerializeFilter[]{simplePropertyPreFilter}, "yyyy-MM-dd HH:mm:ss", JSON.DEFAULT_GENERATE_FEATURE));
BaseExample baseExample = getExample(trafficVo, EXAMPLE_TYPE_PAGE);
if (isNotNull(sortOrder) && isNotNull(sortName)) {
......@@ -72,7 +88,7 @@ public class TrafficController extends TrafficBaseController {
TrafficExample trafficExample = new TrafficExample();
trafficExample.createCriteria().andIdIn(longs);
trafficService.deleteByExample(trafficExample);
return JsonMessageUtil.getSuccessJsonMsg();
return JsonMessageUtil.getSuccessJsonMsg("成功");
}
......@@ -108,7 +124,18 @@ public class TrafficController extends TrafficBaseController {
exportData.setWithVideo(withVideo);
exportDataService.insertSelective(exportData);
return JsonMessageUtil.getSuccessJsonMsg();
return JsonMessageUtil.getSuccessJsonMsg("成功");
}
/**
* 数据概览某个任务某天数据各分析了多少
*/
@GetMapping("overView")
@ResponseBody
public JsonMessageUtil.JsonMessage<List<DataOverViewModel>> overView() {
List<DataOverViewModel> dataOverViewModels = trafficService.dataOverView(new Date());
return JsonMessageUtil.getSuccessJsonMsg(dataOverViewModels);
}
public TrafficExample getExample(TrafficVo trafficVo) {
......
package com.viontech.fanxing.query.mapper;
import com.viontech.fanxing.query.model.TrafficFlowDataModel;
import com.viontech.fanxing.query.model.TrafficFlowEventModel;
import com.viontech.fanxing.query.model.TrafficFlowRequestVo;
import java.util.List;
......@@ -15,7 +14,6 @@ import java.util.List;
public interface FlowMapper {
List<TrafficFlowEventModel> selectEvents(TrafficFlowRequestVo trafficFlowRequestVo);
int counts(TrafficFlowRequestVo trafficFlowRequestVo);
......
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.viontech.fanxing.query.mapper.FlowMapper">
<resultMap id="baseMap" type="com.viontech.fanxing.query.model.TrafficFlowEventModel">
<result column="id" property="id"/>
<result column="event_dt" property="event_dt"/>
</resultMap>
<resultMap id="dataMap" type="com.viontech.fanxing.query.model.TrafficFlowDataModel">
<result column="flow_event_id" property="eventId"/>
<result column="event_time" property="eventTime"/>
......@@ -23,57 +18,33 @@
<result column="dist_time" property="distTime"/>
</resultMap>
<select id="selectEvents" parameterType="com.viontech.fanxing.query.model.TrafficFlowRequestVo" resultMap="baseMap">
select date_format(te.event_time, '%Y-%m-%d %H:%i:%s') as event_dt,
date_format(te.event_time, '%Y-%m-%d %H:%i:%s') as gevent_dt,
te.id
from d_flow_event te
, d_flow_data
<select id="counts" parameterType="com.viontech.fanxing.query.model.TrafficFlowRequestVo"
resultType="java.lang.Integer">
select count(*) as count from (
select 1
from d_flow_event te,
d_flow_data td
<where>
and d_flow_data.flow_event_id = te.id
AND d_flow_data.road_code != '0'
te.id = td.flow_event_id
AND td.road_code != '0'
<if test="task_id != null and task_id != ''">
and te.task_id = #{task_id}
</if>
<if test="vchan_refid != null and vchan_refid != ''">
and te.channel_unid = #{vchan_refid}
</if>
<if test="event_dt__gte != null and event_dt__lt != null">
and te.event_time <![CDATA[>=]]> #{event_dt__gte}
and te.event_time <![CDATA[<=]]> #{event_dt__lt}
</if>
</where>
GROUP BY gevent_dt, te.id
<if test="statistic_type == 'road'">
, d_flow_data.road_code
</if>
order by event_dt desc
<if test="offset != null and limit != null">
LIMIT #{limit} offset #{offset}
</if>
</select>
<select id="counts" parameterType="com.viontech.fanxing.query.model.TrafficFlowRequestVo" resultType="int">
select count(1) as count from (
select date_format(te.event_time, '%Y-%m-%d %H:%i:%s') as gevent_dt
from d_flow_event te
, d_flow_data
<where>
and d_flow_data.flow_event_id = te.id
AND d_flow_data.road_code != '0'
<if test="task_id != null and task_id != ''">
and te.task_id = #{task_id}
</if>
<if test="vchan_refid != null and vchan_refid != ''">
and te.channel_unid = #{vchan_refid}
<if test="detection_type != null and detection_type.size > 0">
and detection_type in
<foreach item="item" index="index" collection="detection_type" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="event_dt__gte != null and event_dt__lt != null">
and te.event_time <![CDATA[>=]]> #{event_dt__gte}
and te.event_time <![CDATA[<=]]> #{event_dt__lt}
</if>
</where>
GROUP BY gevent_dt, te.id
GROUP BY ${groupByClause}
) as con
</select>
......@@ -83,13 +54,12 @@
from d_flow_event te,
d_flow_data td
<where>
<if test="idSet != null">
and td.flow_event_id in
<foreach collection="idSet" item="id" index="index" open="(" close=")" separator=",">
#{id}
</foreach>
te.id = td.flow_event_id
and road_code != '0'
<if test="event_dt__gte != null and event_dt__lt != null">
and te.event_time <![CDATA[>=]]> #{event_dt__gte}
and te.event_time <![CDATA[<=]]> #{event_dt__lt}
</if>
and te.id = td.flow_event_id
<if test="task_id != null">
and td.task_id = #{task_id}
</if>
......@@ -102,20 +72,11 @@
#{item}
</foreach>
</if>
<if test="vehicle_type != null and vehicle_type.length != 0">
and td.detection_type in
<foreach item="item" index="index" collection="vehicle_type"
open="(" separator="," close=")">
#{item}
</foreach>
</if>
and road_code != '0'
</where>
GROUP BY ${groupByClause}
ORDER BY ${orderByClause}
<if test="limit != null">
LIMIT #{limit}
LIMIT #{offset},#{limit}
</if>
</select>
</mapper>
\ No newline at end of file
......@@ -49,9 +49,9 @@ import java.util.zip.ZipOutputStream;
* @date 2021/11/25
*/
@Profile("pro")
@Component
@Slf4j
@Profile("!test")
public class ExportDataJob {
private static final Integer LIMIT_WITH_VIDEO = 1000;
private static final Integer LIMIT_WITH_PIC = 10000;
......
......@@ -7,6 +7,7 @@ import com.viontech.fanxing.commons.exception.FanXingException;
import com.viontech.fanxing.commons.model.ExportData;
import com.viontech.fanxing.query.mapper.ExportDataMapper;
import com.viontech.fanxing.query.service.adapter.ExportDataService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -15,6 +16,7 @@ import javax.annotation.Resource;
import java.io.File;
@Service
@Slf4j
public class ExportDataServiceImpl extends BaseServiceImpl<ExportData> implements ExportDataService {
@Resource
private ExportDataMapper exportDataMapper;
......@@ -35,6 +37,9 @@ public class ExportDataServiceImpl extends BaseServiceImpl<ExportData> implement
try {
if (file.exists()) {
FileUtils.deleteDirectory(file);
log.info("删除目录完成:[{}]", file.getPath());
} else {
log.error("找不到目录:[{}]", file.getPath());
}
} catch (Exception e) {
throw new FanXingException("无法删除目录:{[]}", file.getPath());
......
......@@ -40,7 +40,7 @@ public class VAServerController {
vaServerService.registerVAServer(vaServerInfo);
HashMap<String, Object> result = new HashMap<>();
result.put("code", 200);
result.put("msg", "success");
result.put("msg", "成功");
result.put("resultRecvUrl", vionConfig.getReceiveResultPrefixPath() + "/fanxing-forward/result");
result.put("videoUploadUrl", vionConfig.getReceiveResultPrefixPath() + "/fanxing-forward/result/video");
return result;
......@@ -53,7 +53,7 @@ public class VAServerController {
public Object keepalive(@PathVariable String devId) {
log.info("收到心跳消息:{}", devId);
vaServerService.keepalive(devId);
return JsonMessageUtil.getSuccessJsonMsg("success");
return JsonMessageUtil.getSuccessJsonMsg("成功");
}
@GetMapping("/vaServerInfo")
......@@ -77,7 +77,7 @@ public class VAServerController {
public Object startAnalyzeStream(@RequestBody JSONObject object) {
String taskUnid = object.getString("taskUnid");
String s = vaServerService.startAnalyzeStream(taskUnid);
return JsonMessageUtil.getSuccessJsonMsg("success", s);
return JsonMessageUtil.getSuccessJsonMsg("成功", s);
}
/**
......
......@@ -80,7 +80,7 @@ public class TaskController extends TaskBaseController {
} catch (DuplicateKeyException e) {
return JsonMessageUtil.getErrorJsonMsg("任务名称重复:" + taskVo.getName());
}
return JsonMessageUtil.getSuccessJsonMsg("success", taskVo);
return JsonMessageUtil.getSuccessJsonMsg("成功", taskVo);
}
@Override
......@@ -89,7 +89,7 @@ public class TaskController extends TaskBaseController {
taskVo.setId(id);
taskVo = taskService.updateTask(taskVo);
opsClientService.addLog("修改任务:" + taskVo.getName());
return JsonMessageUtil.getSuccessJsonMsg("success", taskVo);
return JsonMessageUtil.getSuccessJsonMsg("成功", taskVo);
}
@Override
......@@ -99,7 +99,7 @@ public class TaskController extends TaskBaseController {
if (task != null) {
taskService.removeTask(id);
opsClientService.addLog("删除任务:" + task.getName());
return JsonMessageUtil.getSuccessJsonMsg();
return JsonMessageUtil.getSuccessJsonMsg("删除任务成功");
} else {
return JsonMessageUtil.getErrorJsonMsg("任务不存在");
}
......@@ -109,13 +109,13 @@ public class TaskController extends TaskBaseController {
@GetMapping("/{id}/start")
public JsonMessageUtil.JsonMessage<TaskVo> startTask(@PathVariable("id") Long id) {
taskService.startTask(id);
return JsonMessageUtil.getSuccessJsonMsg();
return JsonMessageUtil.getSuccessJsonMsg("启动任务成功");
}
@GetMapping("/{id}/stop")
public JsonMessageUtil.JsonMessage stopTask(@PathVariable("id") Long id) {
taskService.stopTask(id);
return JsonMessageUtil.getSuccessJsonMsg();
return JsonMessageUtil.getSuccessJsonMsg("停止任务成功");
}
@GetMapping("overview")
......@@ -205,6 +205,8 @@ public class TaskController extends TaskBaseController {
Task task = taskService.selectByPrimaryKey(taskId);
Assert.notNull(task, "找不到对应任务");
String scene = task.getScene();
String channelUnid = task.getChannelUnid();
Channel channel = opsClientService.getChannelByChannelUnid(channelUnid);
JSONArray sceneArr = JSON.parseArray(scene);
JSONObject sceneNeed = null;
for (int i = 0; i < sceneArr.size(); i++) {
......@@ -224,10 +226,10 @@ public class TaskController extends TaskBaseController {
result.put("calibration", sceneNeed.getJSONObject("calibration"));
String s = result.toString();
byte[] bytes = s.getBytes(StandardCharsets.UTF_8);
String channelName = channel == null ? "未知" : channel.getName();
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
response.setHeader("Content-Disposition",
"attachment;filename=" + sceneUnid + ".json");
"attachment;filename=" + channelName + "_" + sceneUnid + ".json");
IOUtils.write(bytes, response.getOutputStream());
}
......@@ -269,7 +271,7 @@ public class TaskController extends TaskBaseController {
message.setData(build);
return message;
} else {
return JsonMessageUtil.getSuccessJsonMsg("success");
return JsonMessageUtil.getSuccessJsonMsg("成功");
}
}
......
......@@ -11,6 +11,7 @@ import com.viontech.fanxing.task.model.TaskData;
import com.viontech.fanxing.task.model.vaserver.VaServerInfo;
import com.viontech.fanxing.task.model.vaserver.VaServerOverViewModel;
import com.viontech.fanxing.task.repository.VAServerRedisRepository;
import lombok.extern.slf4j.Slf4j;
import org.redisson.api.RBucket;
import org.redisson.api.RLock;
import org.redisson.api.RMap;
......@@ -32,6 +33,7 @@ import java.util.regex.Pattern;
*/
@Service
@Slf4j
public class VAServerService {
protected final static Pattern IP_PATTERN = Pattern.compile("((?:1[0-9][0-9]\\.|2[0-4][0-9]\\.|25[0-5]\\.|[1-9][0-9]\\.|[0-9]\\.){3}(?:1[0-9][0-9]|2[0-4][0-9]|25[0-5]|[1-9][0-9]|[0-9]))");
......@@ -303,16 +305,24 @@ public class VAServerService {
if (matcher.find()) {
ip = matcher.group();
}
JSONObject status = vaServerHttpService.status(vaServer);
JSONObject brief = status.getJSONObject("resource").getJSONObject("brief");
status.remove("resource");
JSONObject status = new JSONObject();
JSONObject brief = new JSONObject();
try {
status = vaServerHttpService.status(vaServer);
brief = status.getJSONObject("resource").getJSONObject("brief");
status.remove("resource");
} catch (Exception e) {
log.error("", e);
}
status.put("devId", vaServer.getDevID());
status.put("serviceName", vaServer.getServiceName());
status.put("status", vaServer.getStatus());
status.put("platType", vaServer.getPlatType());
status.put("softVersion", vaServer.getSoftVersion());
status.put("algoVersion", vaServer.getAlgoVersion());
status.put("availableResource", vaServer.getAvailableResources());
status.put("videoResource", vaServer.getVideoResource());
VaServerOverViewModel model = map.computeIfAbsent(ip, x -> new VaServerOverViewModel());
model.setIp(ip).addTotal(brief.getFloat("video_total")).addUsed(brief.getFloat("video_busy")).addInfo(status);
......
......@@ -105,8 +105,7 @@ CREATE TABLE IF NOT EXISTS d_traffic
video_name VARCHAR(256),
status INT NOT NULL DEFAULT 0 COMMENT '状态',
PRIMARY KEY (id, event_time),
INDEX d_traffic_unid_idx (unid),
INDEX d_traffic_select_idx (event_time, event_type, vehicle_type)
KEY `d_traffic__select_idx` (`event_time`, `event_type`, `vehicle_type`)
);
-- d_traffic_face
......@@ -121,7 +120,7 @@ CREATE TABLE IF NOT EXISTS d_traffic_face
sex SMALLINT NOT NULL DEFAULT 0,
upper_color VARCHAR(36),
lower_color VARCHAR(36),
INDEX traffic_face_traffic_id_idx (traffic_id),
KEY `d_traffic_face__traffic_id_index` (`traffic_id`),
PRIMARY KEY (id, event_time)
);
......@@ -156,7 +155,7 @@ CREATE TABLE IF NOT EXISTS d_flow_data
time_occupy FLOAT,
status INT NOT NULL DEFAULT 0 COMMENT '状态',
PRIMARY KEY (id, event_time),
INDEX flow_data_select_idx (flow_event_id)
KEY `d_flow_data__flow_event_id_index` (`flow_event_id`)
);
......@@ -179,7 +178,7 @@ CREATE TABLE IF NOT EXISTS d_flow_event
pics VARCHAR(2048),
video_name VARCHAR(256),
PRIMARY KEY (id, event_time),
INDEX flow_event_select_idx (event_time, event_type, channel_unid, task_id)
KEY `d_flow_event__select_index` (`event_time`, `channel_unid`, `task_id`)
);
......@@ -201,7 +200,7 @@ CREATE TABLE IF NOT EXISTS d_behavior
task_name VARCHAR(128),
event_data_num VARCHAR(36),
PRIMARY KEY (id, event_time),
INDEX behavior_select_idx (event_time, event_type, event_cate)
KEY `behavior_select_idx` (`event_time`, `event_type`, `event_cate`)
);
-- s_dict_cate
......@@ -214,7 +213,7 @@ CREATE TABLE IF NOT EXISTS s_dict_cate
code VARCHAR(36) COMMENT 'cate编码',
name VARCHAR(36) NOT NULL COMMENT 'cate名称',
note VARCHAR(36) COMMENT '注释',
INDEX s_dict_cate_type_idx (type)
KEY `s_dict_cate_type_idx` (`type`)
);
......@@ -230,7 +229,7 @@ CREATE TABLE IF NOT EXISTS s_dict_code
name VARCHAR(36) NOT NULL COMMENT 'code名称',
note VARCHAR(36) COMMENT '注释',
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)
KEY `s_dict_code_idx` (`cate_id`)
);
-- s_channel
......@@ -260,7 +259,7 @@ CREATE TABLE IF NOT EXISTS s_channel
latitude FLOAT,
status INT NOT NULL DEFAULT 0,
create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
INDEX s_channel_unid_idx (unid)
KEY `s_channel_unid_idx` (`unid`)
);
-- r_channel_tag
......@@ -272,8 +271,8 @@ CREATE TABLE IF NOT EXISTS r_channel_tag
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),
INDEX r_channel_tag_tag_id_idx (tag)
KEY `r_channel_tag_channel_id_idx` (`channel_id`),
KEY `r_channel_tag_tag_id_idx` (`tag`)
);
-- s_content
......@@ -314,7 +313,8 @@ CREATE TABLE IF NOT EXISTS s_log
username VARCHAR(32) COMMENT '用户名',
log_type int not null default -1 comment '操作类型',
content varchar(256) COMMENT '内容',
INDEX s_log_date_time_idx (date_time)
KEY `s_log__date_time_username_idx` (`date_time`, `username`),
KEY `s_log__date_time_log_type_index` (`date_time`, `log_type`)
);
-- 数据导出表
......@@ -329,25 +329,26 @@ CREATE TABLE IF NOT exists d_export_data
with_video int not null default 0 comment '下载视频',
param varchar(256) not null comment '参数',
path varchar(512) comment '导出文件列表',
status int not null default 0 comment '状态'
status int not null default 0 comment '状态',
key `d_export_data__create_time_type_index` (`create_time`, `type`)
);
-- 分表
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('yyyy-MM-dd'))
);
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('yyyy-MM-dd'))
);
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('yyyy-MM-dd'))
);
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('yyyy-MM-dd'))
);
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('yyyy-MM-dd'))
);
delimiter $$
......@@ -356,7 +357,6 @@ $$
CREATE PROCEDURE timestamp_partition(v_table_name VARCHAR(128), v_schema VARCHAR(128))
BEGIN
DECLARE v_sysdate date; # 声明 当前时间
DECLARE v_mindate date; # 声明 目前分区的最小值
DECLARE v_maxdate date; # 声明 目前分区值中的最大值
DECLARE v_pt varchar(20); # 声明 分区名称 数字部分
DECLARE v_maxval varchar(20);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!