|
@@ -105,32 +105,33 @@ public class DbUtil {
|
|
|
}
|
|
|
|
|
|
|
|
|
- public static RetData renderTable(String citys, String indicators, String ttype, String sdate, HttpSession session) {
|
|
|
+ public static RetData renderTable(String citys, String quxians, String indicators, String ttype, String sdate, HttpSession session) {
|
|
|
log.debug("indicators: {}", indicators);
|
|
|
log.debug("citys: {}", citys);
|
|
|
- String[] idArray = StringUtils.delete(citys, "'").split(",");
|
|
|
+ log.debug("quxians: {}", quxians);
|
|
|
+ // 获取城市数组
|
|
|
+ String[] cityArrays = StringUtils.delete(citys, "'").split(",");
|
|
|
+ // 获取拥有的城市权限
|
|
|
Map<String, String> areas = (Map<String, String>) session.getAttribute("areas");
|
|
|
log.debug("{} areas: {}", areas.keySet().size(), areas.keySet());
|
|
|
- log.debug("{} idArray: {}", idArray.length, Arrays.toString(idArray));
|
|
|
+ log.debug("{} cityArrays: {}", cityArrays.length, Arrays.toString(cityArrays));
|
|
|
// 地区权限校验
|
|
|
- for (String t : idArray) {
|
|
|
+ for (String t : cityArrays) {
|
|
|
if (!areas.containsKey(t)) {
|
|
|
- log.debug("没有权限的地区编号: {}", t);
|
|
|
- return new RetData(null, null, 1);
|
|
|
+ log.debug("没有权限的city: {}", t);
|
|
|
+ return new RetData(null, null, "没有" + t + "的权限");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- citys = getQuxiansByIds(citys);
|
|
|
- log.debug("citys: {}", citys);
|
|
|
String sql = "select b.* from \n" +
|
|
|
- "(select eci from pm_parse.per_cfg_cell where quxian in (" + citys + ")) a\n" +
|
|
|
+ "(select eci from pm_parse.per_cfg_cell where quxian in (" + quxians + ")) a\n" +
|
|
|
"inner join \n" +
|
|
|
"(select eci," + indicators + " from pm_parse.pm_4g_" + ttype + " where sdate='" + sdate + "') b\n" +
|
|
|
"on a.eci=b.eci";
|
|
|
|
|
|
if(indicators.contains("eci")){
|
|
|
sql="select b.* from \n" +
|
|
|
- "(select eci from pm_parse.per_cfg_cell where quxian in (" + citys + ")) a\n" +
|
|
|
+ "(select eci from pm_parse.per_cfg_cell where quxian in (" + quxians + ")) a\n" +
|
|
|
"inner join \n" +
|
|
|
"(select " + indicators + " from pm_parse.pm_4g_" + ttype + " where sdate='" + sdate + "') b\n" +
|
|
|
"on a.eci=b.eci";
|
|
@@ -162,28 +163,7 @@ public class DbUtil {
|
|
|
} catch (SQLException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
- return new RetData(cols, datas, 0);
|
|
|
- }
|
|
|
-
|
|
|
- private static String getQuxiansByIds(String citys) {
|
|
|
- String sql = "select distinct quxian from pm_parse.per_cfg_area where id in (" + citys + ")";
|
|
|
- PreparedStatement psmt = null;
|
|
|
- try {
|
|
|
- psmt = conn.prepareStatement(sql);
|
|
|
- psmt.setQueryTimeout(60 * 10);
|
|
|
- ResultSet rs = psmt.executeQuery();
|
|
|
- StringBuilder sb = new StringBuilder();
|
|
|
- while (rs.next()) {
|
|
|
- String quxian = rs.getString("quxian");
|
|
|
- sb.append("'").append(quxian).append("'").append(",");
|
|
|
- }
|
|
|
-
|
|
|
- sb.deleteCharAt(sb.length() - 1);
|
|
|
- return sb.toString();
|
|
|
- } catch (SQLException e) {
|
|
|
- e.printStackTrace();
|
|
|
- return null;
|
|
|
- }
|
|
|
+ return new RetData(cols, datas);
|
|
|
}
|
|
|
|
|
|
public static List<TreeNode> initTreeCitys() {
|
|
@@ -198,9 +178,9 @@ public class DbUtil {
|
|
|
Map<String, List<TreeNode>> m = new HashMap<>();
|
|
|
|
|
|
while (rs.next()) {
|
|
|
- String id = rs.getString("id");
|
|
|
String city = rs.getString("city");
|
|
|
String quxian = rs.getString("quxian");
|
|
|
+ String id = city + quxian;
|
|
|
TreeNode t = new TreeNode(quxian, id, null);
|
|
|
if (m.keySet().contains(city)) {
|
|
|
m.get(city).add(t);
|
|
@@ -561,6 +541,7 @@ public class DbUtil {
|
|
|
}
|
|
|
|
|
|
public static Object userLogin(String username, String password, HttpSession session) {
|
|
|
+ // 计算密码md5
|
|
|
String passwordMd5 = DigestUtils.md5DigestAsHex(password.getBytes());
|
|
|
log.debug("username: {}, password: {}, passwordMd5: {}", username, password, passwordMd5);
|
|
|
// 查询用户信息
|
|
@@ -583,17 +564,18 @@ public class DbUtil {
|
|
|
}
|
|
|
|
|
|
// 查询地区权限
|
|
|
- sql = "select area_id from pm_parse.user_area where username='" + username +"'";
|
|
|
+ sql = "select area from pm_parse.user_area where username='" + username +"'";
|
|
|
psmt = conn.prepareStatement(sql);
|
|
|
psmt.setQueryTimeout(60 * 10);
|
|
|
rs = psmt.executeQuery();
|
|
|
Map<String, String> map = new HashMap<>();
|
|
|
while (rs.next()) {
|
|
|
- String id = rs.getString("area_id");
|
|
|
- map.put(id, "");
|
|
|
+ String area = rs.getString("area");
|
|
|
+ map.put(area, "");
|
|
|
}
|
|
|
|
|
|
log.debug("areas: {}", map.keySet());
|
|
|
+ // 保存session
|
|
|
session.setMaxInactiveInterval(30*60);
|
|
|
session.setAttribute("username", username);
|
|
|
session.setAttribute("areas", map);
|