• 会议信息管理系统SSM记录(六)



    目录:

    (1)会议预定1

    (2)会议预定2

    (3)会议预约3

    (4)会议预定4


    (1)会议预定1

    创建MeetingController:

    1. //跳转预定会议页面
    2. @RequestMapping("/bookmeeting")
    3. public String bookmeeting(Model model){
    4. model.addAttribute("mrs",meetingRoomService.getAllMr());//查询所有会议室
    5. return "bookmeeting";
    6. }

     

    删除预定页面部门的固定代码:

     

     修改:

     

     

     (2)会议预定2

    添加json依赖:

    在MeetingController添加:获取部门请求:

     

    1. //返回所有的部门
    2. @RequestMapping("/alldeps")
    3. @ResponseBody
    4. public List getAllDeps(){
    5. return departmentService.getAllDeps();
    6. }

     

    1. //获取所有部门
    2. public List getAllDeps() {
    3. return departmentMapper.getAllDeps();
    4. }
    1. //获取所有部门
    2. List<Department> getAllDeps();
    1. <!--获取所有部门-->
    2. <select id="getAllDeps" resultType="com.xzb.meeting.model.Department">
    3. select *
    4. from department
    5. </select>

    在MeetingController:添加 

    获取员工请求:

     

     

    1. //通过部门编号获取员工
    2. @RequestMapping("/getempbydepid")
    3. @ResponseBody
    4. public List getEmpsByDepId(Integer depId){
    5. return employeeService.getEmpsByDepId(depId);
    6. }

     在EmployeeService:添加:

    1. //通过部门编号获取员工
    2. public List<Employee> getEmpsByDepId(Integer depId) {
    3. return employeeMapper.getEmpsByDepId(depId);
    4. }

     在EmployeeMapper:添加这个方法:

    1. //通过部门编号获取员工
    2. List<Employee> getEmpsByDepId(Integer depId);

     EmployeeMapper.xml:书写sql语句:

     

    1. <!--通过部门编号获取员工-->
    2. <select id="getEmpsByDepId" resultType="com.xzb.meeting.model.Employee">
    3. select *
    4. from employee
    5. where departmentid = #{depId}
    6. </select>

    引入在线jquery的依赖:

     

    1. <script type="application/javascript">
    2. var selDepartments;
    3. var selEmployees;
    4. var selSelectedEmployees;
    5. function body_load(){
    6. selDepartments = document.getElementById("selDepartments");
    7. selEmployees = document.getElementById("selEmployees");
    8. selSelectedEmployees = document.getElementById("selSelectedEmployees");
    9. //发送ajax请求 返回所有的部门
    10. $.get("/alldeps", function (data) {
    11. for (let i = 0; i < data.length; i++) {
    12. var item = data[i];
    13. var dep = document.createElement("option");//创建一个option元素
    14. dep.value = item.departmentId;
    15. dep.text = item.departmentName;
    16. selDepartments.appendChild(dep);//把option放到selDepartments下拉列表
    17. }
    18. fillEmployees();
    19. })
    20. }
    21. //填充下方的
    22. function fillEmployees(){
    23. clearList(selEmployees);//清除上次的
    24. var departmentid = selDepartments.options[selDepartments.selectedIndex].value;
    25. //发送ajax获取 通过部门编号获取员工
    26. $.get("/getempbydepid?depId="+departmentid,function (data) {
    27. for(i=0;i<data.length;i++) {
    28. var emp = document.createElement("option");
    29. emp.value = data[i].employeeId;
    30. emp.text = data[i].employeeName;
    31. selEmployees.appendChild(emp);
    32. }
    33. })
    34. }
    35. //清除方法
    36. function clearList(list){
    37. while(list.childElementCount > 0){
    38. list.removeChild(list.lastChild);
    39. }
    40. }
    41. //选择员工
    42. function selectEmployees(){
    43. for(var i=0;i<selEmployees.options.length;i++){
    44. if (selEmployees.options[i].selected){
    45. addEmployee(selEmployees.options[i]);
    46. selEmployees.options[i].selected = false;
    47. }
    48. }
    49. }
    50. //把员工从右边从删除
    51. function deSelectEmployees(){
    52. var elementsToRemoved = new Array();
    53. var options = selSelectedEmployees.options;
    54. for(var i=0;i<options.length;i++){
    55. if (options[i].selected){
    56. elementsToRemoved.push(options[i]);
    57. }
    58. }
    59. for(i=0;i<elementsToRemoved.length;i++){
    60. selSelectedEmployees.removeChild(elementsToRemoved[i]);
    61. }
    62. }
    63. //把选择的员工添加到右边框内
    64. function addEmployee(optEmployee){
    65. var options = selSelectedEmployees.options;
    66. var i = 0;
    67. var insertIndex = -1;
    68. while(i < options.length){
    69. if (optEmployee.value == options[i].value){
    70. return;
    71. } else if (optEmployee.value < options[i].value) {
    72. insertIndex = i;
    73. break;
    74. }
    75. i++;
    76. }
    77. var opt = document.createElement("option");
    78. opt.value = optEmployee.value;
    79. opt.text = optEmployee.text;
    80. opt.selected = true;
    81. if (insertIndex == -1){
    82. selSelectedEmployees.appendChild(opt);
    83. } else {
    84. selSelectedEmployees.insertBefore(opt, options[insertIndex]);
    85. }
    86. }
    87. </script>

    (3)会议预约3

     

    使用日历的插件

     

    在配置文件中mvc:spring-servlet.xml中配置不拦截:

     

     然后 在页面引入js文件:

    修改:

     

     

     

     

     (4)会议预定4

    创建Meeting实体类:

    创建DataConverter:时间类型转换:

    1. package com.xzb.meeting.converter;
    2. import org.springframework.core.convert.converter.Converter;
    3. import java.text.ParseException;
    4. import java.text.SimpleDateFormat;
    5. import java.util.Date;
    6. /**
    7. * 类型转换
    8. */
    9. public class DateConverter implements Converter {
    10. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    11. public Date convert(String source) {
    12. try {
    13. return sdf.parse(source);
    14. } catch (ParseException e) {
    15. e.printStackTrace();
    16. }
    17. return null;
    18. }
    19. }

     在配置文件中配置:mvc:spring-servlet.xml

     

    在MeetingController中添加:预约会议方法:

    1. //添加会议请求 meeting会议的信息 mps:参加人员的数组
    2. @RequestMapping("/doAddMeeting")
    3. public String bookMeeting(Meeting meeting, Integer[] mps, HttpSession httpSession){
    4. Employee currentuser = (Employee) httpSession.getAttribute("currentuser");//从session里面获取当前登录的用户
    5. meeting.setReservationistid(currentuser.getEmployeeId());//设置meeting信息,设置发起会议的用户
    6. Integer result = meetingService.addmeeting(meeting,mps);
    7. if (result == 1){
    8. return "redirect:/searchmeetings";
    9. }else {
    10. return "forward:/bookmeeting";
    11. }
    12. }

     在MeetingService:添加:

     

     

    1. //添加会议请求 mps 参加会议的员工的员工ID
    2. public Integer addmeeting(Meeting meeting, Integer[] mps) {
    3. meeting.setReservationtime(new Date());
    4. meeting.setStatus(0);//设置会议的状态
    5. Integer result = meetingMapper.addmeeting(meeting);//往会议表添加一条数据
    6. meetingMapper.addParticipants(meeting.getMeetingid(),mps);//往会议员工记录表添加一条数据
    7. return result;
    8. }

    在MeetingMapper:添加:

    1. //添加会议请求
    2. Integer addmeeting(Meeting meeting);
    1. //添加参会人员
    2. void addParticipants(@Param("meetingid") Integer meetingid,@Param("mps") Integer[] mps);

    MeetingMapper.xml添加sql语句

    1. <!--添加会议请求-->
    2. <insert id="addmeeting" useGeneratedKeys="true" keyProperty="meetingid">
    3. insert into meeting (meetingname,roomid,reservationistid,numberofparticipants,starttime,endtime,reservationtime,canceledtime,description,status)
    4. values (#{meetingname}, #{roomid}, #{reservationistid}, #{numberofparticipants}, #{starttime}, #{endtime},
    5. #{reservationtime}, #{canceledtime}, #{description}, #{status})
    6. </insert>
    1. <!--添加参会人员-->
    2. <insert id="addParticipants">
    3. insert into meetingparticipants(meetingid,employeeid) values
    4. <foreach collection="mps" item="mp" separator=",">
    5. (#{meetingid},#{mp})
    6. </foreach>
    7. </insert>

     

  • 相关阅读:
    MogaFX—哈萨克斯坦坚戈汇率10月走强
    Python环境安装参考(python解释器+Pycharm软件)
    Google Earth Engine ——常用简单的简写和全程
    『德不孤』Pytest框架 — 7、Pytest预期失败
    lv9 嵌入式开发 数据库sqlite
    如何获取量化交易历史复权数据?
    Sequential Recommendation with Graph Neural Networks
    HTTP1.1协议详解
    谷歌AI搜索功能“翻车”,用户体验引担忧
    C++从0吃透string类
  • 原文地址:https://blog.csdn.net/dengfengling999/article/details/128018347