Files
hzdyjs/docs/变更管理/学生信息家庭信息父母信息特殊情况字段录入问题分析.md
T
2025-07-16 18:11:31 +08:00

12 KiB
Raw Blame History

学生信息家庭信息父母信息和特殊情况字段录入问题分析

问题描述

用户反馈:新增学生信息的时候,家庭信息我都填了,但是父母信息和特殊情况并没有录入数据库。

问题分析

1. 前端表单字段分析

家庭信息标签页字段绑定

文件:web/src/views/xg-xx/studentInfo/components/StudentEditDialog.vue

父母信息字段:

<!-- 父亲信息 -->
<el-form-item label="父亲姓名" prop="fatherName">
  <el-input v-model="form.fatherName" placeholder="请输入父亲姓名" />
</el-form-item>
<el-form-item label="父亲电话" prop="fatherPhone">
  <el-input v-model="form.fatherPhone" placeholder="请输入父亲电话" />
</el-form-item>
<el-form-item label="父亲工作单位" prop="fatherWorkUnit">
  <el-input v-model="form.fatherWorkUnit" placeholder="请输入父亲工作单位" />
</el-form-item>

<!-- 母亲信息 -->
<el-form-item label="母亲姓名" prop="motherName">
  <el-input v-model="form.motherName" placeholder="请输入母亲姓名" />
</el-form-item>
<el-form-item label="母亲电话" prop="motherPhone">
  <el-input v-model="form.motherPhone" placeholder="请输入母亲电话" />
</el-form-item>
<el-form-item label="母亲工作单位" prop="motherWorkUnit">
  <el-input v-model="form.motherWorkUnit" placeholder="请输入母亲工作单位" />
</el-form-item>

特殊情况标签页字段绑定

<el-form-item label="贫困生" prop="isPoorStudent">
  <el-radio-group v-model="form.isPoorStudent">
    <el-radio :label="1">是</el-radio>
    <el-radio :label="0">否</el-radio>
  </el-radio-group>
</el-form-item>
<el-form-item label="少数民族" prop="isMinority">
  <el-radio-group v-model="form.isMinority">
    <el-radio :label="1">是</el-radio>
    <el-radio :label="0">否</el-radio>
  </el-radio-group>
</el-form-item>
<el-form-item label="残疾学生" prop="isDisabled">
  <el-radio-group v-model="form.isDisabled">
    <el-radio :label="1">是</el-radio>
    <el-radio :label="0">否</el-radio>
  </el-radio-group>
</el-form-item>
<el-form-item label="孤儿" prop="isOrphan">
  <el-radio-group v-model="form.isOrphan">
    <el-radio :label="1">是</el-radio>
    <el-radio :label="0">否</el-radio>
  </el-radio-group>
</el-form-item>
<el-form-item label="留守儿童" prop="isLeftBehindChild">
  <el-radio-group v-model="form.isLeftBehindChild">
    <el-radio :label="1">是</el-radio>
    <el-radio :label="0">否</el-radio>
  </el-radio-group>
</el-form-item>
<el-form-item label="独生子女" prop="isSingleChild">
  <el-radio-group v-model="form.isSingleChild">
    <el-radio :label="1">是</el-radio>
    <el-radio :label="0">否</el-radio>
  </el-radio-group>
</el-form-item>

前端表单初始化

// 新增模式表单初始化
form: {
  // 家庭信息
  fatherName: '',
  fatherPhone: '',
  fatherWorkUnit: '',
  motherName: '',
  motherPhone: '',
  motherWorkUnit: '',
  familyIncome: '',
  familyMembers: null,
  // 特殊情况
  isPoorStudent: 0,
  isMinority: 0,
  isDisabled: 0,
  isOrphan: 0,
  isLeftBehindChild: 0,
  isSingleChild: 0,
}

2. 后端实体类字段分析

实体类字段定义

文件:backend/ruoyi-modules/ruoyi-xg-xx/src/main/java/org/dromara/xg/domain/XgStudentInfo.java

父母信息字段:

@TableField("father_name")
private String fatherName;

@TableField("father_phone")
private String fatherPhone;

@TableField("father_work_unit")
private String fatherWorkUnit;

@TableField("mother_name")
private String motherName;

@TableField("mother_phone")
private String motherPhone;

@TableField("mother_work_unit")
private String motherWorkUnit;

特殊情况字段:

@TableField("is_poor_student")
private Integer isPoorStudent;

@TableField("is_minority")
private Integer isMinority;

@TableField("is_disabled")
private Integer isDisabled;

@TableField("is_orphan")
private Integer isOrphan;

@TableField("is_left_behind_child")
private Integer isLeftBehindChild;

@TableField("is_single_child")
private Integer isSingleChild;

3. 数据库字段分析

数据库表结构

表名:xg_student_info

父母信息字段:

  • father_name varchar(50) - 父亲姓名
  • father_phone varchar(20) - 父亲电话
  • father_work_unit varchar(200) - 父亲工作单位
  • mother_name varchar(50) - 母亲姓名
  • mother_phone varchar(20) - 母亲电话
  • mother_work_unit varchar(200) - 母亲工作单位

特殊情况字段:

  • is_poor_student tinyint(1) - 是否贫困生
  • is_minority tinyint(1) - 是否少数民族
  • is_disabled tinyint(1) - 是否残疾
  • is_orphan tinyint(1) - 是否孤儿
  • is_left_behind_child tinyint(1) - 是否留守儿童
  • is_single_child tinyint(1) - 是否独生子女

4. Mapper映射分析

ResultMap映射配置

文件:backend/ruoyi-modules/ruoyi-xg-xx/src/main/resources/mapper/xg/XgStudentInfoMapper.xml

父母信息映射:

<result property="fatherName" column="father_name"/>
<result property="fatherPhone" column="father_phone"/>
<result property="fatherWorkUnit" column="father_work_unit"/>
<result property="motherName" column="mother_name"/>
<result property="motherPhone" column="mother_phone"/>
<result property="motherWorkUnit" column="mother_work_unit"/>

特殊情况映射:

<result property="isPoorStudent" column="is_poor_student"/>
<result property="isMinority" column="is_minority"/>
<result property="isDisabled" column="is_disabled"/>
<result property="isOrphan" column="is_orphan"/>
<result property="isLeftBehindChild" column="is_left_behind_child"/>
<result property="isSingleChild" column="is_single_child"/>

selectVoPage查询语句

SELECT
    id, student_no, name, gender, birth_date, phone, email,
    id_card, nationality, political_status, major_name, class_name,
    grade, college_name, dormitory_building, dormitory_room, photo_path, guardian_name,
    guardian_phone, guardian_relation, emergency_contact_name,
    emergency_contact_phone, emergency_contact_relation,
    enrollment_date, student_status, remark,
    create_by, create_time, update_by, update_time,
    deleted, tenant_id, counselor_id, class_teacher_id,
    home_address, bank_card_no, bank_name, is_poor_student,
    health_status, specialties, family_income,
    social_activities, awards, violations,
    info_status, data_source, last_batch_id, last_audit_time,
    is_complete, completion_rate, ext_field1, ext_field2, ext_field3, ext_field4, ext_field5
FROM xg_student_info

发现问题:查询字段缺失

  • ✅ 包含 is_poor_student 字段
  • ❌ 缺少其他特殊情况字段:is_minority, is_disabled, is_orphan, is_left_behind_child, is_single_child
  • ❌ 缺少所有父母信息字段:father_name, father_phone, father_work_unit, mother_name, mother_phone, mother_work_unit

5. 详情页面显示分析

详情页面字段绑定

文件:web/src/views/xg-xx/studentInfo/components/StudentDetailDialog.vue

父母信息显示:

<div class="info-item">
  <label>父亲姓名:</label>
  <span>{{ studentInfo.fatherName }}</span>
</div>
<div class="info-item">
  <label>父亲电话:</label>
  <span>{{ studentInfo.fatherPhone }}</span>
</div>
<div class="info-item">
  <label>父亲职业:</label>
  <span>{{ studentInfo.fatherJob }}</span>  <!-- 字段名称错误 -->
</div>
<div class="info-item">
  <label>母亲姓名:</label>
  <span>{{ studentInfo.motherName }}</span>
</div>
<div class="info-item">
  <label>母亲电话:</label>
  <span>{{ studentInfo.motherPhone }}</span>
</div>
<div class="info-item">
  <label>母亲职业:</label>
  <span>{{ studentInfo.motherJob }}</span>  <!-- 字段名称错误 -->
</div>

特殊情况显示:

<div class="info-item">
  <label>贫困生:</label>
  <el-tag :type="studentInfo.isFromPoorFamily ? 'danger' : 'success'">
    {{ studentInfo.isFromPoorFamily ? '是' : '否' }}
  </el-tag>  <!-- 字段名称错误 -->
</div>
<div class="info-item">
  <label>少数民族:</label>
  <el-tag :type="studentInfo.isMinority ? 'warning' : 'info'">
    {{ studentInfo.isMinority ? '是' : '否' }}
  </el-tag>
</div>

发现问题:详情页面字段名称错误

  • ❌ fatherJob 应为 fatherWorkUnit
  • ❌ motherJob 应为 motherWorkUnit
  • ❌ isFromPoorFamily 应为 isPoorStudent

根本原因分析

问题1:Mapper查询字段缺失(主要问题)

  • selectVoPage查询:缺少大部分父母信息和特殊情况字段
  • ResultMap映射:正确映射了所有字段
  • 数据库数据:字段存在且有表结构

问题2:详情页面字段名称错误(次要问题)

  • 父母工作单位:详情页面使用 fatherJob 和 motherJob,实际应为 fatherWorkUnit 和 motherWorkUnit
  • 贫困生标识:详情页面使用 isFromPoorFamily,实际应为 isPoorStudent

问题3:数据传输链路分析

  1. ✅ 前端表单字段:正确绑定了所有字段
  2. ✅ 后端实体类:正确定义了所有字段和@TableField注解
  3. ✅ 数据库表:存在所有必要字段
  4. ✅ 数据写入:INSERT操作正常,数据应该能写入数据库
  5. ❌ 数据查询:SELECT操作缺少关键字段,导致查询结果为空
  6. ❌ 前端显示:部分字段名称错误,无法正确显示

解决方案

方案1:修复Mapper查询语句(核心问题)

在 XgStudentInfoMapper.xml 的 selectVoPage 查询中添加缺失字段:

SELECT
    id, student_no, name, gender, birth_date, phone, email,
    id_card, nationality, political_status, major_name, class_name,
    grade, college_name, dormitory_building, dormitory_room, photo_path, guardian_name,
    guardian_phone, guardian_relation, emergency_contact_name,
    emergency_contact_phone, emergency_contact_relation,
    enrollment_date, student_status, remark,
    create_by, create_time, update_by, update_time,
    deleted, tenant_id, counselor_id, class_teacher_id,
    home_address, bank_card_no, bank_name, is_poor_student,
    health_status, specialties, family_income,
    social_activities, awards, violations,
    info_status, data_source, last_batch_id, last_audit_time,
    is_complete, completion_rate, ext_field1, ext_field2, ext_field3, ext_field4, ext_field5,
    -- 新增父母信息字段
    father_name, father_phone, father_work_unit,
    mother_name, mother_phone, mother_work_unit,
    -- 新增特殊情况字段
    is_minority, is_disabled, is_orphan, is_left_behind_child, is_single_child
FROM xg_student_info

方案2:修复详情页面字段名称

在 StudentDetailDialog.vue 中修正字段名称:

<!-- 父母信息 -->
<span>{{ studentInfo.fatherWorkUnit }}</span>  <!-- 修正 fatherJob -->
<span>{{ studentInfo.motherWorkUnit }}</span>  <!-- 修正 motherJob -->

<!-- 特殊情况 -->
<el-tag :type="studentInfo.isPoorStudent ? 'danger' : 'success'">
  {{ studentInfo.isPoorStudent ? '是' : '否' }}
</el-tag>  <!-- 修正 isFromPoorFamily -->

结论

主要问题:XgStudentInfoMapper.xml 的 selectVoPage 查询语句中缺少父母信息和大部分特殊情况字段。

次要问题:前端详情页面部分字段名称与后端不一致。

数据状态:数据实际上可以正确写入数据库,但查询时没有获取到相关字段,导致详情页面显示为空。

修复优先级:

  1. 🔴 高优先级:修复Mapper查询语句,添加缺失的父母信息和特殊情况字段
  2. 🟡 中优先级:修复前端详情页面字段名称不一致问题

修复完成后,家庭信息中的父母信息和特殊情况将正常录入数据库并在详情页面显示。