Explorar el Código

feat: 配置 TypeORM 迁移功能并清理 not_working 数据

- 实现 TypeORM 迁移 CLI 配置(使用 typeorm-ts-node-esm)
- 创建数据迁移脚本,将 65 条 not_working 记录迁移到 pre_working
- 更新数据库枚举,移除 not_working 值
- 修复 DisabledPerson 和 OrderPerson 之间的循环依赖(使用字符串语法)
- 使用 glob 模式加载实体和迁移,避免 ESM 循环依赖问题
- 添加生产环境自动运行迁移逻辑
- 清理 Schema 和 E2E 测试中的 not_working 引用

Co-Authored-By: Claude <noreply@anthropic.com>
yourname hace 6 días
padre
commit
1aa2ad6a49

+ 439 - 0
_bmad-output/implementation-artifacts/14-1-typeorm-migration-not-working-cleanup.md

@@ -0,0 +1,439 @@
+# Story 14.1: TypeORM 迁移配置与 not_working 数据清理
+
+Status: completed
+
+## 元数据
+- Epic: Epic 14 - 数据层改进
+- 状态: completed
+- 优先级: P1 (高 - 阻塞应用启动)
+- 故事点: 5
+- 依赖: Story 13.29 完成
+
+## 用户故事
+
+作为系统开发者,
+我需要配置 TypeORM 迁移功能并清理数据库中的 `not_working` 状态数据,
+以确保数据库状态与代码保持一致,并建立可靠的数据版本控制机制。
+
+## 背景
+
+### 问题发现
+
+Story 13.29 从代码中移除了 `not_working` 状态,但存在以下遗留问题:
+
+1. **数据库数据不一致**:65 条记录的 `work_status` 仍为 `not_working`
+2. **数据库枚举未更新**:`order_person_work_status_enum` 仍包含 `not_working` 值
+3. **Schema 文件遗留引用**:
+   - `talent-employment.schema.ts` 中的 enum 定义
+   - `order.schema.ts` 中的 description 文本
+   - `person-extension.schema.ts` 中的 description 文本
+4. **E2E 测试遗留引用**:
+   - `order-management.page.ts` 中的 `NOT_WORKING` 常量和标签映射
+5. **缺少迁移机制**:项目未配置 TypeORM 迁移功能,依赖 synchronize
+
+### 影响范围
+
+| 问题 | 影响 | 严重性 |
+|------|------|--------|
+| 数据库数据不一致 | 查询、统计可能返回错误结果 | HIGH |
+| 数据库枚举未更新 | 新代码可能因枚举值不匹配而失败 | HIGH |
+| Schema 遗留引用 | API 文档不准确,误导开发者 | MEDIUM |
+| E2E 测试遗留引用 | 测试代码与实际业务状态不一致 | MEDIUM |
+| 缺少迁移机制 | 无法安全地演进数据库结构 | HIGH |
+
+## 验收标准
+
+### AC 1: TypeORM 迁移功能已配置
+**Given** 项目使用 TypeORM 0.3.25
+**When** 配置迁移功能
+**Then** 可以运行 `migration:show`、`migration:generate`、`migration:run`、`migration:revert` 命令
+**And** 迁移文件存储在 `packages/server/migrations/` 目录
+**And** 使用 glob 模式加载实体和迁移文件,避免循环依赖
+**And** `synchronize` 设置为 `false`(项目已有历史数据)
+**And** 生产环境启动时自动运行迁移,开发环境手动运行迁移命令
+**And** ESM 项目使用 `typeorm-ts-node-esm` CLI 工具
+
+### AC 2: 数据迁移脚本已创建
+**Given** 数据库中有 `work_status = 'not_working'` 的记录
+**When** 运行迁移脚本
+**Then** 所有 `not_working` 记录迁移为 `pre_working`
+**And** 数据库枚举 `order_person_work_status_enum` 移除 `not_working` 值
+**And** 迁移脚本支持回滚
+
+### AC 3: Schema 文件已清理
+**Given** Schema 文件包含 `not_working` 引用
+**When** 清理 Schema 文件
+**Then** `talent-employment.schema.ts` 的 enum 移除 `not_working`
+**And** `order.schema.ts` 的 description 移除 `not_working` 相关描述
+**And** `person-extension.schema.ts` 的 description 移除 `not_working` 相关描述
+
+### AC 4: E2E 测试已清理
+**Given** E2E 测试文件包含 `not_working` 引用
+**When** 清理 E2E 测试文件
+**Then** `order-management.page.ts` 移除 `NOT_WORKING` 常量
+**And** `order-management.page.ts` 移除 `WORK_STATUS_LABELS` 中的 `not_working` 条目
+
+### AC 5: 迁移创建自动化脚本已配置
+**Given** 开发者需要创建新迁移
+**When** 运行 `pnpm run migration:create -- -n MigrationName`
+**Then** 自动调用 TypeORM CLI 生成迁移文件
+**And** 自动更新 Barrel 文件 (`migrations/index.ts`)
+**And** 迁移文件保存在 `packages/server/migrations/` 目录
+
+### AC 6: 验证通过
+**Given** 所有迁移和清理完成
+**When** 验证数据库状态
+**Then** `order_person.work_status = 'not_working'` 的记录数为 0
+**And** 数据库枚举只包含 3 个值:`pre_working`, `working`, `resigned`
+**And** 相关测试通过
+
+## Tasks / Subtasks
+
+### 1. 配置 TypeORM 迁移功能 (AC: #1)
+- [x] 1.1 在 `packages/server` 创建 `migrations/` 目录
+- [x] 1.2 修改 `packages/server/src/data-source.ts`,使用 glob 模式配置实体和迁移加载
+- [x] 1.3 创建 `packages/server/migrations/index.ts` Barrel 文件,集中导出所有迁移
+- [x] 1.4 关闭自动同步:设置 `synchronize: false`(项目已有历史数据)
+- [x] 1.5 在 `packages/server/src/index.ts` 添加生产环境自动运行迁移逻辑
+- [x] 1.6 在 `packages/server/package.json` 添加迁移脚本(使用 `typeorm-ts-node-esm`):
+  ```json
+  "migration:show": "npx typeorm-ts-node-esm migration:show -d src/data-source.ts",
+  "migration:run": "npx typeorm-ts-node-esm migration:run -d src/data-source.ts",
+  "migration:generate": "npx typeorm-ts-node-esm migration:generate -d src/data-source.ts",
+  "migration:revert": "npx typeorm-ts-node-esm migration:revert -d src/data-source.ts"
+  ```
+- [x] 1.7 修复 `DisabledPerson` 和 `OrderPerson` 实体之间的循环依赖(使用字符串语法)
+- [x] 1.8 验证 CLI 命令正常运行
+
+### 1.8. 配置迁移创建自动化脚本 (AC: #5)
+- [x] 1.8.1 创建 `packages/server/scripts/create-migration.sh`
+- [x] 1.8.2 脚本功能:调用 TypeORM CLI 生成迁移文件
+- [x] 1.8.3 脚本功能:自动更新 `migrations/index.ts` Barrel 文件
+- [x] 1.8.4 在 `packages/server/package.json` 添加 `migration:create` 脚本
+
+### 2. 创建数据迁移脚本 (AC: #2)
+- [x] 2.1 生成迁移文件模板
+- [x] 2.2 编写 `up` 方法:更新 `order_person.work_status` 从 `not_working` 到 `pre_working`
+- [x] 2.3 编写 `up` 方法:修改数据库枚举,移除 `not_working` 值
+- [x] 2.4 编写 `down` 方法:支持回滚(添加 `not_working` 回到枚举)
+- [x] 2.5 验证迁移脚本语法正确
+
+### 3. 清理 Schema 文件 (AC: #3)
+- [x] 3.1 修改 `allin-packages/order-module/src/schemas/talent-employment.schema.ts`
+  - `EmploymentStatusResponseSchema.workStatus` enum 移除 `not_working`
+  - `EmploymentHistoryItemSchema.workStatus` enum 移除 `not_working`
+- [x] 3.2 修改 `allin-packages/order-module/src/schemas/order.schema.ts`
+  - `UpdatePersonWorkStatusSchema.workStatus` description 移除 `not_working` 相关描述
+- [x] 3.3 修改 `allin-packages/disability-module/src/schemas/person-extension.schema.ts`
+  - `CompanyPersonListQuerySchema.jobStatus` description 移除 `not_working` 相关描述
+
+### 4. 清理 E2E 测试文件 (AC: #4)
+- [x] 4.1 修改 `web/tests/e2e/pages/admin/order-management.page.ts`
+  - 移除 `WORK_STATUS.NOT_WORKING` 常量
+  - 移除 `WORK_STATUS_LABELS.not_working` 条目
+  - 移除 `WorkStatus` 类型中的 `not_working`
+
+### 5. 执行迁移并验证 (AC: #6)
+- [x] 5.1 备份数据库(可选,开发环境)
+- [x] 5.2 运行 `migration:run` 执行迁移
+- [x] 5.3 验证数据库数据:确认 `not_working` 记录数为 0
+- [x] 5.4 验证数据库枚举:确认只包含 3 个值
+- [x] 5.5 运行相关测试(单元测试、集成测试)
+- [x] 5.6 验证回滚功能:运行 `migration:revert` 后再 `migration:run`
+
+## Dev Notes
+
+### 相关文件
+
+**TypeORM 配置:**
+- `packages/server/src/data-source.ts` - 数据源配置(使用类数组/Barrel模式加载迁移)
+- `packages/server/src/index.ts` - 应用启动时在生产环境自动运行迁移
+- `packages/server/migrations/index.ts` - Barrel 文件,集中导出所有迁移
+- `packages/server/package.json` - 迁移脚本
+- `packages/server/scripts/create-migration.sh` - 迁移创建自动化脚本
+
+**Schema 文件需清理:**
+- `allin-packages/order-module/src/schemas/talent-employment.schema.ts` (Lines 32, 118)
+- `allin-packages/order-module/src/schemas/order.schema.ts` (Line 486)
+- `allin-packages/disability-module/src/schemas/person-extension.schema.ts` (Line 274)
+
+**E2E 测试文件需清理:**
+- `web/tests/e2e/pages/admin/order-management.page.ts` (Lines 33-38, 48-52)
+
+### 技术要点
+
+**TypeORM 迁移配置 (最终方案 - glob 模式):**
+```typescript
+// packages/server/src/data-source.ts - 使用 glob 模式避免循环依赖
+import "reflect-metadata"
+import { DataSource } from "typeorm"
+import process from 'node:process'
+
+export const AppDataSource = new DataSource({
+  type: "postgres",
+  host: process.env.DB_HOST || "localhost",
+  port: parseInt(process.env.DB_PORT || "5432"),
+  username: process.env.DB_USERNAME || "postgres",
+  password: process.env.DB_PASSWORD || "",
+  database: process.env.DB_DATABASE || "postgres",
+  // 使用 glob 模式加载实体,避免循环依赖
+  entities: [
+    "../allin-packages/*/src/entities/*.ts",
+    "../packages/*/src/entities/*.ts",
+  ],
+  migrations: [
+    "./migrations/*[0-9].ts",  // 只匹配数字时间戳开头的迁移文件,排除 index.ts
+  ],
+  synchronize: false,  // 迁移时必须关闭自动同步
+  logging: process.env.DB_LOGGING === "true",
+})
+
+// packages/server/src/index.ts - 生产环境自动运行迁移
+const isProduction = process.env.NODE_ENV === 'production';
+if (isProduction) {
+  await AppDataSource.runMigrations();
+  console.log('数据库迁移已完成');
+}
+```
+
+**循环依赖修复 (字符串语法):**
+```typescript
+// allin-packages/disability-module/src/entities/disabled-person.entity.ts
+// 移除 OrderPerson 导入,使用字符串语法
+@OneToMany('OrderPerson', (orderPerson: any) => orderPerson.person)
+orderPersons!: any[];
+
+// allin-packages/order-module/src/entities/order-person.entity.ts
+// 移除 DisabledPerson 导入,使用字符串语法
+@ManyToOne('DisabledPerson', { onDelete: 'CASCADE' })
+JoinColumn({ name: 'person_id' })
+person!: any;
+```
+
+**Barrel 文件模式 (migrations/index.ts):**
+```typescript
+// packages/server/migrations/index.ts
+export { MigrateNotWorkingToPreWorking1737260000000 } from './MigrateNotWorkingToPreWorking1737260000000';
+// 添加新迁移时,在此处导出
+```
+
+**迁移创建自动化脚本:**
+```bash
+#!/bin/bash
+# packages/server/scripts/create-migration.sh
+MIGRATION_NAME=$1
+pnpm exec typeorm-ts-node-commonjs migration:generate -d src/data-source.ts -n "$MIGRATION_NAME"
+# 自动更新 migrations/index.ts Barrel 文件
+```
+
+**迁移脚本模板:**
+```typescript
+import { MigrationInterface, QueryRunner } from 'typeorm';
+
+export class MigrateNotWorkingToPreWorking1234567890 implements MigrationInterface {
+  public async up(queryRunner: QueryRunner): Promise<void> {
+    // 1. 更新数据
+    await queryRunner.query(`
+      UPDATE order_person
+      SET work_status = 'pre_working'
+      WHERE work_status = 'not_working'
+    `);
+
+    // 2. 修改枚举(PostgreSQL)
+    await queryRunner.query(`
+      ALTER TYPE order_person_work_status_enum
+      RENAME TO order_person_work_status_enum_old;
+    `);
+
+    await queryRunner.query(`
+      CREATE TYPE order_person_work_status_enum AS ENUM
+      ('pre_working', 'working', 'resigned');
+    `);
+
+    await queryRunner.query(`
+      ALTER TABLE order_person
+      ALTER COLUMN work_status
+      TYPE order_person_work_status_enum
+      USING work_status::text::order_person_work_status_enum;
+    `);
+
+    await queryRunner.query(`
+      DROP TYPE order_person_work_status_enum_old;
+    `);
+  }
+
+  public async down(queryRunner: QueryRunner): Promise<void> {
+    // 回滚逻辑
+    await queryRunner.query(`
+      ALTER TYPE order_person_work_status_enum
+      RENAME TO order_person_work_status_enum_old;
+    `);
+
+    await queryRunner.query(`
+      CREATE TYPE order_person_work_status_enum AS ENUM
+      ('not_working', 'pre_working', 'working', 'resigned');
+    `);
+
+    await queryRunner.query(`
+      ALTER TABLE order_person
+      ALTER COLUMN work_status
+      TYPE order_person_work_status_enum
+      USING work_status::text::order_person_work_status_enum;
+    `);
+
+    await queryRunner.query(`
+      DROP TYPE order_person_work_status_enum_old;
+    `);
+  }
+}
+```
+
+### PostgreSQL 枚举修改注意事项
+
+1. **PostgreSQL 不支持直接删除枚举值**,需要:
+   - 创建新枚举类型(不包含要删除的值)
+   - 修改列类型到新枚举
+   - 删除旧枚举类型
+
+2. **数据迁移必须先于枚举修改**:
+   - 先将 `not_working` 数据改为 `pre_working`
+   - 再修改枚举定义
+
+3. **外键约束处理**:
+   - 检查是否有其他表引用 `order_person.work_status`
+   - 如有,需先删除约束,迁移后再重建
+
+### 测试验证
+
+**验证数据库数据:**
+```sql
+-- 检查 not_working 记录数
+SELECT COUNT(*) FROM order_person WHERE work_status = 'not_working';
+-- 预期结果: 0
+
+-- 检查枚举值
+SELECT enumlabel FROM pg_enum
+WHERE enumtypid = 'order_person_work_status_enum'::regtype::oid;
+-- 预期结果: pre_working, working, resigned(只有 3 个)
+```
+
+**类型检查:**
+```bash
+# 检查是否有遗留的 not_working 引用
+pnpm typecheck 2>&1 | grep -i "not_working"
+```
+
+### 依赖关系
+
+- **前置依赖**: Story 13.29(已从代码移除 not_working)
+- **后续影响**: 无(这是数据层的清理工作)
+
+### CLI 调试说明
+
+**问题**: TypeORM CLI 在 ESM 项目中遇到 "Cannot access 'DisabledPerson' before initialization" 错误
+
+**根本原因**:
+1. **循环依赖**: `DisabledPerson` 和 `OrderPerson` 实体之间的相互引用
+2. **ESM 模块加载**: 使用类数组导入时,ESM 模块加载器无法正确处理循环依赖
+3. **装饰器执行顺序**: TypeScript 装饰器在模块加载时执行,早于运行时依赖解析
+
+**解决方案**:
+1. **使用 glob 模式**: 改用 glob 模式加载实体和迁移,避免显式导入类
+2. **字符串语法**: 在关系装饰器中使用字符串语法引用其他实体
+3. **ESM 专用 CLI**: 使用 `typeorm-ts-node-esm` 而非 `typeorm` 或 `tsx`
+
+**参考文档**: https://typeorm.io/docs/migrations/executing
+> ESM projects should use: `npx typeorm-ts-node-esm migration:run -- -d path-to-datasource`
+
+**验证命令**:
+```bash
+cd /mnt/code/188-179-template-6/packages/server
+
+# 查看迁移状态
+pnpm migration:show
+# 输出: [X] 1 MigrateNotWorkingToPreWorking1737260000000
+
+# 运行迁移
+pnpm migration:run
+# 输出: No migrations are pending
+```
+
+### 风险评估
+
+| 风险 | 可能性 | 影响 | 缓解措施 |
+|------|--------|------|----------|
+| 迁移脚本执行失败 | 中 | 高 | 在开发环境先验证,准备回滚脚本 |
+| 数据库迁移锁表 | 低 | 中 | 选择低峰时段执行,监控执行时间 |
+| 外键约束冲突 | 低 | 中 | 检查并处理外键约束 |
+| 遗漏代码引用 | 中 | 低 | 使用 grep 全面搜索 |
+
+## References
+
+- **Story 13.29**: `_bmad-output/implementation-artifacts/13-29-remove-not-working-status.md` - 前置 Story,从代码移除 not_working
+- **TypeORM 迁移文档**: https://typeorm.io/#/migrations
+- **PostgreSQL 枚举类型**: https://www.postgresql.org/docs/current/datatype-enum.html
+
+## Dev Agent Record
+
+### Agent Model Used
+Claude (d8d-model)
+
+### Debug Log References
+N/A
+
+### Completion Notes List
+- Story 创建于 2026-01-19
+- 基于 Story 13.29 的遗留问题
+- 配置 TypeORM 迁移功能
+- 清理数据库和代码中的 not_working 引用
+
+**实现总结:**
+1. ✅ 配置 TypeORM 迁移功能:在 `packages/server` 创建 migrations 目录,添加迁移脚本到 package.json
+2. ✅ 创建 Barrel 文件模式:`packages/server/migrations/index.ts` 集中导出所有迁移
+3. ✅ 更新 data-source.ts:使用类数组(Barrel模式)加载迁移,设置 synchronize: false
+4. ✅ 更新 index.ts:添加生产环境自动运行迁移逻辑
+5. ✅ 更新 shared-utils:支持 migrations 参数(类数组或文件路径数组)
+6. ✅ 创建数据迁移脚本:`MigrateNotWorkingToPreWorking1737260000000.ts` 迁移 65 条记录
+7. ✅ 清理 Schema 文件:移除了所有 not_working 引用
+8. ✅ 清理 E2E 测试文件:移除了 NOT_WORKING 常量和相关映射
+9. ✅ 创建迁移创建自动化脚本:`scripts/create-migration.sh` 自动调用 TypeORM CLI 并更新相关文件
+10. ✅ 验证通过:数据库枚举只包含 3 个值(pre_working, working, resigned),无 not_working 记录
+
+**迁移执行结果:**
+- 数据更新:65 条记录从 not_working 迁移到 pre_working
+- 枚举重建:成功移除 not_working 值
+- 最终状态:pre_working (66), working (11), resigned (1)
+
+### File List
+已创建:
+- `packages/server/migrations/MigrateNotWorkingToPreWorking1737260000000.ts` - 迁移文件
+- `packages/server/migrations/index.ts` - Barrel 文件,集中导出所有迁移
+- `packages/server/scripts/create-migration.sh` - 迁移创建自动化脚本
+- `packages/server/dist/migrations/MigrateNotWorkingToPreWorking1737260000000.js` - 编译后的迁移文件
+
+已修改:
+- `packages/server/src/data-source.ts` - 使用 glob 模式加载实体和迁移
+- `packages/server/src/index.ts` - 添加生产环境自动运行迁移逻辑
+- `packages/server/package.json` - 添加 migration:show, migration:run 等脚本(使用 typeorm-ts-node-esm)
+- `allin-packages/disability-module/src/entities/disabled-person.entity.ts` - 移除 OrderPerson 导入,改用字符串语法
+- `allin-packages/order-module/src/entities/order-person.entity.ts` - 移除 DisabledPerson 导入,改用字符串语法
+- `allin-packages/order-module/src/schemas/talent-employment.schema.ts` - 移除 not_working 枚举值
+- `allin-packages/order-module/src/schemas/order.schema.ts` - 移除 not_working 描述
+- `allin-packages/disability-module/src/schemas/person-extension.schema.ts` - 移除 not_working 描述
+- `web/tests/e2e/pages/admin/order-management.page.ts` - 移除 NOT_WORKING 常量和映射
+
+**架构决策说明:**
+1. **迁移位置**:迁移文件放在 `packages/server/migrations/`,因为 server 包负责数据源配置和应用启动
+2. **迁移加载方式**:使用 glob 模式(`./migrations/*[0-9].ts`),避免循环依赖和重复加载
+3. **实体加载方式**:使用 glob 模式(`../allin-packages/*/src/entities/*.ts`),避免显式导入导致的循环依赖
+4. **关闭自动同步**:设置 `synchronize: false`,因为项目已有历史数据,不能使用自动同步
+5. **迁移运行策略**:开发环境手动运行 `pnpm migration:run`,生产环境在应用启动时自动运行
+6. **ESM CLI 工具**:使用 `typeorm-ts-node-esm` 作为 ESM 项目的专用 CLI 工具
+7. **循环依赖处理**:在关系装饰器中使用字符串语法引用实体,避免直接导入类
+
+### Change Log
+- 2026-01-19: 创建 Story,配置 TypeORM 迁移并清理 not_working 遗留
+- 2026-01-19: 完成 Story 实现,所有任务已完成并验证通过
+- 2026-01-19: 完成迁移机制实现 - 创建 Barrel 文件、更新 data-source.ts、创建自动化脚本
+- 2026-01-19: 代码审查修复 - 添加生产环境自动运行迁移逻辑,更新文档路径和描述
+- 2026-01-19: CLI 调试完成 - 修复循环依赖问题,改用 glob 模式加载,CLI 命令正常工作

+ 8 - 0
_bmad-output/implementation-artifacts/sprint-status.yaml

@@ -307,6 +307,14 @@ development_status:
 #   Phase 1: Epic B(简单)→ Epic C(复杂核心业务)
 #   Phase 1: Epic B(简单)→ Epic C(复杂核心业务)
 #   Phase 2: Epic F(配置管理)→ Epic D(用户管理)→ Epic E(跨端同步)
 #   Phase 2: Epic F(配置管理)→ Epic D(用户管理)→ Epic E(跨端同步)
 
 
+# Epic 14: 数据层改进
+# 目标: 配置 TypeORM 迁移功能并清理数据库遗留数据
+# 背景: Story 13.29 从代码移除 not_working 状态,但数据库和 Schema 文件仍有遗留
+# 优先级: P1 (高 - 阻塞应用启动)
+# 详情: 配置迁移、清理数据、更新 Schema、清理测试
+  epic-14: in-progress
+  14-1-typeorm-migration-not-working-cleanup: review   # TypeORM 迁移配置与 not_working 数据清理(2026-01-19 新增)- 配置迁移功能、创建迁移脚本、清理 Schema 和测试文件中的 not_working 引用 ✅ 完成 (2026-01-19) - 已创建 Barrel 文件、更新 data-source.ts、创建自动化脚本、创建 typeorm_migrations 表
+
 # 技术改进完成状态 (2026-01-10):
 # 技术改进完成状态 (2026-01-10):
 # ================================
 # ================================
 # - HIGH: 配置 ESLint 规则捕获常见问题 ✅
 # - HIGH: 配置 ESLint 规则捕获常见问题 ✅

+ 3 - 3
allin-packages/disability-module/src/entities/disabled-person.entity.ts

@@ -4,7 +4,7 @@ import { DisabledPhoto } from './disabled-photo.entity';
 import { DisabledRemark } from './disabled-remark.entity';
 import { DisabledRemark } from './disabled-remark.entity';
 import { DisabledVisit } from './disabled-visit.entity';
 import { DisabledVisit } from './disabled-visit.entity';
 import { DisabledPersonGuardianPhone } from './disabled-person-guardian-phone.entity';
 import { DisabledPersonGuardianPhone } from './disabled-person-guardian-phone.entity';
-import { OrderPerson } from '@d8d/allin-order-module/entities';
+// 注意:OrderPerson 使用字符串语法,避免循环依赖
 
 
 @Entity('disabled_person')
 @Entity('disabled_person')
 @Index(['name'])
 @Index(['name'])
@@ -234,8 +234,8 @@ export class DisabledPerson {
   @OneToMany(() => DisabledVisit, (visit: DisabledVisit) => visit.person)
   @OneToMany(() => DisabledVisit, (visit: DisabledVisit) => visit.person)
   visits!: DisabledVisit[];
   visits!: DisabledVisit[];
 
 
-  @OneToMany(() => OrderPerson, (orderPerson: OrderPerson) => orderPerson.person)
-  orderPersons!: OrderPerson[];
+  @OneToMany('OrderPerson', (orderPerson: any) => orderPerson.person)
+  orderPersons!: any[];
 
 
   @OneToMany(() => DisabledPersonGuardianPhone, (guardianPhone: DisabledPersonGuardianPhone) => guardianPhone.person)
   @OneToMany(() => DisabledPersonGuardianPhone, (guardianPhone: DisabledPersonGuardianPhone) => guardianPhone.person)
   guardianPhones!: DisabledPersonGuardianPhone[];
   guardianPhones!: DisabledPersonGuardianPhone[];

+ 1 - 1
allin-packages/disability-module/src/schemas/person-extension.schema.ts

@@ -271,7 +271,7 @@ export const CompanyPersonListQuerySchema = z.object({
     example: '肢体残疾'
     example: '肢体残疾'
   }),
   }),
   jobStatus: z.union([z.nativeEnum(WorkStatus), z.string()]).optional().openapi({
   jobStatus: z.union([z.nativeEnum(WorkStatus), z.string()]).optional().openapi({
-    description: '工作状态筛选:支持WorkStatus枚举值(working/pre_working/resigned/not_working)或中文标签(在职/待入职/离职/未就业)',
+    description: '工作状态筛选:支持WorkStatus枚举值(pre_working/working/resigned)或中文标签(待入职/在职/离职)',
     example: WorkStatus.WORKING
     example: WorkStatus.WORKING
   }),
   }),
   page: z.coerce.number().int().positive().default(1).openapi({
   page: z.coerce.number().int().positive().default(1).openapi({

+ 2 - 2
allin-packages/order-module/src/entities/order-person.entity.ts

@@ -1,6 +1,6 @@
 import { Entity, Column, PrimaryGeneratedColumn, ManyToOne, JoinColumn, Index } from 'typeorm';
 import { Entity, Column, PrimaryGeneratedColumn, ManyToOne, JoinColumn, Index } from 'typeorm';
 import type { EmploymentOrder } from './employment-order.entity';
 import type { EmploymentOrder } from './employment-order.entity';
-import type { DisabledPerson } from '@d8d/allin-disability-module/entities';
+// 注意:DisabledPerson 使用字符串语法,避免循环依赖
 import { WorkStatus } from '@d8d/allin-enums';
 import { WorkStatus } from '@d8d/allin-enums';
 
 
 @Entity('order_person', { comment: '订单人员关联表' })
 @Entity('order_person', { comment: '订单人员关联表' })
@@ -86,7 +86,7 @@ export class OrderPerson {
   // 与残疾人员的关联(使用字符串语法避免循环依赖)
   // 与残疾人员的关联(使用字符串语法避免循环依赖)
   @ManyToOne('DisabledPerson', { onDelete: 'CASCADE' })
   @ManyToOne('DisabledPerson', { onDelete: 'CASCADE' })
   @JoinColumn({ name: 'person_id' })
   @JoinColumn({ name: 'person_id' })
-  person!: DisabledPerson;
+  person!: any;
 
 
   constructor(partial?: Partial<OrderPerson>) {
   constructor(partial?: Partial<OrderPerson>) {
     Object.assign(this, partial);
     Object.assign(this, partial);

+ 1 - 1
allin-packages/order-module/src/schemas/order.schema.ts

@@ -483,7 +483,7 @@ export const UpdatePersonWorkStatusSchema = z.object({
     example: 1
     example: 1
   }),
   }),
   workStatus: z.nativeEnum(WorkStatus).openapi({
   workStatus: z.nativeEnum(WorkStatus).openapi({
-    description: '工作状态:not_working-未就业, pre_working-待就业, working-已就业, resigned-已离职',
+    description: '工作状态:pre_working-待就业, working-已就业, resigned-已离职',
     example: WorkStatus.WORKING
     example: WorkStatus.WORKING
   })
   })
 });
 });

+ 2 - 2
allin-packages/order-module/src/schemas/talent-employment.schema.ts

@@ -29,7 +29,7 @@ export const EmploymentStatusResponseSchema = z.object({
   }),
   }),
   workStatus: z.string().openapi({
   workStatus: z.string().openapi({
     description: '工作状态',
     description: '工作状态',
-    enum: ['not_working', 'pre_working', 'working', 'resigned'],
+    enum: ['pre_working', 'working', 'resigned'],
     example: 'working'
     example: 'working'
   }),
   }),
   salaryLevel: z.number().openapi({
   salaryLevel: z.number().openapi({
@@ -115,7 +115,7 @@ export const EmploymentHistoryItemSchema = z.object({
   }),
   }),
   workStatus: z.string().openapi({
   workStatus: z.string().openapi({
     description: '工作状态',
     description: '工作状态',
-    enum: ['not_working', 'pre_working', 'working', 'resigned'],
+    enum: ['pre_working', 'working', 'resigned'],
     example: 'working'
     example: 'working'
   }),
   }),
   salaryLevel: z.number().openapi({
   salaryLevel: z.number().openapi({

+ 3 - 1
package.json

@@ -80,7 +80,9 @@
     "eslint-plugin-react-hooks": "^7.0.1",
     "eslint-plugin-react-hooks": "^7.0.1",
     "globals": "^17.0.0",
     "globals": "^17.0.0",
     "husky": "^9.1.7",
     "husky": "^9.1.7",
-    "lint-staged": "^16.2.5"
+    "lint-staged": "^16.2.5",
+    "ts-node": "^10.9.2",
+    "tsx": "^4.20.6"
   },
   },
   "dependencies": {
   "dependencies": {
     "typescript": "^5.9.3"
     "typescript": "^5.9.3"

+ 89 - 0
packages/server/migrations/MigrateNotWorkingToPreWorking1737260000000.ts

@@ -0,0 +1,89 @@
+import { MigrationInterface, QueryRunner } from 'typeorm';
+
+/**
+ * TypeORM 迁移:移除 not_working 工作状态
+ *
+ * 此迁移执行以下操作:
+ * 1. 将所有 order_person 表中 work_status = 'not_working' 的记录更新为 'pre_working'
+ * 2. 重建数据库枚举类型 order_person_work_status_enum,移除 'not_working' 值
+ *
+ * 迁移原因:
+ * - Story 13.29 已从代码中移除 not_working 状态
+ * - 数据库中仍有 65 条记录使用此状态
+ * - 需要保持数据库与代码一致
+ *
+ * 回滚支持:
+ * - down() 方法会重新添加 not_working 值到枚举中
+ */
+export class MigrateNotWorkingToPreWorking1737260000000 implements MigrationInterface {
+  name = 'MigrateNotWorkingToPreWorking1737260000000';
+
+  public async up(queryRunner: QueryRunner): Promise<void> {
+    // 步骤 1: 更新数据 - 将所有 not_working 改为 pre_working
+    await queryRunner.query(`
+      UPDATE order_person
+      SET work_status = 'pre_working'
+      WHERE work_status = 'not_working'
+    `);
+    console.debug('Migration: Updated records from not_working to pre_working');
+
+    // 步骤 2: 重建枚举类型(PostgreSQL 不支持直接删除枚举值)
+    // 2.1 重命名旧枚举
+    await queryRunner.query(`
+      ALTER TYPE order_person_work_status_enum
+      RENAME TO order_person_work_status_enum_old
+    `);
+
+    // 2.2 创建新枚举(不包含 not_working)
+    await queryRunner.query(`
+      CREATE TYPE order_person_work_status_enum AS ENUM
+      ('pre_working', 'working', 'resigned')
+    `);
+
+    // 2.3 修改列类型到新枚举(使用 USING 子句进行类型转换)
+    await queryRunner.query(`
+      ALTER TABLE order_person
+      ALTER COLUMN work_status
+      TYPE order_person_work_status_enum
+      USING work_status::text::order_person_work_status_enum
+    `);
+
+    // 2.4 删除旧枚举类型
+    await queryRunner.query(`
+      DROP TYPE order_person_work_status_enum_old
+    `);
+
+    console.debug('Migration: Successfully removed not_working from enum');
+  }
+
+  public async down(queryRunner: QueryRunner): Promise<void> {
+    // 回滚:重新添加 not_working 值到枚举中
+
+    // 1. 重命名当前枚举
+    await queryRunner.query(`
+      ALTER TYPE order_person_work_status_enum
+      RENAME TO order_person_work_status_enum_old
+    `);
+
+    // 2. 创建包含 not_working 的新枚举
+    await queryRunner.query(`
+      CREATE TYPE order_person_work_status_enum AS ENUM
+      ('not_working', 'pre_working', 'working', 'resigned')
+    `);
+
+    // 3. 修改列类型到新枚举
+    await queryRunner.query(`
+      ALTER TABLE order_person
+      ALTER COLUMN work_status
+      TYPE order_person_work_status_enum
+      USING work_status::text::order_person_work_status_enum
+    `);
+
+    // 4. 删除旧枚举类型
+    await queryRunner.query(`
+      DROP TYPE order_person_work_status_enum_old
+    `);
+
+    console.debug('Migration rollback: Added not_working back to enum');
+  }
+}

+ 9 - 0
packages/server/migrations/index.ts

@@ -0,0 +1,9 @@
+/**
+ * TypeORM 迁移 Barrel 文件
+ *
+ * 集中导出所有迁移文件,便于统一管理
+ *
+ * 添加新迁移时,在此处添加对应的导出语句:
+ * export { NewMigrationClassName } from './NewMigrationClassName';
+ */
+export { MigrateNotWorkingToPreWorking1737260000000 } from './MigrateNotWorkingToPreWorking1737260000000';

+ 7 - 1
packages/server/package.json

@@ -25,7 +25,13 @@
     "test:unit": "vitest run tests/unit",
     "test:unit": "vitest run tests/unit",
     "test:integration": "vitest run tests/integration",
     "test:integration": "vitest run tests/integration",
     "test:coverage": "vitest --coverage",
     "test:coverage": "vitest --coverage",
-    "test:typecheck": "tsc --noEmit"
+    "test:typecheck": "tsc --noEmit",
+    "typeorm": "npx typeorm-ts-node-esm",
+    "migration:run": "npx typeorm-ts-node-esm migration:run -d src/data-source.ts",
+    "migration:generate": "npx typeorm-ts-node-esm migration:generate -d src/data-source.ts",
+    "migration:revert": "npx typeorm-ts-node-esm migration:revert -d src/data-source.ts",
+    "migration:show": "npx typeorm-ts-node-esm migration:show -d src/data-source.ts",
+    "migration:create": "bash scripts/create-migration.sh"
   },
   },
   "dependencies": {
   "dependencies": {
     "@asteasolutions/zod-to-openapi": "^8.1.0",
     "@asteasolutions/zod-to-openapi": "^8.1.0",

+ 86 - 0
packages/server/scripts/create-migration.sh

@@ -0,0 +1,86 @@
+#!/bin/bash
+# TypeORM 迁移创建自动化脚本
+#
+# 用法: pnpm run migration:create -- -n MigrationName
+#
+# 功能:
+# 1. 调用 TypeORM CLI 生成迁移文件
+# 2. 自动更新 migrations/index.ts Barrel 文件
+# 3. 自动更新 src/data-source.ts 的 migrations 数组
+
+set -e  # 遇到错误立即退出
+
+# 获取迁移名称参数
+MIGRATION_NAME="${1:-}"
+
+if [ -z "$MIGRATION_NAME" ]; then
+    echo "错误:请提供迁移名称"
+    echo "用法: pnpm run migration:create -- -n MigrationName"
+    exit 1
+fi
+
+echo "=========================================="
+echo "TypeORM 迁移创建工具"
+echo "=========================================="
+echo "迁移名称: $MIGRATION_NAME"
+echo ""
+
+# 进入 server 目录
+cd "$(dirname "$0")/.."
+
+# 1. 调用 TypeORM CLI 生成迁移文件
+echo "步骤 1: 生成迁移文件..."
+pnpm exec typeorm-ts-node-commonjs migration:generate -d src/data-source.ts -n "$MIGRATION_NAME"
+
+# 查找新生成的迁移文件
+MIGRATION_FILE=$(find migrations -name "*.ts" -type f | grep -v index.ts | tail -1)
+
+if [ -z "$MIGRATION_FILE" ]; then
+    echo "错误:未找到生成的迁移文件"
+    exit 1
+fi
+
+echo "生成的迁移文件: $MIGRATION_FILE"
+
+# 提取迁移类名(不含扩展名)
+MIGRATION_CLASS=$(basename "$MIGRATION_FILE" .ts)
+
+# 2. 更新 migrations/index.ts Barrel 文件
+echo ""
+echo "步骤 2: 更新 migrations/index.ts..."
+
+if ! grep -q "$MIGRATION_CLASS" migrations/index.ts 2>/dev/null; then
+    # 追加导出语句到 index.ts
+    echo "export { $MIGRATION_CLASS } from './$MIGRATION_CLASS';" >> migrations/index.ts
+    echo "已添加 $MIGRATION_CLASS 到 migrations/index.ts"
+else
+    echo "$MIGRATION_CLASS 已存在于 migrations/index.ts"
+fi
+
+# 3. 更新 src/data-source.ts 的 migrations 数组
+echo ""
+echo "步骤 3: 更新 src/data-source.ts..."
+
+if ! grep -q "$MIGRATION_CLASS" src/data-source.ts; then
+    # 在 migrations 数组中添加新类(在最后一个元素后添加)
+    # 使用 awk 查找 // 添加新迁移时... 这一行,并在其前面插入新类
+    awk -v class="$MIGRATION_CLASS" '
+        /\/\/ 添加新迁移时,在此处添加对应的/ {
+            print "    " class ","
+        }
+        { print }
+    ' src/data-source.ts > src/data-source.ts.tmp && mv src/data-source.ts.tmp src/data-source.ts
+    echo "已添加 $MIGRATION_CLASS 到 src/data-source.ts"
+else
+    echo "$MIGRATION_CLASS 已存在于 src/data-source.ts"
+fi
+
+echo ""
+echo "=========================================="
+echo "迁移创建完成!"
+echo "=========================================="
+echo ""
+echo "下一步操作:"
+echo "1. 检查并编辑迁移文件: $MIGRATION_FILE"
+echo "2. 运行迁移: pnpm migration:run"
+echo ""

+ 35 - 0
packages/server/src/data-source.ts

@@ -0,0 +1,35 @@
+import "reflect-metadata"
+import { DataSource } from "typeorm"
+import process from 'node:process'
+
+/**
+ * TypeORM 迁移数据源配置
+ *
+ * 此文件专用于 TypeORM 迁移 CLI 命令:
+ * - pnpm migration:show
+ * - pnpm migration:run
+ * - pnpm migration:revert
+ *
+ * 注意:
+ * - 使用 glob 模式加载实体,避免循环依赖
+ * - 关闭自动同步(synchronize: false)
+ * - 迁移通过 glob 模式加载
+ */
+export const AppDataSource = new DataSource({
+  type: "postgres",
+  host: process.env.DB_HOST || "localhost",
+  port: parseInt(process.env.DB_PORT || "5432"),
+  username: process.env.DB_USERNAME || "postgres",
+  password: process.env.DB_PASSWORD || "",
+  database: process.env.DB_DATABASE || "postgres",
+  // 使用 glob 模式加载实体,避免循环依赖
+  entities: [
+    "../allin-packages/*/src/entities/*.ts",
+    "../packages/*/src/entities/*.ts",
+  ],
+  migrations: [
+    "./migrations/*[0-9].ts",  // 只匹配数字时间戳开头的迁移文件,排除 index.ts
+  ],
+  synchronize: false,  // 迁移时必须关闭自动同步
+  logging: process.env.DB_LOGGING === "true",
+})

+ 12 - 34
packages/server/src/index.ts

@@ -1,48 +1,26 @@
 import { OpenAPIHono } from '@hono/zod-openapi'
 import { OpenAPIHono } from '@hono/zod-openapi'
 import { swaggerUI } from '@hono/swagger-ui'
 import { swaggerUI } from '@hono/swagger-ui'
-import { errorHandler, initializeDataSource } from '@d8d/shared-utils'
+import { errorHandler } from '@d8d/shared-utils'
 import { userRoutes as userModuleRoutes, roleRoutes as roleModuleRoutes } from '@d8d/core-module/user-module'
 import { userRoutes as userModuleRoutes, roleRoutes as roleModuleRoutes } from '@d8d/core-module/user-module'
 import { authRoutes as authModuleRoutes, enterpriseAuthRoutes as enterpriseAuthModuleRoutes, talentAuthRoutes as talentAuthModuleRoutes } from '@d8d/core-module/auth-module'
 import { authRoutes as authModuleRoutes, enterpriseAuthRoutes as enterpriseAuthModuleRoutes, talentAuthRoutes as talentAuthModuleRoutes } from '@d8d/core-module/auth-module'
 import { fileRoutes as fileModuleRoutes } from '@d8d/core-module/file-module'
 import { fileRoutes as fileModuleRoutes } from '@d8d/core-module/file-module'
 import { AuthContext } from '@d8d/shared-types'
 import { AuthContext } from '@d8d/shared-types'
-import { AppDataSource } from '@d8d/shared-utils'
+import { AppDataSource } from './data-source'
 import { Hono } from 'hono'
 import { Hono } from 'hono'
 import { databaseBackup } from './utils/backup'
 import { databaseBackup } from './utils/backup'
-import { UserEntity, Role } from '@d8d/core-module/user-module'
-import { File } from '@d8d/core-module/file-module'
-import { SystemConfig } from '@d8d/core-module/system-config-module'
-import { areasRoutes, adminAreasRoutes, AreaEntity } from '@d8d/geo-areas'
-import { channelRoutes } from '@d8d/allin-channel-module'
-import { Channel } from '@d8d/allin-channel-module/entities'
-import { companyRoutes, companyStatisticsRoutes, companyEnterpriseRoutes } from '@d8d/allin-company-module'
-import { Company } from '@d8d/allin-company-module/entities'
-import { disabledPersonRoutes, personExtensionRoutes, talentPersonalInfoRoutes } from '@d8d/allin-disability-module'
-import { DisabledPerson, DisabledBankCard, DisabledPhoto, DisabledRemark, DisabledVisit, DisabledPersonGuardianPhone } from '@d8d/allin-disability-module/entities'
-import { orderRoutes, enterpriseOrderRoutes, talentEmploymentRoutes } from '@d8d/allin-order-module'
-import { statisticsRoutes } from '@d8d/allin-statistics-module'
-import { EmploymentOrder, OrderPerson, OrderPersonAsset } from '@d8d/allin-order-module/entities'
-import { platformRoutes } from '@d8d/allin-platform-module'
-import { Platform } from '@d8d/allin-platform-module/entities'
-import { salaryRoutes } from '@d8d/allin-salary-module'
-import { SalaryLevel } from '@d8d/allin-salary-module/entities'
-import { bankNameRoutes } from '@d8d/bank-names-module'
-import { BankName } from '@d8d/bank-names-module'
-
-initializeDataSource([
-  UserEntity, Role, File, SystemConfig, AreaEntity,
-  Channel,
-  Company,
-  DisabledPerson, DisabledBankCard, DisabledPhoto, DisabledRemark, DisabledVisit, DisabledPersonGuardianPhone,
-  EmploymentOrder, OrderPerson, OrderPersonAsset,
-  Platform,
-  SalaryLevel,
-  BankName
-])
 
 
+// 使用 data-source.ts 中定义的 AppDataSource(包含所有实体和迁移配置)
 if(!AppDataSource || !AppDataSource.isInitialized) {
 if(!AppDataSource || !AppDataSource.isInitialized) {
   await AppDataSource.initialize();
   await AppDataSource.initialize();
   console.log('数据库初始化完成')
   console.log('数据库初始化完成')
 
 
+  // 生产环境自动运行迁移
+  const isProduction = process.env.NODE_ENV === 'production';
+  if (isProduction) {
+    await AppDataSource.runMigrations();
+    console.log('数据库迁移已完成');
+  }
+
   // 启动数据库备份调度
   // 启动数据库备份调度
   databaseBackup.startScheduledBackups();
   databaseBackup.startScheduledBackups();
   console.log('数据库备份调度已启动');
   console.log('数据库备份调度已启动');
@@ -73,8 +51,8 @@ api.openAPIRegistry.registerComponent('securitySchemes','bearerAuth',{
 })
 })
 
 
 // OpenAPI documentation endpoint
 // OpenAPI documentation endpoint
-// !import.meta.env.PROD
-if(1){
+// eslint-disable-next-line no-constant-condition
+if (true) {
   // api.doc31('/doc', {
   // api.doc31('/doc', {
   //   openapi: '3.1.0',
   //   openapi: '3.1.0',
   //   info: {
   //   info: {

+ 8 - 6
packages/shared-utils/src/data-source.ts

@@ -8,9 +8,10 @@ export type EntityTarget = Function | EntitySchema<any> | string
 /**
 /**
  * 创建数据源配置
  * 创建数据源配置
  * @param entities 实体类数组
  * @param entities 实体类数组
+ * @param migrations 迁移类数组或文件路径数组(可选)
  * @returns DataSource 实例
  * @returns DataSource 实例
  */
  */
-export function createDataSource(entities: EntityTarget[]): DataSource {
+export function createDataSource(entities: EntityTarget[], migrations: (string[] | any[]) = []): DataSource {
   // 在测试环境下使用测试数据库配置
   // 在测试环境下使用测试数据库配置
   const isTestEnv = process.env.NODE_ENV === 'test';
   const isTestEnv = process.env.NODE_ENV === 'test';
   const testDatabaseUrl = process.env.TEST_DATABASE_URL || 'postgresql://postgres:test_password@localhost:5432/test_d8dai';
   const testDatabaseUrl = process.env.TEST_DATABASE_URL || 'postgresql://postgres:test_password@localhost:5432/test_d8dai';
@@ -20,7 +21,7 @@ export function createDataSource(entities: EntityTarget[]): DataSource {
         type: "postgres",
         type: "postgres",
         url: testDatabaseUrl,
         url: testDatabaseUrl,
         entities,
         entities,
-        migrations: [],
+        migrations: [], // 测试环境不使用迁移
         synchronize: true, // 测试环境总是同步schema
         synchronize: true, // 测试环境总是同步schema
         dropSchema: true,  // 测试环境每次重新创建schema
         dropSchema: true,  // 测试环境每次重新创建schema
         logging: false,    // 测试环境关闭日志
         logging: false,    // 测试环境关闭日志
@@ -33,8 +34,8 @@ export function createDataSource(entities: EntityTarget[]): DataSource {
         password: process.env.DB_PASSWORD || "",
         password: process.env.DB_PASSWORD || "",
         database: process.env.DB_DATABASE || "postgres",
         database: process.env.DB_DATABASE || "postgres",
         entities,
         entities,
-        migrations: [],
-        synchronize: process.env.DB_SYNCHRONIZE !== "false",
+        migrations, // 使用传入的迁移类数组或文件路径数组
+        synchronize: (migrations.length > 0) ? false : process.env.DB_SYNCHRONIZE !== "false", // 有迁移时关闭自动同步
         logging: process.env.DB_LOGGING === "true",
         logging: process.env.DB_LOGGING === "true",
       });
       });
 }
 }
@@ -48,7 +49,8 @@ export let AppDataSource: DataSource;
 /**
 /**
  * 初始化默认数据源
  * 初始化默认数据源
  * @param entities 实体类数组
  * @param entities 实体类数组
+ * @param migrations 迁移类数组或文件路径数组(可选)
  */
  */
-export function initializeDataSource(entities: EntityTarget[]): void {
-  AppDataSource = createDataSource(entities);
+export function initializeDataSource(entities: EntityTarget[], migrations: (string[] | any[]) = []): void {
+  AppDataSource = createDataSource(entities, migrations);
 }
 }

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 122 - 116
pnpm-lock.yaml


+ 2 - 5
web/tests/e2e/pages/admin/order-management.page.ts

@@ -31,7 +31,6 @@ export const ORDER_STATUS_LABELS: Record<OrderStatus, string> = {
  * 工作状态常量
  * 工作状态常量
  */
  */
 export const WORK_STATUS = {
 export const WORK_STATUS = {
-  NOT_WORKING: 'not_working',
   PRE_WORKING: 'pre_working',
   PRE_WORKING: 'pre_working',
   WORKING: 'working',
   WORKING: 'working',
   RESIGNED: 'resigned',
   RESIGNED: 'resigned',
@@ -46,7 +45,6 @@ export type WorkStatus = typeof WORK_STATUS[keyof typeof WORK_STATUS];
  * 工作状态显示名称映射
  * 工作状态显示名称映射
  */
  */
 export const WORK_STATUS_LABELS: Record<WorkStatus, string> = {
 export const WORK_STATUS_LABELS: Record<WorkStatus, string> = {
-  not_working: '未就业',
   pre_working: '待入职',
   pre_working: '待入职',
   working: '在职',
   working: '在职',
   resigned: '已离职',
   resigned: '已离职',
@@ -1059,10 +1057,9 @@ export class OrderManagementPage {
 
 
     // 使用中文标签选择选项
     // 使用中文标签选择选项
     // 注意:UI 中的工作状态选项与 WORK_STATUS_LABELS 不同
     // 注意:UI 中的工作状态选项与 WORK_STATUS_LABELS 不同
-    // UI 选项:未入职、已入职、工作中、已离职
-    // WORK_STATUS_LABELS:未就业、待就业、已就业、已离职
+    // UI 选项:已入职、工作中、已离职
+    // WORK_STATUS_LABELS:待入职、在职、已离职
     const statusMapping: Record<WorkStatus, string> = {
     const statusMapping: Record<WorkStatus, string> = {
-      not_working: '未入职',
       pre_working: '已入职',
       pre_working: '已入职',
       working: '工作中',
       working: '工作中',
       resigned: '已离职',
       resigned: '已离职',

Algunos archivos no se mostraron porque demasiados archivos cambiaron en este cambio