SupervisionTrackController.java
6.79 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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
package com.trash.business.controller;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.trash.common.annotation.Log;
import com.trash.common.core.controller.BaseController;
import com.trash.common.core.domain.AjaxResult;
import com.trash.common.enums.BusinessType;
import com.trash.business.domain.SupervisionTrack;
import com.trash.business.mapper.SupervisionTrackMapper;
import com.trash.business.service.ISupervisionTrackService;
import com.trash.common.utils.poi.ExcelUtil;
import com.trash.common.core.page.TableDataInfo;
/**
* 跟踪监督Controller
*
* @author wmh
* @date 2023-11-22
*/
@RestController
@RequestMapping("/business/track")
public class SupervisionTrackController extends BaseController
{
@Autowired
private ISupervisionTrackService supervisionTrackService;
@Autowired
private SupervisionTrackMapper mapper;
/**
* 查询跟踪监督列表
*/
@GetMapping("/list")
public TableDataInfo list(SupervisionTrack supervisionTrack)
{
startPage();
List<SupervisionTrack> list = supervisionTrackService.selectSupervisionTrackList(supervisionTrack);
return getDataTable(list);
}
@GetMapping("/getAllDate")
public AjaxResult getAllDate(SupervisionTrack supervisionTrack)
{
startPage();
List<Map<String,String>> list = mapper.getAllDate();
Map<String,List<String>> data = new HashMap<>();
data.put("year", new ArrayList<String>());
data.put("season", new ArrayList<String>());
for(Map<String,String> map : list){
String y = map.get("month").split("-")[0];
String m = map.get("month").split("-")[1];
int season = (int)Math.ceil(Double.parseDouble(m) / 3);
if(data.get("year").indexOf(y) == -1){
data.get("year").add(y);
}
if(data.get("season").indexOf(y + "第" + season + "季度") == -1){
data.get("season").add(y + "第" + season + "季度");
}
}
return AjaxResult.success(data);
}
@GetMapping("/getTables")
public AjaxResult getTables(SupervisionTrack supervisionTrack)
{
List<Map<String,String>> list = mapper.getTables(supervisionTrack);
return AjaxResult.success(list);
}
/**
* 查询跟踪监督列表
*/
@GetMapping("/getSettings")
public AjaxResult getSettings()
{
Map map = new HashMap<String, String>();
File file =new File("./settings.txt");
String params = "2 1 10 2 1 10 2 1 10 2 1 10 2 1 10 2 1 10 2 1 10 2 1 10";
if(!file.exists()){
try {
file.createNewFile();
FileOutputStream fos =new FileOutputStream(file);
fos.write(params.getBytes());
fos.flush();
fos.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}else{
try {
FileInputStream fis = new FileInputStream(file);
byte[] bs = new byte[fis.available()];
fis.read(bs);
params = new String(bs);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
String[] arr = params.split(" ");
for(int i =0;i<8;i++){
map.put("type_"+i+"_timeout", arr[i*3]);
map.put("type_"+i+"_season", arr[i*3+1]);
map.put("type_"+i+"_pect", arr[i*3+2]);
}
return AjaxResult.success(map);
}
@PostMapping("/saveSettings")
public AjaxResult saveSettings(@RequestBody Map<String, String> map)
{
File file =new File("./settings.txt");
String params = "";
for(int i =0;i<8;i++){
params += " " + map.get("type_"+i+"_timeout") + " " + map.get("type_"+i+"_season") + " " + map.get("type_"+i+"_pect");
}
if(!file.exists()){
try {
file.createNewFile();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
params = params.substring(1,params.length());
try {
FileOutputStream fos =new FileOutputStream(file);
fos.write(params.getBytes());
fos.flush();
fos.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return AjaxResult.success();
}
/**
* 导出跟踪监督列表
*/
@Log(title = "跟踪监督", businessType = BusinessType.EXPORT)
@GetMapping("/export")
public AjaxResult export(SupervisionTrack supervisionTrack)
{
List<SupervisionTrack> list = supervisionTrackService.selectSupervisionTrackList(supervisionTrack);
ExcelUtil<SupervisionTrack> util = new ExcelUtil<SupervisionTrack>(SupervisionTrack.class);
return util.exportExcel(list, "track");
}
/**
* 获取跟踪监督详细信息
*/
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return AjaxResult.success(supervisionTrackService.selectSupervisionTrackById(id));
}
/**
* 新增跟踪监督
*/
@PreAuthorize("@ss.hasPermi('business:track:add')")
@Log(title = "跟踪监督", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody SupervisionTrack supervisionTrack)
{
return toAjax(supervisionTrackService.insertSupervisionTrack(supervisionTrack));
}
/**
* 修改跟踪监督
*/
@Log(title = "跟踪监督", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody SupervisionTrack supervisionTrack)
{
return toAjax(supervisionTrackService.updateSupervisionTrack(supervisionTrack));
}
/**
* 删除跟踪监督
*/
@Log(title = "跟踪监督", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(supervisionTrackService.deleteSupervisionTrackByIds(ids));
}
}