|
|
@@ -7,6 +7,15 @@ import { DisabledRemark } from '../entities/disabled-remark.entity';
|
|
|
import { DisabledVisit } from '../entities/disabled-visit.entity';
|
|
|
import { FileService, File } from '@d8d/file-module';
|
|
|
import { OrderPerson, OrderPersonAsset, EmploymentOrder } from '@d8d/allin-order-module';
|
|
|
+import { WorkStatus, getWorkStatusLabel } from '@d8d/allin-enums';
|
|
|
+
|
|
|
+// 前端专用的工作状态中文标签映射(与mini-ui保持一致)
|
|
|
+const FrontendWorkStatusLabels: Record<WorkStatus, string> = {
|
|
|
+ [WorkStatus.NOT_WORKING]: '未就业',
|
|
|
+ [WorkStatus.PRE_WORKING]: '待入职',
|
|
|
+ [WorkStatus.WORKING]: '在职',
|
|
|
+ [WorkStatus.RESIGNED]: '离职'
|
|
|
+};
|
|
|
|
|
|
export class DisabledPersonService extends GenericCrudService<DisabledPerson> {
|
|
|
private readonly bankCardRepository: Repository<DisabledBankCard>;
|
|
|
@@ -399,7 +408,7 @@ export class DisabledPersonService extends GenericCrudService<DisabledPerson> {
|
|
|
入职日期: item.joinDate, // z.coerce.date().nullable()会自动转换
|
|
|
实际入职日期: item.actualStartDate, // z.coerce.date().nullable()会自动转换
|
|
|
离职日期: item.leaveDate, // z.coerce.date().nullable()会自动转换
|
|
|
- 工作状态: item.workStatus,
|
|
|
+ 工作状态: FrontendWorkStatusLabels[item.workStatus] || getWorkStatusLabel(item.workStatus), // 使用前端专用映射,后备使用默认映射
|
|
|
个人薪资: item.salaryDetail // z.coerce.number()会自动转换
|
|
|
}));
|
|
|
}
|
|
|
@@ -517,6 +526,9 @@ export class DisabledPersonService extends GenericCrudService<DisabledPerson> {
|
|
|
limit = 10
|
|
|
} = query;
|
|
|
|
|
|
+ // 工作状态到中文标签的映射(使用前端专用映射)
|
|
|
+ const workStatusLabelMap: Record<string, string> = FrontendWorkStatusLabels;
|
|
|
+
|
|
|
// 确保page和limit是数字
|
|
|
const pageNum = typeof page === 'string' ? parseInt(page, 10) || 1 : page || 1;
|
|
|
const limitNum = typeof limit === 'string' ? parseInt(limit, 10) || 10 : limit || 10;
|
|
|
@@ -539,25 +551,31 @@ export class DisabledPersonService extends GenericCrudService<DisabledPerson> {
|
|
|
}
|
|
|
|
|
|
if (jobStatus) {
|
|
|
- // 将前端传递的中文工作状态映射到数据库的数字值
|
|
|
- let jobStatusValue: number;
|
|
|
- switch (jobStatus) {
|
|
|
- case '在职':
|
|
|
- jobStatusValue = 1; // 已在职
|
|
|
- break;
|
|
|
- case '离职':
|
|
|
- jobStatusValue = 0; // 未在职
|
|
|
- break;
|
|
|
- case '待入职':
|
|
|
- jobStatusValue = 0; // 未在职(尚未入职)
|
|
|
- break;
|
|
|
- default:
|
|
|
- jobStatusValue = 0; // 默认未在职
|
|
|
+ // 工作状态筛选逻辑 - 支持中文状态和WorkStatus枚举值
|
|
|
+ // 映射中文状态到WorkStatus枚举值
|
|
|
+ const chineseToWorkStatus: Record<string, WorkStatus> = {
|
|
|
+ '在职': WorkStatus.WORKING,
|
|
|
+ '待入职': WorkStatus.PRE_WORKING,
|
|
|
+ '离职': WorkStatus.RESIGNED,
|
|
|
+ '未就业': WorkStatus.NOT_WORKING
|
|
|
+ };
|
|
|
+
|
|
|
+ let workStatusValue: WorkStatus | undefined;
|
|
|
+
|
|
|
+ // 检查是否是有效的WorkStatus枚举值
|
|
|
+ if (Object.values(WorkStatus).includes(jobStatus as WorkStatus)) {
|
|
|
+ workStatusValue = jobStatus as WorkStatus;
|
|
|
+ } else if (chineseToWorkStatus[jobStatus]) {
|
|
|
+ workStatusValue = chineseToWorkStatus[jobStatus];
|
|
|
+ }
|
|
|
+
|
|
|
+ if (workStatusValue) {
|
|
|
+ // 使用order_person.work_status进行筛选
|
|
|
+ queryBuilder.andWhere('op.workStatus = :workStatus', { workStatus: workStatusValue });
|
|
|
}
|
|
|
- queryBuilder.andWhere('person.jobStatus = :jobStatus', { jobStatus: jobStatusValue });
|
|
|
}
|
|
|
|
|
|
- // 按人员ID去重(同一人员可能关联多个订单),使用子查询获取最新订单
|
|
|
+ // 按人员ID去重(同一人员可能关联多个订单),获取最新订单信息
|
|
|
queryBuilder.select([
|
|
|
'person.id as personId',
|
|
|
'person.name as name',
|
|
|
@@ -566,13 +584,13 @@ export class DisabledPersonService extends GenericCrudService<DisabledPerson> {
|
|
|
'person.disabilityType as disabilityType',
|
|
|
'person.disabilityLevel as disabilityLevel',
|
|
|
'person.phone as phone',
|
|
|
- 'person.jobStatus as jobStatus',
|
|
|
'person.birth_date as birthDate',
|
|
|
'MAX(op.joinDate) as latestJoinDate',
|
|
|
'MAX(op.salary_detail) as salaryDetail',
|
|
|
+ 'MAX(op.workStatus) as workStatus', // 获取最新工作状态
|
|
|
'order.orderName as orderName'
|
|
|
])
|
|
|
- .groupBy('person.id, person.name, person.gender, person.idCard, person.disabilityType, person.disabilityLevel, person.phone, person.jobStatus, person.birth_date, order.orderName');
|
|
|
+ .groupBy('person.id, person.name, person.gender, person.idCard, person.disabilityType, person.disabilityLevel, person.phone, person.birth_date, order.orderName');
|
|
|
|
|
|
// 按最新入职日期排序
|
|
|
queryBuilder.orderBy('latestJoinDate', 'DESC');
|
|
|
@@ -587,20 +605,27 @@ export class DisabledPersonService extends GenericCrudService<DisabledPerson> {
|
|
|
const rawResults = await queryBuilder.getRawMany();
|
|
|
|
|
|
// 转换结果格式 - 注意:PostgreSQL列名是小写的
|
|
|
- const data = rawResults.map((row) => ({
|
|
|
- personId: row.personid,
|
|
|
- name: row.name,
|
|
|
- gender: row.gender,
|
|
|
- idCard: row.idcard,
|
|
|
- disabilityType: row.disabilitytype,
|
|
|
- disabilityLevel: row.disabilitylevel,
|
|
|
- phone: row.phone,
|
|
|
- jobStatus: row.jobstatus === 1 ? '在职' : '离职', // 数字映射到中文状态
|
|
|
- birthDate: row.birthdate,
|
|
|
- salaryDetail: row.salarydetail,
|
|
|
- latestJoinDate: row.latestjoindate,
|
|
|
- orderName: row.ordername
|
|
|
- }));
|
|
|
+ const data = rawResults.map((row) => {
|
|
|
+ const workStatus = row.workstatus as WorkStatus | undefined;
|
|
|
+ const workStatusLabel = workStatus ? workStatusLabelMap[workStatus] : '未知状态';
|
|
|
+
|
|
|
+ return {
|
|
|
+ personId: row.personid,
|
|
|
+ name: row.name,
|
|
|
+ gender: row.gender,
|
|
|
+ idCard: row.idcard,
|
|
|
+ disabilityType: row.disabilitytype,
|
|
|
+ disabilityLevel: row.disabilitylevel,
|
|
|
+ phone: row.phone,
|
|
|
+ jobStatus: workStatusLabel, // 保持字段名兼容性,使用中文标签
|
|
|
+ workStatus: workStatus, // 新增:枚举值
|
|
|
+ workStatusLabel: workStatusLabel, // 新增:中文标签
|
|
|
+ birthDate: row.birthdate,
|
|
|
+ salaryDetail: row.salarydetail,
|
|
|
+ latestJoinDate: row.latestjoindate,
|
|
|
+ orderName: row.ordername
|
|
|
+ };
|
|
|
+ });
|
|
|
|
|
|
return { data, total };
|
|
|
}
|
|
|
@@ -615,6 +640,9 @@ export class DisabledPersonService extends GenericCrudService<DisabledPerson> {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ // 工作状态到中文标签的映射(使用前端专用映射)
|
|
|
+ const workStatusLabelMap: Record<string, string> = FrontendWorkStatusLabels;
|
|
|
+
|
|
|
// 获取人员基本信息
|
|
|
const person = await this.findOne(personId);
|
|
|
if (!person) {
|
|
|
@@ -657,6 +685,10 @@ export class DisabledPersonService extends GenericCrudService<DisabledPerson> {
|
|
|
fileUrl: photo.file ? await photo.file.fullUrl : ''
|
|
|
})));
|
|
|
|
|
|
+ // 确定工作状态
|
|
|
+ const workStatus = latestOrderPerson?.workStatus as WorkStatus | undefined;
|
|
|
+ const workStatusLabel = workStatus ? workStatusLabelMap[workStatus] : '未知状态';
|
|
|
+
|
|
|
return {
|
|
|
personId: person.id,
|
|
|
name: person.name,
|
|
|
@@ -667,7 +699,9 @@ export class DisabledPersonService extends GenericCrudService<DisabledPerson> {
|
|
|
birthDate: person.birthDate,
|
|
|
salaryDetail: latestOrderPerson?.salaryDetail || null,
|
|
|
phone: person.phone,
|
|
|
- jobStatus: person.jobStatus === 1 ? '在职' : '离职', // 数字映射到中文状态
|
|
|
+ jobStatus: workStatusLabel, // 保持字段名兼容性,使用中文标签
|
|
|
+ workStatus: workStatus, // 新增:枚举值
|
|
|
+ workStatusLabel: workStatusLabel, // 新增:中文标签
|
|
|
bankCards: formattedBankCards,
|
|
|
photos: formattedPhotos
|
|
|
};
|