From dc6769664e36ffc70ea3af597e4f3dbb93c2b6bf Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期四, 26 五月 2022 12:10:46 +0800
Subject: [PATCH] 兼容不规范的时间格式iso8601格式;升级fastjson版本

---
 src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java             |    1 
 web_src/src/components/service/DeviceService.js                                     |   33 +++++-----
 src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java               |    5 +
 src/main/java/com/genersoft/iot/vmp/utils/DateUtil.java                             |   42 +++++++++++--
 src/main/java/com/genersoft/iot/vmp/media/zlm/event/ZLMStatusEventListener.java     |    2 
 src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/alarm/AlarmController.java     |   18 +----
 src/main/java/com/genersoft/iot/vmp/vmanager/log/LogController.java                 |    9 --
 pom.xml                                                                             |    3 
 README.md                                                                           |    1 
 src/test/java/com/genersoft/iot/vmp/service/impl/DeviceAlarmServiceImplTest.java    |   23 +++++--
 src/main/java/com/genersoft/iot/vmp/gb28181/session/VideoStreamSessionManager.java  |    7 +-
 src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java              |    1 
 src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java        |   13 ++-
 src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/record/GBRecordController.java |    4 
 src/main/java/com/genersoft/iot/vmp/service/IPlayService.java                       |    2 
 15 files changed, 95 insertions(+), 69 deletions(-)

diff --git a/README.md b/README.md
index 7ba443f..1b8b985 100644
--- a/README.md
+++ b/README.md
@@ -163,6 +163,7 @@
 [hotcoffie](https://github.com/hotcoffie) [xiaomu](https://github.com/nikmu) [TristingChen](https://github.com/TristingChen)
 [chenparty](https://github.com/chenparty) [Hotleave](https://github.com/hotleave) [ydwxb](https://github.com/ydwxb)
 [ydpd](https://github.com/ydpd) [szy833](https://github.com/szy833) [ydwxb](https://github.com/ydwxb) [Albertzhu666](https://github.com/Albertzhu666)
+[mk1990](https://github.com/mk1990)
 
 ps: 鍒氬鍔犱簡杩欎釜鍚嶅崟锛岃偗瀹氶仐婕忎簡涓�浜涘ぇ浣紝娆㈣繋澶т浆鑱旂郴鎴戞坊鍔犮��
 
diff --git a/pom.xml b/pom.xml
index 1546e39..9ad41c7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -159,9 +159,10 @@
 		<dependency>
 			<groupId>com.alibaba</groupId>
 			<artifactId>fastjson</artifactId>
-			<version>1.2.73</version>
+			<version>1.2.83</version>
 		</dependency>
 
+
 		<!-- okhttp -->
 		<dependency>
 			<groupId>com.squareup.okhttp3</groupId>
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/session/VideoStreamSessionManager.java b/src/main/java/com/genersoft/iot/vmp/gb28181/session/VideoStreamSessionManager.java
index 85bc39d..2b76ff7 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/session/VideoStreamSessionManager.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/session/VideoStreamSessionManager.java
@@ -99,8 +99,8 @@
 		return dialog;
 	}
 
-	public SIPDialog getDialogByCallId(String deviceId, String channelId, String callID){
-		SsrcTransaction ssrcTransaction = getSsrcTransaction(deviceId, channelId, callID, null);
+	public SIPDialog getDialogByCallId(String deviceId, String channelId, String callId){
+		SsrcTransaction ssrcTransaction = getSsrcTransaction(deviceId, channelId, callId, null);
 		if (ssrcTransaction == null) {
 			return null;
 		}
@@ -108,8 +108,7 @@
 		if (dialogByteArray == null) {
 			return null;
 		}
-		SIPDialog dialog = (SIPDialog)SerializeUtils.deSerialize(dialogByteArray);
-		return dialog;
+		return (SIPDialog)SerializeUtils.deSerialize(dialogByteArray);
 	}
 
 	public SsrcTransaction getSsrcTransaction(String deviceId, String channelId, String callId, String stream){
diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
index 7f62968..3694fdf 100644
--- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
+++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
@@ -11,7 +11,6 @@
 import com.genersoft.iot.vmp.gb28181.bean.GbStream;
 import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction;
 import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
-import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
 import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
 import com.genersoft.iot.vmp.media.zlm.dto.*;
 import com.genersoft.iot.vmp.service.*;
diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/event/ZLMStatusEventListener.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/event/ZLMStatusEventListener.java
index f4a9feb..223ef13 100644
--- a/src/main/java/com/genersoft/iot/vmp/media/zlm/event/ZLMStatusEventListener.java
+++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/event/ZLMStatusEventListener.java
@@ -42,7 +42,7 @@
 		logger.info("[ZLM] 涓婄嚎 ID锛�" + event.getMediaServerId());
 		streamPushService.zlmServerOnline(event.getMediaServerId());
 		streamProxyService.zlmServerOnline(event.getMediaServerId());
-
+		playService.zlmServerOnline(event.getMediaServerId());
 	}
 
 	@Async
diff --git a/src/main/java/com/genersoft/iot/vmp/service/IPlayService.java b/src/main/java/com/genersoft/iot/vmp/service/IPlayService.java
index 9e76493..0b758d8 100644
--- a/src/main/java/com/genersoft/iot/vmp/service/IPlayService.java
+++ b/src/main/java/com/genersoft/iot/vmp/service/IPlayService.java
@@ -40,4 +40,6 @@
     DeferredResult<ResponseEntity<String>> download(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo,String deviceId,  String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack);
 
     StreamInfo getDownLoadInfo(String deviceId, String channelId, String stream);
+
+    void zlmServerOnline(String mediaServerId);
 }
diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java
index e4a2a19..77c7c61 100644
--- a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java
+++ b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java
@@ -68,7 +68,6 @@
         if (deviceInRedis != null && deviceInDb == null) {
             // redis 瀛樺湪鑴忔暟鎹�
             redisCatchStorage.clearCatchByDeviceId(device.getDeviceId());
-
         }
         device.setUpdateTime(now);
         device.setOnline(1);
diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java
index 5468fae..8ad57e8 100644
--- a/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java
+++ b/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java
@@ -6,6 +6,7 @@
 import com.genersoft.iot.vmp.common.VideoManagerConstants;
 import com.genersoft.iot.vmp.conf.SipConfig;
 import com.genersoft.iot.vmp.conf.UserSetting;
+import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction;
 import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
 import com.genersoft.iot.vmp.gb28181.session.SsrcConfig;
 import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
@@ -35,7 +36,9 @@
 
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
+import java.time.LocalDateTime;
 import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * 濯掍綋鏈嶅姟鍣ㄨ妭鐐圭鐞�
@@ -189,6 +192,7 @@
     public void clearRTPServer(MediaServerItem mediaServerItem) {
         mediaServerItem.setSsrcConfig(new SsrcConfig(mediaServerItem.getId(), null, sipConfig.getDomain()));
         redisUtil.zAdd(VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX + userSetting.getServerId(), mediaServerItem.getId(), 0);
+
     }
 
 
@@ -229,11 +233,10 @@
         }
         result.sort((serverItem1, serverItem2)->{
             int sortResult = 0;
-            try {
-                sortResult = DateUtil.format.parse(serverItem1.getCreateTime()).compareTo(DateUtil.format.parse(serverItem2.getCreateTime()));
-            } catch (ParseException e) {
-                e.printStackTrace();
-            }
+            LocalDateTime localDateTime1 = LocalDateTime.parse(serverItem1.getCreateTime(), DateUtil.formatter);
+            LocalDateTime localDateTime2 = LocalDateTime.parse(serverItem2.getCreateTime(), DateUtil.formatter);
+
+            sortResult = localDateTime1.compareTo(localDateTime2);
             return  sortResult;
         });
         return result;
diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
index 2521a06..b164492 100644
--- a/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
+++ b/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
@@ -648,4 +648,9 @@
             }
         }
     }
+
+    @Override
+    public void zlmServerOnline(String mediaServerId) {
+        // 浼间箮娌″暐闇�瑕佸仛鐨�
+    }
 }
diff --git a/src/main/java/com/genersoft/iot/vmp/utils/DateUtil.java b/src/main/java/com/genersoft/iot/vmp/utils/DateUtil.java
index 9d37dcd..787bdae 100644
--- a/src/main/java/com/genersoft/iot/vmp/utils/DateUtil.java
+++ b/src/main/java/com/genersoft/iot/vmp/utils/DateUtil.java
@@ -18,35 +18,61 @@
  */
 public class DateUtil {
 
-	private static final String yyyy_MM_dd_T_HH_mm_ss_SSSXXX = "yyyy-MM-dd'T'HH:mm:ss";
-    public static final String yyyy_MM_dd_HH_mm_ss = "yyyy-MM-dd HH:mm:ss";
+    /**
+     * 鍏煎涓嶈鑼冪殑iso8601鏃堕棿鏍煎紡
+     */
+	private static final String ISO8601_COMPATIBLE_PATTERN = "yyyy-M-d'T'H:m:s";
 
-    public static final SimpleDateFormat formatISO8601 = new SimpleDateFormat(yyyy_MM_dd_T_HH_mm_ss_SSSXXX, Locale.getDefault());
-    public static final SimpleDateFormat format = new SimpleDateFormat(yyyy_MM_dd_HH_mm_ss, Locale.getDefault());
+    /**
+     * 鐢ㄤ互杈撳嚭鏍囧噯鐨刬so8601鏃堕棿鏍煎紡
+     */
+	private static final String ISO8601_PATTERN = "yyyy-MM-dd'T'HH:mm:ss";
 
-    public static final DateTimeFormatter formatterISO8601 = DateTimeFormatter.ofPattern(yyyy_MM_dd_T_HH_mm_ss_SSSXXX, Locale.getDefault()).withZone(ZoneId.systemDefault());
-    public static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern(yyyy_MM_dd_HH_mm_ss, Locale.getDefault()).withZone(ZoneId.systemDefault());
+    /**
+     * wvp鍐呴儴缁熶竴鏃堕棿鏍煎紡
+     */
+    public static final String PATTERN = "yyyy-MM-dd HH:mm:ss";
+
+
+    public static final DateTimeFormatter formatterCompatibleISO8601 = DateTimeFormatter.ofPattern(ISO8601_COMPATIBLE_PATTERN, Locale.getDefault()).withZone(ZoneId.systemDefault());
+    public static final DateTimeFormatter formatterISO8601 = DateTimeFormatter.ofPattern(ISO8601_PATTERN, Locale.getDefault()).withZone(ZoneId.systemDefault());
+    public static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern(PATTERN, Locale.getDefault()).withZone(ZoneId.systemDefault());
 
 	public static String yyyy_MM_dd_HH_mm_ssToISO8601(String formatTime) {
         return formatterISO8601.format(formatter.parse(formatTime));
     }
 	
 	public static String ISO8601Toyyyy_MM_dd_HH_mm_ss(String formatTime) {
-        return formatter.format(formatterISO8601.parse(formatTime));
+        return formatter.format(formatterCompatibleISO8601.parse(formatTime));
 
     }
-	
+
+    /**
+     * yyyy_MM_dd_HH_mm_ss 杞椂闂存埑
+     * @param formatTime
+     * @return
+     */
 	public static long yyyy_MM_dd_HH_mm_ssToTimestamp(String formatTime) {
         TemporalAccessor temporalAccessor = formatter.parse(formatTime);
         Instant instant = Instant.from(temporalAccessor);
         return instant.getEpochSecond();
 	}
 
+    /**
+     * 鑾峰彇褰撳墠鏃堕棿
+     * @return
+     */
     public static String getNow() {
         LocalDateTime nowDateTime = LocalDateTime.now();
         return formatter.format(nowDateTime);
     }
 
+    /**
+     * 鏍煎紡鏍¢獙
+     * @param timeStr 鏃堕棿瀛楃涓�
+     * @param dateTimeFormatter 寰呮牎楠岀殑鏍煎紡
+     * @return
+     */
     public static boolean verification(String timeStr, DateTimeFormatter dateTimeFormatter) {
         try {
             LocalDate.parse(timeStr, dateTimeFormatter);
diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/alarm/AlarmController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/alarm/AlarmController.java
index 56864db..0edec51 100644
--- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/alarm/AlarmController.java
+++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/alarm/AlarmController.java
@@ -24,6 +24,7 @@
 import org.springframework.web.bind.annotation.*;
 
 import java.text.ParseException;
+import java.time.LocalDateTime;
 import java.util.Arrays;
 import java.util.List;
 
@@ -98,14 +99,7 @@
         }
 
 
-        try {
-            if (startTime != null) {
-                DateUtil.format.parse(startTime);
-            }
-            if (endTime != null) {
-                DateUtil.format.parse(endTime);
-            }
-        } catch (ParseException e) {
+        if (!DateUtil.verification(startTime, DateUtil.formatter) || !DateUtil.verification(endTime, DateUtil.formatter)){
             return new ResponseEntity<>(null, HttpStatus.BAD_REQUEST);
         }
 
@@ -144,11 +138,7 @@
         if (StringUtils.isEmpty(time)) {
             time = null;
         }
-        try {
-            if (time != null) {
-                DateUtil.format.parse(time);
-            }
-        } catch (ParseException e) {
+        if (!DateUtil.verification(time, DateUtil.formatter) ){
             return new ResponseEntity<>(null, HttpStatus.BAD_REQUEST);
         }
         List<String> deviceIdList = null;
@@ -189,7 +179,7 @@
         deviceAlarm.setAlarmDescription("test");
         deviceAlarm.setAlarmMethod("1");
         deviceAlarm.setAlarmPriority("1");
-        deviceAlarm.setAlarmTime(DateUtil.formatISO8601.format(System.currentTimeMillis()));
+        deviceAlarm.setAlarmTime(DateUtil.formatterISO8601.format(LocalDateTime.now()));
         deviceAlarm.setAlarmType("1");
         deviceAlarm.setLongitude(115.33333);
         deviceAlarm.setLatitude(39.33333);
diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/record/GBRecordController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/record/GBRecordController.java
index 8cb923a..f0f2eb2 100644
--- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/record/GBRecordController.java
+++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/record/GBRecordController.java
@@ -72,7 +72,7 @@
 		if (!DateUtil.verification(startTime, DateUtil.formatter)){
 			WVPResult<RecordInfo> wvpResult = new WVPResult<>();
 			wvpResult.setCode(-1);
-			wvpResult.setMsg("startTime error, format is " + DateUtil.yyyy_MM_dd_HH_mm_ss);
+			wvpResult.setMsg("startTime error, format is " + DateUtil.PATTERN);
 
 			ResponseEntity<WVPResult<RecordInfo>> resultResponseEntity = new ResponseEntity<>(wvpResult, HttpStatus.OK);
 			result.setResult(resultResponseEntity);
@@ -81,7 +81,7 @@
 		if (!DateUtil.verification(endTime, DateUtil.formatter)){
 			WVPResult<RecordInfo> wvpResult = new WVPResult<>();
 			wvpResult.setCode(-1);
-			wvpResult.setMsg("endTime error, format is " + DateUtil.yyyy_MM_dd_HH_mm_ss);
+			wvpResult.setMsg("endTime error, format is " + DateUtil.PATTERN);
 			ResponseEntity<WVPResult<RecordInfo>> resultResponseEntity = new ResponseEntity<>(wvpResult, HttpStatus.OK);
 			result.setResult(resultResponseEntity);
 			return result;
diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/log/LogController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/log/LogController.java
index 65f5f7c..a9b23ef 100644
--- a/src/main/java/com/genersoft/iot/vmp/vmanager/log/LogController.java
+++ b/src/main/java/com/genersoft/iot/vmp/vmanager/log/LogController.java
@@ -76,14 +76,7 @@
             logger.warn("鑷姩璁板綍鏃ュ織鍔熻兘宸插叧闂紝鏌ヨ缁撴灉鍙兘涓嶅畬鏁淬��");
         }
 
-        try {
-            if (startTime != null) {
-                DateUtil.format.parse(startTime);
-            }
-            if (endTime != null) {
-                DateUtil.format.parse(endTime);
-            }
-        } catch (ParseException e) {
+        if (!DateUtil.verification(startTime, DateUtil.formatter) || !DateUtil.verification(endTime, DateUtil.formatter)){
             return new ResponseEntity<>(null, HttpStatus.BAD_REQUEST);
         }
 
diff --git a/src/test/java/com/genersoft/iot/vmp/service/impl/DeviceAlarmServiceImplTest.java b/src/test/java/com/genersoft/iot/vmp/service/impl/DeviceAlarmServiceImplTest.java
index 6d6ff37..c627511 100644
--- a/src/test/java/com/genersoft/iot/vmp/service/impl/DeviceAlarmServiceImplTest.java
+++ b/src/test/java/com/genersoft/iot/vmp/service/impl/DeviceAlarmServiceImplTest.java
@@ -8,6 +8,10 @@
 import org.springframework.test.context.junit4.SpringRunner;
 
 import javax.annotation.Resource;
+import java.time.Instant;
+import java.time.LocalDateTime;
+import java.time.ZoneOffset;
+import java.time.temporal.TemporalAccessor;
 import java.util.Date;
 
 
@@ -64,8 +68,8 @@
              * 	 * 7鍏朵粬鎶ヨ;鍙互涓虹洿鎺ョ粍鍚堝12涓虹數璇濇姤璀︽垨 璁惧鎶ヨ-
              */
             deviceAlarm.setAlarmMethod((int)(Math.random()*7 + 1) + "");
-            Date date = randomDate("2021-01-01 00:00:00", "2021-06-01 00:00:00");
-            deviceAlarm.setAlarmTime(DateUtil.format.format(date));
+            Instant date = randomDate("2021-01-01 00:00:00", "2021-06-01 00:00:00");
+            deviceAlarm.setAlarmTime(DateUtil.formatter.format(date));
             /**
              * 鎶ヨ绾у埆, 1涓轰竴绾ц鎯�, 2涓轰簩绾ц鎯�, 3涓轰笁绾ц鎯�, 4涓哄洓绾� 璀︽儏-
              */
@@ -85,17 +89,20 @@
 
 
 
-    private Date randomDate(String beginDate, String endDate) {
+    private Instant randomDate(String beginDate, String endDate) {
         try {
 
-            Date start = DateUtil.format.parse(beginDate);//鏋勯�犲紑濮嬫棩鏈�
-            Date end = DateUtil.format.parse(endDate);//鏋勯�犵粨鏉熸棩鏈�
+            //鏋勯�犲紑濮嬫棩鏈�
+            LocalDateTime start = LocalDateTime.parse(beginDate, DateUtil.formatter);
+
+            //鏋勯�犵粨鏉熸棩鏈�
+            LocalDateTime end = LocalDateTime.parse(endDate, DateUtil.formatter);
             //getTime()琛ㄧず杩斿洖鑷� 1970 骞� 1 鏈� 1 鏃� 00:00:00 GMT 浠ユ潵姝� Date 瀵硅薄琛ㄧず鐨勬绉掓暟銆�
-            if (start.getTime() >= end.getTime()) {
+            if (start.isAfter(end)) {
                 return null;
             }
-            long date = random(start.getTime(), end.getTime());
-            return new Date(date);
+            long date = random(start.toInstant(ZoneOffset.of("+8")).toEpochMilli(), end.toInstant(ZoneOffset.of("+8")).toEpochMilli());
+            return Instant.ofEpochMilli(date);
         } catch (Exception e) {
             e.printStackTrace();
         }
diff --git a/web_src/src/components/service/DeviceService.js b/web_src/src/components/service/DeviceService.js
index dbe10d1..4700e79 100644
--- a/web_src/src/components/service/DeviceService.js
+++ b/web_src/src/components/service/DeviceService.js
@@ -21,47 +21,47 @@
       if (typeof (errorCallback) == "function") errorCallback(error)
     });
   }
-  getAllDeviceList(callback, errorCallback) {
+  getAllDeviceList(callback,endCallback, errorCallback) {
     let currentPage = 1;
     let count = 100;
     let deviceList = []
-    this.getAllDeviceListIteration(deviceList, currentPage, count, (data) => {
-      if (typeof (callback) == "function") callback(data)
-    }, errorCallback)
+    this.getAllDeviceListIteration(deviceList, currentPage, count, callback, endCallback, errorCallback)
   }
 
-  getAllDeviceListIteration(deviceList, currentPage, count, callback, errorCallback) {
+  getAllDeviceListIteration(deviceList, currentPage, count, callback, endCallback, errorCallback) {
     this.getDeviceList(currentPage, count, (data) => {
       if (data.list) {
+        if (typeof (callback) == "function") callback(data.list)
         deviceList = deviceList.concat(data.list);
         if (deviceList.length < data.total) {
           currentPage ++
-          this.getAllDeviceListIteration(deviceList, currentPage, count, callback, errorCallback)
+          this.getAllDeviceListIteration(deviceList, currentPage, count, callback,  endCallback, errorCallback)
         }else {
-          if (typeof (callback) == "function") callback(deviceList)
+          if (typeof (endCallback) == "function") endCallback(deviceList)
         }
       }
     }, errorCallback)
   }
 
 
-  getAllChannel(isCatalog, catalogUnderDevice, deviceId, callback, errorCallback) {
+  getAllChannel(isCatalog, catalogUnderDevice, deviceId, callback, endCallback, errorCallback) {
     let currentPage = 1;
     let count = 100;
     let catalogList = []
-    this.getAllChannelIteration(isCatalog, catalogUnderDevice, deviceId, catalogList, currentPage, count, callback, errorCallback)
+    this.getAllChannelIteration(isCatalog, catalogUnderDevice, deviceId, catalogList, currentPage, count, callback, endCallback, errorCallback)
   }
 
-  getAllChannelIteration(isCatalog, catalogUnderDevice, deviceId, catalogList, currentPage, count, callback, errorCallback) {
+  getAllChannelIteration(isCatalog, catalogUnderDevice, deviceId, catalogList, currentPage, count, callback, endCallback, errorCallback) {
     this.getChanel(isCatalog, catalogUnderDevice, deviceId, currentPage, count, (data) => {
       if (data.list) {
+        if (typeof (callback) == "function") callback(data.list)
         catalogList = catalogList.concat(data.list);
         if (catalogList.length < data.total) {
           currentPage ++
           this.getAllChannelIteration(isCatalog,catalogUnderDevice, deviceId, catalogList, currentPage, count, callback, errorCallback)
         }else {
           console.log(1)
-          if (typeof (callback) == "function") callback(catalogList)
+          if (typeof (endCallback) == "function") endCallback(catalogList)
         }
       }
     }, errorCallback)
@@ -84,22 +84,23 @@
   }
 
 
-  getAllSubChannel(isCatalog, deviceId, channelId, callback, errorCallback) {
+  getAllSubChannel(isCatalog, deviceId, channelId, callback, endCallback, errorCallback) {
     let currentPage = 1;
     let count = 100;
     let catalogList = []
-    this.getAllSubChannelIteration(isCatalog, deviceId, channelId, catalogList, currentPage, count, callback, errorCallback)
+    this.getAllSubChannelIteration(isCatalog, deviceId, channelId, catalogList, currentPage, count, callback, endCallback, errorCallback)
   }
 
-  getAllSubChannelIteration(isCatalog, deviceId,channelId, catalogList, currentPage, count, callback, errorCallback) {
+  getAllSubChannelIteration(isCatalog, deviceId,channelId, catalogList, currentPage, count, callback, endCallback, errorCallback) {
     this.getSubChannel(isCatalog, deviceId, channelId, currentPage, count, (data) => {
       if (data.list) {
+        if (typeof (callback) == "function") callback(data.list)
         catalogList = catalogList.concat(data.list);
         if (catalogList.length < data.total) {
           currentPage ++
-          this.getAllSubChannelIteration(isCatalog, deviceId, channelId, catalogList, currentPage, count, callback, errorCallback)
+          this.getAllSubChannelIteration(isCatalog, deviceId, channelId, catalogList, currentPage, count, callback, endCallback, errorCallback)
         }else {
-          if (typeof (callback) == "function") callback(catalogList)
+          if (typeof (endCallback) == "function") endCallback(catalogList)
         }
       }
     }, errorCallback)

--
Gitblit v1.8.0