• OA项目之会议通知(查询&是否参会&反馈详情)


    目录

    一、会议通知查询SQL

    二、会议反馈详情SQL

    三、会议通知后台代码实现

    四、会议反馈功能实现

    五、反馈详情功能实现


    一、会议通知查询SQL(难点)

    登录xx账号,就要查出凡是xx是参与者、列席这、主持人中的一员,那么都要查出来

    查询条件:登录用户 id 2

    分析(涉及到的表):

            会议信息表:t_oa_meeting_info

            会议反馈表:t_oa_meeting_feedback

     例: 1、查询出带xx  id=2 的会议信息:
     

    1. SELECT * from t_oa_meeting_info where FIND_IN_SET(2,CONCAT(canyuze,',',liexize,',',zhuchiren))
    2. and state=4

    运行SQL结果:


            2、不管会议是否得到反馈,都要查询出来,所以选外连接,会议信息表为主:

    1. SELECT
    2.     IFNULL(f.result,-1) result,t1.*
    3. FROM
    4. (SELECT * from t_oa_meeting_info where FIND_IN_SET(2,CONCAT(canyuze,',',liexize,',',zhuchiren)) and state=4) t1
    5. LEFT JOIN t_oa_meeting_feedback f on t1.id=f.meetingId
    6. and f.personId=2
    7.  ORDER BY result;

    运行SQL结果:

    二、会议反馈详情SQL(难点)

    分析(涉及到的表):

            用户表:t_oa_user

            会议信息表:t_oa_meeting_info

            会议反馈表:t_oa_meeting_feedback

    查询条件:会议 id 12

    1、拿到会议 id 为12的会议,所有参与人员的姓名

           1) 先拿到所有的参与人员 id

    1. SELECT CONCAT(canyuze,',',liexize,',',zhuchiren) from
    2. t_oa_meeting_info where id=12

           SQL运行结果: 

                             

           2)   再拿到对应参与人员的姓名

    1. SELECT * from t_oa_user
    2. where
    3. FIND_IN_SET(id, (SELECT CONCAT(canyuze,',',liexize,',',zhuchiren)
    4. from
    5. t_oa_meeting_info where id=12))

           SQL运行结果:  

     

     2、连接 会议信息反馈表,拿到对应的反馈情况(未读、参加、不参加)

    1. SELECT * from t_oa_user where FIND_IN_SET(id, (SELECT CONCAT(canyuze,',',liexize,',',zhuchiren) from
    2. t_oa_meeting_info where id=12))

         SQL运行结果:  

    3、根据 会议信息反馈情况进行分组

    1. select
    2. t.result,GROUP_CONCAT(t.name) names
    3. from
    4. (select
    5. t1.name,IFNULL(f.result,-1) result
    6. from
    7. (SELECT * from t_oa_user where FIND_IN_SET(id, (SELECT CONCAT(canyuze,',',liexize,',',zhuchiren) from
    8. t_oa_meeting_info
    9. where id=12))) t1
    10. left join t_oa_meeting_feedback f on t1.id=f.personId and f.meetingId=12) t
    11. GROUP BY t.result

      SQL运行结果:  

    三、会议通知后台代码实现

            这里简单提及一下前端代码

          

      header.jsp:

    1. <%@ page language="java" contentType="text/html; charset=UTF-8"
    2. pageEncoding="UTF-8"%>
    3. DOCTYPE html>
    4. <link rel="stylesheet" href="${pageContext.request.contextPath }/static/js/layui/css/layui.css">
    5. <script src="${pageContext.request.contextPath }/static/js/layui/layui.js">script>
    6. <base href="${pageContext.request.contextPath }/"/>
    7. <script src="${pageContext.request.contextPath }/static/js/layui/config.js">script>
    8. <input id="ctx" value="${pageContext.request.contextPath }" type="hidden"/>
    9. <title>玉渊工作室title>

     前面SQL语句都已编写完毕,接下来就开始实现后台代码了:

    实体类:MeetingFeedBack  对应会议反馈表

    1. package com.zking.entity;
    2. import java.io.Serializable;
    3. /**
    4. * t_oa_meeting_feedback 会议反馈表
    5. * 实体类:会议反馈
    6. * @author 杨总
    7. *
    8. */
    9. public class MeetingFeedBack implements Serializable {
    10. private String id;
    11. private Long meetingId;
    12. private Integer personType;
    13. private Long personId;
    14. private Integer result;
    15. private String reason;
    16. // 会议标题
    17. private String title;
    18. public String getTitle() {
    19. return title;
    20. }
    21. public void setTitle(String title) {
    22. this.title = title;
    23. }
    24. public String getId() {
    25. return id;
    26. }
    27. public void setId(String id) {
    28. this.id = id;
    29. }
    30. public Long getMeetingId() {
    31. return meetingId;
    32. }
    33. public void setMeetingId(Long meetingId) {
    34. this.meetingId = meetingId;
    35. }
    36. public Integer getPersonType() {
    37. return personType;
    38. }
    39. public void setPersonType(Integer personType) {
    40. this.personType = personType;
    41. }
    42. public Long getPersonId() {
    43. return personId;
    44. }
    45. public void setPersonId(Long personId) {
    46. this.personId = personId;
    47. }
    48. public Integer getResult() {
    49. return result;
    50. }
    51. public void setResult(Integer result) {
    52. this.result = result;
    53. }
    54. public String getReason() {
    55. return reason;
    56. }
    57. public void setReason(String reason) {
    58. this.reason = reason;
    59. }
    60. public MeetingFeedBack() {
    61. super();
    62. // TODO Auto-generated constructor stub
    63. }
    64. @Override
    65. public String toString() {
    66. return "MeetingFeedBack [id=" + id + ", meetingId=" + meetingId + ", personType=" + personType + ", personId="
    67. + personId + ", result=" + result + ", reason=" + reason + "]";
    68. }
    69. }

    MeetingFeedBackDao:

    1. package com.zking.dao;
    2. import java.sql.SQLException;
    3. import java.util.List;
    4. import java.util.Map;
    5. import com.zking.entity.MeetingFeedBack;
    6. import com.zking.util.BaseDao;
    7. import com.zking.util.PageBean;
    8. public class MeetingFeedBackDao extends BaseDao<MeetingFeedBack>{
    9. //会议通知查询
    10. public List<Map<String, Object>> queryMeetingFeedBackByUserId(MeetingFeedBack back, PageBean pageBean)
    11. throws SQLException, InstantiationException, IllegalAccessException {
    12. String sql="SELECT\r\n" +
    13. " IFNULL(f.result,-1) result,t1.*\r\n" +
    14. " FROM\r\n" +
    15. " (SELECT * from t_oa_meeting_info where FIND_IN_SET("+back.getPersonId()+",CONCAT(canyuze,',',liexize,',',zhuchiren)) and state=4) t1\r\n" +
    16. " LEFT JOIN t_oa_meeting_feedback f on t1.id=f.meetingId\r\n" +
    17. " and f.personId="+back.getPersonId()+"\r\n" +
    18. " ORDER BY result";
    19. return super.executeQuery(sql, pageBean);
    20. }
    21. // back.getPersonId()
    22. }

    MeetingFeedBackAction:

    1. package com.zking.web;
    2. import java.util.List;
    3. import java.util.Map;
    4. import javax.servlet.http.HttpServletRequest;
    5. import javax.servlet.http.HttpServletResponse;
    6. import com.zking.dao.MeetingFeedBackDao;
    7. import com.zking.entity.MeetingFeedBack;
    8. import com.zking.framework.ActionSupport;
    9. import com.zking.framework.ModelDriver;
    10. import com.zking.util.PageBean;
    11. import com.zking.util.R;
    12. import com.zking.util.ResponseUtil;
    13. public class MeetingFeedBackAction extends ActionSupport implements ModelDriver<MeetingFeedBack>{
    14. private MeetingFeedBack back=new MeetingFeedBack();
    15. private MeetingFeedBackDao backDao=new MeetingFeedBackDao();
    16. @Override
    17. public MeetingFeedBack getModel() {
    18. return back;
    19. }
    20. // 会议通知查询
    21. public String queryMeetingFeedBackByUserId(HttpServletRequest req, HttpServletResponse resp) {
    22. try {
    23. PageBean pageBean=new PageBean();
    24. pageBean.setRequest(req);
    25. List<Map<String, Object>> infos = backDao.queryMeetingFeedBackByUserId(back, pageBean);
    26. // 注意:layui中的数据表格的格式
    27. ResponseUtil.writeJson(resp, R.ok(0, "会议通知数据查询成功",pageBean.getTotal(),infos));
    28. } catch (Exception e) {
    29. e.printStackTrace();
    30. try {
    31. ResponseUtil.writeJson(resp, R.error(0, "会议通知数据查询失败"));
    32. } catch (Exception e2) {
    33. e2.printStackTrace();
    34. }
    35. }
    36. return null;
    37. }
    38. }

    mvc.xml:

    1. "/feedBack" type="com.zking.web.MeetingFeedBackAction">

    运行效果如下:

    四、会议反馈功能实现(是否参会)

     MeetingFeedBackDao:

    1. // 会议反馈
    2. public int add(MeetingFeedBack back) throws Exception {
    3. String sql="insert into t_oa_meeting_feedback values (?,?,?,?,?,?)";
    4. //前台没有传递id到后台,所以自己生成id
    5. back.setId(UUID.randomUUID().toString().replace("-", ""));
    6. return super.executeUpdate(sql, back, new String [] {"id","meetingId","personType","personId","result","reason"});
    7. }

    MeetingFeedBackAction:

    1. //会议反馈
    2. public String add(HttpServletRequest req, HttpServletResponse resp) {
    3. try {
    4. // rs是sql语句执行的影响行数
    5. int rs = backDao.add(back);
    6. if(rs>0) {
    7. ResponseUtil.writeJson(resp, R.ok(200, "会议反馈信息成功"));
    8. }else {
    9. ResponseUtil.writeJson(resp, R.error(0, "会议反馈信息失败"));
    10. }
    11. } catch (Exception e) {
    12. e.printStackTrace();
    13. try {
    14. ResponseUtil.writeJson(resp, R.error(0, "会议反馈信息失败"));
    15. } catch (Exception e2) {
    16. e2.printStackTrace();
    17. }
    18. }
    19. return null;
    20. }

     接下来运行:

     

     点击会议反馈按钮之后:

    我们会发现第16条数据已经没有了,进数据库查询 会议信息反馈表(t_oa_meeting_feedback):

    会议反馈功能已实现~

    五、反馈详情功能实现

     MeetingFeedBackDao:

    1. // 会议反馈详情
    2. public List<Map<String, Object>> queryMeetingBackByMeetingId(MeetingFeedBack back, PageBean pageBean) throws InstantiationException, IllegalAccessException, SQLException {
    3. String sql="select \r\n" +
    4. " t.result,GROUP_CONCAT(t.name) names\r\n" +
    5. " from\r\n" +
    6. " (select \r\n" +
    7. " t1.name,IFNULL(f.result,-1) result\r\n" +
    8. " from\r\n" +
    9. " (SELECT * from t_oa_user where FIND_IN_SET(id, (SELECT CONCAT(canyuze,',',liexize,',',zhuchiren) from\r\n" +
    10. " t_oa_meeting_info \r\n" +
    11. " where id="+back.getMeetingId()+"))) t1\r\n" +
    12. " left join t_oa_meeting_feedback f on t1.id=f.personId and f.meetingId="+back.getMeetingId()+") t\r\n" +
    13. " GROUP BY t.result";
    14. return super.executeQuery(sql, pageBean);
    15. }

    MeetingFeedBackAction:

    1. //会议反馈详情
    2. public String queryMeetingBackByMeetingId(HttpServletRequest req, HttpServletResponse resp) {
    3. try {
    4. PageBean pageBean=new PageBean();
    5. pageBean.setRequest(req);
    6. List<Map<String, Object>> lst = backDao.queryMeetingBackByMeetingId(back, pageBean);
    7. // 注意:layui中的数据表格的格式
    8. ResponseUtil.writeJson(resp, R.ok(0, "会议反馈详情数据查询成功",pageBean.getTotal(),lst));
    9. } catch (Exception e) {
    10. e.printStackTrace();
    11. try {
    12. ResponseUtil.writeJson(resp, R.error(0, "会议反馈详情数据查询失败"));
    13. } catch (Exception e2) {
    14. e2.printStackTrace();
    15. }
    16. }
    17. return null;
    18. }

    运行效果:

    比如登录此(张强)账号,对 第8条 做出反馈: 

     说明张强是缺席的。

    接着换登录 admin 账号:

     在我的会议中查看 反馈详情:

     我们就可以看到张强在缺席人员的列表中了!

    为了准确性,接着我们测试 添加一些参会人员,比如张三,

    我们登录 张三 账号:

     现在是未读状态,点击参会:

     会议反馈成功之后,再次切换 admin 账号,

     在我的会议中查看 反馈详情:

    那么 张三就出现在参会人员的列表中啦~

    今日功能已经实现,我们下期继续!感谢观看

  • 相关阅读:
    SQL 中的 MIN 和 MAX 以及常见函数详解及示例演示
    1,2,4,5-四嗪-荧光染料-Me-tetrazine-Disulfo-Cyanine5.5/Cyanine7的研究
    C++ STL详解(五) -------- priority_queue
    Linux网络编程(socket的udp通信)
    集成环信IM时常见问题及解决——包括消息、群组、推送
    动态规划之爬楼梯问题
    yolov8 snpe Dynamic value for tensor name: 769, is not supported.
    HTML小游戏12 —— 汽车赛道飙车游戏(附完整源码)
    el-table表格变更前后根据数据值改变背景颜色
    微信小程序商城搭建二手汽车拍卖系统+后台管理系统|前后分离VUE.js
  • 原文地址:https://blog.csdn.net/weixin_65808248/article/details/126033607