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}")
|
@Get("delete/profile-officer/org/{orgRevisionId}")
|
||||||
async deleteRetireInOrg(@Path() orgRevisionId: string, @Request() request: RequestWithUser) {
|
async deleteOfficerRetireInOrg(
|
||||||
const [posMasters, posMastersEmployee] = await Promise.all([
|
@Path() orgRevisionId: string,
|
||||||
this.posMasterRepository.find({
|
@Request() request: RequestWithUser,
|
||||||
where: {
|
) {
|
||||||
orgRevisionId,
|
const posMasters = await this.posMasterRepository.find({
|
||||||
current_holder: {
|
where: {
|
||||||
isLeave: true,
|
orgRevisionId,
|
||||||
isRetirement: true,
|
current_holderId: Not(IsNull()),
|
||||||
leaveType: IsNull(),
|
current_holder: {
|
||||||
},
|
isLeave: true,
|
||||||
positions: { positionIsSelected: true },
|
isRetirement: true,
|
||||||
},
|
},
|
||||||
relations: ["positions"],
|
// positions: { positionIsSelected: true },
|
||||||
}),
|
},
|
||||||
this.employeePosMasterRepository.find({
|
relations: ["positions"],
|
||||||
where: {
|
});
|
||||||
orgRevisionId,
|
|
||||||
current_holder: {
|
|
||||||
isLeave: true,
|
|
||||||
isRetirement: true,
|
|
||||||
leaveType: IsNull(),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
relations: ["positions"],
|
|
||||||
}),
|
|
||||||
]);
|
|
||||||
|
|
||||||
let checkOfficer = 0;
|
let checkOfficer = 0;
|
||||||
let checkEmployee = 0;
|
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
posMasters.map(async (posMaster) => {
|
posMasters.map(async (posMaster) => {
|
||||||
|
|
@ -7371,6 +7360,38 @@ export class OrganizationController extends Controller {
|
||||||
await this.posMasterRepository.save(posMaster);
|
await this.posMasterRepository.save(posMaster);
|
||||||
await CreatePosMasterHistoryOfficer(posMaster.id, null);
|
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) => {
|
posMastersEmployee.map(async (posMaster) => {
|
||||||
posMaster.current_holderId = null;
|
posMaster.current_holderId = null;
|
||||||
posMaster.isSit = false;
|
posMaster.isSit = false;
|
||||||
|
|
@ -7384,12 +7405,10 @@ export class OrganizationController extends Controller {
|
||||||
await this.employeePosMasterRepository.save(posMaster);
|
await this.employeePosMasterRepository.save(posMaster);
|
||||||
await CreatePosMasterHistoryEmployee(posMaster.id, null);
|
await CreatePosMasterHistoryEmployee(posMaster.id, null);
|
||||||
}),
|
}),
|
||||||
]);
|
);
|
||||||
|
|
||||||
return new HttpSuccess({
|
return new HttpSuccess({
|
||||||
totalOfficer: posMasters.length,
|
|
||||||
totalEmployee: posMastersEmployee.length,
|
totalEmployee: posMastersEmployee.length,
|
||||||
officerSuccessAmount: checkOfficer,
|
|
||||||
employeeSuccessAmount: checkEmployee,
|
employeeSuccessAmount: checkEmployee,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue