Recommended study column:
Java基础学习专栏:
java basic knowledge learningJava进阶学习专栏:
Java programming advanced learning
foreword
The epidemic has been repeated in our lives. In order to facilitate us to understand the data of the new crown epidemic more intuitively, the epidemic information can be counted through Java programming for better control. This article will share with you a new crown epidemic statistics system based on SpringBoot. This article is also suitable for graduation design of computer science majors, and also meets the needs of the current society. (Source code attached at the end of the article)
Article directory
注:系统使用步骤可直接跳到【系统部署】
1. System functions
Function introduction : There are user management, new crown symptom management, new crown epidemic prevention management, epidemic data management, administrator management, system management and other functions
①System home page
Realized dynamic graphs and pie charts to record daily changes in the number of epidemic personnel
②Punch function
This function realizes the user's daily check-in, and can realize the addition, deletion, modification, and query of user information and status, which is convenient for the management of the unit.
Here is the punch list
③User Management
This function realizes the information management of using this system, checks user information and adds administrators
④ Epidemic information
There are three functions - vaccination, nucleic acid detection, and epidemic prevention materials
-
Vaccination : Recommended vaccination points based on location, and instructions for vaccination instructions
-
Nucleic acid detection : introduce relevant knowledge of nucleic acid and nucleic acid detection, so that users have a clearer understanding of nucleic acid detection
-
Epidemic prevention materials : make detailed science popularization of epidemic prevention knowledge
⑤ Epidemic personnel
Realized the management of the epidemic personnel. Realize the addition, deletion, modification, and checking of information on close contacts, confirmed cases, cured cases, and deaths
2. System deployment
Partners who need the source code of the project can download it at the end of the article , and here is a demonstration of the entire implementation steps
① Create a database
Open Navicat ( Navicat的安装you can private message if you need to activate it ), then right-click the local point 打开连接
, copy the file name in the resource package, that is coronavirus
, right-click the local point again 新建数据库
to create a database.
Then double-click to select the newly created database, right-
click to run the SQL file, click Start to run, wait for the data to be imported, then select the database, press F5 to refresh, and all the database tables in this project will be imported successfully Next,
start running the code
②Run the code
Find the source code in the data folder, drag the project coronavirus
named into IDEA , and wait for the project to load its dependent jar package. After loading, there are two places that need to be modified. The specific modification content is shown in the figure.
After modifying, find the startup class, right-click to run (run) to run,
you can see that there is no error and it is OK
③Open the browser
The last step is to open the browser and enter the access path in the search box localhost:8083
. If there is no error, you can enter the main page of the system.
3. System use
You need to log in to use the system, just click on the homepage option to enter the login page.
The account number and password can be found in the database user, select the first one, and the account number and password are both. admin
The function of the system refers to the previous article
4. Code display
- CheckOutController
@Controller
public class CheckOutController {
@Autowired
CheckOutService checkOutService;
//打卡
@RequestMapping(value = "/checkOut/toAdd")
public String toAdd() {
return "checkOutAdd";
}
//打卡
@RequestMapping(value = "/checkOut/add", method = RequestMethod.POST)
public String addCheckOut(@RequestParam("currentPosition") String currentPosition, @RequestParam("bodyTemperature") Double bodyTemperature,
@RequestParam("healthState") String healthState, @RequestParam("isToHighArea") String isToHighArea,
@RequestParam("isTouch") String isTouch, @RequestParam("remarks") String remarks,
@RequestParam("name") String name, @RequestParam("checkOutDate") Date checkOutDate) {
CheckOut checkOut = new CheckOut().setCurrentPosition(currentPosition).setBodyTemperature(bodyTemperature)
.setHealthState(healthState).setIsToHighArea(isToHighArea).setIsTouch(isTouch)
.setRemarks(remarks).setName(name).setCheckOutDate(checkOutDate);
checkOutService.add(checkOut);
return "redirect:/checkOut/list";
}
@InitBinder
public void initBinder(WebDataBinder binder, WebRequest request) {
//转换日期 注意这里的转化要和传进来的字符串的格式一直 如2015-9-9 就应该为yyyy-MM-dd
DateFormat dateFormat=new SimpleDateFormat("yyyy-MM-dd");
binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));// CustomDateEditor为自定义日期编辑器
}
@RequestMapping(value = "/checkOut/list", method = RequestMethod.GET)
public String list(Model model, @RequestParam(name="page",required = true,defaultValue = "1")int page, @RequestParam(name="size",required=true,defaultValue = "25")int size){
java.util.List<CheckOut> checkOuts = checkOutService.findAll(page,size);
PageInfo<User> pageInfo=new PageInfo(checkOuts);
model.addAttribute("pageInfo",pageInfo);
return "checkOutList";
}
@RequestMapping(value = "/checkOut/listByCheckOutName")
public String listByCureName(Model model, @RequestParam(name = "name", required = true) String name) {
java.util.List<CheckOut> checkOut = checkOutService.findByName(name);
PageInfo<Cure> pageInfo = new PageInfo(checkOut);
model.addAttribute("pageInfo", pageInfo);
return "checkOutList";
}
}
- CureController
@Controller
public class CureController {
@Autowired
CureService service;
//所有治愈者
@RequestMapping(value = "cure/list",method = RequestMethod.GET)
public String list(Model model, @RequestParam(name="page",required = true,defaultValue = "1")int page, @RequestParam(name="size",required=true,defaultValue = "25")int size){
List<Cure> cures = service.findAll(page,size);
PageInfo<User> pageInfo=new PageInfo(cures);
model.addAttribute("pageInfo",pageInfo);
return "list";
}
//根据id查找治愈者
@RequestMapping(value = "cure/info/{id}",method = RequestMethod.GET)
public String info(@PathVariable("id")int id,Model model){
Cure cure = service.get(id);
model.addAttribute("cure",cure);
return "cureInfo";
}
//更新或插入治愈者的现状
@RequestMapping(value = "cure/update",method = RequestMethod.GET)
public String update(int baseId,String current){
service.update(baseId,current);
System.out.println(baseId+current);
return "redirect:/cure/info/"+baseId;
}
@RequestMapping(value = "cure/listByCureName")
public String listByCureName(Model model, @RequestParam(name = "name", required = true) String name) {
List<Cure> cures = service.findByName(name);
System.out.println(cures);
PageInfo<Cure> pageInfo = new PageInfo<>(cures);
model.addAttribute("pageInfo", pageInfo);
return "list";
}
}
- UserController
@Controller
public class UserController {
@Autowired
UserService userService;
@RequestMapping(value = "/manager/list" ,method = RequestMethod.GET)
public String list(Model model, @RequestParam(name="page",required = true,defaultValue = "1")int page, @RequestParam(name="size",required=true,defaultValue = "25") int size){
List<User> users = userService.findAll(page, size);
PageInfo<User> pageInfo=new PageInfo(users);
model.addAttribute("pageInfo",pageInfo);
return "managerlist";
}
//跳转添加页面
@RequestMapping(value = "/manager/toAdd")
public String toAdd(){
return "managerAdd";
}
//添加管理员功能
@RequestMapping(value = "/manager/add",method = RequestMethod.POST)
public String add(@RequestParam("username")String username, @RequestParam("name")String name,
@RequestParam("password")String password, @RequestParam("unit")String unit,
@RequestParam("phone") BigInteger phone, @RequestParam("supermanager")char supermanager){
BCryptPasswordEncoder bCryptPasswordEncoder = new BCryptPasswordEncoder();
//加密密码
String pwd=bCryptPasswordEncoder.encode(password);
User user=new User().setName(name).setPassword(pwd).setUsername(username).setPhone(phone).setUnit(unit);
System.out.println(user);
//添加用户
userService.addUser(user);
//找到id
int id = userService.findByUsername(user.getUsername()).getId();
//添加普通权限
userService.addUserRole(id);
//添加超级管理员权限
if ("是".equals(supermanager)){
userService.addAdminRole(id);
}
return "redirect:/manager/list";
}
//升级权限
@RequestMapping("/manager/toSuper/{id}")
public String toSuper(@PathVariable("id")int id){
userService.addAdminRole(id);
return "redirect:/manager/list";
}
//删除用户
@RequestMapping("/manager/delete/{id}")
public String delete(@PathVariable("id")int id){
userService.deleteUser(id);
return "redirect:/manager/list";
}
}
5. Resource acquisition
- CSDN acquisition :
https://download.csdn.net/download/CSDN_anhl/87097686
Summarize
This is the end of the project introduction. The learning process is the process of knowing yourself. In the process of development, you will constantly supplement your own knowledge, increase your own understanding, and make up for the shortcomings. You can also master the system development environment, configuration, and development software more proficiently. I can clearly feel that my English level needs to be improved. Although the debugging process is very irritating, it is also a pleasure to settle down and deal with it. Welcome to subscribe to the blogger column below and learn with bloggers! More exciting articles will be updated later! If you feel good, give it a thumbs up!