Browse Source

Merge branch 'master' of http://nokia.tianhaikj.tk:13000/other/hb_nokia_pm_ui

wangrulan 2 năm trước cách đây
mục cha
commit
9bcbc8ecdb

+ 18 - 6
pom.xml

@@ -54,14 +54,12 @@
 		<dependency>
 			<groupId>org.postgresql</groupId>
 			<artifactId>postgresql</artifactId>
-			<version>42.3.5</version>
+			<scope>runtime</scope>
 		</dependency>
-		<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
 		<dependency>
 			<groupId>org.projectlombok</groupId>
 			<artifactId>lombok</artifactId>
-			<version>1.18.24</version>
-			<scope>provided</scope>
+			<optional>true</optional>
 		</dependency>
 		<!-- https://mvnrepository.com/artifact/com.alibaba/fastjson -->
 		<dependency>
@@ -91,14 +89,28 @@
 			<plugin>
 				<groupId>org.apache.maven.plugins</groupId>
 				<artifactId>maven-resources-plugin</artifactId>
-				<version>2.7</version>
+				<version>3.3.0</version>
 			</plugin>
 			<plugin>
 				<groupId>org.springframework.boot</groupId>
 				<artifactId>spring-boot-maven-plugin</artifactId>
-				<version>2.5.4</version>
+				<version>${project.parent.version}</version>
+				<executions>
+					<execution>
+						<id>repackage</id>
+						<goals>
+							<goal>repackage</goal>
+						</goals>
+					</execution>
+				</executions>
 				<configuration>
 					<fork>true</fork>
+					<excludes>
+						<exclude>
+							<groupId>org.projectlombok</groupId>
+							<artifactId>lombok</artifactId>
+						</exclude>
+					</excludes>
 				</configuration>
 			</plugin>
 		</plugins>

+ 15 - 14
src/main/java/com/nokia/hb/Controller/TemplateController.java

@@ -39,23 +39,24 @@ public class TemplateController {
 
     @PostMapping("renderTable")
     @ResponseBody
-    public RetData renderTable(String citys, String quxians, String indicators, String ttype, String sdate, HttpSession session) {
+    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,session);
+        return DbUtil.renderTable(citys,quxians,indicators,ttype,sdate,condition,searchType,session);
     }
     
-    @PostMapping({"conditionRenderTable"})
-    @ResponseBody
-    public RetData conditionRenderTable(String condition, String searchType, String indicators, String ttype, String sdate)
-    {
-      String[] split = condition.split("\n");
-      String c = "";
-      for (String s : split) {
-        c = c + "'" + s + "',";
-      }
-      c = c.substring(0, c.length() - 1);
-      return DbUtil.conditionRenderTable(c, searchType, indicators, ttype, sdate);
-    }
+//    @PostMapping({"conditionRenderTable"})
+//    @ResponseBody
+//    public RetData conditionRenderTable(String condition, String searchType, String indicators, String ttype, String sdate)
+//    {
+//      String[] split = condition.split("\n");
+//      String c = "";
+//      for (String s : split) {
+//        c = c + "'" + s + "',";
+//      }
+//      c = c.substring(0, c.length() - 1);
+//      return DbUtil.conditionRenderTable(c, searchType, indicators, ttype, sdate);
+//    }
 
     /**
      * 添加指标模板

+ 75 - 64
src/main/java/com/nokia/hb/utils/DbUtil.java

@@ -54,69 +54,65 @@ public class DbUtil {
         return m;
     }
 
-    public static RetData conditionRenderTable(String condition, String searchType, String indicators, String ttype,
-            String sdate) {
-        Map<String, String> ezMap = initZnEnMap();
-        String[] timeArray = sdate.split(" - ");
-        String startTime = timeArray[0];
-        String endTime = timeArray[1];
-        condition = condition.replace(",", "','");
-        log.debug("condition: {}", condition);
-        // eci
-        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 eci in (" + condition + ")) a"
-                + " inner join (select " + indicators + " from pm_parse.pm_4g_" + ttype
-                    + " where sdate >= '" + startTime
-                    + "' and sdate <= '" + endTime + "') b"
-                + " 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"
-                    + " inner join (select " + indicators + " from pm_parse.pm_4g_" + ttype
-                        + " where sdate >= '" + startTime
-                        + "' and sdate <= '" + endTime + "') b"
-                    + " on a.eci = b.eci";
-        }
-
-        log.debug("sql: {}", sql);
-        List<Map<String, String>> datas = new ArrayList<>();
-        List<Col> cols = new ArrayList<>();
-        try {
-            PreparedStatement psmt = null;
-            psmt = conn.prepareStatement(sql);
-            psmt.setQueryTimeout(600);
-            ResultSet rs = psmt.executeQuery();
-            ResultSetMetaData rsmd = rs.getMetaData();
-            List<String> heads = new ArrayList<>();
-            String columnName;
-            for (int i = 1; i <= rsmd.getColumnCount(); i++) {
-                columnName = rsmd.getColumnName(i);
-                heads.add(columnName);
-                cols.add(new Col(columnName, (String) ezMap.get(columnName)));
-            }
-            while (rs.next()) {
-                Map<String, String> m = new HashMap<>();
-                for (String head : heads) {
-                    String string = rs.getString(head);
-                    m.put(head, string);
-                }
-                datas.add(m);
-            }
-        } catch (SQLException e) {
-            e.printStackTrace();
-        }
-        return new RetData(cols, datas);
-    }
+//    public static RetData conditionRenderTable(String condition, String searchType, String indicators, String ttype,
+//            String sdate) {
+//        Map<String, String> ezMap = initZnEnMap();
+//        String[] timeArray = sdate.split(" - ");
+//        String startTime = timeArray[0];
+//        String endTime = timeArray[1];
+//        condition = condition.replace(",", "','");
+//        log.debug("condition: {}", condition);
+//        // eci
+//        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 eci in (" + condition + ")) a"
+//                + " inner join (select " + indicators + " from pm_parse.pm_4g_" + ttype
+//                    + " where sdate >= '" + startTime
+//                    + "' and sdate <= '" + endTime + "') b"
+//                + " 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"
+//                    + " inner join (select " + indicators + " from pm_parse.pm_4g_" + ttype
+//                        + " where sdate >= '" + startTime
+//                        + "' and sdate <= '" + endTime + "') b"
+//                    + " on a.eci = b.eci";
+//        }
+//
+//        log.debug("sql: {}", sql);
+//        List<Map<String, String>> datas = new ArrayList<>();
+//        List<Col> cols = new ArrayList<>();
+//        try {
+//            PreparedStatement psmt = null;
+//            psmt = conn.prepareStatement(sql);
+//            psmt.setQueryTimeout(600);
+//            ResultSet rs = psmt.executeQuery();
+//            ResultSetMetaData rsmd = rs.getMetaData();
+//            List<String> heads = new ArrayList<>();
+//            String columnName;
+//            for (int i = 1; i <= rsmd.getColumnCount(); i++) {
+//                columnName = rsmd.getColumnName(i);
+//                heads.add(columnName);
+//                cols.add(new Col(columnName, ezMap.get(columnName)));
+//            }
+//            while (rs.next()) {
+//                Map<String, String> m = new HashMap<>();
+//                for (String head : heads) {
+//                    String string = rs.getString(head);
+//                    m.put(head, string);
+//                }
+//                datas.add(m);
+//            }
+//        } catch (SQLException e) {
+//            e.printStackTrace();
+//        }
+//        return new RetData(cols, datas);
+//    }
 
     public static RetData renderTable(String citys, String quxians, String indicators, String ttype, String sdate,
-            HttpSession session) {
-        log.debug("indicators: {}", indicators);
-        log.debug("citys: {}", citys);
-        log.debug("quxians: {}", quxians);
-        log.debug("ttype: {}", ttype);
-        log.debug("sdate: {}", sdate);
+                                      String condition, String searchType, HttpSession session) {
+        Map<String, String> ezMap = initZnEnMap();
         // 获取城市数组
         String[] cityArray = StringUtils.delete(citys, "'").split(",");
         // 获取拥有的城市权限
@@ -134,12 +130,27 @@ public class DbUtil {
         String[] timeArray = sdate.split(" - ");
         String startTime = timeArray[0];
         String endTime = timeArray[1];
-
-        String sql = "select b.* from (select eci from pm_parse.per_cfg_cell where quxian in (" + quxians + ")) a"
+        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 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";
+        // eci
+        if ("eci".equals(searchType)) {
+            condition = "'" + condition.replace(",", "','") + "'";
+            log.debug("condition: {}", condition);
+            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 eci in (" + condition + ")) a"
+                    + " inner join (select " + indicators + " from pm_parse.pm_4g_" + ttype
+                    + " where sdate >= '" + startTime
+                    + "' and sdate <= '" + endTime + "') b"
+                    + " on a.eci = b.eci";
+        }
+
         log.debug("sql: {}", sql);
         List<Map<String, String>> datas = new ArrayList<>();
         List<Col> cols = new ArrayList<>();
@@ -154,7 +165,7 @@ public class DbUtil {
             for (int i = 1; i <= rsmd.getColumnCount(); i++) {
                 String columnName = rsmd.getColumnName(i);
                 heads.add(columnName);
-                cols.add(new Col(columnName, columnName));
+                cols.add(new Col(columnName, ezMap.get(columnName)));
             }
             while (rs.next()) {
                 Map<String, String> m = new HashMap<>();

+ 94 - 84
src/main/resources/templates/template.html

@@ -130,13 +130,13 @@
                 <div class="c1 label" style="margin-left: 120px;">时间:</div>
                 <input type="text" class="layui-input c1" style="width: 300px;" id="time1">
                 <button class="layui-btn btn c1" style="margin-left: 20px;" onclick="search()">查询</button>
-                <button class="layui-btn btn c1" style="margin-left: 20px;" onclick="conditionSearch()">条件查询</button>
+<!--                <button class="layui-btn btn c1" style="margin-left: 20px;" onclick="conditionSearch()">条件查询</button>-->
             </div>
         </br>
             <div style="width:100%;float: left;">
                 <div class="column" id="searchType" style="width:auto;float: left;">
                     <input type="radio" name="where" value="eci" title="按eci查询" lay-filter="where" checked>
-                    <input type="radio" name="where" value="all" title="全网选择" lay-filter="where">
+                    <input type="radio" name="where" value="area" title="按地市查询" lay-filter="where">
                 </div>
                 <div style="width:70%;float: left;">
                     <input id="condition" class="layui-input" placeholder="如多个eci查询请用英文逗号隔开"
@@ -286,7 +286,7 @@
             });
         }
 
-        function renderTable(table, citys, quxians, indicators, ttype, sdate) {
+        function renderTable(condition, searchType, table, citys, quxians, indicators, ttype, sdate) {
             console.log('renderTable')
             // var tishi = layer.load(2, { shade: [0.15, '#ccc'] });
             var tishi = layer.open({
@@ -301,6 +301,8 @@
                 async: false,
                 traditional: true,
                 data: {
+                    "condition": condition,
+                    "searchType": searchType,
                     "citys": citys,
                     "quxians": quxians,
                     "indicators": indicators,
@@ -347,50 +349,50 @@
             });
         }
 
-        function conditionRenderTable(table, condition, searchType, indicators, ttype, sdate) {
-            console.log('conditionRenderTable')
-            $.ajax({
-                type: "POST",
-                url: './conditionRenderTable',
-                async: false,
-                data: {
-                    "condition": condition,
-                    "searchType": searchType,
-                    "indicators": indicators,
-                    "ttype": ttype,
-                    "sdate": sdate
-                },
-                success: function (r) {
-                    dataA = r;
-                    // console.log(r)
-                    let o = r instanceof Object
-                    if (!o) {
-                        r = JSON.parse(r)
-                    }
-                    table.render({
-                        elem: '#demo',
-                        height: 320,
-                        // url: 'https://www.layui.com/demo/table/user/' , //数据接口
-                        page: true, //开启分页
-                        toolbar: true,
-                        defaultToolbar: [{
-                            title: '提示' //标题
-                            ,
-                            layEvent: 'export' //事件名,用于 toolbar 事件中使用
-                            ,
-                            icon: 'layui-icon-export' //图标类名
-                        }],
-                        limit: 50,
-                        limits: [50, 200, 500],
-                        cols: [
-                            r.cols
-                        ],
-                        data: r.datas
-                    });
-                    return false;
-                }
-            });
-        }
+        // function conditionRenderTable(table, condition, searchType, indicators, ttype, sdate) {
+        //     console.log('conditionRenderTable')
+        //     $.ajax({
+        //         type: "POST",
+        //         url: './conditionRenderTable',
+        //         async: false,
+        //         data: {
+        //             "condition": condition,
+        //             "searchType": searchType,
+        //             "indicators": indicators,
+        //             "ttype": ttype,
+        //             "sdate": sdate
+        //         },
+        //         success: function (r) {
+        //             dataA = r;
+        //             // console.log(r)
+        //             let o = r instanceof Object
+        //             if (!o) {
+        //                 r = JSON.parse(r)
+        //             }
+        //             table.render({
+        //                 elem: '#demo',
+        //                 height: 320,
+        //                 // url: 'https://www.layui.com/demo/table/user/' , //数据接口
+        //                 page: true, //开启分页
+        //                 toolbar: true,
+        //                 defaultToolbar: [{
+        //                     title: '提示' //标题
+        //                     ,
+        //                     layEvent: 'export' //事件名,用于 toolbar 事件中使用
+        //                     ,
+        //                     icon: 'layui-icon-export' //图标类名
+        //                 }],
+        //                 limit: 50,
+        //                 limits: [50, 200, 500],
+        //                 cols: [
+        //                     r.cols
+        //                 ],
+        //                 data: r.datas
+        //             });
+        //             return false;
+        //         }
+        //     });
+        // }
 
         function search() {
             // form.on('submit(formDemo)', function (data) {
@@ -406,6 +408,14 @@
                 alert('请选择指标')
                 return;
             }
+            let condition = $('#condition').val();
+            let searchType = $('#searchType').find('input:checked').val()
+            if (searchType === 'eci' && $('#condition').val().length === 0) {
+                alert('请填写eci')
+                return;
+            }
+            console.log(`searchType: ${searchType}`)
+            console.log(`condition: ${condition}`)
            alert('开始查询')
             // layer.msg(JSON.stringify(data.field));
             console.log(JSON.stringify(tree.getChecked('Id1')))
@@ -437,46 +447,46 @@
             let ttype = $('#timeType').val()
             let sdate = $('#time1').val()
             console.log(`sdate: ${sdate}`)
-            renderTable(table, citys, quxians,indicators, ttype, sdate)
+            renderTable(condition, searchType, table, citys, quxians,indicators, ttype, sdate)
             return false;
         }
 
-        function conditionSearch() {
-            let sdate = $('#time1').val()
-            if (sdate.length === 0) {
-                alert('请选择时间')
-                return;
-            }
-
-            if (tree.getChecked('Id3').length == 0) {
-                alert('请选择指标')
-                return;
-            }
-            let condition = $('#condition').val();
-            let ttype = $('#timeType').val()
-            let searchType = $('#searchType').find('input:checked').val()
-            if (searchType === 'eci' && $('#condition').val().length === 0) {
-                alert('请填写查询条件')
-                return;
-            }
-            console.log(`searchType: ${searchType}`)
-            console.log(`condition: ${condition}`)
-            // layer.msg(JSON.stringify(data.field));
-            // let checkData1 = tree.getChecked('Id1')[0].children;
-            let checkData2 = tree.getChecked('Id3')[0].children;
-            const indicatorsA = new Set();
-            checkData2.forEach(eee => {
-                eee.children.forEach(ee => {
-                    indicatorsA.add(ee.id)
-                })
-            });
-            indicatorsA.add('eci')
-            const indicatorsB = [...indicatorsA]
-            const indicators = indicatorsB.join(',')
-            console.log(`indicators: ${indicators}`)
-            conditionRenderTable(table, condition, searchType, indicators, ttype, sdate)
-            return false;
-        }
+        // function conditionSearch() {
+        //     let sdate = $('#time1').val()
+        //     if (sdate.length === 0) {
+        //         alert('请选择时间')
+        //         return;
+        //     }
+        //
+        //     if (tree.getChecked('Id3').length == 0) {
+        //         alert('请选择指标')
+        //         return;
+        //     }
+        //     let condition = $('#condition').val();
+        //     let ttype = $('#timeType').val()
+        //     let searchType = $('#searchType').find('input:checked').val()
+        //     if (searchType === 'eci' && $('#condition').val().length === 0) {
+        //         alert('请填写查询条件')
+        //         return;
+        //     }
+        //     console.log(`searchType: ${searchType}`)
+        //     console.log(`condition: ${condition}`)
+        //     // layer.msg(JSON.stringify(data.field));
+        //     // let checkData1 = tree.getChecked('Id1')[0].children;
+        //     let checkData2 = tree.getChecked('Id3')[0].children;
+        //     const indicatorsA = new Set();
+        //     checkData2.forEach(eee => {
+        //         eee.children.forEach(ee => {
+        //             indicatorsA.add(ee.id)
+        //         })
+        //     });
+        //     indicatorsA.add('eci')
+        //     const indicatorsB = [...indicatorsA]
+        //     const indicators = indicatorsB.join(',')
+        //     console.log(`indicators: ${indicators}`)
+        //     conditionRenderTable(table, condition, searchType, indicators, ttype, sdate)
+        //     return false;
+        // }
 
         // 添加指标模板
         function addTemplate() {