huliguo
5 天以前 9fb04a62cf681403345043eabafee4378173787d
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
package com.linghu.controller;
 
import com.alibaba.excel.EasyExcel;
import com.linghu.mapper.KeywordMapper;
import com.linghu.model.common.ResponseResult;
import com.linghu.model.entity.Keyword;
import com.linghu.model.entity.Reference;
import com.linghu.model.vo.KeywordStaticsListVO;
import com.linghu.model.vo.KeywordStaticsVO;
import com.linghu.model.vo.PlatformProportionVO;
import com.linghu.model.vo.ResultListVO;
import com.linghu.service.KeywordService;
import com.linghu.service.ReferenceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
 
import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayOutputStream;
import java.util.List;
 
@RestController
@RequestMapping("/keyword")
@Api(value = "采集详情相关接口", tags = "订单列表-采集列表-采集详情")
public class KeywordController {
    @Autowired
    private KeywordService keywordService;
 
    @Autowired
    private KeywordMapper keywordMapper;
 
    @Autowired
    private ReferenceService referenceService;
 
    /**
     * 关键词统计 EChart图
     */
    @GetMapping("/statics")
    @ApiOperation(value = "EChart图")
    public ResponseResult<KeywordStaticsListVO> statics(@RequestParam("id") Integer keywordId, @RequestParam(value = "questionId",required = false) Integer questionId) {
        return keywordService.statics(keywordId,questionId);
    }
 
    @PostMapping(value = "/exportStatics")
    @ApiOperation(value = "EChart图导出")
    public ResponseEntity<byte[]> exportStatics(@RequestParam("id") Integer keywordId, @RequestParam(value = "questionId",required = false) Integer questionId, HttpServletResponse response) {
        Keyword keyword = keywordMapper.selectById(keywordId);
        List<KeywordStaticsVO> voList = keywordMapper.statics(keywordId,questionId,keyword.getNum());
 
        // 3. 导出Excel
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        EasyExcel.write(out, KeywordStaticsVO.class)
                .sheet("引用数据")
                .doWrite(voList);
 
        // 4. 构建响应
        return ResponseEntity.ok()
                .header(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=references_export.xlsx")
                .contentType(MediaType.APPLICATION_OCTET_STREAM)
                .body(out.toByteArray());
    }
    /**
     * 根据类别查看
     */
    @GetMapping("/getResultByTypeId")
    @ApiOperation(value = "根据类别查看")
    public ResponseResult<List<PlatformProportionVO>> getResultByTypeId(@RequestParam("id") Integer keywordId, @RequestParam(value = "questionId",required = false) Integer questionId, @RequestParam(value = "typeId",required = false) Integer typeId) {
        return keywordService.getResultByTypeId(keywordId,questionId,typeId);
    }
 
 
    /**
     * 导出:根据类别查看
     */
    @PostMapping(value = "/exportGetResultByTypeId")
    @ApiOperation(value = "导出:根据类别查看")
    public ResponseEntity<byte[]> exportGetResultByTypeId(@RequestParam("id") Integer keywordId, @RequestParam(value = "questionId",required = false) Integer questionId, @RequestParam(value = "typeId",required = false) Integer typeId,@RequestParam(value = "isNow") Integer isNow ) {
        Keyword keyword = keywordService.getById(keywordId);
        List<PlatformProportionVO> result = keywordMapper.getResultByTypeId(keywordId, questionId, keyword.getNum() - isNow, typeId);
        // 3. 导出Excel
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        EasyExcel.write(out, PlatformProportionVO.class)
                .sheet("引用数据")
                .doWrite(result);
 
        // 4. 构建响应
        return ResponseEntity.ok()
                .header(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=references_export.xlsx")
                .contentType(MediaType.APPLICATION_OCTET_STREAM)
                .body(out.toByteArray());
    }
 
    /**
     * 根据平台查看
     */
    @GetMapping("/getResultByPlatformId")
    @ApiOperation(value = "根据平台查看")
    public ResponseResult<List<ResultListVO>> getResultByPlatformId(@RequestParam("id") Integer keywordId, @RequestParam(value = "questionId",required = false) Integer questionId, @RequestParam(value = "platformId",required = false) Integer platformId) {
        return keywordService.getResultByPlatformId(keywordId,questionId,platformId);
    }
 
    /**
     * 根据平台查看 0-当前轮 1-代表前1轮 2-代表前2轮
     */
    @GetMapping("/exportGetResultByPlatformId")
    @ApiOperation(value = "根据平台查看")
    public ResponseEntity<byte[]>  exportGetResultByPlatformId(@RequestParam("id") Integer keywordId, @RequestParam(value = "questionId",required = false) Integer questionId, @RequestParam(value = "platformId",required = false) Integer platformId,@RequestParam(value = "isNow") Integer isNow) {
        Keyword keyword = keywordService.getById(keywordId);
        List<ResultListVO> result = keywordMapper.getResultByPlatformId(keywordId, questionId, keyword.getNum() - isNow, platformId);
        // 3. 导出Excel
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        EasyExcel.write(out, ResultListVO.class)
                .sheet("引用数据")
                .doWrite(result);
 
        // 4. 构建响应
        return ResponseEntity.ok()
                .header(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=references_export.xlsx")
                .contentType(MediaType.APPLICATION_OCTET_STREAM)
                .body(out.toByteArray());
    }
 
    /**
     * 查看详情
     */
    @GetMapping("/getResultById")
    @ApiOperation(value = "根据平台查看")
    public ResponseResult getResultById(@RequestParam("referenceId") Integer referenceId) {
        Reference reference = referenceService.getById(referenceId);
        if (reference == null) {
            return ResponseResult.error("该结果不存在");
        }
        return ResponseResult.success(reference);
    }
 
 
    /**
     * 投喂
     */
 
 
 
 
 
}