管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2023-02-20 95da38d29cc4a88d1ee8b852f54b37fc5052a0ee
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
package com.lf.server.controller.data;
 
import com.lf.server.annotation.SysLog;
import com.lf.server.controller.all.BaseQueryController;
import com.lf.server.entity.all.ResponseMsg;
import com.lf.server.entity.sys.ReportEntity;
import com.lf.server.entity.sys.UserEntity;
import com.lf.server.helper.StringHelper;
import com.lf.server.service.all.UploadAttachService;
import com.lf.server.service.sys.ReportService;
import com.lf.server.service.sys.TokenService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
 
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 
/**
 * 数据统计
 * @author WWW
 */
@Api(tags = "数据管理\\数据统计")
@RestController
@RequestMapping("/dataCount")
public class DataCountController extends BaseQueryController {
    @Autowired
    ReportService reportService;
 
    @Autowired
    TokenService tokenService;
 
    @Autowired
    UploadAttachService uploadAttachService;
 
    private final static String TAB_NAME = "lf.sys_report";
 
    @SysLog()
    @ApiOperation(value = "上传文件")
    @ResponseBody
    @PostMapping(value = "/upload")
    public ResponseMsg<String> upload(@RequestParam("file") MultipartFile file, HttpServletRequest req) {
        UserEntity ue = tokenService.getCurrentUser(req);
 
        return uploadAttachService.upload(ue, TAB_NAME, file, this);
    }
 
    @SysLog()
    @ApiOperation(value = "下载文件")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "guid", value = "附件Guid", dataType = "String", paramType = "body")
    })
    @GetMapping(value = "/download")
    public void download(String guid, HttpServletResponse res) {
        uploadAttachService.download(guid, res);
    }
 
    @SysLog()
    @ApiOperation(value = "下载报告")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "报告ID", dataType = "Integer", paramType = "7")
    })
    @GetMapping(value = "/downloadReport")
    public void downloadReport(Integer id, HttpServletRequest req, HttpServletResponse res) {
        try {
            if (null == id || id < 1) {
                return;
            }
 
            ReportEntity re = reportService.selectById(id);
            if (null == re || StringHelper.isEmpty(re.getGuid()) || StringHelper.isEmpty(re.getType()) || StringHelper.isEmpty(re.getCode())) {
                return;
            }
 
            UserEntity ue = tokenService.getCurrentUser(req);
 
            reportService.createReport(ue, re, res);
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
        }
    }
}