修改了employee相关

This commit is contained in:
lik
2026-10-06 21:44:42 +08:00
parent 0e81341bff
commit 7fc91b75f7
7 changed files with 309 additions and 9 deletions
+36 -2
View File
@@ -3,6 +3,21 @@
import mongoose from "mongoose";
import { pinyin } from "pinyin-pro";
/**
* 培训记录子文档
*
* 国标 GB/T 47801—2026 4.2.1.5 把「培训记录」列为陪同人员信息公示项,
* 故按一条一次培训存成数组,便于逐条核对;不用 _id,这些条目只跟着员工走
*/
const TrainingSchema = mongoose.Schema(
{
title: { type: String, default: "", comment: "培训名称/课程" },
org: { type: String, default: "", comment: "培训机构" },
date: { type: Date, comment: "结业日期" },
},
{ _id: false }
);
/**
* Employee Schema
* 员工/人员信息,支持陪诊员、护士、医生、管理员等角色
@@ -56,6 +71,19 @@ const EmployeeSchema = mongoose.Schema(
entryDate: { type: Date, comment: "入职日期" },
workYears: { type: Number, default: 0, comment: "工作年限" },
qualification: { type: String, default: "", comment: "资质证书编号" },
// 健康证明:国标 4.2.1.5 公示的是「健康证明有效期」。
// 公示接口只输出"是否在有效期内"+ 到期日;number 属资质原文,
// 与 qualification 一样只作内部留存,绝不随公示接口下发
healthCertificate: {
number: { type: String, default: "", comment: "健康证明编号(不对外公示)" },
org: { type: String, default: "", comment: "发证机构" },
issueDate: { type: Date, comment: "签发日期" },
expireDate: { type: Date, comment: "有效期至" },
},
// 培训记录:同为 4.2.1.5 公示项
trainings: { type: [TrainingSchema], default: [], comment: "培训记录列表" },
},
// 陪诊员特有信息
@@ -63,7 +91,10 @@ const EmployeeSchema = mongoose.Schema(
serviceAreas: { type: [String], default: [], comment: "服务区域/城市列表" },
specialties: { type: [String], default: [], comment: "擅长科室/领域" },
languages: { type: [String], default: ["普通话"], comment: "掌握语言" },
rating: { type: Number, default: 5.0, min: 1, max: 5, comment: "评分(1-5)" },
// 注意:本字段全项目没有任何写入点(恒为默认 5.0),不可作为评级来源。
// 对外评级一律由 employee_review 真实评价聚合得出(employee_review.js),
// 达阈值才展示,详见 .trae/documents/陪诊师公示与指定陪诊师.md
rating: { type: Number, default: 5.0, min: 1, max: 5, comment: "评分(无写入点,勿用于公示)" },
orderCount: { type: Number, default: 0, comment: "接单数量" },
isOnline: { type: Boolean, default: false, comment: "是否在线" },
},
@@ -197,6 +228,9 @@ EmployeeSchema.statics.updateEmployee = async function (id, update) {
/**
* 查询在线陪诊员列表
*
* 排序口径与 handler/employee.js 的公示列表保持一致:服务年限优先、累计服务次数次之。
* 曾按 attendantInfo.rating 排,但该字段没有任何写入点(恒为 5.0),等于没排序
*/
EmployeeSchema.statics.findOnlineAttendants = async function (options = {}) {
const { page = 1, pageSize = 20 } = options;
@@ -206,7 +240,7 @@ EmployeeSchema.statics.findOnlineAttendants = async function (options = {}) {
status: "active",
"attendantInfo.isOnline": true,
})
.sort({ "attendantInfo.rating": -1 })
.sort({ "work.workYears": -1, "attendantInfo.orderCount": -1 })
.skip(skip)
.limit(pageSize)
.exec();