Browse Source

fix: 修复按eci查询错误

weijianghai 2 years ago
parent
commit
f9861e3120

+ 15 - 4
src/main/java/com/nokia/hb/config/web/LoginHandlerInterceptor.java

@@ -1,7 +1,7 @@
 package com.nokia.hb.config.web;
 package com.nokia.hb.config.web;
 
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import lombok.NoArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.web.servlet.HandlerInterceptor;
 import org.springframework.web.servlet.HandlerInterceptor;
 
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletRequest;
@@ -11,19 +11,30 @@ import javax.servlet.http.HttpSession;
 /**
 /**
  * 登录拦截器
  * 登录拦截器
  */
  */
+@Slf4j
+@NoArgsConstructor
 public class LoginHandlerInterceptor implements HandlerInterceptor {
 public class LoginHandlerInterceptor implements HandlerInterceptor {
-    private static final Logger log= LoggerFactory.getLogger(LoginHandlerInterceptor.class);
+    /**
+     * session过期时间(秒)
+     */
+    private Integer timeoutSeconds;
+
+    public LoginHandlerInterceptor(Integer timeoutSeconds) {
+        this.timeoutSeconds = timeoutSeconds;
+    }
 
 
     @Override
     @Override
     public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
     public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
         HttpSession session = request.getSession();
         HttpSession session = request.getSession();
         Object username = session.getAttribute("username");
         Object username = session.getAttribute("username");
         log.debug("username: {}", username);
         log.debug("username: {}", username);
+        // 用户名为空重定向登录页面
         if (username == null) {
         if (username == null) {
             response.sendRedirect("/login");
             response.sendRedirect("/login");
             return false;
             return false;
         }
         }
-
+        // 延长session过期时间
+        session.setMaxInactiveInterval(timeoutSeconds);
         return true;
         return true;
     }
     }
 }
 }

+ 6 - 28
src/main/java/com/nokia/hb/config/web/MyWebMvcConfigurer.java

@@ -11,7 +11,10 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
 
 
 @Configuration
 @Configuration
 public class MyWebMvcConfigurer implements WebMvcConfigurer {
 public class MyWebMvcConfigurer implements WebMvcConfigurer {
-    @Value("${redis.timeoutSeconds:600}")
+    /**
+     * session过期时间(秒)
+     */
+    @Value("${session.timeout}")
     private Integer timeoutSeconds;
     private Integer timeoutSeconds;
 
 
     @Override
     @Override
@@ -20,8 +23,8 @@ public class MyWebMvcConfigurer implements WebMvcConfigurer {
         registry.addInterceptor(new RequestLogHandlerInterceptor())
         registry.addInterceptor(new RequestLogHandlerInterceptor())
                 .addPathPatterns("/**")
                 .addPathPatterns("/**")
                 .excludePathPatterns("/", "/login", "/template", "/error", "/js/**", "/html/**", "/image/**", "/css/**");
                 .excludePathPatterns("/", "/login", "/template", "/error", "/js/**", "/html/**", "/image/**", "/css/**");
-        // 添加web登录拦截
-        registry.addInterceptor(new LoginHandlerInterceptor())
+        // 添加登录拦截
+        registry.addInterceptor(new LoginHandlerInterceptor(timeoutSeconds))
                 .addPathPatterns("/**")
                 .addPathPatterns("/**")
                 .excludePathPatterns("/login", "/error", "/userLogin", "/js/**", "/html/**", "/image/**", "/css/**");
                 .excludePathPatterns("/login", "/error", "/userLogin", "/js/**", "/html/**", "/image/**", "/css/**");
     }
     }
@@ -34,29 +37,4 @@ public class MyWebMvcConfigurer implements WebMvcConfigurer {
     public DispatcherServlet dispatcherServlet() {
     public DispatcherServlet dispatcherServlet() {
         return new MyDispatcherServlet();
         return new MyDispatcherServlet();
     }
     }
-
-//    /**
-//     * 配置消息转换器
-//     *
-//     * @param converters 转换器
-//     */
-//    @Override
-//    public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
-//        converters.add(mappingJackson2HttpMessageConverter());
-//    }
-//
-//    /**
-//     * 配置映射jackson2 http消息转换器
-//     *
-//     * @return {@link MappingJackson2HttpMessageConverter}
-//     */
-//    @Bean
-//    public MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter() {
-//        MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
-//        ObjectMapper mapper = new ObjectMapper();
-//        mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
-//        mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
-//        converter.setObjectMapper(mapper);
-//        return converter;
-//    }
 }
 }

+ 211 - 0
src/main/java/com/nokia/hb/controller/DataViewController.java

@@ -0,0 +1,211 @@
+//package com.nokia.hb.Controller;
+//
+//import com.alibaba.fastjson.JSON;
+//import com.nokia.hb.Service.DataViewService;
+//import org.springframework.stereotype.Controller;
+//import org.springframework.web.bind.annotation.GetMapping;
+//import org.springframework.web.bind.annotation.RequestMapping;
+//import org.springframework.web.bind.annotation.RequestParam;
+//import org.springframework.web.bind.annotation.ResponseBody;
+//
+//import javax.servlet.http.HttpServletResponse;
+//import java.io.ByteArrayInputStream;
+//import java.io.IOException;
+//import java.io.UnsupportedEncodingException;
+//import java.time.LocalDate;
+//import java.time.format.DateTimeFormatter;
+//import java.util.*;
+//
+//@Controller
+//@RequestMapping("/")
+//public class DataViewController {
+//    public DataViewService dataViewService = new DataViewService();
+//
+//    @GetMapping("initProvince")
+//    @ResponseBody
+//    public List<String> initProvince(String type) {
+//        System.out.println("initProvince");
+//        System.out.println(type);
+//        return dataViewService.initProvince(type);
+//
+//    }
+//
+//    @GetMapping("initCitys")
+//    @ResponseBody
+//    public List<String> initCitys(String type, String province) {
+//        System.out.println("initCitys");
+//        System.out.println(type);
+//        System.out.println(province);
+//
+//
+//        return dataViewService.initCitys(type, province);
+//
+//    }
+//
+//    @GetMapping("search")
+//    @ResponseBody
+//    public String search(String from, String range, String stype, String ttype, String provinces, String citys) {
+//        String[] split = range.split("-");
+//        String t1 = split[0].trim();
+//        String t2 = split[1].trim();
+//        if (!"".equals(citys)) {
+//            String[] split1 = citys.split(",");
+//            citys = "";
+//            for (String s : split1) {
+//                citys += "'" + s + "'" + ",";
+//            }
+//            citys = citys.substring(0, citys.length() - 1);
+//        }
+//        String[] split2 = provinces.split(",");
+//        provinces = "";
+//        for (String s : split2) {
+//            provinces += "'" + s + "'" + ",";
+//        }
+//        provinces = provinces.substring(0, provinces.length() - 1);
+//        Map<String, List<Object>> search = dataViewService.search(from, t1, t2, stype, ttype, provinces, citys);
+//        String s = JSON.toJSONString(search);
+//
+//        System.out.println(s);
+//        return s;
+//
+//    }
+//
+//
+//    @GetMapping("typeExport")
+//    public void typeExport(HttpServletResponse response, String from, String provinces, String citys, String ttype, String range) {
+//        //from :local roaming
+//        //etype :导出全量
+//        //ttype:天 7天
+//        //range: 20210721 - 20210728
+//
+//        String[] split = range.split("-");
+//        String t1 = split[0].trim();
+//        String t2 = split[1].trim();
+//
+//
+//
+//        String s = dataViewService.typeExport(from, provinces, citys, ttype, t1, t2);
+//
+//
+////        list.toString().getBytes();
+//        ByteArrayInputStream bis = null;
+//        try {
+//            bis = new ByteArrayInputStream(s.getBytes("gbk"));
+//        } catch (UnsupportedEncodingException e) {
+//            e.printStackTrace();
+//        }
+//        // 下载本地文件
+//        String fileName = "5GTypeDownload_" + range + ".csv"; // 文件的默认保存名
+//        // 读到流中
+//        //InputStream inStream = new FileInputStream("/home/ubantu/Desktop/seq.java");// 文件的存放路径
+//        // 设置输出的格式
+//        response.reset();
+//        response.setContentType("text/plain");
+//        response.addHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
+//        response.setCharacterEncoding("UTF-8");
+//        // 循环取出流中的数据
+//        byte[] b = new byte[100];
+//        int len;
+//        try {
+//            while ((len = bis.read(b)) > 0)
+//                response.getOutputStream().write(b, 0, len);
+//            bis.close();
+//        } catch (IOException e) {
+//            e.printStackTrace();
+//        }
+//    }
+//
+//
+//    @GetMapping("exportAll")
+//    public void typeExport(HttpServletResponse response, @RequestParam String ttype, @RequestParam String range) {
+//
+//        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
+//        String[] split = range.split("-");
+//        String sts = split[0].trim();
+//        String ets = split[1].trim();//最后日期
+//        LocalDate sld = LocalDate.parse(sts, formatter);
+//        LocalDate eld = LocalDate.parse(ets, formatter);
+//        LocalDate smld = sld.minusDays(Integer.valueOf(ttype));
+//        LocalDate emld = eld.minusDays(Integer.valueOf(ttype));
+//        String smts = formatter.format(smld);
+//        String emts = formatter.format(emld);
+//        String s = dataViewService.exportAll(ttype, sts, ets, smts, emts);
+//
+//
+////        list.toString().getBytes();
+//        ByteArrayInputStream bis = null;
+//        try {
+////            bis = new ByteArrayInputStream(s.getBytes("UTF-8"));
+//            bis = new ByteArrayInputStream(s.getBytes("gbk"));
+//        } catch (UnsupportedEncodingException e) {
+//            e.printStackTrace();
+//        }
+//        // 下载本地文件
+//        String fileName = "5GTypeAllDownload_" + range + ".csv"; // 文件的默认保存名
+//        // 读到流中
+//        //InputStream inStream = new FileInputStream("/home/ubantu/Desktop/seq.java");// 文件的存放路径
+//        // 设置输出的格式
+//        response.reset();
+//        response.setContentType("text/plain");
+//        response.addHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
+//        response.setCharacterEncoding("UTF-8");
+//        // 循环取出流中的数据
+//        byte[] b = new byte[100];
+//        int len;
+//        try {
+//            while ((len = bis.read(b)) > 0)
+//                response.getOutputStream().write(b, 0, len);
+//            bis.close();
+//        } catch (IOException e) {
+//            e.printStackTrace();
+//        }
+//    }
+//
+//
+//    @GetMapping("exportClose")
+//    public void typeExportClose(HttpServletResponse response, @RequestParam String ttype, @RequestParam String range) {
+//
+//        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
+//        String[] split = range.split("-");
+//        String sts = split[0].trim();
+//        String ets = split[1].trim();//最后日期
+//        LocalDate sld = LocalDate.parse(sts, formatter);
+//        LocalDate eld = LocalDate.parse(ets, formatter);
+//        LocalDate smld = sld.minusDays(Integer.valueOf(ttype));
+//        LocalDate emld = eld.minusDays(Integer.valueOf(ttype));
+//        String smts = formatter.format(smld);
+//        String emts = formatter.format(emld);
+//        String s = dataViewService.exportClose(ttype, sts, ets, smts, emts);
+//
+//
+////        list.toString().getBytes();
+//        ByteArrayInputStream bis = null;
+//        try {
+////            bis = new ByteArrayInputStream(s.getBytes("UTF-8"));
+//            bis = new ByteArrayInputStream(s.getBytes("gbk"));
+//        } catch (UnsupportedEncodingException e) {
+//            e.printStackTrace();
+//        }
+//        // 下载本地文件
+//        String fileName = "5GTypeCloseDownload_" + range + ".csv"; // 文件的默认保存名
+//        // 读到流中
+//        //InputStream inStream = new FileInputStream("/home/ubantu/Desktop/seq.java");// 文件的存放路径
+//        // 设置输出的格式
+//        response.reset();
+//        response.setContentType("text/plain");
+//        response.addHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
+//        response.setCharacterEncoding("UTF-8");
+//        // 循环取出流中的数据
+//        byte[] b = new byte[100];
+//        int len;
+//        try {
+//            while ((len = bis.read(b)) > 0)
+//                response.getOutputStream().write(b, 0, len);
+//            bis.close();
+//        } catch (IOException e) {
+//            e.printStackTrace();
+//        }
+//    }
+//
+//
+//}

+ 91 - 0
src/main/java/com/nokia/hb/controller/TemplateController.java

@@ -0,0 +1,91 @@
+package com.nokia.hb.controller;
+
+import com.nokia.hb.pojo.RetData;
+import com.nokia.hb.pojo.TreeNode;
+import com.nokia.hb.utils.DbUtil;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpSession;
+import java.util.List;
+
+@RestController
+public class TemplateController {
+    /**
+     * 用户登录
+     */
+    @PostMapping("userLogin")
+    public Object userLogin(String username, String password, HttpSession session) {
+        return DbUtil.userLogin(username, password, session);
+    }
+
+    /**
+     * 查询地市树形结构
+     *
+     * @return {@link List}<{@link TreeNode}>
+     */
+    @GetMapping("initTreeCitys")
+    public List<TreeNode> initTreeCitys() {
+        return DbUtil.initTreeCitys();
+    }
+
+    /**
+     * 查询指标树形结构
+     *
+     * @return {@link List}<{@link TreeNode}>
+     */
+    @GetMapping("initTreeIndicator")
+    public List<TreeNode> initTreeIndicator() {
+        return DbUtil.initTreeIndicator();
+    }
+
+    /**
+     * 查询pm数据
+     *
+     * @param citys      地市
+     * @param quxians    区县
+     * @param indicators 指标
+     * @param ttype      时间单位
+     * @param sdate      时间范围
+     * @param condition  条件
+     * @param searchType 搜索类型
+     * @param session    会话
+     * @return {@link RetData}
+     */
+    @PostMapping("renderTable")
+    public RetData renderTable(String citys, String quxians, String indicators, String ttype, String sdate,
+                               String condition, String searchType, HttpSession session) {
+        return DbUtil.renderTable(citys, quxians, indicators, ttype, sdate, condition, searchType, session);
+    }
+
+    /**
+     * 添加指标模板
+     *
+     * @param templateName 指标模板名称
+     * @param indicators   指标
+     */
+    @PostMapping("addTemplate")
+    public Object addTemplate(String templateName, String indicators, HttpSession session) {
+        return DbUtil.addTemplate(templateName, indicators, session);
+    }
+
+    /**
+     * 获取指标模板
+     */
+    @GetMapping("initTreeIndicatorTemplate")
+    public List<TreeNode> initTreeIndicatorTemplate(HttpSession session) {
+        return DbUtil.initTreeIndicatorTemplate(session);
+    }
+
+    /**
+     * 删除指标模板
+     *
+     * @param ids 模板id
+     */
+    @PostMapping("deleteTemplate")
+    public Object deleteTemplate(String ids) {
+
+        return DbUtil.deleteTemplate(ids);
+    }
+}

+ 43 - 0
src/main/java/com/nokia/hb/controller/ViewController.java

@@ -0,0 +1,43 @@
+package com.nokia.hb.Controller;
+
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.servlet.ModelAndView;
+
+@Controller
+@RequestMapping("/")
+public class ViewController {
+//    @GetMapping("view")
+//    public ModelAndView  view()
+//    {
+//        ModelAndView model = new ModelAndView("view");
+//        return model;
+//    }
+
+    /**
+     * 登录页面
+     */
+    @GetMapping("login")
+    public ModelAndView  login()
+    {
+        ModelAndView model = new ModelAndView("login");
+        return model;
+    }
+
+    @GetMapping("template")
+    public ModelAndView  template()
+    {
+        ModelAndView model = new ModelAndView("template");
+        return model;
+    }
+
+    @GetMapping("error")
+    public ModelAndView error()
+    {
+        ModelAndView model = new ModelAndView("error");
+        return model;
+    }
+
+
+}

+ 50 - 0
src/main/java/com/nokia/hb/dao/DataViewDao.java

@@ -0,0 +1,50 @@
+//package com.nokia.hb.Dao;
+//
+//import com.alibaba.fastjson.JSON;
+//import com.nokia.hb.utils.DbUtil;
+//import javafx.application.Application;
+//import javafx.stage.Stage;
+//
+//import java.awt.image.DataBuffer;
+//import java.util.HashMap;
+//import java.util.List;
+//import java.util.Map;
+//
+//public class DataViewDao {
+//
+//
+//    public static String typeExport(String from, String provinces, String citys, String ttype, String t1, String t2) {
+//
+//
+//        return DbUtil.typeExport(from, provinces, citys, ttype, t1, t2);
+//    }
+//
+//    public static String exportAll(String ttype, String sts, String ets, String smts, String emts) {
+//        return DbUtil.exportAll(ttype, sts, ets, smts, emts);
+//    }
+//
+//    public static Map<String, List<Object>> search(String from, String t1, String t2, String stype, String ttype, String provinces, String citys) {
+//        Map<String, List<Object>>res = null;
+//        if("5G开关打开率".equals(stype)){
+//            res=DbUtil.searchRate(from, t1, t2, ttype, provinces, citys);
+//        }else {
+//            res=DbUtil.search(from, t1, t2, stype, ttype, provinces, citys);
+//        }
+//
+//        return res;
+//    }
+//
+//    public static String exportClose(String ttype, String sts, String ets, String smts, String emts) {
+//        return DbUtil.exportClose(ttype, sts, ets, smts, emts);
+//    }
+//
+//
+//    public List<String> initProvince(String type) {
+//        return DbUtil.initProvince(type);
+//    }
+//
+//    public List<String> initCitys(String type, String province) {
+//        return DbUtil.initCitys(type, province);
+//    }
+//
+//}

+ 38 - 0
src/main/java/com/nokia/hb/pojo/Col.java

@@ -0,0 +1,38 @@
+package com.nokia.hb.pojo;
+
+public class Col {
+    String field;
+    String title;
+
+    public Col() {
+    }
+
+    public Col(String field, String title) {
+        this.field = field;
+        this.title = title;
+    }
+
+    public String getField() {
+        return field;
+    }
+
+    public void setField(String field) {
+        this.field = field;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    public void setTitle(String title) {
+        this.title = title;
+    }
+
+    @Override
+    public String toString() {
+        return "{" +
+                "field:'" + field + '\'' +
+                ", title:'" + title + '\'' +
+                '}';
+    }
+}

+ 60 - 0
src/main/java/com/nokia/hb/pojo/RetData.java

@@ -0,0 +1,60 @@
+package com.nokia.hb.pojo;
+
+import java.util.List;
+import java.util.Map;
+
+public class RetData {
+    /**
+     * 错误信息
+     */
+    String msg;
+    List<Col> cols;
+    List<Map<String,String>> datas;
+
+    public RetData() {
+    }
+
+    public RetData(List<Col> cols, List<Map<String, String>> datas) {
+        this.cols = cols;
+        this.datas = datas;
+    }
+
+    public RetData(List<Col> cols, List<Map<String, String>> datas, String msg) {
+        this.cols = cols;
+        this.datas = datas;
+        this.msg = msg;
+    }
+
+    public List<Col> getCols() {
+        return cols;
+    }
+
+    public void setCols(List<Col> cols) {
+        this.cols = cols;
+    }
+
+    public List<Map<String, String>> getDatas() {
+        return datas;
+    }
+
+    public void setDatas(List<Map<String, String>> datas) {
+        this.datas = datas;
+    }
+
+    public String getMsg() {
+        return msg;
+    }
+
+    public void setMsg(String msg) {
+        this.msg = msg;
+    }
+
+    @Override
+    public String toString() {
+        return "RetData{" +
+                "msg='" + msg + '\'' +
+                ", cols=" + cols +
+                ", datas=" + datas +
+                '}';
+    }
+}

+ 74 - 0
src/main/java/com/nokia/hb/pojo/TreeNode.java

@@ -0,0 +1,74 @@
+package com.nokia.hb.pojo;
+
+import java.util.List;
+
+public class TreeNode {
+
+    String title = "";
+    String id = "";
+    boolean spread = false;
+    List<TreeNode> children = null;
+
+    public TreeNode() {
+    }
+
+    public TreeNode(String title, String id, List<TreeNode> children) {
+        this.title = title;
+        this.id = id;
+        this.children = children;
+    }
+
+    public TreeNode(String title, String id, boolean spread, List<TreeNode> children) {
+        this.title = title;
+        this.id = id;
+        this.spread = spread;
+        this.children = children;
+    }
+
+    public TreeNode(String title, String id) {
+        this.title = title;
+        this.id = id;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    public void setTitle(String title) {
+        this.title = title;
+    }
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public boolean isSpread() {
+        return spread;
+    }
+
+    public void setSpread(boolean spread) {
+        this.spread = spread;
+    }
+
+    public List<TreeNode> getChildren() {
+        return children;
+    }
+
+    public void setChildren(List<TreeNode> children) {
+        this.children = children;
+    }
+
+    @Override
+    public String toString() {
+        return "TreeNode{" +
+                "title='" + title + '\'' +
+                ", id='" + id + '\'' +
+                ", spread=" + spread +
+                ", children=" + children +
+                '}';
+    }
+}

+ 37 - 0
src/main/java/com/nokia/hb/service/DataViewService.java

@@ -0,0 +1,37 @@
+//package com.nokia.hb.Service;
+//
+//import com.nokia.hb.Dao.DataViewDao;
+//import org.springframework.stereotype.Service;
+//
+//import java.util.HashMap;
+//import java.util.List;
+//import java.util.Map;
+//
+//@Service
+//public class DataViewService {
+//    public DataViewDao dataViewDao = new DataViewDao();
+//
+//    public List<String> initProvince(String type) {
+//        return dataViewDao.initProvince(type);
+//    }
+//
+//    public List<String> initCitys(String type, String province) {
+//        return dataViewDao.initCitys(type, province);
+//    }
+//
+//    public String typeExport(String from, String provinces, String citys, String ttype, String t1, String t2) {
+//        return DataViewDao.typeExport(from, provinces, citys, ttype, t1, t2);
+//    }
+//
+//    public String exportAll(String ttype, String sts, String ets, String smts, String emts) {
+//        return DataViewDao.exportAll(ttype, sts, ets, smts, emts);
+//    }
+//
+//    public Map<String, List<Object>> search(String from, String t1, String t2, String stype, String ttype, String provinces, String citys) {
+//        return DataViewDao.search(from, t1, t2, stype, ttype, provinces, citys);
+//    }
+//
+//    public String exportClose(String ttype, String sts, String ets, String smts, String emts) {
+//        return DataViewDao.exportClose(ttype, sts, ets, smts, emts);
+//    }
+//}

+ 29 - 27
src/main/java/com/nokia/hb/utils/DbUtil.java

@@ -1,8 +1,8 @@
 package com.nokia.hb.utils;
 package com.nokia.hb.utils;
 
 
-import com.nokia.hb.Pojo.Col;
-import com.nokia.hb.Pojo.RetData;
-import com.nokia.hb.Pojo.TreeNode;
+import com.nokia.hb.pojo.Col;
+import com.nokia.hb.pojo.RetData;
+import com.nokia.hb.pojo.TreeNode;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
 import org.springframework.util.StringUtils;
 import org.springframework.util.StringUtils;
@@ -113,32 +113,35 @@ public class DbUtil {
     public static RetData renderTable(String citys, String quxians, String indicators, String ttype, String sdate,
     public static RetData renderTable(String citys, String quxians, String indicators, String ttype, String sdate,
                                       String condition, String searchType, HttpSession session) {
                                       String condition, String searchType, HttpSession session) {
         Map<String, String> ezMap = initZnEnMap();
         Map<String, String> ezMap = initZnEnMap();
-        // 获取城市数组
-        String[] cityArray = StringUtils.delete(citys, "'").split(",");
-        // 获取拥有的城市权限
-        Map<String, String> areas = (Map<String, String>) session.getAttribute("areas");
-        log.debug("{} areas: {}", areas.keySet().size(), areas.keySet());
-        log.debug("{} cityArray: {}", cityArray.length, Arrays.toString(cityArray));
-        // 地区权限校验
-        for (String t : cityArray) {
-            if (!areas.containsKey(t)) {
-                log.debug("没有权限的city: {}", t);
-                return new RetData(null, null, "没有" + t + "的权限");
-            }
-        }
-
         String[] timeArray = sdate.split(" - ");
         String[] timeArray = sdate.split(" - ");
         String startTime = timeArray[0];
         String startTime = timeArray[0];
         String endTime = timeArray[1];
         String endTime = timeArray[1];
-        String sql = "select a.cellname, a.city, a.quxian, a.vendor, b.*"
-                + " from (select eci, cellname, city, quxian, vendor from pm_parse.per_cfg_cell"
-                + " where city in (" + citys + ") and quxian in (" + quxians + ")) a"
-                + " inner join (select " + indicators + " from pm_parse.pm_4g_" + ttype
-                + " where sdate >= '" + startTime
-                + "' and sdate <= '" + endTime + "') b"
-                + " on a.eci = b.eci"
-                + " order by b.sdate desc";
-        // eci
+        String sql = null;
+        // 按地市查询
+        if ("area".equals(searchType)) {
+            // 获取城市数组
+            String[] cityArray = StringUtils.delete(citys, "'").split(",");
+            // 获取拥有的城市权限
+            Map<String, String> areas = (Map<String, String>) session.getAttribute("areas");
+            log.debug("{} areas: {}", areas.keySet().size(), areas.keySet());
+            log.debug("{} cityArray: {}", cityArray.length, Arrays.toString(cityArray));
+            // 地区权限校验
+            for (String t : cityArray) {
+                if (!areas.containsKey(t)) {
+                    log.debug("没有权限的city: {}", t);
+                    return new RetData(null, null, "没有" + t + "的权限");
+                }
+            }
+            sql = "select a.cellname, a.city, a.quxian, a.vendor, b.*"
+                    + " from (select eci, cellname, city, quxian, vendor from pm_parse.per_cfg_cell"
+                    + " where city in (" + citys + ") and quxian in (" + quxians + ")) a"
+                    + " inner join (select " + indicators + " from pm_parse.pm_4g_" + ttype
+                    + " where sdate >= '" + startTime
+                    + "' and sdate <= '" + endTime + "') b"
+                    + " on a.eci = b.eci"
+                    + " order by b.sdate desc";
+        }
+        // 按eci查询
         if ("eci".equals(searchType)) {
         if ("eci".equals(searchType)) {
             condition = "'" + condition.replace(",", "','") + "'";
             condition = "'" + condition.replace(",", "','") + "'";
             log.debug("condition: {}", condition);
             log.debug("condition: {}", condition);
@@ -152,7 +155,6 @@ public class DbUtil {
                     + " on a.eci = b.eci"
                     + " on a.eci = b.eci"
                     + " order by b.sdate desc";
                     + " order by b.sdate desc";
         }
         }
-
         log.debug("sql: {}", sql);
         log.debug("sql: {}", sql);
         List<Map<String, String>> datas = new ArrayList<>();
         List<Map<String, String>> datas = new ArrayList<>();
         List<Col> cols = new ArrayList<>();
         List<Col> cols = new ArrayList<>();

+ 2 - 0
src/main/resources/application.yml

@@ -17,3 +17,5 @@ spring:
 logging:
 logging:
   level:
   level:
     com.nokia.hb: debug
     com.nokia.hb: debug
+session:
+  timeout: 1800

+ 22 - 24
src/main/resources/templates/template.html

@@ -403,10 +403,6 @@
                 alert('填选择时间')
                 alert('填选择时间')
                 return;
                 return;
             }
             }
-            if (tree.getChecked('Id1').length === 0) {
-                alert('请选择地市')
-                return;
-            }
             if (tree.getChecked('Id3').length === 0) {
             if (tree.getChecked('Id3').length === 0) {
                 alert('请选择指标')
                 alert('请选择指标')
                 return;
                 return;
@@ -417,27 +413,29 @@
                 alert('请填写eci')
                 alert('请填写eci')
                 return;
                 return;
             }
             }
-            // console.log(`searchType: ${searchType}`)
-            console.log(`condition: ${condition}`)
-           alert('开始查询')
-            // layer.msg(JSON.stringify(data.field));
-            // console.log(JSON.stringify(tree.getChecked('Id1')))
-            let checkData1 = tree.getChecked('Id1')[0].children;
+            if (searchType === 'area' && tree.getChecked('Id1').length === 0) {
+                alert('请选择地市')
+                return;
+            }
+            alert('开始查询')
+            let checkData1 = tree?.getChecked('Id1')?.[0]?.children;
+            let quxians
+            let citys
+            if (checkData1) {
+                const quxianA = new Set();
+                const citysA = [];
+                checkData1.forEach(eee => {
+                    citysA.push("'" + eee.title + "'")
+                    eee.children.forEach(ee => {
+                        quxianA.add("'" + ee.title + "'")
+                    })
+                });
+                quxians = Array.from(quxianA).join(',')
+                citys = citysA.join(',')
+                console.log(`citys: ${citys}`)
+                console.log(`quxians: ${quxians}`)
+            }
             let checkData2 = tree.getChecked('Id3')[0].children;
             let checkData2 = tree.getChecked('Id3')[0].children;
-            console.log(checkData1)
-            console.log(checkData2)
-            const quxianA = new Set();
-            var citysA = [];
-            checkData1.forEach(eee => {
-                citysA.push("'" + eee.title + "'")
-                eee.children.forEach(ee => {
-                    quxianA.add("'" + ee.title + "'")
-                })
-            });
-            const quxians = Array.from(quxianA).join(',')
-            citys = citysA.join(',')
-            console.log(`citys: ${citys}`)
-            console.log(`quxians: ${quxians}`)
             const indicatorsA = new Set();
             const indicatorsA = new Set();
             checkData2.forEach(eee => {
             checkData2.forEach(eee => {
                 eee.children.forEach(ee => {
                 eee.children.forEach(ee => {