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 selectSegNames() { try { List 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 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 map = new HashMap<>(); for (String tab : pe.getTabs()) { List 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 tabs) { for (String tab : tabs) { if (!StaticData.PIPE_ANALYSIS_TABS.contains(tab)) { return false; } } return true; } }