|
@@ -68,6 +68,7 @@ public class DbUtil {
|
|
|
String startTime = timeArray[0];
|
|
|
String endTime = timeArray[1];
|
|
|
String sql = "select a.cellname,a.city,a.quxian,a.vendor,b.* from \n(select eci,cellname,city,quxian,vendor from pm_parse.per_cfg_cell where " + searchType + " in (" + condition + ")) a\ninner join \n(select " + indicators + " from pm_parse.pm_4g_" + ttype + " where sdate>='" + startTime + "' and sdate <= '" + endTime + "') b\n" + "on a.eci=b.eci";
|
|
|
+ // 全网
|
|
|
if ("all".equals(searchType)) {
|
|
|
sql = "select a.cellname,a.city,a.quxian,a.vendor,b.* from pm_parse.per_cfg_cell a\ninner join \n(select " + indicators + " from pm_parse.pm_4g_" + ttype + " where sdate>='" + startTime + "' and sdate <= '" + endTime + "') b\n" + "on a.eci=b.eci";
|
|
|
}
|
|
@@ -115,13 +116,13 @@ public class DbUtil {
|
|
|
log.debug("ttype: {}", ttype);
|
|
|
log.debug("sdate: {}", sdate);
|
|
|
// 获取城市数组
|
|
|
- String[] cityArrays = StringUtils.delete(citys, "'").split(",");
|
|
|
+ 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("{} cityArrays: {}", cityArrays.length, Arrays.toString(cityArrays));
|
|
|
+ log.debug("{} cityArray: {}", cityArray.length, Arrays.toString(cityArray));
|
|
|
// 地区权限校验
|
|
|
- for (String t : cityArrays) {
|
|
|
+ for (String t : cityArray) {
|
|
|
if (!areas.containsKey(t)) {
|
|
|
log.debug("没有权限的city: {}", t);
|
|
|
return new RetData(null, null, "没有" + t + "的权限");
|
|
@@ -215,7 +216,7 @@ public class DbUtil {
|
|
|
List<TreeNode> res = new ArrayList<>();
|
|
|
allTree.setSpread(true);
|
|
|
res.add(allTree);
|
|
|
- log.debug("res: {}", res);
|
|
|
+ log.debug("initTreeCitys: {}", res);
|
|
|
return res;
|
|
|
}
|
|
|
|
|
@@ -233,8 +234,8 @@ public class DbUtil {
|
|
|
while (rs.next()) {
|
|
|
String indicator_type = rs.getString("indicator_type");
|
|
|
String indicator_cn = rs.getString("indicator_cn");
|
|
|
- String indicator_en = rs.getString("indicator_en");
|
|
|
- TreeNode t = new TreeNode(indicator_cn, indicator_en, null);
|
|
|
+ String indicator_id = rs.getString("indicator_id");
|
|
|
+ TreeNode t = new TreeNode(indicator_cn, indicator_id, null);
|
|
|
if (m.keySet().contains(indicator_type)) {
|
|
|
m.get(indicator_type).add(t);
|
|
|
} else {
|
|
@@ -254,6 +255,7 @@ public class DbUtil {
|
|
|
List<TreeNode> res = new ArrayList<>();
|
|
|
allTree.setSpread(true);
|
|
|
res.add(allTree);
|
|
|
+ log.debug("initTreeIndicator: {}", res);
|
|
|
return res;
|
|
|
}
|
|
|
|
|
@@ -311,47 +313,47 @@ public class DbUtil {
|
|
|
// return res;
|
|
|
// }
|
|
|
|
|
|
- public static HashMap<String, List<Object>> search(String from, String t1, String t2, String stype, String ttype, String provinces, String citys) {
|
|
|
- HashMap<String, List<Object>> res = new HashMap<>();
|
|
|
- PreparedStatement psmt = null;
|
|
|
- String pn = "province_name";
|
|
|
- String cn = "city_name";
|
|
|
- if ("roaming".equals(from)) {
|
|
|
- pn = "roaming_province_name";
|
|
|
- cn = "roaming_city_name";
|
|
|
- }
|
|
|
-// String sql = "select sdate,sum(user_count) from sqmdb_5g.user_terminal_status_5g_abstract where sdate between '20210720' and '20210727' and stype='5G终端用户数' and size_type='7天' and province_name in ('河北') and city_name in ('石家庄','唐山') group by sdate;";
|
|
|
- String sql = "select sdate as dt ,sum(user_count) as num from sqmdb_5g.user_terminal_status_5g_abstract where sdate between ? and ? and stype=? and size_type=? and " + pn + " in (" + provinces + ") and " + cn + " in (" + citys + ") group by sdate order by sdate;";
|
|
|
- if ("".equals(citys)) {
|
|
|
- sql = "select sdate as dt ,sum(user_count) as num from sqmdb_5g.user_terminal_status_5g_abstract where sdate between ? and ? and stype=? and size_type=? and " + pn + " in (" + provinces + ") group by sdate order by sdate;";
|
|
|
- }
|
|
|
-
|
|
|
- List<Object> dtList = new ArrayList<>();
|
|
|
- List<Object> numList = new ArrayList<>();
|
|
|
- try {
|
|
|
- psmt = conn.prepareStatement(sql);
|
|
|
-
|
|
|
- psmt.setQueryTimeout(60 * 10);
|
|
|
- psmt.setLong(1, Integer.valueOf(t1));
|
|
|
- psmt.setLong(2, Integer.valueOf(t2));
|
|
|
- psmt.setString(3, stype);
|
|
|
- psmt.setString(4, ttype + "天");
|
|
|
-// psmt.setString(5,provinces);
|
|
|
-// psmt.setString(6,citys);
|
|
|
- ResultSet rs = psmt.executeQuery();
|
|
|
- while (rs.next()) {
|
|
|
- String dt = rs.getString("dt");
|
|
|
- Long num = rs.getLong("num");
|
|
|
- dtList.add(dt);
|
|
|
- numList.add(num);
|
|
|
- }
|
|
|
- res.put("dt", dtList);
|
|
|
- res.put("num", numList);
|
|
|
- } catch (SQLException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- return res;
|
|
|
- }
|
|
|
+// public static HashMap<String, List<Object>> search(String from, String t1, String t2, String stype, String ttype, String provinces, String citys) {
|
|
|
+// HashMap<String, List<Object>> res = new HashMap<>();
|
|
|
+// PreparedStatement psmt = null;
|
|
|
+// String pn = "province_name";
|
|
|
+// String cn = "city_name";
|
|
|
+// if ("roaming".equals(from)) {
|
|
|
+// pn = "roaming_province_name";
|
|
|
+// cn = "roaming_city_name";
|
|
|
+// }
|
|
|
+//// String sql = "select sdate,sum(user_count) from sqmdb_5g.user_terminal_status_5g_abstract where sdate between '20210720' and '20210727' and stype='5G终端用户数' and size_type='7天' and province_name in ('河北') and city_name in ('石家庄','唐山') group by sdate;";
|
|
|
+// String sql = "select sdate as dt ,sum(user_count) as num from sqmdb_5g.user_terminal_status_5g_abstract where sdate between ? and ? and stype=? and size_type=? and " + pn + " in (" + provinces + ") and " + cn + " in (" + citys + ") group by sdate order by sdate;";
|
|
|
+// if ("".equals(citys)) {
|
|
|
+// sql = "select sdate as dt ,sum(user_count) as num from sqmdb_5g.user_terminal_status_5g_abstract where sdate between ? and ? and stype=? and size_type=? and " + pn + " in (" + provinces + ") group by sdate order by sdate;";
|
|
|
+// }
|
|
|
+//
|
|
|
+// List<Object> dtList = new ArrayList<>();
|
|
|
+// List<Object> numList = new ArrayList<>();
|
|
|
+// try {
|
|
|
+// psmt = conn.prepareStatement(sql);
|
|
|
+//
|
|
|
+// psmt.setQueryTimeout(60 * 10);
|
|
|
+// psmt.setLong(1, Integer.valueOf(t1));
|
|
|
+// psmt.setLong(2, Integer.valueOf(t2));
|
|
|
+// psmt.setString(3, stype);
|
|
|
+// psmt.setString(4, ttype + "天");
|
|
|
+//// psmt.setString(5,provinces);
|
|
|
+//// psmt.setString(6,citys);
|
|
|
+// ResultSet rs = psmt.executeQuery();
|
|
|
+// while (rs.next()) {
|
|
|
+// String dt = rs.getString("dt");
|
|
|
+// Long num = rs.getLong("num");
|
|
|
+// dtList.add(dt);
|
|
|
+// numList.add(num);
|
|
|
+// }
|
|
|
+// res.put("dt", dtList);
|
|
|
+// res.put("num", numList);
|
|
|
+// } catch (SQLException e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// }
|
|
|
+// return res;
|
|
|
+// }
|
|
|
|
|
|
// public static String typeExport(String from, String provinces, String citys, String ttype, String t1, String t2) {
|
|
|
// String res = "";
|
|
@@ -522,36 +524,36 @@ public class DbUtil {
|
|
|
// return res;
|
|
|
// }
|
|
|
|
|
|
- public static String rsprocess(ResultSet rs) {
|
|
|
- List<String> heads = new ArrayList<>();
|
|
|
- String headStr = "";
|
|
|
- StringBuffer sb = new StringBuffer();
|
|
|
- try {
|
|
|
- ResultSetMetaData rsmd = rs.getMetaData();
|
|
|
- for (int i = 1; i <= rsmd.getColumnCount(); i++) {
|
|
|
- String columnName = rsmd.getColumnName(i);
|
|
|
- heads.add(columnName);
|
|
|
- headStr += columnName + ",";
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- headStr = headStr.substring(0, headStr.length() - 1);
|
|
|
- sb.append(headStr + "\n");
|
|
|
- while (rs.next()) {
|
|
|
- String line = "";
|
|
|
- for (String head : heads) {
|
|
|
- line += rs.getString(head) + ",";
|
|
|
-
|
|
|
- }
|
|
|
- line = line.substring(0, line.length() - 1);
|
|
|
- sb.append(line + "\n");
|
|
|
- }
|
|
|
-
|
|
|
- } catch (SQLException throwables) {
|
|
|
- throwables.printStackTrace();
|
|
|
- }
|
|
|
- return sb.toString();
|
|
|
- }
|
|
|
+// public static String rsprocess(ResultSet rs) {
|
|
|
+// List<String> heads = new ArrayList<>();
|
|
|
+// String headStr = "";
|
|
|
+// StringBuffer sb = new StringBuffer();
|
|
|
+// try {
|
|
|
+// ResultSetMetaData rsmd = rs.getMetaData();
|
|
|
+// for (int i = 1; i <= rsmd.getColumnCount(); i++) {
|
|
|
+// String columnName = rsmd.getColumnName(i);
|
|
|
+// heads.add(columnName);
|
|
|
+// headStr += columnName + ",";
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// headStr = headStr.substring(0, headStr.length() - 1);
|
|
|
+// sb.append(headStr + "\n");
|
|
|
+// while (rs.next()) {
|
|
|
+// String line = "";
|
|
|
+// for (String head : heads) {
|
|
|
+// line += rs.getString(head) + ",";
|
|
|
+//
|
|
|
+// }
|
|
|
+// line = line.substring(0, line.length() - 1);
|
|
|
+// sb.append(line + "\n");
|
|
|
+// }
|
|
|
+//
|
|
|
+// } catch (SQLException throwables) {
|
|
|
+// throwables.printStackTrace();
|
|
|
+// }
|
|
|
+// return sb.toString();
|
|
|
+// }
|
|
|
|
|
|
public static Object userLogin(String username, String password, HttpSession session) {
|
|
|
// 计算密码md5
|
|
@@ -599,6 +601,126 @@ public class DbUtil {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public static Object addTemplate(String templateName, String indicators, HttpSession session) {
|
|
|
+ log.debug("templateName: {}", templateName);
|
|
|
+ log.debug("indicators: {}", indicators);
|
|
|
+ String username = (String) session.getAttribute("username");
|
|
|
+ long id = System.currentTimeMillis();
|
|
|
+ String sql = "insert into pm_parse.indicator_template (id, template_name, username) values (?, ?, ?)";
|
|
|
+ PreparedStatement psmt;
|
|
|
+ try {
|
|
|
+ conn.setAutoCommit(false);
|
|
|
+ psmt = conn.prepareStatement(sql);
|
|
|
+ psmt.setObject(1, id);
|
|
|
+ psmt.setObject(2, templateName);
|
|
|
+ psmt.setObject(3, username);
|
|
|
+ int rs = psmt.executeUpdate();
|
|
|
+ if (rs < 1) {
|
|
|
+ conn.rollback();
|
|
|
+ return "添加失败";
|
|
|
+ }
|
|
|
+
|
|
|
+ String[] indicatorArray = StringUtils.delete(indicators, "'").split(",");
|
|
|
+ sql = "insert into pm_parse.indicator_template_item (template_id, indicator_id) values (?, ?)";
|
|
|
+ psmt = conn.prepareStatement(sql);
|
|
|
+ for (String s : indicatorArray) {
|
|
|
+ psmt.setObject(1, id);
|
|
|
+ psmt.setObject(2, Integer.valueOf(s));
|
|
|
+ rs = psmt.executeUpdate();
|
|
|
+ if (rs < 1) {
|
|
|
+ conn.rollback();
|
|
|
+ return "添加失败";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ conn.commit();
|
|
|
+ } catch (SQLException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ try {
|
|
|
+ conn.rollback();
|
|
|
+ } catch (SQLException ex) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return "添加失败";
|
|
|
+ }
|
|
|
+ return "添加失败";
|
|
|
+ }
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static List<TreeNode> initTreeIndicatorTemplate(HttpSession session) {
|
|
|
+ // 查询用户指标模板
|
|
|
+ String username = (String) session.getAttribute("username");
|
|
|
+ String sql = "select id, template_name from pm_parse.indicator_template where username = ?";
|
|
|
+ PreparedStatement psmt = null;
|
|
|
+ TreeNode allTree = new TreeNode("指标模板选择", "指标模板选择", true, new ArrayList<>());
|
|
|
+ try {
|
|
|
+ psmt = conn.prepareStatement(sql);
|
|
|
+ psmt.setQueryTimeout(60 * 10);
|
|
|
+ psmt.setObject(1, username);
|
|
|
+ ResultSet rs = psmt.executeQuery();
|
|
|
+ while (rs.next()) {
|
|
|
+ String id = rs.getString("id");
|
|
|
+ String templateName = rs.getString("template_name");
|
|
|
+ TreeNode t = new TreeNode(templateName, id, new ArrayList<>());
|
|
|
+ allTree.getChildren().add(t);
|
|
|
+ // 查询模板下的指标
|
|
|
+ sql = "select x.indicator_cn, x.indicator_en from pm_parse.per_cfg_indicator x where x.indicator_id " +
|
|
|
+ "in (select indicator_id from pm_parse.indicator_template_item where template_id = ?)";
|
|
|
+ psmt = conn.prepareStatement(sql);
|
|
|
+ psmt.setQueryTimeout(60 * 10);
|
|
|
+ psmt.setObject(1, Long.valueOf(id));
|
|
|
+ ResultSet r = psmt.executeQuery();
|
|
|
+ while (r.next()) {
|
|
|
+ String indicatorCn = r.getString("indicator_cn");
|
|
|
+ String indicatorEn = r.getString("indicator_en");
|
|
|
+ t.getChildren().add(new TreeNode(indicatorCn, indicatorEn));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (SQLException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ List<TreeNode> res = new ArrayList<>();
|
|
|
+ res.add(allTree);
|
|
|
+ log.debug("initTreeIndicatorTemplate: {}", res);
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static Object deleteTemplate(String ids) {
|
|
|
+ log.debug("ids: {}", ids);
|
|
|
+ String sql = "delete from pm_parse.indicator_template where id in (" + ids + ")";
|
|
|
+ PreparedStatement psmt;
|
|
|
+ try {
|
|
|
+ conn.setAutoCommit(false);
|
|
|
+ psmt = conn.prepareStatement(sql);
|
|
|
+ int rs = psmt.executeUpdate();
|
|
|
+ if (rs < 1) {
|
|
|
+ conn.rollback();
|
|
|
+ return "删除失败";
|
|
|
+ }
|
|
|
+
|
|
|
+ sql = "delete from pm_parse.indicator_template_item where template_id in (" + ids + ")";
|
|
|
+ psmt = conn.prepareStatement(sql);
|
|
|
+ rs = psmt.executeUpdate();
|
|
|
+ if (rs < 1) {
|
|
|
+ conn.rollback();
|
|
|
+ return "删除失败";
|
|
|
+ }
|
|
|
+
|
|
|
+ conn.commit();
|
|
|
+ } catch (SQLException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ try {
|
|
|
+ conn.rollback();
|
|
|
+ } catch (SQLException ex) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return "删除失败";
|
|
|
+ }
|
|
|
+ return "删除失败";
|
|
|
+ }
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
|
|
|
// public static List<String> initCitys(String type, String province) {
|
|
|
// PreparedStatement psmt = null;
|