|
@@ -2,10 +2,14 @@ package cn.com.taiji.algorithm.service.impl;
|
|
|
|
|
|
|
|
|
|
import cn.com.taiji.algorithm.model.VideoCatalog;
|
|
import cn.com.taiji.algorithm.model.VideoCatalog;
|
|
|
|
+import cn.com.taiji.algorithm.model.VideoInfo;
|
|
|
|
+import cn.com.taiji.algorithm.model.VideoInfoDTO;
|
|
import cn.com.taiji.algorithm.service.IVideoCatalogService;
|
|
import cn.com.taiji.algorithm.service.IVideoCatalogService;
|
|
|
|
+import cn.com.taiji.algorithm.service.IVideoInfoService;
|
|
import cn.com.taiji.algorithm.service.IVideoTreeService;
|
|
import cn.com.taiji.algorithm.service.IVideoTreeService;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
@@ -35,6 +39,9 @@ public class VideoTreeServiceImpl implements IVideoTreeService {
|
|
@Autowired
|
|
@Autowired
|
|
private IVideoCatalogService catalogService;
|
|
private IVideoCatalogService catalogService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private IVideoInfoService videoInfoService;
|
|
|
|
+
|
|
@Value("${taiji.clientId}")
|
|
@Value("${taiji.clientId}")
|
|
private String clientId;
|
|
private String clientId;
|
|
|
|
|
|
@@ -69,10 +76,10 @@ public class VideoTreeServiceImpl implements IVideoTreeService {
|
|
|
|
|
|
String parentCode = "0";
|
|
String parentCode = "0";
|
|
String platformid = "0";
|
|
String platformid = "0";
|
|
- String deviceUrl = url + "/api/CommonApi/GetOrganizationList?client_id="+clientId+"&parentCode="+parentCode+"&platformid="+platformid;
|
|
|
|
|
|
+ String catalogUrl = url + "/api/CommonApi/GetOrganizationList?client_id="+clientId+"&parentCode="+parentCode+"&platformid="+platformid;
|
|
|
|
|
|
// log.info(deviceUrl);
|
|
// log.info(deviceUrl);
|
|
- ResponseEntity<JSONObject> exchange = restTemplate.exchange(deviceUrl, HttpMethod.GET, reqEntity,JSONObject.class);
|
|
|
|
|
|
+ ResponseEntity<JSONObject> exchange = restTemplate.exchange(catalogUrl, HttpMethod.GET, reqEntity,JSONObject.class);
|
|
log.info(exchange.getBody().toString());
|
|
log.info(exchange.getBody().toString());
|
|
JSONObject resData = exchange.getBody();
|
|
JSONObject resData = exchange.getBody();
|
|
JSONArray jsonArray = resData.getJSONArray("List");
|
|
JSONArray jsonArray = resData.getJSONArray("List");
|
|
@@ -83,36 +90,85 @@ public class VideoTreeServiceImpl implements IVideoTreeService {
|
|
// // catalogService.saveOrUpdate(o,new LambdaQueryWrapper<VideoCatalog>()
|
|
// // catalogService.saveOrUpdate(o,new LambdaQueryWrapper<VideoCatalog>()
|
|
// // .eq(VideoCatalog::getPlatformId, o.getPlatformId()));
|
|
// // .eq(VideoCatalog::getPlatformId, o.getPlatformId()));
|
|
// });
|
|
// });
|
|
- getChildNodes(restTemplate,reqEntity,catalogs,url + "/api/CommonApi/GetOrganizationList?client_id="+clientId);
|
|
|
|
- catalogService.saveBatch(orgChildNodes);
|
|
|
|
|
|
+ catalogArrayList.clear();
|
|
|
|
+ getChildNodes(restTemplate, reqEntity, catalogs, url + "/api/CommonApi/GetOrganizationList?client_id=" + clientId);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ catalogArrayList.forEach(videoCatalog -> {
|
|
|
|
+ catalogService.saveOrUpdate(videoCatalog,new LambdaQueryWrapper<VideoCatalog>()
|
|
|
|
+ .eq(VideoCatalog::getAreaCode,videoCatalog.getAreaCode())
|
|
|
|
+ .eq(VideoCatalog::getPlatformId,videoCatalog.getPlatformId()));
|
|
|
|
+ });
|
|
|
|
+ log.info("长度:{}", catalogArrayList.size());
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
|
|
|
|
+ List<VideoCatalog> list = catalogService.list();
|
|
|
|
+ if (null != list && list.size() > 0) {
|
|
|
|
+ String deviceUrl = url + "/api/CommonApi/GetMonitorByOrganization?pageSize=100&client_id="+clientId;
|
|
|
|
+ list.forEach(videoCatalog -> {
|
|
|
|
+ int page = 1;
|
|
|
|
+ String videoInfoUrl = deviceUrl + "&organizationcode="+videoCatalog.getAreaCode()+"&platformid="+videoCatalog.getPlatformId()+"&page="+page;
|
|
|
|
+ ResponseEntity<JSONObject> devicList = restTemplate.exchange(videoInfoUrl, HttpMethod.GET, reqEntity,JSONObject.class);
|
|
|
|
+ int count = devicList.getBody().getIntValue("Count");
|
|
|
|
+ log.info("数量:{}", count);
|
|
|
|
+ if (count > 0) {
|
|
|
|
+
|
|
|
|
+ JSONArray videoInfoArray = devicList.getBody().getJSONArray("List");
|
|
|
|
+ List<VideoInfo> videoInfos = JSONArray.parseArray(videoInfoArray.toJSONString(), VideoInfo.class);
|
|
|
|
+ int i = (count - 1) / 100 + 1;
|
|
|
|
+ for (int j = 2 ; j <= i ; j++) {
|
|
|
|
+ getdevices(restTemplate, reqEntity, videoInfos, deviceUrl + "&organizationcode="+videoCatalog.getAreaCode()+"&platformid="+videoCatalog.getPlatformId()+"&page="+j);
|
|
|
|
+ }
|
|
|
|
+ if (null != videoInfos && videoInfos.size() > 0) {
|
|
|
|
+// videoInfoService.saveBatch(videoInfos);
|
|
|
|
+ videoInfos.forEach(videoInfo -> {
|
|
|
|
+ videoInfoService.saveOrUpdate(videoInfo,new LambdaQueryWrapper<VideoInfo>()
|
|
|
|
+ .eq(VideoInfo::getAreaCode,videoInfo.getAreaCode())
|
|
|
|
+ .eq(VideoInfo::getDeviceId,videoInfo.getDeviceId()));
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
- public static List<VideoCatalog> orgChildNodes = new ArrayList<VideoCatalog>();
|
|
|
|
|
|
+ public static List<VideoCatalog> catalogArrayList = new ArrayList<VideoCatalog>();
|
|
|
|
|
|
//根据父节点递归所有子节点
|
|
//根据父节点递归所有子节点
|
|
public void getChildNodes(RestTemplate restTemplate, HttpEntity reqEntity, List<VideoCatalog> list, String url) {
|
|
public void getChildNodes(RestTemplate restTemplate, HttpEntity reqEntity, List<VideoCatalog> list, String url) {
|
|
for (VideoCatalog catalog : list) {
|
|
for (VideoCatalog catalog : list) {
|
|
|
|
|
|
- orgChildNodes.add(catalog);
|
|
|
|
|
|
+ catalogArrayList.add(catalog);
|
|
String catalogUrl = url + "&parentCode="+catalog.getAreaCode()+"&platformid="+catalog.getPlatformId();
|
|
String catalogUrl = url + "&parentCode="+catalog.getAreaCode()+"&platformid="+catalog.getPlatformId();
|
|
ResponseEntity<JSONObject> exchange = restTemplate.exchange(catalogUrl, HttpMethod.GET, reqEntity,JSONObject.class);
|
|
ResponseEntity<JSONObject> exchange = restTemplate.exchange(catalogUrl, HttpMethod.GET, reqEntity,JSONObject.class);
|
|
log.info(exchange.getBody().toString());
|
|
log.info(exchange.getBody().toString());
|
|
JSONObject resData = exchange.getBody();
|
|
JSONObject resData = exchange.getBody();
|
|
JSONArray jsonArray = resData.getJSONArray("List");
|
|
JSONArray jsonArray = resData.getJSONArray("List");
|
|
List<VideoCatalog> catalogs = JSONArray.parseArray(jsonArray.toJSONString(), VideoCatalog.class);
|
|
List<VideoCatalog> catalogs = JSONArray.parseArray(jsonArray.toJSONString(), VideoCatalog.class);
|
|
- for (VideoCatalog log : catalogs) {
|
|
|
|
- //遍历出父id等于参数的id,add进子节点集合
|
|
|
|
- if (catalog.getParentCode().equals(log.getParentCode())) {
|
|
|
|
- //递归遍历下一级
|
|
|
|
- getChildNodes(restTemplate,reqEntity,list,url);
|
|
|
|
- // orgChildNodes.add(log);
|
|
|
|
- }
|
|
|
|
|
|
+ if (catalogs.size() > 0) {
|
|
|
|
+// for (VideoCatalog log : catalogs) {
|
|
|
|
+// //遍历出父id等于参数的id,add进子节点集合
|
|
|
|
+// if (catalog.getAreaCode().equals(log.getParentCode())) {
|
|
|
|
+// //递归遍历下一级
|
|
|
|
+// getChildNodes(restTemplate,reqEntity,catalogs,url);
|
|
|
|
+// // orgChildNodes.add(log);
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+ //递归遍历下一级
|
|
|
|
+ getChildNodes(restTemplate,reqEntity,catalogs,url);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- // return orgChildNodes;
|
|
|
|
|
|
+// return catalogArrayList;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void getdevices(RestTemplate restTemplate, HttpEntity reqEntity, List<VideoInfo> list, String url) {
|
|
|
|
+ ResponseEntity<JSONObject> devicList = restTemplate.exchange(url, HttpMethod.GET, reqEntity,JSONObject.class);
|
|
|
|
+ JSONArray videoInfoArray = devicList.getBody().getJSONArray("List");
|
|
|
|
+ List<VideoInfo> videoInfos = JSONArray.parseArray(videoInfoArray.toJSONString(), VideoInfo.class);
|
|
|
|
+ if (null != videoInfos && videoInfos.size() > 0) {
|
|
|
|
+ list.addAll(videoInfos);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|