Commit c8aa9e36 by xmh

运维服务:

1. <feat> 视频通道添加 createTime 和 tag
1 parent 7ef951c1
Showing 18 changed files with 964 additions and 13 deletions
......@@ -2,6 +2,9 @@ package com.viontech.fanxing.commons.model;
import com.viontech.fanxing.commons.base.BaseModel;
import java.util.Date;
import java.util.List;
public class Channel extends BaseModel {
private Long id;
......@@ -37,6 +40,10 @@ public class Channel extends BaseModel {
private Integer status;
private Date createTime;
private List<Long> tags;
public Long getId() {
return id;
}
......@@ -172,4 +179,21 @@ public class Channel extends BaseModel {
public void setStatus(Integer status) {
this.status = status;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public List<Long> getTags() {
return tags;
}
public Channel setTags(List<Long> tags) {
this.tags = tags;
return this;
}
}
\ No newline at end of file
......@@ -2,6 +2,7 @@ package com.viontech.fanxing.commons.model;
import com.viontech.fanxing.commons.base.BaseExample;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
......@@ -1207,6 +1208,66 @@ public class ChannelExample extends BaseExample {
addCriterion("`channel`.`status` not between", value1, value2, "status");
return (Criteria) this;
}
public Criteria andCreateTimeIsNull() {
addCriterion("`channel`.create_time is null");
return (Criteria) this;
}
public Criteria andCreateTimeIsNotNull() {
addCriterion("`channel`.create_time is not null");
return (Criteria) this;
}
public Criteria andCreateTimeEqualTo(Date value) {
addCriterion("`channel`.create_time =", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotEqualTo(Date value) {
addCriterion("`channel`.create_time <>", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThan(Date value) {
addCriterion("`channel`.create_time >", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThanOrEqualTo(Date value) {
addCriterion("`channel`.create_time >=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThan(Date value) {
addCriterion("`channel`.create_time <", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThanOrEqualTo(Date value) {
addCriterion("`channel`.create_time <=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeIn(List<Date> values) {
addCriterion("`channel`.create_time in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotIn(List<Date> values) {
addCriterion("`channel`.create_time not in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeBetween(Date value1, Date value2) {
addCriterion("`channel`.create_time between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotBetween(Date value1, Date value2) {
addCriterion("`channel`.create_time not between", value1, value2, "createTime");
return (Criteria) this;
}
}
public static class ColumnContainer extends ColumnContainerBase {
......@@ -1299,5 +1360,10 @@ public class ChannelExample extends BaseExample {
addColumnStr("`channel`.`status` as `channel_status` ");
return (ColumnContainer) this;
}
public ColumnContainer hasCreateTimeColumn() {
addColumnStr("`channel`.create_time as channel_create_time ");
return (ColumnContainer) this;
}
}
}
\ No newline at end of file
package com.viontech.fanxing.commons.model;
import com.viontech.fanxing.commons.base.BaseModel;
public class ChannelTag extends BaseModel {
private Long id;
private Long channelId;
private Long tagId;
private Channel channel;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getChannelId() {
return channelId;
}
public void setChannelId(Long channelId) {
this.channelId = channelId;
}
public Long getTagId() {
return tagId;
}
public void setTagId(Long tagId) {
this.tagId = tagId;
}
public Channel getChannel() {
return channel;
}
public void setChannel(Channel channel) {
this.channel = channel;
}
}
\ No newline at end of file
package com.viontech.fanxing.commons.vo;
import com.viontech.fanxing.commons.model.ChannelTag;
import com.viontech.fanxing.commons.vobase.ChannelTagVoBase;
public class ChannelTagVo extends ChannelTagVoBase {
public ChannelTagVo() {
super();
}
public ChannelTagVo(ChannelTag channelTag) {
super(channelTag);
}
}
\ No newline at end of file
......@@ -2,12 +2,12 @@ package com.viontech.fanxing.commons.vo;
import com.viontech.fanxing.commons.model.Channel;
import com.viontech.fanxing.commons.vobase.ChannelVoBase;
import net.minidev.json.annotate.JsonIgnore;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
public class ChannelVo extends ChannelVoBase {
@JsonIgnore
private MultipartFile file;
private Boolean tree;
......
package com.viontech.fanxing.commons.vobase;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.viontech.fanxing.commons.base.VoInterface;
import com.viontech.fanxing.commons.model.Channel;
import com.viontech.fanxing.commons.model.ChannelTag;
import java.util.ArrayList;
public class ChannelTagVoBase extends ChannelTag implements VoInterface<ChannelTag> {
private ChannelTag channelTag;
@JsonIgnore
private ArrayList<Long> id_arr;
@JsonIgnore
private Long id_gt;
@JsonIgnore
private Long id_lt;
@JsonIgnore
private Long id_gte;
@JsonIgnore
private Long id_lte;
@JsonIgnore
private ArrayList<Long> channelId_arr;
@JsonIgnore
private Long channelId_gt;
@JsonIgnore
private Long channelId_lt;
@JsonIgnore
private Long channelId_gte;
@JsonIgnore
private Long channelId_lte;
@JsonIgnore
private ArrayList<Long> tagId_arr;
@JsonIgnore
private Long tagId_gt;
@JsonIgnore
private Long tagId_lt;
@JsonIgnore
private Long tagId_gte;
@JsonIgnore
private Long tagId_lte;
public ChannelTagVoBase() {
this(null);
}
public ChannelTagVoBase(ChannelTag channelTag) {
if(channelTag == null) {
channelTag = new ChannelTag();
}
this.channelTag = channelTag;
}
@JsonIgnore
public ChannelTag getModel() {
return channelTag;
}
public void setModel(ChannelTag channelTag) {
this.channelTag = channelTag;
}
public ArrayList<Long> getId_arr() {
return id_arr;
}
public void setId_arr(ArrayList<Long> id_arr) {
this.id_arr = id_arr;
}
public Long getId_gt() {
return id_gt;
}
public void setId_gt(Long id_gt) {
this.id_gt = id_gt;
}
public Long getId_lt() {
return id_lt;
}
public void setId_lt(Long id_lt) {
this.id_lt = id_lt;
}
public Long getId_gte() {
return id_gte;
}
public void setId_gte(Long id_gte) {
this.id_gte = id_gte;
}
public Long getId_lte() {
return id_lte;
}
public void setId_lte(Long id_lte) {
this.id_lte = id_lte;
}
public Long getId() {
if(getModel() == null ){
throw new RuntimeException("model is null");
}
return this.getModel().getId();
}
public void setId(Long id) {
if(getModel() == null ){
throw new RuntimeException("model is null");
}
this.getModel().setId(id);
}
public ArrayList<Long> getChannelId_arr() {
return channelId_arr;
}
public void setChannelId_arr(ArrayList<Long> channelId_arr) {
this.channelId_arr = channelId_arr;
}
public Long getChannelId_gt() {
return channelId_gt;
}
public void setChannelId_gt(Long channelId_gt) {
this.channelId_gt = channelId_gt;
}
public Long getChannelId_lt() {
return channelId_lt;
}
public void setChannelId_lt(Long channelId_lt) {
this.channelId_lt = channelId_lt;
}
public Long getChannelId_gte() {
return channelId_gte;
}
public void setChannelId_gte(Long channelId_gte) {
this.channelId_gte = channelId_gte;
}
public Long getChannelId_lte() {
return channelId_lte;
}
public void setChannelId_lte(Long channelId_lte) {
this.channelId_lte = channelId_lte;
}
public Long getChannelId() {
if(getModel() == null ){
throw new RuntimeException("model is null");
}
return this.getModel().getChannelId();
}
public void setChannelId(Long channelId) {
if(getModel() == null ){
throw new RuntimeException("model is null");
}
this.getModel().setChannelId(channelId);
}
public ArrayList<Long> getTagId_arr() {
return tagId_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) {
this.tagId_gt = tagId_gt;
}
public Long getTagId_lt() {
return tagId_lt;
}
public void setTagId_lt(Long tagId_lt) {
this.tagId_lt = tagId_lt;
}
public Long getTagId_gte() {
return tagId_gte;
}
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");
}
return this.getModel().getTagId();
}
public void setTagId(Long tagId) {
if(getModel() == null ){
throw new RuntimeException("model is null");
}
this.getModel().setTagId(tagId);
}
public Channel getChannel() {
if(getModel() == null ){
throw new RuntimeException("model is null");
}
return this.getModel().getChannel();
}
public void setChannel(Channel channel) {
if(getModel() == null ){
throw new RuntimeException("model is null");
}
this.getModel().setChannel(channel);
}
}
\ No newline at end of file
......@@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
import com.viontech.fanxing.commons.base.VoInterface;
import com.viontech.fanxing.commons.model.Channel;
import java.util.ArrayList;
import java.util.Date;
public class ChannelVoBase extends Channel implements VoInterface<Channel> {
private Channel channel;
......@@ -36,6 +37,9 @@ public class ChannelVoBase extends Channel implements VoInterface<Channel> {
private String channelUnid_like;
@JsonIgnore
private Boolean deviceUnid_null;
@JsonIgnore
private ArrayList<String> deviceUnid_arr;
@JsonIgnore
......@@ -206,6 +210,21 @@ public class ChannelVoBase extends Channel implements VoInterface<Channel> {
@JsonIgnore
private Integer status_lte;
@JsonIgnore
private ArrayList<Date> createTime_arr;
@JsonIgnore
private Date createTime_gt;
@JsonIgnore
private Date createTime_lt;
@JsonIgnore
private Date createTime_gte;
@JsonIgnore
private Date createTime_lte;
public ChannelVoBase() {
this(null);
}
......@@ -340,6 +359,14 @@ public class ChannelVoBase extends Channel implements VoInterface<Channel> {
this.getModel().setChannelUnid(channelUnid);
}
public Boolean getDeviceUnid_null() {
return deviceUnid_null;
}
public void setDeviceUnid_null(Boolean deviceUnid_null) {
this.deviceUnid_null = deviceUnid_null;
}
public ArrayList<String> getDeviceUnid_arr() {
return deviceUnid_arr;
}
......@@ -991,4 +1018,58 @@ public class ChannelVoBase extends Channel implements VoInterface<Channel> {
}
this.getModel().setStatus(status);
}
public ArrayList<Date> getCreateTime_arr() {
return createTime_arr;
}
public void setCreateTime_arr(ArrayList<Date> createTime_arr) {
this.createTime_arr = createTime_arr;
}
public Date getCreateTime_gt() {
return createTime_gt;
}
public void setCreateTime_gt(Date createTime_gt) {
this.createTime_gt = createTime_gt;
}
public Date getCreateTime_lt() {
return createTime_lt;
}
public void setCreateTime_lt(Date createTime_lt) {
this.createTime_lt = createTime_lt;
}
public Date getCreateTime_gte() {
return createTime_gte;
}
public void setCreateTime_gte(Date createTime_gte) {
this.createTime_gte = createTime_gte;
}
public Date getCreateTime_lte() {
return createTime_lte;
}
public void setCreateTime_lte(Date createTime_lte) {
this.createTime_lte = createTime_lte;
}
public Date getCreateTime() {
if(getModel() == null ){
throw new RuntimeException("model is null");
}
return this.getModel().getCreateTime();
}
public void setCreateTime(Date createTime) {
if(getModel() == null ){
throw new RuntimeException("model is null");
}
this.getModel().setCreateTime(createTime);
}
}
\ No newline at end of file
package com.viontech.fanxing.ops.controller.base;
import com.viontech.fanxing.commons.base.BaseController;
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.model.ChannelTag;
import com.viontech.fanxing.commons.model.ChannelTagExample;
import com.viontech.fanxing.commons.vo.ChannelTagVo;
import com.viontech.fanxing.ops.mapper.ChannelTagMapper;
import com.viontech.fanxing.ops.service.adapter.ChannelTagService;
import javax.annotation.Resource;
public abstract class ChannelTagBaseController extends BaseController<ChannelTag, ChannelTagVo> {
@Resource
protected ChannelTagService channelTagService;
@Override
protected BaseExample getExample(ChannelTagVo channelTagVo, int type) {
ChannelTagExample channelTagExample = new ChannelTagExample();
ChannelTagExample.Criteria criteria = channelTagExample.createCriteria();
if(channelTagVo.getId() != null) {
criteria.andIdEqualTo(channelTagVo.getId());
}
if(channelTagVo.getId_arr() != null) {
criteria.andIdIn(channelTagVo.getId_arr());
}
if(channelTagVo.getId_gt() != null) {
criteria.andIdGreaterThan(channelTagVo.getId_gt());
}
if(channelTagVo.getId_lt() != null) {
criteria.andIdLessThan(channelTagVo.getId_lt());
}
if(channelTagVo.getId_gte() != null) {
criteria.andIdGreaterThanOrEqualTo(channelTagVo.getId_gte());
}
if(channelTagVo.getId_lte() != null) {
criteria.andIdLessThanOrEqualTo(channelTagVo.getId_lte());
}
if(channelTagVo.getChannelId() != null) {
criteria.andChannelIdEqualTo(channelTagVo.getChannelId());
}
if(channelTagVo.getChannelId_arr() != null) {
criteria.andChannelIdIn(channelTagVo.getChannelId_arr());
}
if(channelTagVo.getChannelId_gt() != null) {
criteria.andChannelIdGreaterThan(channelTagVo.getChannelId_gt());
}
if(channelTagVo.getChannelId_lt() != null) {
criteria.andChannelIdLessThan(channelTagVo.getChannelId_lt());
}
if(channelTagVo.getChannelId_gte() != null) {
criteria.andChannelIdGreaterThanOrEqualTo(channelTagVo.getChannelId_gte());
}
if(channelTagVo.getChannelId_lte() != null) {
criteria.andChannelIdLessThanOrEqualTo(channelTagVo.getChannelId_lte());
}
if(channelTagVo.getTagId() != null) {
criteria.andTagIdEqualTo(channelTagVo.getTagId());
}
if(channelTagVo.getTagId_arr() != null) {
criteria.andTagIdIn(channelTagVo.getTagId_arr());
}
if(channelTagVo.getTagId_gt() != null) {
criteria.andTagIdGreaterThan(channelTagVo.getTagId_gt());
}
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;
}
@Override
protected BaseService<ChannelTag> getService() {
return channelTagService;
}
}
\ No newline at end of file
package com.viontech.fanxing.ops.controller.web;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
import com.viontech.fanxing.commons.base.BaseExample;
import com.viontech.fanxing.commons.constant.ChannelType;
import com.viontech.fanxing.commons.model.Channel;
import com.viontech.fanxing.commons.model.ChannelExample;
import com.viontech.fanxing.commons.model.ChannelTag;
import com.viontech.fanxing.commons.model.ChannelTagExample;
import com.viontech.fanxing.commons.vo.ChannelVo;
import com.viontech.fanxing.commons.vo.DictCodeVo;
import com.viontech.fanxing.ops.controller.base.ChannelBaseController;
import com.viontech.fanxing.ops.service.adapter.ChannelTagService;
import com.viontech.keliu.util.JsonMessageUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import static com.viontech.keliu.util.JsonMessageUtil.getSuccessJsonMsg;
@RestController
@RequestMapping("/channels")
@Slf4j
public class ChannelController extends ChannelBaseController {
@Resource
private ChannelTagService channelTagService;
@Override
protected BaseExample getExample(ChannelVo channelVo, int type) {
......@@ -36,7 +48,35 @@ public class ChannelController extends ChannelBaseController {
List<DictCodeVo> dictCodeVos = channelService.channelOrg(channels);
return JsonMessageUtil.getSuccessJsonMsg(dictCodeVos);
} else {
return super.page(channelVo, page, pageSize, sortName, sortOrder);
BaseExample baseExample = getExample(channelVo, EXAMPLE_TYPE_PAGE);
if (isNotNull(sortOrder) && isNotNull(sortName)) {
baseExample.setOrderByClause(baseExample.getTableAlias() + "." + sortName + " " + sortOrder);
} else if (isNotNull(sortName) && !isNotNull(sortOrder)) {
baseExample.setOrderByClause(sortName);
}
Object response;
List<Channel> channels;
if (page <= 0) {
channels = getService().selectByExample(baseExample);
response = channels;
} else {
PageInfo<Channel> pageInfo = (PageInfo<Channel>) getService().pagedQuery(baseExample, page, pageSize);
channels = pageInfo.getList();
response = pageInfo;
}
if (channels.size() > 0 && channelVo.getType() != null && channelVo.getType().equals(ChannelType.FILE.value)) {
List<Long> channelIdList = channels.stream().map(Channel::getId).collect(Collectors.toList());
ChannelTagExample channelTagExample = new ChannelTagExample();
channelTagExample.createCriteria().andChannelIdIn(channelIdList);
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())));
for (Channel channel : channels) {
List<Long> tags = channel_tag_map.get(channel.getId());
channel.setTags(tags);
}
}
return getSuccessJsonMsg(MESSAGE_SELECT_SUCCESS, response);
}
}
......
package com.viontech.fanxing.ops.controller.web;
import com.viontech.fanxing.commons.base.BaseExample;
import com.viontech.fanxing.commons.model.ChannelTagExample;
import com.viontech.fanxing.commons.vo.ChannelTagVo;
import com.viontech.fanxing.ops.controller.base.ChannelTagBaseController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping("/channelTags")
public class ChannelTagController extends ChannelTagBaseController {
@Override
protected BaseExample getExample(ChannelTagVo channelTagVo, int type) {
ChannelTagExample channelTagExample = (ChannelTagExample) super.getExample(channelTagVo, type);
return channelTagExample;
}
}
\ No newline at end of file
package com.viontech.fanxing.ops.mapper;
import com.viontech.fanxing.commons.base.BaseMapper;
import com.viontech.fanxing.commons.model.ChannelTag;
import com.viontech.fanxing.commons.model.ChannelTagExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface ChannelTagMapper extends BaseMapper {
int countByExample(ChannelTagExample example);
int deleteByExample(ChannelTagExample example);
int deleteByPrimaryKey(Long id);
int insert(ChannelTag record);
int insertSelective(ChannelTag record);
List<ChannelTag> selectByExample(ChannelTagExample example);
ChannelTag selectByPrimaryKey(Long id);
int updateByExampleSelective(@Param("record") ChannelTag record, @Param("example") ChannelTagExample example);
int updateByExample(@Param("record") ChannelTag record, @Param("example") ChannelTagExample example);
int updateByPrimaryKeySelective(ChannelTag record);
int updateByPrimaryKey(ChannelTag record);
}
\ No newline at end of file
......@@ -19,6 +19,7 @@
<result column="channel_longitude" property="longitude" />
<result column="channel_latitude" property="latitude" />
<result column="channel_status" property="status" />
<result column="channel_create_time" property="createTime" />
</resultMap>
<resultMap id="BaseResultMap" type="com.viontech.fanxing.commons.model.Channel" extends="BaseResultMapRoot" />
<sql id="Example_Where_Clause" >
......@@ -87,7 +88,7 @@
`channel`.address_unid as channel_address_unid, `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`.`status` as `channel_status`
`channel`.`status` as `channel_status`, `channel`.create_time as channel_create_time
</sql>
<sql id="Base_Column_List" >
<if test="!(_parameter.getClass().getSimpleName() == 'ChannelExample')" >
......@@ -146,14 +147,14 @@
`type`, stream_type, stream_path,
username, `password`, address_unid,
`name`, ip, port, expand,
longitude, latitude, `status`
)
longitude, latitude, `status`,
create_time)
values (#{unid,jdbcType=VARCHAR}, #{channelUnid,jdbcType=VARCHAR}, #{deviceUnid,jdbcType=VARCHAR},
#{type,jdbcType=INTEGER}, #{streamType,jdbcType=INTEGER}, #{streamPath,jdbcType=VARCHAR},
#{username,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR}, #{addressUnid,jdbcType=VARCHAR},
#{name,jdbcType=VARCHAR}, #{ip,jdbcType=VARCHAR}, #{port,jdbcType=INTEGER}, #{expand,jdbcType=VARCHAR},
#{longitude,jdbcType=REAL}, #{latitude,jdbcType=REAL}, #{status,jdbcType=INTEGER}
)
#{longitude,jdbcType=REAL}, #{latitude,jdbcType=REAL}, #{status,jdbcType=INTEGER},
#{createTime,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="com.viontech.fanxing.commons.model.Channel" useGeneratedKeys="true" keyProperty="id" keyColumn="id" >
insert into `s_channel`
......@@ -206,6 +207,9 @@
<if test="status != null" >
`status`,
</if>
<if test="createTime != null" >
create_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="unid != null" >
......@@ -256,6 +260,9 @@
<if test="status != null" >
#{status,jdbcType=INTEGER},
</if>
<if test="createTime != null" >
#{createTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.viontech.fanxing.commons.model.ChannelExample" resultType="java.lang.Integer" >
......@@ -318,6 +325,9 @@
<if test="record.status != null" >
`status` = #{record.status,jdbcType=INTEGER},
</if>
<if test="record.createTime != null" >
create_time = #{record.createTime,jdbcType=TIMESTAMP},
</if>
</set>
<if test="_parameter != null" >
<include refid="Update_By_Example_Where_Clause" />
......@@ -341,7 +351,8 @@
expand = #{record.expand,jdbcType=VARCHAR},
longitude = #{record.longitude,jdbcType=REAL},
latitude = #{record.latitude,jdbcType=REAL},
`status` = #{record.status,jdbcType=INTEGER}
`status` = #{record.status,jdbcType=INTEGER},
create_time = #{record.createTime,jdbcType=TIMESTAMP}
<if test="_parameter != null" >
<include refid="Update_By_Example_Where_Clause" />
</if>
......@@ -397,6 +408,9 @@
<if test="status != null" >
`status` = #{status,jdbcType=INTEGER},
</if>
<if test="createTime != null" >
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
......@@ -417,7 +431,8 @@
expand = #{expand,jdbcType=VARCHAR},
longitude = #{longitude,jdbcType=REAL},
latitude = #{latitude,jdbcType=REAL},
`status` = #{status,jdbcType=INTEGER}
`status` = #{status,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>
\ No newline at end of file
<?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.ops.mapper.ChannelTagMapper" >
<resultMap id="BaseResultMapRoot" type="com.viontech.fanxing.commons.model.ChannelTag" >
<id column="channel_tag_id" property="id" />
<result column="channel_tag_channel_id" property="channelId" />
<result column="channel_tag_tag_id" property="tagId" />
</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>
<sql id="Left_Join_List" >
<foreach collection="leftJoinTableSet" item="leftJoinTable" >
<choose >
<when test="leftJoinTable == 's_channel'.toString()" >
left join `s_channel` `channel` on `channel`.id = `channel_tag`.channel_id
</when>
</choose>
</foreach>
</sql>
<sql id="Example_Where_Clause" >
<where >
<foreach collection="oredCriteria" item="criteria" separator="or" >
<if test="criteria.valid" >
<trim prefix="(" suffix=")" prefixOverrides="and" >
<foreach collection="criteria.criteria" item="criterion" >
<choose >
<when test="criterion.noValue" >
and ${criterion.condition}
</when>
<when test="criterion.singleValue" >
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue" >
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue" >
and ${criterion.condition}
<foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause" >
<where >
<foreach collection="example.oredCriteria" item="criteria" separator="or" >
<if test="criteria.valid" >
<trim prefix="(" suffix=")" prefixOverrides="and" >
<foreach collection="criteria.criteria" item="criterion" >
<choose >
<when test="criterion.noValue" >
and ${criterion.condition}
</when>
<when test="criterion.singleValue" >
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue" >
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue" >
and ${criterion.condition}
<foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List_Root" >
`channel_tag`.id as channel_tag_id, `channel_tag`.channel_id as channel_tag_channel_id,
`channel_tag`.tag_id as channel_tag_tag_id
</sql>
<sql id="Base_Column_List" >
<if test="!(_parameter.getClass().getSimpleName() == 'ChannelTagExample')" >
<include refid="com.viontech.fanxing.ops.mapper.ChannelTagMapper.Base_Column_List_Root" />
</if>
<if test="_parameter.getClass().getSimpleName() == 'ChannelTagExample'" >
<foreach collection="columnContainerSet" item="columns" separator="," >
<choose >
<when test="columns.tableName == 'r_channel_tag'.toString()" >
<if test="columns.valid" >
${columns.columnContainerStr}
</if>
<if test="!columns.valid" >
<include refid="com.viontech.fanxing.ops.mapper.ChannelTagMapper.Base_Column_List_Root" />
</if>
</when>
<when test="columns.tableName == 's_channel'.toString()" >
<if test="columns.valid" >
${columns.columnContainerStr}
</if>
<if test="!columns.valid" >
<include refid="com.viontech.fanxing.ops.mapper.ChannelMapper.Base_Column_List_Root" />
</if>
</when>
</choose>
</foreach>
</if>
</sql>
<select id="selectByExample" resultMap="BaseResultMap" parameterType="com.viontech.fanxing.commons.model.ChannelTagExample" >
select
<if test="distinct" >
distinct
</if>
<include refid="Base_Column_List" />
from `r_channel_tag` `channel_tag`
<include refid="Left_Join_List" />
<if test="_parameter != null" >
<include refid="Example_Where_Clause" />
</if>
<if test="groupByClause != null" >
group by ${groupByClause}
</if>
<if test="orderByClause != null" >
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
select
<include refid="Base_Column_List" />
from `r_channel_tag` `channel_tag`
where `channel_tag`.id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
delete from `r_channel_tag` `channel_tag`
where id = #{id,jdbcType=BIGINT}
</delete>
<delete id="deleteByExample" parameterType="com.viontech.fanxing.commons.model.ChannelTagExample" >
delete from `r_channel_tag` `channel_tag`
<if test="_parameter != null" >
<include refid="Example_Where_Clause" />
</if>
</delete>
<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)
values (#{channelId,jdbcType=BIGINT}, #{tagId,jdbcType=BIGINT})
</insert>
<insert id="insertSelective" parameterType="com.viontech.fanxing.commons.model.ChannelTag" useGeneratedKeys="true" keyProperty="id" keyColumn="id" >
insert into `r_channel_tag`
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="channelId != null" >
channel_id,
</if>
<if test="tagId != null" >
tag_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="channelId != null" >
#{channelId,jdbcType=BIGINT},
</if>
<if test="tagId != null" >
#{tagId,jdbcType=BIGINT},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.viontech.fanxing.commons.model.ChannelTagExample" resultType="java.lang.Integer" >
select count(*) from `r_channel_tag` `channel_tag`
<include refid="Left_Join_List" />
<if test="_parameter != null" >
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map" >
update `r_channel_tag` `channel_tag`
<set >
<if test="record.id != null" >
id = #{record.id,jdbcType=BIGINT},
</if>
<if test="record.channelId != null" >
channel_id = #{record.channelId,jdbcType=BIGINT},
</if>
<if test="record.tagId != null" >
tag_id = #{record.tagId,jdbcType=BIGINT},
</if>
</set>
<if test="_parameter != null" >
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map" >
update `r_channel_tag` `channel_tag`
set id = #{record.id,jdbcType=BIGINT},
channel_id = #{record.channelId,jdbcType=BIGINT},
tag_id = #{record.tagId,jdbcType=BIGINT}
<if test="_parameter != null" >
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.viontech.fanxing.commons.model.ChannelTag" >
update `r_channel_tag`
<set >
<if test="channelId != null" >
channel_id = #{channelId,jdbcType=BIGINT},
</if>
<if test="tagId != null" >
tag_id = #{tagId,jdbcType=BIGINT},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.viontech.fanxing.commons.model.ChannelTag" >
update `r_channel_tag`
set channel_id = #{channelId,jdbcType=BIGINT},
tag_id = #{tagId,jdbcType=BIGINT}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>
\ No newline at end of file
package com.viontech.fanxing.ops.service.adapter;
import com.viontech.fanxing.commons.base.BaseService;
import com.viontech.fanxing.commons.model.ChannelTag;
public interface ChannelTagService extends BaseService<ChannelTag> {
}
\ No newline at end of file
......@@ -12,6 +12,7 @@ import com.viontech.fanxing.commons.vo.ChannelVo;
import com.viontech.fanxing.commons.vo.DictCodeVo;
import com.viontech.fanxing.ops.mapper.ChannelMapper;
import com.viontech.fanxing.ops.service.adapter.ChannelService;
import com.viontech.fanxing.ops.service.adapter.ChannelTagService;
import com.viontech.fanxing.ops.service.adapter.DictCateService;
import com.viontech.fanxing.ops.service.adapter.DictCodeService;
import lombok.extern.slf4j.Slf4j;
......@@ -20,6 +21,7 @@ import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.reactive.function.client.WebClient;
......@@ -41,6 +43,8 @@ public class ChannelServiceImpl extends BaseServiceImpl<Channel> implements Chan
private DictCateService dictCateService;
@Resource
private VionConfig vionConfig;
@Resource
private ChannelTagService channelTagService;
@Override
public BaseMapper<Channel> getMapper() {
......@@ -177,6 +181,7 @@ public class ChannelServiceImpl extends BaseServiceImpl<Channel> implements Chan
* 上传存储视频文件
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Channel uploadVideo(ChannelVo channelVo) {
MultipartFile file = channelVo.getFile();
String originalFilename = file.getOriginalFilename();
......@@ -195,7 +200,9 @@ public class ChannelServiceImpl extends BaseServiceImpl<Channel> implements Chan
throw new RuntimeException(e);
}
long videoLength = video.length();
long mbSize = videoLength / 1024 / 1024;
List<Long> tags = channelVo.getTags();
channelVo.setUnid(unid);
channelVo.setChannelUnid(unid);
channelVo.setDeviceUnid(unid);
......@@ -203,9 +210,20 @@ public class ChannelServiceImpl extends BaseServiceImpl<Channel> implements Chan
channelVo.setStreamPath(video.getPath());
channelVo.setType(ChannelType.FILE.value);
channelVo.setStreamType(ChannelType.STREAM_FILE.value);
channelVo.setPort(Math.toIntExact(mbSize));
Channel channel = this.insertSelective(channelVo);
channel = selectByPrimaryKey(channel.getId());
return channel;
channelVo = new ChannelVo(channel);
channelVo.setTags(tags);
if (tags != null && tags.size() > 0) {
for (Long tagId : tags) {
ChannelTag channelTag = new ChannelTag();
channelTag.setChannelId(channel.getId());
channelTag.setTagId(tagId);
channelTagService.insertSelective(channelTag);
}
}
return channelVo;
}
}
\ No newline at end of file
package com.viontech.fanxing.ops.service.impl;
import com.viontech.fanxing.commons.base.BaseMapper;
import com.viontech.fanxing.commons.base.BaseServiceImpl;
import com.viontech.fanxing.commons.model.ChannelTag;
import com.viontech.fanxing.ops.mapper.ChannelTagMapper;
import com.viontech.fanxing.ops.service.adapter.ChannelTagService;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
@Service
public class ChannelTagServiceImpl extends BaseServiceImpl<ChannelTag> implements ChannelTagService {
@Resource
private ChannelTagMapper channelTagMapper;
@Override
public BaseMapper<ChannelTag> getMapper() {
return channelTagMapper;
}
}
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!