Commit 6f300a23007aa419c41f600bf23a0ea5c71e5492

Authored by liujun001
1 parent 395d70a8

修改展示形式

src/main/java/com/bsth/controller/video/VideoController.java
@@ -17,11 +17,13 @@ import com.bsth.service.video.VideoService; @@ -17,11 +17,13 @@ import com.bsth.service.video.VideoService;
17 import lombok.extern.slf4j.Slf4j; 17 import lombok.extern.slf4j.Slf4j;
18 import org.apache.commons.collections.CollectionUtils; 18 import org.apache.commons.collections.CollectionUtils;
19 import org.apache.commons.collections.MapUtils; 19 import org.apache.commons.collections.MapUtils;
  20 +import org.apache.commons.lang3.StringUtils;
20 import org.springframework.beans.BeanUtils; 21 import org.springframework.beans.BeanUtils;
21 import org.springframework.beans.factory.annotation.Autowired; 22 import org.springframework.beans.factory.annotation.Autowired;
22 import org.springframework.data.domain.PageImpl; 23 import org.springframework.data.domain.PageImpl;
23 import org.springframework.web.bind.annotation.*; 24 import org.springframework.web.bind.annotation.*;
24 25
  26 +import javax.servlet.http.HttpServletRequest;
25 import java.util.*; 27 import java.util.*;
26 28
27 /** 29 /**
@@ -55,6 +57,27 @@ public class VideoController { @@ -55,6 +57,27 @@ public class VideoController {
55 return result; 57 return result;
56 } 58 }
57 59
  60 + @GetMapping("/tree/carNo/{parentId}")
  61 + public List<VideoTree> layTreeNodeCarNo(@PathVariable("parentId") String parentId) {
  62 + return videoService.combinationTreeOfCar(parentId);
  63 + }
  64 +
  65 + @GetMapping("/tree/search")
  66 + public Map<String, Object> searchLayTreeNode(HttpServletRequest request) {
  67 + String carNo = request.getParameter("insideCode_like");
  68 + if (StringUtils.isEmpty(carNo)) {
  69 + return combinationTree();
  70 + }
  71 + List<VideoTree> groups = videoService.searchTreeDataByCarNo(carNo);
  72 +
  73 + Map<String, Object> result = new HashMap<>();
  74 + result.put("status", ResponseCode.SUCCESS);
  75 + result.put("data", groups);
  76 +
  77 + return result;
  78 + }
  79 +
  80 +
58 @GetMapping("/tree/table") 81 @GetMapping("/tree/table")
59 public Map<String, Object> queryTreeTable(@RequestParam Map<String, Object> map, 82 public Map<String, Object> queryTreeTable(@RequestParam Map<String, Object> map,
60 @RequestParam(defaultValue = "0") int page, 83 @RequestParam(defaultValue = "0") int page,
@@ -117,16 +140,53 @@ public class VideoController { @@ -117,16 +140,53 @@ public class VideoController {
117 return result; 140 return result;
118 } 141 }
119 142
  143 + @GetMapping("/car/channel/tree/{carNo}")
  144 + public Map<String, Object> queryChannelsTree(@PathVariable String carNo) {
  145 + Map<String, Object> result = new HashMap<>();
  146 + try {
  147 +
  148 +
  149 + List<Map<String, Object>> videoChannels = videoService.getVideoChannel(carNo);
  150 + List<VideoTree> trees = new ArrayList<>();
  151 +
  152 + if (CollectionUtils.isNotEmpty(videoChannels)) {
  153 + for (Map<String, Object> map : videoChannels) {
  154 + VideoTree tree = new VideoTree();
  155 + tree.setId(map.get("channelId"));
  156 + tree.setCode(map.get("channelId"));
  157 + tree.setSourceId(map.get("deviceId"));
  158 + tree.setType(401);
  159 + tree.setIcon("layui-icon-video");
  160 + String name = Objects.isNull(map.get("name")) ? map.get("channelId") + "_" + map.get("deviceId") : map.get("name").toString();
  161 + tree.setText(name);
  162 + tree.setNodePValue(carNo);
  163 +
  164 + trees.add(tree);
  165 + }
  166 + }
  167 + result.put("status", ResponseCode.SUCCESS);
  168 + result.put("data", trees);
  169 + result.put("channelImageURL", wvpConfig.getChannelListOfImgURL());
  170 + result.put("wvpPlayURL", wvpConfig.getWvpPlayURL());
  171 + result.put("wvpLiveBroadcast", wvpConfig.getWvpLiveBroadcast());
  172 +
  173 + } catch (Exception e) {
  174 + log.error("查询车辆通道异常:[{}]", carNo, e);
  175 + result.put("status", ResponseCode.ERROR);
  176 + }
  177 + return result;
  178 + }
  179 +
120 @GetMapping("/car/channel/history/{device}/{channel}/{dateStr}") 180 @GetMapping("/car/channel/history/{device}/{channel}/{dateStr}")
121 public Map<String, Object> queryChannelHistoryList(@PathVariable("device") String device, @PathVariable("channel") String channel, @PathVariable("dateStr") String dateStr) { 181 public Map<String, Object> queryChannelHistoryList(@PathVariable("device") String device, @PathVariable("channel") String channel, @PathVariable("dateStr") String dateStr) {
122 Map<String, Object> result = new HashMap<>(); 182 Map<String, Object> result = new HashMap<>();
123 try { 183 try {
124 String token = videoService.getToken(); 184 String token = videoService.getToken();
125 185
126 - List<Map<String, Object>> videoChannels = videoService.getVideoChannelHistoryList(device, channel, dateStr,token); 186 + List<Map<String, Object>> videoChannels = videoService.getVideoChannelHistoryList(device, channel, dateStr, token);
127 result.put("status", ResponseCode.SUCCESS); 187 result.put("status", ResponseCode.SUCCESS);
128 result.put("data", videoChannels); 188 result.put("data", videoChannels);
129 - result.put("wvpPlayURL",wvpConfig.getWvpPlayURL()); 189 + result.put("wvpPlayURL", wvpConfig.getWvpPlayURL());
130 } catch (Exception e) { 190 } catch (Exception e) {
131 log.error("查询通道历史数据异常:[{}],[{}],[{}]", device, channel, dateStr, e); 191 log.error("查询通道历史数据异常:[{}],[{}],[{}]", device, channel, dateStr, e);
132 result.put("status", ResponseCode.ERROR); 192 result.put("status", ResponseCode.ERROR);
src/main/java/com/bsth/entity/video/VideoTree.java
1 package com.bsth.entity.video; 1 package com.bsth.entity.video;
2 2
3 import lombok.Data; 3 import lombok.Data;
  4 +import org.apache.commons.lang3.StringUtils;
4 5
5 6
6 import javax.persistence.Id; 7 import javax.persistence.Id;
@@ -54,11 +55,14 @@ public class VideoTree implements Serializable { @@ -54,11 +55,14 @@ public class VideoTree implements Serializable {
54 @Transient 55 @Transient
55 private Object code; 56 private Object code;
56 57
57 -// @Transient  
58 -// private String icon; 58 + @Transient
  59 + private String icon;
59 60
60 @Transient 61 @Transient
61 private List<VideoTree> children; 62 private List<VideoTree> children;
  63 + /**是否展开*/
  64 + @Transient
  65 + private String spread;
62 66
63 67
64 public String getTitle() { 68 public String getTitle() {
@@ -66,7 +70,7 @@ public class VideoTree implements Serializable { @@ -66,7 +70,7 @@ public class VideoTree implements Serializable {
66 } 70 }
67 71
68 public boolean getSpread() { 72 public boolean getSpread() {
69 - return getType() == 0 ? true : false; 73 + return StringUtils.isEmpty(spread)?getType() == 0 ? true : false:Boolean.parseBoolean(spread);
70 } 74 }
71 75
72 } 76 }
src/main/java/com/bsth/service/impl/videoimpl/VideoServiceImpl.java
@@ -2,6 +2,7 @@ package com.bsth.service.impl.videoimpl; @@ -2,6 +2,7 @@ package com.bsth.service.impl.videoimpl;
2 2
3 import com.alibaba.fastjson.JSON; 3 import com.alibaba.fastjson.JSON;
4 import com.alibaba.fastjson.JSONArray; 4 import com.alibaba.fastjson.JSONArray;
  5 +import com.bsth.data.BasicData;
5 import com.bsth.entity.Business; 6 import com.bsth.entity.Business;
6 import com.bsth.entity.Line; 7 import com.bsth.entity.Line;
7 import com.bsth.entity.video.VideoChannel; 8 import com.bsth.entity.video.VideoChannel;
@@ -46,6 +47,8 @@ public class VideoServiceImpl implements VideoService { @@ -46,6 +47,8 @@ public class VideoServiceImpl implements VideoService {
46 private LineService lineService; 47 private LineService lineService;
47 @Autowired 48 @Autowired
48 private WvpConfig wvpConfig; 49 private WvpConfig wvpConfig;
  50 + @Autowired
  51 + private BasicData basicData;
49 52
50 53
51 @Override 54 @Override
@@ -66,13 +69,119 @@ public class VideoServiceImpl implements VideoService { @@ -66,13 +69,119 @@ public class VideoServiceImpl implements VideoService {
66 } 69 }
67 70
68 @Override 71 @Override
  72 + public List<VideoTree> combinationTreeOfCar(String code) {
  73 + if (Objects.nonNull(code)) {
  74 + List<VideoTree> trees = new ArrayList<>();
  75 + Set<String> carNos = groupCarNosByComputeCode(code);
  76 +
  77 + Set<Line> lineSet = groupLingByCompany(code);
  78 + if (CollectionUtils.isNotEmpty(lineSet)) {
  79 + for (Line line : lineSet) {
  80 + VideoTree videoTree = combinationOfLine(code, line);
  81 + trees.add(videoTree);
  82 +
  83 + Set<String> carNoSets = groupCarNoByLine(line.getId());
  84 + if (CollectionUtils.isNotEmpty(carNoSets)) {
  85 + List<VideoTree> children = new ArrayList<>();
  86 + for (String carNo : carNoSets) {
  87 + VideoTree carTree = combnationOfCar(carNo, line.getId().toString());
  88 + children.add(carTree);
  89 +
  90 + if (CollectionUtils.isNotEmpty(carNos)) {
  91 + carNos.remove(carNo);
  92 + }
  93 + }
  94 + videoTree.setChildren(children);
  95 + }
  96 + }
  97 +
  98 + }
  99 +
  100 +
  101 + if (CollectionUtils.isNotEmpty(carNos)) {
  102 + for (String carNo : carNos) {
  103 + VideoTree carTree = combnationOfCar(carNo, code);
  104 + trees.add(carTree);
  105 + }
  106 + }
  107 + return trees;
  108 + }
  109 + return null;
  110 + }
  111 +
  112 + private VideoTree combnationOfCar(String carNo, String line) {
  113 + String name = Objects.isNull(basicData) || MapUtils.isEmpty(basicData.nbbmCompanyPlateMap) ? null : basicData.nbbmCompanyPlateMap.get(carNo);
  114 + return combinationVideoTree(carNo, carNo, line, carNo, 301, "layui-icon-transfer", carNo);
  115 + }
  116 +
  117 + private VideoTree combinationOfLine(String code, Line line) {
  118 + return combinationVideoTree(line.getId(), line.getName(), code, line.getId(), 201, "layui-icon-link", line.getLineCode());
  119 + }
  120 +
  121 + @Override
  122 + public List<VideoTree> searchTreeDataByCarNo(String carNo) {
  123 + Line line = findLineByCode(carNo);
  124 +
  125 + Iterable<Business> businessIterable = businessService.list(new HashMap<>());
  126 + if (Objects.isNull(businessIterable)) {
  127 + return Collections.emptyList();
  128 + }
  129 +
  130 + if (Objects.nonNull(line)) {
  131 + Set<Business> businesses = new LinkedHashSet<>();
  132 + findBussinessByUpCode(line.getCompany(), businessIterable, businesses);
  133 + if (CollectionUtils.isNotEmpty(businesses)) {
  134 + List<VideoTree> group = combitionBussiness(businesses);
  135 +
  136 + VideoTree sourceTree = findVideoTreeByBusinessCode(line.getCompany(), group);
  137 + if (Objects.isNull(sourceTree.getChildren())) {
  138 + sourceTree.setChildren(new ArrayList<>());
  139 + }
  140 + VideoTree lineOfTreeNode = combinationOfLine(sourceTree.getId().toString(), line);
  141 + lineOfTreeNode.setSpread(Boolean.TRUE.toString());
  142 + lineOfTreeNode.setChildren(new ArrayList<>());
  143 + sourceTree.getChildren().add(lineOfTreeNode);
  144 +
  145 + VideoTree carOfTreeNode = combnationOfCar(carNo, line.getLineCode());
  146 + lineOfTreeNode.getChildren().add(carOfTreeNode);
  147 + carOfTreeNode.setSpread(Boolean.TRUE.toString());
  148 +
  149 + return group;
  150 + }
  151 + } else {
  152 + Set<Business> businesses = new LinkedHashSet<>();
  153 + String company = basicData.nbbm2CompanyCodeMap.get(carNo);
  154 + if (StringUtils.isNotEmpty(company)) {
  155 + findBussinessByUpCode(company, businessIterable, businesses);
  156 + if (CollectionUtils.isNotEmpty(businesses)) {
  157 + List<VideoTree> group = combitionBussiness(businesses);
  158 + VideoTree sourceTree = findVideoTreeByBusinessCode(company, group);
  159 + if (Objects.nonNull(sourceTree) && Objects.isNull(sourceTree.getChildren())) {
  160 + sourceTree.setChildren(new ArrayList<>());
  161 + }
  162 + VideoTree carOfTreeNode = combnationOfCar(carNo, company);
  163 + carOfTreeNode.setSpread(Boolean.TRUE.toString());
  164 + sourceTree.getChildren().add(carOfTreeNode);
  165 +
  166 + sourceTree.setSpread("true");
  167 +
  168 + return group;
  169 + }
  170 + }
  171 + }
  172 +
  173 +
  174 + return Collections.emptyList();
  175 + }
  176 +
  177 + @Override
69 public List<Map<String, Object>> getVideoChannel(String carNo) throws Exception { 178 public List<Map<String, Object>> getVideoChannel(String carNo) throws Exception {
70 return getWvpVideoChannelByCarNo(carNo); 179 return getWvpVideoChannelByCarNo(carNo);
71 } 180 }
72 181
73 @Override 182 @Override
74 - public List<Map<String, Object>> getVideoChannelHistoryList(String device, String channel, String dateStr,String token) throws Exception {  
75 - return getVideoChannelHistoryListReq(device, channel, dateStr,token); 183 + public List<Map<String, Object>> getVideoChannelHistoryList(String device, String channel, String dateStr, String token) throws Exception {
  184 + return getVideoChannelHistoryListReq(device, channel, dateStr, token);
76 } 185 }
77 186
78 @Override 187 @Override
@@ -93,11 +202,16 @@ public class VideoServiceImpl implements VideoService { @@ -93,11 +202,16 @@ public class VideoServiceImpl implements VideoService {
93 return Collections.emptyList(); 202 return Collections.emptyList();
94 } 203 }
95 204
  205 + return combitionBussiness(businessIterable);
  206 +
  207 + }
  208 +
  209 + private List<VideoTree> combitionBussiness(Iterable<Business> businessIterable) {
96 List<VideoTree> trees = new ArrayList<>(); 210 List<VideoTree> trees = new ArrayList<>();
97 Iterator<Business> iterator = businessIterable.iterator(); 211 Iterator<Business> iterator = businessIterable.iterator();
98 while (iterator.hasNext()) { 212 while (iterator.hasNext()) {
99 Business business = iterator.next(); 213 Business business = iterator.next();
100 - VideoTree videoTree = combinationVideoTree(business.getBusinessCode(), business.getBusinessName(), business.getUpCode(), business.getId(), null, null, business.getBusinessCode()); 214 + VideoTree videoTree = combinationVideoTree(business.getBusinessCode(), business.getBusinessName(), business.getUpCode(), business.getId(), null, "layui-icon-component", business.getBusinessCode());
101 trees.add(videoTree); 215 trees.add(videoTree);
102 } 216 }
103 List<VideoTree> groupTree = new ArrayList<>(); 217 List<VideoTree> groupTree = new ArrayList<>();
@@ -116,32 +230,9 @@ public class VideoServiceImpl implements VideoService { @@ -116,32 +230,9 @@ public class VideoServiceImpl implements VideoService {
116 groupTree(trees, tree); 230 groupTree(trees, tree);
117 } 231 }
118 } 232 }
119 -  
120 return groupTree; 233 return groupTree;
121 } 234 }
122 235
123 - private List<VideoTree> queryLine() {  
124 - Iterable<Line> lines = lineService.list(new HashMap<>());  
125 - if (Objects.isNull(lines)) {  
126 - return Collections.emptyList();  
127 - }  
128 -  
129 - List<VideoTree> trees = new ArrayList<>();  
130 - Iterator<Line> iterator = lines.iterator();  
131 - while (iterator.hasNext()) {  
132 - Line line = iterator.next();  
133 - VideoTree videoTree = combinationVideoTree(line.getId(), line.getName(), line.getCompany(), line.getId(), 2, null, null);  
134 - trees.add(videoTree);  
135 - }  
136 -  
137 -  
138 - return trees;  
139 - }  
140 -  
141 - private List<VideoTree> queryCars() {  
142 - return null;  
143 - }  
144 -  
145 /*** 236 /***
146 * 组合树 237 * 组合树
147 * @author liujun 238 * @author liujun
@@ -154,14 +245,14 @@ public class VideoServiceImpl implements VideoService { @@ -154,14 +245,14 @@ public class VideoServiceImpl implements VideoService {
154 * @param icon 图标 245 * @param icon 图标
155 * @return com.bsth.entity.video.VideoTree 246 * @return com.bsth.entity.video.VideoTree
156 */ 247 */
157 - private VideoTree combinationVideoTree(Object id, String text, String parent, Integer sourceId, Integer type, String icon, Object code) { 248 + private VideoTree combinationVideoTree(Object id, String text, String parent, Object sourceId, Integer type, String icon, Object code) {
158 VideoTree videoTree = new VideoTree(); 249 VideoTree videoTree = new VideoTree();
159 videoTree.setId(id); 250 videoTree.setId(id);
160 videoTree.setText(text); 251 videoTree.setText(text);
161 videoTree.setSourceId(sourceId); 252 videoTree.setSourceId(sourceId);
162 videoTree.setNodePValue(parent); 253 videoTree.setNodePValue(parent);
163 videoTree.setType(type); 254 videoTree.setType(type);
164 -// videoTree.setIcon(icon); 255 + videoTree.setIcon(icon);
165 videoTree.setCode(code); 256 videoTree.setCode(code);
166 return videoTree; 257 return videoTree;
167 } 258 }
@@ -235,7 +326,7 @@ public class VideoServiceImpl implements VideoService { @@ -235,7 +326,7 @@ public class VideoServiceImpl implements VideoService {
235 } 326 }
236 } 327 }
237 328
238 - private List<Map<String, Object>> getVideoChannelHistoryListReq(String device, String channel, String dateStr,String token) throws Exception { 329 + private List<Map<String, Object>> getVideoChannelHistoryListReq(String device, String channel, String dateStr, String token) throws Exception {
239 if (StringUtils.isEmpty(token)) { 330 if (StringUtils.isEmpty(token)) {
240 log.error("wvp login token is null"); 331 log.error("wvp login token is null");
241 return Collections.emptyList(); 332 return Collections.emptyList();
@@ -334,4 +425,137 @@ public class VideoServiceImpl implements VideoService { @@ -334,4 +425,137 @@ public class VideoServiceImpl implements VideoService {
334 return null; 425 return null;
335 } 426 }
336 427
  428 +
  429 + private Set<String> groupCarNosByComputeCode(String code) {
  430 + if (Objects.isNull(basicData) || MapUtils.isEmpty(basicData.nbbm2CompanyCodeMap)) {
  431 + return Collections.emptySet();
  432 + }
  433 + Set<String> carNos = new LinkedHashSet<>();
  434 + for (Map.Entry<String, String> entry : basicData.nbbm2CompanyCodeMap.entrySet()) {
  435 + if (Objects.equals(code, entry.getValue())) {
  436 + carNos.add(entry.getKey());
  437 + }
  438 + }
  439 +
  440 + return carNos;
  441 + }
  442 +
  443 + private Set<String> groupCarNoByLine(Integer id) {
  444 + if (Objects.isNull(basicData) || MapUtils.isEmpty(basicData.nbbm2LineMap)) {
  445 + return Collections.emptySet();
  446 + }
  447 +
  448 + Set<String> carNos = new LinkedHashSet<>();
  449 + for (Map.Entry<String, Line> entry : basicData.nbbm2LineMap.entrySet()) {
  450 + if (Objects.nonNull(entry.getValue()) && Objects.equals(entry.getValue().getId(), id)) {
  451 + carNos.add(entry.getKey());
  452 + }
  453 +
  454 + }
  455 +
  456 + return carNos;
  457 +
  458 + }
  459 +
  460 +
  461 + private Set<Line> groupLine(Collection<String> carNos) {
  462 + if (Objects.isNull(basicData) || MapUtils.isEmpty(basicData.nbbm2LineMap)) {
  463 + return Collections.emptySet();
  464 + }
  465 +
  466 + Set<Line> lineSet = new LinkedHashSet<>();
  467 + for (String carNo : carNos) {
  468 + Line line = basicData.nbbm2LineMap.get(carNo);
  469 + if (Objects.nonNull(line)) {
  470 + lineSet.add(line);
  471 + }
  472 + }
  473 +
  474 + return lineSet;
  475 + }
  476 +
  477 + private Set<Line> groupLingByCompany(String companyCode) {
  478 + if (Objects.isNull(basicData) || MapUtils.isEmpty(basicData.nbbm2LineMap)) {
  479 + return Collections.emptySet();
  480 + }
  481 +
  482 + Set<Line> lineSet = new LinkedHashSet<>();
  483 + for (Map.Entry<String, Line> entry : basicData.nbbm2LineMap.entrySet()) {
  484 + if (Objects.nonNull(entry.getValue()) && Objects.equals(entry.getValue().getCompany(), companyCode)) {
  485 + lineSet.add(entry.getValue());
  486 + }
  487 +
  488 + }
  489 + return lineSet;
  490 + }
  491 +
  492 + private void findBussinessByUpCode(String upCode, Iterable<Business> businessIterable, Collection<Business> results) {
  493 + for (Business business : businessIterable) {
  494 + if (Objects.equals(business.getBusinessCode(), upCode)) {
  495 + results.add(business);
  496 + findBussinessByUpCode(business.getUpCode(), businessIterable, results);
  497 + }
  498 + }
  499 + }
  500 +
  501 + private VideoTree findVideoTreeByBusinessCode(String bussinessCode, List<VideoTree> videoTrees) {
  502 + if (CollectionUtils.isEmpty(videoTrees)) {
  503 + return null;
  504 + }
  505 +
  506 + for (VideoTree videoTree : videoTrees) {
  507 + if (Objects.nonNull(videoTree.getId()) && Objects.equals(videoTree.getId().toString(), bussinessCode)) {
  508 + return videoTree;
  509 + } else if (CollectionUtils.isNotEmpty(videoTree.getChildren())) {
  510 + VideoTree source = findVideoTreeByBusinessCode(bussinessCode, videoTree.getChildren());
  511 + if (Objects.nonNull(source)) {
  512 + return source;
  513 + }
  514 + }
  515 + }
  516 +
  517 + return null;
  518 + }
  519 +
  520 + private Line findLineByCode(String carNo) {
  521 + Line line = basicData.nbbm2LineMap.get(carNo);
  522 + if (Objects.nonNull(line)) {
  523 + return line;
  524 + }
  525 + for (Map.Entry<String, Line> entry : basicData.nbbm2LineMap.entrySet()) {
  526 + if (StringUtils.equalsIgnoreCase(carNo, entry.getKey())) {
  527 + return entry.getValue();
  528 + }
  529 + }
  530 + String lineId = null;
  531 + for (Map.Entry<String, List<String>> entry : basicData.lineCodeHistoryNbbmMap.entrySet()) {
  532 + if (CollectionUtils.isNotEmpty(entry.getValue())) {
  533 + for (String sourceCarNo : entry.getValue()) {
  534 + if (StringUtils.equalsIgnoreCase(carNo, sourceCarNo)) {
  535 + lineId = entry.getKey();
  536 + break;
  537 + }
  538 + }
  539 + }
  540 +
  541 + if (StringUtils.isNotEmpty(lineId)) {
  542 + break;
  543 + }
  544 + }
  545 +
  546 + if (StringUtils.isEmpty(lineId)) {
  547 + return null;
  548 + }
  549 +
  550 + for (Map.Entry<String, Line> entry : basicData.nbbm2LineMap.entrySet()) {
  551 + if (StringUtils.equalsIgnoreCase(lineId, String.valueOf(entry.getValue().getId()))) {
  552 + return entry.getValue();
  553 + }
  554 + }
  555 +
  556 + return null;
  557 +
  558 + }
  559 +
  560 +
337 } 561 }
src/main/java/com/bsth/service/video/VideoService.java
@@ -18,6 +18,10 @@ public interface VideoService { @@ -18,6 +18,10 @@ public interface VideoService {
18 18
19 List<VideoTree> combinationTree(); 19 List<VideoTree> combinationTree();
20 20
  21 + List<VideoTree> combinationTreeOfCar(String code);
  22 +
  23 + List<VideoTree> searchTreeDataByCarNo(String carNo);
  24 +
21 List<Map<String, Object>> getVideoChannel(String carNo)throws Exception; 25 List<Map<String, Object>> getVideoChannel(String carNo)throws Exception;
22 26
23 List<Map<String,Object>> getVideoChannelHistoryList(String device,String channel,String dateStr,String token) throws Exception; 27 List<Map<String,Object>> getVideoChannelHistoryList(String device,String channel,String dateStr,String token) throws Exception;
src/main/resources/static/pages/video/video.html
@@ -16,7 +16,7 @@ @@ -16,7 +16,7 @@
16 16
17 <div class="row"> 17 <div class="row">
18 <div class="col-md-4" style="padding-right: 0px;width: 20%"> 18 <div class="col-md-4" style="padding-right: 0px;width: 20%">
19 - <div class="portlet light bordered" style="min-height: 715px;"> 19 + <div class="portlet light bordered" style="height: 715px;overflow:scroll">
20 <div class="portlet-body"> 20 <div class="portlet-body">
21 <div id="video_tree"></div> 21 <div id="video_tree"></div>
22 22
@@ -25,8 +25,8 @@ @@ -25,8 +25,8 @@
25 </div> 25 </div>
26 26
27 <div class="col-md-6" style="padding-left: 0px;width: 76%"> 27 <div class="col-md-6" style="padding-left: 0px;width: 76%">
28 - <div class="portlet light bordered" style="height: 715px;">  
29 - <div class="portlet-body" style="min-height: 701px;"> 28 + <div class="portlet light bordered" >
  29 + <div class="portlet-body">
30 <div class="layui-inline"> 30 <div class="layui-inline">
31 <input type="text" placeholder="请输入车辆编号" autocomplete="off" class="layui-input" id="carCode_like" style="display:inline-block;width: 200px"/> 31 <input type="text" placeholder="请输入车辆编号" autocomplete="off" class="layui-input" id="carCode_like" style="display:inline-block;width: 200px"/>
32 <input type="text" placeholder="请输入内部编号" autocomplete="off" class="layui-input" id="insideCode_like" style="display:inline-block;width: 200px"/> 32 <input type="text" placeholder="请输入内部编号" autocomplete="off" class="layui-input" id="insideCode_like" style="display:inline-block;width: 200px"/>
@@ -35,7 +35,25 @@ @@ -35,7 +35,25 @@
35 <button type="button" class="layui-btn layui-btn-primary" lay-on="get-vercode" onclick="queryTreeTable()">查询</button> 35 <button type="button" class="layui-btn layui-btn-primary" lay-on="get-vercode" onclick="queryTreeTable()">查询</button>
36 </div> 36 </div>
37 37
38 - <table class="layui-hide" id="treeTable"></table> 38 + <div class="layui-tab layui-tab-card">
  39 + <ul class="layui-tab-title">
  40 + <li class="layui-this">直播</li>
  41 + <li>历史数据</li>
  42 + </ul>
  43 + <div class="layui-tab-content">
  44 + <div class="layui-tab-item layui-show" id="live_broadcastDiv" style="height: 572px;100%">
  45 + <div>分屏:
  46 + <a href="#" class="layui-btn layui-btn-primary layui-btn-xs" onclick="skeyewebplayerOne()">□</a>
  47 + <a href="#" class="layui-btn layui-btn-primary layui-btn-xs" onclick="skeyewebplayerFour()">▤</a>
  48 + <a href="#" class="layui-btn layui-btn-primary layui-btn-xs" onclick="skeyewebplayerNine()">▦</a>
  49 + </div>
  50 + <div id="skeyewebplayerDivContent" >
  51 +
  52 + </div>
  53 + </div>
  54 + <div class="layui-tab-item" style="height: 572px;width: 100%"></div>
  55 + </div>
  56 + </div>
39 </div> 57 </div>
40 </div> 58 </div>
41 </div> 59 </div>
src/main/resources/static/pages/video/video.js
@@ -16,20 +16,100 @@ $(document).ready(function () { @@ -16,20 +16,100 @@ $(document).ready(function () {
16 function initTree(data) { 16 function initTree(data) {
17 layui.use(function () { 17 layui.use(function () {
18 var tree = layui.tree; 18 var tree = layui.tree;
  19 + var opt = initTreeOpt(data, tree);
19 // 渲染 20 // 渲染
20 - tree.render({  
21 - elem: '#video_tree',  
22 - data: data,  
23 - onlyIconControl: true, // 是否仅允许节点左侧图标控制展开收缩  
24 - showLine: true, // 是否开启连接线  
25 - click: function (node) {  
26 - initTable(node);  
27 - }  
28 - }); 21 + var treeObj = tree.render(opt);
29 closeLoading(); 22 closeLoading();
30 }); 23 });
31 } 24 }
32 25
  26 +function initTreeOpt(data, tree) {
  27 +
  28 + var opt = {
  29 + elem: '#video_tree',
  30 + id: "video_tree",
  31 + data: data,
  32 + onlyIconControl: true, // 是否仅允许节点左侧图标控制展开收缩
  33 + showLine: true, // 是否开启连接线
  34 + click: function (node) {
  35 + loading = loadingFunction();
  36 + if (node.data.type < 400) {
  37 + lasyCarNo(node, tree, data);
  38 + node.initChild = true;
  39 + } else {
  40 + playWvpVideo1(node);
  41 + closeLoading();
  42 + }
  43 +
  44 + }, dblClick: function (node) {
  45 + // lasyCarNo(node,tree,data);
  46 + }
  47 + };
  48 + return opt;
  49 +}
  50 +
  51 +function lasyCarNo(node, tree, oldData) {
  52 + if (isEmpty(node.initChild) || false === node.initChild) {
  53 + if (node.data.type < 200) {
  54 + $.getJSON("/video/tree/carNo/" + node.data.code, function (data) {
  55 + if (oldData) {
  56 + $.each(oldData, function (index, d) {
  57 + layCarNoConcatArr(d, node, data);
  58 + initTable(node);
  59 + });
  60 + closeLoading();
  61 + tree.reload('video_tree', {data: oldData});
  62 +
  63 + }
  64 + });
  65 + } else if (node.data.type > 300) {
  66 + $.getJSON("/video/car/channel/tree/" + node.data.sourceId, function (data) {
  67 + $.each(oldData, function (index, d) {
  68 + layCarNoConcatArr(d, node, data.data, data);
  69 + initTable(node);
  70 +
  71 + });
  72 +
  73 + tree.reload('video_tree', {data: oldData});
  74 + closeLoading();
  75 + });
  76 + } else {
  77 + closeLoading();
  78 + }
  79 +
  80 + }
  81 +
  82 +}
  83 +
  84 +function layCarNoChildren(oldData, node, data, result) {
  85 + if (oldData) {
  86 + $.each(oldData, function (index, d) {
  87 + layCarNoConcatArr(d, node, data, result);
  88 + });
  89 + }
  90 +}
  91 +
  92 +function layCarNoConcatArr(d, node, data, result) {
  93 + if (d.id === node.data.id && d.type === node.data.type) {
  94 + if (isEmpty(d.children)) {
  95 + d.children = [];
  96 + }
  97 + d.spread = true;
  98 + if (result) {
  99 + $.each(data, function (index, d1) {
  100 + d1.wvpLiveBroadcast = result.wvpLiveBroadcast;
  101 + })
  102 + }
  103 +
  104 + d.children = d.children.concat(data);
  105 + if (result) {
  106 + d.wvpLiveBroadcast = result.wvpLiveBroadcast;
  107 + }
  108 + } else {
  109 + layCarNoChildren(d.children, node, data, result);
  110 + }
  111 +}
  112 +
33 113
34 function initTable(treeNode) { 114 function initTable(treeNode) {
35 var queryURL = "/video/tree/table?1=1"; 115 var queryURL = "/video/tree/table?1=1";
@@ -70,29 +150,29 @@ function initTable(treeNode) { @@ -70,29 +150,29 @@ function initTable(treeNode) {
70 }); 150 });
71 } 151 }
72 152
73 -function queryTreeTable(){  
74 - let url = treeURL;  
75 - if(!isEmpty($("#carCode_like").val())){  
76 - url += "&carCode_like="+$("#carCode_like").val(); 153 +function queryTreeTable() {
  154 + let url = treeURL;
  155 + if (!isEmpty($("#carCode_like").val())) {
  156 + url += "&carCode_like=" + $("#carCode_like").val();
77 } 157 }
78 158
79 - if(!isEmpty($("#insideCode_like").val())){  
80 - url += "&insideCode_like="+$("#insideCode_like").val(); 159 + if (!isEmpty($("#insideCode_like").val())) {
  160 + url += "&insideCode_like=" + $("#insideCode_like").val();
81 } 161 }
82 162
83 - if(!isEmpty($("#equipmentCode_like").val())){  
84 - url += "&equipmentCode_like="+$("#equipmentCode_like").val(); 163 + if (!isEmpty($("#equipmentCode_like").val())) {
  164 + url += "&equipmentCode_like=" + $("#equipmentCode_like").val();
85 } 165 }
86 166
87 - if(!isEmpty($("#carPlate_like").val())){  
88 - url += "&carPlate_like="+$("#carPlate_like").val(); 167 + if (!isEmpty($("#carPlate_like").val())) {
  168 + url += "&carPlate_like=" + $("#carPlate_like").val();
89 } 169 }
90 option.url = url; 170 option.url = url;
91 var treeTable = layui.treeTable; 171 var treeTable = layui.treeTable;
92 treeTable.render(option); 172 treeTable.render(option);
93 } 173 }
94 174
95 -function isEmpty(val){ 175 +function isEmpty(val) {
96 return null == val || undefined == val || "" == val; 176 return null == val || undefined == val || "" == val;
97 } 177 }
98 178
@@ -102,10 +182,10 @@ function initTreeTableOption(queryURL) { @@ -102,10 +182,10 @@ function initTreeTableOption(queryURL) {
102 url: queryURL, 182 url: queryURL,
103 loading: true, 183 loading: true,
104 treeColIndex: 1, 184 treeColIndex: 1,
105 - even:true, 185 + even: true,
106 treeSpid: 0, 186 treeSpid: 0,
107 - limit:5,  
108 - limits :[5,10,20,50], 187 + limit: 5,
  188 + limits: [5, 10, 20, 50],
109 maxHeight: '701px', 189 maxHeight: '701px',
110 cols: [[ 190 cols: [[
111 {field: 'name', title: '车辆编号', width: 140}, 191 {field: 'name', title: '车辆编号', width: 140},
@@ -189,7 +269,7 @@ function getBigSnap(imageURL, deviceId, channelId) { @@ -189,7 +269,7 @@ function getBigSnap(imageURL, deviceId, channelId) {
189 function playWvpVideo(playURL, deviceId, channelId) { 269 function playWvpVideo(playURL, deviceId, channelId) {
190 var idDiv = "video_" + (Date.now()); 270 var idDiv = "video_" + (Date.now());
191 var html = "'<div id='" + idDiv + "' style='padding-top: 0;'></div>'"; 271 var html = "'<div id='" + idDiv + "' style='padding-top: 0;'></div>'";
192 - playURL = playURL.replace("{device}",deviceId).replace("{channel}",channelId); 272 + playURL = playURL.replace("{device}", deviceId).replace("{channel}", channelId);
193 273
194 274
195 var index = layer.open({ 275 var index = layer.open({
@@ -204,11 +284,16 @@ function playWvpVideo(playURL, deviceId, channelId) { @@ -204,11 +284,16 @@ function playWvpVideo(playURL, deviceId, channelId) {
204 284
205 } 285 }
206 286
207 -function playVideo(url, ID,time) { 287 +function playWvpVideo1(node) {
  288 + let url = node.data.wvpLiveBroadcast.replace("{device}", node.data.sourceId).replace("{channel}", node.data.id);
  289 + $("#live_broadcastDiv").html("<iframe src='"+url+"' style='width: 100%;height: 100%' frameborder='0' boder='0'/>");
  290 +}
  291 +
  292 +function playVideo(url, ID, time) {
208 return new WebMediaPlayer(url, ID, function () { 293 return new WebMediaPlayer(url, ID, function () {
209 }, { 294 }, {
210 autoplay: 1, 295 autoplay: 1,
211 - currentTime:time 296 + currentTime: time
212 }).play(); 297 }).play();
213 } 298 }
214 299
@@ -220,7 +305,7 @@ function playVideo1(url, ID) { @@ -220,7 +305,7 @@ function playVideo1(url, ID) {
220 } 305 }
221 306
222 function playVideo2(url, jqeruyObj, style) { 307 function playVideo2(url, jqeruyObj, style) {
223 - console.log(url); 308 +
224 let html = " <video id=\"video\" controls=\"\" src=\"" + url + "\" style=\"width:100%; height:100%; object-fit: fill\" autoplay></video>"; 309 let html = " <video id=\"video\" controls=\"\" src=\"" + url + "\" style=\"width:100%; height:100%; object-fit: fill\" autoplay></video>";
225 jqeruyObj.html(html); 310 jqeruyObj.html(html);
226 } 311 }
@@ -282,10 +367,10 @@ function deviceVidemoQueryHistory(device, channel, $deviceVideoDiv, idDiv) { @@ -282,10 +367,10 @@ function deviceVidemoQueryHistory(device, channel, $deviceVideoDiv, idDiv) {
282 if (resp.status === "SUCCESS") { 367 if (resp.status === "SUCCESS") {
283 var html = "<tr>"; 368 var html = "<tr>";
284 $.each(resp.data, function (index, node) { 369 $.each(resp.data, function (index, node) {
285 - if(isEmpty(node.filePath)){  
286 - node.filePath=node.startTime+"_"+index; 370 + if (isEmpty(node.filePath)) {
  371 + node.filePath = node.startTime + "_" + index;
287 } 372 }
288 - html += "<td><button class=\"layui-btn layui-btn-primary layui-border\" onclick=\"playDeviceVidemoQueryHistory('" + idDiv + "','" + resp.wvpPlayURL + "','" + device + "','" + channel + "','" + node.startTime + "','" + node.endTime + "','" + resp.token + "')\" title='"+ node.filePath+"'>" + node.filePath + "</button></td>"; 373 + html += "<td><button class=\"layui-btn layui-btn-primary layui-border\" onclick=\"playDeviceVidemoQueryHistory('" + idDiv + "','" + resp.wvpPlayURL + "','" + device + "','" + channel + "','" + node.startTime + "','" + node.endTime + "','" + resp.token + "')\" title='" + node.filePath + "'>" + node.filePath + "</button></td>";
289 if (index % 2 === 1) { 374 if (index % 2 === 1) {
290 html += "</tr><tr>"; 375 html += "</tr><tr>";
291 } 376 }
@@ -293,7 +378,7 @@ function deviceVidemoQueryHistory(device, channel, $deviceVideoDiv, idDiv) { @@ -293,7 +378,7 @@ function deviceVidemoQueryHistory(device, channel, $deviceVideoDiv, idDiv) {
293 378
294 $("#deviceVideoTbody", $deviceVideoDiv).html(html); 379 $("#deviceVideoTbody", $deviceVideoDiv).html(html);
295 closeLoading(); 380 closeLoading();
296 - }else{ 381 + } else {
297 closeLoading(); 382 closeLoading();
298 } 383 }
299 }); 384 });
@@ -305,12 +390,12 @@ function playDeviceVidemoQueryHistory(idDiv, url, device, channel, startTime, en @@ -305,12 +390,12 @@ function playDeviceVidemoQueryHistory(idDiv, url, device, channel, startTime, en
305 } 390 }
306 startTime = startTime.replace("-", "").replace("-", "").replace(":", "").replace(":", "").replace(" ", ""); 391 startTime = startTime.replace("-", "").replace("-", "").replace(":", "").replace(":", "").replace(" ", "");
307 endTime = endTime.replace("-", "").replace("-", "").replace(":", "").replace(":", "").replace(" ", ""); 392 endTime = endTime.replace("-", "").replace("-", "").replace(":", "").replace(":", "").replace(" ", "");
308 - console.log(startTime); 393 +
309 url = url + device + "_" + channel + "_" + startTime + "_" + endTime + ".live.mp4"; 394 url = url + device + "_" + channel + "_" + startTime + "_" + endTime + ".live.mp4";
310 - console.log(url); 395 +
311 var idDiv1 = "device_video_play_" + (Date.now()); 396 var idDiv1 = "device_video_play_" + (Date.now());
312 $("#videoPlay", $("#" + idDiv)).html("<div id='" + idDiv1 + "' style='height:550px;width:99%'></div>") 397 $("#videoPlay", $("#" + idDiv)).html("<div id='" + idDiv1 + "' style='height:550px;width:99%'></div>")
313 - player = playVideo(url, idDiv1,0); 398 + player = playVideo(url, idDiv1, 0);
314 399
315 } 400 }
316 401
@@ -361,16 +446,16 @@ function skeywebPlayerChannel($skeyewebplayer, carNo) { @@ -361,16 +446,16 @@ function skeywebPlayerChannel($skeyewebplayer, carNo) {
361 }); 446 });
362 } 447 }
363 448
364 -function skeyewebplayerChannelClick(playURL, btn,deviceId,channelId) { 449 +function skeyewebplayerChannelClick(playURL, btn, deviceId, channelId) {
365 let children = $("#skeyewebplayerDivContent", $("#skeyewebplayer")).children(); 450 let children = $("#skeyewebplayerDivContent", $("#skeyewebplayer")).children();
366 let length = children.length; 451 let length = children.length;
367 if (length === 1) { 452 if (length === 1) {
368 - displaySkeyewebplayerChannel(children[0], playURL, btn,deviceId,channelId); 453 + displaySkeyewebplayerChannel(children[0], playURL, btn, deviceId, channelId);
369 } else if (length > 1) { 454 } else if (length > 1) {
370 for (let i = 0; i < length; i++) { 455 for (let i = 0; i < length; i++) {
371 let classCss = $(children[i]).attr("class"); 456 let classCss = $(children[i]).attr("class");
372 if (classCss.indexOf("skeyewebplayerDivContent_play_selected") > -1) { 457 if (classCss.indexOf("skeyewebplayerDivContent_play_selected") > -1) {
373 - displaySkeyewebplayerChannel(children[i], playURL, btn,deviceId,channelId); 458 + displaySkeyewebplayerChannel(children[i], playURL, btn, deviceId, channelId);
374 break; 459 break;
375 } 460 }
376 } 461 }
@@ -379,48 +464,48 @@ function skeyewebplayerChannelClick(playURL, btn,deviceId,channelId) { @@ -379,48 +464,48 @@ function skeyewebplayerChannelClick(playURL, btn,deviceId,channelId) {
379 464
380 } 465 }
381 466
382 -function displaySkeyewebplayerChannel(htmlNode, playURL, btn,deviceId,channelId) { 467 +function displaySkeyewebplayerChannel(htmlNode, playURL, btn, deviceId, channelId) {
383 loading = loadingFunction(); 468 loading = loadingFunction();
384 let $htmlNode = $(htmlNode); 469 let $htmlNode = $(htmlNode);
385 let $btn = $(btn); 470 let $btn = $(btn);
386 deviceId = $btn.attr("deviceId"); 471 deviceId = $btn.attr("deviceId");
387 - channelId = $btn.attr("channelId"); 472 + channelId = $btn.attr("channelId");
388 473
389 474
390 - let htmlObj = $("div[class='skeyewebplayerDiv_play_content']", $htmlNode); 475 + let htmlObj = $("div[class='skeyewebplayerDiv_play_content']", $htmlNode);
391 476
392 htmlObj.html(""); 477 htmlObj.html("");
393 $("div[class='skeyewebplayerDiv_title']", $htmlNode).html($btn.attr("channelNode")); 478 $("div[class='skeyewebplayerDiv_title']", $htmlNode).html($btn.attr("channelNode"));
394 - playURL = playURL.replace("{device}",deviceId).replace("{channel}",channelId);  
395 - let playURL1 = "<iframe style='width:100%;height:100%;' src ='"+playURL+"'/>"; 479 + playURL = playURL.replace("{device}", deviceId).replace("{channel}", channelId);
  480 + let playURL1 = "<iframe style='width:100%;height:100%;' src ='" + playURL + "'/>";
396 481
397 htmlObj.html(playURL1); 482 htmlObj.html(playURL1);
398 closeLoading(); 483 closeLoading();
399 } 484 }
400 485
401 function skeyewebplayerOne() { 486 function skeyewebplayerOne() {
402 - skeyWebPlayer(1, "skeyewebplayer"); 487 + skeyWebPlayer(1, "live_broadcastDiv");
403 } 488 }
404 489
405 function skeyewebplayerFour() { 490 function skeyewebplayerFour() {
406 - skeyWebPlayer(4, "skeyewebplayer"); 491 + skeyWebPlayer(4, "live_broadcastDiv");
407 } 492 }
408 493
409 function skeyewebplayerNine() { 494 function skeyewebplayerNine() {
410 - skeyWebPlayer(9, "skeyewebplayer"); 495 + skeyWebPlayer(9, "live_broadcastDiv");
411 } 496 }
412 497
413 function skeyWebPlayer(len, parentId) { 498 function skeyWebPlayer(len, parentId) {
414 - var $skeyewebplayerDivContent = $("#skeyewebplayerDivContent", $("#" + parentId)); 499 + var $skeyewebplayerDivContent = $("#skeyewebplayerDivContent123", $("#" + parentId));
415 var classCss = "skeyewebplayerDivContent_one"; 500 var classCss = "skeyewebplayerDivContent_one";
416 - let width = $(window).width(); 501 + let width = $(window).width()*0.75;
417 width = width - width * 0.1; 502 width = width - width * 0.1;
418 - $skeyewebplayerDivContent.attr("style", "width:" + width + "px;height:98%;float:right");  
419 - skeyWebPlayer_myVar = setInterval(function () {  
420 - width = $(window).width();  
421 - width = width - width * 0.1;  
422 - $skeyewebplayerDivContent.attr("style", "width:" + width + "px;height:98%;float:right");  
423 - }, 1000); 503 + // $skeyewebplayerDivContent.attr("style", "width:100%;height:98%;float:right");
  504 + // skeyWebPlayer_myVar = setInterval(function () {
  505 + // width = $(window).width();
  506 + // width = width - width * 0.1;
  507 + // // $skeyewebplayerDivContent.attr("style", "width:100%;height:98%;float:right");
  508 + // }, 1000);
424 509
425 if (len === 4) { 510 if (len === 4) {
426 classCss = "skeyewebplayerDivContent_Four"; 511 classCss = "skeyewebplayerDivContent_Four";
@@ -428,6 +513,7 @@ function skeyWebPlayer(len, parentId) { @@ -428,6 +513,7 @@ function skeyWebPlayer(len, parentId) {
428 classCss = "skeyewebplayerDivContent_nine"; 513 classCss = "skeyewebplayerDivContent_nine";
429 } 514 }
430 515
  516 + console.log($skeyewebplayerDivContent)
431 var html = ""; 517 var html = "";
432 for (let i = 0; i < len; i++) { 518 for (let i = 0; i < len; i++) {
433 html += "<div class='" + classCss + "' id='skeyewebplayerDivContent_play_" + i + "' onclick=\"skeyewebplayerDivContent_play_click(this)\"><div class='skeyewebplayerDiv_title'>"; 519 html += "<div class='" + classCss + "' id='skeyewebplayerDivContent_play_" + i + "' onclick=\"skeyewebplayerDivContent_play_click(this)\"><div class='skeyewebplayerDiv_title'>";
src/main/resources/static/pages/video/videoPage.html
1 <script type="text/javascript"> 1 <script type="text/javascript">
2 var url = window.location.href; 2 var url = window.location.href;
3 - url= url.substring(0,url.indexOf("/pages/"))+"/video/video.html"; 3 + url= url.substring(0,url.indexOf("/pages/"))+"/other/video/video.html";
4 window.location.href=url; 4 window.location.href=url;
5 </script> 5 </script>