|
@@ -1,5 +1,5 @@
|
|
|
import { GenericCrudService } from '@d8d/shared-crud';
|
|
import { GenericCrudService } from '@d8d/shared-crud';
|
|
|
-import { DataSource, Repository, Like, Not, MoreThanOrEqual } from 'typeorm';
|
|
|
|
|
|
|
+import { DataSource, Like, Not, MoreThanOrEqual } from 'typeorm';
|
|
|
import { EmploymentOrder, OrderPerson } from '@d8d/allin-order-module';
|
|
import { EmploymentOrder, OrderPerson } from '@d8d/allin-order-module';
|
|
|
import { OrderStatus, WorkStatus } from '@d8d/allin-enums';
|
|
import { OrderStatus, WorkStatus } from '@d8d/allin-enums';
|
|
|
import { Company } from '../entities/company.entity';
|
|
import { Company } from '../entities/company.entity';
|
|
@@ -14,7 +14,7 @@ export class CompanyService extends GenericCrudService<Company> {
|
|
|
/**
|
|
/**
|
|
|
* 创建公司 - 覆盖父类方法,添加公司名称在同一平台下唯一性检查
|
|
* 创建公司 - 覆盖父类方法,添加公司名称在同一平台下唯一性检查
|
|
|
*/
|
|
*/
|
|
|
- override async create(data: Partial<Company>, userId?: string | number): Promise<Company> {
|
|
|
|
|
|
|
+ override async create(data: Partial<Company>, _userId?: string | number): Promise<Company> {
|
|
|
// 检查公司名称是否在同一平台下已存在
|
|
// 检查公司名称是否在同一平台下已存在
|
|
|
if (data.companyName) {
|
|
if (data.companyName) {
|
|
|
const whereCondition: any = { companyName: data.companyName };
|
|
const whereCondition: any = { companyName: data.companyName };
|
|
@@ -101,7 +101,7 @@ export class CompanyService extends GenericCrudService<Company> {
|
|
|
/**
|
|
/**
|
|
|
* 删除公司 - 覆盖父类方法,改为软删除(设置status为0)
|
|
* 删除公司 - 覆盖父类方法,改为软删除(设置status为0)
|
|
|
*/
|
|
*/
|
|
|
- override async delete(id: number, userId?: string | number): Promise<boolean> {
|
|
|
|
|
|
|
+ override async delete(id: number, _userId?: string | number): Promise<boolean> {
|
|
|
// 改为软删除:设置status为0
|
|
// 改为软删除:设置status为0
|
|
|
const result = await this.repository.update({ id }, { status: 0 });
|
|
const result = await this.repository.update({ id }, { status: 0 });
|
|
|
return result.affected === 1;
|
|
return result.affected === 1;
|
|
@@ -213,6 +213,24 @@ export class CompanyService extends GenericCrudService<Company> {
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
+ // 查询待入职人员数(order_person.work_status = 'pre_working')
|
|
|
|
|
+ const preWorkingCount = await orderPersonRepo.count({
|
|
|
|
|
+ where: {
|
|
|
|
|
+ workStatus: WorkStatus.PRE_WORKING,
|
|
|
|
|
+ order: { companyId }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ // 查询本月新增分配人员数量(当前月份新分配的人员)
|
|
|
|
|
+ const now = new Date();
|
|
|
|
|
+ const startOfMonth = new Date(now.getFullYear(), now.getMonth(), 1);
|
|
|
|
|
+ const newHiresThisMonth = await orderPersonRepo.count({
|
|
|
|
|
+ where: {
|
|
|
|
|
+ order: { companyId },
|
|
|
|
|
+ joinDate: MoreThanOrEqual(startOfMonth)
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
// 查询进行中订单数(employment_order.order_status = 'in_progress')
|
|
// 查询进行中订单数(employment_order.order_status = 'in_progress')
|
|
|
const inProgressOrders = await employmentOrderRepo.count({
|
|
const inProgressOrders = await employmentOrderRepo.count({
|
|
|
where: {
|
|
where: {
|
|
@@ -236,6 +254,8 @@ export class CompanyService extends GenericCrudService<Company> {
|
|
|
|
|
|
|
|
return {
|
|
return {
|
|
|
在职人员数: workingCount,
|
|
在职人员数: workingCount,
|
|
|
|
|
+ 待入职数: preWorkingCount,
|
|
|
|
|
+ 本月新增数: newHiresThisMonth,
|
|
|
进行中订单数: inProgressOrders,
|
|
进行中订单数: inProgressOrders,
|
|
|
已完成订单数: completedOrders,
|
|
已完成订单数: completedOrders,
|
|
|
累计订单数: totalOrders
|
|
累计订单数: totalOrders
|
|
@@ -278,8 +298,12 @@ export class CompanyService extends GenericCrudService<Company> {
|
|
|
人才列表: talents.map(talent => ({
|
|
人才列表: talents.map(talent => ({
|
|
|
personId: talent.personId,
|
|
personId: talent.personId,
|
|
|
personName: talent.person?.name,
|
|
personName: talent.person?.name,
|
|
|
- joinDate: talent.joinDate || new Date(), // z.coerce.date()会自动转换
|
|
|
|
|
|
|
+ disabilityType: talent.person?.disabilityType,
|
|
|
|
|
+ disabilityLevel: talent.person?.disabilityLevel,
|
|
|
|
|
+ phone: talent.person?.phone,
|
|
|
|
|
+ joinDate: talent.joinDate || new Date(),
|
|
|
workStatus: talent.workStatus,
|
|
workStatus: talent.workStatus,
|
|
|
|
|
+ orderId: talent.orderId,
|
|
|
orderName: talent.order?.orderName
|
|
orderName: talent.order?.orderName
|
|
|
})),
|
|
})),
|
|
|
状态分布: statusDistribution
|
|
状态分布: statusDistribution
|
|
@@ -313,8 +337,12 @@ export class CompanyService extends GenericCrudService<Company> {
|
|
|
人才列表: talents.map(talent => ({
|
|
人才列表: talents.map(talent => ({
|
|
|
personId: talent.personId,
|
|
personId: talent.personId,
|
|
|
personName: talent.person?.name,
|
|
personName: talent.person?.name,
|
|
|
- joinDate: talent.joinDate || new Date(), // z.coerce.date()会自动转换
|
|
|
|
|
|
|
+ disabilityType: talent.person?.disabilityType,
|
|
|
|
|
+ disabilityLevel: talent.person?.disabilityLevel,
|
|
|
|
|
+ phone: talent.person?.phone,
|
|
|
|
|
+ joinDate: talent.joinDate || new Date(),
|
|
|
workStatus: talent.workStatus,
|
|
workStatus: talent.workStatus,
|
|
|
|
|
+ orderId: talent.orderId,
|
|
|
orderName: talent.order?.orderName
|
|
orderName: talent.order?.orderName
|
|
|
}))
|
|
}))
|
|
|
};
|
|
};
|