1 项目目的与意义

 1.1项目背景说明

 1.2项目目的与意义

2 软件开发环境与技术说明

 2.1软件开发环境

 2.2软件开发技术描述

3 系统分析与设计

 3.1项目需求分析说明

 3.2系统设计方案

4 系统源代码

 4.1系统源代码文件说明

 4.2源代码

5 系统使用说明书

6 参考资料

7 附件说明

  

1 项目目的与意义

1.1项目背景说明

  “武汉街道空无一人,但是每个窗户后面都有配合应对疫情的市民。中国展现了惊人的集体行动力与合作精神。”这是世界卫生组织总干事高级顾问布鲁斯·艾尔沃德2月下旬在结束对中国的实地考察后发出的感慨。

放眼全中国,怀有浓厚家国情怀的中国人不计其数。来自中国各地的4.2万余名医护人员快速驰援湖北与武汉,义无反顾地成为“最美逆行者”,有人甚至为此献出了生命。正是抱定共克时艰的意志,14亿中国人齐心响应国家号召,自觉居家隔离,为疫情防控尽自己的一份力。艾尔沃德在考察中国防疫工作后曾动情地说,“中国人民的坚韧和奉献,极大延缓了新冠肺炎疫情传播。”联合国秘书长古特雷斯认为,“中国人民为防控疫情作出的牺牲,是对人类极大的贡献。”

   美国破百万、全球大流行, 可以确定地说,目前我们正在经历本世纪以来最严重的灾难,其波及范围,人员伤亡,后续影响及对全球经济形势的损害都将是自二战以来最惨烈的。

目前疫情正在全球肆虐,已波及209个国家,地球上己几无一片净土。截止4月11日,全球确诊人数已近两百万,死亡人数达十余万,而且还在以每天数万确诊,上千死亡的速度飞速增长。目前除中国疫情基本受控之外,欧美各国疫情均在发酵中,拐点还远远没有到来。以现在疫情最严重的美国为例,预计拐点最快也要到月底,以目前的发展速度,达到百万级别确诊和十万级别死亡将是大概率事件。

   新冠肺炎疫情对全球经济影响巨大,据最新数据预测,2020年全球经济将萎缩3.0%,为1930年以来遭遇的最大经济危机。不容乐观的是,面对多国放松封锁措施,世界卫生组织警告,疫情尚未到峰值。

 

1.2项目目的与意义

   该项目的研究可以让人们每日清晰地看到世界的疫情数据,时刻关注世界疫情状况在当下也具有重要意义。

   据全球疫情实时监控网站统计,每天都有十几亿的访问量,这也看到了大家对于实时的数据重视

 

 

2 软件开发环境与技术说明

2.1 软件开发环境

   该系统应用eclipse使用JavaScript语言建立可视化界面

   Python软件进行数据的爬取

   Python标准库和扩展库:pymysql、 requests、bs4

   数据库环境:MySQL

2.2软件开发技术描述

界面设计:应用JavaScript对界面进行包装

Python爬取数据连接:

url= https://ncov.dxy.cn/ncovh5/view/pneumonia?from=timeline&isappinstalled=0\'  
# 请求地址
headers = {\'user-agent\': \'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36\'}  
# 创建头部信息
response = requests.get(url, headers=headers)  # 发送网络请求
content = response.content.decode(\'utf-8\')
soup = BeautifulSoup(content, \'html.parser\')

 

数据库连接:

Python连接MySQL数据库

db = pymysql.connect("localhost", "root", "0000", "yiqing", charset=\'utf8\')
cursor = db.cursor()

 

JavaScript连接MySQL数据库

conn=DriverManager.getConnection("jdbc:mysql://localhost:8080/疫情统计图/world?useUnicode=true&characterEncoding=utf-8","root","");

 

数据连接:

    String sql="select * from world_map where now_time like \'"+time+"%\' ";
    String sql="select * from world_map where now_time like \'"+time+"%\' ORDER BY deadCount desc ";
    String sql="select * from world_map where now_time like \'"+time+"%\' order by curedCount desc ";
    //等等,此处不过多列举

 

网络连接:

 Web:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" id="WebApp_ID" version="4.0">
  <display-name>疫情统计图</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
</web-app>

 

Python连接JavaScript:

sql_world = "INSERT INTO world_map values (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"

 

正则字符串处理:

(.+?)  (.*)  等等

 

3系统分析与设计

3.1项目需求分析说明

  仿照约翰·霍普金斯大学制作全球疫情发布图(WEB版),可以实时访问。用例图如下:

 

      

3.2系统设计方案

数据库表:

      

 

Python爬取数据到数据库

       

 

框架设计图如下:

      

 

4 系统源代码

4.1系统源代码文件说明

文件

作用

Python文件

爬取世界疫情信息到Mysql

dao包

对数据库进行操作

servlet包

函数代码

util包

连接数据库

entity包

定义类对象的set get方法和构造函数

src目录下所有文件

后台的java代码,支持界面所有操作

world.jsp

实现界面

js和layui文件夹

调样式

css 和layui文件夹

美化界面

lib下所有文件

连接数据库操作需要引用的jar包

Xml文件

配置文件

chart下所有文件

用echart图表用来实现地图

 

 

4.2源代码

登录界面

 1 package First;
 2  
 3  
 4 import java.awt.*;//导入awt包
 5 import javax.swing.*;//导入swing包
 6 import java.awt.event.ActionListener;//导入awt包中的监听器事件包
 7 import java.awt.event.ActionEvent;//导入awt包中的ActionEvent事件包
 8  
 9  
10  
11 public class login extends JFrame {
12      
13         
14     public login() { 
15         setSize(300,290);//设计窗体的大小
16         JLabel a=new JLabel("用户名"); //实例化JLabel对象
17         JLabel b=new JLabel("密    码");
18         JTextField c=new JTextField(15);//实例化用户名文本框
19         JPasswordField d=new JPasswordField(15);//实例化密码框
20         d.setEchoChar(\'*\');//将输入密码框中的密码以*显示出来
21         JButton e=new JButton("确定");
22         JButton f=new JButton("重置");
23         JButton g=new JButton("注册");
24         setVisible(true);//使窗体可视化
25         Container mk=getContentPane();//获取一个容器
26 //      将用户名、密码的Jlabel和用户名JTextField文本框、密码JPasswordField密码框以及确定JButton、重置JButton、注册JButton添加到container容器里面                         //
27         mk.add(a);
28         mk.add(b);
29         mk.add(c);
30         mk.add(d);
31         mk.add(e);
32         mk.add(f);
33         mk.add(g);
34         setBounds(300,300,300,290);//设置窗体的长宽各为300、300  让其显示在左上方的300、300处
35         mk.setLayout(null);
36 //      a、b、c、d、e、f、g显示在container容器中的位置坐标
37         a.setBounds(10,40,50,18);
38         b.setBounds(10,80,50,18);
39         c.setBounds(60,40,200,18);
40         d.setBounds(60,80,200,18);
41         e.setBounds(110,180,60,30);
42         f.setBounds(30,180,60,30);
43         g.setBounds(190,180,60,30);
44         
45         f.addActionListener(new ActionListener() {//对重置按钮添加监听事件
46  
47             @Override
48             public void actionPerformed(ActionEvent arg0) {
49                 // TODO Auto-generated method stub
50                 c.setText("");//对用户名文本框进行重置
51                 d.setText("");//对密码文本框进行重置
52             }
53             
54         });
55         e.addActionListener(new ActionListener() {//对确定按钮添加监听事件
56              
57             @SuppressWarnings("deprecation")
58             @Override
59             public void actionPerformed(ActionEvent arg0) {
60                 // TODO Auto-generated method stub
61                 
62                 if(c.getText().trim().equals("py")&&new String(d.getPassword()).equals("123456")) {//equals函数进行用户名和密码的匹配
63                    JOptionPane.showMessageDialog(null,"登录成功");
64                    
65                    new world();//进入到world这个窗体中
66                 }
67                    else if(c.getText().trim().equals("zs")&&new String(d.getPassword()).equals("123")) {//equals函数进行用户名和密码的匹配
68                        JOptionPane.showMessageDialog(null,"登录成功");
69                        
70                        new Add();//进入到world这个窗体中
71                 }
72                    else {
73                    JOptionPane.showMessageDialog(null, "登录失败");
74                 }
75             }
76                 
77         });
78         g.addActionListener(new ActionListener(){//对注册按钮添加监听事件
79             @SuppressWarnings("deprecation")
80             @Override
81             public void actionPerformed(ActionEvent arg0) {
82                 // TODO Auto-generated method stub
83                 new zhuce();//进入都到zhuce窗体中
84             }
85             
86         });
87         
88     }
89         public static void main(String[] args) {
90             new main();
91             
92  
93                     }
94         
95         
96     }

login

 

注册界面

 

package First;
 
import java.sql.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
 
 
import com.mysql.jdbc.Driver;
 
import First.login;
 
 
 
    
 
    public class zhuce extends login {
        private static final long serialVersionUID = -1928970409928880648L;
        
        JLabel jlnumber = new JLabel("用户名:");
        JLabel jpassword = new JLabel("密码:");
        
        JTextField jtnumber = new JTextField("",20);
        JTextField jtpassword = new JTextField("",20);
        
        JButton buttonadd = new JButton("注册");
        JButton buttonreturn = new JButton("取消");
        
        public zhuce() {
            JPanel jpnumber = new JPanel();
            JPanel jtpassword = new JPanel();
            JPanel jpforbutton = new JPanel(new GridLayout(1,1));
            
            jpnumber.add(jlnumber);
            jpnumber.add(jtnumber);
 
            
            jtpassword.add(jtpassword);
            jtpassword.add(jtpassword);
            
            jpforbutton.add(buttonadd);
            jpforbutton.add(buttonreturn);
            
            buttonadd.addActionListener(new ActionListener(){
                public void actionPerformed(ActionEvent e){
                   
                   //Add
                   Connection conn = null;
                   Statement stat = null;
                   PreparedStatement ps=null;
                   String a1=jtnumber.getText();
                   String e2=jpassword.getText();
                   String sql = "INSERT INTO student(number,password) values(\'"+a1+"\',\'"+e2+"\')";
                   try{
                       Class.forName("com.mysql.jdbc.Driver");
                       System.out.println("JBDC 连接成功!");
                   }catch(Exception a){
                       System.out.println("JBDC 连接失败!");
                       a.printStackTrace();
                   }
                   try{
                       conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/STU?useUnicode=true&characterEncoding=utf-8","root","");
                       //ps=conn.prepareStatement(sql);
                       
                       //ps.setString(1,jtnumber.getText());
                       //ps.setString(2,jtname.getText());
                       //ps.setString(3,jtsex.getText());
                       //ps.setString(4,jtbirthday.getText());
                       //ps.setString(5,jtdepartment.getText());
     
     
                       //ps.executeUpdate();
                       
                       System.out.println("MySQL 连接成功!");
                       stat = conn.createStatement();
                       stat.executeUpdate(sql);
                       System.out.println("插入数据成功!");
                       
                   }catch (SQLException b){
                       b.printStackTrace();
                   }finally{
                       try{
                           conn.close();
                           System.out.println("MySQL 关闭成功");
                       }catch (SQLException c){
                           System.out.println("MySQL 关闭失败 ");
                           c.printStackTrace();
                       }
                       
                   }
                       
                       
            }}  
            
                   );
            
            buttonreturn.addActionListener(new ActionListener(){
                public void actionPerformed(ActionEvent e){
                   login();           
                }           
            });
            
            
            this.setTitle("注册信息");
            this.setLayout(new GridLayout(9,1));
            this.add(jpnumber);
            this.add(jpassword);
            this.add(jpforbutton);
            this.setLocation(400,300);
            this.setSize(350,300);
            this.setVisible(true);
            
        }
        
        
    }

register

 

界面实现

jsp代码部分

  1 <%@ page language="java" contentType="text/html; charset=UTF-8"
  2     pageEncoding="UTF-8"%>
  3 <%@page import="java.util.Date"%>
  4 <%@page import="java.text.SimpleDateFormat"%>
  5 <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
  6 <!DOCTYPE html>
  7 <html>
  8 <head>
  9 <meta charset="UTF-8">
 10 <title>Insert title here</title>
 11 <script src="js/jquery-1.11.3.min.js"></script>
 12 <script type="text/javascript" src="chart/echarts.min.js"></script>
 13 <script type="text/javascript"
 14     src="https://www.echartsjs.com/examples/vendors/echarts/map/js/world.js?_v_=1584687926098"></script>
 15 </head>
 16 <style>
 17 #title {
 18     background-color: black;
 19     border: solid 1px;
 20     font-family: "楷体";
 21     text-align: center;
 22     font-color: white;
 23     height: 80px;
 24     width: 1200px;
 25     float: left;
 26 }
 27  
 28 #time {
 29     background-color: black;
 30     border: solid 1px;
 31     font-family: "楷体";
 32     text-align: center;
 33     font-color: #333;
 34     width: 250px;
 35     height: 80px;
 36     float: left;
 37 }
 38  
 39 #left {
 40     background-color: black;
 41     overflow-x: auto;
 42     overflow-y: auto;
 43     border: solid 1px;
 44     font-family: "楷体";
 45     text-align: center;
 46     font-color: #333;
 47     width: 250px;
 48     height: 800px;
 49     float: left;
 50 }
 51  
 52 #right {
 53     background-color: black;
 54     border: solid 1px;
 55     font-family: "楷体";
 56     text-align: center;
 57     font-color: #333;
 58     width: 350px;
 59     height: 450px;
 60     float: left;
 61 }
 62  
 63 #right1 {
 64     background-color: black;
 65     overflow-x: auto;
 66     overflow-y: auto;
 67     border: solid 1px;
 68     font-family: "楷体";
 69     text-align: center;
 70     font-color: #333;
 71     width: 175px;
 72     height: 450px;
 73     float: left;
 74 }
 75  
 76 #right2 {
 77     background-color: black;
 78     overflow-x: auto;
 79     overflow-y: auto;
 80     border: solid 1px;
 81     font-family: "楷体";
 82     text-align: center;
 83     font-color: #333;
 84     width: 170px;
 85     height: 450px;
 86     float: right;
 87 }
 88  
 89 #mid {
 90     background-color: black;
 91     border: solid 1px;
 92     font-family: "楷体";
 93     text-align: center;
 94     font-color: #333;
 95     width: 850px;
 96     height: 800px;
 97     float: left;
 98 }
 99  
100 #line {
101     background-color: #5c5c5c;
102     border: solid 1px;
103     width: 350px;
104     height: 350px;
105     float: left;
106 }
107 </style>
108 <body onload="onload()">
109     <%
110     
111 %>
112     <!-- 为ECharts准备一个具备大小(宽高)的Dom -->
113     <div id="title">
114         <h2 style="color: white">全球疫情可视化展示</h2>
115     </div>
116     <div id="time">
117         <h2 id="showtime" style="color: white">time</h2>
118     </div>
119     <div id="left"></div>
120     <div id="mid"></div>
121     <div id="right">
122         <div id="right1">死亡人数</div>
123         <div id="right2">治愈人数</div>
124     </div>
125     <div id="line">柱状图</div>
126     <script type="text/javascript">
127     
128     function onload(){
129         
130         setInterval("document.getElementById(\'showtime\').innerHTML=new Date().toLocaleString();", 1000);
131         $.post(
132                 "Getconfirmed",
133                 function(data){
134                     var sum=0;
135                     for(var i=0;i<data.length;i++)
136                         sum+= parseInt(data[i].confirmedCount);
137                     var htmltext="<h style=\'color: white;\'>全球确诊人数为:"+"<span style=\'color: red;font-size:50px\'>"+sum+"</span></h>";
138                     htmltext+="<table>"
139                     for(var i=0;i<data.length;i++)
140                         htmltext+="<tr><td>"+"<span style=\'color: white;\'>"+data[i].provinceName+"</span></td><td><span style=\'color: red;\'>"+data[i].confirmedCount+"</span></td></tr>";
141                     htmltext+="</table>";
142                     $("#left").html(htmltext);
143                     
144                 },
145                 "json"
146                 );
147         $.post(
148                 "GetDead",
149                 function(data){
150                     var sum=0;
151                     for(var i=0;i<data.length;i++)
152                         sum+= parseInt(data[i].deadCount);
153                     var htmltext="<h style=\'color: white;\'>全球死亡人数为:"+"<span style=\'color: red;font-size:50px\'>"+sum+"</span></h>";
154                     htmltext+="<table>"
155                     for(var i=0;i<data.length;i++)
156                         htmltext+="<tr><td>"+"<span style=\'color: white;\'>"+data[i].provinceName+"</span></td><td><span style=\'color: red;\'>"+data[i].deadCount+"</span></td></tr>";
157                     htmltext+="</table>";
158                     $("#right1").html(htmltext);
159                     
160                 },
161                 "json"
162                 );
163         $.post(
164                 "Getcured",
165                 function(data){
166                     var sum=0;
167                     for(var i=0;i<data.length;i++)
168                         sum+= parseInt(data[i].curedCount);
169                     var htmltext="<h style=\'color: white;\'>全球治愈人数为:"+"<span style=\'color: green;font-size:50px\'>"+sum+"</span></h>";
170                     htmltext+="<table>"
171                     for(var i=0;i<data.length;i++)
172                         htmltext+="<tr><td>"+"<span style=\'color: white;\'>"+data[i].provinceName+"</span></td><td><span style=\'color: green;\'>"+data[i].curedCount+"</span></td></tr>";
173                     htmltext+="</table>";
174                     $("#right2").html(htmltext);
175                     
176                 },
177                 "json"
178                 );
179         //处理随日期变化的全球确诊人数图
180          var myChart1 = echarts.init(document.getElementById(\'line\'));
181          myChart1.setOption({
182              title:{
183              text:\'确诊人数变化\'
184              },
185              
186              tooltip:{},
187              grid: {
188                     left: \'4%\',
189                     right: \'4%\',
190                     bottom: \'3%\',
191                     //是否显示刻度标签
192                     containLabel: true
193                 },
194              legend:{
195              data:[\'确诊数\']
196              },
197              xAxis:{
198                  data:[],
199                  axisLabel:{
200                     //横坐标全部显示                     
201                            interval:0,
202                        //横坐标倾斜45度    
203                            rotate:-45,
204                             },
205              },
206              yAxis:{},
207              series:[{
208              name:\'确诊数\',
209              type:\'line\',
210              data:[]
211              }]
212              })
213         var cname=[];
214         var value=[];
215         //处理这段时间疫情总数变化趋势
216          $.ajax({
217              url:"Dataconfirmed",
218              type:"POST",
219              dataType:"JSON",
220              async:true,
221              success:function(data){
222                  for(var i=0;i<data.length;i++)
223                  {
224                      cname[i]=data[i].provinceName;
225                      value[i]=parseInt(data[i].confirmedCount);
226                  }
227                  myChart1.setOption({
228                        xAxis:{
229                       //放横坐标的数组
230                        data:cname,
231                        },
232                        series:[{
233                        name:\'确诊数\',
234                        //每个横坐标对应的数值
235                        data:value
236                        }]
237                        });
238              }
239          });
240     
241         //处理世界疫情地图
242          $.ajax({
243              url:"Allworld",
244              type:"POST",
245              dataType:"JSON",
246              async:true,
247              success:function(data){//表示处理成功之后做什么,后面跟一个匿名函数。回调函数,表示处理页面处理完数据以后执行这个函数。data表示处理页面返回的值,用形参接收。
248                   var mydata = new Array(0);
249                
250                   for(var i=0;i<data.length;i++){
251                       var d = {
252                               
253                       };
254                       d["name"] = data[i].provinceName;//.substring(0, 2);
255                       d["value"] = data[i].confirmedCount;
256                       d["Yisi_num"] = data[i].suspectedCount;
257                       d["Cured_num"] = data[i].curedCount;
258                       d["Dead_num"] = data[i].deadCount;
259                       mydata.push(d);
260                   }
261                     //初始化echarts实例
262                  var myChart = echarts.init(document.getElementById(\'mid\'));
263                  // 指定图表的配置项和数据
264                var  option = {
265                          tooltip : {  
266                              trigger: \'item\',
267                              formatter : function(params) {
268                                  return params.name + \'<br/>\' + \'确诊人数 : \'
269                                          + params.value + \'<br/>\' + \'死亡人数 : \'
270                                          + params[\'data\'].Dead_num + \'<br/>\' + \'治愈人数 : \'
271                                          + params[\'data\'].Cured_num + \'<br/>\'+ \'疑似患者人数 : \'
272                                          + params[\'data\'].Yisi_num;
273                              }//数据格式化
274                          },  
275                    title: {
276                      text: \'世界疫情图\',
277                      left: \'center\'
278                    },
279                  
280                    legend: {
281                      orient: \'vertical\',
282                      left: \'left\',
283                      data: [\'世界疫情图\']
284                    },
285                    visualMap: {
286                      type: \'piecewise\',
287                      pieces: [
288                          { min: 70000, max: 50000000, label: \'确诊70000人以上\', color: \'red\' },
289                        { min: 10000, max: 69999, label: \'确诊10000-69999人\', color: \'blue\' },
290                        { min: 5000, max: 9999, label: \'确诊5000-9999人\', color: \'purple\' },
291                        { min: 1500, max: 4999, label: \'确诊1500-4999人\', color: \'yellow\' },
292                        { min: 500, max: 1499, label: \'确诊500-1499人\', color: \'gold\' },
293                        { min: 0, max: 499, label: \'确诊1-499人\', color: \'green\' },
294                      ],
295                      color: [\'#E0022B\', \'#E09107\', \'#A3E00B\']
296                    },
297                    toolbox: {
298                      show: true,
299                      orient: \'vertical\',
300                      left: \'right\',
301                      top: \'center\',
302                      feature: {
303                        mark: { show: true },
304                        dataView: { show: true, readOnly: false },
305                        restore: { show: true },
306                        saveAsImage: { show: true }
307                      }
308                    },
309                    roamController: {
310                      show: true,
311                      left: \'right\',
312                      mapTypeControl: {
313                        \'world\': true
314                      }
315                    },
316                    series: [
317                      {
318                        name: \'确诊数\',
319                        type: \'map\',
320                        mapType: \'world\',
321                      
322                        nameMap : {"Canada": "加拿大",
323                                "Turkmenistan": "土库曼斯坦",
324                                "Saint Helena": "圣赫勒拿",
325                                "Lao PDR": "老挝",
326                                "Lithuania": "立陶宛",
327                                "Cambodia": "柬埔寨",
328                                "Ethiopia": "埃塞俄比亚",
329                                "Faeroe Is.": "法罗群岛",
330                                "Swaziland": "斯威士兰",
331                                "Palestine": "巴勒斯坦",
332                                "Belize": "伯利兹",
333                                "Argentina": "阿根廷",
334                                "Bolivia": "玻利维亚",
335                                "Cameroon": "喀麦隆",
336                                "Burkina Faso": "布基纳法索",
337                                "Aland": "奥兰群岛",
338                                "Bahrain": "巴林",
339                                "Saudi Arabia": "沙特阿拉伯",
340                                "Fr. Polynesia": "法属波利尼西亚",
341                                "Cape Verde": "佛得角",
342                                "W. Sahara": "西撒哈拉",
343                                "Slovenia": "斯洛文尼亚",
344                                "Guatemala": "危地马拉",
345                                "Guinea": "几内亚",
346                                "Dem. Rep. Congo": "刚果(金)",
347                                "Germany": "德国",
348                                "Spain": "西班牙",
349                                "Liberia": "利比里亚",
350                                "Netherlands": "荷兰",
351                                "Jamaica": "牙买加",
352                                "Solomon Is.": "所罗门群岛",
353                                "Oman": "阿曼",
354                                "Tanzania": "坦桑尼亚",
355                                "Costa Rica": "哥斯达黎加",
356                                "Isle of Man": "曼岛",
357                                "Gabon": "加蓬",
358                                "Niue": "纽埃",
359                                "Bahamas": "巴哈马",
360                                "New Zealand": "新西兰",
361                                "Yemen": "也门",
362                                "Jersey": "泽西岛",
363                                "Pakistan": "巴基斯坦",
364                                "Albania": "阿尔巴尼亚",
365                                "Samoa": "萨摩亚",
366                                "Czech Rep.": "捷克",
367                                "United Arab Emirates": "阿拉伯联合酋长国",
368                                "Guam": "关岛",
369                                "India": "印度",
370                                "Azerbaijan": "阿塞拜疆",
371                                "N. Mariana Is.": "北马里亚纳群岛",
372                                "Lesotho": "莱索托",
373                                "Kenya": "肯尼亚",
374                                "Belarus": "白俄罗斯",
375                                "Tajikistan": "塔吉克斯坦",
376                                "Turkey": "土耳其",
377                                "Afghanistan": "阿富汗",
378                                "Bangladesh": "孟加拉国",
379                                "Mauritania": "毛里塔尼亚",
380                                "Dem. Rep. Korea": "朝鲜",
381                                "Saint Lucia": "圣卢西亚",
382                                "Br. Indian Ocean Ter.": "英属印度洋领地",
383                                "Mongolia": "蒙古",
384                                "France": "法国",
385                                "Cura?ao": "库拉索岛",
386                                "S. Sudan": "南苏丹",
387                                "Rwanda": "卢旺达",
388                                "Slovakia": "斯洛伐克",
389                                "Somalia": "索马里",
390                                "Peru": "秘鲁",
391                                "Vanuatu": "瓦努阿图",
392                                "Norway": "挪威",
393                                "Malawi": "马拉维",
394                                "Benin": "贝宁",
395                                "St. Vin. and Gren.": "圣文森特和格林纳丁斯",
396                                "Korea": "韩国",
397                                "Singapore": "新加坡",
398                                "Montenegro": "黑山共和国",
399                                "Cayman Is.": "开曼群岛",
400                                "Togo": "多哥",
401                                "China": "中国",
402                                "Heard I. and McDonald Is.": "赫德岛和麦克唐纳群岛",
403                                "Armenia": "亚美尼亚",
404                                "Falkland Is.": "马尔维纳斯群岛(福克兰)",
405                                "Ukraine": "乌克兰",
406                                "Ghana": "加纳",
407                                "Tonga": "汤加",
408                                "Finland": "芬兰",
409                                "Libya": "利比亚",
410                                "Dominican Rep.": "多米尼加",
411                                "Indonesia": "印度尼西亚",
412                                "Mauritius": "毛里求斯",
413                                "Eq. Guinea": "赤道几内亚",
414                                "Sweden": "瑞典",
415                                "Vietnam": "越南",
416                                "Mali": "马里",
417                                "Russia": "俄罗斯",
418                                "Bulgaria": "保加利亚",
419                                "United States": "美国",
420                                "Romania": "罗马尼亚",
421                                "Angola": "安哥拉",
422                                "Chad": "乍得",
423                                "South Africa": "南非",
424                                "Fiji": "斐济",
425                                "Liechtenstein": "列支敦士登",
426                                "Malaysia": "马来西亚",
427                                "Austria": "奥地利",
428                                "Mozambique": "莫桑比克",
429                                "Uganda": "乌干达",
430                                "Japan": "日本",
431                                "Niger": "尼日尔",
432                                "Brazil": "巴西",
433                                "Kuwait": "科威特",
434                                "Panama": "巴拿马",
435                                "Guyana": "圭亚那",
436                                "Madagascar": "马达加斯加",
437                                "Luxembourg": "卢森堡",
438                                "American Samoa": "美属萨摩亚",
439                                "Andorra": "安道尔",
440                                "Ireland": "爱尔兰",
441                                "Italy": "意大利",
442                                "Nigeria": "尼日利亚",
443                                "Turks and Caicos Is.": "特克斯和凯科斯群岛",
444                                "Ecuador": "厄瓜多尔",
445                                "U.S. Virgin Is.": "美属维尔京群岛",
446                                "Brunei": "文莱",
447                                "Australia": "澳大利亚",
448                                "Iran": "伊朗",
449                                "Algeria": "阿尔及利亚",
450                                "El Salvador": "萨尔瓦多",
451                                "C?te d\'Ivoire": "科特迪瓦",
452                                "Chile": "智利",
453                                "Puerto Rico": "波多黎各",
454                                "Belgium": "比利时",
455                                "Thailand": "泰国",
456                                "Haiti": "海地",
457                                "Iraq": "伊拉克",
458                                "S?o Tomé and Principe": "圣多美和普林西比",
459                                "Sierra Leone": "塞拉利昂",
460                                "Georgia": "格鲁吉亚",
461                                "Denmark": "丹麦",
462                                "Philippines": "菲律宾",
463                                "S. Geo. and S. Sandw. Is.": "南乔治亚岛和南桑威奇群岛",
464                                "Moldova": "摩尔多瓦",
465                                "Morocco": "摩洛哥",
466                                "Namibia": "纳米比亚",
467                                "Malta": "马耳他",
468                                "Guinea-Bissau": "几内亚比绍",
469                                "Kiribati": "基里巴斯",
470                                "Switzerland": "瑞士",
471                                "Grenada": "格林纳达",
472                                "Seychelles": "塞舌尔",
473                                "Portugal": "葡萄牙",
474                                "Estonia": "爱沙尼亚",
475                                "Uruguay": "乌拉圭",
476                                "Antigua and Barb.": "安提瓜和巴布达",
477                                "Lebanon": "黎巴嫩",
478                                "Uzbekistan": "乌兹别克斯坦",
479                                "Tunisia": "突尼斯",
480                                "Djibouti": "吉布提",
481                                "Greenland": "格陵兰",
482                                "Timor-Leste": "东帝汶",
483                                "Dominica": "多米尼克",
484                                "Colombia": "哥伦比亚",
485                                "Burundi": "布隆迪",
486                                "Bosnia and Herz.": "波斯尼亚和黑塞哥维那",
487                                "Cyprus": "塞浦路斯",
488                                "Barbados": "巴巴多斯",
489                                "Qatar": "卡塔尔",
490                                "Palau": "帕劳",
491                                "Bhutan": "不丹",
492                                "Sudan": "苏丹",
493                                "Nepal": "尼泊尔",
494                                "Micronesia": "密克罗尼西亚",
495                                "Bermuda": "百慕大",
496                                "Suriname": "苏里南",
497                                "Venezuela": "委内瑞拉",
498                                "Israel": "以色列",
499                                "St. Pierre and Miquelon": "圣皮埃尔和密克隆群岛",
500                                "Central African Rep.": "中非",
501                                "Iceland": "冰岛",
502                                "Zambia": "赞比亚",
503                                "Senegal": "塞内加尔",
504                                "Papua New Guinea": "巴布亚新几内亚",
505                                "Trinidad and Tobago": "特立尼达和多巴哥",
506                                "Zimbabwe": "津巴布韦",
507                                "Jordan": "约旦",
508                                "Gambia": "冈比亚",
509                                "Kazakhstan": "哈萨克斯坦",
510                                "Poland": "波兰",
511                                "Eritrea": "厄立特里亚",
512                                "Kyrgyzstan": "吉尔吉斯斯坦",
513                                "Montserrat": "蒙特塞拉特",
514                                "New Caledonia": "新喀里多尼亚",
515                                "Macedonia": "马其顿",
516                                "Paraguay": "巴拉圭",
517                                "Latvia": "拉脱维亚",
518                                "Hungary": "匈牙利",
519                                "Syria": "叙利亚",
520                                "Honduras": "洪都拉斯",
521                                "Myanmar": "缅甸",
522                                "Mexico": "墨西哥",
523                                "Egypt": "埃及",
524                                "Nicaragua": "尼加拉瓜",
525                                "Cuba": "古巴",
526                                "Serbia": "塞尔维亚",
527                                "Comoros": "科摩罗",
528                                "United Kingdom": "英国",
529                                "Fr. S. Antarctic Lands": "南极洲",
530                                "Congo": "刚果(布)",
531                                "Greece": "希腊",
532                                "Sri Lanka": "斯里兰卡",
533                                "Croatia": "克罗地亚",
534                                "Botswana": "博茨瓦纳",
535                                "Siachen Glacier": "锡亚琴冰川地区"
536                        },
537                        roam: false,
538                        label: {
539                          show: false,
540                          color: \'blue\'
541                        },
542                        data: mydata  
543                  }
544                      ]
545                  };
546               
547                  //使用指定的配置项和数据显示图表
548                  myChart.setOption(option);
549                
550                  },
551              error:function(){//处理页面出错以后执行的函数。
552              
553                  }        
554              });
555     }
556 </script>
557 </body>
558 </html>

jsp

 

dao层

  1 package dao;
  2  
  3 import java.sql.Connection;
  4 import java.sql.ResultSet;
  5 import java.sql.SQLException;
  6 import java.sql.Statement;
  7 import java.util.ArrayList;
  8  
  9 import entity.World;
 10 import util.DBUtil;
 11  
 12 public class Dao {
 13  
 14     public ArrayList<World> getconfirmed(String time) {
 15         String sql="select * from world_map where now_time like \'"+time+"%\' ";
 16         System.out.println(time);
 17         Connection con=null;
 18         Statement state=null;
 19         ResultSet rs=null;
 20         boolean flag=false;
 21         con=DBUtil.getConn();
 22         World bean=null;
 23         ArrayList<World> list=new ArrayList<World>();
 24         try {
 25             state=con.createStatement();
 26             rs=state.executeQuery(sql);
 27             while(rs.next())
 28             {
 29                 bean=new World();
 30                 bean.setProvinceName(rs.getString("provinceName"));
 31                 bean.setConfirmedCount(rs.getString("confirmedCount"));
 32                 bean.setSuspectedCount(rs.getString("suspectedCount"));
 33                 bean.setCuredCount(rs.getString("curedCount"));
 34                 bean.setDeadCount(rs.getString("deadCount"));
 35                 //System.out.println(bean.getName()+" "+bean.getConfirmed());
 36                 list.add(bean);
 37             }
 38         } catch (SQLException e) {
 39             // TODO 自动生成的 catch 块
 40             e.printStackTrace();
 41         }
 42         DBUtil.close(rs, state, con);
 43         return list;    
 44     }
 45  
 46     public ArrayList<World> getdead(String time) {
 47         String sql="select * from world_map where now_time like \'"+time+"%\' ORDER BY deadCount desc ";
 48         System.out.println(time);
 49         Connection con=null;
 50         Statement state=null;
 51         ResultSet rs=null;
 52         boolean flag=false;
 53         con=DBUtil.getConn();
 54         World bean=null;
 55         ArrayList<World> list=new ArrayList<World>();
 56         try {
 57             state=con.createStatement();
 58             rs=state.executeQuery(sql);
 59             while(rs.next())
 60             {
 61                 bean=new World();
 62                 bean.setProvinceName(rs.getString("provinceName"));
 63                 bean.setConfirmedCount(rs.getString("confirmedCount"));
 64                 bean.setSuspectedCount(rs.getString("suspectedCount"));
 65                 bean.setCuredCount(rs.getString("curedCount"));
 66                 bean.setDeadCount(rs.getString("deadCount"));
 67                 //System.out.println(bean.getName()+" "+bean.getConfirmed());
 68                 list.add(bean);
 69             }
 70         } catch (SQLException e) {
 71             // TODO 自动生成的 catch 块
 72             e.printStackTrace();
 73         }
 74         DBUtil.close(rs, state, con);
 75         return list;    
 76     }
 77  
 78     public ArrayList<World> getcured(String time) {
 79         String sql="select * from world_map where now_time like \'"+time+"%\' order by curedCount desc ";
 80         System.out.println(time);
 81         Connection con=null;
 82         Statement state=null;
 83         ResultSet rs=null;
 84         boolean flag=false;
 85         con=DBUtil.getConn();
 86         World bean=null;
 87         ArrayList<World> list=new ArrayList<World>();
 88         try {
 89             state=con.createStatement();
 90             rs=state.executeQuery(sql);
 91             while(rs.next())
 92             {
 93                 bean=new World();
 94                 bean.setProvinceName(rs.getString("provinceName"));
 95                 bean.setConfirmedCount(rs.getString("confirmedCount"));
 96                 bean.setSuspectedCount(rs.getString("suspectedCount"));
 97                 bean.setCuredCount(rs.getString("curedCount"));
 98                 bean.setDeadCount(rs.getString("deadCount"));
 99                 //System.out.println(bean.getCuredCount());
100                 list.add(bean);
101             }
102         } catch (SQLException e) {
103             // TODO 自动生成的 catch 块
104             e.printStackTrace();
105         }
106         DBUtil.close(rs, state, con);
107         return list;    
108     }
109  
110     public ArrayList<World> dataconfirmed() {
111         String sql="select * from world_map ";
112         Connection con=null;
113         Statement state=null;
114         ResultSet rs=null;
115         boolean flag=false;
116         con=DBUtil.getConn();
117         World bean=null;
118         int sum=0;
119         int ans=0;
120         String data=null;
121         ArrayList<World> list=new ArrayList<World>();
122         try {
123             state=con.createStatement();
124             rs=state.executeQuery(sql);
125             while(rs.next())
126             {
127                 sum++;
128                 bean=new World();
129                 bean.setProvinceName(rs.getString("now_time"));
130                 if(sum==1)
131                    data=bean.getProvinceName();
132                 bean.setConfirmedCount(rs.getString("confirmedCount"));
133                 if(data.equals(bean.getProvinceName()))
134                    ans+=Integer.parseInt(bean.getConfirmedCount());
135                 else
136                 {
137                    String timeString=data.substring(0,10);
138                    World bean2=new World();
139                    bean2.setProvinceName(timeString);
140                    bean2.setConfirmedCount(String.valueOf(ans));
141                    sum=1;
142                    ans=0;
143                    ans+=Integer.parseInt(bean.getConfirmedCount());
144                    data=bean.getProvinceName();
145                    list.add(bean2);
146                 }
147             }
148             bean.setProvinceName(data.substring(0,10));
149             bean.setConfirmedCount(String.valueOf(ans));
150             list.add(bean);
151         } catch (SQLException e) {
152             // TODO 自动生成的 catch 块
153             e.printStackTrace();
154         }
155         DBUtil.close(rs, state, con);
156         return list;    
157     }
158     public ArrayList<World> allworld(String time) {
159         String sql="select * from world_map where now_time like \'"+time+"%\' ";
160         System.out.println(time);
161         Connection con=null;
162         Statement state=null;
163         ResultSet rs=null;
164         boolean flag=false;
165         con=DBUtil.getConn();
166         World bean=null;
167         ArrayList<World> list=new ArrayList<World>();
168         try {
169             state=con.createStatement();
170             rs=state.executeQuery(sql);
171             while(rs.next())
172             {
173                 bean=new World();
174                 bean.setProvinceName(rs.getString("provinceName"));
175                 bean.setConfirmedCount(rs.getString("confirmedCount"));
176                 bean.setSuspectedCount(rs.getString("suspectedCount"));
177                 bean.setCuredCount(rs.getString("curedCount"));
178                 bean.setDeadCount(rs.getString("deadCount"));
179                 //System.out.println(bean.getName()+" "+bean.getConfirmed());
180                 list.add(bean);
181             }
182         } catch (SQLException e) {
183             // TODO 自动生成的 catch 块
184             e.printStackTrace();
185         }
186         DBUtil.close(rs, state, con);
187         return list;    
188     }
189 }
190 Dao.java
191  

dao

 

显示治愈人数、死亡人数、确诊人数功能

  1 package servlet;
  2  
  3 import java.io.IOException;
  4 import java.util.Date;
  5 import java.text.SimpleDateFormat;
  6 import java.util.ArrayList;
  7  
  8 import javax.servlet.ServletException;
  9 import javax.servlet.annotation.WebServlet;
 10 import javax.servlet.http.HttpServlet;
 11 import javax.servlet.http.HttpServletRequest;
 12 import javax.servlet.http.HttpServletResponse;
 13  
 14 import com.google.gson.Gson;
 15  
 16 import dao.Dao;
 17 import entity.World;
 18  
 19 /**
 20  * Servlet implementation class Getconfirmed
 21  */
 22 @WebServlet("/Getconfirmed")
 23 public class Getconfirmed extends HttpServlet {
 24     private static final long serialVersionUID = 1L;
 25  
 26     /**
 27      * @see HttpServlet#HttpServlet()
 28      */
 29     public Getconfirmed() {
 30         super();
 31         // TODO Auto-generated constructor stub
 32     }
 33  
 34     /**
 35      * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
 36      */
 37     protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
 38         // TODO Auto-generated method stub
 39         Dao dao=new Dao();
 40         request.setCharacterEncoding("utf-8");
 41         Date now = new Date(); 
 42         SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
 43         String Time = dateFormat.format(now);//格式化然后放入字符串中
 44         String data=Time.substring(0,10);
 45         ArrayList<World> list=dao.getconfirmed(data);
 46         Gson gson = new Gson();        
 47         response.setContentType("text/html;charset=utf-8");
 48         String json = gson.toJson(list);
 49         response.getWriter().write(json);
 50         System.out.println(json);
 51     }
 52  
 53     /**
 54      * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
 55      */
 56     protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
 57         // TODO Auto-generated method stub
 58         doGet(request, response);
 59     }
 60  
 61 }
 62 Getconfirmed.java
 63  
 64 package servlet;
 65  
 66 import java.io.IOException;
 67 import java.text.SimpleDateFormat;
 68 import java.util.ArrayList;
 69 import java.util.Date;
 70  
 71 import javax.servlet.ServletException;
 72 import javax.servlet.annotation.WebServlet;
 73 import javax.servlet.http.HttpServlet;
 74 import javax.servlet.http.HttpServletRequest;
 75 import javax.servlet.http.HttpServletResponse;
 76  
 77 import com.google.gson.Gson;
 78  
 79 import dao.Dao;
 80 import entity.World;
 81  
 82 /**
 83  * Servlet implementation class Getcured
 84  */
 85 @WebServlet("/Getcured")
 86 public class Getcured extends HttpServlet {
 87     private static final long serialVersionUID = 1L;
 88  
 89     /**
 90      * @see HttpServlet#HttpServlet()
 91      */
 92     public Getcured() {
 93         super();
 94         // TODO Auto-generated constructor stub
 95     }
 96  
 97     /**
 98      * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
 99      */
100     protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
101         Dao dao =new Dao();
102         request.setCharacterEncoding("utf-8");
103         Date now = new Date(); 
104         SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
105         String Time = dateFormat.format(now);//格式化然后放入字符串中
106         String data=Time.substring(0,10);
107         ArrayList<World> list=dao.getcured(data);
108         Gson gson = new Gson();        
109         response.setContentType("text/html;charset=utf-8");
110         String json = gson.toJson(list);
111         response.getWriter().write(json);
112         System.out.println(json);
113     }
114  
115     /**
116      * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
117      */
118     protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
119         // TODO Auto-generated method stub
120         doGet(request, response);
121     }
122  
123 }
124 Getcured.java
125  
126 package servlet;
127  
128 import java.io.IOException;
129 import java.text.SimpleDateFormat;
130 import java.util.ArrayList;
131 import java.util.Date;
132  
133 import javax.servlet.ServletException;
134 import javax.servlet.annotation.WebServlet;
135 import javax.servlet.http.HttpServlet;
136 import javax.servlet.http.HttpServletRequest;
137 import javax.servlet.http.HttpServletResponse;
138  
139 import com.google.gson.Gson;
140  
141 import dao.Dao;
142 import entity.World;
143  
144 /**
145  * Servlet implementation class GetDead
146  */
147 @WebServlet("/GetDead")
148 public class GetDead extends HttpServlet {
149     private static final long serialVersionUID = 1L;
150  
151     /**
152      * @see HttpServlet#HttpServlet()
153      */
154     public GetDead() {
155         super();
156         // TODO Auto-generated constructor stub
157     }
158  
159     /**
160      * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
161      */
162     protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
163         Dao dao=new Dao();
164         request.setCharacterEncoding("utf-8");
165         Date now = new Date(); 
166         SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
167         String Time = dateFormat.format(now);//格式化然后放入字符串中
168         String data=Time.substring(0,10);
169         ArrayList<World> list=dao.getdead(data);
170         Gson gson = new Gson();        
171         response.setContentType("text/html;charset=utf-8");
172         String json = gson.toJson(list);
173         response.getWriter().write(json);
174         System.out.println(json);
175     }
176  
177     /**
178      * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
179      */
180     protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
181         // TODO Auto-generated method stub
182         doGet(request, response);
183     }
184  
185 }
186 GetDead.java

View Code

 

实现日期控制

 1 package servlet;
 2  
 3 import java.io.IOException;
 4 import java.util.ArrayList;
 5  
 6 import javax.servlet.ServletException;
 7 import javax.servlet.annotation.WebServlet;
 8 import javax.servlet.http.HttpServlet;
 9 import javax.servlet.http.HttpServletRequest;
10 import javax.servlet.http.HttpServletResponse;
11  
12 import com.google.gson.Gson;
13  
14 import dao.Dao;
15 import entity.World;
16  
17 /**
18  * Servlet implementation class Dataconfirmed
19  */
20 @WebServlet("/Dataconfirmed")
21 public class Dataconfirmed extends HttpServlet {
22     private static final long serialVersionUID = 1L;
23        
24     /**
25      * @see HttpServlet#HttpServlet()
26      */
27     public Dataconfirmed() {
28         super();
29         // TODO Auto-generated constructor stub
30     }
31  
32     /**
33      * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
34      */
35     protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
36         Dao dao =new Dao();
37         request.setCharacterEncoding("utf-8");
38         ArrayList<World> list=dao.dataconfirmed();
39         Gson gson = new Gson();        
40         response.setContentType("text/html;charset=utf-8");
41         String json = gson.toJson(list);
42         response.getWriter().write(json);
43         System.out.println("日期变化曲线!");
44         System.out.println(json);
45     }
46  
47     /**
48      * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
49      */
50     protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
51         // TODO Auto-generated method stub
52         doGet(request, response);
53     }
54  
55 }
56 Dataconfirmed.java

View Code

 

具体实现

 1 import json
 2  
 3 import pymysql
 4 import requests
 5 from bs4 import BeautifulSoup
 6 import datetime
 7  
 8 url = \'https://ncov.dxy.cn/ncovh5/view/pneumonia?from=timeline&isappinstalled=0\'  # 请求地址
 9 headers = {
10     \'user-agent\': \'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36\'}  # 创建头部信息
11 response = requests.get(url, headers=headers)  # 发送网络请求
12 content = response.content.decode(\'utf-8\')
13 soup = BeautifulSoup(content, \'html.parser\')
14  
15 # 世界确诊getAreaStat
16 listB = soup.find_all(name=\'script\', attrs={"id": "getListByCountryTypeService2true"})
17  
18 world_messages = str(listB)[95:-21]
19  
20 print(world_messages)
21 world_messages_json = json.loads(world_messages)
22 worldList = []
23 now_time = datetime.datetime.now().strftime(\'%Y-%m-%d\')
24  
25 for k in range(len(world_messages_json)):
26     worldvalue = (now_time,
27                   world_messages_json[k].get(\'countryType\'), world_messages_json[k].get(\'continents\'),
28                   world_messages_json[k].get(\'provinceId\'), world_messages_json[k].get(\'provinceName\'),
29                   world_messages_json[k].get(\'provinceShortName\'), world_messages_json[k].get(\'cityName\'),
30                   world_messages_json[k].get(\'currentConfirmedCount\'), world_messages_json[k].get(\'confirmedCount\'),
31                   world_messages_json[k].get(\'suspectedCount\'), world_messages_json[k].get(\'curedCount\'),
32                   world_messages_json[k].get(\'deadCount\'), world_messages_json[k].get(\'locationId\'),
33                   world_messages_json[k].get(\'countryShortCode\'),)
34     worldList.append(worldvalue)
35  
36 db = pymysql.connect("localhost", "root", "0000", "yiqing", charset=\'utf8\')
37 cursor = db.cursor()
38  
39 sql_world = "INSERT INTO world_map values (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
40  
41 worldTuple = tuple(worldList)
42 print(worldTuple)
43  
44 try:
45     cursor.executemany(sql_world, worldTuple)
46     db.commit()
47 except:
48     print(\'执行失败,进入回调2\')
49     db.rollback()
50  
51 db.close()

View Code

 

5系统使用说明书

  首先进入系统

        

需要先进行注册:

        

  提示注册成功:

        

  使用刚刚注册的用户名密码就可登陆:

    

  登录成功即进入如下界面即可实时查询:

       

 我在这插入了一个操作小视频,也不知道为啥不可以显示

      

6 参考资料

    [1] https://3g.163.com/news/article_cambrian/FBCUAKGF0521C9T8.html

    [2] http://www.jingji.com.cn/shtml/jr/gdxw/110702.html

    [3] https://article.itxueyuan.com/666gJq

    [4] https://www.arcgis.com/apps/opsdashboard/index.html#/bda7594740fd40299423467b48e9ecf6

    [5] https://www.esri.com/en-us/disaster-response/request-assistance

    [6] 参考博文:https://www.cnblogs.com/dd110343/p/12404756.html 

    [7] 参考博文: https://www.cnblogs.com/dd110343/p/12461824.html

 

7 附件说明

  本文档要求的附件资料均压缩在“疫情统计图”压缩文件里。

  Eclipse版本是2019

  Python需导入的库有:pymysql、 requests、bs4

  可执行文件“疫情统计图”将其解压就可运行,为了方便我把Python文件也放进去了,运行时吧Python文件单独出来就可

  数据库需要后台建立才可完整运行。

  项目源代码也均在压缩包里

 

 

 

注:其实地图可以没有必要有登录注册的,毕竟是人人可看的东西,但此处为了使系统完善强行加入了,登录界面也比较丑。

版权声明:本文为ynly原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/ynly/p/12844998.html