# 页面效果
![](https://www.writebug.com/myres/static/uploads/2021/12/29/f4864298618c99fd9d06519e1cb4fc40.writebug)
# 项目准备
## 所用技术
springboot+mybatis+echarts+webmagic
## 实现过程
用 webmagic 爬取腾讯,百度疫情网站,获取数据
将返回的数据存储在 MySQL 中
编写业务,在 controller 中调用业务
用 AJAX 获取 controller 传来的数据
## 环境和软件
JDK1.8 ,IntelliJ IDEA 2020.1 x64, MySQL 5.5.40,node.js v12.16.2 ,Maven
## 依赖
```
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.2.RELEASE</version>
</parent>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.12</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.9.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>com.huaban</groupId>
<artifactId>jieba-analysis</artifactId>
<version>1.0.2</version>
</dependency>
<!--SpringMVC-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>us.codecraft</groupId>
<artifactId>webmagic-core</artifactId>
<version>0.7.3</version>
</dependency>
<dependency>
<groupId>us.codecraft</groupId>
<artifactId>webmagic-extension</artifactId>
<version>0.7.3</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
</dependencies>
```
## 数据库搭建
```
# 详情信息
CREATE TABLE `details` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`update_time` varchar(50) DEFAULT NULL COMMENT '数据最后更新时间',
`province` varchar(50) DEFAULT NULL COMMENT '省',
`city` varchar(50) DEFAULT NULL COMMENT '市',
`confirm` int(11) DEFAULT NULL COMMENT '累计确诊',
`confirm_add` int(11) DEFAULT NULL COMMENT '新增确诊',
`heal` int(11) DEFAULT NULL COMMENT '累计治愈',
`dead` int(11) DEFAULT NULL COMMENT '累计死亡',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1826 DEFAULT CHARSET=utf8mb4
```
```
# 历史信息
CREATE TABLE `history` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`ds` varchar(50) NOT NULL COMMENT '日期',
`confirm` int(11) DEFAULT NULL COMMENT '累计确诊',
`confirm_add` int(11) DEFAULT NULL COMMENT '当日新增确诊',
`suspect` int(11) DEFAULT NULL COMMENT '剩余疑似',
`suspect_add` int(11) DEFAULT NULL COMMENT '当日新增疑似',
`heal` int(11) DEFAULT NULL COMMENT '累计治愈',
`heal_add` int(11) DEFAULT NULL COMMENT '今日新增治愈',
`dead` int(11) DEFAULT NULL COMMENT '累计死亡',
`dead_add` int(11) DEFAULT NULL COMMENT '当日新增死亡',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=108 DEFAULT CHARSET=utf8mb4
```
```sql
# 热搜
Create Table
CREATE TABLE `hot` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`dt` varchar(50) DEFAULT NULL,
`content` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1085 DEFAULT CHARSET=utf8mb4
```
## 爬虫源网址
在项目中
## Application 配置类
```
DB Configuration:
spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/pro?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8
spring.datasource.username=root
spring.datasource.password=root
mybatis.type-aliases-package=CR553.Pojo
mybatis.mapper-locations=classpath:Mapper/*.xml
server.port=8088
//关闭缓存
spring.thymeleaf.cache=false
```
## POJO,Mapper,Service
没啥特别的,基本的 crud,直接上代码
POJO
```java
@Data//依赖于lombok
@AllArgsConstructor
@NoArgsConstructor
public class Details {
private Long id;
private String update_time; //更新时间
private String province; //省
private String city; //市
private Long confirm; //累计确诊
private Long confirm_add; //今日新增确诊
private Long heal; //治愈
private Long dead; //死亡
}
```
```java
@Data
@NoArgsConstructor
@AllArgsConstructor
public class History {
private Long id;
private String ds; //日期
private Long confirm;//累计确诊
private Long confirm_add;//今日累计确诊
private Long suspect;//疑似
private Long suspect_add;//今日新增疑似
private Long heal;//治愈
private Long heal_add;//当日新增治愈
private Long dead;//死亡
private Long dead_add;//今日新增死亡
}
```
```java
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Hot {
private Long id;
private String content;
private String dt;
}
```
mapper
```
@Mapper
public interface DetailsMapper {
//存储
void saveDetails(Details details);
//更新
void updateDetails(Details details);
//查找(省份和市名相同的)
List<Details> findDetails(Details details);
//查找省
List<String> findProvince();
//查找每个省的确诊人数
List<Integer> findProvinceValue();
//查找城市
List<String> findCity();
//查找每个城市的确诊人数
List<Long> findCityValue();
}
```
```
@Mapper
public interface HistoryMapper {
//保存
void saveHistory(History history);
//更新
void updateHistory(History history);
//查找 日期相同的
List<History> findHistory(History history);
//查找今日数据
History findToday();
//返回每天历史累计数据
List<History> findEachDayTotal();
//返回每天历史增加数据
List<History> findEachDayAdd();
}
```
```
@Mapper
public interface HotMapper {
//保存
void saveHot(Hot hot);
List<Hot> findTopHot20();
}
```
serviceImp
```
@Service
public class DetailsServiceImpl implements DetailsService {
@Autowired
private DetailsMapper detailsMapper;
//查找并更新
@Override
public void saveDetails(Details details) {
List<Details> list = this.findDetails(details);
if (list.size() == 0) {
//没查到,新增
this.detailsMapper.saveDetails(details);
}else
{
//查到了,修改
this.detailsMapper.updateDetails(details);
}
}
@Override
public void updateDetails(Details details) {
this.updateDetails(details);
}
@Override
public
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
实现过程 用webmagic获取数据 将返回的数据存储在mysql中 编写业务,在controller中调用业务 用ajax获取controller传来的数据 环境和软件 JDK1.8 ,IntelliJ IDEA 2020.1 x64, MySQL 5.5.40,node.js v12.16.2 ,Maven
资源推荐
资源详情
资源评论
收起资源包目录
100012183-基于Java+MySQL实现疫情数据可视化网站.zip (94个子文件)
epidemicdata-visualization
pom.xml 3KB
.gitattributes 87B
src
test
java
Test
Mtest.java 5KB
main
resources
Application.properties 417B
templates
index.html 2KB
Mapper
HotMapper.xml 469B
DetailsMapper.xml 2KB
HistoryMapper.xml 1KB
static
js
ec_center.js 3KB
ec_right1.js 753B
dark.js 4KB
ec_left1.js 2KB
china.js 136KB
ec_right2.js 1KB
echarts.min.js 727KB
echarts-wordcloud.min.js 125KB
controller.js 3KB
ec_left2.js 2KB
jquery.js 82KB
css
main.css 1KB
java
CR553
Application.java 380B
controller
IndexController.java 5KB
Task
DetailsProcesser.java 4KB
NewsSpringDataPipeline.java 801B
HistorySpringDataPipeline.java 854B
NewsProcesser.java 3KB
HistoryProcesser.java 4KB
DetailsSpringDataPipeline.java 841B
Mapper
DetailsMapper.java 609B
HotMapper.java 230B
HistoryMapper.java 552B
Service
HistoryService.java 119B
HotService.java 108B
DetailsService.java 119B
impl
HistoryServiceImpl.java 1KB
HotServiceImpl.java 562B
DetailsServiceImpl.java 2KB
Pojo
Hot.java 248B
History.java 562B
Details.java 469B
LICENSE 1KB
out
artifacts
project_innovation_jar
project_innovation.jar 53.96MB
.idea
jarRepositories.xml 845B
uiDesigner.xml 9KB
artifacts
project_innovation_jar.xml 18KB
misc.xml 513B
compiler.xml 779B
.gitignore 176B
encodings.xml 308B
target
classes
Application.properties 417B
templates
index.html 2KB
Mapper
HotMapper.xml 469B
DetailsMapper.xml 2KB
HistoryMapper.xml 1KB
static
js
ec_center.js 3KB
ec_right1.js 753B
dark.js 4KB
ec_left1.js 2KB
china.js 136KB
ec_right2.js 1KB
echarts.min.js 727KB
echarts-wordcloud.min.js 125KB
controller.js 3KB
ec_left2.js 2KB
jquery.js 82KB
css
main.css 1KB
CR553
Application.class 766B
controller
IndexController.class 6KB
Task
NewsProcesser.class 5KB
DetailsProcesser.class 5KB
HistorySpringDataPipeline.class 2KB
NewsSpringDataPipeline.class 2KB
DetailsSpringDataPipeline.class 2KB
HistoryProcesser.class 5KB
Mapper
HistoryMapper.class 658B
HotMapper.class 372B
DetailsMapper.class 750B
Service
DetailsService.class 157B
HistoryService.class 157B
HotService.class 145B
impl
HotServiceImpl.class 925B
HistoryServiceImpl.class 2KB
DetailsServiceImpl.class 2KB
Pojo
Details.class 5KB
Hot.class 2KB
History.class 6KB
test-classes
Test
Mtest.class 6KB
maven-status
maven-compiler-plugin
compile
default-compile
createdFiles.lst 0B
inputFiles.lst 1KB
testCompile
default-testCompile
inputFiles.lst 0B
project_innovation-1.0-SNAPSHOT.jar 19KB
maven-archiver
pom.properties 102B
project_innovation.iml 80B
README.md 19KB
共 94 条
- 1
资源评论
- 白禁811922023-06-19感谢资源主的分享,这个资源对我来说很有用,内容描述详尽,值得借鉴。
神仙别闹
- 粉丝: 2667
- 资源: 7640
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 使用 C 语言实现的计算非负整数的阶乘
- 2011-2021最新版本北京大学数字普惠金融指数(PKU-DFIIC).xlsx
- 县域数字乡村指数2018-2020(1).xlsx
- Docker容器配置进阶
- tensorflow-gpu-2.7.4-cp37-cp37m-manylinux2010-x86-64.whl
- 多段线、 圆、弧转多段线(仅我可见)
- tensorflow-2.7.2-cp38-cp38-manylinux2010-x86-64.whl
- 李慧琴C语言基础部分.zip
- yeyue-p8Yi4-ve4a83792.apk
- tensorflow-gpu-2.7.3-cp38-cp38-manylinux2010-x86-64.whl
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功