Commit a083018c by xmh

转发服务:

1. <fix> 修复 OpsFeignClient.getForwards 的返回值泛型错误
2. <fix> 优化 ForwardProcessor 的流程

其他:
1. <refactor> 添加 maven 版本发布插件
1 parent 492b628b
......@@ -66,7 +66,7 @@
<dependency>
<groupId>com.viontech.keliu</groupId>
<artifactId>keliu-util</artifactId>
<version>6.0.10-SNAPSHOT</version>
<version>6.0.10</version>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
......
......@@ -32,6 +32,9 @@ public class ForwardProcessor implements ItemStream, ItemProcessor<JSONObject, F
public ForwardContent process(JSONObject item) throws Exception {
List<Forward> allForward = cacheUtils.getAllForward();
if (allForward == null || allForward.size() == 0) {
return null;
}
String eventType = item.getString("event_type");
String eventCate = item.getString("event_cate");
......
......@@ -9,6 +9,8 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
/**
* .
*
......@@ -21,7 +23,7 @@ import org.springframework.web.bind.annotation.RequestBody;
public interface OpsFeignClient {
@GetMapping("/forwards")
JsonMessageUtil.JsonMessage<Forward> getForwards();
JsonMessageUtil.JsonMessage<List<Forward>> getForwards();
@PostMapping("/forwards/{id}")
JsonMessageUtil.JsonMessage<Forward> updateById(@PathVariable("id") Long id, @RequestBody Forward forward);
......
......@@ -40,7 +40,7 @@ public class CacheUtils {
log.info("获取 task_map 失败:", e);
}
if (response != null && response.getData() != null) {
List<Task> data = (List<Task>) response.getData();
List<Task> data = response.getData();
return data.stream().collect(Collectors.toMap(Task::getUnid, x -> x, (x, y) -> x));
} else {
return Collections.emptyMap();
......@@ -49,14 +49,14 @@ public class CacheUtils {
@LocalCache(value = "forward_list", duration = 5)
public synchronized List<Forward> getAllForward() {
JsonMessageUtil.JsonMessage<Forward> response = null;
JsonMessageUtil.JsonMessage<List<Forward>> response = null;
try {
response = opsFeignClient.getForwards();
} catch (Exception e) {
log.info("获取 forward_list 失败:", e);
}
if (response != null && response.getData() != null) {
return (List<Forward>) response.getData();
return response.getData();
} else {
return Collections.emptyList();
}
......
......@@ -11,7 +11,7 @@
</parent>
<artifactId>fanxing-gateway</artifactId>
<version>3.0.0-SNAPSHOT</version>
<version>${parent.version}</version>
<dependencies>
<dependency>
......
......@@ -21,10 +21,7 @@ import org.springframework.web.reactive.function.client.WebClient;
import javax.annotation.Resource;
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;
@Service
......@@ -95,7 +92,17 @@ public class ChannelServiceImpl extends BaseServiceImpl<Channel> implements Chan
private boolean needRemoveFromTree(DictCodeVo dictCodeVo) {
if (dictCodeVo.getChildren() != null) {
dictCodeVo.getChildren().removeIf(this::needRemoveFromTree);
Iterator<DictCodeVo> iterator = dictCodeVo.getChildren().iterator();
boolean remove = true;
while (iterator.hasNext()) {
DictCodeVo next = iterator.next();
if (needRemoveFromTree(next)) {
iterator.remove();
} else {
remove = false;
}
}
return remove;
}
if (dictCodeVo.getChannels() == null) {
return dictCodeVo.getChildren() == null || dictCodeVo.getChildren().size() == 0;
......@@ -158,7 +165,7 @@ public class ChannelServiceImpl extends BaseServiceImpl<Channel> implements Chan
channel.setType(ChannelType.THIRD_PART.value);
channel.setExpand("nvs3000");
channel.setStreamType(ChannelType.STREAM_RTSP.value);
channel.setStreamPath(nvsRegex + id);
channel.setStreamPath(nvsRegex.replace("{id}", id));
insertSelective(channel);
success++;
}
......
......@@ -40,7 +40,7 @@ public class TaskDataService {
// 获取存储配置
Long storeConfigId = task.getStoreConfigId();
JsonMessageUtil.JsonMessage<StoreConfig> storeConfigRes = opsClient.getStoreConfigById(storeConfigId);
StoreConfig storeConfigVo = (StoreConfig) storeConfigRes.getData();
StoreConfig storeConfigVo = storeConfigRes.getData();
if (storeConfigVo == null) {
throw new FanXingException("无法获取对应的存储配置");
}
......
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
......@@ -22,6 +20,28 @@
<module>fanxing-query</module>
</modules>
<properties>
<skipTests>true</skipTests>
<maven.javadoc.failOnError>false</maven.javadoc.failOnError>
</properties>
<scm>
<developerConnection>scm:git:http://git.keliuyun.com:55676/xmh/fanxing3</developerConnection>
<tag>develop</tag>
</scm>
<distributionManagement>
<repository>
<id>vionmaven</id>
<name>vion maven</name>
<url>http://maven.vionyun.com:8081/nexus/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>vionmaven</id>
<name>vion maven</name>
<url>http://maven.vionyun.com:8081/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
<dependencyManagement>
<dependencies>
<dependency>
......@@ -44,4 +64,30 @@
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.3</version>
<configuration>
<generateBackupPoms>false</generateBackupPoms>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
<configuration>
<tagNameFormat>V@{project.version}</tagNameFormat>
<autoVersionSubmodules>true</autoVersionSubmodules>
<username>xmh</username>
<password>hbr25hYQDwhJ</password>
<branchName>develop</branchName>
<commitByProject>true</commitByProject>
<tagBase>http://git.keliuyun.com:55676/xmh/fanxing3/tags</tagBase>
</configuration>
</plugin>
</plugins>
</build>
</project>
\ 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!