first commit

peishitong_branch
SHITONGPEI 1 year ago
parent 4d8b31843f
commit 5c9ba62488

38
.gitignore vendored

@ -0,0 +1,38 @@
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store

8
.idea/.gitignore vendored

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
</component>
</project>

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

@ -0,0 +1,118 @@
/*
* Copyright 2007-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.net.*;
import java.io.*;
import java.nio.channels.*;
import java.util.Properties;
public class MavenWrapperDownloader {
private static final String WRAPPER_VERSION = "0.5.6";
/**
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
*/
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
/**
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
* use instead of the default one.
*/
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
".mvn/wrapper/maven-wrapper.properties";
/**
* Path where the maven-wrapper.jar will be saved to.
*/
private static final String MAVEN_WRAPPER_JAR_PATH =
".mvn/wrapper/maven-wrapper.jar";
/**
* Name of the property which should be used to override the default download url for the wrapper.
*/
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
public static void main(String args[]) {
System.out.println("- Downloader started");
File baseDirectory = new File(args[0]);
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
// If the maven-wrapper.properties exists, read it and check if it contains a custom
// wrapperUrl parameter.
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
String url = DEFAULT_DOWNLOAD_URL;
if (mavenWrapperPropertyFile.exists()) {
FileInputStream mavenWrapperPropertyFileInputStream = null;
try {
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
Properties mavenWrapperProperties = new Properties();
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
} catch (IOException e) {
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
} finally {
try {
if (mavenWrapperPropertyFileInputStream != null) {
mavenWrapperPropertyFileInputStream.close();
}
} catch (IOException e) {
// Ignore ...
}
}
}
System.out.println("- Downloading from: " + url);
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
if (!outputFile.getParentFile().exists()) {
if (!outputFile.getParentFile().mkdirs()) {
System.out.println(
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
}
}
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
try {
downloadFileFromURL(url, outputFile);
System.out.println("Done");
System.exit(0);
} catch (Throwable e) {
System.out.println("- Error downloading");
e.printStackTrace();
System.exit(1);
}
}
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
String username = System.getenv("MVNW_USERNAME");
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
}
URL website = new URL(urlString);
ReadableByteChannel rbc;
rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream(destination);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
fos.close();
rbc.close();
}
}

Binary file not shown.

@ -0,0 +1,2 @@
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar

@ -0,0 +1,96 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.liu</groupId>
<artifactId>covid</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>covid</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<spring-boot.version>2.2.2.RELEASE</spring-boot.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.4.2</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.3.7.RELEASE</version>
<configuration>
<mainClass>com.liu.covid.CovidApplication</mainClass>
</configuration>
<executions>
<execution>
<id>repackage</id>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

@ -0,0 +1,17 @@
create table department
(
id int not null
primary key,
name varchar(20) null,
charge varchar(20) null
);
create index name
on department (name);
INSERT INTO covid.department (id, name, charge) VALUES (1, '财务部', '王刚');
INSERT INTO covid.department (id, name, charge) VALUES (2, '人力资源部', '李师');
INSERT INTO covid.department (id, name, charge) VALUES (3, '后勤部', '王二霞');
INSERT INTO covid.department (id, name, charge) VALUES (4, '客服部', '刘晓华');
INSERT INTO covid.department (id, name, charge) VALUES (5, '研发部', '李海红');
INSERT INTO covid.department (id, name, charge) VALUES (6, '技术部', '刘苏哈');

@ -0,0 +1,28 @@
create table emp_health
(
id int(10) auto_increment
primary key,
name varchar(20) null,
sex int(1) null,
phonenum bigint null,
temp float(4, 1) null,
risk varchar(30) null,
health varchar(30) null,
content varchar(255) null,
createTime datetime null,
depart varchar(30) null,
constraint de
foreign key (depart) references department (name)
);
INSERT INTO covid.emp_health (id, name, sex, phonenum, temp, risk, health, content, createTime, depart) VALUES (2, '刘先生', 1, 15143355464, 36.5, '', '正常', '', '2021-03-31 14:03:52', '后勤部');
INSERT INTO covid.emp_health (id, name, sex, phonenum, temp, risk, health, content, createTime, depart) VALUES (3, '吴雷师', 0, 15151549751, 37, '', '正常', '', '2021-03-13 20:16:30', '客服部');
INSERT INTO covid.emp_health (id, name, sex, phonenum, temp, risk, health, content, createTime, depart) VALUES (4, '刘腾键', 1, 13415135795, 36.5, '', '正常', '', '2021-03-13 19:54:40', '客服部');
INSERT INTO covid.emp_health (id, name, sex, phonenum, temp, risk, health, content, createTime, depart) VALUES (5, '刘腾键', 1, 13415135795, 36.5, '', '感冒', '', '2021-03-13 19:54:40', '研发部');
INSERT INTO covid.emp_health (id, name, sex, phonenum, temp, risk, health, content, createTime, depart) VALUES (6, '刘胜虎', 1, 123414234123, 39, '', '低烧', '', '2021-04-05 22:41:39', '技术部');
INSERT INTO covid.emp_health (id, name, sex, phonenum, temp, risk, health, content, createTime, depart) VALUES (7, '王继红', 0, 13513534534, 38, '', '与新冠肺炎有关的其他症状,如流涕,咽痛,肌痛,腹泻等', '', '2021-04-06 13:39:38', '客服部');
INSERT INTO covid.emp_health (id, name, sex, phonenum, temp, risk, health, content, createTime, depart) VALUES (8, '刘小姐', 1, 231123123, 23, '', '呼吸困难', '', '2021-04-06 15:34:42', '后勤部');
INSERT INTO covid.emp_health (id, name, sex, phonenum, temp, risk, health, content, createTime, depart) VALUES (9, '111', 1, 111111111, 11, '111', '正常', '11', '2021-04-10 16:03:01', '研发部');
INSERT INTO covid.emp_health (id, name, sex, phonenum, temp, risk, health, content, createTime, depart) VALUES (10, '刘渲', 1, 13514124567, 37, '', '正常', '', '2021-04-15 14:29:15', '后勤部');
INSERT INTO covid.emp_health (id, name, sex, phonenum, temp, risk, health, content, createTime, depart) VALUES (11, '王佳', 0, 13512314534, 37.5, '', '正常', '', '2021-04-15 14:42:55', '人力资源部');
INSERT INTO covid.emp_health (id, name, sex, phonenum, temp, risk, health, content, createTime, depart) VALUES (12, '刘腾键', 1, 13512365456, 36.5, '', '乏力', '', '2021-04-15 14:46:49', '技术部');

@ -0,0 +1,28 @@
create table emp_iden
(
id bigint auto_increment
primary key,
name varchar(10) null,
sex int(2) null,
idcard varchar(20) null,
idate date null,
place varchar(100) null,
phonenum bigint(100) null,
register datetime null,
status varchar(10) null,
depart varchar(20) null,
constraint emp_iden_ibfk_1
foreign key (depart) references department (name)
on update cascade on delete cascade
);
INSERT INTO covid.emp_iden (id, name, sex, idcard, idate, place, phonenum, register, status, depart) VALUES (1, '李先生', 1, '440524196002152100', '2020-11-13', '广州市第一附属医院', 13457896457, '2020-11-14 15:31:44', '确诊', '财务部');
INSERT INTO covid.emp_iden (id, name, sex, idcard, idate, place, phonenum, register, status, depart) VALUES (2, '蔡二思', 1, '440634199004050312', '2021-03-22', '深圳市福田区第一医院', null, '2021-03-03 11:33:31', '确诊', '财务部');
INSERT INTO covid.emp_iden (id, name, sex, idcard, idate, place, phonenum, register, status, depart) VALUES (3, '王金枝', 0, null, '2021-02-01', '深圳市福田区第一医院', null, null, '疑似', '后勤部');
INSERT INTO covid.emp_iden (id, name, sex, idcard, idate, place, phonenum, register, status, depart) VALUES (4, '季王红', 0, '440578199505150547', '2021-03-02', '佛山市三水人民医院', 13411234457, null, '治愈', null);
INSERT INTO covid.emp_iden (id, name, sex, idcard, idate, place, phonenum, register, status, depart) VALUES (5, '李王思', 1, '440578199902150351', '2021-01-07', '佛山市三水人民医院', 13453456785, '2021-04-06 16:05:11', '疑似', '人力资源部');
INSERT INTO covid.emp_iden (id, name, sex, idcard, idate, place, phonenum, register, status, depart) VALUES (6, '王二会', 1, '440582198005040800', '2021-02-19', '深圳市中心医院', 13457891231, '2020-04-09 16:22:26', '疑似', '后勤部');
INSERT INTO covid.emp_iden (id, name, sex, idcard, idate, place, phonenum, register, status, depart) VALUES (7, '于雪师', 1, '440578198905213551', '2020-12-12', '深圳市中心医院', 1581456785, '2021-04-06 16:05:11', '死亡', '人力资源部');
INSERT INTO covid.emp_iden (id, name, sex, idcard, idate, place, phonenum, register, status, depart) VALUES (10, '阿斯顿', 0, null, '2021-04-01', '汕头市李嘉诚医院', 13531342457, '2021-04-02 14:49:15', '治愈', '财务部');
INSERT INTO covid.emp_iden (id, name, sex, idcard, idate, place, phonenum, register, status, depart) VALUES (11, '士大夫', 0, '34124', '2021-03-31', '广州市暨南大学第一附属医院', 13411213257, '2021-04-02 14:49:32', '死亡', '客服部');
INSERT INTO covid.emp_iden (id, name, sex, idcard, idate, place, phonenum, register, status, depart) VALUES (12, '吴开师', 1, '440578199807050321', '2021-03-18', '佛山市三水人民医院', 13412823457, '2021-04-06 16:05:11', '疑似', '人力资源部');

@ -0,0 +1,24 @@
create table emp_is
(
id bigint auto_increment
primary key,
name varchar(20) null,
sex int(3) null,
phone bigint null,
temp float(10, 2) null,
type varchar(10) null,
place varchar(100) null,
begin datetime null,
end datetime null,
leaved varchar(100) null,
arrived varchar(100) null,
content varchar(255) null,
depart varchar(20) null,
constraint dep
foreign key (depart) references department (name)
);
INSERT INTO covid.emp_is (id, name, sex, phone, temp, type, place, begin, end, leaved, arrived, content, depart) VALUES (1, '黎香湖', 0, 12341231231, 35, '酒店隔离', '广州市广州南站如家酒店', '2021-04-06 00:00:00', '2021-04-20 00:00:00', '广东汕头', '广东东莞', null, '人力资源部');
INSERT INTO covid.emp_is (id, name, sex, phone, temp, type, place, begin, end, leaved, arrived, content, depart) VALUES (2, '王老二', 1, 13545479653, 38.5, '酒店集中隔离', '广州市火车站快捷酒店', '2021-04-14 00:00:00', '2021-04-28 00:00:00', '广东汕头', '广东东莞', '', '后勤部');
INSERT INTO covid.emp_is (id, name, sex, phone, temp, type, place, begin, end, leaved, arrived, content, depart) VALUES (3, '蔡司', 1, 13452342356, 36.6, '酒店集中隔离', '深圳市宝安区平和小区', '2020-11-23 00:00:00', '2020-12-07 00:00:00', '重庆市', '湖南长沙', '', '研发部');
INSERT INTO covid.emp_is (id, name, sex, phone, temp, type, place, begin, end, leaved, arrived, content, depart) VALUES (5, '蔡司', 1, 13452342356, 35.6, '居家隔离', '深圳市宝安区平和小区', '2021-01-09 00:00:00', '2021-01-23 00:00:00', '重庆市', '湖南长沙', '', '研发部');

@ -0,0 +1,19 @@
create table material_manage
(
id int(20) auto_increment
primary key,
name varchar(255) null,
count int null,
type varchar(255) null,
isImp int null,
charge varchar(255) null,
cnum bigint null,
updateTime datetime null
);
INSERT INTO covid.material_manage (id, name, count, type, isImp, charge, cnum, updateTime) VALUES (113, 'KN94口罩', 150, '', 1, '孙迪', 13415135777, '2021-03-31 13:54:36');
INSERT INTO covid.material_manage (id, name, count, type, isImp, charge, cnum, updateTime) VALUES (114, 'N95口罩', 220, '', 1, '孙迪', 13415135777, '2021-04-06 16:14:45');
INSERT INTO covid.material_manage (id, name, count, type, isImp, charge, cnum, updateTime) VALUES (123, '防护服', 30, '', 1, '王旭', 15148796568, '2021-04-22 14:21:56');
INSERT INTO covid.material_manage (id, name, count, type, isImp, charge, cnum, updateTime) VALUES (125, '酒精消毒棉片', 200, '', 1, '李建', 13431357964, '2021-03-31 13:54:06');
INSERT INTO covid.material_manage (id, name, count, type, isImp, charge, cnum, updateTime) VALUES (126, '抽纸纸巾', 20, '', 0, '李玉', 13534654675, '2021-04-22 19:29:30');
INSERT INTO covid.material_manage (id, name, count, type, isImp, charge, cnum, updateTime) VALUES (133, '防护眼罩', 30, '', 1, '杨迪', 123123123123, '2021-04-23 17:00:52');

@ -0,0 +1,12 @@
create table user
(
id int auto_increment
primary key,
username varchar(20) null,
password varchar(255) null,
depart varchar(20) null
);
INSERT INTO covid.user (id, username, password, depart) VALUES (1, 'admin', 'e10adc3949ba59abbe56e057f20f883e', '人力资源部');
INSERT INTO covid.user (id, username, password, depart) VALUES (3, 'root', 'e10adc3949ba59abbe56e057f20f883e', '后勤部');
INSERT INTO covid.user (id, username, password, depart) VALUES (12, '994091246', 'd7d7b53081e1e3ecbd28c30c34b4bcd3', '技术部');

@ -0,0 +1,14 @@
package com.liu.covid;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
@MapperScan("com.liu.covid.mapper")
public class CovidApplication {
public static void main(String[] args) {
SpringApplication.run(CovidApplication.class, args);
}
}

@ -0,0 +1,19 @@
package com.liu.covid.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class CrosConfig implements WebMvcConfigurer {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins("*")
.allowedMethods("GET","HEAD","POST","PUT","DELETE","OPTIONS")
.allowCredentials(true)
.maxAge(3600)
.allowedHeaders("*");
}
}

@ -0,0 +1,18 @@
package com.liu.covid.config;
import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class MybatisPlusConfig {
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
return interceptor;
}
}

@ -0,0 +1,26 @@
package com.liu.covid.controller;
import com.liu.covid.entity.Department;
import com.liu.covid.mapper.DepartMapper;
import com.liu.covid.service.DepartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
@RestController
@RequestMapping("/depart")
public class DepartController {
@Autowired
DepartService service;
@GetMapping("/findAll")
private List<String> findAll(){
return service.getAll();
}
}

@ -0,0 +1,66 @@
package com.liu.covid.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.liu.covid.entity.EmpHealth;
import com.liu.covid.mapper.EmpMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/emp")
public class EmpController {
@Autowired
private EmpMapper mapper;
//分页查询
@GetMapping("/findAll/{page}/{size}")
public Page<EmpHealth> findAll(@PathVariable("page") Integer page, @PathVariable("size") Integer size){
QueryWrapper<EmpHealth> wrapper=new QueryWrapper<>();
wrapper.orderByDesc("createTime");
Page<EmpHealth> page1= new Page<>(page,size);
Page<EmpHealth> result=mapper.selectPage(page1,wrapper).addOrder();
return result;
}
@PostMapping("/save")
public String save(@RequestBody EmpHealth emp){
int result = mapper.insert(emp);
if (result==1){
return "success";
}else {
return "error";
}
}
@GetMapping("/findById/{id}")
public EmpHealth findById(@PathVariable("id") Integer id){
return mapper.selectById(id);
}
@PutMapping("/update")
public String update(@RequestBody EmpHealth emp){
int result=mapper.updateById(emp);
if (result==1){
return "success";
}else {
return "error";
}
}
@DeleteMapping("/deleteById/{id}")
public void deleteById(@PathVariable("id")Long id){
mapper.deleteById(id+"L");
}
@GetMapping("/search/{searchkey}/{stext}")
public List<EmpHealth> search(@PathVariable("searchkey")String searchkey, @PathVariable("stext")String stext){
QueryWrapper<EmpHealth> userQueryWrapper = Wrappers.query();
userQueryWrapper.like(searchkey,stext);
return mapper.selectList(userQueryWrapper);
}
}

@ -0,0 +1,81 @@
package com.liu.covid.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.liu.covid.entity.EmpIden;
import com.liu.covid.mapper.EmpIdenMapper;
import com.liu.covid.service.ChartService;
import com.liu.covid.vo.LineVO;
import com.liu.covid.vo.PieVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/empiden")
public class EmpIdenController {
@Autowired
private ChartService chartService;
@Autowired
private EmpIdenMapper mapper;
//分页查询
@GetMapping("/findAll/{page}/{size}")
public Page<EmpIden> findAll(@PathVariable("page") Integer page, @PathVariable("size") Integer size){
Page<EmpIden> page1= new Page<>(page,size);
Page<EmpIden> result=mapper.selectPage(page1,null);
return result;
}
@PostMapping("/save")
public String save(@RequestBody EmpIden empIden){
int result = mapper.insert(empIden);
if (result==1){
return "success";
}else {
return "error";
}
}
@GetMapping("/LineVO")
public LineVO getLineVO(){
return this.chartService.lineVOList();
}
@GetMapping("/PieVO")
public List<PieVo> getPieVO(){
return this.chartService.pieVOMap();
}
@GetMapping("/findById/{id}")
public EmpIden findById(@PathVariable("id") Integer id){
return mapper.selectById(id);
}
@PutMapping("/update")
public String update(@RequestBody EmpIden empIden){
int result=mapper.updateById(empIden);
if (result==1){
return "success";
}else {
return "error";
}
}
@DeleteMapping("/deleteById/{id}")
public void deleteById(@PathVariable("id")Long id){
mapper.deleteById(id+"L");
}
@GetMapping("/search/{searchkey}/{stext}")
public List<EmpIden> search(@PathVariable("searchkey")String searchkey, @PathVariable("stext")String stext){
QueryWrapper<EmpIden> userQueryWrapper = Wrappers.query();
userQueryWrapper.like(searchkey,stext);
return mapper.selectList(userQueryWrapper);
}
}

@ -0,0 +1,81 @@
package com.liu.covid.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.liu.covid.entity.EmpIs;
import com.liu.covid.mapper.EmpIsMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.text.Format;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
@RestController
@RequestMapping("/empis")
public class EmpIsController {
@Autowired
private EmpIsMapper mapper;
//分页查询
@GetMapping("/findAll/{page}/{size}")
public Page<EmpIs> findAll(@PathVariable("page") Integer page, @PathVariable("size") Integer size){
Page<EmpIs> page1= new Page<>(page,size);
Page<EmpIs> result=mapper.selectPage(page1,null);
return result;
}
@PostMapping("/save")
public String save(@RequestBody EmpIs empis){
Format f = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
c.setTime(empis.getBegin());
c.add(Calendar.DAY_OF_MONTH, 14);
Date end = c.getTime();
empis.setEnd(end);
int result = mapper.insert(empis);
if (result==1){
return "success";
}else {
return "error";
}
}
@GetMapping("/findById/{id}")
public EmpIs findById(@PathVariable("id") Integer id){
return mapper.selectById(id);
}
@PutMapping("/update")
public String update(@RequestBody EmpIs empis){
Format f = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
c.setTime(empis.getBegin());
c.add(Calendar.DAY_OF_MONTH, 14);
Date end = c.getTime();
empis.setEnd(end);
int result=mapper.updateById(empis);
if (result==1){
return "success";
}else {
return "error";
}
}
@DeleteMapping("/deleteById/{id}")
public void deleteById(@PathVariable("id")Long id){
mapper.deleteById(id+"L");
}
@GetMapping("/search/{searchkey}/{stext}")
public List<EmpIs> search(@PathVariable("searchkey")String searchkey, @PathVariable("stext")String stext){
QueryWrapper<EmpIs> userQueryWrapper = Wrappers.query();
userQueryWrapper.like(searchkey,stext);
return mapper.selectList(userQueryWrapper);
}
}

@ -0,0 +1,27 @@
package com.liu.covid.controller;
import com.liu.covid.entity.User;
import com.liu.covid.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/userlogin")
public class LoginController {
@Autowired
UserService userService;
@PostMapping("/user")
public String login(@RequestBody User loginform){
String message=userService.login(loginform);
return message;
}
@PostMapping("/register")
public String register(@RequestBody User reUser){
String message=userService.register(reUser);
return message;
}
}

@ -0,0 +1,65 @@
package com.liu.covid.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.liu.covid.entity.EmpIs;
import com.liu.covid.entity.MaterialManage;
import com.liu.covid.mapper.MaterialMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/Material")
public class MaterialController {
@Autowired
private MaterialMapper mapper;
//分页查询
@GetMapping("/findAll/{page}/{size}")
public Page<MaterialManage> findAll(@PathVariable("page") Integer page, @PathVariable("size") Integer size){
Page<MaterialManage> page1= new Page<>(page,size);
Page<MaterialManage> result=mapper.selectPage(page1,null);
return result;
}
@PostMapping("/save")
public String save(@RequestBody MaterialManage material){
int result = mapper.insert(material);
if (result==1){
return "success";
}else {
return "error";
}
}
@GetMapping("/findById/{id}")
public MaterialManage findById(@PathVariable("id") Integer id){
return mapper.selectById(id);
}
@PutMapping("/update")
public String update(@RequestBody MaterialManage material){
int result=mapper.updateById(material);
if (result==1){
return "success";
}else {
return "error";
}
}
@DeleteMapping("/deleteById/{id}")
public void deleteById(@PathVariable("id")Long id){
mapper.deleteById(id+"L");
}
@GetMapping("/search/{searchkey}/{stext}")
public List<MaterialManage> search(@PathVariable("searchkey")String searchkey, @PathVariable("stext")String stext){
QueryWrapper<MaterialManage> userQueryWrapper = Wrappers.query();
userQueryWrapper.like(searchkey,stext);
return mapper.selectList(userQueryWrapper);
}
}

@ -0,0 +1,13 @@
package com.liu.covid.entity;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
@Data
public class Department {
@TableId
private Integer id;
private String name;
private String charge;
}

@ -0,0 +1,29 @@
package com.liu.covid.entity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.liu.covid.entity.Enum.GenderEnum;
import lombok.Data;
import java.util.Date;
@Data
public class EmpHealth {
@TableId(type = IdType.AUTO)
private Long id;
private String name;
private GenderEnum sex;
private Long phonenum;
private float temp;
private String risk;
private String health;
private String content;
private String depart;
@TableField(value = "createTime" ,fill = FieldFill.INSERT)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
private Date createTime;
}

@ -0,0 +1,33 @@
package com.liu.covid.entity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.liu.covid.entity.Enum.GenderEnum;
import lombok.Data;
import java.util.Date;
@Data
public class EmpIden {
@TableId(type = IdType.AUTO)
private Long id;
private String name;
private String status;
private GenderEnum sex;
private Long idcard;
@JsonFormat(pattern = "yyyy-MM-dd",timezone="GMT+8")
private Date idate;
private String place;
private String depart;
private Long phonenum;
@TableField(value = "register" ,fill = FieldFill.INSERT)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
private Date register;
}

@ -0,0 +1,29 @@
package com.liu.covid.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.liu.covid.entity.Enum.GenderEnum;
import lombok.Data;
import java.util.Date;
@Data
public class EmpIs {
@TableId(type = IdType.AUTO)
private Long id;
private String name;
private GenderEnum sex;
private Long phone;
private float temp;
private String type;
private String place;
@JsonFormat(pattern = "yyyy-MM-dd",timezone="GMT+8")
private Date begin;
@JsonFormat(pattern = "yyyy-MM-dd",timezone="GMT+8")
private Date end;
private String leaved;
private String content;
private String arrived;
private String depart;
}

@ -0,0 +1,17 @@
package com.liu.covid.entity.Enum;
import com.baomidou.mybatisplus.annotation.EnumValue;
public enum GenderEnum {
(1,"男"),
(0,"女");
GenderEnum(Integer code, String gender) {
this.code = code;
this.gender = gender;
}
@EnumValue
private Integer code;
private String gender;
}

@ -0,0 +1,17 @@
package com.liu.covid.entity.Enum;
import com.baomidou.mybatisplus.annotation.EnumValue;
public enum ImpEnum {
(1,"是"),
(0,"否");
ImpEnum(Integer code, String isImp) {
this.code = code;
this.isImp = isImp;
}
@EnumValue
private Integer code;
private String isImp;
}

@ -0,0 +1,28 @@
package com.liu.covid.entity;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.liu.covid.entity.Enum.ImpEnum;
import lombok.Data;
import java.util.Date;
@Data
@TableName(value = "material_manage")
public class MaterialManage {
@TableId(type = IdType.AUTO)
private Long id;
private String name;
private int count;
private String type;
@TableField(value = "isImp")
private ImpEnum isImp;
private String charge;
private Long cnum;
@TableField(value = "updateTime" ,fill = FieldFill.INSERT_UPDATE)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
private Date updateTime;
}

@ -0,0 +1,15 @@
package com.liu.covid.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
@Data
public class User {
@TableId(type = IdType.AUTO)
private Long id;
private String username;
private String password;
private String depart;
}

@ -0,0 +1,22 @@
package com.liu.covid.handler;
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;
import java.util.Date;
@Component
public class MyMetaObjectHandler implements MetaObjectHandler {
@Override
public void insertFill(MetaObject metaObject) {
this.setFieldValByName("createTime",new Date(),metaObject);
this.setFieldValByName("register",new Date(),metaObject);
this.setFieldValByName("updateTime",new Date(),metaObject);
}
@Override
public void updateFill(MetaObject metaObject) {
this.setFieldValByName("updateTime",new Date(),metaObject);
}
}

@ -0,0 +1,9 @@
package com.liu.covid.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.liu.covid.entity.Department;
import org.springframework.stereotype.Repository;
@Repository
public interface DepartMapper extends BaseMapper<Department> {
}

@ -0,0 +1,9 @@
package com.liu.covid.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.liu.covid.entity.EmpIden;
import org.springframework.stereotype.Repository;
@Repository
public interface EmpIdenMapper extends BaseMapper<EmpIden> {
}

@ -0,0 +1,9 @@
package com.liu.covid.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.liu.covid.entity.EmpIs;
import org.springframework.stereotype.Repository;
@Repository
public interface EmpIsMapper extends BaseMapper<EmpIs> {
}

@ -0,0 +1,9 @@
package com.liu.covid.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.liu.covid.entity.EmpHealth;
import org.springframework.stereotype.Repository;
@Repository
public interface EmpMapper extends BaseMapper<EmpHealth> {
}

@ -0,0 +1,9 @@
package com.liu.covid.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.liu.covid.entity.MaterialManage;
import org.springframework.stereotype.Repository;
@Repository
public interface MaterialMapper extends BaseMapper<MaterialManage> {
}

@ -0,0 +1,9 @@
package com.liu.covid.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.liu.covid.entity.User;
import org.springframework.stereotype.Repository;
@Repository
public interface UserMapper extends BaseMapper<User> {
}

@ -0,0 +1,14 @@
package com.liu.covid.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.liu.covid.entity.EmpIden;
import com.liu.covid.vo.LineVO;
import com.liu.covid.vo.PieVo;
import java.util.List;
import java.util.Map;
public interface ChartService extends IService<EmpIden> {
public LineVO lineVOList();
public List<PieVo> pieVOMap();
}

@ -0,0 +1,10 @@
package com.liu.covid.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.liu.covid.entity.Department;
import java.util.List;
public interface DepartService extends IService<Department> {
public List<String> getAll();
}

@ -0,0 +1,9 @@
package com.liu.covid.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.liu.covid.entity.User;
public interface UserService extends IService<User> {
public String login(User user);
public String register(User user);
}

@ -0,0 +1,93 @@
package com.liu.covid.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.liu.covid.entity.EmpIden;
import com.liu.covid.entity.EmpIs;
import com.liu.covid.entity.MaterialManage;
import com.liu.covid.mapper.EmpIdenMapper;
import com.liu.covid.mapper.EmpIsMapper;
import com.liu.covid.mapper.MaterialMapper;
import com.liu.covid.service.ChartService;
import com.liu.covid.vo.LineVO;
import com.liu.covid.vo.PieVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.*;
@Service
public class ChartServiceImpl extends ServiceImpl<EmpIdenMapper, EmpIden> implements ChartService {
@Autowired
private EmpIdenMapper empIdenMapper;
@Autowired
private EmpIsMapper empIsMapper;
@Autowired
private MaterialMapper materialMapper;
@Override
public LineVO lineVOList() {
LineVO lineVO = new LineVO();
Date date = new Date();
Calendar cal = Calendar.getInstance();
List<String> month = new ArrayList<>();
List<Integer> list=new ArrayList<>();
Map<String, List> all = new HashMap<>();
String type[] = {"确诊", "疑似", "治愈", "死亡"};
for (int i = 0; i < 7; i++) {
cal.setTime(date);
cal.set(Calendar.MONTH, cal.get(Calendar.MONTH) - i);
SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM");
String mon = ft.format(cal.getTime());
month.add(mon);
}
//设置折线图月份
Collections.reverse(month);
lineVO.setMonth(month);
// 设置 类型-数量 键值对
for (String t : type) {
List<Integer> cot=new ArrayList<>();
int j = 0;
while (j <7 ) {
QueryWrapper<EmpIden> userQueryWrapper = Wrappers.query();
userQueryWrapper.like("status", t).likeRight("idate", month.get(j++));
Integer count = empIdenMapper.selectCount(userQueryWrapper);
cot.add(count);
userQueryWrapper.clear();
}
all.put(t, cot);
}
int j = 0;
while (j <7 ) {
QueryWrapper<EmpIs> userQueryWrapper = Wrappers.query();
userQueryWrapper.likeRight("begin", month.get(j++));
Integer count = empIsMapper.selectCount(userQueryWrapper);
list.add(count);
}
all.put("隔离", list);
lineVO.setStatus(all);
return lineVO;
}
@Override
public List<PieVo> pieVOMap() {
List<PieVo> pielist=new ArrayList<>();
QueryWrapper queryWrapper=new QueryWrapper();
queryWrapper.eq("isImp","1");
List<MaterialManage> list=materialMapper.selectList(queryWrapper);
for (MaterialManage mat:list){
PieVo pieVo=new PieVo();
pieVo.setName(mat.getName());
pieVo.setValue(mat.getCount());
pielist.add(pieVo);
}
return pielist;
}
}

@ -0,0 +1,30 @@
package com.liu.covid.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.liu.covid.entity.Department;
import com.liu.covid.entity.EmpIden;
import com.liu.covid.mapper.DepartMapper;
import com.liu.covid.mapper.EmpIdenMapper;
import com.liu.covid.service.DepartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
@Service
public class DepartServiceImpl extends ServiceImpl<DepartMapper, Department> implements DepartService {
@Autowired
private DepartMapper mapper;
@Override
public List<String> getAll() {
List<Department> list;
List<String> name=new ArrayList<>();
list=mapper.selectList(null);
for (Department de:list){
name.add(de.getName());
}
return name;
}
}

@ -0,0 +1,51 @@
package com.liu.covid.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.liu.covid.entity.EmpIden;
import com.liu.covid.entity.User;
import com.liu.covid.mapper.EmpIdenMapper;
import com.liu.covid.mapper.UserMapper;
import com.liu.covid.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.DigestUtils;
import java.util.List;
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
@Autowired
UserMapper mapper;
@Override
public String login(User user) {
QueryWrapper<User> userQueryWrapper = Wrappers.query();
userQueryWrapper.like("username", user.getUsername());
List<User> list = mapper.selectList(userQueryWrapper);
if (list.size()!=0){
String password= DigestUtils.md5DigestAsHex(user.getPassword().getBytes());
if (list.get(0).getPassword().equals(password)){
return "success";
}else return "error";
}else return "error";
}
@Override
public String register(User user) {
if (user!=null){
boolean flag=true;
for (User list:mapper.selectList(null)){
if (list.getUsername().equals(user.getUsername()))
flag=false;
}
if (flag){
String pw=DigestUtils.md5DigestAsHex(user.getPassword().getBytes());
user.setPassword(pw);
int index=mapper.insert(user);
if (index==1){return "success";}else return "error";
}else return "repeat";
}else return "error";
}
}

@ -0,0 +1,29 @@
package com.liu.covid.util;
import java.sql.*;
public class JDBCUtils {
static final String url="jdbc:mysql://localhost:3306/covid?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai";
static final String user="root";
static final String password="123456";
private static Connection con;
/**
*
* @return
*/
public static Connection getConnection(){
//添加驱动
try {
Class.forName("coym.msql.cj.jdbc.Driver");// 8.0以后版本加载驱动
}catch (ClassNotFoundException e){
e.printStackTrace();
}
//进行连接
try {
con= DriverManager.getConnection(url, user, password);
con.setAutoCommit(true);
}catch (SQLException e){
e.printStackTrace();
}
return con;
}
}

@ -0,0 +1,16 @@
package com.liu.covid.util;
import java.sql.Connection;
import java.sql.SQLException;
public class test{
public static void main(String[] args) throws SQLException {
JDBCUtils jdbcConnection=new JDBCUtils();
Connection connection=jdbcConnection.getConnection();
if(connection!=null){
System.out.println("数据库连接成功");
}else {
System.out.println("数据库连接失败");
}
}
}

@ -0,0 +1,13 @@
package com.liu.covid.vo;
import lombok.Data;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Data
public class LineVO {
private List<String> month;
private Map<String,List> status;
}

@ -0,0 +1,9 @@
package com.liu.covid.vo;
import lombok.Data;
@Data
public class PieVo {
private String name;
private Integer value;
}

@ -0,0 +1,13 @@
package org.example;
/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
}
}

@ -0,0 +1,15 @@
# 应用名称
spring:
datasource:
url: jdbc:mysql://localhost:3306/covid?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
username: root
password: 123456
driver-class-name: com.mysql.cj.jdbc.Driver
server:
port: 8080
mybatis-plus:
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
type-enums-package:
com.liu.covid.entity

@ -0,0 +1,13 @@
package com.liu.covid;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class CovidApplicationTests {
@Test
void contextLoads() {
}
}

@ -0,0 +1,30 @@
package com.liu.covid.controller;
import com.liu.covid.entity.EmpHealth;
import com.liu.covid.entity.User;
import com.liu.covid.mapper.EmpMapper;
import com.liu.covid.mapper.UserMapper;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.util.DigestUtils;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
@SpringBootTest
class LoginServiceTest {
@Autowired
private UserMapper mapper;
@Test
void register(){
User user=new User();
String pw=DigestUtils.md5DigestAsHex("99409".getBytes());
user.setUsername("994091246");
user.setPassword(pw);
int message= mapper.insert(user);
System.out.println(message);
}
}

@ -0,0 +1,60 @@
package com.liu.covid.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.liu.covid.entity.EmpIden;
import com.liu.covid.entity.EmpIs;
import com.liu.covid.mapper.EmpIdenMapper;
import com.liu.covid.mapper.EmpIsMapper;
import com.liu.covid.vo.LineVO;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import java.sql.Wrapper;
import java.text.SimpleDateFormat;
import java.util.*;
@SpringBootTest
class MaterialControllerTest {
@Autowired
private EmpIdenMapper mapper;
@Test
void find() {
LineVO lineVO=new LineVO();
Date date=new Date();
Calendar cal = Calendar.getInstance();
List<String> month=new ArrayList<>();
Map<String,Integer> status=new HashMap<>();
Map<String,Map> all=new HashMap<>();
String type[]={"确诊","疑似","治愈","死亡"};
for (int i=0;i<7;i++) {
cal.setTime(date);
cal.set(Calendar.MONTH, cal.get(Calendar.MONTH) - i);
SimpleDateFormat ft=new SimpleDateFormat("yyyy-MM");
String mon=ft.format(cal.getTime());
month.add(mon);
}
//设置折线图月份
lineVO.setMonth(month);
// 设置 类型-数量 键值对
for (String t : type) {
int j=0;
while (j<7){
QueryWrapper<EmpIden> userQueryWrapper = Wrappers.query();
userQueryWrapper.like("status", t).likeRight("idate", month.get(j));
Integer count = mapper.selectCount(userQueryWrapper);
status.put(month.get(j++),count);
userQueryWrapper.clear();
}
all.put(t,status);
}
System.out.println(all.toString());
}
}

@ -0,0 +1,38 @@
package org.example;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
* Unit test for simple App.
*/
public class AppTest
extends TestCase
{
/**
* Create the test case
*
* @param testName name of the test case
*/
public AppTest( String testName )
{
super( testName );
}
/**
* @return the suite of tests being tested
*/
public static Test suite()
{
return new TestSuite( AppTest.class );
}
/**
* Rigourous Test :-)
*/
public void testApp()
{
assertTrue( true );
}
}
Loading…
Cancel
Save