九维能力打分

parent 5d2323dc
...@@ -66,6 +66,7 @@ async function getAuthToken(): Promise<string> { ...@@ -66,6 +66,7 @@ async function getAuthToken(): Promise<string> {
* @param classRole 班级职务(可选) * @param classRole 班级职务(可选)
* @param growthPoints 成长亮点数组 * @param growthPoints 成长亮点数组
* @param writingStyle 评语文风(可选) * @param writingStyle 评语文风(可选)
* @param nineDimensionalScore 九维评分(可选)
* @param copilotId 智能体ID(可选) * @param copilotId 智能体ID(可选)
* @param promptTemplateName 提示词模板名称(可选) * @param promptTemplateName 提示词模板名称(可选)
* @returns 生成的评语文本 * @returns 生成的评语文本
...@@ -78,6 +79,7 @@ export async function generateGrowthMessagePreview( ...@@ -78,6 +79,7 @@ export async function generateGrowthMessagePreview(
classRole?: string, classRole?: string,
growthPoints?: string[], growthPoints?: string[],
writingStyle?: string, writingStyle?: string,
nineDimensionalScore?: Map<String, Number>,
copilotId: string = DEFAULT_COPILOT_ID, copilotId: string = DEFAULT_COPILOT_ID,
promptTemplateName: string = DEFAULT_PROMPT_NAME promptTemplateName: string = DEFAULT_PROMPT_NAME
): Promise<string> { ): Promise<string> {
...@@ -96,7 +98,8 @@ export async function generateGrowthMessagePreview( ...@@ -96,7 +98,8 @@ export async function generateGrowthMessagePreview(
rank_change: rankChange || '上升10名', rank_change: rankChange || '上升10名',
class_role: classRole || '无职务', class_role: classRole || '无职务',
growth_points: growthPoints || [], growth_points: growthPoints || [],
writing_style: writingStyle || '温暖鼓励型' writing_style: writingStyle || '温暖鼓励型',
nine_dimensional_score: nineDimensionalScore || {}
}; };
// 3. 构造 GraphQL 请求(以下代码不变) // 3. 构造 GraphQL 请求(以下代码不变)
......
...@@ -8,6 +8,7 @@ import { TABLENAME, TABLEID } from "../../config/dbEnum"; ...@@ -8,6 +8,7 @@ import { TABLENAME, TABLEID } from "../../config/dbEnum";
import { getCurrentSemester } from "../common/semesterService"; import { getCurrentSemester } from "../common/semesterService";
import { BizError } from "../../util/bizError"; import { BizError } from "../../util/bizError";
import { ERRORENUM } from "../../config/errorEnum"; import { ERRORENUM } from "../../config/errorEnum";
import { ABILITYDIMENSION } from "../../config/enum";
import { randomId } from "../../tools/systemTools"; import { randomId } from "../../tools/systemTools";
import { getMySqlMs } from "../../tools/systemTools"; import { getMySqlMs } from "../../tools/systemTools";
import * as notificationBiz from "../headteacher/notification"; import * as notificationBiz from "../headteacher/notification";
...@@ -63,6 +64,8 @@ export async function addGrowthMessage(data: any) { ...@@ -63,6 +64,8 @@ export async function addGrowthMessage(data: any) {
if (!match.data) { if (!match.data) {
throw new BizError(ERRORENUM.权限不足, '您与该学生在所选学期无师生关系'); throw new BizError(ERRORENUM.权限不足, '您与该学生在所选学期无师生关系');
} }
let nineDimensionalScore:any = data.nineDimensionalScore || {};
/**创建成长寄语 */ /**创建成长寄语 */
await addData(TABLENAME.成长寄语表, { await addData(TABLENAME.成长寄语表, {
...@@ -73,6 +76,9 @@ export async function addGrowthMessage(data: any) { ...@@ -73,6 +76,9 @@ export async function addGrowthMessage(data: any) {
content: data.content, content: data.content,
created_at: getMySqlMs() created_at: getMySqlMs()
}); });
/**保存九维能力评分 */
await saveAbilityAssessment(data.teacher_id, data.student_id, nineDimensionalScore);
/**生成消息通知 */ /**生成消息通知 */
try { try {
...@@ -353,10 +359,10 @@ export async function getGrowthStudent( ...@@ -353,10 +359,10 @@ export async function getGrowthStudent(
// 5. 获取最近成绩(语数英物化生...)、总分、班级排名 // 5. 获取最近成绩(语数英物化生...)、总分、班级排名
let xuenian = semesterNameToXuenian(semester ? semester.name : ''); let xuenian = semesterNameToXuenian(semester ? semester.name : '');
let latestScore = await getStudentLatestScore(studentNo, xuenian); let latestScore = await getStudentLatestScore(studentId, xuenian);
// 6. 获取获奖情况列表(获奖内容、获奖时间) // 6. 获取获奖情况列表(获奖内容、获奖时间)
let awards = await getStudentAwards(studentNo); let awards = await getStudentAwards(studentId);
return { return {
student_info: { student_info: {
...@@ -375,6 +381,45 @@ export async function getGrowthStudent( ...@@ -375,6 +381,45 @@ export async function getGrowthStudent(
}; };
} }
/**
* 保存九维能力评分到 ability_assessment 表
* 固定插入9条记录,缺失的维度分值默认置0
* @param teacherId 导师ID
* @param studentId 学生ID
* @param nineDimensionalScore 前端传入的九维打分数据,key=维度编码,value=分值
*/
async function saveAbilityAssessment(
teacherId: string,
studentId: string,
nineDimensionalScore: any
) {
const now = getMySqlMs();
// 批次号: YYYYMMDDHHmmssT导师IDS学生ID
const timeStr = now.replace(/-/g, '').replace(/:/g, '').replace(/\s/g, '');
const assessmentId = `${timeStr}T${teacherId}S${studentId}`;
// 固定9个维度,缺失或非法则默认0
const dimensionCodes = Object.values(ABILITYDIMENSION);
const records = dimensionCodes.map(dimensionCode => ({
assessment_id: assessmentId,
teacher_id: teacherId,
student_id: studentId,
dimension_code: dimensionCode,
score: toValidScore(nineDimensionalScore && nineDimensionalScore[dimensionCode]),
assess_time: now,
created_at: now,
updated_at: now
}));
await addData(TABLENAME.九维能力打分表, records);
}
/** 将任意值转成合法的 DECIMAL(4,1) 分值,非法值返回 0 */
function toValidScore(value: any): number {
const num = Number(value);
return (isNaN(num) || num < 0) ? 0 : Number(num.toFixed(1));
}
......
...@@ -25,6 +25,7 @@ export enum TABLENAME { ...@@ -25,6 +25,7 @@ export enum TABLENAME {
交流记录子类型表 = 'communication_subtype', 交流记录子类型表 = 'communication_subtype',
交流提醒记录表 = 'communication_reminder', 交流提醒记录表 = 'communication_reminder',
成长寄语表 = 'growth_message', 成长寄语表 = 'growth_message',
九维能力打分表 = 'ability_assessment',
导师见面会表 = 'meeting', 导师见面会表 = 'meeting',
见面会学生表 = 'meeting_students', 见面会学生表 = 'meeting_students',
导师案例表 = 'teacher_case', 导师案例表 = 'teacher_case',
...@@ -55,6 +56,7 @@ export enum TABLEID { ...@@ -55,6 +56,7 @@ export enum TABLEID {
交流记录子类型表 = 'CMS', 交流记录子类型表 = 'CMS',
交流提醒记录表 = 'CR', 交流提醒记录表 = 'CR',
成长寄语表 = 'GM', 成长寄语表 = 'GM',
九维能力打分表 = 'AA',
导师见面会表 = 'MT', 导师见面会表 = 'MT',
导师案例表 = 'CS', 导师案例表 = 'CS',
预约表 = 'AP', 预约表 = 'AP',
......
...@@ -162,4 +162,19 @@ export enum POLITICALSTATUS { ...@@ -162,4 +162,19 @@ export enum POLITICALSTATUS {
无党派人士 = '无党派人士', 无党派人士 = '无党派人士',
}; };
/**
* 九大能力维度编码(固定9项)
*/
export enum ABILITYDIMENSION {
家国情怀 = 'jgqh',
国际视野 = 'gjsy',
劳动意识 = 'ldys',
审美健康 = 'smjk',
健康生活 = 'jksh',
善于学习 = 'syxx',
勇于创新 = 'yycx',
学业扎实 = 'xysz',
责任担当 = 'zrdd',
};
...@@ -243,6 +243,23 @@ export const TablesConfig = [ ...@@ -243,6 +243,23 @@ export const TablesConfig = [
}, },
association: [] association: []
}, },
// 九维能力打分表
{
tableNameCn: '九维能力打分表',
tableName: 'ability_assessment',
schema: {
id: { type: DataTypes.INTEGER, allowNull: false, primaryKey: true, autoIncrement: true, comment: '自增主键' },
assessment_id: { type: DataTypes.STRING(50), allowNull: false, comment: '批次号: 年月日时分秒导师ID学生ID,例如20221201103000T001S001' },
teacher_id: { type: DataTypes.STRING(20), allowNull: false, comment: '评分导师user_id,关联uac_user.user_id' },
student_id: { type: DataTypes.STRING(20), allowNull: false, comment: '学生user_id,关联uac_user.user_id' },
dimension_code: { type: DataTypes.STRING(32), allowNull: false, comment: '能力维度编码: jgqh-家国情怀,gjsy-国际视野,ldys-劳动意识' },
score: { type: DataTypes.DECIMAL(4, 1), allowNull: false, comment: '分值' },
assess_time: { type: DataTypes.DATE, allowNull: false, comment: '评分时间' },
created_at: { type: DataTypes.DATE, allowNull: false, defaultValue: DataTypes.NOW },
updated_at: { type: DataTypes.DATE, allowNull: false, defaultValue: DataTypes.NOW }
},
association: []
},
// 成长寄语表 // 成长寄语表
{ {
tableNameCn: '成长寄语表', tableNameCn: '成长寄语表',
......
...@@ -450,16 +450,17 @@ async function getStudentOptions(req, res) { ...@@ -450,16 +450,17 @@ async function getStudentOptions(req, res) {
async function addGrowthMessage(req, res) { async function addGrowthMessage(req, res) {
const userInfo = req.userInfo; const userInfo = req.userInfo;
let reqConf = {student_id:'String', date:'String', content:'String', semester_id:'Number'}; let reqConf = {student_id:'String', date:'String', content:'String', semester_id:'Number', nineDimensionalScore:'Map<String, Number>'};
const NotMustHaveKeys = ['semester_id']; const NotMustHaveKeys = ['semester_id', 'nineDimensionalScore'];
let { student_id, date, content, semester_id } = eccReqParamater(reqConf, req.body, NotMustHaveKeys); let { student_id, date, content, semester_id, nineDimensionalScore } = eccReqParamater(reqConf, req.body, NotMustHaveKeys);
let msgData = { let msgData = {
student_id, student_id,
date, date,
content, content,
teacher_id: userInfo.userId, teacher_id: userInfo.userId,
semester_id: semester_id || null // 可选参数,不传则为null semester_id: semester_id || null, // 可选参数,不传则为null
nine_dimensional_score: nineDimensionalScore || {} // 可选参数,不传则为{}
}; };
let result = await growthMessageBiz.addGrowthMessage(msgData); let result = await growthMessageBiz.addGrowthMessage(msgData);
...@@ -545,11 +546,11 @@ async function aiPreviewGrowthMessage(req, res) { ...@@ -545,11 +546,11 @@ async function aiPreviewGrowthMessage(req, res) {
let reqConf = { let reqConf = {
student_id:'String', personalityTags:'[String]', academicLevel:'String', rankChange:'String', classRole:'String', student_id:'String', personalityTags:'[String]', academicLevel:'String', rankChange:'String', classRole:'String',
growthPoints:'[String]', writingStyle:'String', copilotId:'String', promptTemplateName:'String' }; growthPoints:'[String]', writingStyle:'String', copilotId:'String', promptTemplateName:'String', nineDimensionalScore:'Map<String, Number>' };
const NotMustHaveKeys = [ 'personalityTags', 'academicLevel', 'rankChange', 'classRole', 'growthPoints', 'writingStyle', 'copilotId', 'promptTemplateName' ]; const NotMustHaveKeys = [ 'personalityTags', 'academicLevel', 'rankChange', 'classRole', 'growthPoints', 'writingStyle', 'copilotId', 'promptTemplateName', 'nineDimensionalScore' ];
let { student_id, personalityTags, academicLevel, rankChange, classRole, growthPoints, writingStyle } = eccReqParamater(reqConf, req.body, NotMustHaveKeys); let { student_id, personalityTags, academicLevel, rankChange, classRole, growthPoints, writingStyle, nineDimensionalScore } = eccReqParamater(reqConf, req.body, NotMustHaveKeys);
const content = await AIGrowthMessageBiz.generateGrowthMessagePreview( const content = await AIGrowthMessageBiz.generateGrowthMessagePreview(
student_id, student_id,
...@@ -558,7 +559,8 @@ async function aiPreviewGrowthMessage(req, res) { ...@@ -558,7 +559,8 @@ async function aiPreviewGrowthMessage(req, res) {
rankChange, rankChange,
classRole, classRole,
growthPoints, growthPoints,
writingStyle writingStyle,
nineDimensionalScore
); );
res.success({ content }); res.success({ content });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment