no message
This commit is contained in:
parent
9bbbc4b14c
commit
4f8bc677a0
1 changed files with 345 additions and 169 deletions
|
|
@ -54,6 +54,7 @@ import { ProfileFamilyFather } from "../entities/ProfileFamilyFather";
|
||||||
import CallAPI from "../interfaces/call-api";
|
import CallAPI from "../interfaces/call-api";
|
||||||
import Extension from "../interfaces/extension";
|
import Extension from "../interfaces/extension";
|
||||||
import { Prefixe } from "../entities/Prefixe";
|
import { Prefixe } from "../entities/Prefixe";
|
||||||
|
import { ProfileInsignia } from "../entities/ProfileInsignia";
|
||||||
|
|
||||||
@Route("api/v1/org/profile")
|
@Route("api/v1/org/profile")
|
||||||
@Tags("Profile")
|
@Tags("Profile")
|
||||||
|
|
@ -88,6 +89,8 @@ export class ProfileController extends Controller {
|
||||||
private provinceRepo = AppDataSource.getRepository(Province);
|
private provinceRepo = AppDataSource.getRepository(Province);
|
||||||
private districtRepo = AppDataSource.getRepository(District);
|
private districtRepo = AppDataSource.getRepository(District);
|
||||||
private subDistrictRepo = AppDataSource.getRepository(SubDistrict);
|
private subDistrictRepo = AppDataSource.getRepository(SubDistrict);
|
||||||
|
private profileInsigniaRepo = AppDataSource.getRepository(ProfileInsignia);
|
||||||
|
private profileDisciplineRepo = AppDataSource.getRepository(ProfileDiscipline);
|
||||||
/**
|
/**
|
||||||
* report ประวัติแบบย่อ ข้าราชการ
|
* report ประวัติแบบย่อ ข้าราชการ
|
||||||
*
|
*
|
||||||
|
|
@ -196,11 +199,7 @@ export class ProfileController extends Controller {
|
||||||
profile.profileSalary.length > 0 && profile.profileSalary[0].amount != null
|
profile.profileSalary.length > 0 && profile.profileSalary[0].amount != null
|
||||||
? Extension.ToThaiNumber(profile.profileSalary[0].amount.toLocaleString())
|
? Extension.ToThaiNumber(profile.profileSalary[0].amount.toLocaleString())
|
||||||
: "",
|
: "",
|
||||||
Education:
|
Education: profile.profileEducations,
|
||||||
profile.profileEducations.length > 0 &&
|
|
||||||
profile.profileEducations[profile.profileEducations.length - 1].institute != null
|
|
||||||
? profile.profileEducations[profile.profileEducations.length - 1].institute
|
|
||||||
: "",
|
|
||||||
AppointText:
|
AppointText:
|
||||||
profile.dateAppoint != null
|
profile.dateAppoint != null
|
||||||
? Extension.ToThaiNumber(Extension.ToThaiShortDate_monthYear(profile.dateAppoint))
|
? Extension.ToThaiNumber(Extension.ToThaiShortDate_monthYear(profile.dateAppoint))
|
||||||
|
|
@ -474,6 +473,7 @@ export class ProfileController extends Controller {
|
||||||
Rank: item.positionLevel ?? null,
|
Rank: item.positionLevel ?? null,
|
||||||
RefAll: item.templateDoc ? Extension.ToThaiNumber(item.templateDoc) : null,
|
RefAll: item.templateDoc ? Extension.ToThaiNumber(item.templateDoc) : null,
|
||||||
PositionLevel: item.positionLevel ?? null,
|
PositionLevel: item.positionLevel ?? null,
|
||||||
|
PositionType: item.positionType ?? null,
|
||||||
PositionAmount:
|
PositionAmount:
|
||||||
item.positionSalaryAmount == null
|
item.positionSalaryAmount == null
|
||||||
? null
|
? null
|
||||||
|
|
@ -496,79 +496,7 @@ export class ProfileController extends Controller {
|
||||||
* @param {string} id Id ทะเบียนประวัติ
|
* @param {string} id Id ทะเบียนประวัติ
|
||||||
*/
|
*/
|
||||||
@Get("placement/{id}")
|
@Get("placement/{id}")
|
||||||
async getProfilePlacement(@Path() id: string) {
|
async getProfilePlacement(@Request() request: RequestWithUser, @Path() id: string) {
|
||||||
const profile = await this.profileRepo.findOne({
|
|
||||||
where: { id },
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
|
||||||
|
|
||||||
const _caregiver = await this.profileRepo
|
|
||||||
.createQueryBuilder("profile")
|
|
||||||
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
|
||||||
.leftJoinAndSelect("profile.posType", "posType")
|
|
||||||
.andWhere({ keycloak: Not(IsNull()) })
|
|
||||||
.skip((1 - 1) * 20)
|
|
||||||
.take(20)
|
|
||||||
.getMany();
|
|
||||||
const _commander = await this.profileRepo
|
|
||||||
.createQueryBuilder("profile")
|
|
||||||
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
|
||||||
.leftJoinAndSelect("profile.posType", "posType")
|
|
||||||
.andWhere({ keycloak: Not(IsNull()) })
|
|
||||||
.skip((1 - 1) * 20)
|
|
||||||
.take(20)
|
|
||||||
.getMany();
|
|
||||||
const _chairman = await this.profileRepo
|
|
||||||
.createQueryBuilder("profile")
|
|
||||||
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
|
||||||
.leftJoinAndSelect("profile.posType", "posType")
|
|
||||||
.andWhere({ keycloak: Not(IsNull()) })
|
|
||||||
.skip((1 - 1) * 20)
|
|
||||||
.take(20)
|
|
||||||
.getMany();
|
|
||||||
|
|
||||||
const caregiver = _caregiver.map((_data) => ({
|
|
||||||
id: _data.id,
|
|
||||||
prefix: _data.prefix,
|
|
||||||
firstName: _data.firstName,
|
|
||||||
lastName: _data.lastName,
|
|
||||||
citizenId: _data.citizenId,
|
|
||||||
position: _data.position,
|
|
||||||
posLevel: _data.posLevel == null ? null : _data.posLevel.posLevelName,
|
|
||||||
posType: _data.posType == null ? null : _data.posType.posTypeName,
|
|
||||||
isDirector: true,
|
|
||||||
}));
|
|
||||||
const commander = _commander.map((_data) => ({
|
|
||||||
id: _data.id,
|
|
||||||
prefix: _data.prefix,
|
|
||||||
firstName: _data.firstName,
|
|
||||||
lastName: _data.lastName,
|
|
||||||
citizenId: _data.citizenId,
|
|
||||||
position: _data.position,
|
|
||||||
posLevel: _data.posLevel == null ? null : _data.posLevel.posLevelName,
|
|
||||||
posType: _data.posType == null ? null : _data.posType.posTypeName,
|
|
||||||
isDirector: true,
|
|
||||||
}));
|
|
||||||
const chairman = _chairman.map((_data) => ({
|
|
||||||
id: _data.id,
|
|
||||||
prefix: _data.prefix,
|
|
||||||
firstName: _data.firstName,
|
|
||||||
lastName: _data.lastName,
|
|
||||||
citizenId: _data.citizenId,
|
|
||||||
position: _data.position,
|
|
||||||
posLevel: _data.posLevel == null ? null : _data.posLevel.posLevelName,
|
|
||||||
posType: _data.posType == null ? null : _data.posType.posTypeName,
|
|
||||||
isDirector: true,
|
|
||||||
}));
|
|
||||||
return new HttpSuccess({ caregiver, commander, chairman });
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Get("commander")
|
|
||||||
async getProfileCommander(@Request() request: RequestWithUser) {
|
|
||||||
const profile = await this.profileRepo.findOne({
|
const profile = await this.profileRepo.findOne({
|
||||||
where: { keycloak: request.user.sub },
|
where: { keycloak: request.user.sub },
|
||||||
});
|
});
|
||||||
|
|
@ -582,65 +510,75 @@ export class ProfileController extends Controller {
|
||||||
const orgChild2 = posMaster.orgChild2Id;
|
const orgChild2 = posMaster.orgChild2Id;
|
||||||
const orgChild3 = posMaster.orgChild3Id;
|
const orgChild3 = posMaster.orgChild3Id;
|
||||||
const orgChild4 = posMaster.orgChild4Id;
|
const orgChild4 = posMaster.orgChild4Id;
|
||||||
|
|
||||||
const findChild4 = await this.profileRepo
|
const findChild4 = await this.profileRepo
|
||||||
.createQueryBuilder("profile")
|
.createQueryBuilder("profile")
|
||||||
.leftJoinAndSelect("profile.current_holders", "current_holders")
|
.leftJoinAndSelect("profile.current_holders", "current_holders")
|
||||||
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
||||||
.leftJoinAndSelect("profile.posType", "posType")
|
.leftJoinAndSelect("profile.posType", "posType")
|
||||||
.andWhere({ keycloak: Not(IsNull()) })
|
.andWhere({ keycloak: Not(IsNull()) })
|
||||||
.where("current_holders.current_holderId IS NOT NULL")
|
.where("current_holders.current_holderId IS NOT NULL")
|
||||||
.andWhere("current_holders.orgRootId = :orgRootId", { orgRootId: orgRoot })
|
.andWhere("current_holders.orgRootId = :orgRootId", { orgRootId: orgRoot })
|
||||||
.andWhere("current_holders.current_holderId <> :current_holderId", { current_holderId: posMaster.current_holderId })
|
.andWhere("current_holders.current_holderId <> :current_holderId", {
|
||||||
.getMany();
|
current_holderId: posMaster.current_holderId,
|
||||||
const findChild3 = await this.profileRepo
|
})
|
||||||
.createQueryBuilder("profile")
|
.getMany();
|
||||||
.leftJoinAndSelect("profile.current_holders", "current_holders")
|
const findChild3 = await this.profileRepo
|
||||||
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
.createQueryBuilder("profile")
|
||||||
.leftJoinAndSelect("profile.posType", "posType")
|
.leftJoinAndSelect("profile.current_holders", "current_holders")
|
||||||
.andWhere({ keycloak: Not(IsNull()) })
|
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
||||||
.where("current_holders.current_holderId IS NOT NULL")
|
.leftJoinAndSelect("profile.posType", "posType")
|
||||||
.andWhere("current_holders.orgRootId = :orgRootId", { orgRootId: orgRoot })
|
.andWhere({ keycloak: Not(IsNull()) })
|
||||||
.andWhere("current_holders.current_holderId <> :current_holderId", { current_holderId: posMaster.current_holderId })
|
.where("current_holders.current_holderId IS NOT NULL")
|
||||||
.andWhere("current_holders.orgChild3Id = :orgChild3Id", { orgChild3Id: orgChild3 })
|
.andWhere("current_holders.orgRootId = :orgRootId", { orgRootId: orgRoot })
|
||||||
.andWhere("current_holders.orgChild4Id IS NULL")
|
.andWhere("current_holders.current_holderId <> :current_holderId", {
|
||||||
.getMany();
|
current_holderId: posMaster.current_holderId,
|
||||||
const findChild2 = await this.profileRepo
|
})
|
||||||
.createQueryBuilder("profile")
|
.andWhere("current_holders.orgChild3Id = :orgChild3Id", { orgChild3Id: orgChild3 })
|
||||||
.leftJoinAndSelect("profile.current_holders", "current_holders")
|
.andWhere("current_holders.orgChild4Id IS NULL")
|
||||||
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
.getMany();
|
||||||
.leftJoinAndSelect("profile.posType", "posType")
|
const findChild2 = await this.profileRepo
|
||||||
.andWhere({ keycloak: Not(IsNull()) })
|
.createQueryBuilder("profile")
|
||||||
.where("current_holders.current_holderId IS NOT NULL")
|
.leftJoinAndSelect("profile.current_holders", "current_holders")
|
||||||
.andWhere("current_holders.orgRootId = :orgRootId", { orgRootId: orgRoot })
|
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
||||||
.andWhere("current_holders.current_holderId <> :current_holderId", { current_holderId: posMaster.current_holderId })
|
.leftJoinAndSelect("profile.posType", "posType")
|
||||||
.andWhere("current_holders.orgChild2Id = :orgChild2Id", { orgChild2Id: orgChild2 })
|
.andWhere({ keycloak: Not(IsNull()) })
|
||||||
.andWhere("current_holders.orgChild3Id IS NULL")
|
.where("current_holders.current_holderId IS NOT NULL")
|
||||||
.getMany();
|
.andWhere("current_holders.orgRootId = :orgRootId", { orgRootId: orgRoot })
|
||||||
const findChild1 = await this.profileRepo
|
.andWhere("current_holders.current_holderId <> :current_holderId", {
|
||||||
.createQueryBuilder("profile")
|
current_holderId: posMaster.current_holderId,
|
||||||
.leftJoinAndSelect("profile.current_holders", "current_holders")
|
})
|
||||||
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
.andWhere("current_holders.orgChild2Id = :orgChild2Id", { orgChild2Id: orgChild2 })
|
||||||
.leftJoinAndSelect("profile.posType", "posType")
|
.andWhere("current_holders.orgChild3Id IS NULL")
|
||||||
.andWhere({ keycloak: Not(IsNull()) })
|
.getMany();
|
||||||
.where("current_holders.current_holderId IS NOT NULL")
|
const findChild1 = await this.profileRepo
|
||||||
.andWhere("current_holders.orgRootId = :orgRootId", { orgRootId: orgRoot })
|
.createQueryBuilder("profile")
|
||||||
.andWhere("current_holders.current_holderId <> :current_holderId", { current_holderId: posMaster.current_holderId })
|
.leftJoinAndSelect("profile.current_holders", "current_holders")
|
||||||
.andWhere("current_holders.orgChild1Id = :orgChild1Id", { orgChild1Id: orgChild1 })
|
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
||||||
.andWhere("current_holders.orgChild2Id IS NULL")
|
.leftJoinAndSelect("profile.posType", "posType")
|
||||||
.getMany();
|
.andWhere({ keycloak: Not(IsNull()) })
|
||||||
const findRoot = await this.profileRepo
|
.where("current_holders.current_holderId IS NOT NULL")
|
||||||
.createQueryBuilder("profile")
|
.andWhere("current_holders.orgRootId = :orgRootId", { orgRootId: orgRoot })
|
||||||
.leftJoinAndSelect("profile.current_holders", "current_holders")
|
.andWhere("current_holders.current_holderId <> :current_holderId", {
|
||||||
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
current_holderId: posMaster.current_holderId,
|
||||||
.leftJoinAndSelect("profile.posType", "posType")
|
})
|
||||||
.andWhere({ keycloak: Not(IsNull()) })
|
.andWhere("current_holders.orgChild1Id = :orgChild1Id", { orgChild1Id: orgChild1 })
|
||||||
.where("current_holders.current_holderId IS NOT NULL")
|
.andWhere("current_holders.orgChild2Id IS NULL")
|
||||||
.andWhere("current_holders.orgRootId = :orgRootId", { orgRootId: orgRoot })
|
.getMany();
|
||||||
.andWhere("current_holders.current_holderId <> :current_holderId", { current_holderId: posMaster.current_holderId })
|
const findRoot = await this.profileRepo
|
||||||
.andWhere("current_holders.orgChild1Id IS NULL")
|
.createQueryBuilder("profile")
|
||||||
.getMany();
|
.leftJoinAndSelect("profile.current_holders", "current_holders")
|
||||||
|
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
||||||
|
.leftJoinAndSelect("profile.posType", "posType")
|
||||||
|
.andWhere({ keycloak: Not(IsNull()) })
|
||||||
|
.where("current_holders.current_holderId IS NOT NULL")
|
||||||
|
.andWhere("current_holders.orgRootId = :orgRootId", { orgRootId: orgRoot })
|
||||||
|
.andWhere("current_holders.current_holderId <> :current_holderId", {
|
||||||
|
current_holderId: posMaster.current_holderId,
|
||||||
|
})
|
||||||
|
.andWhere("current_holders.orgChild1Id IS NULL")
|
||||||
|
.getMany();
|
||||||
|
|
||||||
let _caregiver: any;
|
let _caregiver: any;
|
||||||
let caregiver: any;
|
let caregiver: any;
|
||||||
let _commander: any;
|
let _commander: any;
|
||||||
|
|
@ -712,48 +650,251 @@ export class ProfileController extends Controller {
|
||||||
_commander = findRoot;
|
_commander = findRoot;
|
||||||
_chairman = findRoot;
|
_chairman = findRoot;
|
||||||
}
|
}
|
||||||
} else if (orgRoot) {
|
} else if (orgRoot) {
|
||||||
if (findRoot) {
|
if (findRoot) {
|
||||||
_caregiver = findRoot;
|
_caregiver = findRoot;
|
||||||
_commander = findRoot;
|
_commander = findRoot;
|
||||||
_chairman = findRoot;
|
_chairman = findRoot;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
caregiver = _caregiver.map((_data:any) => ({
|
caregiver = _caregiver.map((_data: any) => ({
|
||||||
id: _data.id,
|
id: _data.id,
|
||||||
prefix: _data.prefix,
|
prefix: _data.prefix,
|
||||||
firstName: _data.firstName,
|
firstName: _data.firstName,
|
||||||
lastName: _data.lastName,
|
lastName: _data.lastName,
|
||||||
citizenId: _data.citizenId,
|
citizenId: _data.citizenId,
|
||||||
position: _data.position,
|
position: _data.position,
|
||||||
posLevel: _data.posLevel == null ? null : _data.posLevel.posLevelName,
|
posLevel: _data.posLevel == null ? null : _data.posLevel.posLevelName,
|
||||||
posType: _data.posType == null ? null : _data.posType.posTypeName,
|
posType: _data.posType == null ? null : _data.posType.posTypeName,
|
||||||
isDirector: true,
|
isDirector: true,
|
||||||
}));
|
}));
|
||||||
commander = _commander.map((_data:any) => ({
|
commander = _commander.map((_data: any) => ({
|
||||||
id: _data.id,
|
id: _data.id,
|
||||||
prefix: _data.prefix,
|
prefix: _data.prefix,
|
||||||
firstName: _data.firstName,
|
firstName: _data.firstName,
|
||||||
lastName: _data.lastName,
|
lastName: _data.lastName,
|
||||||
citizenId: _data.citizenId,
|
citizenId: _data.citizenId,
|
||||||
position: _data.position,
|
position: _data.position,
|
||||||
posLevel: _data.posLevel == null ? null : _data.posLevel.posLevelName,
|
posLevel: _data.posLevel == null ? null : _data.posLevel.posLevelName,
|
||||||
posType: _data.posType == null ? null : _data.posType.posTypeName,
|
posType: _data.posType == null ? null : _data.posType.posTypeName,
|
||||||
isDirector: true,
|
isDirector: true,
|
||||||
}));
|
}));
|
||||||
chairman = _chairman.map((_data:any) => ({
|
chairman = _chairman.map((_data: any) => ({
|
||||||
id: _data.id,
|
id: _data.id,
|
||||||
prefix: _data.prefix,
|
prefix: _data.prefix,
|
||||||
firstName: _data.firstName,
|
firstName: _data.firstName,
|
||||||
lastName: _data.lastName,
|
lastName: _data.lastName,
|
||||||
citizenId: _data.citizenId,
|
citizenId: _data.citizenId,
|
||||||
position: _data.position,
|
position: _data.position,
|
||||||
posLevel: _data.posLevel == null ? null : _data.posLevel.posLevelName,
|
posLevel: _data.posLevel == null ? null : _data.posLevel.posLevelName,
|
||||||
posType: _data.posType == null ? null : _data.posType.posTypeName,
|
posType: _data.posType == null ? null : _data.posType.posTypeName,
|
||||||
isDirector: true,
|
isDirector: true,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return new HttpSuccess({ caregiver, commander, chairman });
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Get("commander")
|
||||||
|
async getProfileCommander(@Request() request: RequestWithUser) {
|
||||||
|
const profile = await this.profileRepo.findOne({
|
||||||
|
where: { keycloak: request.user.sub },
|
||||||
|
});
|
||||||
|
|
||||||
|
const posMaster = await this.posMasterRepo.findOne({
|
||||||
|
where: { current_holderId: profile?.id },
|
||||||
|
});
|
||||||
|
if (!posMaster) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลการครองตำแหน่ง");
|
||||||
|
const orgRoot = posMaster.orgRootId;
|
||||||
|
const orgChild1 = posMaster.orgChild1Id;
|
||||||
|
const orgChild2 = posMaster.orgChild2Id;
|
||||||
|
const orgChild3 = posMaster.orgChild3Id;
|
||||||
|
const orgChild4 = posMaster.orgChild4Id;
|
||||||
|
|
||||||
|
const findChild4 = await this.profileRepo
|
||||||
|
.createQueryBuilder("profile")
|
||||||
|
.leftJoinAndSelect("profile.current_holders", "current_holders")
|
||||||
|
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
||||||
|
.leftJoinAndSelect("profile.posType", "posType")
|
||||||
|
.andWhere({ keycloak: Not(IsNull()) })
|
||||||
|
.where("current_holders.current_holderId IS NOT NULL")
|
||||||
|
.andWhere("current_holders.orgRootId = :orgRootId", { orgRootId: orgRoot })
|
||||||
|
.andWhere("current_holders.current_holderId <> :current_holderId", {
|
||||||
|
current_holderId: posMaster.current_holderId,
|
||||||
|
})
|
||||||
|
.getMany();
|
||||||
|
const findChild3 = await this.profileRepo
|
||||||
|
.createQueryBuilder("profile")
|
||||||
|
.leftJoinAndSelect("profile.current_holders", "current_holders")
|
||||||
|
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
||||||
|
.leftJoinAndSelect("profile.posType", "posType")
|
||||||
|
.andWhere({ keycloak: Not(IsNull()) })
|
||||||
|
.where("current_holders.current_holderId IS NOT NULL")
|
||||||
|
.andWhere("current_holders.orgRootId = :orgRootId", { orgRootId: orgRoot })
|
||||||
|
.andWhere("current_holders.current_holderId <> :current_holderId", {
|
||||||
|
current_holderId: posMaster.current_holderId,
|
||||||
|
})
|
||||||
|
.andWhere("current_holders.orgChild3Id = :orgChild3Id", { orgChild3Id: orgChild3 })
|
||||||
|
.andWhere("current_holders.orgChild4Id IS NULL")
|
||||||
|
.getMany();
|
||||||
|
const findChild2 = await this.profileRepo
|
||||||
|
.createQueryBuilder("profile")
|
||||||
|
.leftJoinAndSelect("profile.current_holders", "current_holders")
|
||||||
|
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
||||||
|
.leftJoinAndSelect("profile.posType", "posType")
|
||||||
|
.andWhere({ keycloak: Not(IsNull()) })
|
||||||
|
.where("current_holders.current_holderId IS NOT NULL")
|
||||||
|
.andWhere("current_holders.orgRootId = :orgRootId", { orgRootId: orgRoot })
|
||||||
|
.andWhere("current_holders.current_holderId <> :current_holderId", {
|
||||||
|
current_holderId: posMaster.current_holderId,
|
||||||
|
})
|
||||||
|
.andWhere("current_holders.orgChild2Id = :orgChild2Id", { orgChild2Id: orgChild2 })
|
||||||
|
.andWhere("current_holders.orgChild3Id IS NULL")
|
||||||
|
.getMany();
|
||||||
|
const findChild1 = await this.profileRepo
|
||||||
|
.createQueryBuilder("profile")
|
||||||
|
.leftJoinAndSelect("profile.current_holders", "current_holders")
|
||||||
|
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
||||||
|
.leftJoinAndSelect("profile.posType", "posType")
|
||||||
|
.andWhere({ keycloak: Not(IsNull()) })
|
||||||
|
.where("current_holders.current_holderId IS NOT NULL")
|
||||||
|
.andWhere("current_holders.orgRootId = :orgRootId", { orgRootId: orgRoot })
|
||||||
|
.andWhere("current_holders.current_holderId <> :current_holderId", {
|
||||||
|
current_holderId: posMaster.current_holderId,
|
||||||
|
})
|
||||||
|
.andWhere("current_holders.orgChild1Id = :orgChild1Id", { orgChild1Id: orgChild1 })
|
||||||
|
.andWhere("current_holders.orgChild2Id IS NULL")
|
||||||
|
.getMany();
|
||||||
|
const findRoot = await this.profileRepo
|
||||||
|
.createQueryBuilder("profile")
|
||||||
|
.leftJoinAndSelect("profile.current_holders", "current_holders")
|
||||||
|
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
||||||
|
.leftJoinAndSelect("profile.posType", "posType")
|
||||||
|
.andWhere({ keycloak: Not(IsNull()) })
|
||||||
|
.where("current_holders.current_holderId IS NOT NULL")
|
||||||
|
.andWhere("current_holders.orgRootId = :orgRootId", { orgRootId: orgRoot })
|
||||||
|
.andWhere("current_holders.current_holderId <> :current_holderId", {
|
||||||
|
current_holderId: posMaster.current_holderId,
|
||||||
|
})
|
||||||
|
.andWhere("current_holders.orgChild1Id IS NULL")
|
||||||
|
.getMany();
|
||||||
|
|
||||||
|
let _caregiver: any;
|
||||||
|
let caregiver: any;
|
||||||
|
let _commander: any;
|
||||||
|
let commander: any;
|
||||||
|
let _chairman: any;
|
||||||
|
let chairman: any;
|
||||||
|
if (posMaster) {
|
||||||
|
if (orgChild4) {
|
||||||
|
if (findChild4) {
|
||||||
|
_caregiver = findChild4;
|
||||||
|
_commander = findChild3;
|
||||||
|
_chairman = findChild2;
|
||||||
|
} else if (findChild3) {
|
||||||
|
_caregiver = findChild3;
|
||||||
|
_commander = findChild2;
|
||||||
|
_chairman = findChild1;
|
||||||
|
} else if (findChild2) {
|
||||||
|
_caregiver = findChild2;
|
||||||
|
_commander = findChild1;
|
||||||
|
_chairman = findRoot;
|
||||||
|
} else if (findChild1) {
|
||||||
|
_caregiver = findChild1;
|
||||||
|
_commander = findRoot;
|
||||||
|
_chairman = findRoot;
|
||||||
|
} else if (findRoot) {
|
||||||
|
_caregiver = findRoot;
|
||||||
|
_commander = findRoot;
|
||||||
|
_chairman = findRoot;
|
||||||
|
}
|
||||||
|
} else if (orgChild3) {
|
||||||
|
if (findChild3) {
|
||||||
|
_caregiver = findChild3;
|
||||||
|
_commander = findChild2;
|
||||||
|
_chairman = findChild1;
|
||||||
|
} else if (findChild2) {
|
||||||
|
_caregiver = findChild2;
|
||||||
|
_commander = findChild1;
|
||||||
|
_chairman = findRoot;
|
||||||
|
} else if (findChild1) {
|
||||||
|
_caregiver = findChild1;
|
||||||
|
_commander = findRoot;
|
||||||
|
_chairman = findRoot;
|
||||||
|
} else if (findRoot) {
|
||||||
|
_caregiver = findRoot;
|
||||||
|
_commander = findRoot;
|
||||||
|
_chairman = findRoot;
|
||||||
|
}
|
||||||
|
} else if (orgChild2) {
|
||||||
|
if (findChild2) {
|
||||||
|
_caregiver = findChild2;
|
||||||
|
_commander = findChild1;
|
||||||
|
_chairman = findRoot;
|
||||||
|
} else if (findChild1) {
|
||||||
|
_caregiver = findChild1;
|
||||||
|
_commander = findRoot;
|
||||||
|
_chairman = findRoot;
|
||||||
|
} else if (findRoot) {
|
||||||
|
_caregiver = findRoot;
|
||||||
|
_commander = findRoot;
|
||||||
|
_chairman = findRoot;
|
||||||
|
}
|
||||||
|
} else if (orgChild1) {
|
||||||
|
if (findChild1) {
|
||||||
|
_caregiver = findChild1;
|
||||||
|
_commander = findRoot;
|
||||||
|
_chairman = findRoot;
|
||||||
|
} else if (findRoot) {
|
||||||
|
_caregiver = findRoot;
|
||||||
|
_commander = findRoot;
|
||||||
|
_chairman = findRoot;
|
||||||
|
}
|
||||||
|
} else if (orgRoot) {
|
||||||
|
if (findRoot) {
|
||||||
|
_caregiver = findRoot;
|
||||||
|
_commander = findRoot;
|
||||||
|
_chairman = findRoot;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
caregiver = _caregiver.map((_data: any) => ({
|
||||||
|
id: _data.id,
|
||||||
|
prefix: _data.prefix,
|
||||||
|
firstName: _data.firstName,
|
||||||
|
lastName: _data.lastName,
|
||||||
|
citizenId: _data.citizenId,
|
||||||
|
position: _data.position,
|
||||||
|
posLevel: _data.posLevel == null ? null : _data.posLevel.posLevelName,
|
||||||
|
posType: _data.posType == null ? null : _data.posType.posTypeName,
|
||||||
|
isDirector: true,
|
||||||
|
}));
|
||||||
|
commander = _commander.map((_data: any) => ({
|
||||||
|
id: _data.id,
|
||||||
|
prefix: _data.prefix,
|
||||||
|
firstName: _data.firstName,
|
||||||
|
lastName: _data.lastName,
|
||||||
|
citizenId: _data.citizenId,
|
||||||
|
position: _data.position,
|
||||||
|
posLevel: _data.posLevel == null ? null : _data.posLevel.posLevelName,
|
||||||
|
posType: _data.posType == null ? null : _data.posType.posTypeName,
|
||||||
|
isDirector: true,
|
||||||
|
}));
|
||||||
|
chairman = _chairman.map((_data: any) => ({
|
||||||
|
id: _data.id,
|
||||||
|
prefix: _data.prefix,
|
||||||
|
firstName: _data.firstName,
|
||||||
|
lastName: _data.lastName,
|
||||||
|
citizenId: _data.citizenId,
|
||||||
|
position: _data.position,
|
||||||
|
posLevel: _data.posLevel == null ? null : _data.posLevel.posLevelName,
|
||||||
|
posType: _data.posType == null ? null : _data.posType.posTypeName,
|
||||||
|
isDirector: true,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
return new HttpSuccess({ caregiver, commander, chairman });
|
return new HttpSuccess({ caregiver, commander, chairman });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -4841,4 +4982,39 @@ export class ProfileController extends Controller {
|
||||||
await this.profileRepo.save(profiles);
|
await this.profileRepo.save(profiles);
|
||||||
return new HttpSuccess("zxczx");
|
return new HttpSuccess("zxczx");
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @summary (ADMIN)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Get("salarym/zxczxcsa")
|
||||||
|
async zxczxczxczxczxc() {
|
||||||
|
const profile = await this.profileRepo.find({ relations: ["current_holders", "next_holders"] });
|
||||||
|
const profiles = await Promise.all(
|
||||||
|
profile.map(async (_data) => {
|
||||||
|
if (_data.current_holders.length == 0 && _data.next_holders.length == 0) {
|
||||||
|
const salary = await this.salaryRepository.find({
|
||||||
|
where: {
|
||||||
|
profileId: _data.id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const insignia = await this.profileInsigniaRepo.find({
|
||||||
|
where: {
|
||||||
|
profileId: _data.id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const discipline = await this.profileDisciplineRepo.find({
|
||||||
|
where: {
|
||||||
|
profileId: _data.id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
await this.salaryRepository.remove(salary);
|
||||||
|
await this.profileInsigniaRepo.remove(insignia);
|
||||||
|
await this.profileDisciplineRepo.remove(discipline);
|
||||||
|
await this.profileRepo.remove(_data);
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
return new HttpSuccess("zxczx");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue