Commit b1d7f0a5 by xmh

commons:

1. 引入 content 表相关代码
2. Channel 添加 brand(品牌/厂家) 和 direction(方向) 字段

ops:
1. 引入 content 表相关代码
2. 更新 channel 表的代码
3. <fix> VideoService.uploadVideo 上传资源文件的 path 更新为相对目录

task:
1. <feature> 新增任务时构建 scene , 并且使用默认配置
2. <feature> 添加接口 TaskController.channelUnidWithTask 获取所有分配了任务的通道序列号
1 parent 1927bb4e
Showing 39 changed files with 1332 additions and 63 deletions
......@@ -16,7 +16,7 @@ public enum ChannelType {
/** stream type rtsp */
STREAM_RTSP(0),
/** stream type file */
STREAM_FILE(2),
STREAM_FILE(1),
;
public int value;
......
......@@ -24,6 +24,10 @@ public class Channel extends BaseModel {
private String password;
private String brand;
private String direction;
private String addressUnid;
private String name;
......@@ -44,6 +48,15 @@ public class Channel extends BaseModel {
private List<Long> tags;
public List<Long> getTags() {
return tags;
}
public Channel setTags(List<Long> tags) {
this.tags = tags;
return this;
}
public Long getId() {
return id;
}
......@@ -116,6 +129,22 @@ public class Channel extends BaseModel {
this.password = password == null ? null : password.trim();
}
public String getBrand() {
return brand;
}
public void setBrand(String brand) {
this.brand = brand == null ? null : brand.trim();
}
public String getDirection() {
return direction;
}
public void setDirection(String direction) {
this.direction = direction == null ? null : direction.trim();
}
public String getAddressUnid() {
return addressUnid;
}
......@@ -187,13 +216,4 @@ public class Channel extends BaseModel {
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
......@@ -689,6 +689,146 @@ public class ChannelExample extends BaseExample {
return (Criteria) this;
}
public Criteria andBrandIsNull() {
addCriterion("`channel`.brand is null");
return (Criteria) this;
}
public Criteria andBrandIsNotNull() {
addCriterion("`channel`.brand is not null");
return (Criteria) this;
}
public Criteria andBrandEqualTo(String value) {
addCriterion("`channel`.brand =", value, "brand");
return (Criteria) this;
}
public Criteria andBrandNotEqualTo(String value) {
addCriterion("`channel`.brand <>", value, "brand");
return (Criteria) this;
}
public Criteria andBrandGreaterThan(String value) {
addCriterion("`channel`.brand >", value, "brand");
return (Criteria) this;
}
public Criteria andBrandGreaterThanOrEqualTo(String value) {
addCriterion("`channel`.brand >=", value, "brand");
return (Criteria) this;
}
public Criteria andBrandLessThan(String value) {
addCriterion("`channel`.brand <", value, "brand");
return (Criteria) this;
}
public Criteria andBrandLessThanOrEqualTo(String value) {
addCriterion("`channel`.brand <=", value, "brand");
return (Criteria) this;
}
public Criteria andBrandLike(String value) {
addCriterion("`channel`.brand like", value, "brand");
return (Criteria) this;
}
public Criteria andBrandNotLike(String value) {
addCriterion("`channel`.brand not like", value, "brand");
return (Criteria) this;
}
public Criteria andBrandIn(List<String> values) {
addCriterion("`channel`.brand in", values, "brand");
return (Criteria) this;
}
public Criteria andBrandNotIn(List<String> values) {
addCriterion("`channel`.brand not in", values, "brand");
return (Criteria) this;
}
public Criteria andBrandBetween(String value1, String value2) {
addCriterion("`channel`.brand between", value1, value2, "brand");
return (Criteria) this;
}
public Criteria andBrandNotBetween(String value1, String value2) {
addCriterion("`channel`.brand not between", value1, value2, "brand");
return (Criteria) this;
}
public Criteria andDirectionIsNull() {
addCriterion("`channel`.direction is null");
return (Criteria) this;
}
public Criteria andDirectionIsNotNull() {
addCriterion("`channel`.direction is not null");
return (Criteria) this;
}
public Criteria andDirectionEqualTo(String value) {
addCriterion("`channel`.direction =", value, "direction");
return (Criteria) this;
}
public Criteria andDirectionNotEqualTo(String value) {
addCriterion("`channel`.direction <>", value, "direction");
return (Criteria) this;
}
public Criteria andDirectionGreaterThan(String value) {
addCriterion("`channel`.direction >", value, "direction");
return (Criteria) this;
}
public Criteria andDirectionGreaterThanOrEqualTo(String value) {
addCriterion("`channel`.direction >=", value, "direction");
return (Criteria) this;
}
public Criteria andDirectionLessThan(String value) {
addCriterion("`channel`.direction <", value, "direction");
return (Criteria) this;
}
public Criteria andDirectionLessThanOrEqualTo(String value) {
addCriterion("`channel`.direction <=", value, "direction");
return (Criteria) this;
}
public Criteria andDirectionLike(String value) {
addCriterion("`channel`.direction like", value, "direction");
return (Criteria) this;
}
public Criteria andDirectionNotLike(String value) {
addCriterion("`channel`.direction not like", value, "direction");
return (Criteria) this;
}
public Criteria andDirectionIn(List<String> values) {
addCriterion("`channel`.direction in", values, "direction");
return (Criteria) this;
}
public Criteria andDirectionNotIn(List<String> values) {
addCriterion("`channel`.direction not in", values, "direction");
return (Criteria) this;
}
public Criteria andDirectionBetween(String value1, String value2) {
addCriterion("`channel`.direction between", value1, value2, "direction");
return (Criteria) this;
}
public Criteria andDirectionNotBetween(String value1, String value2) {
addCriterion("`channel`.direction not between", value1, value2, "direction");
return (Criteria) this;
}
public Criteria andAddressUnidIsNull() {
addCriterion("`channel`.address_unid is null");
return (Criteria) this;
......@@ -1321,6 +1461,16 @@ public class ChannelExample extends BaseExample {
return (ColumnContainer) this;
}
public ColumnContainer hasBrandColumn() {
addColumnStr("`channel`.brand as channel_brand ");
return (ColumnContainer) this;
}
public ColumnContainer hasDirectionColumn() {
addColumnStr("`channel`.direction as channel_direction ");
return (ColumnContainer) this;
}
public ColumnContainer hasAddressUnidColumn() {
addColumnStr("`channel`.address_unid as channel_address_unid ");
return (ColumnContainer) this;
......
package com.viontech.fanxing.commons.model;
import com.viontech.fanxing.commons.base.BaseModel;
public class Content extends BaseModel {
private Long id;
private String unid;
private String name;
private String type;
private String content;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getUnid() {
return unid;
}
public void setUnid(String unid) {
this.unid = unid == null ? null : unid.trim();
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name == null ? null : name.trim();
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type == null ? null : type.trim();
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content == null ? null : content.trim();
}
}
\ No newline at end of file
package com.viontech.fanxing.commons.vo;
import com.viontech.fanxing.commons.model.Content;
import com.viontech.fanxing.commons.vobase.ContentVoBase;
public class ContentVo extends ContentVoBase {
public ContentVo() {
super();
}
public ContentVo(Content content) {
super(content);
}
}
\ No newline at end of file
......@@ -106,6 +106,24 @@ public class ChannelVoBase extends Channel implements VoInterface<Channel> {
private String password_like;
@JsonIgnore
private Boolean brand_null;
@JsonIgnore
private ArrayList<String> brand_arr;
@JsonIgnore
private String brand_like;
@JsonIgnore
private Boolean direction_null;
@JsonIgnore
private ArrayList<String> direction_arr;
@JsonIgnore
private String direction_like;
@JsonIgnore
private Boolean addressUnid_null;
@JsonIgnore
......@@ -627,6 +645,82 @@ public class ChannelVoBase extends Channel implements VoInterface<Channel> {
this.getModel().setPassword(password);
}
public Boolean getBrand_null() {
return brand_null;
}
public void setBrand_null(Boolean brand_null) {
this.brand_null = brand_null;
}
public ArrayList<String> getBrand_arr() {
return brand_arr;
}
public void setBrand_arr(ArrayList<String> brand_arr) {
this.brand_arr = brand_arr;
}
public String getBrand_like() {
return brand_like;
}
public void setBrand_like(String brand_like) {
this.brand_like = brand_like;
}
public String getBrand() {
if(getModel() == null ){
throw new RuntimeException("model is null");
}
return this.getModel().getBrand();
}
public void setBrand(String brand) {
if(getModel() == null ){
throw new RuntimeException("model is null");
}
this.getModel().setBrand(brand);
}
public Boolean getDirection_null() {
return direction_null;
}
public void setDirection_null(Boolean direction_null) {
this.direction_null = direction_null;
}
public ArrayList<String> getDirection_arr() {
return direction_arr;
}
public void setDirection_arr(ArrayList<String> direction_arr) {
this.direction_arr = direction_arr;
}
public String getDirection_like() {
return direction_like;
}
public void setDirection_like(String direction_like) {
this.direction_like = direction_like;
}
public String getDirection() {
if(getModel() == null ){
throw new RuntimeException("model is null");
}
return this.getModel().getDirection();
}
public void setDirection(String direction) {
if(getModel() == null ){
throw new RuntimeException("model is null");
}
this.getModel().setDirection(direction);
}
public Boolean getAddressUnid_null() {
return addressUnid_null;
}
......
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.Content;
import java.util.ArrayList;
public class ContentVoBase extends Content implements VoInterface<Content> {
private Content content;
@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<String> unid_arr;
@JsonIgnore
private String unid_like;
@JsonIgnore
private ArrayList<String> name_arr;
@JsonIgnore
private String name_like;
@JsonIgnore
private Boolean type_null;
@JsonIgnore
private ArrayList<String> type_arr;
@JsonIgnore
private String type_like;
@JsonIgnore
private Boolean content_null;
@JsonIgnore
private ArrayList<String> content_arr;
@JsonIgnore
private String content_like;
public ContentVoBase() {
this(null);
}
public ContentVoBase(Content content) {
if(content == null) {
content = new Content();
}
this.content = content;
}
@JsonIgnore
public Content getModel() {
return content;
}
public void setModel(Content content) {
this.content = content;
}
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<String> getUnid_arr() {
return unid_arr;
}
public void setUnid_arr(ArrayList<String> unid_arr) {
this.unid_arr = unid_arr;
}
public String getUnid_like() {
return unid_like;
}
public void setUnid_like(String unid_like) {
this.unid_like = unid_like;
}
public String getUnid() {
if(getModel() == null ){
throw new RuntimeException("model is null");
}
return this.getModel().getUnid();
}
public void setUnid(String unid) {
if(getModel() == null ){
throw new RuntimeException("model is null");
}
this.getModel().setUnid(unid);
}
public ArrayList<String> getName_arr() {
return name_arr;
}
public void setName_arr(ArrayList<String> name_arr) {
this.name_arr = name_arr;
}
public String getName_like() {
return name_like;
}
public void setName_like(String name_like) {
this.name_like = name_like;
}
public String getName() {
if(getModel() == null ){
throw new RuntimeException("model is null");
}
return this.getModel().getName();
}
public void setName(String name) {
if(getModel() == null ){
throw new RuntimeException("model is null");
}
this.getModel().setName(name);
}
public Boolean getType_null() {
return type_null;
}
public void setType_null(Boolean type_null) {
this.type_null = type_null;
}
public ArrayList<String> getType_arr() {
return type_arr;
}
public void setType_arr(ArrayList<String> type_arr) {
this.type_arr = type_arr;
}
public String getType_like() {
return type_like;
}
public void setType_like(String type_like) {
this.type_like = type_like;
}
public String getType() {
if(getModel() == null ){
throw new RuntimeException("model is null");
}
return this.getModel().getType();
}
public void setType(String type) {
if(getModel() == null ){
throw new RuntimeException("model is null");
}
this.getModel().setType(type);
}
public Boolean getContent_null() {
return content_null;
}
public void setContent_null(Boolean content_null) {
this.content_null = content_null;
}
public ArrayList<String> getContent_arr() {
return content_arr;
}
public void setContent_arr(ArrayList<String> content_arr) {
this.content_arr = content_arr;
}
public String getContent_like() {
return content_like;
}
public void setContent_like(String content_like) {
this.content_like = content_like;
}
public String getContent() {
if(getModel() == null ){
throw new RuntimeException("model is null");
}
return this.getModel().getContent();
}
public void setContent(String content) {
if(getModel() == null ){
throw new RuntimeException("model is null");
}
this.getModel().setContent(content);
}
}
\ No newline at end of file
......@@ -8,6 +8,7 @@ import org.redisson.api.RKeys;
import org.redisson.api.RLock;
import org.redisson.api.RMap;
import org.redisson.api.RedissonClient;
import org.springframework.context.annotation.Profile;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
......@@ -23,6 +24,7 @@ import java.util.Date;
@Component
@Slf4j
@Profile("!test")
public class ForwardResultPersistenceRunner {
@Resource
......
......@@ -7,6 +7,7 @@ import org.springframework.batch.core.JobParametersBuilder;
import org.springframework.batch.core.launch.support.SimpleJobLauncher;
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Profile;
import org.springframework.core.annotation.Order;
import org.springframework.core.task.TaskExecutor;
import org.springframework.stereotype.Component;
......@@ -23,6 +24,7 @@ import java.util.UUID;
@Component
@Order(11)
@Profile("!test")
public class JobStartRunner implements CommandLineRunner {
@Resource
......
......@@ -3,6 +3,7 @@ package com.viontech.fanxing.forward.runner;
import com.viontech.fanxing.commons.config.VionConfig;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils;
import org.springframework.context.annotation.Profile;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
......@@ -19,6 +20,7 @@ import java.time.format.DateTimeFormatter;
*/
@Component
@Slf4j
@Profile("!test")
public class PicKeepRunner {
@Resource
......
......@@ -7,6 +7,7 @@ import lombok.extern.slf4j.Slf4j;
import org.redisson.api.RTopic;
import org.redisson.api.RedissonClient;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
......@@ -19,6 +20,7 @@ import javax.annotation.Resource;
*/
@Component
@Slf4j
@Profile("!test")
public class PicRealTimeRunner implements CommandLineRunner {
@Resource
......
......@@ -11,6 +11,7 @@ import org.junit.runner.RunWith;
import org.redisson.api.RTopic;
import org.redisson.api.RedissonClient;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
......@@ -25,6 +26,7 @@ import java.util.List;
@SpringBootTest
@RunWith(SpringRunner.class)
@ActiveProfiles("test")
public class Test0 {
@Resource
......
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.Content;
import com.viontech.fanxing.commons.model.ContentExample;
import com.viontech.fanxing.commons.vo.ContentVo;
import com.viontech.fanxing.ops.mapper.ContentMapper;
import com.viontech.fanxing.ops.service.adapter.ContentService;
import javax.annotation.Resource;
public abstract class ContentBaseController extends BaseController<Content, ContentVo> {
@Resource
protected ContentService contentService;
@Override
protected BaseExample getExample(ContentVo contentVo, int type) {
ContentExample contentExample = new ContentExample();
ContentExample.Criteria criteria = contentExample.createCriteria();
if(contentVo.getId() != null) {
criteria.andIdEqualTo(contentVo.getId());
}
if(contentVo.getId_arr() != null) {
criteria.andIdIn(contentVo.getId_arr());
}
if(contentVo.getId_gt() != null) {
criteria.andIdGreaterThan(contentVo.getId_gt());
}
if(contentVo.getId_lt() != null) {
criteria.andIdLessThan(contentVo.getId_lt());
}
if(contentVo.getId_gte() != null) {
criteria.andIdGreaterThanOrEqualTo(contentVo.getId_gte());
}
if(contentVo.getId_lte() != null) {
criteria.andIdLessThanOrEqualTo(contentVo.getId_lte());
}
if(contentVo.getUnid() != null) {
criteria.andUnidEqualTo(contentVo.getUnid());
}
if(contentVo.getUnid_arr() != null) {
criteria.andUnidIn(contentVo.getUnid_arr());
}
if(contentVo.getUnid_like() != null) {
criteria.andUnidLike(contentVo.getUnid_like());
}
if(contentVo.getName() != null) {
criteria.andNameEqualTo(contentVo.getName());
}
if(contentVo.getName_arr() != null) {
criteria.andNameIn(contentVo.getName_arr());
}
if(contentVo.getName_like() != null) {
criteria.andNameLike(contentVo.getName_like());
}
if(contentVo.getType() != null) {
criteria.andTypeEqualTo(contentVo.getType());
}
if(contentVo.getType_null() != null) {
if(contentVo.getType_null().booleanValue()) {
criteria.andTypeIsNull();
} else {
criteria.andTypeIsNotNull();
}
}
if(contentVo.getType_arr() != null) {
criteria.andTypeIn(contentVo.getType_arr());
}
if(contentVo.getType_like() != null) {
criteria.andTypeLike(contentVo.getType_like());
}
return contentExample;
}
@Override
protected BaseService<Content> getService() {
return contentService;
}
}
\ No newline at end of file
package com.viontech.fanxing.ops.controller.web;
import com.github.pagehelper.PageInfo;
import com.viontech.fanxing.commons.base.BaseExample;
import com.viontech.fanxing.commons.model.ContentExample;
import com.viontech.fanxing.commons.vo.ContentVo;
import com.viontech.fanxing.ops.controller.base.ContentBaseController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
import static com.viontech.keliu.util.JsonMessageUtil.getSuccessJsonMsg;
@Controller
@RequestMapping("/contents")
public class ContentController extends ContentBaseController {
@Override
protected BaseExample getExample(ContentVo contentVo, int type) {
ContentExample contentExample = (ContentExample) super.getExample(contentVo, type);
return contentExample;
}
@RequestMapping(value = "", method = RequestMethod.GET)
@ResponseBody
@Override
public Object page(ContentVo contentVo, @RequestParam(value = "page", defaultValue = "-1") int page, @RequestParam(value = "pageSize", defaultValue = "100") int pageSize, String sortName, String sortOrder) {
ContentExample baseExample = (ContentExample) getExample(contentVo, 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 = contentService.selectByExampleWithBlob(baseExample);
return getSuccessJsonMsg(MESSAGE_SELECT_SUCCESS, result);
} else {
PageInfo pageInfo = getService().pagedQuery(baseExample, page, pageSize);
return getSuccessJsonMsg(MESSAGE_PAGE_SUCCESS, pageInfo);
}
}
}
\ No newline at end of file
package com.viontech.fanxing.ops.feign;
import com.viontech.fanxing.commons.model.Task;
import com.viontech.keliu.util.JsonMessageUtil;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;
import java.util.List;
/**
* .
*
* @author 谢明辉
* @date 2021/7/16
*/
@FeignClient(value = "fanxing-task")
@Service
public interface TaskFeignClient {
@GetMapping("/tasks")
JsonMessageUtil.JsonMessage<List<Task>> getAllTask();
}
package com.viontech.fanxing.ops.mapper;
import com.viontech.fanxing.commons.base.BaseMapper;
import com.viontech.fanxing.commons.model.Content;
import com.viontech.fanxing.commons.model.ContentExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface ContentMapper extends BaseMapper {
int countByExample(ContentExample example);
int deleteByExample(ContentExample example);
int deleteByPrimaryKey(Long id);
int insert(Content record);
int insertSelective(Content record);
List<Content> selectByExampleWithBLOBs(ContentExample example);
List<Content> selectByExample(ContentExample example);
Content selectByPrimaryKey(Long id);
int updateByExampleSelective(@Param("record") Content record, @Param("example") ContentExample example);
int updateByExampleWithBLOBs(@Param("record") Content record, @Param("example") ContentExample example);
int updateByExample(@Param("record") Content record, @Param("example") ContentExample example);
int updateByPrimaryKeySelective(Content record);
int updateByPrimaryKeyWithBLOBs(Content record);
int updateByPrimaryKey(Content record);
}
\ No newline at end of file
......@@ -11,6 +11,8 @@
<result column="channel_stream_path" property="streamPath" />
<result column="channel_username" property="username" />
<result column="channel_password" property="password" />
<result column="channel_brand" property="brand" />
<result column="channel_direction" property="direction" />
<result column="channel_address_unid" property="addressUnid" />
<result column="channel_name" property="name" />
<result column="channel_ip" property="ip" />
......@@ -85,9 +87,9 @@
`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`.username as channel_username, `channel`.`password` as `channel_password`,
`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`.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`.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
</sql>
<sql id="Base_Column_List" >
......@@ -145,16 +147,18 @@
<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,
`type`, stream_type, stream_path,
username, `password`, address_unid,
`name`, ip, port, expand,
longitude, latitude, `status`,
create_time)
username, `password`, brand,
direction, address_unid, `name`,
ip, port, expand, 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},
#{createTime,jdbcType=TIMESTAMP})
#{username,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR}, #{brand,jdbcType=VARCHAR},
#{direction,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}, #{createTime,jdbcType=TIMESTAMP}
)
</insert>
<insert id="insertSelective" parameterType="com.viontech.fanxing.commons.model.Channel" useGeneratedKeys="true" keyProperty="id" keyColumn="id" >
insert into `s_channel`
......@@ -183,6 +187,12 @@
<if test="password != null" >
`password`,
</if>
<if test="brand != null" >
brand,
</if>
<if test="direction != null" >
direction,
</if>
<if test="addressUnid != null" >
address_unid,
</if>
......@@ -236,6 +246,12 @@
<if test="password != null" >
#{password,jdbcType=VARCHAR},
</if>
<if test="brand != null" >
#{brand,jdbcType=VARCHAR},
</if>
<if test="direction != null" >
#{direction,jdbcType=VARCHAR},
</if>
<if test="addressUnid != null" >
#{addressUnid,jdbcType=VARCHAR},
</if>
......@@ -301,6 +317,12 @@
<if test="record.password != null" >
`password` = #{record.password,jdbcType=VARCHAR},
</if>
<if test="record.brand != null" >
brand = #{record.brand,jdbcType=VARCHAR},
</if>
<if test="record.direction != null" >
direction = #{record.direction,jdbcType=VARCHAR},
</if>
<if test="record.addressUnid != null" >
address_unid = #{record.addressUnid,jdbcType=VARCHAR},
</if>
......@@ -344,6 +366,8 @@
stream_path = #{record.streamPath,jdbcType=VARCHAR},
username = #{record.username,jdbcType=VARCHAR},
`password` = #{record.password,jdbcType=VARCHAR},
brand = #{record.brand,jdbcType=VARCHAR},
direction = #{record.direction,jdbcType=VARCHAR},
address_unid = #{record.addressUnid,jdbcType=VARCHAR},
`name` = #{record.name,jdbcType=VARCHAR},
ip = #{record.ip,jdbcType=VARCHAR},
......@@ -384,6 +408,12 @@
<if test="password != null" >
`password` = #{password,jdbcType=VARCHAR},
</if>
<if test="brand != null" >
brand = #{brand,jdbcType=VARCHAR},
</if>
<if test="direction != null" >
direction = #{direction,jdbcType=VARCHAR},
</if>
<if test="addressUnid != null" >
address_unid = #{addressUnid,jdbcType=VARCHAR},
</if>
......@@ -424,6 +454,8 @@
stream_path = #{streamPath,jdbcType=VARCHAR},
username = #{username,jdbcType=VARCHAR},
`password` = #{password,jdbcType=VARCHAR},
brand = #{brand,jdbcType=VARCHAR},
direction = #{direction,jdbcType=VARCHAR},
address_unid = #{addressUnid,jdbcType=VARCHAR},
`name` = #{name,jdbcType=VARCHAR},
ip = #{ip,jdbcType=VARCHAR},
......
package com.viontech.fanxing.ops.service.adapter;
import com.viontech.fanxing.commons.base.BaseService;
import com.viontech.fanxing.commons.model.Content;
import com.viontech.fanxing.commons.model.ContentExample;
import java.util.List;
public interface ContentService extends BaseService<Content> {
List<Content> selectByExampleWithBlob(ContentExample contentExample);
}
\ No newline at end of file
package com.viontech.fanxing.ops.service.impl;
import com.viontech.fanxing.commons.base.BaseExample;
import com.viontech.fanxing.commons.base.BaseMapper;
import com.viontech.fanxing.commons.base.BaseServiceImpl;
import com.viontech.fanxing.commons.model.Content;
import com.viontech.fanxing.commons.model.ContentExample;
import com.viontech.fanxing.ops.mapper.ContentMapper;
import com.viontech.fanxing.ops.service.adapter.ContentService;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class ContentServiceImpl extends BaseServiceImpl<Content> implements ContentService {
@Resource
private ContentMapper contentMapper;
@Override
public BaseMapper<Content> getMapper() {
return contentMapper;
}
@Override
public List<Content> selectByExampleWithBlob(ContentExample contentExample) {
return contentMapper.selectByExampleWithBLOBs(contentExample);
}
}
\ No newline at end of file
......@@ -31,7 +31,7 @@ public class DictCodeServiceImpl extends BaseServiceImpl<DictCode> implements Di
}
@Override
public ImmutablePair<Map<Long,DictCodeVo>,List<DictCodeVo>> getTreeCode(List<DictCode> dictCodes) {
public ImmutablePair<Map<Long, DictCodeVo>, List<DictCodeVo>> getTreeCode(List<DictCode> dictCodes) {
Map<Long, DictCodeVo> map = dictCodes.stream().map(DictCodeVo::new).collect(Collectors.toMap(DictCode::getId, x -> x, (x, y) -> x));
......
......@@ -72,7 +72,7 @@ public class VideoService {
channel.setChannelUnid(unid);
channel.setDeviceUnid(unid);
channel.setName(originalFilename);
channel.setStreamPath(video.getPath());
channel.setStreamPath("/uploadVideo/" + filename);
channel.setType(ChannelType.FILE.value);
channel.setStreamType(ChannelType.STREAM_FILE.value);
channel.setPort(Math.toIntExact(mbSize));
......
......@@ -29,6 +29,11 @@
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-config</artifactId>
</dependency>
<dependency>
<groupId>org.dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>2.1.3</version>
</dependency>
</dependencies>
......
......@@ -2,6 +2,7 @@ package com.viontech.fanxing.task.controller.web;
import com.alibaba.fastjson.JSONObject;
import com.viontech.fanxing.commons.base.BaseExample;
import com.viontech.fanxing.commons.model.Task;
import com.viontech.fanxing.commons.model.TaskExample;
import com.viontech.fanxing.commons.vo.TaskVo;
import com.viontech.fanxing.task.controller.base.TaskBaseController;
......@@ -9,6 +10,10 @@ import com.viontech.keliu.util.JsonMessageUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
@RestController
@RequestMapping("/tasks")
@Slf4j
......@@ -61,4 +66,19 @@ public class TaskController extends TaskBaseController {
JSONObject overview = taskService.overview();
return JsonMessageUtil.getSuccessJsonMsg(overview);
}
/**
* 获取所有分配过任务的通道序列号
*
* @return
*/
@GetMapping("channelUnidWithTask")
public JsonMessageUtil.JsonMessage channelUnidWithTask() {
TaskExample taskExample = new TaskExample();
taskExample.createColumns().hasChannelUnidColumn();
List<Task> tasks = taskService.selectByExample(taskExample);
Set<String> collect = tasks.stream().map(Task::getChannelUnid).collect(Collectors.toSet());
return JsonMessageUtil.getSuccessJsonMsg(collect);
}
}
\ No newline at end of file
package com.viontech.fanxing.task.feign;
import com.viontech.fanxing.commons.model.Channel;
import com.viontech.fanxing.commons.model.Content;
import com.viontech.fanxing.commons.model.DictCode;
import com.viontech.fanxing.commons.model.StoreConfig;
import com.viontech.keliu.util.JsonMessageUtil;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
/**
* .
......@@ -21,4 +27,14 @@ public interface OpsClient {
@GetMapping("/storeConfigs/{id}")
JsonMessageUtil.JsonMessage<StoreConfig> getStoreConfigById(@PathVariable("id") Long storeConfigId);
@GetMapping("/contents")
JsonMessageUtil.JsonMessage<List<Content>> getContentByName(@RequestParam("name") String name);
@GetMapping("/channels")
JsonMessageUtil.JsonMessage<List<Channel>> getChannelByChannelUnid(@RequestParam("channelUnid") String channelUnid);
@GetMapping("/dictCodes")
JsonMessageUtil.JsonMessage<List<DictCode>> getDictCodeByUnid(@RequestParam("unid") String unid);
}
package com.viontech.fanxing.task.model;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.SAXReader;
import org.dom4j.io.XMLWriter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.nio.charset.Charset;
import java.util.List;
/**
* .
*
* @author 谢明辉
* @date 2021/9/26
*/
public class ConfigBuilder {
private static final Logger log = LoggerFactory.getLogger(ConfigBuilder.class);
private Document document;
private String build;
private boolean vChanInfoBuilt;
private boolean defaultConfigBuilt;
public ConfigBuilder() {
document = DocumentHelper.createDocument();
document.setRootElement(DocumentHelper.createElement("root"));
}
public void setText(Element element, String name, String text) {
Element e = element.element(name);
if (e == null) {
e = element.addElement(name);
}
e.clearContent();
e.setText(text);
}
public String build() {
try {
OutputFormat format = OutputFormat.createPrettyPrint();
format.setEncoding("GBK");
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
XMLWriter xmlWriter = new XMLWriter(byteArrayOutputStream, format);
xmlWriter.write(document);
build = new String(byteArrayOutputStream.toByteArray(), Charset.forName("GBK"));
} catch (Exception e) {
log.error("", e);
}
log.debug("xmh:构建默认配置完成:{}", build);
return build;
}
public ConfigBuilder buildDefaultConfig(String defaultConfig) {
if (defaultConfigBuilt) {
return this;
}
try {
SAXReader saxReader = new SAXReader();
Document defaultDoc = saxReader.read(new ByteArrayInputStream(defaultConfig.getBytes(Charset.forName("GBK"))));
Element defaultRoot = defaultDoc.getRootElement();
Element root = document.getRootElement();
List<Element> defE = defaultRoot.elements();
for (Element element : defE) {
Element copy = element.createCopy();
root.add(copy);
}
defaultConfigBuilt = true;
} catch (Exception e) {
log.error("", e);
}
return this;
}
public ConfigBuilder buildVchanInfo(String name, String channelUnid, String addressUnid, String addressName) {
if (vChanInfoBuilt) {
return this;
}
try {
// 构建默认配置
Element rootElement = document.getRootElement();
Element deviceConfig = rootElement.element("设备配置");
if (deviceConfig == null) {
deviceConfig = rootElement.addElement("设备配置");
}
setText(deviceConfig, "设备名称", name);
setText(deviceConfig, "设备编号", channelUnid);
if (addressUnid != null) {
setText(deviceConfig, "地点名称", addressUnid);
setText(deviceConfig, "地点编号", addressName);
}
this.vChanInfoBuilt = true;
} catch (Exception e) {
log.error("", e);
}
return this;
}
}
package com.viontech.fanxing.task.model;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import java.util.UUID;
/**
* .
*
* @author 谢明辉
* @date 2021/9/28
*/
@Getter
@Setter
@Accessors(chain = true)
public class Scene {
private String algo_type;
/** 标定,后端不需要关心 */
private Calibration calibration;
/** 配置信息 */
private Config config;
private String position_name;
private String position_num;
private String scene_unid = UUID.randomUUID().toString();
private String vchan_refid;
private Integer runtime = -1;
private PlayUrls play_urls;
public static class Calibration {
private String calibration;
public String getCalibration() {
return calibration;
}
public Calibration setCalibration(String calibration) {
this.calibration = calibration;
return this;
}
}
public static class Config {
private String xml;
public String getXml() {
return xml;
}
public Config setXml(String xml) {
this.xml = xml;
return this;
}
}
public static class PlayUrls {
private String rtsp;
private String http;
public String getHttp() {
return http;
}
public PlayUrls setHttp(String http) {
this.http = http;
return this;
}
public String getRtsp() {
return rtsp;
}
public PlayUrls setRtsp(String rtsp) {
this.rtsp = rtsp;
return this;
}
}
}
......@@ -8,6 +8,7 @@ import com.viontech.fanxing.task.service.TaskDataService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
......@@ -22,6 +23,7 @@ import java.util.List;
@Component
@Slf4j
@Profile("!test")
public class TaskInitRunner implements CommandLineRunner {
@Resource
......
package com.viontech.fanxing.task.service;
import com.viontech.fanxing.commons.exception.FanXingException;
import com.viontech.fanxing.commons.model.Channel;
import com.viontech.fanxing.commons.model.Content;
import com.viontech.fanxing.commons.model.DictCode;
import com.viontech.fanxing.commons.model.StoreConfig;
import com.viontech.fanxing.task.feign.OpsClient;
import com.viontech.keliu.util.JsonMessageUtil;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/**
* .
*
* @author 谢明辉
* @date 2021/9/28
*/
@Service
public class OpsClientService {
@Resource
private OpsClient opsClient;
public StoreConfig getStoreConfigById(Long id) {
JsonMessageUtil.JsonMessage<StoreConfig> res = opsClient.getStoreConfigById(id);
if (res.getCode() != 200) {
throw new FanXingException(res.getMsg());
} else {
return res.getData();
}
}
public String getContentByName(String name) {
JsonMessageUtil.JsonMessage<List<Content>> res = opsClient.getContentByName(name);
if (res.getCode() != 200) {
throw new FanXingException(res.getMsg());
} else {
List<Content> data = res.getData();
return (data == null || data.size() == 0) ? null : data.get(0).getContent();
}
}
public Channel getChannelByChannelUnid(String channelUnid) {
JsonMessageUtil.JsonMessage<List<Channel>> res = opsClient.getChannelByChannelUnid(channelUnid);
if (res.getCode() != 200) {
throw new FanXingException(res.getMsg());
} else {
List<Channel> data = res.getData();
return (data == null || data.size() == 0) ? null : data.get(0);
}
}
public DictCode getDictCodeByUnid(String unid) {
JsonMessageUtil.JsonMessage<List<DictCode>> res = opsClient.getDictCodeByUnid(unid);
if (res.getCode() != 200) {
throw new FanXingException(res.getMsg());
} else {
List<DictCode> data = res.getData();
return (data == null || data.size() == 0) ? null : data.get(0);
}
}
}
......@@ -4,12 +4,10 @@ import com.viontech.fanxing.commons.exception.FanXingException;
import com.viontech.fanxing.commons.model.StoreConfig;
import com.viontech.fanxing.commons.model.Task;
import com.viontech.fanxing.commons.service.RedisService;
import com.viontech.fanxing.task.feign.OpsClient;
import com.viontech.fanxing.task.model.RuntimeConfig;
import com.viontech.fanxing.task.model.TaskData;
import com.viontech.fanxing.task.model.vaserver.VaServerInfo;
import com.viontech.fanxing.task.repository.TaskDataRedisRepository;
import com.viontech.keliu.util.JsonMessageUtil;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.redisson.api.RMap;
import org.redisson.api.RScoredSortedSet;
......@@ -33,18 +31,17 @@ public class TaskDataService {
@Resource
private TaskDataRedisRepository taskDataRedisRepository;
@Resource
private OpsClient opsClient;
private OpsClientService opsClientService;
public void addTask(Task task) {
TaskData taskData = new TaskData(task);
// 获取存储配置
Long storeConfigId = task.getStoreConfigId();
JsonMessageUtil.JsonMessage<StoreConfig> storeConfigRes = opsClient.getStoreConfigById(storeConfigId);
StoreConfig storeConfigVo = storeConfigRes.getData();
if (storeConfigVo == null) {
StoreConfig storeConfig = opsClientService.getStoreConfigById(storeConfigId);
if (storeConfig == null) {
throw new FanXingException("无法获取对应的存储配置");
}
taskData.setStoreConfig(storeConfigVo.getContent());
taskData.setStoreConfig(storeConfig.getContent());
taskDataRedisRepository.addOrUpdateTaskData(taskData);
// 计算运行时间并生成任务
boolean success = distributeTask(taskData);
......
package com.viontech.fanxing.task.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.viontech.fanxing.commons.base.BaseMapper;
import com.viontech.fanxing.commons.base.BaseServiceImpl;
import com.viontech.fanxing.commons.base.LocalCache;
import com.viontech.fanxing.commons.constant.TaskStatus;
import com.viontech.fanxing.commons.model.Channel;
import com.viontech.fanxing.commons.model.DictCode;
import com.viontech.fanxing.commons.model.Task;
import com.viontech.fanxing.commons.model.TaskExample;
import com.viontech.fanxing.commons.vo.TaskVo;
import com.viontech.fanxing.task.mapper.TaskMapper;
import com.viontech.fanxing.task.model.ConfigBuilder;
import com.viontech.fanxing.task.model.Scene;
import com.viontech.fanxing.task.model.vaserver.VaServerInfo;
import com.viontech.fanxing.task.service.OpsClientService;
import com.viontech.fanxing.task.service.TaskDataService;
import com.viontech.fanxing.task.service.VAServerService;
import com.viontech.fanxing.task.service.adapter.TaskService;
......@@ -32,6 +38,8 @@ public class TaskServiceImpl extends BaseServiceImpl<Task> implements TaskServic
private TaskDataService taskDataService;
@Resource
private VAServerService vaServerService;
@Resource
private OpsClientService opsClientService;
@Override
public BaseMapper<Task> getMapper() {
......@@ -41,11 +49,65 @@ public class TaskServiceImpl extends BaseServiceImpl<Task> implements TaskServic
@Transactional(rollbackFor = Exception.class)
@Override
public TaskVo addTask(Task task) {
buildTask(task);
task = insertSelective(task);
task = selectByPrimaryKey(task.getId());
return new TaskVo(task);
}
private void buildTask(Task task) {
String channelUnid = task.getChannelUnid();
Channel channel = opsClientService.getChannelByChannelUnid(channelUnid);
String streamPath = task.getStreamPath();
if (streamPath == null) {
streamPath = channel.getStreamPath();
task.setStreamPath(channel.getStreamPath());
}
JSONArray sceneArray = new JSONArray();
String algType = task.getAlgType();
String addressName = null;
String addressUnid = channel.getAddressUnid();
if (addressUnid != null) {
DictCode dictCode = opsClientService.getDictCodeByUnid(addressUnid);
addressName = dictCode.getName();
}
int sceneNum;
String content;
if ("3".equals(algType)) {
content = opsClientService.getContentByName("illegalStopDefaultConfig");
sceneNum = 5;
} else {
content = opsClientService.getContentByName("defaultConfig");
sceneNum = 1;
}
ConfigBuilder configBuilder = new ConfigBuilder().buildVchanInfo(channel.getName(), channelUnid, addressUnid, addressName);
if (content != null) {
configBuilder.buildDefaultConfig(content);
}
String xml = configBuilder.build();
for (int i = 1; i < sceneNum + 1; i++) {
Scene.Config config = new Scene.Config().setXml(xml);
Scene.PlayUrls playUrls = new Scene.PlayUrls();
Scene scene = new Scene()
.setPosition_num(String.valueOf(i))
.setPosition_name(String.valueOf(i))
.setVchan_refid(channelUnid)
.setAlgo_type(algType)
.setConfig(config)
.setPlay_urls(playUrls);
if (streamPath.contains("http")) {
playUrls.setHttp(streamPath);
} else {
playUrls.setRtsp(streamPath);
}
sceneArray.add(scene);
}
String sceneString = sceneArray.toJSONString();
task.setScene(sceneString);
}
@Transactional(rollbackFor = Exception.class)
@Override
public TaskVo updateTask(Task task) {
......@@ -88,12 +150,7 @@ public class TaskServiceImpl extends BaseServiceImpl<Task> implements TaskServic
if (task.getStoreConfigId() == null) {
throw new IllegalArgumentException("存储配置为空,无法执行");
}
TaskVo taskVo = new TaskVo();
taskVo.setStatus(TaskStatus.PAUSE.val);
taskVo.setId(id);
updateByPrimaryKeySelective(taskVo);
updateStatus(id, TaskStatus.PAUSE.val);
taskDataService.addTask(task);
}
......
package com.viontech.fanxing.task;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.viontech.fanxing.commons.model.Channel;
import com.viontech.fanxing.commons.model.DictCode;
import com.viontech.fanxing.commons.model.Task;
import com.viontech.fanxing.task.service.OpsClientService;
import com.viontech.fanxing.task.service.impl.TaskServiceImpl;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
/**
* .
*
......@@ -7,7 +24,26 @@ package com.viontech.fanxing.task;
* @date 2021/7/21
*/
@SpringBootTest
@RunWith(SpringRunner.class)
@ActiveProfiles("test")
public class MainTest {
@Resource
private OpsClientService opsClientService;
@Resource
private TaskServiceImpl taskService;
@Test
public void opsClientTest() {
DictCode nvs3000 = opsClientService.getDictCodeByUnid("460b359f-0bc6-11ec-a74d-0242ac11001d");
Channel channel = opsClientService.getChannelByChannelUnid("2200001201000D01");
String defaultConfig = opsClientService.getContentByName("defaultConfig");
System.out.println(JSON.toJSONString(nvs3000));
System.out.println(JSON.toJSONString(channel));
System.out.println(JSON.toJSONString(defaultConfig));
}
}
......@@ -5,14 +5,11 @@ import com.viontech.fanxing.commons.constant.TaskStatus;
import com.viontech.fanxing.commons.model.StoreConfig;
import com.viontech.fanxing.commons.model.Task;
import com.viontech.fanxing.commons.service.RedisService;
import com.viontech.fanxing.commons.vo.TaskVo;
import com.viontech.fanxing.task.model.TaskData;
import com.viontech.fanxing.task.feign.OpsClient;
import com.viontech.fanxing.task.model.vaserver.VaServerInfo;
import com.viontech.fanxing.task.repository.TaskDataRedisRepository;
import com.viontech.fanxing.task.repository.VAServerRedisRepository;
import com.viontech.fanxing.task.service.adapter.TaskService;
import com.viontech.keliu.util.JsonMessageUtil;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
......@@ -42,11 +39,13 @@ class VAServerHttpServiceTest {
private VAServerRedisRepository vaServerRedisRepository;
@Resource
private OpsClient opsClient;
private OpsClientService opsClientService;
private VaServerInfo vaServerInfo;
private TaskData taskData;
@Resource
private TaskService taskService;
@Resource
private TaskDataRedisRepository taskDataRedisRepository;
@BeforeEach
public void before() {
......@@ -57,7 +56,6 @@ class VAServerHttpServiceTest {
this.taskData.setTask(task);
}
@Test
void snapshot() {
vaServerHttpService.snapshot(TASK_UNID, vaServerInfo);
......@@ -95,9 +93,8 @@ class VAServerHttpServiceTest {
@Test
void storeConfig() {
JsonMessageUtil.JsonMessage<StoreConfig> storeConfigById = opsClient.getStoreConfigById(6L);
System.out.println(JSON.toJSONString(storeConfigById.getData()));
StoreConfig storeConfig = opsClientService.getStoreConfigById(6L);
System.out.println(JSON.toJSONString(storeConfig));
}
@Test
......@@ -105,8 +102,6 @@ class VAServerHttpServiceTest {
}
@Resource
private TaskDataRedisRepository taskDataRedisRepository;
@Test
void test() throws Exception {
// RMap<String, String> taskVaServerMap = redisService.getTaskVaServerMap();
......
......@@ -25,27 +25,45 @@
<property name="forceBigDecimals" value="false"/>
</javaTypeResolver>
<!-- 生成模型的包名和位置-->
<javaModelGenerator targetPackage="com.viontech.fanxing.code.model" targetProject="F:\mybatis-generator\fanxing-code">
<javaModelGenerator targetPackage="com.viontech.fanxing.commons.model" targetProject="F:\mybatis-generator\fanxing-ops">
<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.code.mapping" targetProject="F:\mybatis-generator\fanxing-code">
<sqlMapGenerator targetPackage="com.viontech.fanxing.commons.mapping" targetProject="F:\mybatis-generator\fanxing-ops">
<property name="enableSubPackages" value="true"/>
</sqlMapGenerator>
<!-- 生成DAO的包名和位置-->
<javaClientGenerator type="XMLMAPPER" targetPackage="com.viontech.fanxing.code.mapper" targetProject="F:\mybatis-generator\fanxing-code" >
<javaClientGenerator type="XMLMAPPER" targetPackage="com.viontech.fanxing.ops.mapper" targetProject="F:\mybatis-generator\fanxing-ops" >
<property name="enableSubPackages" value="true"/>
<property name="rootInterface" value="com.viontech.fanxing.commons.base.BaseMapper"/>
</javaClientGenerator>
<table delimitIdentifiers="true" tableName="s_forward" alias="forward" domainObjectName="Forward">
<generatedKey column="id" sqlStatement="JDBC"/>
</table>
<table delimitIdentifiers="true" tableName="s_forward_config" alias="forwardConfig" domainObjectName="ForwardConfig">
<generatedKey column="id" sqlStatement="JDBC"/>
</table>
<table delimitIdentifiers="true" tableName="s_channel" alias="channel" domainObjectName="Channel">
<generatedKey column="id" sqlStatement="JDBC"/>
</table>
<table delimitIdentifiers="true" tableName="r_channel_tag" alias="channel_tag" domainObjectName="ChannelTag">
<generatedKey column="id" sqlStatement="JDBC"/>
</table>
<table delimitIdentifiers="true" tableName="s_store_config" alias="storeConfig" domainObjectName="StoreConfig">
<generatedKey column="id" sqlStatement="JDBC"/>
</table>
<table delimitIdentifiers="true" tableName="s_dict_cate" alias="dictCate" domainObjectName="DictCate">
<generatedKey column="id" sqlStatement="JDBC"/>
</table>
<table delimitIdentifiers="true" tableName="s_dict_code" alias="dictCode" domainObjectName="DictCode">
<generatedKey column="id" sqlStatement="JDBC"/>
</table>
<table delimitIdentifiers="true" tableName="s_content" alias="content" domainObjectName="Content">
<generatedKey column="id" sqlStatement="JDBC"/>
</table>
</context>
</generatorConfiguration>
......@@ -40,14 +40,7 @@
<property name="rootInterface" value="com.viontech.fanxing.commons.base.BaseMapper"/>
</javaClientGenerator>
<table delimitIdentifiers="true" tableName="s_forward" alias="forward" domainObjectName="Forward">
<generatedKey column="id" sqlStatement="JDBC"/>
</table>
<table delimitIdentifiers="true" tableName="s_forward_config" alias="forwardConfig" domainObjectName="ForwardConfig">
<generatedKey column="id" sqlStatement="JDBC"/>
</table>
<table delimitIdentifiers="true" tableName="d_behavior" alias="behavior" domainObjectName="Behavior">
<generatedKey column="id" sqlStatement="JDBC"/>
</table>
......
......@@ -25,17 +25,17 @@
<property name="forceBigDecimals" value="false"/>
</javaTypeResolver>
<!-- 生成模型的包名和位置-->
<javaModelGenerator targetPackage="com.viontech.fanxing.task.manager.model" targetProject="F:\mybatis-generator\fanxing-task">
<javaModelGenerator targetPackage="com.viontech.fanxing.commons.model" targetProject="F:\mybatis-generator\fanxing-task">
<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.task.manager.mapping" targetProject="F:\mybatis-generator\fanxing-task">
<sqlMapGenerator targetPackage="com.viontech.fanxing.task.mapping" targetProject="F:\mybatis-generator\fanxing-task">
<property name="enableSubPackages" value="true"/>
</sqlMapGenerator>
<!-- 生成DAO的包名和位置-->
<javaClientGenerator type="XMLMAPPER" targetPackage="com.viontech.fanxing.task.manager.mapper" targetProject="F:\mybatis-generator\fanxing-task" >
<javaClientGenerator type="XMLMAPPER" targetPackage="com.viontech.fanxing.task.mapper" targetProject="F:\mybatis-generator\fanxing-task" >
<property name="enableSubPackages" value="true"/>
<property name="rootInterface" value="com.viontech.fanxing.commons.base.BaseMapper"/>
</javaClientGenerator>
......@@ -44,8 +44,5 @@
<table delimitIdentifiers="true" tableName="s_task" alias="task" domainObjectName="Task">
<generatedKey column="id" sqlStatement="JDBC"/>
</table>
<table delimitIdentifiers="true" tableName="s_store_config" alias="storeConfig" domainObjectName="StoreConfig">
<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!