Commit 42da1656 by xmh

<feat> 数据统计值写入和查询

<feat> 数据统计值表 d_data_statistic
1 parent beb46b1c
Showing 25 changed files with 560 additions and 30 deletions
......@@ -9,7 +9,6 @@ import java.io.Serializable;
public abstract class BaseModel implements Serializable {
private Long count;
private Long id;
private Integer hour;
public BaseModel() {
super();
......@@ -30,13 +29,4 @@ public abstract class BaseModel implements Serializable {
public void setId(Long id) {
this.id = id;
}
public Integer getHour() {
return hour;
}
public BaseModel setHour(Integer hour) {
this.hour = hour;
return this;
}
}
package com.viontech.fanxing.commons.model;
import com.viontech.fanxing.commons.base.BaseModel;
import java.util.Date;
public class DataStatistic extends BaseModel {
private Long id;
private Long taskId;
private String taskName;
private Date date;
private Integer hour;
private Integer traffic;
private Integer behavior;
private Integer flow;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getTaskId() {
return taskId;
}
public void setTaskId(Long taskId) {
this.taskId = taskId;
}
public String getTaskName() {
return taskName;
}
public void setTaskName(String taskName) {
this.taskName = taskName == null ? null : taskName.trim();
}
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
public Integer getHour() {
return hour;
}
public void setHour(Integer hour) {
this.hour = hour;
}
public Integer getTraffic() {
return traffic;
}
public void setTraffic(Integer traffic) {
this.traffic = traffic;
}
public Integer getBehavior() {
return behavior;
}
public void setBehavior(Integer behavior) {
this.behavior = behavior;
}
public Integer getFlow() {
return flow;
}
public void setFlow(Integer flow) {
this.flow = flow;
}
}
\ No newline at end of file
package com.viontech.fanxing.commons.vo;
import com.viontech.fanxing.commons.model.DataStatistic;
import com.viontech.fanxing.commons.vobase.DataStatisticVoBase;
public class DataStatisticVo extends DataStatisticVoBase {
public DataStatisticVo() {
super();
}
public DataStatisticVo(DataStatistic dataStatistic) {
super(dataStatistic);
}
}
\ No newline at end of file
......@@ -5,7 +5,6 @@ import com.alibaba.fastjson.JSONObject;
import com.viontech.fanxing.commons.model.FlowData;
import com.viontech.fanxing.commons.model.FlowEvent;
import com.viontech.fanxing.forward.model.TrafficFlowContent;
import com.viontech.fanxing.forward.util.CacheUtils;
import com.viontech.keliu.util.DateUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
......@@ -15,7 +14,6 @@ import org.springframework.batch.item.ItemStream;
import org.springframework.batch.item.ItemStreamException;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
......@@ -41,6 +39,7 @@ public class TrafficFlowProcessor implements ItemProcessor<JSONObject, TrafficFl
log.info("收到 flow 消息 , 任务名称:[{}] , 消息ID:[{}]", taskName, eventRefid);
TrafficFlowContent content = new TrafficFlowContent();
content.setTaskName(taskName);
FlowEvent flowEvent = new FlowEvent();
flowEvent.setJsonData(item.toJSONString());
content.setFlowEvent(flowEvent);
......
......@@ -41,6 +41,7 @@ public class TrafficProcessor implements ItemProcessor<JSONObject, TrafficConten
log.info("收到 traffic 消息 , 任务名称:[{}] , 消息ID:[{}]", taskName, eventRefid);
TrafficContent content = new TrafficContent();
content.setTaskName(taskName);
Traffic traffic = new Traffic();
traffic.setJsonData(item.toJSONString());
content.setTraffic(traffic);
......
package com.viontech.fanxing.forward.batch.writer;
import com.viontech.fanxing.commons.model.Behavior;
import com.viontech.fanxing.forward.util.DataStatisticUtil;
import org.springframework.batch.item.ItemWriter;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.jdbc.core.namedparam.SqlParameterSource;
......@@ -25,9 +26,15 @@ public class BehaviorWriter implements ItemWriter<Behavior> {
":taskId,:eventType,:eventCate,:eventRefid,:eventTime,:eventData,:pics,:video,:channelUnid,:taskName,:eventDataNum)";
@Resource
private NamedParameterJdbcTemplate namedParameterJdbcTemplate;
@Resource
private DataStatisticUtil dataStatisticUtil;
@Override
public void write(List<? extends Behavior> items) throws Exception {
for (Behavior item : items) {
dataStatisticUtil.increase(item.getTaskId(), item.getTaskName(), item.getEventTime(), "behavior");
}
SqlParameterSource[] batchParam = SqlParameterSourceUtils.createBatch(items);
namedParameterJdbcTemplate.batchUpdate(INSERT_BEHAVIOR, batchParam);
}
......
......@@ -3,6 +3,7 @@ package com.viontech.fanxing.forward.batch.writer;
import com.viontech.fanxing.commons.model.FlowData;
import com.viontech.fanxing.commons.model.FlowEvent;
import com.viontech.fanxing.forward.model.TrafficFlowContent;
import com.viontech.fanxing.forward.util.DataStatisticUtil;
import org.springframework.batch.item.ItemWriter;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.jdbc.core.namedparam.SqlParameterSource;
......@@ -23,15 +24,13 @@ import java.util.List;
@Component
public class TrafficFlowWriter implements ItemWriter<TrafficFlowContent> {
private final static String INSERT_FLOW_EVENT = "insert into d_flow_event (" +
"task_id,event_type,event_time,event_id,device_code,device_name,location_code,location_name,json_data,pics,video_name,channel_unid) values(" +
":taskId,:eventType,:eventTime,:eventId,:deviceCode,:deviceName,:locationCode,:locationName,:jsonData,:pics,:videoName,:channelUnid)";
private final static String INSERT_FLOW_DATA = "insert into d_flow_data (" +
"flow_event_id,task_id,detection_type,road_code,direction_code,sample_dura,sample_num,velocity,velocity_unit,occupy,distance,queue_length,region_id,region_name,position_content,head_content,area,density,sample_num_in,sample_num_out,event_time,dist_time,time_occupy) values (" +
":flowEventId,:taskId,:detectionType,:roadCode,:directionCode,:sampleDura,:sampleNum,:velocity,:velocityUnit,:occupy,:distance,:queueLength,:regionId,:regionName,:positionContent,:headContent,:area,:density,:sampleNumIn,:sampleNumOut,:eventTime,:distTime,:timeOccupy)";
private final static String INSERT_FLOW_EVENT = "insert into d_flow_event (" + "task_id,event_type,event_time,event_id,device_code,device_name,location_code,location_name,json_data,pics,video_name,channel_unid) values(" + ":taskId,:eventType,:eventTime,:eventId,:deviceCode,:deviceName,:locationCode,:locationName,:jsonData,:pics,:videoName,:channelUnid)";
private final static String INSERT_FLOW_DATA = "insert into d_flow_data (" + "flow_event_id,task_id,detection_type,road_code,direction_code,sample_dura,sample_num,velocity,velocity_unit,occupy,distance,queue_length,region_id,region_name,position_content,head_content,area,density,sample_num_in,sample_num_out,event_time,dist_time,time_occupy) values (" + ":flowEventId,:taskId,:detectionType,:roadCode,:directionCode,:sampleDura,:sampleNum,:velocity,:velocityUnit,:occupy,:distance,:queueLength,:regionId,:regionName,:positionContent,:headContent,:area,:density,:sampleNumIn,:sampleNumOut,:eventTime,:distTime,:timeOccupy)";
@Resource
private NamedParameterJdbcTemplate namedParameterJdbcTemplate;
@Resource
private DataStatisticUtil dataStatisticUtil;
@Override
public void write(List<? extends TrafficFlowContent> list) {
......@@ -39,6 +38,8 @@ public class TrafficFlowWriter implements ItemWriter<TrafficFlowContent> {
List<FlowData> trafficFlowData = item.getFlowData();
FlowEvent flowEvent = item.getFlowEvent();
dataStatisticUtil.increase(flowEvent.getTaskId(), item.getTaskName(), flowEvent.getEventTime(), "flow");
SqlParameterSource flowEventParam = SqlParameterSourceUtils.createBatch(flowEvent)[0];
GeneratedKeyHolder generatedKeyHolder = new GeneratedKeyHolder();
namedParameterJdbcTemplate.update(INSERT_FLOW_EVENT, flowEventParam, generatedKeyHolder);
......
......@@ -3,6 +3,7 @@ package com.viontech.fanxing.forward.batch.writer;
import com.viontech.fanxing.commons.model.Traffic;
import com.viontech.fanxing.commons.model.TrafficFace;
import com.viontech.fanxing.forward.model.TrafficContent;
import com.viontech.fanxing.forward.util.DataStatisticUtil;
import org.springframework.batch.item.ItemWriter;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.jdbc.core.namedparam.SqlParameterSource;
......@@ -25,20 +26,22 @@ import java.util.stream.Collectors;
@Component
public class TrafficWriter implements ItemWriter<TrafficContent> {
private final static String INSERT_TRAFFIC = "insert into d_traffic (" +
"task_id,event_cate,event_type,event_time,channel_unid,plate_color,plate_number,location_code,location_name,lane_code,direction_code,vehicle_type,vehicle_color,vehicle_logo,illegal_code,illegal_state,feature_annual_inspection_mark,feature_pendant,feature_decoration,feature_sun_shield,xcycle_type,event_id,special_type,with_helmet,json_data,pics,video_name,company) values(" +
":taskId,:eventCate,:eventType,:eventTime,:channelUnid,:plateColor,:plateNumber,:locationCode,:locationName,:laneCode,:directionCode,:vehicleType,:vehicleColor,:vehicleLogo,:illegalCode,:illegalState,:featureAnnualInspectionMark,:featurePendant,:featureDecoration,:featureSunShield,:xcycleType,:eventId,:specialType,:withHelmet,:jsonData,:pics,:videoName,:company)";
private final static String INSERT_TRAFFIC_FACE = "insert into d_traffic_face (" +
"traffic_id,state,sex,upper_color,lower_color,event_time) values (:trafficId,:state,:sex,:upperColor,:lowerColor,:eventTime)";
private final static String INSERT_TRAFFIC = "insert into d_traffic (" + "task_id,event_cate,event_type,event_time,channel_unid,plate_color,plate_number,location_code,location_name,lane_code,direction_code,vehicle_type,vehicle_color,vehicle_logo,illegal_code,illegal_state,feature_annual_inspection_mark,feature_pendant,feature_decoration,feature_sun_shield,xcycle_type,event_id,special_type,with_helmet,json_data,pics,video_name,company) values(" + ":taskId,:eventCate,:eventType,:eventTime,:channelUnid,:plateColor,:plateNumber,:locationCode,:locationName,:laneCode,:directionCode,:vehicleType,:vehicleColor,:vehicleLogo,:illegalCode,:illegalState,:featureAnnualInspectionMark,:featurePendant,:featureDecoration,:featureSunShield,:xcycleType,:eventId,:specialType,:withHelmet,:jsonData,:pics,:videoName,:company)";
private final static String INSERT_TRAFFIC_FACE = "insert into d_traffic_face (" + "traffic_id,state,sex,upper_color,lower_color,event_time) values (:trafficId,:state,:sex,:upperColor,:lowerColor,:eventTime)";
@Resource
private NamedParameterJdbcTemplate namedParameterJdbcTemplate;
@Resource
private DataStatisticUtil dataStatisticUtil;
@Override
public void write(List<? extends TrafficContent> list) throws Exception {
List<TrafficContent> withFace = new ArrayList<>();
List<TrafficContent> withoutFace = new ArrayList<>();
for (TrafficContent item : list) {
dataStatisticUtil.increase(item.getTraffic().getTaskId(), item.getTaskName(), item.getTraffic().getEventTime(), "traffic");
if (item.getTrafficFaces() != null && item.getTrafficFaces().size() > 0) {
withFace.add(item);
} else {
......
......@@ -16,6 +16,7 @@ import java.util.List;
@Data
public class TrafficContent {
private String taskName;
private Traffic traffic;
private List<TrafficFace> trafficFaces;
......
......@@ -16,6 +16,7 @@ import java.util.List;
@Data
public class TrafficFlowContent {
private String taskName;
private FlowEvent flowEvent;
private List<FlowData> flowData;
......
package com.viontech.fanxing.forward.runner;
import com.viontech.fanxing.commons.service.RedisService;
import lombok.extern.slf4j.Slf4j;
import org.redisson.api.RMap;
import org.redisson.api.RedissonClient;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
/**
* .
*
* @author 谢明辉
* @date 2022/2/10
*/
@Component
@Slf4j
public class DataStatisticPersistenceRunner {
@Resource
private RedisService redisService;
@Resource
private JdbcTemplate jdbcTemplate;
@Scheduled(cron = "10 0/2 * * * ?")
public void run() {
try {
RedissonClient client = redisService.getClient();
Iterable<String> keys = client.getKeys().getKeysByPattern("forward:dataStatistic:*");
for (String key : keys) {
try {
RMap<String, Object> map = client.getMap(key);
Long taskId = (Long) map.get("task_id");
String localDateStr = (String) map.get("date");
LocalDate localDate = LocalDate.parse(localDateStr, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
Integer hour = (Integer) map.get("hour");
String taskName = (String) map.get("task_name");
Integer traffic = (Integer) map.get("traffic");
Integer flow = (Integer) map.get("flow");
Integer behavior = (Integer) map.get("behavior");
if (exists(taskId, localDate, hour)) {
update(taskId, localDate, hour, traffic, flow, behavior);
} else {
insert(taskId, localDate, hour, taskName, traffic, flow, behavior);
}
} catch (Exception e) {
log.error("", e);
}
}
} catch (Exception e) {
log.error("", e);
}
}
private void insert(Long taskId, LocalDate localDate, Integer hour, String taskName, Integer traffic, Integer flow, Integer behavior) {
jdbcTemplate.update("insert into d_data_statistic(task_id, task_name, date, hour, traffic, behavior, flow) values(?,?,?,?,?,?,?)", taskId, taskName, localDate, hour, traffic, behavior, flow);
}
private void update(Long taskId, LocalDate localDate, Integer hour, Integer traffic, Integer flow, Integer behavior) {
jdbcTemplate.update("update d_data_statistic set traffic=?,flow=?,behavior=? where date=? and task_id=? and hour=?", traffic, flow, behavior, localDate, taskId, hour);
}
private boolean exists(Long taskId, LocalDate localDate, Integer hour) {
Long count = jdbcTemplate.queryForObject("select count(*) from d_data_statistic where date=? and task_id=? and hour=?", Long.class, localDate, taskId, hour);
return count != null && count > 0;
}
}
package com.viontech.fanxing.forward.util;
import cn.hutool.core.date.DateUtil;
import com.viontech.fanxing.commons.model.DataStatistic;
import com.viontech.fanxing.commons.service.RedisService;
import lombok.extern.slf4j.Slf4j;
import org.redisson.api.RLock;
import org.redisson.api.RMap;
import org.redisson.api.RedissonClient;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.List;
import java.util.concurrent.TimeUnit;
/**
* .
*
* @author 谢明辉
* @date 2022/2/10
*/
@Component
@Slf4j
public class DataStatisticUtil {
@Resource
private RedisService redisService;
@Resource
private JdbcTemplate jdbcTemplate;
public void increase(Long taskId, String taskName, Date date, String type) {
try {
LocalDateTime localDateTime = DateUtil.toLocalDateTime(date).plusHours(8);
RedissonClient client = redisService.getClient();
String redisKey = getRedisKey(taskId, localDateTime);
RMap<String, Object> map = client.getMap(redisKey);
if (!map.isExists()) {
RLock lockMust = redisService.getLockMust("lock:" + redisKey);
if (!map.isExists()) {
loadDataStatistic(taskId, taskName, localDateTime, redisKey);
}
lockMust.forceUnlock();
}
map.addAndGet(type, 1);
map.expire(2, TimeUnit.HOURS);
} catch (Exception e) {
log.error("写入redis失败", e);
}
}
private String getRedisKey(Long taskId, LocalDateTime date) {
String str = date.format(DateTimeFormatter.ofPattern("yyyyMMddHH"));
return "forward:dataStatistic:" + taskId + ":" + str;
}
public void loadDataStatistic(Long taskId, String taskName, LocalDateTime dateTime, String redisKey) {
LocalDate localDate = dateTime.toLocalDate();
int hour = dateTime.getHour();
List<DataStatistic> query = jdbcTemplate.query("select * from d_data_statistic where date=? and task_id=?", new BeanPropertyRowMapper<>(DataStatistic.class), localDate, hour);
RMap<String, Object> map = redisService.getClient().getMap(redisKey);
map.put("task_id", taskId);
String format = DateTimeFormatter.ofPattern("yyyy-MM-dd").format(dateTime);
map.put("date", format);
map.put("hour", hour);
map.put("task_name", taskName);
if (query.size() > 0) {
DataStatistic dataStatistic = query.get(0);
map.addAndGet("traffic", dataStatistic.getTraffic());
map.addAndGet("flow", dataStatistic.getFlow());
map.addAndGet("behavior", dataStatistic.getBehavior());
} else {
map.addAndGet("traffic", 0);
map.addAndGet("flow", 0);
map.addAndGet("behavior", 0);
}
}
}
......@@ -4,6 +4,7 @@ import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.ArrayUtil;
import com.viontech.fanxing.commons.config.VionConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Profile;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
......@@ -23,6 +24,7 @@ import java.time.ZoneOffset;
@Component
@Slf4j
@Profile("pro")
public class CleanJob {
@Resource
......
create table if not exists d_data_statistic
(
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
task_id bigint not null comment '任务ID',
task_name varchar(128) not null comment '任务名称',
date date not null default (current_date) comment '日期',
hour int not null comment '小时',
traffic int not null default 0 comment '交通数据量',
behavior int not null default 0 comment '事件数据量',
flow int not null default 0 comment '流量数据量',
key `d_data_statistic_idx` (`date`, `task_id`)
);
package com.viontech.fanxing.query.controller.base;
import com.viontech.fanxing.commons.base.BaseController;
import com.viontech.fanxing.commons.base.BaseExample;
import com.viontech.fanxing.commons.base.BaseService;
import com.viontech.fanxing.commons.model.DataStatistic;
import com.viontech.fanxing.commons.model.DataStatisticExample;
import com.viontech.fanxing.commons.vo.DataStatisticVo;
import com.viontech.fanxing.query.service.adapter.DataStatisticService;
import javax.annotation.Resource;
public abstract class DataStatisticBaseController extends BaseController<DataStatistic, DataStatisticVo> {
@Resource
protected DataStatisticService dataStatisticService;
@Override
protected BaseExample getExample(DataStatisticVo dataStatisticVo, int type) {
DataStatisticExample dataStatisticExample = new DataStatisticExample();
DataStatisticExample.Criteria criteria = dataStatisticExample.createCriteria();
if (dataStatisticVo.getId() != null) {
criteria.andIdEqualTo(dataStatisticVo.getId());
}
if (dataStatisticVo.getId_arr() != null) {
criteria.andIdIn(dataStatisticVo.getId_arr());
}
if (dataStatisticVo.getId_gt() != null) {
criteria.andIdGreaterThan(dataStatisticVo.getId_gt());
}
if (dataStatisticVo.getId_lt() != null) {
criteria.andIdLessThan(dataStatisticVo.getId_lt());
}
if (dataStatisticVo.getId_gte() != null) {
criteria.andIdGreaterThanOrEqualTo(dataStatisticVo.getId_gte());
}
if (dataStatisticVo.getId_lte() != null) {
criteria.andIdLessThanOrEqualTo(dataStatisticVo.getId_lte());
}
if (dataStatisticVo.getTaskId() != null) {
criteria.andTaskIdEqualTo(dataStatisticVo.getTaskId());
}
if (dataStatisticVo.getTaskId_arr() != null) {
criteria.andTaskIdIn(dataStatisticVo.getTaskId_arr());
}
if (dataStatisticVo.getTaskId_gt() != null) {
criteria.andTaskIdGreaterThan(dataStatisticVo.getTaskId_gt());
}
if (dataStatisticVo.getTaskId_lt() != null) {
criteria.andTaskIdLessThan(dataStatisticVo.getTaskId_lt());
}
if (dataStatisticVo.getTaskId_gte() != null) {
criteria.andTaskIdGreaterThanOrEqualTo(dataStatisticVo.getTaskId_gte());
}
if (dataStatisticVo.getTaskId_lte() != null) {
criteria.andTaskIdLessThanOrEqualTo(dataStatisticVo.getTaskId_lte());
}
if (dataStatisticVo.getTaskName() != null) {
criteria.andTaskNameEqualTo(dataStatisticVo.getTaskName());
}
if (dataStatisticVo.getTaskName_arr() != null) {
criteria.andTaskNameIn(dataStatisticVo.getTaskName_arr());
}
if (dataStatisticVo.getTaskName_like() != null) {
criteria.andTaskNameLike(dataStatisticVo.getTaskName_like());
}
if (dataStatisticVo.getDate() != null) {
criteria.andDateEqualTo(dataStatisticVo.getDate());
}
if (dataStatisticVo.getDate_arr() != null) {
criteria.andDateIn(dataStatisticVo.getDate_arr());
}
if (dataStatisticVo.getDate_gt() != null) {
criteria.andDateGreaterThan(dataStatisticVo.getDate_gt());
}
if (dataStatisticVo.getDate_lt() != null) {
criteria.andDateLessThan(dataStatisticVo.getDate_lt());
}
if (dataStatisticVo.getDate_gte() != null) {
criteria.andDateGreaterThanOrEqualTo(dataStatisticVo.getDate_gte());
}
if (dataStatisticVo.getDate_lte() != null) {
criteria.andDateLessThanOrEqualTo(dataStatisticVo.getDate_lte());
}
if (dataStatisticVo.getHour() != null) {
criteria.andHourEqualTo(dataStatisticVo.getHour());
}
if (dataStatisticVo.getHour_arr() != null) {
criteria.andHourIn(dataStatisticVo.getHour_arr());
}
if (dataStatisticVo.getHour_gt() != null) {
criteria.andHourGreaterThan(dataStatisticVo.getHour_gt());
}
if (dataStatisticVo.getHour_lt() != null) {
criteria.andHourLessThan(dataStatisticVo.getHour_lt());
}
if (dataStatisticVo.getHour_gte() != null) {
criteria.andHourGreaterThanOrEqualTo(dataStatisticVo.getHour_gte());
}
if (dataStatisticVo.getHour_lte() != null) {
criteria.andHourLessThanOrEqualTo(dataStatisticVo.getHour_lte());
}
if (dataStatisticVo.getTraffic() != null) {
criteria.andTrafficEqualTo(dataStatisticVo.getTraffic());
}
if (dataStatisticVo.getTraffic_arr() != null) {
criteria.andTrafficIn(dataStatisticVo.getTraffic_arr());
}
if (dataStatisticVo.getTraffic_gt() != null) {
criteria.andTrafficGreaterThan(dataStatisticVo.getTraffic_gt());
}
if (dataStatisticVo.getTraffic_lt() != null) {
criteria.andTrafficLessThan(dataStatisticVo.getTraffic_lt());
}
if (dataStatisticVo.getTraffic_gte() != null) {
criteria.andTrafficGreaterThanOrEqualTo(dataStatisticVo.getTraffic_gte());
}
if (dataStatisticVo.getTraffic_lte() != null) {
criteria.andTrafficLessThanOrEqualTo(dataStatisticVo.getTraffic_lte());
}
if (dataStatisticVo.getBehavior() != null) {
criteria.andBehaviorEqualTo(dataStatisticVo.getBehavior());
}
if (dataStatisticVo.getBehavior_arr() != null) {
criteria.andBehaviorIn(dataStatisticVo.getBehavior_arr());
}
if (dataStatisticVo.getBehavior_gt() != null) {
criteria.andBehaviorGreaterThan(dataStatisticVo.getBehavior_gt());
}
if (dataStatisticVo.getBehavior_lt() != null) {
criteria.andBehaviorLessThan(dataStatisticVo.getBehavior_lt());
}
if (dataStatisticVo.getBehavior_gte() != null) {
criteria.andBehaviorGreaterThanOrEqualTo(dataStatisticVo.getBehavior_gte());
}
if (dataStatisticVo.getBehavior_lte() != null) {
criteria.andBehaviorLessThanOrEqualTo(dataStatisticVo.getBehavior_lte());
}
if (dataStatisticVo.getFlow() != null) {
criteria.andFlowEqualTo(dataStatisticVo.getFlow());
}
if (dataStatisticVo.getFlow_arr() != null) {
criteria.andFlowIn(dataStatisticVo.getFlow_arr());
}
if (dataStatisticVo.getFlow_gt() != null) {
criteria.andFlowGreaterThan(dataStatisticVo.getFlow_gt());
}
if (dataStatisticVo.getFlow_lt() != null) {
criteria.andFlowLessThan(dataStatisticVo.getFlow_lt());
}
if (dataStatisticVo.getFlow_gte() != null) {
criteria.andFlowGreaterThanOrEqualTo(dataStatisticVo.getFlow_gte());
}
if (dataStatisticVo.getFlow_lte() != null) {
criteria.andFlowLessThanOrEqualTo(dataStatisticVo.getFlow_lte());
}
return dataStatisticExample;
}
@Override
protected BaseService<DataStatistic> getService() {
return dataStatisticService;
}
}
\ No newline at end of file
package com.viontech.fanxing.query.controller.web;
import com.viontech.fanxing.commons.base.BaseExample;
import com.viontech.fanxing.commons.model.DataStatisticExample;
import com.viontech.fanxing.commons.vo.DataStatisticVo;
import com.viontech.fanxing.query.controller.base.DataStatisticBaseController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping("/dataStatistics")
public class DataStatisticController extends DataStatisticBaseController {
@Override
protected BaseExample getExample(DataStatisticVo dataStatisticVo, int type) {
DataStatisticExample dataStatisticExample = (DataStatisticExample) super.getExample(dataStatisticVo, type);
return dataStatisticExample;
}
}
\ No newline at end of file
package com.viontech.fanxing.query.mapper;
import com.viontech.fanxing.commons.base.BaseMapper;
import com.viontech.fanxing.commons.model.DataStatistic;
import com.viontech.fanxing.commons.model.DataStatisticExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface DataStatisticMapper extends BaseMapper {
int countByExample(DataStatisticExample example);
int deleteByExample(DataStatisticExample example);
int deleteByPrimaryKey(Long id);
int insert(DataStatistic record);
int insertSelective(DataStatistic record);
List<DataStatistic> selectByExample(DataStatisticExample example);
DataStatistic selectByPrimaryKey(Long id);
int updateByExampleSelective(@Param("record") DataStatistic record, @Param("example") DataStatisticExample example);
int updateByExample(@Param("record") DataStatistic record, @Param("example") DataStatisticExample example);
int updateByPrimaryKeySelective(DataStatistic record);
int updateByPrimaryKey(DataStatistic record);
}
\ No newline at end of file
......@@ -14,9 +14,9 @@ import lombok.Setter;
@Setter
public class DataOverViewModel {
private Long taskId;
private Long traffic = 0L;
private Long flow = 0L;
private Long behavior = 0L;
private Integer traffic = 0;
private Integer flow = 0;
private Integer behavior = 0;
private Integer hour;
private String taskName;
private Integer effectiveAnalysisTime;
......
package com.viontech.fanxing.query.service.adapter;
import com.viontech.fanxing.commons.base.BaseService;
import com.viontech.fanxing.commons.model.DataStatistic;
public interface DataStatisticService extends BaseService<DataStatistic> {
}
\ No newline at end of file
package com.viontech.fanxing.query.service.impl;
import com.viontech.fanxing.commons.base.BaseMapper;
import com.viontech.fanxing.commons.base.BaseServiceImpl;
import com.viontech.fanxing.commons.model.DataStatistic;
import com.viontech.fanxing.query.mapper.DataStatisticMapper;
import com.viontech.fanxing.query.service.adapter.DataStatisticService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@Service
public class DataStatisticServiceImpl extends BaseServiceImpl<DataStatistic> implements DataStatisticService {
@Resource
private DataStatisticMapper dataStatisticMapper;
@Override
public BaseMapper<DataStatistic> getMapper() {
return dataStatisticMapper;
}
}
\ No newline at end of file
......@@ -5,7 +5,7 @@
<generatorConfiguration>
<!-- 数据库驱动 -->
<classPathEntry location="libs/mysql-connector-java-8.0.25.jar"/>
<context id="DB2Tables" targetRuntime="MyBatis3" defaultModelType="flat" >
<context id="DB2Tables" targetRuntime="MyBatis3" defaultModelType="flat">
<property name="autoDelimitKeywords" value="true"/>
<property name="xmlMergeable" value="false"/>
<property name="endingDelimiter" value="`"/>
......@@ -25,17 +25,20 @@
<property name="forceBigDecimals" value="false"/>
</javaTypeResolver>
<!-- 生成模型的包名和位置-->
<javaModelGenerator targetPackage="com.viontech.fanxing.commons.model" targetProject="F:\mybatis-generator\fanxing-forward">
<javaModelGenerator targetPackage="com.viontech.fanxing.commons.model"
targetProject="F:\mybatis-generator\fanxing-query">
<property name="enableSubPackages" value="true"/>
<property name="trimStrings" value="true"/>
<property name="rootClass" value="com.viontech.fanxing.commons.base.BaseModel"/>
</javaModelGenerator>
<!-- 生成映射文件的包名和位置-->
<sqlMapGenerator targetPackage="com.viontech.fanxing.commons.mapping" targetProject="F:\mybatis-generator\fanxing-forward">
<sqlMapGenerator targetPackage="com.viontech.fanxing.commons.mapping"
targetProject="F:\mybatis-generator\fanxing-query">
<property name="enableSubPackages" value="true"/>
</sqlMapGenerator>
<!-- 生成DAO的包名和位置-->
<javaClientGenerator type="XMLMAPPER" targetPackage="com.viontech.fanxing.query.mapper" targetProject="F:\mybatis-generator\fanxing-forward" >
<javaClientGenerator type="XMLMAPPER" targetPackage="com.viontech.fanxing.query.mapper"
targetProject="F:\mybatis-generator\fanxing-query">
<property name="enableSubPackages" value="true"/>
<property name="rootInterface" value="com.viontech.fanxing.commons.base.BaseMapper"/>
</javaClientGenerator>
......@@ -59,5 +62,9 @@
<table delimitIdentifiers="true" tableName="d_export_data" alias="exportData" domainObjectName="ExportData">
<generatedKey column="id" sqlStatement="JDBC"/>
</table>
<table delimitIdentifiers="true" tableName="d_data_statistic" alias="dataStatistic"
domainObjectName="DataStatistic">
<generatedKey column="id" sqlStatement="JDBC"/>
</table>
</context>
</generatorConfiguration>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!