Explorar el Código

完成网站点评所有数据展示,
完成智能问答PC端和移动端的切换

hyx hace 3 años
padre
commit
921407c053

+ 5 - 0
nngkxxdp/src/main/resources/static/intelligence/intelligence.html

@@ -640,6 +640,11 @@
 <script src="../zdjc/js/constans.js"></script>
 <!--南岸区人民政府网站有,只是暂时存放,待以后拿到数据再说 -->
 <script>
+    // PC端 移动端 跳转
+    var is_mobi = navigator.userAgent.toLowerCase().match(/(ipod|iphone|android|coolpad|mmp|smartphone|midp|wap|xoom|symbian|j2me|blackberry|wince)/i) != null;
+    if (is_mobi) {
+        window.location.href = "mobile_intelligence.html";
+    }
     var loginURL = "https://auth.cq.gov.cn:81/sso/login?utype=0&client_id=I34U4QF4D&goto=";
     var registerURL = "https://auth.cq.gov.cn:81/sso/login?utype=0&client_id=I34U4QF4D&goto=";
     var curURL = window.location.href;

+ 6 - 0
nngkxxdp/src/main/resources/static/intelligence/mobile_intelligence.html

@@ -36,6 +36,12 @@
 <script src="js/jquery-3.5.1.min.js"></script>
 <script src="../zdjc/js/constans.js"></script>
 <script>
+    // PC端 移动端 跳转
+    var is_mobi = navigator.userAgent.toLowerCase().match(/(ipod|iphone|android|coolpad|mmp|smartphone|midp|wap|xoom|symbian|j2me|blackberry|wince)/i) != null;
+    if (!is_mobi) {
+        window.location.href="intelligence.html"
+    }
+
     // 聊天消息固定在底部
     var otherHeight = $('.head_tab').outerHeight() + $('.wrap_hot_QA').outerHeight() + $('.btn_send').outerHeight()
     var listHeight = window.outerHeight - otherHeight - 18

+ 293 - 61
nngkxxdp/src/main/resources/static/wzkp/wzkp.html

@@ -50,10 +50,10 @@
                                                     <p class="wrap_text">公安</p>
                                                     <img src="img/pm_g.png" alt="" class="img_g">
                                                 </div>
-                                                <div class="descript_box">
-                                                    <h1>区公安分局</h1>
-                                                    <p class="descript_totall">总分&nbsp;<span>98.03</span></p>
-                                                    <div class="fs">基础分<p>95</p><span>+</span>加分<p>3分</p></div>
+                                                <div id="bestRanking1" class="descript_box">
+                                                    <h1></h1>
+                                                    <p class="descript_totall">总分&nbsp;<span></span></p>
+                                                    <div class="fs">基础分<p></p><span>+</span>加分<p></p></div>
                                                 </div>
                                             </li>
                                             <li>
@@ -61,10 +61,10 @@
                                                     <p class="wrap_text">文旅</p>
                                                     <img src="img/pm_y.png" alt="" class="img_g">
                                                 </div>
-                                                <div class="descript_box">
-                                                    <h1>区文化旅游委</h1>
-                                                    <p class="descript_totall">总分&nbsp;<span>96.77</span></p>
-                                                    <div class="fs">基础分<p>95</p><span>+</span>加分<p>3分</p></div>
+                                                <div id="bestRanking2" class="descript_box">
+                                                    <h1></h1>
+                                                    <p class="descript_totall">总分&nbsp;<span></span></p>
+                                                    <div class="fs">基础分<p></p><span>+</span>加分<p></p></div>
                                                 </div>
                                             </li>
                                             <li>
@@ -72,10 +72,10 @@
                                                     <p class="wrap_text">社保</p>
                                                     <img src="img/pm_j.png" alt="" class="img_g">
                                                 </div>
-                                                <div class="descript_box">
-                                                    <h1>区人力社保局</h1>
-                                                    <p class="descript_totall">总分&nbsp;<span>90.36</span></p>
-                                                    <div class="fs">基础分<p>95</p><span>+</span>加分<p>3分</p></div>
+                                                <div id="bestRanking3" class="descript_box">
+                                                    <h1></h1>
+                                                    <p class="descript_totall">总分&nbsp;<span></span></p>
+                                                    <div class="fs">基础分<p></p><span>+</span>加分<p></p></div>
                                                 </div>
                                             </li>
                                         </ul>
@@ -93,30 +93,30 @@
                                                 <div class="img_wrap">
                                                     <p class="wrap_text_cover">公安</p>
                                                 </div>
-                                                <div class="descript_box">
-                                                    <h1>区公安分局</h1>
-                                                    <p class="descript_totall">总分&nbsp;<span>98.03</span></p>
-                                                    <div class="fs">基础分<p>95</p><span>+</span>加分<p>3分</p></div>
+                                                <div id="lowestRanking1" class="descript_box">
+                                                    <h1></h1>
+                                                    <p class="descript_totall">总分&nbsp;<span></span></p>
+                                                    <div class="fs">基础分<p></p><span>+</span>加分<p></p></div>
                                                 </div>
                                             </li>
                                             <li>
                                                 <div class="img_wrap">
                                                     <p class="wrap_text_cover">文旅</p>
                                                 </div>
-                                                <div class="descript_box">
-                                                    <h1>区文化旅游委</h1>
-                                                    <p class="descript_totall">总分&nbsp;<span>96.77</span></p>
-                                                    <div class="fs">基础分<p>95</p><span>+</span>加分<p>3分</p></div>
+                                                <div id="lowestRanking2" class="descript_box">
+                                                    <h1></h1>
+                                                    <p class="descript_totall">总分&nbsp;<span></span></p>
+                                                    <div class="fs">基础分<p></p><span>+</span>加分<p></p></div>
                                                 </div>
                                             </li>
                                             <li>
                                                 <div class="img_wrap">
                                                     <p class="wrap_text_cover">社保</p>
                                                 </div>
-                                                <div class="descript_box">
-                                                    <h1>区人力社保局</h1>
-                                                    <p class="descript_totall">总分&nbsp;<span>90.36</span></p>
-                                                    <div class="fs">基础分<p>95</p><span>+</span>加分<p>3分</p></div>
+                                                <div id="lowestRanking3" class="descript_box">
+                                                    <h1></h1>
+                                                    <p class="descript_totall">总分&nbsp;<span></span></p>
+                                                    <div class="fs">基础分<p></p><span>+</span>加分<p></p></div>
                                                 </div>
                                             </li>
                                         </ul>
@@ -135,7 +135,7 @@
                                                     <p class="wrap_text">公安</p>
                                                     <img src="img/jb_zd.png" alt="" class="img_jb">
                                                 </div>
-                                                <div class="descript_box">
+                                                <div id="greatestProgress1" class="descript_box">
                                                     <h1>区公安分局</h1>
                                                     <div class="up_green">较上月上升5名<img src="img/up.png" alt=""
                                                                                       class="up_img"></div>
@@ -148,7 +148,7 @@
                                                     <p class="wrap_text">文旅</p>
                                                     <img src="img/jb_zd.png" alt="" class="img_jb">
                                                 </div>
-                                                <div class="descript_box">
+                                                <div id="greatestProgress2" class="descript_box">
                                                     <h1>区文化旅游委</h1>
                                                     <div class="up_green">较上月上升5名<img src="img/up.png" alt=""
                                                                                       class="up_img"></div>
@@ -161,7 +161,7 @@
                                                     <p class="wrap_text">社保</p>
                                                     <img src="img/jb_zd.png" alt="" class="img_jb">
                                                 </div>
-                                                <div class="descript_box">
+                                                <div id="greatestProgress3" class="descript_box">
                                                     <h1>区人力社保局</h1>
                                                     <div class="up_green">较上月上升5名<img src="img/up.png" alt=""
                                                                                       class="up_img"></div>
@@ -184,7 +184,7 @@
                                                 <div class="img_wrap">
                                                     <p class="wrap_text_cover">公安</p>
                                                 </div>
-                                                <div class="descript_box">
+                                                <div id="regressiveMaximum1" class="descript_box">
                                                     <h1>区公安分局</h1>
                                                     <div class="up_green">较上月退步5名<img src="img/down.png" alt=""
                                                                                       class="up_img"></div>
@@ -196,7 +196,7 @@
                                                 <div class="img_wrap">
                                                     <p class="wrap_text_cover">文旅</p>
                                                 </div>
-                                                <div class="descript_box">
+                                                <div id="regressiveMaximum2" class="descript_box">
                                                     <h1>区文化旅游委</h1>
                                                     <div class="up_green">较上月退步5名<img src="img/down.png" alt=""
                                                                                       class="up_img"></div>
@@ -208,7 +208,7 @@
                                                 <div class="img_wrap">
                                                     <p class="wrap_text_cover">社保</p>
                                                 </div>
-                                                <div class="descript_box">
+                                                <div id="regressiveMaximum3" class="descript_box">
                                                     <h1>区人力社保局</h1>
                                                     <div class="up_green">较上月退步5名<img src="img/down.png" alt=""
                                                                                       class="up_img"></div>
@@ -240,31 +240,31 @@
                                             <th>基础分加分</th>
                                         </tr>
                                         </thead>
-                                        <tbody>
+                                        <tbody id="rankingTbody">
                                         <tr>
-                                            <td>区交通局</td>
-                                            <td>98(95/3)</td>
+                                            <td></td>
+                                            <td></td>
                                             <td>1</td>
                                             <td>
-                                                <img src="img/down.png" alt="" class="img_tr">16
+
                                             </td>
                                             <td></td>
                                         </tr>
                                         <tr>
-                                            <td>区财政局</td>
-                                            <td>98(95/3)</td>
+                                            <td></td>
+                                            <td></td>
                                             <td>2</td>
                                             <td>
-                                                <img src="img/up.png" alt="" class="img_tr">16
+
                                             </td>
                                             <td></td>
                                         </tr>
                                         <tr>
-                                            <td>区交通局</td>
-                                            <td>98(95/3)</td>
+                                            <td></td>
+                                            <td></td>
                                             <td>3</td>
                                             <td>
-                                                <img src="img/up.png" alt="" class="img_tr">16
+
                                             </td>
                                             <td></td>
                                         </tr>
@@ -378,11 +378,26 @@
 <script src="../zdjc/js/constans.js"></script>
 <script>
     $(function () {
+        let month = getMonth();
         let type = 0;
-        let childrenType = $("#monInput").val();
+        let childrenType = (new Date).getMonth() + 1;
         let deptId = $("[name='department']").val();
         let hasDept = 1;
-        let newMon = '';
+        let newMon = (new Date).getFullYear() + "-" + month;
+        loadData(type, childrenType, deptId, hasDept, newMon);
+    });
+
+    //获取当前月份
+    function getMonth() {
+        let date = new Date();
+        let month = date.getMonth() + 1;
+        if (month < 10) {
+            month = "0" + month;
+        }
+        return month;
+    }
+
+    function loadData(type, childrenType, deptId, hasDept, newMon) {
         $.ajax({
             url: PATH + '/tj/websiteRating',
             data: {
@@ -394,16 +409,72 @@
             },
             type: "post",
             success: function (data) {
-                console.log(data.data);
+                let dataList = [];
+                let lastDataList = [];
+                for (let i = 0; i < data.data.deptids.length; i++) {
+                    let dataD = {};
+                    dataD.department = data.data.yData[i];
+                    dataD.basicScore = data.data.basic[i];
+                    dataD.addScore = data.data.add[i];
+                    dataD.deptid = data.data.deptids[i];
+                    dataList.push(dataD);
+                }
+                for (let i = 0; i < data.data.lastMonth.deptids.length; i++) {
+                    let dataD = {};
+                    dataD.department = data.data.lastMonth.yData[i];
+                    dataD.basicScore = data.data.lastMonth.basic[i];
+                    dataD.addScore = data.data.lastMonth.add[i];
+                    dataD.deptid = data.data.lastMonth.deptids[i];
+                    lastDataList.push(dataD);
+                }
+                //对数据排名进行排序,使用快速排序
+                listSort(dataList);
+                listSort(lastDataList);
+
+                let newDataList = [];
+                let dlLength = dataList.length;
+                for (let i = 0; i < dlLength; i++) {
+                    newDataList.push(dataList[dlLength - 1 - i]);
+                    newDataList[i].totalScore = (newDataList[i].basicScore + newDataList[i].addScore) + '(' + newDataList[i].basicScore + '/' + newDataList[i].addScore + ')';
+                    for (let j = 0; j < lastDataList.length; j++) {
+                        if (newDataList[i].deptid == lastDataList[j].deptid) {
+                            newDataList[i].rankingLast = j - i;
+                        }
+                    }
+                }
+
+                //生成本月排名最优3位
+                bestRanking(newDataList);
+                let lowestRankingList = [];
+                lowestRankingList.push(dataList[0]);
+                lowestRankingList.push(dataList[1]);
+                lowestRankingList.push(dataList[2]);
+                //生成本月排名最末3位
+                lowestRanking(lowestRankingList);
+
+                //对数据进步进行排序
+                progressSort(newDataList);
+                //排名进步最大3位
+                let greatestProgressList = [];
+                greatestProgressList.push(newDataList[newDataList.length - 1]);
+                greatestProgressList.push(newDataList[newDataList.length - 2]);
+                greatestProgressList.push(newDataList[newDataList.length - 3]);
+                greatestProgress(greatestProgressList);
+                //排名退步最大3位
+                let regressiveMaximumList = [];
+                regressiveMaximumList.push(newDataList[0]);
+                regressiveMaximumList.push(newDataList[1]);
+                regressiveMaximumList.push(newDataList[2]);
+                regressiveMaximum(regressiveMaximumList);
                 //生成排名表格
-                rankingDetails();
+                rankingDetails(newDataList);
                 //生成相应的部门
                 generationDepartment(data.data);
                 //生成折线图
                 lineChart(data.data['detail-data'], data.data['detail-x']);
             }
         })
-    });
+    }
 
     layui.use(['laydate', 'form', 'element', 'table'], function () {
 
@@ -419,32 +490,161 @@
 
         //监听下拉选择框
         form.on('select(department_filter)', function (data) {
-            console.log(data);
+            selectDepartment(data.value);
         });
 
         laydate.render({
             elem: '#monInput',
             type: 'month',
             value: new Date(),
+            done: function (value, date, endDate) {
+                dateDone(value);
+            }
         });
     });
 
-    var tableIns = layui.table.render({
-        elem: '#demo'
-        , height: 312
-        , page: true //开启分页
-        , cols: [[ //表头
-            {type: numbers, title: '排名', width: 80, sort: true, fixed: 'left'}
-            , {field: 'username', title: '部门', width: 80}
-            , {field: 'sex', title: '总分(基础分/加分)', width: 80, sort: true}
-            , {field: 'city', title: '环比上月排名', width: 80}
-            , {field: 'sign', title: '基础分加分', width: 177}
-        ]]
-    });
+    //快速排序集合
+    function listSort(array, lo = 0, hi = array.length) {
+        if (hi - lo < 2) return
+        const p = partition(array, lo, hi);//寻找中心点位置
+        listSort(array, lo, p);//左边排序
+        listSort(array, p + 1, hi);//右边排序
+    }
+
+    function partition(array, lo, hi) {
+        const pivot = array[hi - 1].basicScore + array[hi - 1].addScore;
+        let i = lo, j = hi - 1;
+        while (i != j) {
+            (array[i].basicScore + array[i].addScore) < pivot ? i++ : exchange(array, i, --j)
+        }
+        exchange(array, j, hi - 1)
+        return j;
+    }
+
+    //快速排序
+    function progressSort(array, lo = 0, hi = array.length) {
+        if (hi - lo < 2) return
+        const p = partition1(array, lo, hi);//寻找中心点位置
+        progressSort(array, lo, p);//左边排序
+        progressSort(array, p + 1, hi);//右边排序
+    }
+
+    function partition1(array, lo, hi) {
+        const pivot = array[hi - 1].rankingLast;
+        let i = lo, j = hi - 1;
+        while (i != j) {
+            array[i].rankingLast < pivot ? i++ : exchange(array, i, --j)
+        }
+        exchange(array, j, hi - 1)
+        return j;
+    }
+
+    //定义交换方法
+    function exchange(array, lo, hi) {
+        [array[lo], array[hi]] = [array[hi], array[lo]]
+    }
+
+    //生成本月排名最优3位
+    function bestRanking(obj) {
+        $("#bestRanking1").children("h1").text(obj[0].department);
+        $("#bestRanking1").children("p").children("span").text(obj[0].basicScore + obj[0].addScore);
+        $("#bestRanking1").children("div").children("p").eq(0).text(obj[0].basicScore);
+        $("#bestRanking1").children("div").children("p").eq(1).text(obj[0].addScore);
+
+        $("#bestRanking2").children("h1").text(obj[1].department);
+        $("#bestRanking2").children("p").children("span").text(obj[1].basicScore + obj[1].addScore);
+        $("#bestRanking2").children("div").children("p").eq(0).text(obj[1].basicScore);
+        $("#bestRanking2").children("div").children("p").eq(1).text(obj[1].addScore);
+
+        $("#bestRanking3").children("h1").text(obj[2].department);
+        $("#bestRanking3").children("p").children("span").text(obj[2].basicScore + obj[2].addScore);
+        $("#bestRanking3").children("div").children("p").eq(0).text(obj[2].basicScore);
+        $("#bestRanking3").children("div").children("p").eq(1).text(obj[2].addScore);
+    }
+
+    //生成本月排名最末3位
+    function lowestRanking(obj) {
+        $("#lowestRanking1").children("h1").text(obj[0].department);
+        $("#lowestRanking1").children("p").children("span").text(obj[0].basicScore + obj[0].addScore);
+        $("#lowestRanking1").children("div").children("p").eq(0).text(obj[0].basicScore);
+        $("#lowestRanking1").children("div").children("p").eq(1).text(obj[0].addScore);
+
+        $("#lowestRanking2").children("h1").text(obj[1].department);
+        $("#lowestRanking2").children("p").children("span").text(obj[1].basicScore + obj[1].addScore);
+        $("#lowestRanking2").children("div").children("p").eq(0).text(obj[1].basicScore);
+        $("#lowestRanking2").children("div").children("p").eq(1).text(obj[1].addScore);
+
+        $("#lowestRanking3").children("h1").text(obj[2].department);
+        $("#lowestRanking3").children("p").children("span").text(obj[2].basicScore + obj[2].addScore);
+        $("#lowestRanking3").children("div").children("p").eq(0).text(obj[2].basicScore);
+        $("#lowestRanking3").children("div").children("p").eq(1).text(obj[2].addScore);
+    }
+
+    //排名进步最大3位
+    function greatestProgress(obj) {
+        $("#greatestProgress1").children("h1").text(obj[0].department);
+        $("#greatestProgress1").children("p").children("span").text(obj[0].basicScore + obj[0].addScore);
+        $("#greatestProgress1").children("div").children("p").eq(0).text(obj[0].basicScore);
+        $("#greatestProgress1").children("div").children("p").eq(1).text(obj[0].addScore);
+
+        $("#greatestProgress2").children("h1").text(obj[1].department);
+        $("#greatestProgress2").children("p").children("span").text(obj[1].basicScore + obj[1].addScore);
+        $("#greatestProgress2").children("div").children("p").eq(0).text(obj[1].basicScore);
+        $("#greatestProgress2").children("div").children("p").eq(1).text(obj[1].addScore);
+
+        $("#greatestProgress3").children("h1").text(obj[2].department);
+        $("#greatestProgress3").children("p").children("span").text(obj[2].basicScore + obj[2].addScore);
+        $("#greatestProgress3").children("div").children("p").eq(0).text(obj[2].basicScore);
+        $("#greatestProgress3").children("div").children("p").eq(1).text(obj[2].addScore);
+    }
+
+    //排名退步最大3位
+    function regressiveMaximum(obj) {
+        $("#regressiveMaximum1").children("h1").text(obj[0].department);
+        $("#regressiveMaximum1").children("p").children("span").text(obj[0].basicScore + obj[0].addScore);
+        $("#regressiveMaximum1").children("div").children("p").eq(0).text(obj[0].basicScore);
+        $("#regressiveMaximum1").children("div").children("p").eq(1).text(obj[0].addScore);
+
+        $("#regressiveMaximum2").children("h1").text(obj[1].department);
+        $("#regressiveMaximum2").children("p").children("span").text(obj[1].basicScore + obj[1].addScore);
+        $("#regressiveMaximum2").children("div").children("p").eq(0).text(obj[1].basicScore);
+        $("#regressiveMaximum2").children("div").children("p").eq(1).text(obj[1].addScore);
+
+        $("#regressiveMaximum3").children("h1").text(obj[2].department);
+        $("#regressiveMaximum3").children("p").children("span").text(obj[2].basicScore + obj[2].addScore);
+        $("#regressiveMaximum3").children("div").children("p").eq(0).text(obj[2].basicScore);
+        $("#regressiveMaximum3").children("div").children("p").eq(1).text(obj[2].addScore);
+    }
+
+    //生成排名表格
+    function rankingDetails(dataList) {
+        $("#rankingTbody").children("tr").eq(0).children("td").eq(0).html(dataList[dataList.length - 1].department);
+        $("#rankingTbody").children("tr").eq(0).children("td").eq(1).html(dataList[dataList.length - 1].totalScore);
+        if (dataList[dataList.length - 1].rankingLast >= 0) {
+            $("#rankingTbody").children("tr").eq(0).children("td").eq(3).html('<img src="img/up.png" alt="" class="img_tr">' + dataList[dataList.length - 1].rankingLast);
+        } else {
+            $("#rankingTbody").children("tr").eq(0).children("td").eq(3).html('<img src="img/down.png" alt="" class="img_tr">' + dataList[dataList.length - 1].rankingLast);
+        }
+        $("#rankingTbody").children("tr").eq(0).children("td").eq(4).html(dataList[dataList.length - 2].addScore);
+
+        $("#rankingTbody").children("tr").eq(1).children("td").eq(0).html(dataList[dataList.length - 2].department);
+        $("#rankingTbody").children("tr").eq(1).children("td").eq(1).html(dataList[dataList.length - 2].totalScore);
+        if (dataList[dataList.length - 2].rankingLast >= 0) {
+            $("#rankingTbody").children("tr").eq(1).children("td").eq(3).html('<img src="img/up.png" alt="" class="img_tr">' + dataList[dataList.length - 2].rankingLast);
+        } else {
+            $("#rankingTbody").children("tr").eq(1).children("td").eq(3).html('<img src="img/down.png" alt="" class="img_tr">' + dataList[dataList.length - 2].rankingLast);
+        }
+        $("#rankingTbody").children("tr").eq(1).children("td").eq(4).html(dataList[dataList.length - 2].addScore);
+
+        $("#rankingTbody").children("tr").eq(2).children("td").eq(0).html(dataList[dataList.length - 3].department);
+        $("#rankingTbody").children("tr").eq(2).children("td").eq(1).html(dataList[dataList.length - 3].totalScore);
+        if (dataList[dataList.length - 3].rankingLast >= 0) {
+            $("#rankingTbody").children("tr").eq(2).children("td").eq(3).html('<img src="img/up.png" alt="" class="img_tr">' + dataList[dataList.length - 3].rankingLast);
+        } else {
+            $("#rankingTbody").children("tr").eq(2).children("td").eq(3).html('<img src="img/down.png" alt="" class="img_tr">' + dataList[dataList.length - 3].rankingLast);
+        }
+        $("#rankingTbody").children("tr").eq(2).children("td").eq(4).html(dataList[dataList.length - 3].addScore);
 
-    //
-    function rankingDetails() {
-        tableIns.reload();
     }
 
     //生成相应的部门
@@ -503,6 +703,38 @@
         option.series[0].data = dataList;
         option && myChart.setOption(option);
     }
+
+    //选择时间生成对应的数据
+    function dateDone(obj) {
+        let type = 0;
+        let childrenType = obj.substring(5, 7);
+        let deptId = $("[name='department']").val();
+        let hasDept = 1;
+        let newMon = obj;
+        loadData(type, childrenType, deptId, hasDept, newMon);
+    }
+
+    //选择部门生成对应的折线统计图
+    function selectDepartment(obj) {
+        let type = 0;
+        let childrenType = $("#monInput").val().substring(5, 7);
+        let hasDept = 1;
+        let newMon = '';
+        $.ajax({
+            url: PATH + '/tj/websiteRating',
+            data: {
+                "type": type,
+                "childrenType": childrenType,
+                "deptId": obj,
+                "hasDept": hasDept,
+                "newMon": newMon
+            },
+            type: "post",
+            success: function (data) {
+                lineChart(data.data['detail-data'], data.data['detail-x']);
+            }
+        })
+    }
 </script>
 </body>
 </html>