zoukankan      html  css  js  c++  java
  • 移动端疫情显示

    主要是做了一个网页,上传到阿里云,然后用Android访问那个网址来实现。

    <%@ page language="java" import="getDataTest.GetYiQing" contentType="text/html; charset=UTF-8"
        pageEncoding="UTF-8"%>
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>全国疫情统计</title>
    <style type="text/css">
    #btn {
        /* 按钮美化 */
        margin-top: 5px;
         75px; /* 宽度 */
        height: 23px; /* 高度 */
        border- 0px; /* 边框宽度 */
        border-radius: 3px; /* 边框半径 */
        background: #1E90FF; /* 背景颜色 */
        cursor: pointer; /* 鼠标移入按钮范围时出现手势 */
        outline: none; /* 不显示轮廓线 */
        font-family: Microsoft YaHei; /* 设置字体 */
        color: white; /* 字体颜色 */
        font-size: 14px; /* 字体大小 */
    }
    
    #btn:hover {
        background: orange;
    }
    table td,th{
             padding: 20px;
            text-align: center;
            border:1px solid #70aefb ;
            vertical-align:middle;
        }
    </style>
    <script src="echarts.js"></script>
    <script src="jquery-3.4.1.js"></script>
    
    <script>
        $(function(){
                
            $("#btn").click(function(){
                
                $.post("GetdataServlet",{time1:$("#time1").val(),time2:$("#time2").val()},function(result){
                        if(result!=null){
                            var array=JSON.parse(result);
                            console.log(result);
                            console.log(array);
                            var province=[];
                            var count=[];
                            for(var i=0;i<array.length;i++){
                                province.push(array[i].province);
                                count.push(array[i].count);
                            }
                            var myChart = echarts.init(document.getElementById('main'));
                            myChart.hideLoading();
                                myChart.setOption({
                                 title: {
                                      text: '疫情统计'
                                  },
                                    legend: {
                                            data:['确诊人数']
                                       },
                                xAxis: {
                                    data: province,
                                    axisLabel: {interval:0,rotate:40 }
                                },
                                
                                yAxis: {
                                    
                                },
                                series: [{
                                    // 根据名字对应到相应的系列
                                      name: '确诊人数',
                                    data:count
    
                                }]
                                
                            });
                                
                                $.get("GetdataServlet?time1="+$("#time1").val()+"&time2="+$("#time2").val(),function(result){
                                    if(result!=null){
                                        var html="<table><tr><td>编号</td><td>日期</td><td>省份</td><td>城市</td><td>确诊人数</td><td>治愈人数</td><td>死亡人数</td></tr>";
                                        var json=JSON.parse(result);
                                        for(var j=0;j<json.length;j++){
                                            html+="<tr><td>"+json[j].id+"</td><td>"+json[j].date+"</td><td>"+json[j].province+"</td><td>"+json[j].city+"</td><td>"+json[j].confirmed_num+"</td><td>"+json[j].Cured_num+"</td><td>"+json[j].Death_num+"</td></tr>"
                                        }
    
                                        console.log(json);
                                        $("#table").html(html+"</table>");
                                    }else{
                                        
                                    }
                                });
                        
                                
                                
                        }else{
                            alert("暂无该数据统计情况");
                        }
                });        
                
                
        
                
            
            });
        });
    </script>
    </head>
    <body>
        <input type="text" id="time1" name="time1" />
        <span>--------></span>
        <input type="text" id="time2" name="time2" />
        <input type="button" value="查询" id="btn">
        <div id="main" style=" 1200px; height: 500px;"></div>
        <div id="table"></div>
        <script>
            var myChart = echarts.init(document.getElementById('main'));
            // 显示标题,图例和空的坐标轴
            myChart.setOption({
                title : {
                    text : '疫情统计柱形图'
                },
                tooltip : {},
                legend : {
                    data : [ '确诊人数' ]
                },
                xAxis : {
                    data : []
                },
                yAxis : {},
                series : [ {
                    name : '确诊人数',
                    type : 'bar',
                    data : []
                } ]
            });
        </script>
    </body>
    </html>
    View Code
    package servlet;
    
    import java.io.IOException;
    import java.io.PrintWriter;
    import java.sql.SQLException;
    
    import javax.servlet.ServletException;
    import javax.servlet.annotation.WebServlet;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    
    import dao.Function;
    
    
    @WebServlet("/GetdataServlet")
    public class GetdataServlet extends HttpServlet {
        private static final long serialVersionUID = 1L;
    
       
        protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            request.setCharacterEncoding("utf-8");      
            response.setContentType("utf-8");         
            response.setCharacterEncoding("utf-8");        
            String time1=request.getParameter("time1");
            String time2=request.getParameter("time2");
            System.out.println(time1+"--->"+time2);
            String json=null;
            try {
                 json=Function.getData(time1, time2);
            } catch (SQLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            System.out.println(json);
            PrintWriter out=response.getWriter();
            out.println(json);
            out.close();
        }
    
        
        protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            request.setCharacterEncoding("utf-8");     
            response.setContentType("utf-8");        
            response.setCharacterEncoding("utf-8");        
            String time1=request.getParameter("time1");
            String time2=request.getParameter("time2");
            System.out.println(time1+"--->"+time2);
            String json=null;
            try {
                 json=Function.query(time1, time2);
            } catch (SQLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            System.out.println(json);
            PrintWriter out=response.getWriter();
            out.println(json);
            out.close();
        }
    
    }
    View Code
    package dao;
    
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    import com.alibaba.fastjson.JSONArray;
    import com.alibaba.fastjson.JSONObject;
    
    import util.DButil;
    
    public class Function {
        
        public static  String query(String a,String b) throws SQLException{
            JSONArray jsonArray=new JSONArray();
            String sql = "select province,sum(confirmed_num) as total from todaydata  where date_format(updateDate,'%Y-%m-%d') between '"+a+"' and '"+b+"'"
                    + "group by province order by total desc";
            Connection conn = DButil.getConn();
            conn.setAutoCommit(false);
            PreparedStatement preparedStatement = conn.prepareStatement(sql);
            ResultSet resultSet = preparedStatement.executeQuery();
            while (resultSet.next()) {
                JSONObject json=new JSONObject();
                String province=resultSet.getString("province");
                if(province==null||province.equals("")) {
                    province="鍩庡競";
                }
                int total=resultSet.getInt("total");
                json.put("province", province);
                json.put("count", total+"");
                jsonArray.add(json);
            }
            conn.commit();
            conn.close();
            return jsonArray.toString();
        }
        
        
        
        
        
        public static String getData(String a,String b) throws SQLException{
            JSONArray jsonArray=new JSONArray();
            String sql="select * from todaydata  where date_format(updateDate,'%Y-%m-%d') between '"+a+"' and '"+b+"' ";
            Connection conn=DButil.getConn();
            try {
            Statement st=conn.createStatement();
            ResultSet rs=st.executeQuery(sql);
            while(rs.next()) {
                JSONObject json=new JSONObject();
                json.put("id",rs.getInt("id"));
                json.put("date", rs.getTimestamp("updateDate").toString());
                String province=rs.getString("province");
                if(province==null||province.equals("")) {
                    province="鐪�";
                }
                json.put("province", province);
                String city=rs.getString("city");
                if(city==null||city.equals("")) {
                    city="甯傚尯";
                }
                json.put("city", city);
                json.put("confirmed_num", rs.getInt("Confirmed_num"));
                json.put("Cured_num", rs.getString("Cured_num"));
                json.put("Death_num",rs.getString("Death_num"));
                jsonArray.add(json);
                }
            }
            catch(Exception e) {
                System.out.println(e.getMessage());
            }
            finally {
                if(conn!=null) {
                   conn.close();
                }
            }
            
            return jsonArray.toString();
        }
    
    }
    View Code
  • 相关阅读:
    使用Visual Studio自带工具dumpbin解析PE文件
    Python内置函数—bytearray
    .gitignore
    Git本地仓库基本操作
    推荐一款编辑神器UltraEdit
    APK文件结构
    在QQ浏览器中使用微信读书辅助工具“小悦记”插件
    Vue动画
    自定义指令的学习
    Vue过滤器的基本使用
  • 原文地址:https://www.cnblogs.com/vvxvv/p/13085152.html
Copyright © 2011-2022 走看看