——————————DescriptionStart——————————
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明






基于javaweb的SpringBoot送水公司管理系统(java+springboot+html+thymeleaf+mybatis+mysql+maven)
项目介绍
这个项目是一个基于SpringBoot+MyBatis的送水公司管理系统
管理员权限包括: 客户管理 送水工管理 送水历史管理 计算工资 统计送水数量
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA; 3.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 4.数据库:MySql 5.7版本; 5.是否Maven项目:是;
技术栈
1.后端:SpringBoot+Mybatis+Mysql 2.前端:html+css+javascript
使用说明
- 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中application.yml配置文件中的数据库配置改为自己的配置; 4. 运行项目,在浏览器中输入http://localhost:8091/ 注意:端口不要修改,否则会有异常 管理员账户:admin/admin
——————————CodeStart——————————
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| * 1 上传送水工照片 * 1.1 获取上传文件的名称 * 1.2 获取上传文件后缀的索引 * 1.3 根据索引获取上传的文件名后缀,例如:.png * 1.4 获取上传文件的前缀,例如:15456435635。注意前缀命名使用1970-01-01距离现在的毫秒数 * 1.5 判断上传路径是否存在,如果不存在创建改路径。例如: D:/upLoad/picture/ * 1.6 拼接上传文件的前缀和后缀名称。例如:15456435635.png。然后创建对应的File对象 * 1.7 上传文件 * 1.8 将凭借的上传文件名称设置到Worker对象中 * 2 调用WorkerService对象的saveWorker方法,将送水工信息保存到数据库中 * 3 重定向到客户列表,显示新添加的送水工信息 * @param worker 表单采集的新送水工信息 * @param file 封装了浏览器上传的图片数据 * @return 重定向到客户列表,显示新添加的送水工信息 */ @RequestMapping(value="/saveWorker",method = RequestMethod.POST) public String saveWorker(Worker worker, MultipartFile file) { uploadFile(worker, file); workerService.saveWorker(worker); return "redirect:/worker/workerList"; }
private void uploadFile(Worker worker, MultipartFile file) { if (null != file) { String fileName = file.getOriginalFilename(); int suffixIndex = fileName.lastIndexOf("."); String suffix = StringUtils.substring(fileName, suffixIndex); long prefix = System.nanoTime(); File serverPath = new File(location); if (!serverPath.exists()) { serverPath.mkdirs(); } String uploadFile = prefix + suffix; File uploadFilePath = new File(serverPath, uploadFile);
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| @RequestMapping(value="/updateHis",method=RequestMethod.POST) public String updateHistory(Integer workerId,Integer custId,History history) { log.info(" update custId id = "+custId); log.info(" update worker id = "+workerId); log.info(" update History = "+history); Worker worker = new Worker(); worker.setWid(workerId);
Customer customer = new Customer(); customer.setCid(custId); history.setCustomer(customer); history.setWorker(worker); int rows = historyService.updateHistory(history); log.info("update history rows = "+rows); return "redirect:/history/listHis"; }
@RequestMapping(value="/batchDeleteHistory",method = RequestMethod.POST) @ResponseBody public String batchDeleteHistory(String idList) { int rows = historyService.batchDeleteHistory(idList); if (rows > 0) { return "OK"; } else { return "Fail"; } } } package com.minzu.controller;
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| model.addAttribute("custList",custList); model.addAttribute("workerList",workerList); return "historySave"; }
@RequestMapping(value = "/saveHis",method = RequestMethod.POST) public String saveHistory(Integer workerId,Integer custId,History history) { log.info("workerId = "+workerId); log.info("custId = "+custId); log.info("history = "+history); Worker worker = new Worker(); worker.setWid(workerId);
Customer customer = new Customer(); customer.setCid(custId); history.setWorker(worker); history.setCustomer(customer); int rows = historyService.saveHistory(history); log.info("save History rows = "+rows); return "redirect:/history/listHis"; }
@RequestMapping("/listHis")
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
@Controller @RequestMapping("/worker") @Slf4j public class WorkerController {
@Autowired private WorkerService workerService;
@Value("${location}") private String location;
@RequestMapping("/workerList") public String listWorker(Model model) { List<Worker> workerList = workerService.listWorker(); model.addAttribute("workerList",workerList); return "workerList"; }
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| }
@RequestMapping(value="/updateHis",method=RequestMethod.POST) public String updateHistory(Integer workerId,Integer custId,History history) { log.info(" update custId id = "+custId); log.info(" update worker id = "+workerId); log.info(" update History = "+history); Worker worker = new Worker(); worker.setWid(workerId);
Customer customer = new Customer(); customer.setCid(custId); history.setCustomer(customer); history.setWorker(worker); int rows = historyService.updateHistory(history); log.info("update history rows = "+rows); return "redirect:/history/listHis"; }
@RequestMapping(value="/batchDeleteHistory",method = RequestMethod.POST) @ResponseBody public String batchDeleteHistory(String idList) { int rows = historyService.batchDeleteHistory(idList); if (rows > 0) { return "OK"; } else { return "Fail"; } } } package com.minzu.controller;
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| * @version 1.0 */ @Controller @Slf4j public class AccountController {
@Autowired private AccountService accountService;
@RequestMapping(value="/login",method = RequestMethod.POST) public String login(String userName, String userPwd, Model model, HttpSession session) { boolean result = accountService.login(userName, userPwd); if(result) { session.setAttribute("currentUser",userName); return "waterMainMenu"; } else { model.addAttribute("loginFail","用户名或者密码错误"); return "index"; } }
@RequestMapping("/logout") public String logout() { return "index"; }
|
——————————PayStart——————————
项目链接:
https://javayms.github.io?id=141122542008200sd
https://javayms.pages.dev?id=141122542008200sd