管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2022-12-29 1d53dd8f501a98ddcce8146443b51b357ef5f9b1
src/main/java/com/lf/server/controller/show/PipelineController.java
@@ -1,9 +1,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 sws
 * @date   2022-09-22
 * 管道分析
 * @author WWW
 */
public class PipelineController {
@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;
    }
}