Merge branch 'develop' into adiDev
This commit is contained in:
commit
0929693703
1 changed files with 51 additions and 32 deletions
|
|
@ -7321,41 +7321,30 @@ export class OrganizationController extends Controller {
|
|||
}
|
||||
|
||||
/**
|
||||
* API ลบคนในโครงสร้าง
|
||||
* API ลบข้าราชการในโครงสร้าง
|
||||
*
|
||||
* @summary - ลบคนในโครงสร้าง (ADMIN)
|
||||
* @summary - ลบข้าราชการในโครงสร้าง (ADMIN)
|
||||
*
|
||||
*/
|
||||
@Get("delete/profile/org/{orgRevisionId}")
|
||||
async deleteRetireInOrg(@Path() orgRevisionId: string, @Request() request: RequestWithUser) {
|
||||
const [posMasters, posMastersEmployee] = await Promise.all([
|
||||
this.posMasterRepository.find({
|
||||
where: {
|
||||
orgRevisionId,
|
||||
current_holder: {
|
||||
isLeave: true,
|
||||
isRetirement: true,
|
||||
leaveType: IsNull(),
|
||||
},
|
||||
positions: { positionIsSelected: true },
|
||||
@Get("delete/profile-officer/org/{orgRevisionId}")
|
||||
async deleteOfficerRetireInOrg(
|
||||
@Path() orgRevisionId: string,
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
const posMasters = await this.posMasterRepository.find({
|
||||
where: {
|
||||
orgRevisionId,
|
||||
current_holderId: Not(IsNull()),
|
||||
current_holder: {
|
||||
isLeave: true,
|
||||
isRetirement: true,
|
||||
},
|
||||
relations: ["positions"],
|
||||
}),
|
||||
this.employeePosMasterRepository.find({
|
||||
where: {
|
||||
orgRevisionId,
|
||||
current_holder: {
|
||||
isLeave: true,
|
||||
isRetirement: true,
|
||||
leaveType: IsNull(),
|
||||
},
|
||||
},
|
||||
relations: ["positions"],
|
||||
}),
|
||||
]);
|
||||
// positions: { positionIsSelected: true },
|
||||
},
|
||||
relations: ["positions"],
|
||||
});
|
||||
|
||||
let checkOfficer = 0;
|
||||
let checkEmployee = 0;
|
||||
|
||||
await Promise.all([
|
||||
posMasters.map(async (posMaster) => {
|
||||
|
|
@ -7371,6 +7360,38 @@ export class OrganizationController extends Controller {
|
|||
await this.posMasterRepository.save(posMaster);
|
||||
await CreatePosMasterHistoryOfficer(posMaster.id, null);
|
||||
}),
|
||||
]);
|
||||
|
||||
return new HttpSuccess({
|
||||
totalOfficer: posMasters.length,
|
||||
officerSuccessAmount: checkOfficer,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* API ลบลูกจ้างในโครงสร้าง
|
||||
*
|
||||
* @summary - ลบลูกจ้างในโครงสร้าง (ADMIN)
|
||||
*
|
||||
*/
|
||||
@Get("delete/profile-emp/org/{orgRevisionId}")
|
||||
async deleteRetireEmpInOrg(@Path() orgRevisionId: string, @Request() request: RequestWithUser) {
|
||||
const posMastersEmployee = await this.employeePosMasterRepository.find({
|
||||
where: {
|
||||
orgRevisionId,
|
||||
current_holderId: Not(IsNull()),
|
||||
current_holder: {
|
||||
isLeave: true,
|
||||
isRetirement: true,
|
||||
},
|
||||
// positions: { positionIsSelected: true },
|
||||
},
|
||||
relations: ["positions"],
|
||||
});
|
||||
|
||||
let checkEmployee = 0;
|
||||
|
||||
await Promise.all(
|
||||
posMastersEmployee.map(async (posMaster) => {
|
||||
posMaster.current_holderId = null;
|
||||
posMaster.isSit = false;
|
||||
|
|
@ -7384,12 +7405,10 @@ export class OrganizationController extends Controller {
|
|||
await this.employeePosMasterRepository.save(posMaster);
|
||||
await CreatePosMasterHistoryEmployee(posMaster.id, null);
|
||||
}),
|
||||
]);
|
||||
);
|
||||
|
||||
return new HttpSuccess({
|
||||
totalOfficer: posMasters.length,
|
||||
totalEmployee: posMastersEmployee.length,
|
||||
officerSuccessAmount: checkOfficer,
|
||||
employeeSuccessAmount: checkEmployee,
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue