• Java项目:SSM智能制造车间管理系统


    作者主页:夜未央5788

     简介:Java领域优质创作者、Java项目、学习资料、技术互助

    文末获取源码

    项目介绍

    本项目为智能制造车间管理系统,只有管理员一个角色。

    管理员角色包含以下功能:

    管理员登陆,设备管理,客户管理,用户管理,产品管理,工序管理,车间管理,订单管理等功能。

    由于本程序规模不大,可供课程设计,毕业设计学习演示之用

    环境需要

    1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
    2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
    3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可
    4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 

    5.数据库:MySql 5.7版本或8.0版本均可;
    6.是否Maven项目:否;

    技术栈

    1. 后端:Spring+SpringMVC+Mybatis

    2. 前端:JSP+CSS+JavaScript+jquery+bootstrap

    使用说明

    1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
    2. 使用IDEA/Eclipse/MyEclipse导入项目,修改配置,然后运行;
    3. 将项目中spring-common.xml配置文件中的数据库配置改为自己的配置;
    4. 运行项目,输入http://localhost:8080/IM_SSM/ 登录
    管理员账号/密码:admin/admin

    运行截图

     

     

     

     

     

     

     

     相关代码

    登录控制器

    1. @Controller
    2. public class LoginController {
    3. //登录跳转
    4. @RequestMapping(value = "/login", method = {RequestMethod.GET})
    5. public String loginUI() throws Exception {
    6. return "../../login";
    7. }
    8. //登录表单处理
    9. @RequestMapping(value = "/login", method = {RequestMethod.POST})
    10. public String login(Userlogin userlogin) throws Exception {
    11. //Shiro实现登录
    12. UsernamePasswordToken token = new UsernamePasswordToken(userlogin.getUsername(),
    13. userlogin.getPassword());
    14. Subject subject = SecurityUtils.getSubject();
    15. //如果获取不到用户名就是登录失败,但登录失败的话,会直接抛出异常
    16. subject.login(token);
    17. if (subject.hasRole("admin")) {
    18. return "redirect:/admin/showStudent";
    19. } else if (subject.hasRole("teacher")) {
    20. return "redirect:/teacher/showCourse";
    21. } else if (subject.hasRole("student")) {
    22. return "redirect:/student/showCourse";
    23. }
    24. return "/login";
    25. }
    26. }

    管理端控制器

    1. @Controller
    2. @RequestMapping("/admin")
    3. public class AdminController {
    4. @Resource(name = "studentServiceImpl")
    5. private StudentService studentService;
    6. @Resource(name = "teacherServiceImpl")
    7. private TeacherService teacherService;
    8. @Resource(name = "courseServiceImpl")
    9. private CourseService courseService;
    10. @Resource(name = "collegeServiceImpl")
    11. private CollegeService collegeService;
    12. @Resource(name = "userloginServiceImpl")
    13. private UserloginService userloginService;
    14. /*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<学生操作>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
    15. // 学生信息显示
    16. @RequestMapping("/showStudent")
    17. public String showStudent(Model model, Integer page) throws Exception {
    18. List list = null;
    19. //页码对象
    20. PagingVO pagingVO = new PagingVO();
    21. //设置总页数
    22. pagingVO.setTotalCount(studentService.getCountStudent());
    23. if (page == null || page == 0) {
    24. pagingVO.setToPageNo(1);
    25. list = studentService.findByPaging(1);
    26. } else {
    27. pagingVO.setToPageNo(page);
    28. list = studentService.findByPaging(page);
    29. }
    30. model.addAttribute("studentList", list);
    31. model.addAttribute("pagingVO", pagingVO);
    32. return "admin/showStudent";
    33. }
    34. // 添加学生信息页面显示
    35. @RequestMapping(value = "/addStudent", method = {RequestMethod.GET})
    36. public String addStudentUI(Model model) throws Exception {
    37. List list = collegeService.finAll();
    38. model.addAttribute("collegeList", list);
    39. return "admin/addStudent";
    40. }
    41. // 添加学生信息操作
    42. @RequestMapping(value = "/addStudent", method = {RequestMethod.POST})
    43. public String addStudent(StudentCustom studentCustom, Model model) throws Exception {
    44. Boolean result = studentService.save(studentCustom);
    45. if (!result) {
    46. model.addAttribute("message", "学号重复");
    47. return "error";
    48. }
    49. //添加成功后,也添加到登录表
    50. Userlogin userlogin = new Userlogin();
    51. userlogin.setUsername(studentCustom.getUserid().toString());
    52. userlogin.setPassword("123");
    53. userlogin.setRole(2);
    54. userloginService.save(userlogin);
    55. //重定向
    56. return "redirect:/admin/showStudent";
    57. }
    58. // 修改学生信息页面显示
    59. @RequestMapping(value = "/editStudent", method = {RequestMethod.GET})
    60. public String editStudentUI(Integer id, Model model) throws Exception {
    61. if (id == null) {
    62. //加入没有带学生id就进来的话就返回学生显示页面
    63. return "redirect:/admin/showStudent";
    64. }
    65. StudentCustom studentCustom = studentService.findById(id);
    66. if (studentCustom == null) {
    67. throw new CustomException("未找到该名学生");
    68. }
    69. List list = collegeService.finAll();
    70. model.addAttribute("collegeList", list);
    71. model.addAttribute("student", studentCustom);
    72. return "admin/editStudent";
    73. }
    74. // 修改学生信息处理
    75. @RequestMapping(value = "/editStudent", method = {RequestMethod.POST})
    76. public String editStudent(StudentCustom studentCustom) throws Exception {
    77. studentService.updataById(studentCustom.getUserid(), studentCustom);
    78. //重定向
    79. return "redirect:/admin/showStudent";
    80. }
    81. // 删除学生
    82. @RequestMapping(value = "/removeStudent", method = {RequestMethod.GET} )
    83. private String removeStudent(Integer id) throws Exception {
    84. if (id == null) {
    85. //加入没有带学生id就进来的话就返回学生显示页面
    86. return "admin/showStudent";
    87. }
    88. studentService.removeById(id);
    89. userloginService.removeByName(id.toString());
    90. return "redirect:/admin/showStudent";
    91. }
    92. // 搜索学生
    93. @RequestMapping(value = "selectStudent", method = {RequestMethod.POST})
    94. private String selectStudent(String findByName, Model model) throws Exception {
    95. List list = studentService.findByName(findByName);
    96. model.addAttribute("studentList", list);
    97. return "admin/showStudent";
    98. }
    99. /*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<教师操作>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
    100. // 教师页面显示
    101. @RequestMapping("/showTeacher")
    102. public String showTeacher(Model model, Integer page) throws Exception {
    103. List list = null;
    104. //页码对象
    105. PagingVO pagingVO = new PagingVO();
    106. //设置总页数
    107. pagingVO.setTotalCount(teacherService.getCountTeacher());
    108. if (page == null || page == 0) {
    109. pagingVO.setToPageNo(1);
    110. list = teacherService.findByPaging(1);
    111. } else {
    112. pagingVO.setToPageNo(page);
    113. list = teacherService.findByPaging(page);
    114. }
    115. model.addAttribute("teacherList", list);
    116. model.addAttribute("pagingVO", pagingVO);
    117. return "admin/showTeacher";
    118. }
    119. // 添加教师信息
    120. @RequestMapping(value = "/addTeacher", method = {RequestMethod.GET})
    121. public String addTeacherUI(Model model) throws Exception {
    122. List list = collegeService.finAll();
    123. model.addAttribute("collegeList", list);
    124. return "admin/addTeacher";
    125. }
    126. // 添加教师信息处理
    127. @RequestMapping(value = "/addTeacher", method = {RequestMethod.POST})
    128. public String addTeacher(TeacherCustom teacherCustom, Model model) throws Exception {
    129. Boolean result = teacherService.save(teacherCustom);
    130. if (!result) {
    131. model.addAttribute("message", "工号重复");
    132. return "error";
    133. }
    134. //添加成功后,也添加到登录表
    135. Userlogin userlogin = new Userlogin();
    136. userlogin.setUsername(teacherCustom.getUserid().toString());
    137. userlogin.setPassword("123");
    138. userlogin.setRole(1);
    139. userloginService.save(userlogin);
    140. //重定向
    141. return "redirect:/admin/showTeacher";
    142. }
    143. // 修改教师信息页面显示
    144. @RequestMapping(value = "/editTeacher", method = {RequestMethod.GET})
    145. public String editTeacherUI(Integer id, Model model) throws Exception {
    146. if (id == null) {
    147. return "redirect:/admin/showTeacher";
    148. }
    149. TeacherCustom teacherCustom = teacherService.findById(id);
    150. if (teacherCustom == null) {
    151. throw new CustomException("未找到该名学生");
    152. }
    153. List list = collegeService.finAll();
    154. model.addAttribute("collegeList", list);
    155. model.addAttribute("teacher", teacherCustom);
    156. return "admin/editTeacher";
    157. }
    158. // 修改教师信息页面处理
    159. @RequestMapping(value = "/editTeacher", method = {RequestMethod.POST})
    160. public String editTeacher(TeacherCustom teacherCustom) throws Exception {
    161. teacherService.updateById(teacherCustom.getUserid(), teacherCustom);
    162. //重定向
    163. return "redirect:/admin/showTeacher";
    164. }
    165. //删除教师
    166. @RequestMapping("/removeTeacher")
    167. public String removeTeacher(Integer id) throws Exception {
    168. if (id == null) {
    169. //加入没有带教师id就进来的话就返回教师显示页面
    170. return "admin/showTeacher";
    171. }
    172. teacherService.removeById(id);
    173. userloginService.removeByName(id.toString());
    174. return "redirect:/admin/showTeacher";
    175. }
    176. //搜索教师
    177. @RequestMapping(value = "selectTeacher", method = {RequestMethod.POST})
    178. private String selectTeacher(String findByName, Model model) throws Exception {
    179. List list = teacherService.findByName(findByName);
    180. model.addAttribute("teacherList", list);
    181. return "admin/showTeacher";
    182. }
    183. /*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<课程操作>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
    184. // 课程信息显示
    185. @RequestMapping("/showCourse")
    186. public String showCourse(Model model, Integer page) throws Exception {
    187. List list = null;
    188. //页码对象
    189. PagingVO pagingVO = new PagingVO();
    190. //设置总页数
    191. pagingVO.setTotalCount(courseService.getCountCouse());
    192. if (page == null || page == 0) {
    193. pagingVO.setToPageNo(1);
    194. list = courseService.findByPaging(1);
    195. } else {
    196. pagingVO.setToPageNo(page);
    197. list = courseService.findByPaging(page);
    198. }
    199. model.addAttribute("courseList", list);
    200. model.addAttribute("pagingVO", pagingVO);
    201. return "admin/showCourse";
    202. }
    203. //添加课程
    204. @RequestMapping(value = "/addCourse", method = {RequestMethod.GET})
    205. public String addCourseUI(Model model) throws Exception {
    206. List list = teacherService.findAll();
    207. List collegeList = collegeService.finAll();
    208. model.addAttribute("collegeList", collegeList);
    209. model.addAttribute("teacherList", list);
    210. return "admin/addCourse";
    211. }
    212. // 添加课程信息处理
    213. @RequestMapping(value = "/addCourse", method = {RequestMethod.POST})
    214. public String addCourse(CourseCustom courseCustom, Model model) throws Exception {
    215. Boolean result = courseService.save(courseCustom);
    216. if (!result) {
    217. model.addAttribute("message", "课程号重复");
    218. return "error";
    219. }
    220. //重定向
    221. return "redirect:/admin/showCourse";
    222. }
    223. // 修改教师信息页面显示
    224. @RequestMapping(value = "/editCourse", method = {RequestMethod.GET})
    225. public String editCourseUI(Integer id, Model model) throws Exception {
    226. if (id == null) {
    227. return "redirect:/admin/showCourse";
    228. }
    229. CourseCustom courseCustom = courseService.findById(id);
    230. if (courseCustom == null) {
    231. throw new CustomException("未找到该课程");
    232. }
    233. List list = teacherService.findAll();
    234. List collegeList = collegeService.finAll();
    235. model.addAttribute("teacherList", list);
    236. model.addAttribute("collegeList", collegeList);
    237. model.addAttribute("course", courseCustom);
    238. return "admin/editCourse";
    239. }
    240. // 修改教师信息页面处理
    241. @RequestMapping(value = "/editCourse", method = {RequestMethod.POST})
    242. public String editCourse(CourseCustom courseCustom) throws Exception {
    243. courseService.upadteById(courseCustom.getCourseid(), courseCustom);
    244. //重定向
    245. return "redirect:/admin/showCourse";
    246. }
    247. // 删除课程信息
    248. @RequestMapping("/removeCourse")
    249. public String removeCourse(Integer id) throws Exception {
    250. if (id == null) {
    251. //加入没有带教师id就进来的话就返回教师显示页面
    252. return "admin/showCourse";
    253. }
    254. courseService.removeById(id);
    255. return "redirect:/admin/showCourse";
    256. }
    257. //搜索课程
    258. @RequestMapping(value = "selectCourse", method = {RequestMethod.POST})
    259. private String selectCourse(String findByName, Model model) throws Exception {
    260. List list = courseService.findByName(findByName);
    261. model.addAttribute("courseList", list);
    262. return "admin/showCourse";
    263. }
    264. /*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<其他操作>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
    265. // 普通用户账号密码重置
    266. @RequestMapping("/userPasswordRest")
    267. public String userPasswordRestUI() throws Exception {
    268. return "admin/userPasswordRest";
    269. }
    270. // 普通用户账号密码重置处理
    271. @RequestMapping(value = "/userPasswordRest", method = {RequestMethod.POST})
    272. public String userPasswordRest(Userlogin userlogin) throws Exception {
    273. Userlogin u = userloginService.findByName(userlogin.getUsername());
    274. if (u != null) {
    275. if (u.getRole() == 0) {
    276. throw new CustomException("该账户为管理员账户,没法修改");
    277. }
    278. u.setPassword(userlogin.getPassword());
    279. userloginService.updateByName(userlogin.getUsername(), u);
    280. } else {
    281. throw new CustomException("没找到该用户");
    282. }
    283. return "admin/userPasswordRest";
    284. }
    285. // 本账户密码重置
    286. @RequestMapping("/passwordRest")
    287. public String passwordRestUI() throws Exception {
    288. return "admin/passwordRest";
    289. }
    290. }

    如果也想学习本系统,下面领取。关注并回复:159ssm

  • 相关阅读:
    【cpolar】Ubuntu本地快速搭建web小游戏网站,公网用户远程访问
    Google Earth Engine(GEE)——快速建立一个10km的格网
    杭州动环监控系统供应商,动环监控设备
    2022-8-6 集合容器
    Nuscenes数据集总结(下)
    STL set 和 map
    基于Java+SpringBoot+Vue+协同过滤算法的电影推荐系统(亮点:智能推荐、协同过滤算法、在线支付、视频观看)
    vue3版本网页小游戏
    功率放大器应用领域分享:利用微流控层流实现多种先进聚合物薄膜
    【响应式布局】使用 flexbox 实现简单响应式布局
  • 原文地址:https://blog.csdn.net/hanyunlong1989/article/details/126456256