Commit dc6769664e36ffc70ea3af597e4f3dbb93c2b6bf
1 parent
63263081
兼容不规范的时间格式iso8601格式;升级fastjson版本
Showing
15 changed files
with
95 additions
and
69 deletions
README.md
| ... | ... | @@ -163,6 +163,7 @@ QQ遘∽ソ。荳闊ャ荳榊屓, 邊セ蜉帶怏髯.谺「霑主、ァ螳カ蝨ィ鄒、驥瑚ョィ隶コ.隗牙セ鈴。ケ逶ョ蟇ケ菴 |
| 163 | 163 | [hotcoffie](https://github.com/hotcoffie) [xiaomu](https://github.com/nikmu) [TristingChen](https://github.com/TristingChen) |
| 164 | 164 | [chenparty](https://github.com/chenparty) [Hotleave](https://github.com/hotleave) [ydwxb](https://github.com/ydwxb) |
| 165 | 165 | [ydpd](https://github.com/ydpd) [szy833](https://github.com/szy833) [ydwxb](https://github.com/ydwxb) [Albertzhu666](https://github.com/Albertzhu666) |
| 166 | +[mk1990](https://github.com/mk1990) | |
| 166 | 167 | |
| 167 | 168 | ps: 蛻壼「槫刈莠ソ吩クェ蜷榊黒瑚け螳夐@貍丈コク莠帛、ァ菴ャ梧ャ「霑主、ァ菴ャ閨皮ウサ謌第キサ蜉縲 |
| 168 | 169 | ... | ... |
pom.xml
| ... | ... | @@ -159,9 +159,10 @@ |
| 159 | 159 | <dependency> |
| 160 | 160 | <groupId>com.alibaba</groupId> |
| 161 | 161 | <artifactId>fastjson</artifactId> |
| 162 | - <version>1.2.73</version> | |
| 162 | + <version>1.2.83</version> | |
| 163 | 163 | </dependency> |
| 164 | 164 | |
| 165 | + | |
| 165 | 166 | <!-- okhttp --> |
| 166 | 167 | <dependency> |
| 167 | 168 | <groupId>com.squareup.okhttp3</groupId> | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/session/VideoStreamSessionManager.java
| ... | ... | @@ -99,8 +99,8 @@ public class VideoStreamSessionManager { |
| 99 | 99 | return dialog; |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - public SIPDialog getDialogByCallId(String deviceId, String channelId, String callID){ | |
| 103 | - SsrcTransaction ssrcTransaction = getSsrcTransaction(deviceId, channelId, callID, null); | |
| 102 | + public SIPDialog getDialogByCallId(String deviceId, String channelId, String callId){ | |
| 103 | + SsrcTransaction ssrcTransaction = getSsrcTransaction(deviceId, channelId, callId, null); | |
| 104 | 104 | if (ssrcTransaction == null) { |
| 105 | 105 | return null; |
| 106 | 106 | } |
| ... | ... | @@ -108,8 +108,7 @@ public class VideoStreamSessionManager { |
| 108 | 108 | if (dialogByteArray == null) { |
| 109 | 109 | return null; |
| 110 | 110 | } |
| 111 | - SIPDialog dialog = (SIPDialog)SerializeUtils.deSerialize(dialogByteArray); | |
| 112 | - return dialog; | |
| 111 | + return (SIPDialog)SerializeUtils.deSerialize(dialogByteArray); | |
| 113 | 112 | } |
| 114 | 113 | |
| 115 | 114 | public SsrcTransaction getSsrcTransaction(String deviceId, String channelId, String callId, String stream){ | ... | ... |
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
| ... | ... | @@ -11,7 +11,6 @@ import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; |
| 11 | 11 | import com.genersoft.iot.vmp.gb28181.bean.GbStream; |
| 12 | 12 | import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction; |
| 13 | 13 | import com.genersoft.iot.vmp.gb28181.event.EventPublisher; |
| 14 | -import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent; | |
| 15 | 14 | import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; |
| 16 | 15 | import com.genersoft.iot.vmp.media.zlm.dto.*; |
| 17 | 16 | import com.genersoft.iot.vmp.service.*; | ... | ... |
src/main/java/com/genersoft/iot/vmp/media/zlm/event/ZLMStatusEventListener.java
| ... | ... | @@ -42,7 +42,7 @@ public class ZLMStatusEventListener { |
| 42 | 42 | logger.info("[ZLM] 上线 ID:" + event.getMediaServerId()); |
| 43 | 43 | streamPushService.zlmServerOnline(event.getMediaServerId()); |
| 44 | 44 | streamProxyService.zlmServerOnline(event.getMediaServerId()); |
| 45 | - | |
| 45 | + playService.zlmServerOnline(event.getMediaServerId()); | |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | @Async | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/IPlayService.java
| ... | ... | @@ -40,4 +40,6 @@ public interface IPlayService { |
| 40 | 40 | DeferredResult<ResponseEntity<String>> download(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo,String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack); |
| 41 | 41 | |
| 42 | 42 | StreamInfo getDownLoadInfo(String deviceId, String channelId, String stream); |
| 43 | + | |
| 44 | + void zlmServerOnline(String mediaServerId); | |
| 43 | 45 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java
| ... | ... | @@ -68,7 +68,6 @@ public class DeviceServiceImpl implements IDeviceService { |
| 68 | 68 | if (deviceInRedis != null && deviceInDb == null) { |
| 69 | 69 | // redis 存在脏数据 |
| 70 | 70 | redisCatchStorage.clearCatchByDeviceId(device.getDeviceId()); |
| 71 | - | |
| 72 | 71 | } |
| 73 | 72 | device.setUpdateTime(now); |
| 74 | 73 | device.setOnline(1); | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java
| ... | ... | @@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject; |
| 6 | 6 | import com.genersoft.iot.vmp.common.VideoManagerConstants; |
| 7 | 7 | import com.genersoft.iot.vmp.conf.SipConfig; |
| 8 | 8 | import com.genersoft.iot.vmp.conf.UserSetting; |
| 9 | +import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction; | |
| 9 | 10 | import com.genersoft.iot.vmp.gb28181.event.EventPublisher; |
| 10 | 11 | import com.genersoft.iot.vmp.gb28181.session.SsrcConfig; |
| 11 | 12 | import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; |
| ... | ... | @@ -35,7 +36,9 @@ import org.springframework.util.StringUtils; |
| 35 | 36 | |
| 36 | 37 | import java.text.ParseException; |
| 37 | 38 | import java.text.SimpleDateFormat; |
| 39 | +import java.time.LocalDateTime; | |
| 38 | 40 | import java.util.*; |
| 41 | +import java.util.stream.Collectors; | |
| 39 | 42 | |
| 40 | 43 | /** |
| 41 | 44 | * 媒体服务器节点管理 |
| ... | ... | @@ -189,6 +192,7 @@ public class MediaServerServiceImpl implements IMediaServerService { |
| 189 | 192 | public void clearRTPServer(MediaServerItem mediaServerItem) { |
| 190 | 193 | mediaServerItem.setSsrcConfig(new SsrcConfig(mediaServerItem.getId(), null, sipConfig.getDomain())); |
| 191 | 194 | redisUtil.zAdd(VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX + userSetting.getServerId(), mediaServerItem.getId(), 0); |
| 195 | + | |
| 192 | 196 | } |
| 193 | 197 | |
| 194 | 198 | |
| ... | ... | @@ -229,11 +233,10 @@ public class MediaServerServiceImpl implements IMediaServerService { |
| 229 | 233 | } |
| 230 | 234 | result.sort((serverItem1, serverItem2)->{ |
| 231 | 235 | int sortResult = 0; |
| 232 | - try { | |
| 233 | - sortResult = DateUtil.format.parse(serverItem1.getCreateTime()).compareTo(DateUtil.format.parse(serverItem2.getCreateTime())); | |
| 234 | - } catch (ParseException e) { | |
| 235 | - e.printStackTrace(); | |
| 236 | - } | |
| 236 | + LocalDateTime localDateTime1 = LocalDateTime.parse(serverItem1.getCreateTime(), DateUtil.formatter); | |
| 237 | + LocalDateTime localDateTime2 = LocalDateTime.parse(serverItem2.getCreateTime(), DateUtil.formatter); | |
| 238 | + | |
| 239 | + sortResult = localDateTime1.compareTo(localDateTime2); | |
| 237 | 240 | return sortResult; |
| 238 | 241 | }); |
| 239 | 242 | return result; | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
src/main/java/com/genersoft/iot/vmp/utils/DateUtil.java
| ... | ... | @@ -18,35 +18,61 @@ import java.util.Locale; |
| 18 | 18 | */ |
| 19 | 19 | public class DateUtil { |
| 20 | 20 | |
| 21 | - private static final String yyyy_MM_dd_T_HH_mm_ss_SSSXXX = "yyyy-MM-dd'T'HH:mm:ss"; | |
| 22 | - public static final String yyyy_MM_dd_HH_mm_ss = "yyyy-MM-dd HH:mm:ss"; | |
| 21 | + /** | |
| 22 | + * 兼容不规范的iso8601时间格式 | |
| 23 | + */ | |
| 24 | + private static final String ISO8601_COMPATIBLE_PATTERN = "yyyy-M-d'T'H:m:s"; | |
| 23 | 25 | |
| 24 | - public static final SimpleDateFormat formatISO8601 = new SimpleDateFormat(yyyy_MM_dd_T_HH_mm_ss_SSSXXX, Locale.getDefault()); | |
| 25 | - public static final SimpleDateFormat format = new SimpleDateFormat(yyyy_MM_dd_HH_mm_ss, Locale.getDefault()); | |
| 26 | + /** | |
| 27 | + * 用以输出标准的iso8601时间格式 | |
| 28 | + */ | |
| 29 | + private static final String ISO8601_PATTERN = "yyyy-MM-dd'T'HH:mm:ss"; | |
| 26 | 30 | |
| 27 | - public static final DateTimeFormatter formatterISO8601 = DateTimeFormatter.ofPattern(yyyy_MM_dd_T_HH_mm_ss_SSSXXX, Locale.getDefault()).withZone(ZoneId.systemDefault()); | |
| 28 | - public static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern(yyyy_MM_dd_HH_mm_ss, Locale.getDefault()).withZone(ZoneId.systemDefault()); | |
| 31 | + /** | |
| 32 | + * wvp内部统一时间格式 | |
| 33 | + */ | |
| 34 | + public static final String PATTERN = "yyyy-MM-dd HH:mm:ss"; | |
| 35 | + | |
| 36 | + | |
| 37 | + public static final DateTimeFormatter formatterCompatibleISO8601 = DateTimeFormatter.ofPattern(ISO8601_COMPATIBLE_PATTERN, Locale.getDefault()).withZone(ZoneId.systemDefault()); | |
| 38 | + public static final DateTimeFormatter formatterISO8601 = DateTimeFormatter.ofPattern(ISO8601_PATTERN, Locale.getDefault()).withZone(ZoneId.systemDefault()); | |
| 39 | + public static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern(PATTERN, Locale.getDefault()).withZone(ZoneId.systemDefault()); | |
| 29 | 40 | |
| 30 | 41 | public static String yyyy_MM_dd_HH_mm_ssToISO8601(String formatTime) { |
| 31 | 42 | return formatterISO8601.format(formatter.parse(formatTime)); |
| 32 | 43 | } |
| 33 | 44 | |
| 34 | 45 | public static String ISO8601Toyyyy_MM_dd_HH_mm_ss(String formatTime) { |
| 35 | - return formatter.format(formatterISO8601.parse(formatTime)); | |
| 46 | + return formatter.format(formatterCompatibleISO8601.parse(formatTime)); | |
| 36 | 47 | |
| 37 | 48 | } |
| 38 | - | |
| 49 | + | |
| 50 | + /** | |
| 51 | + * yyyy_MM_dd_HH_mm_ss 转时间戳 | |
| 52 | + * @param formatTime | |
| 53 | + * @return | |
| 54 | + */ | |
| 39 | 55 | public static long yyyy_MM_dd_HH_mm_ssToTimestamp(String formatTime) { |
| 40 | 56 | TemporalAccessor temporalAccessor = formatter.parse(formatTime); |
| 41 | 57 | Instant instant = Instant.from(temporalAccessor); |
| 42 | 58 | return instant.getEpochSecond(); |
| 43 | 59 | } |
| 44 | 60 | |
| 61 | + /** | |
| 62 | + * 获取当前时间 | |
| 63 | + * @return | |
| 64 | + */ | |
| 45 | 65 | public static String getNow() { |
| 46 | 66 | LocalDateTime nowDateTime = LocalDateTime.now(); |
| 47 | 67 | return formatter.format(nowDateTime); |
| 48 | 68 | } |
| 49 | 69 | |
| 70 | + /** | |
| 71 | + * 格式校验 | |
| 72 | + * @param timeStr 时间字符串 | |
| 73 | + * @param dateTimeFormatter 待校验的格式 | |
| 74 | + * @return | |
| 75 | + */ | |
| 50 | 76 | public static boolean verification(String timeStr, DateTimeFormatter dateTimeFormatter) { |
| 51 | 77 | try { |
| 52 | 78 | LocalDate.parse(timeStr, dateTimeFormatter); | ... | ... |
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/alarm/AlarmController.java
| ... | ... | @@ -24,6 +24,7 @@ import org.springframework.util.StringUtils; |
| 24 | 24 | import org.springframework.web.bind.annotation.*; |
| 25 | 25 | |
| 26 | 26 | import java.text.ParseException; |
| 27 | +import java.time.LocalDateTime; | |
| 27 | 28 | import java.util.Arrays; |
| 28 | 29 | import java.util.List; |
| 29 | 30 | |
| ... | ... | @@ -98,14 +99,7 @@ public class AlarmController { |
| 98 | 99 | } |
| 99 | 100 | |
| 100 | 101 | |
| 101 | - try { | |
| 102 | - if (startTime != null) { | |
| 103 | - DateUtil.format.parse(startTime); | |
| 104 | - } | |
| 105 | - if (endTime != null) { | |
| 106 | - DateUtil.format.parse(endTime); | |
| 107 | - } | |
| 108 | - } catch (ParseException e) { | |
| 102 | + if (!DateUtil.verification(startTime, DateUtil.formatter) || !DateUtil.verification(endTime, DateUtil.formatter)){ | |
| 109 | 103 | return new ResponseEntity<>(null, HttpStatus.BAD_REQUEST); |
| 110 | 104 | } |
| 111 | 105 | |
| ... | ... | @@ -144,11 +138,7 @@ public class AlarmController { |
| 144 | 138 | if (StringUtils.isEmpty(time)) { |
| 145 | 139 | time = null; |
| 146 | 140 | } |
| 147 | - try { | |
| 148 | - if (time != null) { | |
| 149 | - DateUtil.format.parse(time); | |
| 150 | - } | |
| 151 | - } catch (ParseException e) { | |
| 141 | + if (!DateUtil.verification(time, DateUtil.formatter) ){ | |
| 152 | 142 | return new ResponseEntity<>(null, HttpStatus.BAD_REQUEST); |
| 153 | 143 | } |
| 154 | 144 | List<String> deviceIdList = null; |
| ... | ... | @@ -189,7 +179,7 @@ public class AlarmController { |
| 189 | 179 | deviceAlarm.setAlarmDescription("test"); |
| 190 | 180 | deviceAlarm.setAlarmMethod("1"); |
| 191 | 181 | deviceAlarm.setAlarmPriority("1"); |
| 192 | - deviceAlarm.setAlarmTime(DateUtil.formatISO8601.format(System.currentTimeMillis())); | |
| 182 | + deviceAlarm.setAlarmTime(DateUtil.formatterISO8601.format(LocalDateTime.now())); | |
| 193 | 183 | deviceAlarm.setAlarmType("1"); |
| 194 | 184 | deviceAlarm.setLongitude(115.33333); |
| 195 | 185 | deviceAlarm.setLatitude(39.33333); | ... | ... |
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/record/GBRecordController.java
| ... | ... | @@ -72,7 +72,7 @@ public class GBRecordController { |
| 72 | 72 | if (!DateUtil.verification(startTime, DateUtil.formatter)){ |
| 73 | 73 | WVPResult<RecordInfo> wvpResult = new WVPResult<>(); |
| 74 | 74 | wvpResult.setCode(-1); |
| 75 | - wvpResult.setMsg("startTime error, format is " + DateUtil.yyyy_MM_dd_HH_mm_ss); | |
| 75 | + wvpResult.setMsg("startTime error, format is " + DateUtil.PATTERN); | |
| 76 | 76 | |
| 77 | 77 | ResponseEntity<WVPResult<RecordInfo>> resultResponseEntity = new ResponseEntity<>(wvpResult, HttpStatus.OK); |
| 78 | 78 | result.setResult(resultResponseEntity); |
| ... | ... | @@ -81,7 +81,7 @@ public class GBRecordController { |
| 81 | 81 | if (!DateUtil.verification(endTime, DateUtil.formatter)){ |
| 82 | 82 | WVPResult<RecordInfo> wvpResult = new WVPResult<>(); |
| 83 | 83 | wvpResult.setCode(-1); |
| 84 | - wvpResult.setMsg("endTime error, format is " + DateUtil.yyyy_MM_dd_HH_mm_ss); | |
| 84 | + wvpResult.setMsg("endTime error, format is " + DateUtil.PATTERN); | |
| 85 | 85 | ResponseEntity<WVPResult<RecordInfo>> resultResponseEntity = new ResponseEntity<>(wvpResult, HttpStatus.OK); |
| 86 | 86 | result.setResult(resultResponseEntity); |
| 87 | 87 | return result; | ... | ... |
src/main/java/com/genersoft/iot/vmp/vmanager/log/LogController.java
| ... | ... | @@ -76,14 +76,7 @@ public class LogController { |
| 76 | 76 | logger.warn("自动记录日志功能已关闭,查询结果可能不完整。"); |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - try { | |
| 80 | - if (startTime != null) { | |
| 81 | - DateUtil.format.parse(startTime); | |
| 82 | - } | |
| 83 | - if (endTime != null) { | |
| 84 | - DateUtil.format.parse(endTime); | |
| 85 | - } | |
| 86 | - } catch (ParseException e) { | |
| 79 | + if (!DateUtil.verification(startTime, DateUtil.formatter) || !DateUtil.verification(endTime, DateUtil.formatter)){ | |
| 87 | 80 | return new ResponseEntity<>(null, HttpStatus.BAD_REQUEST); |
| 88 | 81 | } |
| 89 | 82 | ... | ... |
src/test/java/com/genersoft/iot/vmp/service/impl/DeviceAlarmServiceImplTest.java
| ... | ... | @@ -8,6 +8,10 @@ import org.springframework.boot.test.context.SpringBootTest; |
| 8 | 8 | import org.springframework.test.context.junit4.SpringRunner; |
| 9 | 9 | |
| 10 | 10 | import javax.annotation.Resource; |
| 11 | +import java.time.Instant; | |
| 12 | +import java.time.LocalDateTime; | |
| 13 | +import java.time.ZoneOffset; | |
| 14 | +import java.time.temporal.TemporalAccessor; | |
| 11 | 15 | import java.util.Date; |
| 12 | 16 | |
| 13 | 17 | |
| ... | ... | @@ -64,8 +68,8 @@ class DeviceAlarmServiceImplTest { |
| 64 | 68 | * * 7其他报警;可以为直接组合如12为电话报警或 设备报警- |
| 65 | 69 | */ |
| 66 | 70 | deviceAlarm.setAlarmMethod((int)(Math.random()*7 + 1) + ""); |
| 67 | - Date date = randomDate("2021-01-01 00:00:00", "2021-06-01 00:00:00"); | |
| 68 | - deviceAlarm.setAlarmTime(DateUtil.format.format(date)); | |
| 71 | + Instant date = randomDate("2021-01-01 00:00:00", "2021-06-01 00:00:00"); | |
| 72 | + deviceAlarm.setAlarmTime(DateUtil.formatter.format(date)); | |
| 69 | 73 | /** |
| 70 | 74 | * 报警级别, 1为一级警情, 2为二级警情, 3为三级警情, 4为四级 警情- |
| 71 | 75 | */ |
| ... | ... | @@ -85,17 +89,20 @@ class DeviceAlarmServiceImplTest { |
| 85 | 89 | |
| 86 | 90 | |
| 87 | 91 | |
| 88 | - private Date randomDate(String beginDate, String endDate) { | |
| 92 | + private Instant randomDate(String beginDate, String endDate) { | |
| 89 | 93 | try { |
| 90 | 94 | |
| 91 | - Date start = DateUtil.format.parse(beginDate);//构造开始日期 | |
| 92 | - Date end = DateUtil.format.parse(endDate);//构造结束日期 | |
| 95 | + //构造开始日期 | |
| 96 | + LocalDateTime start = LocalDateTime.parse(beginDate, DateUtil.formatter); | |
| 97 | + | |
| 98 | + //构造结束日期 | |
| 99 | + LocalDateTime end = LocalDateTime.parse(endDate, DateUtil.formatter); | |
| 93 | 100 | //getTime()表示返回自 1970 年 1 月 1 日 00:00:00 GMT 以来此 Date 对象表示的毫秒数。 |
| 94 | - if (start.getTime() >= end.getTime()) { | |
| 101 | + if (start.isAfter(end)) { | |
| 95 | 102 | return null; |
| 96 | 103 | } |
| 97 | - long date = random(start.getTime(), end.getTime()); | |
| 98 | - return new Date(date); | |
| 104 | + long date = random(start.toInstant(ZoneOffset.of("+8")).toEpochMilli(), end.toInstant(ZoneOffset.of("+8")).toEpochMilli()); | |
| 105 | + return Instant.ofEpochMilli(date); | |
| 99 | 106 | } catch (Exception e) { |
| 100 | 107 | e.printStackTrace(); |
| 101 | 108 | } | ... | ... |
web_src/src/components/service/DeviceService.js
| ... | ... | @@ -21,47 +21,47 @@ class DeviceService{ |
| 21 | 21 | if (typeof (errorCallback) == "function") errorCallback(error) |
| 22 | 22 | }); |
| 23 | 23 | } |
| 24 | - getAllDeviceList(callback, errorCallback) { | |
| 24 | + getAllDeviceList(callback,endCallback, errorCallback) { | |
| 25 | 25 | let currentPage = 1; |
| 26 | 26 | let count = 100; |
| 27 | 27 | let deviceList = [] |
| 28 | - this.getAllDeviceListIteration(deviceList, currentPage, count, (data) => { | |
| 29 | - if (typeof (callback) == "function") callback(data) | |
| 30 | - }, errorCallback) | |
| 28 | + this.getAllDeviceListIteration(deviceList, currentPage, count, callback, endCallback, errorCallback) | |
| 31 | 29 | } |
| 32 | 30 | |
| 33 | - getAllDeviceListIteration(deviceList, currentPage, count, callback, errorCallback) { | |
| 31 | + getAllDeviceListIteration(deviceList, currentPage, count, callback, endCallback, errorCallback) { | |
| 34 | 32 | this.getDeviceList(currentPage, count, (data) => { |
| 35 | 33 | if (data.list) { |
| 34 | + if (typeof (callback) == "function") callback(data.list) | |
| 36 | 35 | deviceList = deviceList.concat(data.list); |
| 37 | 36 | if (deviceList.length < data.total) { |
| 38 | 37 | currentPage ++ |
| 39 | - this.getAllDeviceListIteration(deviceList, currentPage, count, callback, errorCallback) | |
| 38 | + this.getAllDeviceListIteration(deviceList, currentPage, count, callback, endCallback, errorCallback) | |
| 40 | 39 | }else { |
| 41 | - if (typeof (callback) == "function") callback(deviceList) | |
| 40 | + if (typeof (endCallback) == "function") endCallback(deviceList) | |
| 42 | 41 | } |
| 43 | 42 | } |
| 44 | 43 | }, errorCallback) |
| 45 | 44 | } |
| 46 | 45 | |
| 47 | 46 | |
| 48 | - getAllChannel(isCatalog, catalogUnderDevice, deviceId, callback, errorCallback) { | |
| 47 | + getAllChannel(isCatalog, catalogUnderDevice, deviceId, callback, endCallback, errorCallback) { | |
| 49 | 48 | let currentPage = 1; |
| 50 | 49 | let count = 100; |
| 51 | 50 | let catalogList = [] |
| 52 | - this.getAllChannelIteration(isCatalog, catalogUnderDevice, deviceId, catalogList, currentPage, count, callback, errorCallback) | |
| 51 | + this.getAllChannelIteration(isCatalog, catalogUnderDevice, deviceId, catalogList, currentPage, count, callback, endCallback, errorCallback) | |
| 53 | 52 | } |
| 54 | 53 | |
| 55 | - getAllChannelIteration(isCatalog, catalogUnderDevice, deviceId, catalogList, currentPage, count, callback, errorCallback) { | |
| 54 | + getAllChannelIteration(isCatalog, catalogUnderDevice, deviceId, catalogList, currentPage, count, callback, endCallback, errorCallback) { | |
| 56 | 55 | this.getChanel(isCatalog, catalogUnderDevice, deviceId, currentPage, count, (data) => { |
| 57 | 56 | if (data.list) { |
| 57 | + if (typeof (callback) == "function") callback(data.list) | |
| 58 | 58 | catalogList = catalogList.concat(data.list); |
| 59 | 59 | if (catalogList.length < data.total) { |
| 60 | 60 | currentPage ++ |
| 61 | 61 | this.getAllChannelIteration(isCatalog,catalogUnderDevice, deviceId, catalogList, currentPage, count, callback, errorCallback) |
| 62 | 62 | }else { |
| 63 | 63 | console.log(1) |
| 64 | - if (typeof (callback) == "function") callback(catalogList) | |
| 64 | + if (typeof (endCallback) == "function") endCallback(catalogList) | |
| 65 | 65 | } |
| 66 | 66 | } |
| 67 | 67 | }, errorCallback) |
| ... | ... | @@ -84,22 +84,23 @@ class DeviceService{ |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | |
| 87 | - getAllSubChannel(isCatalog, deviceId, channelId, callback, errorCallback) { | |
| 87 | + getAllSubChannel(isCatalog, deviceId, channelId, callback, endCallback, errorCallback) { | |
| 88 | 88 | let currentPage = 1; |
| 89 | 89 | let count = 100; |
| 90 | 90 | let catalogList = [] |
| 91 | - this.getAllSubChannelIteration(isCatalog, deviceId, channelId, catalogList, currentPage, count, callback, errorCallback) | |
| 91 | + this.getAllSubChannelIteration(isCatalog, deviceId, channelId, catalogList, currentPage, count, callback, endCallback, errorCallback) | |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - getAllSubChannelIteration(isCatalog, deviceId,channelId, catalogList, currentPage, count, callback, errorCallback) { | |
| 94 | + getAllSubChannelIteration(isCatalog, deviceId,channelId, catalogList, currentPage, count, callback, endCallback, errorCallback) { | |
| 95 | 95 | this.getSubChannel(isCatalog, deviceId, channelId, currentPage, count, (data) => { |
| 96 | 96 | if (data.list) { |
| 97 | + if (typeof (callback) == "function") callback(data.list) | |
| 97 | 98 | catalogList = catalogList.concat(data.list); |
| 98 | 99 | if (catalogList.length < data.total) { |
| 99 | 100 | currentPage ++ |
| 100 | - this.getAllSubChannelIteration(isCatalog, deviceId, channelId, catalogList, currentPage, count, callback, errorCallback) | |
| 101 | + this.getAllSubChannelIteration(isCatalog, deviceId, channelId, catalogList, currentPage, count, callback, endCallback, errorCallback) | |
| 101 | 102 | }else { |
| 102 | - if (typeof (callback) == "function") callback(catalogList) | |
| 103 | + if (typeof (endCallback) == "function") endCallback(catalogList) | |
| 103 | 104 | } |
| 104 | 105 | } |
| 105 | 106 | }, errorCallback) | ... | ... |