VideoController.java
4.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
package com.bsth.controller.video;
import com.alibaba.dubbo.container.page.Page;
import com.alibaba.fastjson.JSON;
import com.bsth.common.ResponseCode;
import com.bsth.controller.schedule.basicinfo.legacy.CarsController;
import com.bsth.entity.Business;
import com.bsth.entity.Cars;
import com.bsth.entity.Line;
import com.bsth.entity.video.CarsTreeTable;
import com.bsth.entity.video.VideoChannel;
import com.bsth.entity.video.VideoTree;
import com.bsth.service.BusinessService;
import com.bsth.service.LineService;
import com.bsth.service.impl.videoimpl.WvpConfig;
import com.bsth.service.video.VideoService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageImpl;
import org.springframework.web.bind.annotation.*;
import java.util.*;
/**
* @author liujun
* @date 2024年07月01日 12:52
*/
@RestController
@Slf4j
@RequestMapping("video")
public class VideoController {
@Autowired
private VideoService videoService;
@Autowired
private CarsController carsController;
@Autowired
private WvpConfig wvpConfig;
@GetMapping("/tree")
public Map<String, Object> combinationTree() {
Map<String, Object> result = new HashMap<>();
try {
List<VideoTree> trees = videoService.combinationTree();
result.put("status", ResponseCode.SUCCESS);
result.put("data", trees);
} catch (Exception e) {
log.error("查询视频树异常", e);
result.put("status", ResponseCode.ERROR);
}
return result;
}
@GetMapping("/tree/table")
public Map<String, Object> queryTreeTable(@RequestParam Map<String, Object> map,
@RequestParam(defaultValue = "0") int page,
@RequestParam(defaultValue = "10") int size,
@RequestParam(defaultValue = "id") String order,
@RequestParam(defaultValue = "DESC") String direction) {
Map<String, Object> result = new HashMap<>();
page = page - 1;
Map<String, Object> queryResult = carsController.list(map, page, size, order, direction);
if (MapUtils.isEmpty(queryResult)) {
result.put("status", ResponseCode.ERROR);
return result;
}
if (Objects.equals(queryResult.get("status"), ResponseCode.ERROR.name())) {
result.put("status", ResponseCode.ERROR);
return result;
}
PageImpl<Cars> page1 = (PageImpl<Cars>) queryResult.get("data");
if (Objects.nonNull(page1)) {
result.put("count", page1.getTotalElements());
int contentSize = CollectionUtils.size(page1.getContent());
if (contentSize > 0) {
List<CarsTreeTable> carsTreeTables = new ArrayList<>(contentSize);
for (Object car : page1.getContent()) {
CarsTreeTable treeTable = new CarsTreeTable();
BeanUtils.copyProperties(car, treeTable);
carsTreeTables.add(treeTable);
}
result.put("data", carsTreeTables);
}
result.put("code", 0);
}
return result;
}
@GetMapping("/car/channel/{carNo}")
public Map<String, Object> queryChannels(@PathVariable String carNo) {
Map<String, Object> result = new HashMap<>();
try {
List<Map<String, Object>> videoChannels = videoService.getVideoChannel(carNo);
result.put("status", ResponseCode.SUCCESS);
result.put("data", videoChannels);
result.put("channelImageURL",wvpConfig.getChannelListOfImgURL());
result.put("wvpPlayURL",wvpConfig.getWvpPlayURL());
} catch (Exception e) {
log.error("查询车辆通道异常:[{}]", carNo, e);
result.put("status", ResponseCode.ERROR);
}
return result;
}
}