管道基础大数据平台系统开发-【后端】-Server
13693261870
2022-12-28 049e8125cd972b564c20dcdc153dfec55b6ae810
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
package com.lf.server.controller.show;
 
import com.lf.server.annotation.SysLog;
import com.lf.server.controller.all.BaseController;
import com.lf.server.entity.all.ResponseMsg;
import com.lf.server.entity.all.StaticData;
import com.lf.server.entity.show.PipelineEntity;
import com.lf.server.service.show.PipelineService;
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 java.util.*;
 
/**
 * 管道分析
 * @author WWW
 */
@Api(tags = "综合展示\\管道分析")
@RestController
@RequestMapping("/pipeline")
public class PipelineController extends BaseController {
    @Autowired
    PipelineService pipelineService;
 
    @SysLog()
    @ApiOperation(value = "查询管段")
    @GetMapping(value = "/selectSegNames")
    public ResponseMsg<Object> selectSegNames() {
        try {
            List<PipelineEntity> rs = pipelineService.selectSegNames();
 
            return success(rs);
        } catch (Exception ex) {
            return fail(ex.getMessage(), null);
        }
    }
 
    @SysLog()
    @ApiOperation(value = "查询管线分析")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pe", value = "管道分析实体类", dataType = "PipelineEntity", paramType = "body")
    })
    @ResponseBody
    @PostMapping(value = "/selectPipeAnalysis")
    public ResponseMsg<Object> selectPipeAnalysis(@RequestBody PipelineEntity pe) {
        try {
            if (null == pe.getGid() || pe.getGid() < 1) {
                return fail("请输入管段ID");
            }
            if (null == pe.getTabs() || 0 == pe.getTabs().size()) {
                return fail("请输入表名");
            }
            if (!checkTabs(pe.getTabs())) {
                return fail("存在非法表名");
            }
 
            Map<String, Object> map = new HashMap<>();
            for (String tab : pe.getTabs()) {
                List<PipelineEntity> rs = pipelineService.selectPipeAnalysis(tab, pe.getGid());
                map.put(tab, rs);
            }
 
            return success(map);
        } catch (Exception ex) {
            return fail(ex.getMessage(), null);
        }
    }
 
    /**
     * 检查表名
     */
    private boolean checkTabs(List<String> tabs) {
        for (String tab : tabs) {
            if (!StaticData.PIPE_ANALYSIS_TABS.contains(tab)) {
                return false;
            }
        }
 
        return true;
    }
}