Commit c4fc4abf7cbaa621f7ca1946f67c786c6cd55b68

Authored by 648540858
1 parent 4a0037d1

优化代码空字符串判断

src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
... ... @@ -24,6 +24,8 @@ import org.springframework.beans.factory.annotation.Qualifier;
24 24 import org.springframework.beans.factory.annotation.Value;
25 25 import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
26 26 import org.springframework.stereotype.Service;
  27 +import org.springframework.util.ObjectUtils;
  28 +import org.springframework.util.StringUtils;
27 29 import org.springframework.web.context.request.async.DeferredResult;
28 30  
29 31 import com.alibaba.fastjson.JSON;
... ... @@ -405,12 +407,11 @@ public class PlayServiceImpl implements IPlayService {
405 407 if (device == null) {
406 408 return null;
407 409 }
408   - String mediaServerId = device.getMediaServerId();
409 410 MediaServerItem mediaServerItem;
410   - if (mediaServerId == null || "".equals(device.getMediaServerId()) || "auto".equals(device.getMediaServerId())) {
  411 + if (ObjectUtils.isEmpty(device.getMediaServerId()) || "auto".equals(device.getMediaServerId())) {
411 412 mediaServerItem = mediaServerService.getMediaServerForMinimumLoad();
412 413 } else {
413   - mediaServerItem = mediaServerService.getOne(mediaServerId);
  414 + mediaServerItem = mediaServerService.getOne(device.getMediaServerId());
414 415 }
415 416 if (mediaServerItem == null) {
416 417 logger.warn("点播时未找到可使用的ZLM...");
... ...
src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java
... ... @@ -98,7 +98,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
98 98 @Override
99 99 public StreamInfo save(StreamProxyItem param) {
100 100 MediaServerItem mediaInfo;
101   - if (param.getMediaServerId() == null || "".equals(param.getMediaServerId()) || "auto".equals(param.getMediaServerId())){
  101 + if (ObjectUtils.isEmpty(param.getMediaServerId()) || "auto".equals(param.getMediaServerId())){
102 102 mediaInfo = mediaServerService.getMediaServerForMinimumLoad();
103 103 }else {
104 104 mediaInfo = mediaServerService.getOne(param.getMediaServerId());
... ...
src/main/java/com/genersoft/iot/vmp/utils/CollectionUtil.java deleted 100644 → 0
1   -package com.genersoft.iot.vmp.utils;
2   -
3   -import java.util.Arrays;
4   -
5   -public class CollectionUtil {
6   -
7   - public static <T> boolean contains(T[] array, final T element) {
8   - return array != null && Arrays.stream(array).anyMatch((x) -> {
9   - return ObjectUtils.nullSafeEquals(x, element);
10   - });
11   - }
12   -}
src/main/java/com/genersoft/iot/vmp/utils/ObjectUtils.java deleted 100644 → 0
1   -package com.genersoft.iot.vmp.utils;
2   -
3   -import java.util.Arrays;
4   -
5   -public class ObjectUtils {
6   - public static boolean nullSafeEquals(Object o1, Object o2) {
7   - if (o1 == o2) {
8   - return true;
9   - } else if (o1 != null && o2 != null) {
10   - if (o1.equals(o2)) {
11   - return true;
12   - } else {
13   - return o1.getClass().isArray() && o2.getClass().isArray() && arrayEquals(o1, o2);
14   - }
15   - } else {
16   - return false;
17   - }
18   - }
19   -
20   - private static boolean arrayEquals(Object o1, Object o2) {
21   - if (o1 instanceof Object[] && o2 instanceof Object[]) {
22   - return Arrays.equals((Object[])((Object[])o1), (Object[])((Object[])o2));
23   - } else if (o1 instanceof boolean[] && o2 instanceof boolean[]) {
24   - return Arrays.equals((boolean[])((boolean[])o1), (boolean[])((boolean[])o2));
25   - } else if (o1 instanceof byte[] && o2 instanceof byte[]) {
26   - return Arrays.equals((byte[])((byte[])o1), (byte[])((byte[])o2));
27   - } else if (o1 instanceof char[] && o2 instanceof char[]) {
28   - return Arrays.equals((char[])((char[])o1), (char[])((char[])o2));
29   - } else if (o1 instanceof double[] && o2 instanceof double[]) {
30   - return Arrays.equals((double[])((double[])o1), (double[])((double[])o2));
31   - } else if (o1 instanceof float[] && o2 instanceof float[]) {
32   - return Arrays.equals((float[])((float[])o1), (float[])((float[])o2));
33   - } else if (o1 instanceof int[] && o2 instanceof int[]) {
34   - return Arrays.equals((int[])((int[])o1), (int[])((int[])o2));
35   - } else if (o1 instanceof long[] && o2 instanceof long[]) {
36   - return Arrays.equals((long[])((long[])o1), (long[])((long[])o2));
37   - } else {
38   - return o1 instanceof short[] && o2 instanceof short[] && Arrays.equals((short[]) ((short[]) o1), (short[]) ((short[]) o2));
39   - }
40   - }
41   -}