Преглед на файлове

后台首页实时数据测试

wuzhiqiang преди 5 години
родител
ревизия
9feac5f91e

+ 5 - 0
src/main/java/com/yc/education/controller/admin/ArticleController.java

@@ -12,6 +12,7 @@ import org.springframework.web.servlet.ModelAndView;
 
 import javax.servlet.http.HttpServletRequest;
 import java.util.List;
+import java.util.TimerTask;
 
 /**
  * @author wuzhiqiang 测试   图片上传
@@ -21,6 +22,8 @@ import java.util.List;
 public class ArticleController {
 
 
+
+
     @RequestMapping("/admin/article-list.html")
     public ModelAndView articleList(){
 
@@ -60,4 +63,6 @@ public class ArticleController {
 
         return new ApiMessage<>();
     }
+
+
 }

+ 58 - 0
src/main/java/com/yc/education/controller/admin/BackHomePageController.java

@@ -0,0 +1,58 @@
+package com.yc.education.controller.admin;
+
+import com.yc.education.service.IUserInfoService;
+import com.yc.education.util.AjaxMessage;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import java.util.*;
+
+
+/**
+ * @author wuzhiqiang
+ * @create 2019-10-26 14:18
+ * @Description  后台首页显示实时数据管理
+ */
+@Controller
+@RequestMapping("admin")
+public class BackHomePageController {
+
+    @Autowired
+    private IUserInfoService iUserInfoService;//用户
+
+    @ResponseBody
+    @RequestMapping("homePageData.html")
+    public AjaxMessage<Object>  backHomePage(){
+        AjaxMessage<Object> am = new AjaxMessage<>();
+        List<Object> list = new ArrayList<>();
+
+        Integer  userNumber = iUserInfoService.listUserNumber();//查询用户总数
+        Integer  businessNumber = iUserInfoService.listBusinessNumber();//查询商家总数
+        Integer  providerNumber = iUserInfoService.listProviderNumber();//查询服务商总数
+        Integer  supplierNumber = iUserInfoService.listSupplierNumber();//查询经销商总数
+        Integer  carNumber    = iUserInfoService.listCarNumber();//查询车主总数
+
+        /*map.put("userNumber",userNumber);
+        map.put("businessNumber",businessNumber);
+        map.put("providerNumber",providerNumber);
+        map.put("supplierNumber",supplierNumber);
+        map.put("carNumber",carNumber);*/
+
+        list.add(userNumber);
+        list.add(businessNumber);
+        list.add(providerNumber);
+        list.add(supplierNumber);
+        list.add(carNumber);
+
+
+        am.setIs(true);
+        am.setData(list);
+
+
+        return am;
+    }
+
+
+}

+ 1 - 1
src/main/java/com/yc/education/interceptor/Listen.java

@@ -15,7 +15,7 @@ import org.springframework.stereotype.Component;
 @Component
 public class Listen {
 
-    @Scheduled(cron="*/5 * * * * ?")   //每5分钟执行一次
+//    @Scheduled(cron="*/5 * * * * ?")   //每5分钟执行一次
     public void myTest1() {
         System.out.println("定时器执行.................................." );
     }

+ 9 - 0
src/main/java/com/yc/education/mapper/UserInfoMapper.java

@@ -65,4 +65,13 @@ public interface UserInfoMapper extends MyMapper<UserInfo> {
     @Update("set names utf8mb4")
     void updateByUserInfo(@Param("userInfo") UserInfo userInfo);
 
+    int listUserNumber();
+
+    int listBusinessNumber();
+
+    int listProviderNumber();
+
+    int listSupplierNumber();
+
+    int listCarNumber();
 }

+ 9 - 0
src/main/java/com/yc/education/service/IUserInfoService.java

@@ -70,4 +70,13 @@ public interface IUserInfoService  extends IService<UserInfo>  {      //继承
      */
     List<UserInfo> listOwnerCarInfo(String nickName, String phone,Integer pageNum, Integer pageSize);
 
+    int  listUserNumber();
+
+    int listBusinessNumber();
+
+    int listProviderNumber();
+
+    int listSupplierNumber();
+
+    int listCarNumber();
 }

+ 26 - 0
src/main/java/com/yc/education/service/impl/UserInfoServiceImpl.java

@@ -139,4 +139,30 @@ public class UserInfoServiceImpl extends BaseService<UserInfo> implements IUserI
         PageHelper.startPage(pageNum, pageSize);
         return userInfoMapper.listOwnerCarInfo(nickName,phone);
     }
+
+    @Override
+    public int listUserNumber() {
+        return userInfoMapper.listUserNumber();
+    }
+
+    @Override
+    public int listBusinessNumber() {
+        return userInfoMapper.listBusinessNumber();
+    }
+
+    @Override
+    public int listProviderNumber() {
+        return userInfoMapper.listProviderNumber();
+
+    }
+
+    @Override
+    public int listSupplierNumber() {
+        return userInfoMapper.listSupplierNumber();
+    }
+
+    @Override
+    public int listCarNumber() {
+        return userInfoMapper.listCarNumber();
+    }
 }

+ 20 - 0
src/main/resources/mapper/UserInfoMapper.xml

@@ -68,6 +68,26 @@
             </if>
         </where>
     </select>
+    <!--查询用户总数-->
+    <select id="listUserNumber" resultType="INTEGER">
+        select count(*) from user_info
+    </select>
+    <!--查询商家总数-->
+    <select id="listBusinessNumber" resultType="INTEGER">
+        select count(*) from user_info where role != 0
+    </select>
+    <!--查询服务商总数-->
+    <select id="listProviderNumber" resultType="INTEGER">
+        select count(*) from user_info where role = 1
+    </select>
+    <!--查询经销商总数-->
+    <select id="listSupplierNumber" resultType="INTEGER">
+        select count(*) from user_info where role = 2
+    </select>
+    <!--查询车主总数-->
+    <select id="listCarNumber" resultType="INTEGER">
+        select count(*) from user_info where role = 0
+    </select>
 
     <!--    <update id="updateByUserInfo" parameterType="java.util.Map">
           update user_info a a.photo = #{userInfo.photo},a.nick_name = #{userInfo.nickName} ,a.longitude = #{userInfo.longitude} ,a.latitude = #{userInfo.latitude} ,a.modified_date = #{userInfo.modifiedDate} where a.openid = #{userInfo.openid}

+ 135 - 23
src/main/webapp/WEB-INF/jsp/admin/welcome.jsp

@@ -24,6 +24,10 @@
 <script type="text/javascript" src="${pageContext.request.contextPath}/static/admin/index/js/DD_belatedPNG_0.0.8a-min.js" ></script>
 <script>DD_belatedPNG.fix('*');</script>
 <![endif]-->
+    <script type="text/javascript" src="${pageContext.request.contextPath}/static/echarts/echarts.min.js"></script>
+    <script type="text/javascript"
+            src="${pageContext.request.contextPath}/static/admin/index/jquery/1.9.1/jquery.min.js"></script>
+    <script type="text/javascript" src="${pageContext.request.contextPath}/static/admin/index/layer/layer.js"></script>
 <title>我的桌面</title>
 </head>
 <body>
@@ -35,28 +39,136 @@
     .widget-box-overview ul li h5{font-size: 26px;height: 1.5em;letter-spacing: -1px;line-height: 1.5em;}
 </style>
 <div class="box">
-        <div class="qus">
-            <h3>欢迎使用杰冠网络(上海君之道信息科技有限公司 上海杰冠网络技术有限公司)技术团队开发的管理系统</h3>
-        </div>
-        <div class="content-wrapper">
-			<div class="gy">
-				<p>杰冠网络以实现企业信息化建设为己任,致力于网站建设、商城搭建、微信应用开发、APP 及 ERP开发,我们立志为客户提供最好的技术,最适合的解决方案。</p>
-				<p>我们拥有10年以上的平面及UI设计和开发经验的技术骨干,公司还通过合作引进国内、外知名院校毕业生等方式,拥有了一批多语种项目开发的高端人才。</p>
-			</div>
-            
-            <div class="qus">
-				<h3>如果您在使用中有任何问题,欢迎及时与我们联系,我们将提供7*24小时全天后的技术支持。</h3>
-            <ul>
-                <li>上海杰冠网络技术有限公司</li>
-                <li>上海君之道信息科技有限公司</li>
-                <li>服务热线:021-62340162 62362177 </li>
-                <li>传 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 真:021-62340162-8005 </li>
-                <li>邮件咨询:andy@jzdsh.com </li>
-                <li>地 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 址:上海市普陀区中江路879号天地软件园27号楼207室 </li>
-                <li>网 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 址:<a href="http://www.jzdsh.com" target="_blank">www.jzdsh.com </a>    <a href="http://www.shjieguan.com" target="_blank">www.shjieguan.com </a>  </li>
-            </ul>
-			</div>     
-        </div>
-    </div>
+    <div id="chartmain" style="width: 800px;height:400px;"></div>
+</div>
+
+<script type="text/javascript">
+    var option = {
+        tooltip : {
+            trigger: 'axis',
+            axisPointer : {            // 坐标轴指示器,坐标轴触发有效
+                type : 'shadow'        // 默认为直线,可选为:'line' | 'shadow'
+            }
+        },
+        legend: {
+            data:['新增用户','用户总数','商家总数','服务商总数','经销商总数','车主总数']
+        },
+        grid: {
+            left: '3%',
+            right: '4%',
+            bottom: '1%',
+            containLabel: true
+        },
+        xAxis : [
+            {
+                type : 'category',
+
+                data :['上海']
+            }
+        ],
+        yAxis : [
+            {
+                type: 'value',
+                min: 0,
+                max: 10,
+                splitArea: {
+                    show: true
+                }
+            }
+        ],
+        series : [
+            {
+                name:'新增用户',
+                type:'bar',
+                barWidth : 20,
+                data:[]
+            },
+            {
+                name:'用户总数',
+                type:'bar',
+                barWidth : 20,
+                data:[]
+            },
+            {
+                name:'商家总数',
+                type:'bar',
+                barWidth : 20,
+                data:[]
+            },
+            {
+                name:'服务商总数',
+                type:'bar',
+                barWidth : 20,
+                data:[]
+            },
+            {
+                name:'经销商总数',
+                type:'bar',
+                barWidth : 20,
+
+                data:[]
+            },
+            {
+                name:'车主总数',
+                type:'bar',
+                barWidth : 20,
+                data:[]
+            }
+        ]
+    };
+
+
+    // js定时器
+    $(function () {
+        funkaishi();
+    })
+    var i = 4;
+    var intervalid;
+    function funkaishi() {
+        intervalid = setInterval("fun()", 5000);
+    }
+    function fun() {
+        if (i == 0) {
+            clearInterval(intervalid);
+            i = 5;
+            funkaishi();
+        }
+        i--;
+        // console.log(i+"第一个");
+        $(function(){
+
+           /* console.log(i+"第二个");*/
+            $.ajax({
+                type: "post",
+                url: "homePageData.html",
+                dataType: "json",
+                success: function (ajax) {
+                  /*  console.log(ajax.data);*/
+                    if (ajax.is) {
+                        var listData = ajax.data;
+
+                        option.series[0].data.push(listData[0]);
+                        option.series[1].data.push(listData[0]);
+                        option.series[2].data.push(listData[1]);
+                        option.series[3].data.push(listData[2]);
+                        option.series[4].data.push(listData[3]);
+                        option.series[5].data.push(listData[4]);
+                        //初始化echarts实例
+                        var myChart = echarts.init(document.getElementById('chartmain'));
+                        // alert(option.series[0].name);
+                        //使用制定的配置项和数据显示图表
+                        myChart.setOption(option);
+
+                    }
+                }
+            });
+        });
+
+    }
+
+
+
+
+</script>
 </body>
 </html>

Файловите разлики са ограничени, защото са твърде много
+ 24 - 0
src/main/webapp/static/echarts/echarts.min.js