Commit a083018c by xmh

转发服务:

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

其他:
1. <refactor> 添加 maven 版本发布插件
1 parent 492b628b
...@@ -66,7 +66,7 @@ ...@@ -66,7 +66,7 @@
<dependency> <dependency>
<groupId>com.viontech.keliu</groupId> <groupId>com.viontech.keliu</groupId>
<artifactId>keliu-util</artifactId> <artifactId>keliu-util</artifactId>
<version>6.0.10-SNAPSHOT</version> <version>6.0.10</version>
<exclusions> <exclusions>
<exclusion> <exclusion>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
......
...@@ -32,6 +32,9 @@ public class ForwardProcessor implements ItemStream, ItemProcessor<JSONObject, F ...@@ -32,6 +32,9 @@ public class ForwardProcessor implements ItemStream, ItemProcessor<JSONObject, F
public ForwardContent process(JSONObject item) throws Exception { public ForwardContent process(JSONObject item) throws Exception {
List<Forward> allForward = cacheUtils.getAllForward(); List<Forward> allForward = cacheUtils.getAllForward();
if (allForward == null || allForward.size() == 0) {
return null;
}
String eventType = item.getString("event_type"); String eventType = item.getString("event_type");
String eventCate = item.getString("event_cate"); String eventCate = item.getString("event_cate");
......
...@@ -9,6 +9,8 @@ import org.springframework.web.bind.annotation.PathVariable; ...@@ -9,6 +9,8 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
/** /**
* . * .
* *
...@@ -21,7 +23,7 @@ import org.springframework.web.bind.annotation.RequestBody; ...@@ -21,7 +23,7 @@ import org.springframework.web.bind.annotation.RequestBody;
public interface OpsFeignClient { public interface OpsFeignClient {
@GetMapping("/forwards") @GetMapping("/forwards")
JsonMessageUtil.JsonMessage<Forward> getForwards(); JsonMessageUtil.JsonMessage<List<Forward>> getForwards();
@PostMapping("/forwards/{id}") @PostMapping("/forwards/{id}")
JsonMessageUtil.JsonMessage<Forward> updateById(@PathVariable("id") Long id, @RequestBody Forward forward); JsonMessageUtil.JsonMessage<Forward> updateById(@PathVariable("id") Long id, @RequestBody Forward forward);
......
...@@ -40,7 +40,7 @@ public class CacheUtils { ...@@ -40,7 +40,7 @@ public class CacheUtils {
log.info("获取 task_map 失败:", e); log.info("获取 task_map 失败:", e);
} }
if (response != null && response.getData() != null) { 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)); return data.stream().collect(Collectors.toMap(Task::getUnid, x -> x, (x, y) -> x));
} else { } else {
return Collections.emptyMap(); return Collections.emptyMap();
...@@ -49,14 +49,14 @@ public class CacheUtils { ...@@ -49,14 +49,14 @@ public class CacheUtils {
@LocalCache(value = "forward_list", duration = 5) @LocalCache(value = "forward_list", duration = 5)
public synchronized List<Forward> getAllForward() { public synchronized List<Forward> getAllForward() {
JsonMessageUtil.JsonMessage<Forward> response = null; JsonMessageUtil.JsonMessage<List<Forward>> response = null;
try { try {
response = opsFeignClient.getForwards(); response = opsFeignClient.getForwards();
} catch (Exception e) { } catch (Exception e) {
log.info("获取 forward_list 失败:", e); log.info("获取 forward_list 失败:", e);
} }
if (response != null && response.getData() != null) { if (response != null && response.getData() != null) {
return (List<Forward>) response.getData(); return response.getData();
} else { } else {
return Collections.emptyList(); return Collections.emptyList();
} }
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
</parent> </parent>
<artifactId>fanxing-gateway</artifactId> <artifactId>fanxing-gateway</artifactId>
<version>3.0.0-SNAPSHOT</version> <version>${parent.version}</version>
<dependencies> <dependencies>
<dependency> <dependency>
......
...@@ -21,10 +21,7 @@ import org.springframework.web.reactive.function.client.WebClient; ...@@ -21,10 +21,7 @@ import org.springframework.web.reactive.function.client.WebClient;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.time.Duration; import java.time.Duration;
import java.util.ArrayList; import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Service @Service
...@@ -95,7 +92,17 @@ public class ChannelServiceImpl extends BaseServiceImpl<Channel> implements Chan ...@@ -95,7 +92,17 @@ public class ChannelServiceImpl extends BaseServiceImpl<Channel> implements Chan
private boolean needRemoveFromTree(DictCodeVo dictCodeVo) { private boolean needRemoveFromTree(DictCodeVo dictCodeVo) {
if (dictCodeVo.getChildren() != null) { 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) { if (dictCodeVo.getChannels() == null) {
return dictCodeVo.getChildren() == null || dictCodeVo.getChildren().size() == 0; return dictCodeVo.getChildren() == null || dictCodeVo.getChildren().size() == 0;
...@@ -158,7 +165,7 @@ public class ChannelServiceImpl extends BaseServiceImpl<Channel> implements Chan ...@@ -158,7 +165,7 @@ public class ChannelServiceImpl extends BaseServiceImpl<Channel> implements Chan
channel.setType(ChannelType.THIRD_PART.value); channel.setType(ChannelType.THIRD_PART.value);
channel.setExpand("nvs3000"); channel.setExpand("nvs3000");
channel.setStreamType(ChannelType.STREAM_RTSP.value); channel.setStreamType(ChannelType.STREAM_RTSP.value);
channel.setStreamPath(nvsRegex + id); channel.setStreamPath(nvsRegex.replace("{id}", id));
insertSelective(channel); insertSelective(channel);
success++; success++;
} }
......
...@@ -40,7 +40,7 @@ public class TaskDataService { ...@@ -40,7 +40,7 @@ public class TaskDataService {
// 获取存储配置 // 获取存储配置
Long storeConfigId = task.getStoreConfigId(); Long storeConfigId = task.getStoreConfigId();
JsonMessageUtil.JsonMessage<StoreConfig> storeConfigRes = opsClient.getStoreConfigById(storeConfigId); JsonMessageUtil.JsonMessage<StoreConfig> storeConfigRes = opsClient.getStoreConfigById(storeConfigId);
StoreConfig storeConfigVo = (StoreConfig) storeConfigRes.getData(); StoreConfig storeConfigVo = storeConfigRes.getData();
if (storeConfigVo == null) { if (storeConfigVo == null) {
throw new FanXingException("无法获取对应的存储配置"); throw new FanXingException("无法获取对应的存储配置");
} }
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" <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">
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> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
...@@ -22,6 +20,28 @@ ...@@ -22,6 +20,28 @@
<module>fanxing-query</module> <module>fanxing-query</module>
</modules> </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> <dependencyManagement>
<dependencies> <dependencies>
<dependency> <dependency>
...@@ -44,4 +64,30 @@ ...@@ -44,4 +64,30 @@
<artifactId>spring-boot-starter-actuator</artifactId> <artifactId>spring-boot-starter-actuator</artifactId>
</dependency> </dependency>
</dependencies> </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> </project>
\ No newline at end of file \ 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!