Compare commits

..

No commits in common. 'master' and 'master' have entirely different histories.

@ -1 +0,0 @@
Subproject commit df30c6ee517297783b8f1e46eba280b0300862b7

@ -1,14 +0,0 @@
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);
}
}

@ -1,27 +0,0 @@
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 {
// 重写 addCorsMappings 方法,配置跨域访问规则
@Override
public void addCorsMappings(CorsRegistry registry) {
// 允许所有路径的跨域请求
registry.addMapping("/**")
// 允许的来源,"*" 表示任意来源
.allowedOrigins("*")
// 允许的 HTTP 方法
.allowedMethods("GET","HEAD","POST","PUT","DELETE","OPTIONS")
// 是否允许携带凭据(如 Cookie
.allowCredentials(true)
// 预检请求的缓存时间,单位为秒
.maxAge(3600)
// 允许的请求头,"*" 表示任意请求头
.allowedHeaders("*");
}
}

@ -1,22 +0,0 @@
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;
// 配置类,用于设置 MyBatis Plus 的拦截器
@Configuration
public class MybatisPlusConfig {
// 声明一个 MybatisPlusInterceptor Bean
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
// 创建 MybatisPlusInterceptor 对象
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
// 添加分页拦截器,指定数据库类型为 MySQL
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
// 返回配置完成的拦截器实例
return interceptor;
}
}

@ -1,29 +0,0 @@
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 {
// 自动注入 DepartService 服务
@Autowired
DepartService service;
// 处理 GET 请求,返回所有部门信息的列表// 处理 GET 请求,返回所有部门信息的列表
@GetMapping("/findAll")
private List<String> findAll(){
return service.getAll();
}// 调用服务层方法获取所有部门信息
}

@ -1,78 +0,0 @@
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 {
// 自动注入 EmpMapper 对象
@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";
}
}
// 根据员工 ID 查询健康信息
@GetMapping("/findById/{id}")
public EmpHealth findById(@PathVariable("id") Integer id){
return mapper.selectById(id);
}// 根据 ID 查询数据并返回
// 更新员工健康信息
@PutMapping("/update")
public String update(@RequestBody EmpHealth emp){
// 更新数据并返回操作结果
int result=mapper.updateById(emp);
if (result==1){
return "success";
}else {
return "error";
}
}
// 根据员工 ID 删除健康信息
@DeleteMapping("/deleteById/{id}")
public void deleteById(@PathVariable("id")Long id){
mapper.deleteById(id+"L");
}// 删除指定 ID 的数据
// 根据指定字段和内容搜索员工健康信息
@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);
}
}

@ -1,122 +0,0 @@
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; // 员工身份信息的 Mapper
/**
*
* @param page
* @param size
* @return
*/
@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;
}
/**
*
* @param empIden
* @return "success" "error"
*/
@PostMapping("/save")
public String save(@RequestBody EmpIden empIden) {
int result = mapper.insert(empIden);
if (result == 1) {
return "success";
} else {
return "error";
}
}
/**
* 线
* @return 线
*/
@GetMapping("/LineVO")
public LineVO getLineVO() {
return this.chartService.lineVOList();
}
/**
*
* @return
*/
@GetMapping("/PieVO")
public List<PieVo> getPieVO() {
return this.chartService.pieVOMap();
}
/**
* ID
* @param id ID
* @return
*/
@GetMapping("/findById/{id}")
public EmpIden findById(@PathVariable("id") Integer id) {
return mapper.selectById(id);
}
/**
*
* @param empIden
* @return "success" "error"
*/
@PutMapping("/update")
public String update(@RequestBody EmpIden empIden) {
int result = mapper.updateById(empIden);
if (result == 1) {
return "success";
} else {
return "error";
}
}
/**
* ID
* @param id ID
*/
@DeleteMapping("/deleteById/{id}")
public void deleteById(@PathVariable("id") Long id) {
mapper.deleteById(id + "L");
}
/**
*
* @param searchkey
* @param stext
* @return
*/
@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);
}
}

@ -1,117 +0,0 @@
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; // 员工身份信息的 Mapper
/**
*
* @param page
* @param size
* @return
*/
@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;
}
/**
*
* @param empis
* @return "success" "error"
*/
@PostMapping("/save")
public String save(@RequestBody EmpIs empis) {
// 设置结束日期为开始日期后14天
Format f = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
c.setTime(empis.getBegin());
c.add(Calendar.DAY_OF_MONTH, 14); // 增加14天
Date end = c.getTime();
empis.setEnd(end);
int result = mapper.insert(empis);
if (result == 1) {
return "success";
} else {
return "error";
}
}
/**
* ID
* @param id ID
* @return
*/
@GetMapping("/findById/{id}")
public EmpIs findById(@PathVariable("id") Integer id) {
return mapper.selectById(id);
}
/**
*
* @param empis
* @return "success" "error"
*/
@PutMapping("/update")
public String update(@RequestBody EmpIs empis) {
// 设置结束日期为开始日期后14天
Format f = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
c.setTime(empis.getBegin());
c.add(Calendar.DAY_OF_MONTH, 14); // 增加14天
Date end = c.getTime();
empis.setEnd(end);
int result = mapper.updateById(empis);
if (result == 1) {
return "success";
} else {
return "error";
}
}
/**
* ID
* @param id ID
*/
@DeleteMapping("/deleteById/{id}")
public void deleteById(@PathVariable("id") Long id) {
mapper.deleteById(id + "L");
}
/**
*
* @param searchkey
* @param stext
* @return
*/
@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);
}
}

@ -1,41 +0,0 @@
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; // 用户服务,用于处理登录和注册逻辑
/**
*
* @param loginform
* @return
*/
@PostMapping("/user")
public String login(@RequestBody User loginform) {
// 调用 userService 的 login 方法进行登录验证
String message = userService.login(loginform);
return message; // 返回登录结果消息
}
/**
*
* @param reUser
* @return
*/
@PostMapping("/register")
public String register(@RequestBody User reUser) {
// 调用 userService 的 register 方法进行用户注册
String message = userService.register(reUser);
return message; // 返回注册结果消息
}
}

@ -1,97 +0,0 @@
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.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; // 物资管理的 Mapper
/**
*
* @param page
* @param size
* @return
*/
@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;
}
/**
*
* @param material
* @return "success" "error"
*/
@PostMapping("/save")
public String save(@RequestBody MaterialManage material) {
int result = mapper.insert(material);
if (result == 1) {
return "success";
} else {
return "error";
}
}
/**
* ID
* @param id ID
* @return
*/
@GetMapping("/findById/{id}")
public MaterialManage findById(@PathVariable("id") Integer id) {
return mapper.selectById(id);
}
/**
*
* @param material
* @return "success" "error"
*/
@PutMapping("/update")
public String update(@RequestBody MaterialManage material) {
int result = mapper.updateById(material);
if (result == 1) {
return "success";
} else {
return "error";
}
}
/**
* ID
* @param id ID
*/
@DeleteMapping("/deleteById/{id}")
public void deleteById(@PathVariable("id") Long id) {
mapper.deleteById(id + "L");
}
/**
*
* @param searchkey
* @param stext
* @return
*/
@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);
}
}

@ -1,12 +0,0 @@
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;
}

@ -1,52 +0,0 @@
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;
// 员工性别,使用 GenderEnum 枚举类型
private GenderEnum sex;
// 员工联系电话
private Long phonenum;
// 员工体温
private float temp;
// 健康风险评估
private String risk;
// 员工健康状态(如:健康、需要隔离等)
private String health;
// 健康内容的详细说明
private String content;
// 员工所属部门
private String depart;
// 记录的创建时间,插入时自动填充,格式为 "yyyy-MM-dd HH:mm:ss"
@TableField(value = "createTime", fill = FieldFill.INSERT)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
}

@ -1,53 +0,0 @@
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;
// 员工性别,使用 GenderEnum 枚举类型
private GenderEnum sex;
// 员工身份证号码
private Long idcard;
// 员工身份证发证日期,格式为 "yyyy-MM-dd"
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date idate;
// 员工出生地
private String place;
// 员工所属部门
private String depart;
// 员工联系电话
private Long phonenum;
// 员工注册时间,插入时自动填充,格式为 "yyyy-MM-dd HH:mm:ss"
@TableField(value = "register", fill = FieldFill.INSERT)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date register;
}

@ -1,59 +0,0 @@
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;
// 员工性别,使用 GenderEnum 枚举类型
private GenderEnum sex;
// 员工联系电话
private Long phone;
// 员工体温
private float temp;
// 隔离类型(例如:居家、集中等)
private String type;
// 隔离地点
private String place;
// 隔离开始日期,格式为 "yyyy-MM-dd"
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date begin;
// 隔离结束日期,格式为 "yyyy-MM-dd"
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date end;
// 是否离开隔离地点
private String leaved;
// 隔离期间的健康内容说明
private String content;
// 是否已到达隔离地点
private String arrived;
// 员工所属部门
private String depart;
}

@ -1,23 +0,0 @@
package com.liu.covid.entity.Enum;
import com.baomidou.mybatisplus.annotation.EnumValue;
/**
*
*
*/
public enum GenderEnum {
(1, "男"), // 男性code为1
(0, "女"); // 女性code为0
// 枚举类的构造函数传入code和gender值
GenderEnum(Integer code, String gender) {
this.code = code;
this.gender = gender;
}
@EnumValue // 标记该字段为数据库存储的值
private Integer code; // 性别代码1为男性0为女性
private String gender; // 性别名称:男或女
}

@ -1,23 +0,0 @@
package com.liu.covid.entity.Enum;
import com.baomidou.mybatisplus.annotation.EnumValue;
/**
*
*
*/
public enum ImpEnum {
(1, "是"), // 表示重要code为1
(0, "否"); // 表示不重要code为0
// 枚举类的构造函数传入code和isImp值
ImpEnum(Integer code, String isImp) {
this.code = code;
this.isImp = isImp;
}
@EnumValue // 标记该字段为数据库存储的值
private Integer code; // 是否重要的代码1为是0为否
private String isImp; // 是否重要的名称:是或否
}

@ -1,45 +0,0 @@
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;
// 物资是否重要,使用 ImpEnum 枚举类型(例如:是、否)
@TableField(value = "isImp")
private ImpEnum isImp;
// 物资负责人
private String charge;
// 物资负责人联系方式
private Long cnum;
// 物资管理记录的更新时间,插入或更新时自动填充,格式为 "yyyy-MM-dd HH:mm:ss"
@TableField(value = "updateTime", fill = FieldFill.INSERT_UPDATE)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updateTime;
}

@ -1,15 +0,0 @@
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;
}

@ -1,39 +0,0 @@
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;
/**
* MyMetaObjectHandler
*
*/
@Component
public class MyMetaObjectHandler implements MetaObjectHandler {
/**
*
* createTimeregister updateTime
*/
@Override
public void insertFill(MetaObject metaObject) {
// 设置 createTime 字段为当前时间
this.setFieldValByName("createTime", new Date(), metaObject);
// 设置 register 字段为当前时间
this.setFieldValByName("register", new Date(), metaObject);
// 设置 updateTime 字段为当前时间
this.setFieldValByName("updateTime", new Date(), metaObject);
}
/**
*
* updateTime
*/
@Override
public void updateFill(MetaObject metaObject) {
// 设置 updateTime 字段为当前时间
this.setFieldValByName("updateTime", new Date(), metaObject);
}
}

@ -1,9 +0,0 @@
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> {
}

@ -1,9 +0,0 @@
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> {
}

@ -1,9 +0,0 @@
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> {
}

@ -1,9 +0,0 @@
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> {
}

@ -1,9 +0,0 @@
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> {
}

@ -1,9 +0,0 @@
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> {
}

@ -1,14 +0,0 @@
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();
}

@ -1,10 +0,0 @@
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();
}

@ -1,9 +0,0 @@
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);
}

@ -1,108 +0,0 @@
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.*;
/**
* ChartServiceImpl ChartService
* 线
*/
@Service
public class ChartServiceImpl extends ServiceImpl<EmpIdenMapper, EmpIden> implements ChartService {
@Autowired
private EmpIdenMapper empIdenMapper; // 自动注入 EmpIdenMapper用于操作身份证信息表
@Autowired
private EmpIsMapper empIsMapper; // 自动注入 EmpIsMapper用于操作隔离信息表
@Autowired
private MaterialMapper materialMapper; // 自动注入 MaterialMapper用于操作物资管理表
/**
* lineVOList 线 7
* @return LineVO 线
*/
@Override
public LineVO lineVOList() {
LineVO lineVO = new LineVO(); // 创建 LineVO 对象,用于存储折线图数据
Date date = new Date(); // 当前时间
Calendar cal = Calendar.getInstance(); // 获取当前时间的 Calendar 对象
List<String> month = new ArrayList<>(); // 用于存储过去 7 个月的月份
List<Integer> list = new ArrayList<>(); // 用于存储隔离人数的数量
Map<String, List> all = new HashMap<>(); // 存储每个疾病状态的数量
String type[] = {"确诊", "疑似", "治愈", "死亡"}; // 疾病状态类型数组
// 获取过去 7 个月的月份
for (int i = 0; i < 7; i++) {
cal.setTime(date);
cal.set(Calendar.MONTH, cal.get(Calendar.MONTH) - i); // 设置当前月份减去 i 个月
SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM"); // 格式化日期为 "yyyy-MM" 格式
String mon = ft.format(cal.getTime()); // 获取当前月份
month.add(mon); // 将月份添加到 month 列表中
}
Collections.reverse(month); // 翻转月份列表,确保月份顺序从过去到现在
lineVO.setMonth(month); // 设置 LineVO 中的月份
// 获取每个疾病状态类型在过去 7 个月内的数量
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); // 将数量添加到 cot 列表中
userQueryWrapper.clear(); // 清除查询条件
}
all.put(t, cot); // 将疾病状态和数量添加到 all 映射中
}
// 获取过去 7 个月内的隔离人数
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); // 将隔离人数添加到 list 列表中
}
all.put("隔离", list); // 将隔离人数添加到 all 映射中
lineVO.setStatus(all); // 设置 LineVO 中的疾病状态数量映射
return lineVO; // 返回 LineVO 对象
}
/**
* pieVOMap
* @return List<PieVo>
*/
@Override
public List<PieVo> pieVOMap() {
List<PieVo> pielist = new ArrayList<>(); // 用于存储饼图数据的列表
QueryWrapper queryWrapper = new QueryWrapper(); // 创建查询条件
queryWrapper.eq("isImp", "1"); // 查询 isImp 字段为 1 的记录,表示重要物资
List<MaterialManage> list = materialMapper.selectList(queryWrapper); // 获取符合条件的物资记录
// 遍历所有重要物资,创建 PieVo 对象存储物资名称和数量
for (MaterialManage mat : list) {
PieVo pieVo = new PieVo();
pieVo.setName(mat.getName()); // 设置物资名称
pieVo.setValue(mat.getCount()); // 设置物资数量
pielist.add(pieVo); // 将 PieVo 对象添加到 pielist 列表中
}
return pielist; // 返回饼图数据列表
}
}

@ -1,38 +0,0 @@
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;
/**
* DepartServiceImpl DepartService
*/
@Service
public class DepartServiceImpl extends ServiceImpl<DepartMapper, Department> implements DepartService {
@Autowired
private DepartMapper mapper; // 自动注入 DepartMapper用于操作部门数据表
/**
*
* @return List<String>
*/
@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()); // 将部门名称添加到 name 列表中
}
return name; // 返回部门名称列表
}
}

@ -1,95 +0,0 @@
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;
/**
* UserServiceImpl UserService
*/
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
@Autowired
UserMapper mapper; // 自动注入 UserMapper用于操作用户数据表
/**
*
* @param user
* @return "success" "error"
*/
@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) {
// 对用户输入的密码进行MD5加密
String password = DigestUtils.md5DigestAsHex(user.getPassword().getBytes());
// 比较加密后的密码与数据库中的密码是否一致
if (list.get(0).getPassword().equals(password)) {
return "success"; // 密码匹配,登录成功
} else {
return "error"; // 密码不匹配,登录失败
}
} else {
return "error"; // 用户不存在,登录失败
}
}
/**
*
* @param user
* @return "success""error""repeat"
*/
@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; // 如果用户名已存在,则标记为 false
break;
}
}
// 如果用户名没有重复
if (flag) {
// 对用户输入的密码进行MD5加密
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"; // 用户信息为空,注册失败
}
}
}

@ -1,44 +0,0 @@
package com.liu.covid.util;
import java.sql.*;
/**
* JDBCUtils
* 使 MySQL
*/
public class JDBCUtils {
// 数据库连接的 URL包含数据库名称、字符编码及时区设置
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 null
*/
public static Connection getConnection(){
// 加载数据库驱动
try {
Class.forName("coym.msql.cj.jdbc.Driver"); // 加载 MySQL 驱动8.0 版本及以上)
} catch (ClassNotFoundException e) {
e.printStackTrace(); // 如果驱动加载失败,打印异常
}
// 进行数据库连接
try {
con = DriverManager.getConnection(url, user, password); // 使用 JDBC URL、用户名和密码进行连接
con.setAutoCommit(true); // 设置自动提交事务
} catch (SQLException e) {
e.printStackTrace(); // 如果连接失败,打印异常
}
return con; // 返回连接对象
}
}

@ -1,16 +0,0 @@
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("数据库连接失败");
}
}
}

@ -1,13 +0,0 @@
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;
}

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

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

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/java" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

@ -1,15 +0,0 @@
# 应用名称
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

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

@ -1,30 +0,0 @@
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);
}
}

@ -1,60 +0,0 @@
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());
}
}

@ -1,38 +0,0 @@
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 );
}
}

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/java" isTestSource="true" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="main" />
</component>
</module>
Loading…
Cancel
Save