寒假web开发8

表七: Social
sql

点击查看代码
CREATE TABLE tb_social(
    AssessmentID VARCHAR(8) PRIMARY KEY,  -- 评估编号(主键,关联到 tb_older 表的 AssessmentID)
    -- B.4.1 生活能力
    lifeAbility INT, -- 生活能力评分
    -- B.4.2 工作能力
    workAbility INT, -- 工作能力评分
    -- B.4.3 时间/空间定向
    timeSpaceOrientation INT , -- 时间/空间定向评分
    -- B.4.4 人物定向
    personOrientation INT , -- 人物定向评分
    -- B.4.5 社会交往能力
    socialInteractionAbility INT , -- 社会交往能力评分
    -- B.4.6 社会参与总分
    totalScore INT , -- 社会参与总分
    -- 上述5个项目得分之和

    participationGrade INT  -- 社会参与分级
);

SocialMapper

点击查看代码
package com.QixunQiu.mapper;

import com.QixunQiu.pojo.Communication;
import com.QixunQiu.pojo.Social;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface SocialMapper {
    @Select("select * from tb_social where AssessmentID = #{AssessmentID} ")
    List<Social> select(@Param("AssessmentID") String AssessmentID);

    void addSocial(Social social);
}

Social的pojo

点击查看代码
package com.QixunQiu.pojo;

public class Social{

    private String assessmentID; // 评估编号(主键)
    private Integer lifeAbility; // 生活能力评分
    private Integer workAbility; // 工作能力评分
    private Integer timeSpaceOrientation; // 时间/空间定向评分
    private Integer personOrientation; // 人物定向评分
    private Integer socialInteractionAbility; // 社会交往能力评分
    private Integer totalScore; // 社会参与总分
    private Integer participationGrade; // 社会参与分级

    // Default constructor
    public Social() {
    }

    // Parameterized constructor
    public Social(String assessmentID, Integer lifeAbility, Integer workAbility,
                            Integer timeSpaceOrientation, Integer personOrientation,
                            Integer socialInteractionAbility, Integer totalScore,
                            Integer participationGrade) {
        this.assessmentID = assessmentID;
        this.lifeAbility = lifeAbility;
        this.workAbility = workAbility;
        this.timeSpaceOrientation = timeSpaceOrientation;
        this.personOrientation = personOrientation;
        this.socialInteractionAbility = socialInteractionAbility;
        this.totalScore = totalScore;
        this.participationGrade = participationGrade;
    }

    // Getters and Setters
    public String getAssessmentID() {
        return assessmentID;
    }

    public void setAssessmentID(String assessmentID) {
        this.assessmentID = assessmentID;
    }

    public Integer getLifeAbility() {
        return lifeAbility;
    }

    public void setLifeAbility(Integer lifeAbility) {
        this.lifeAbility = lifeAbility;
    }

    public Integer getWorkAbility() {
        return workAbility;
    }

    public void setWorkAbility(Integer workAbility) {
        this.workAbility = workAbility;
    }

    public Integer getTimeSpaceOrientation() {
        return timeSpaceOrientation;
    }

    public void setTimeSpaceOrientation(Integer timeSpaceOrientation) {
        this.timeSpaceOrientation = timeSpaceOrientation;
    }

    public Integer getPersonOrientation() {
        return personOrientation;
    }

    public void setPersonOrientation(Integer personOrientation) {
        this.personOrientation = personOrientation;
    }

    public Integer getSocialInteractionAbility() {
        return socialInteractionAbility;
    }

    public void setSocialInteractionAbility(Integer socialInteractionAbility) {
        this.socialInteractionAbility = socialInteractionAbility;
    }

    public Integer getTotalScore() {
        return totalScore;
    }

    public void setTotalScore(Integer totalScore) {
        this.totalScore = totalScore;
    }

    public Integer getParticipationGrade() {
        return participationGrade;
    }

    public void setParticipationGrade(Integer participationGrade) {
        this.participationGrade = participationGrade;
    }

    // toString method for debugging
    @Override
    public String toString() {
        return "SocialAssessment{" +
                "assessmentID='" + assessmentID + '\'' +
                ", lifeAbility=" + lifeAbility +
                ", workAbility=" + workAbility +
                ", timeSpaceOrientation=" + timeSpaceOrientation +
                ", personOrientation=" + personOrientation +
                ", socialInteractionAbility=" + socialInteractionAbility +
                ", totalScore=" + totalScore +
                ", participationGrade=" + participationGrade +
                '}';
    }
}

SocialService

点击查看代码
package com.QixunQiu.pojo;

public class Social{

    private String assessmentID; // 评估编号(主键)
    private Integer lifeAbility; // 生活能力评分
    private Integer workAbility; // 工作能力评分
    private Integer timeSpaceOrientation; // 时间/空间定向评分
    private Integer personOrientation; // 人物定向评分
    private Integer socialInteractionAbility; // 社会交往能力评分
    private Integer totalScore; // 社会参与总分
    private Integer participationGrade; // 社会参与分级

    // Default constructor
    public Social() {
    }

    // Parameterized constructor
    public Social(String assessmentID, Integer lifeAbility, Integer workAbility,
                            Integer timeSpaceOrientation, Integer personOrientation,
                            Integer socialInteractionAbility, Integer totalScore,
                            Integer participationGrade) {
        this.assessmentID = assessmentID;
        this.lifeAbility = lifeAbility;
        this.workAbility = workAbility;
        this.timeSpaceOrientation = timeSpaceOrientation;
        this.personOrientation = personOrientation;
        this.socialInteractionAbility = socialInteractionAbility;
        this.totalScore = totalScore;
        this.participationGrade = participationGrade;
    }

    // Getters and Setters
    public String getAssessmentID() {
        return assessmentID;
    }

    public void setAssessmentID(String assessmentID) {
        this.assessmentID = assessmentID;
    }

    public Integer getLifeAbility() {
        return lifeAbility;
    }

    public void setLifeAbility(Integer lifeAbility) {
        this.lifeAbility = lifeAbility;
    }

    public Integer getWorkAbility() {
        return workAbility;
    }

    public void setWorkAbility(Integer workAbility) {
        this.workAbility = workAbility;
    }

    public Integer getTimeSpaceOrientation() {
        return timeSpaceOrientation;
    }

    public void setTimeSpaceOrientation(Integer timeSpaceOrientation) {
        this.timeSpaceOrientation = timeSpaceOrientation;
    }

    public Integer getPersonOrientation() {
        return personOrientation;
    }

    public void setPersonOrientation(Integer personOrientation) {
        this.personOrientation = personOrientation;
    }

    public Integer getSocialInteractionAbility() {
        return socialInteractionAbility;
    }

    public void setSocialInteractionAbility(Integer socialInteractionAbility) {
        this.socialInteractionAbility = socialInteractionAbility;
    }

    public Integer getTotalScore() {
        return totalScore;
    }

    public void setTotalScore(Integer totalScore) {
        this.totalScore = totalScore;
    }

    public Integer getParticipationGrade() {
        return participationGrade;
    }

    public void setParticipationGrade(Integer participationGrade) {
        this.participationGrade = participationGrade;
    }

    // toString method for debugging
    @Override
    public String toString() {
        return "SocialAssessment{" +
                "assessmentID='" + assessmentID + '\'' +
                ", lifeAbility=" + lifeAbility +
                ", workAbility=" + workAbility +
                ", timeSpaceOrientation=" + timeSpaceOrientation +
                ", personOrientation=" + personOrientation +
                ", socialInteractionAbility=" + socialInteractionAbility +
                ", totalScore=" + totalScore +
                ", participationGrade=" + participationGrade +
                '}';
    }
}

AddSocialServlet

点击查看代码
package com.QixunQiu.web;

import com.QixunQiu.pojo.Social;
import com.QixunQiu.service.SocialService;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet("/AddSocialServlet")
public class AddSocialServlet extends HttpServlet {
    private SocialService socialService = new SocialService();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        response.setCharacterEncoding("UTF-8");
        response.setContentType("text/html;charset=UTF-8");
        String assessmentID=request.getParameter("assessmentID");
        int lifeAbility=Integer.parseInt(request.getParameter("lifeAbility"));
        int workAbility=Integer.parseInt(request.getParameter("workAbility"));
        int timeSpaceOrientation=Integer.parseInt(request.getParameter("timeSpaceOrientation"));
        int personOrientation=Integer.parseInt(request.getParameter("personOrientation"));
        int socialInteractionAbility=Integer.parseInt(request.getParameter("socialInteractionAbility"));

        // 计算总分
        int totalScore = lifeAbility + workAbility + timeSpaceOrientation + personOrientation
                + socialInteractionAbility;

        // 计算社会参与分级
        int participationGrade;
        if (totalScore >= 0 && totalScore <= 2) {
            participationGrade = 0;
        } else if (totalScore >= 3 && totalScore <= 7) {
            participationGrade = 1;
        } else if (totalScore >= 8 && totalScore <= 13) {
            participationGrade = 2;
        } else {
            participationGrade = 3;
        }

        Social social = new Social();
        social.setAssessmentID(assessmentID);
        social.setLifeAbility(lifeAbility);
        social.setWorkAbility(workAbility);
        social.setTimeSpaceOrientation(timeSpaceOrientation);
        social.setPersonOrientation(personOrientation);
        social.setSocialInteractionAbility(socialInteractionAbility);
        social.setTotalScore(totalScore);
        social.setParticipationGrade(participationGrade);

        socialService.add(social);


    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
}

selectSocialServlet

点击查看代码
package com.QixunQiu.web;

import com.QixunQiu.pojo.Communication;
import com.QixunQiu.pojo.Older;
import com.QixunQiu.pojo.Social;
import com.QixunQiu.pojo.User;
import com.QixunQiu.service.OlderService;
import com.QixunQiu.service.SocialService;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

@WebServlet("/selectSocialServlet")
public class selectSocialServlet extends HttpServlet {
    private OlderService olderService = new OlderService();
    private SocialService socialService = new SocialService();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html;charset=utf-8");
        HttpSession session = request.getSession();
        User user = (User) session.getAttribute("user");
        Older older=olderService.selectOlderById(user.getUserID());
        List<Social> socialList=socialService.selectSocial(older.getAssessmentID());
        PrintWriter writer = response.getWriter();
        if(!socialList.isEmpty()){
            // 登陆成功
            writer.write("登陆成功");
            System.out.println(socialList);
            session.setAttribute("socialList", socialList);
            request.getRequestDispatcher("/social.jsp").forward(request,response);

        }else {
            // 登陆失败
            writer.write("登陆失败");
            request.getRequestDispatcher("/addSocial.jsp").forward(request,response);
        }

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
}

SocialMapper.xml

点击查看代码
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.QixunQiu.mapper.SocialMapper">


    <insert id="addSocial" parameterType="com.QixunQiu.pojo.Social">
        INSERT INTO tb_social (
            AssessmentID,
            lifeAbility,
            workAbility,
            timeSpaceOrientation,
            personOrientation,
            socialInteractionAbility,
            totalScore,
            participationGrade
        ) VALUES (
                     #{assessmentID},
                     #{lifeAbility},
                     #{workAbility},
                     #{timeSpaceOrientation},
                     #{personOrientation},
                     #{socialInteractionAbility},
                     #{totalScore},
                     #{participationGrade}
                 )
    </insert>
</mapper>

addSocial.jsp

点击查看代码
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>添加社会参与评估</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f4f4f4;
            margin: 0;
            padding: 0;
        }
        .container {
            width: 50%;
            margin: 50px auto;
            background: #fff;
            padding: 20px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
        }
        h2 {
            text-align: center;
            color: #333;
        }
        label {
            display: block;
            margin: 10px 0 5px;
            color: #555;
        }
        input[type="text"], input[type="number"], select {
            width: 100%;
            padding: 8px;
            margin-bottom: 10px;
            border: 1px solid #ccc;
            border-radius: 4px;
        }
        input[type="submit"] {
            width: 100%;
            padding: 10px;
            background-color: #28a745;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
        }
        input[type="submit"]:hover {
            background-color: #218838;
        }
    </style>
</head>
<body>
<div class="container">
    <h2>添加社会参与评估</h2>
    <form action="${pageContext.request.contextPath}/AddSocialServlet" method="post">
        <label for="assessmentID">评估编号:</label>
        <input type="text" id="assessmentID" name="assessmentID" required>

        <label for="lifeAbility">生活能力评分:</label>
        <select id="lifeAbility" name="lifeAbility" required>
            <option value="0">0 - 除个人生活自理外,能料理家务或当家管理事务</option>
            <option value="1">1 - 除个人生活自理外,能做家务,但欠好,家庭事务安排欠条理</option>
            <option value="2">2 - 个人生活能自理;只有在他人帮助下才能做些家务,但质量不好</option>
            <option value="3">3 - 个人基本生活事务能自理,在督促下可洗漱</option>
            <option value="4">4 - 个人基本生活事务需要部分帮助或完全依赖他人帮助</option>
        </select>

        <label for="workAbility">工作能力评分:</label>
        <select id="workAbility" name="workAbility" required>
            <option value="0">0 - 原来熟练的脑力工作或体力技巧性工作可照常进行</option>
            <option value="1">1 - 原来熟练的脑力工作或体力技巧性工作能力有所下降</option>
            <option value="2">2 - 原来熟练的脑力工作或体力技巧性工作明显不如以往,部分遗忘</option>
            <option value="3">3 - 对熟练工作只有一些片段保留,技能全部遗忘</option>
            <option value="4">4 - 对以往的知识或技能全部磨灭</option>
        </select>

        <label for="timeSpaceOrientation">时间/空间定向评分:</label>
        <select id="timeSpaceOrientation" name="timeSpaceOrientation" required>
            <option value="0">0 - 时间观念清楚;可单独出远门,能很快掌握新环境的方位</option>
            <option value="1">1 - 时间观念有些下降,可单独来往于近街,知道现住地的名称和方位</option>
            <option value="2">2 - 时间观念较差,只能单独在家附近行动,对现住地只知名称</option>
            <option value="3">3 - 时间观念很差,只能在左邻右舍间串门,对现住地不知名称和方位</option>
            <option value="4">4 - 无时间观念;不能单独外出</option>
        </select>

        <label for="personOrientation">人物定向评分:</label>
        <select id="personOrientation" name="personOrientation" required>
            <option value="0">0 - 知道周围人们的关系,知道祖孙、叔伯、姑姨等称谓的意义</option>
            <option value="1">1 - 只知家中亲密近亲的关系,不会分辨陌生人的大致年龄</option>
            <option value="2">2 - 只能称呼家中人,或只能照样称呼,不知其关系,不辨辈分</option>
            <option value="3">3 - 只认识常同住的亲人,可称呼子女或孙子女,可辨熟人和生人</option>
            <option value="4">4 - 只认识保护人,不辨熟人和生人</option>
        </select>

        <label for="socialInteractionAbility">社会交往能力评分:</label>
        <select id="socialInteractionAbility" name="socialInteractionAbility" required>
            <option value="0">0 - 参与社会,在社会环境有一定的适应能力,待人接物恰当</option>
            <option value="1">1 - 能适应单纯环境,主动接触人,初见面时难让人发现智力问题</option>
            <option value="2">2 - 脱离社会,可被动接触,不会主动待人,谈话中很多不适词句</option>
            <option value="3">3 - 勉强可与人交往,谈吐内容不清楚,表情不恰当</option>
            <option value="4">4 - 难以与人接触</option>
        </select>

        <input type="submit" value="提交">
    </form>
</div>
</body>
</html>

social.jsp

点击查看代码
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>社会参与评估列表</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 20px;
        }
        h1 {
            text-align: center;
        }
        table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 20px;
        }
        table, th, td {
            border: 1px solid #ddd;
        }
        th, td {
            padding: 10px;
            text-align: left;
        }
        th {
            background-color: #f2f2f2;
        }
        tr:hover {
            background-color: #f5f5f5;
        }
    </style>
</head>
<body>
<h1>社会参与评估记录</h1>
    <table>
        <thead>
        <tr>
            <th>评估编号</th>
            <th>生活能力评分</th>
            <th>工作能力评分</th>
            <th>时间/空间定向评分</th>
            <th>人物定向评分</th>
            <th>社会交往能力评分</th>
            <th>社会参与总分</th>
            <th>社会参与分级</th>
        </tr>
        </thead>
        <tbody>
        <c:forEach var="assessment" items="${socialList}">
        <tr>
            <td>${assessment.assessmentID}</td>
            <td>
                <c:choose>
                    <c:when test="${assessment.lifeAbility == 0}">0 - 除个人生活自理外,能料理家务或当家管理事务</c:when>
                    <c:when test="${assessment.lifeAbility == 1}">1 - 除个人生活自理外,能做家务,但欠好,家庭事务安排欠条理</c:when>
                    <c:when test="${assessment.lifeAbility == 2}">2 - 个人生活能自理;只有在他人帮助下才能做些家务,但质量不好</c:when>
                    <c:when test="${assessment.lifeAbility == 3}">3 - 个人基本生活事务能自理,在督促下可洗漱</c:when>
                    <c:when test="${assessment.lifeAbility == 4}">4 - 个人基本生活事务需要部分帮助或完全依赖他人帮助</c:when>
                    <c:otherwise>未知</c:otherwise>
                </c:choose>
            </td>
            <td>
                <c:choose>
                    <c:when test="${assessment.workAbility == 0}">0 - 原来熟练的脑力工作或体力技巧性工作可照常进行</c:when>
                    <c:when test="${assessment.workAbility == 1}">1 - 原来熟练的脑力工作或体力技巧性工作能力有所下降</c:when>
                    <c:when test="${assessment.workAbility == 2}">2 - 原来熟练的脑力工作或体力技巧性工作明显不如以往,部分遗忘</c:when>
                    <c:when test="${assessment.workAbility == 3}">3 - 对熟练工作只有一些片段保留,技能全部遗忘</c:when>
                    <c:when test="${assessment.workAbility == 4}">4 - 对以往的知识或技能全部磨灭</c:when>
                    <c:otherwise>未知</c:otherwise>
                </c:choose>
            </td>
            <td>
                <c:choose>
                    <c:when test="${assessment.timeSpaceOrientation == 0}">0 - 时间观念清楚;可单独出远门,能很快掌握新环境的方位</c:when>
                    <c:when test="${assessment.timeSpaceOrientation == 1}">1 - 时间观念有些下降,可单独来往于近街,知道现住地的名称和方位</c:when>
                    <c:when test="${assessment.timeSpaceOrientation == 2}">2 - 时间观念较差,只能单独在家附近行动,对现住地只知名称</c:when>
                    <c:when test="${assessment.timeSpaceOrientation == 3}">3 - 时间观念很差,只能在左邻右舍间串门,对现住地不知名称和方位</c:when>
                    <c:when test="${assessment.timeSpaceOrientation == 4}">4 - 无时间观念;不能单独外出</c:when>
                    <c:otherwise>未知</c:otherwise>
                </c:choose>
            </td>
            <td>
                <c:choose>
                    <c:when test="${assessment.personOrientation == 0}">0 - 知道周围人们的关系,知道祖孙、叔伯、姑姨等称谓的意义</c:when>
                    <c:when test="${assessment.personOrientation == 1}">1 - 只知家中亲密近亲的关系,不会分辨陌生人的大致年龄</c:when>
                    <c:when test="${assessment.personOrientation == 2}">2 - 只能称呼家中人,或只能照样称呼,不知其关系,不辨辈分</c:when>
                    <c:when test="${assessment.personOrientation == 3}">3 - 只认识常同住的亲人,可称呼子女或孙子女,可辨熟人和生人</c:when>
                    <c:when test="${assessment.personOrientation == 4}">4 - 只认识保护人,不辨熟人和生人</c:when>
                    <c:otherwise>未知</c:otherwise>
                </c:choose>
            </td>
            <td>
                <c:choose>
                    <c:when test="${assessment.socialInteractionAbility == 0}">0 - 参与社会,在社会环境有一定的适应能力,待人接物恰当</c:when>
                    <c:when test="${assessment.socialInteractionAbility == 1}">1 - 能适应单纯环境,主动接触人,初见面时难让人发现智力问题</c:when>
                    <c:when test="${assessment.socialInteractionAbility == 2}">2 - 脱离社会,可被动接触,不会主动待人,谈话中很多不适词句</c:when>
                    <c:when test="${assessment.socialInteractionAbility == 3}">3 - 勉强可与人交往,谈吐内容不清楚,表情不恰当</c:when>
                    <c:when test="${assessment.socialInteractionAbility == 4}">4 - 难以与人接触</c:when>
                    <c:otherwise>未知</c:otherwise>
                </c:choose>
            </td>
            <td>${assessment.totalScore}</td>
            <td>
                <c:choose>
                    <c:when test="${assessment.participationGrade == 0}">0 - 能力完好(总分0-2分)</c:when>
                    <c:when test="${assessment.participationGrade == 1}">1 - 轻度受损(总分3-7分)</c:when>
                    <c:when test="${assessment.participationGrade == 2}">2 - 中度受损(总分8-13分)</c:when>
                    <c:when test="${assessment.participationGrade == 3}">3 - 重度受损(总分14-20分)</c:when>
                    <c:otherwise>未知</c:otherwise>
                </c:choose>
            </td>
        </tr>
        </c:forEach>
        </tbody>
    </table>
</div>
</body>
</html>
posted @   QixunQiu  阅读(2)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· DeepSeek在M芯片Mac上本地化部署
· 葡萄城 AI 搜索升级:DeepSeek 加持,客户体验更智能
点击右上角即可分享
微信分享提示