RealTimeDataController.java
5.3 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
package com.skua.modules.realtimedata.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.skua.core.api.vo.Result;
import com.skua.core.aspect.annotation.AutoLog;
import com.skua.core.context.BaseContextHandler;
import com.skua.modules.realtimedata.service.IRealTimeDataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
/**
* 实时数据
*/
@Slf4j
@RestController
@RequestMapping("/sys/duplicate")
@Api(tags = "实时数据")
public class RealTimeDataController {
@Autowired
private IRealTimeDataService realTimeDataService;
/**
* 获取实时数据
*
* @return
*/
@RequestMapping(value = "/queryRealTimeData", method = RequestMethod.GET)
@ApiOperation("获取实时数据")
public Result<IPage> queryRealTimeData(@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, String departId, String type, String structId,String nmName, HttpServletRequest request) {
Result<IPage> result = new Result();
List<Map<String, Object>> data = realTimeDataService.queryRealTimeData(departId, type, structId,nmName);
IPage iPage = new IPage() {
@Override
public List<OrderItem> orders() {
return null;
}
@Override
public List getRecords() {
List list;
if (pageNo * pageSize <= data.size()) {
list = data.subList((pageNo - 1) * pageSize, pageNo * pageSize);
} else {
list = data.subList((pageNo - 1) * pageSize, data.size());
}
return list;
}
@Override
public IPage setRecords(List records) {
return null;
}
@Override
public long getTotal() {
return data.size();
}
@Override
public IPage setTotal(long total) {
return null;
}
@Override
public long getSize() {
return pageSize;
}
@Override
public IPage setSize(long size) {
return null;
}
@Override
public long getCurrent() {
return pageNo;
}
@Override
public IPage setCurrent(long current) {
return null;
}
};
result.setResult(iPage);
result.setSuccess(true);
return result;
}
/**
* 获取实时数据
*
* @return
*/
@RequestMapping(value = "/queryStructData", method = RequestMethod.GET)
@ApiOperation("获取实时数据工艺区间")
public Result<List<Map<String, Object>>> queryStructData(String departId) {
Result<List<Map<String, Object>>> result = new Result();
if(StringUtils.isEmpty(departId)) {
departId = BaseContextHandler.getRealDepartId();
}
List<Map<String, Object>> data = realTimeDataService.queryStructData(departId);
result.setResult(data);
result.setSuccess(true);
return result;
}
@AutoLog(value = "web趋势")
@ApiOperation(value = "web趋势", notes = "web趋势")
@GetMapping(value = "/getSZTreadWeb")
public Result<Map<String, Object>> getSZTreadWeb(String factoryId, String timeType, String startTime, String endTime, String id) {
Result<Map<String, Object>> result = new Result<>();
Map<String, Object> data = realTimeDataService.getSZTreadWeb(factoryId, timeType, startTime,endTime,id);
result.setResult(data);
result.setSuccess(true);
return result;
}
/**
* 获取实时数据
*
* @return
*/
@RequestMapping(value = "/queryStructDataApp", method = RequestMethod.GET)
@ApiOperation("APP获取实时数据工艺区间")
public Result<List<Map<String, Object>>> queryStructDataApp(String departId, HttpServletRequest request) {
Result<List<Map<String, Object>>> result = new Result();
List<Map<String, Object>> data = realTimeDataService.queryStructDataApp(departId);
result.setResult(data);
result.setSuccess(true);
return result;
}
/**
* 获取实时数据
*
* @return
*/
@RequestMapping(value = "/queryRealTimeDataApp", method = RequestMethod.GET)
@ApiOperation("APP获取实时数据")
public Result<List<Map<String, Object>>> queryRealTimeDataApp(String departId, String type, String structId, String sortType,String nmName, HttpServletRequest request) {
Result<List<Map<String, Object>>> result = new Result();
List<Map<String, Object>> data = realTimeDataService.queryRealTimeDataApp(departId, type, structId, sortType,nmName);
result.setResult(data);
result.setSuccess(true);
return result;
}
}