InfoPublishController.java
2.64 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
package com.bsth.controller.publish;
import com.bsth.common.ResponseCode;
import com.bsth.entity.publish.ScanStatictic;
import com.bsth.message.entity.AlarmADASVo;
import com.bsth.service.alarm.AlarmAdasService;
import com.bsth.service.publish.InfoPublishService;
import com.bsth.util.ReportUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.*;
//@RestController
//@RequestMapping("api/info_publish")
public class InfoPublishController {
private final static Logger log = LoggerFactory.getLogger(InfoPublishController.class);
@Autowired
private InfoPublishService infoPublishService;
@RequestMapping(value = "/scan_statistic/list")
public Map<String, Object> list(@RequestParam Map<String, String> param,
@RequestParam(defaultValue = "0") int page,
@RequestParam(defaultValue = "15") int size,
@RequestParam(defaultValue = "timestamp") String order,
@RequestParam(defaultValue = "0") int direction) {
Map<String, Object> result = new HashMap<>();
try {
Map<String, Object> results = infoPublishService.list(param, page, size, order, direction);
result.putAll(results);
result.put("page", page);
result.put("status", ResponseCode.SUCCESS);
} catch (Exception e) {
result.put("status", ResponseCode.ERROR);
log.error(e.getMessage(), e);
}
return result;
}
@RequestMapping(value = "/scan_statistic/list_export")
public Map<String, Object> list(@RequestParam Map<String, String> param) {
Map<String, Object> result = new HashMap<>();
try {
Map<String, Object> results = infoPublishService.export(param);
ReportUtils util = new ReportUtils();
String path = this.getClass().getResource("/").getPath() + "static/pages/forms", rq = param.get("rq");
util.excelReplace((List<Iterator<?>>) results.get("list"), new Object[]{}, String.format("%s/mould/scanStatistic.xls", path), String.format("%s/export/一站一码扫码情况%s.xls", path, rq));
result.put("status", ResponseCode.SUCCESS);
} catch (Exception e) {
result.put("status", ResponseCode.ERROR);
log.error(e.getMessage(), e);
}
return result;
}
}