no message

This commit is contained in:
Kittapath 2024-02-09 22:55:42 +07:00
parent 3bfbb93691
commit bc86f4d2d9
5 changed files with 200 additions and 128 deletions

View file

@ -753,46 +753,56 @@ export class OrganizationController extends Controller {
},
}),
totalRootPosition: await this.posMasterRepository.count({
where: {
orgRevisionId: orgRoot.orgRevisionId,
where: {
orgRevisionId: orgRoot.orgRevisionId,
orgRootId: orgRoot.id,
orgChild1Id : IsNull() || "", orgChild2Id : IsNull() || "",
orgChild3Id : IsNull() || "", orgChild4Id : IsNull() || "",
orgChild1Id: IsNull() || "",
orgChild2Id: IsNull() || "",
orgChild3Id: IsNull() || "",
orgChild4Id: IsNull() || "",
},
}),
totalRootPositionCurrentUse: await this.posMasterRepository.count({
where: {
orgRevisionId: orgRoot.orgRevisionId,
where: {
orgRevisionId: orgRoot.orgRevisionId,
orgRootId: orgRoot.id,
orgChild1Id : IsNull() || "", orgChild2Id : IsNull() || "",
orgChild3Id : IsNull() || "", orgChild4Id : IsNull() || "",
orgChild1Id: IsNull() || "",
orgChild2Id: IsNull() || "",
orgChild3Id: IsNull() || "",
orgChild4Id: IsNull() || "",
current_holderId: Not(IsNull()) || Not(""),
},
}),
totalRootPositionCurrentVacant: await this.posMasterRepository.count({
where: {
orgRevisionId: orgRoot.orgRevisionId,
where: {
orgRevisionId: orgRoot.orgRevisionId,
orgRootId: orgRoot.id,
orgChild1Id : IsNull() || "", orgChild2Id : IsNull() || "",
orgChild3Id : IsNull() || "", orgChild4Id : IsNull() || "",
orgChild1Id: IsNull() || "",
orgChild2Id: IsNull() || "",
orgChild3Id: IsNull() || "",
orgChild4Id: IsNull() || "",
current_holderId: IsNull() || "",
},
}),
totalRootPositionNextUse: await this.posMasterRepository.count({
where: {
orgRevisionId: orgRoot.orgRevisionId,
where: {
orgRevisionId: orgRoot.orgRevisionId,
orgRootId: orgRoot.id,
orgChild1Id : IsNull() || "", orgChild2Id : IsNull() || "",
orgChild3Id : IsNull() || "", orgChild4Id : IsNull() || "",
orgChild1Id: IsNull() || "",
orgChild2Id: IsNull() || "",
orgChild3Id: IsNull() || "",
orgChild4Id: IsNull() || "",
next_holderId: Not(IsNull()) || Not(""),
},
}),
totalRootPositionNextVacant: await this.posMasterRepository.count({
where: {
orgRevisionId: orgRoot.orgRevisionId,
where: {
orgRevisionId: orgRoot.orgRevisionId,
orgRootId: orgRoot.id,
orgChild1Id : IsNull() || "", orgChild2Id : IsNull() || "",
orgChild3Id : IsNull() || "", orgChild4Id : IsNull() || "",
orgChild1Id: IsNull() || "",
orgChild2Id: IsNull() || "",
orgChild3Id: IsNull() || "",
orgChild4Id: IsNull() || "",
next_holderId: IsNull() || "",
},
}),
@ -849,46 +859,56 @@ export class OrganizationController extends Controller {
},
}),
totalRootPosition: await this.posMasterRepository.count({
where: {
orgRevisionId: orgRoot.orgRevisionId,
where: {
orgRevisionId: orgRoot.orgRevisionId,
orgRootId: orgRoot.id,
orgChild1Id : orgChild1.id, orgChild2Id : IsNull() || "",
orgChild3Id : IsNull() || "", orgChild4Id : IsNull() || "",
orgChild1Id: orgChild1.id,
orgChild2Id: IsNull() || "",
orgChild3Id: IsNull() || "",
orgChild4Id: IsNull() || "",
},
}),
totalRootPositionCurrentUse: await this.posMasterRepository.count({
where: {
orgRevisionId: orgRoot.orgRevisionId,
where: {
orgRevisionId: orgRoot.orgRevisionId,
orgRootId: orgRoot.id,
orgChild1Id : orgChild1.id, orgChild2Id : IsNull() || "",
orgChild3Id : IsNull() || "", orgChild4Id : IsNull() || "",
orgChild1Id: orgChild1.id,
orgChild2Id: IsNull() || "",
orgChild3Id: IsNull() || "",
orgChild4Id: IsNull() || "",
current_holderId: Not(IsNull()) || Not(""),
},
}),
totalRootPositionCurrentVacant: await this.posMasterRepository.count({
where: {
orgRevisionId: orgRoot.orgRevisionId,
where: {
orgRevisionId: orgRoot.orgRevisionId,
orgRootId: orgRoot.id,
orgChild1Id : orgChild1.id, orgChild2Id : IsNull() || "",
orgChild3Id : IsNull() || "", orgChild4Id : IsNull() || "",
orgChild1Id: orgChild1.id,
orgChild2Id: IsNull() || "",
orgChild3Id: IsNull() || "",
orgChild4Id: IsNull() || "",
current_holderId: IsNull() || "",
},
}),
totalRootPositionNextUse: await this.posMasterRepository.count({
where: {
orgRevisionId: orgRoot.orgRevisionId,
where: {
orgRevisionId: orgRoot.orgRevisionId,
orgRootId: orgRoot.id,
orgChild1Id : orgChild1.id, orgChild2Id : IsNull() || "",
orgChild3Id : IsNull() || "", orgChild4Id : IsNull() || "",
orgChild1Id: orgChild1.id,
orgChild2Id: IsNull() || "",
orgChild3Id: IsNull() || "",
orgChild4Id: IsNull() || "",
next_holderId: Not(IsNull()) || Not(""),
},
}),
totalRootPositionNextVacant: await this.posMasterRepository.count({
where: {
orgRevisionId: orgRoot.orgRevisionId,
where: {
orgRevisionId: orgRoot.orgRevisionId,
orgRootId: orgRoot.id,
orgChild1Id : orgChild1.id, orgChild2Id : IsNull() || "",
orgChild3Id : IsNull() || "", orgChild4Id : IsNull() || "",
orgChild1Id: orgChild1.id,
orgChild2Id: IsNull() || "",
orgChild3Id: IsNull() || "",
orgChild4Id: IsNull() || "",
next_holderId: IsNull() || "",
},
}),
@ -948,46 +968,56 @@ export class OrganizationController extends Controller {
},
}),
totalRootPosition: await this.posMasterRepository.count({
where: {
orgRevisionId: orgRoot.orgRevisionId,
where: {
orgRevisionId: orgRoot.orgRevisionId,
orgRootId: orgRoot.id,
orgChild1Id : orgChild1.id, orgChild2Id : orgChild2.id,
orgChild3Id : IsNull() || "", orgChild4Id : IsNull() || "",
orgChild1Id: orgChild1.id,
orgChild2Id: orgChild2.id,
orgChild3Id: IsNull() || "",
orgChild4Id: IsNull() || "",
},
}),
totalRootPositionCurrentUse: await this.posMasterRepository.count({
where: {
orgRevisionId: orgRoot.orgRevisionId,
where: {
orgRevisionId: orgRoot.orgRevisionId,
orgRootId: orgRoot.id,
orgChild1Id : orgChild1.id, orgChild2Id : orgChild2.id,
orgChild3Id : IsNull() || "", orgChild4Id : IsNull() || "",
orgChild1Id: orgChild1.id,
orgChild2Id: orgChild2.id,
orgChild3Id: IsNull() || "",
orgChild4Id: IsNull() || "",
current_holderId: Not(IsNull()) || Not(""),
},
}),
totalRootPositionCurrentVacant: await this.posMasterRepository.count({
where: {
orgRevisionId: orgRoot.orgRevisionId,
where: {
orgRevisionId: orgRoot.orgRevisionId,
orgRootId: orgRoot.id,
orgChild1Id : orgChild1.id, orgChild2Id : orgChild2.id,
orgChild3Id : IsNull() || "", orgChild4Id : IsNull() || "",
orgChild1Id: orgChild1.id,
orgChild2Id: orgChild2.id,
orgChild3Id: IsNull() || "",
orgChild4Id: IsNull() || "",
current_holderId: IsNull() || "",
},
}),
totalRootPositionNextUse: await this.posMasterRepository.count({
where: {
orgRevisionId: orgRoot.orgRevisionId,
where: {
orgRevisionId: orgRoot.orgRevisionId,
orgRootId: orgRoot.id,
orgChild1Id : orgChild1.id, orgChild2Id : orgChild2.id,
orgChild3Id : IsNull() || "", orgChild4Id : IsNull() || "",
orgChild1Id: orgChild1.id,
orgChild2Id: orgChild2.id,
orgChild3Id: IsNull() || "",
orgChild4Id: IsNull() || "",
next_holderId: Not(IsNull()) || Not(""),
},
}),
totalRootPositionNextVacant: await this.posMasterRepository.count({
where: {
orgRevisionId: orgRoot.orgRevisionId,
where: {
orgRevisionId: orgRoot.orgRevisionId,
orgRootId: orgRoot.id,
orgChild1Id : orgChild1.id, orgChild2Id : orgChild2.id,
orgChild3Id : IsNull() || "", orgChild4Id : IsNull() || "",
orgChild1Id: orgChild1.id,
orgChild2Id: orgChild2.id,
orgChild3Id: IsNull() || "",
orgChild4Id: IsNull() || "",
next_holderId: IsNull() || "",
},
}),
@ -1047,46 +1077,56 @@ export class OrganizationController extends Controller {
},
}),
totalRootPosition: await this.posMasterRepository.count({
where: {
orgRevisionId: orgRoot.orgRevisionId,
where: {
orgRevisionId: orgRoot.orgRevisionId,
orgRootId: orgRoot.id,
orgChild1Id : orgChild1.id, orgChild2Id : orgChild2.id,
orgChild3Id : orgChild3.id, orgChild4Id : IsNull() || "",
orgChild1Id: orgChild1.id,
orgChild2Id: orgChild2.id,
orgChild3Id: orgChild3.id,
orgChild4Id: IsNull() || "",
},
}),
totalRootPositionCurrentUse: await this.posMasterRepository.count({
where: {
orgRevisionId: orgRoot.orgRevisionId,
where: {
orgRevisionId: orgRoot.orgRevisionId,
orgRootId: orgRoot.id,
orgChild1Id : orgChild1.id, orgChild2Id : orgChild2.id,
orgChild3Id : orgChild3.id, orgChild4Id : IsNull() || "",
orgChild1Id: orgChild1.id,
orgChild2Id: orgChild2.id,
orgChild3Id: orgChild3.id,
orgChild4Id: IsNull() || "",
current_holderId: Not(IsNull()) || Not(""),
},
}),
totalRootPositionCurrentVacant: await this.posMasterRepository.count({
where: {
orgRevisionId: orgRoot.orgRevisionId,
where: {
orgRevisionId: orgRoot.orgRevisionId,
orgRootId: orgRoot.id,
orgChild1Id : orgChild1.id, orgChild2Id : orgChild2.id,
orgChild3Id : orgChild3.id, orgChild4Id : IsNull() || "",
orgChild1Id: orgChild1.id,
orgChild2Id: orgChild2.id,
orgChild3Id: orgChild3.id,
orgChild4Id: IsNull() || "",
current_holderId: IsNull() || "",
},
}),
totalRootPositionNextUse: await this.posMasterRepository.count({
where: {
orgRevisionId: orgRoot.orgRevisionId,
where: {
orgRevisionId: orgRoot.orgRevisionId,
orgRootId: orgRoot.id,
orgChild1Id : orgChild1.id, orgChild2Id : orgChild2.id,
orgChild3Id : orgChild3.id, orgChild4Id : IsNull() || "",
orgChild1Id: orgChild1.id,
orgChild2Id: orgChild2.id,
orgChild3Id: orgChild3.id,
orgChild4Id: IsNull() || "",
next_holderId: Not(IsNull()) || Not(""),
},
}),
totalRootPositionNextVacant: await this.posMasterRepository.count({
where: {
orgRevisionId: orgRoot.orgRevisionId,
where: {
orgRevisionId: orgRoot.orgRevisionId,
orgRootId: orgRoot.id,
orgChild1Id : orgChild1.id, orgChild2Id : orgChild2.id,
orgChild3Id : orgChild3.id, orgChild4Id : IsNull() || "",
orgChild1Id: orgChild1.id,
orgChild2Id: orgChild2.id,
orgChild3Id: orgChild3.id,
orgChild4Id: IsNull() || "",
next_holderId: IsNull() || "",
},
}),
@ -1147,49 +1187,62 @@ export class OrganizationController extends Controller {
},
}),
totalRootPosition: await this.posMasterRepository.count({
where: {
orgRevisionId: orgRoot.orgRevisionId,
where: {
orgRevisionId: orgRoot.orgRevisionId,
orgRootId: orgRoot.id,
orgChild1Id : orgChild1.id, orgChild2Id : orgChild2.id,
orgChild3Id : orgChild3.id, orgChild4Id : orgChild4.id,
},
}),
totalRootPositionCurrentUse: await this.posMasterRepository.count({
where: {
orgRevisionId: orgRoot.orgRevisionId,
orgRootId: orgRoot.id,
orgChild1Id : orgChild1.id, orgChild2Id : orgChild2.id,
orgChild3Id : orgChild3.id, orgChild4Id : orgChild4.id,
current_holderId: Not(IsNull()) || Not(""),
},
}),
totalRootPositionCurrentVacant: await this.posMasterRepository.count({
where: {
orgRevisionId: orgRoot.orgRevisionId,
orgRootId: orgRoot.id,
orgChild1Id : orgChild1.id, orgChild2Id : orgChild2.id,
orgChild3Id : orgChild3.id, orgChild4Id : orgChild4.id,
current_holderId: IsNull() || "",
orgChild1Id: orgChild1.id,
orgChild2Id: orgChild2.id,
orgChild3Id: orgChild3.id,
orgChild4Id: orgChild4.id,
},
}),
totalRootPositionCurrentUse:
await this.posMasterRepository.count({
where: {
orgRevisionId: orgRoot.orgRevisionId,
orgRootId: orgRoot.id,
orgChild1Id: orgChild1.id,
orgChild2Id: orgChild2.id,
orgChild3Id: orgChild3.id,
orgChild4Id: orgChild4.id,
current_holderId: Not(IsNull()) || Not(""),
},
}),
totalRootPositionCurrentVacant:
await this.posMasterRepository.count({
where: {
orgRevisionId: orgRoot.orgRevisionId,
orgRootId: orgRoot.id,
orgChild1Id: orgChild1.id,
orgChild2Id: orgChild2.id,
orgChild3Id: orgChild3.id,
orgChild4Id: orgChild4.id,
current_holderId: IsNull() || "",
},
}),
totalRootPositionNextUse: await this.posMasterRepository.count({
where: {
orgRevisionId: orgRoot.orgRevisionId,
where: {
orgRevisionId: orgRoot.orgRevisionId,
orgRootId: orgRoot.id,
orgChild1Id : orgChild1.id, orgChild2Id : orgChild2.id,
orgChild3Id : orgChild3.id, orgChild4Id : orgChild4.id,
orgChild1Id: orgChild1.id,
orgChild2Id: orgChild2.id,
orgChild3Id: orgChild3.id,
orgChild4Id: orgChild4.id,
next_holderId: Not(IsNull()) || Not(""),
},
}),
totalRootPositionNextVacant: await this.posMasterRepository.count({
where: {
orgRevisionId: orgRoot.orgRevisionId,
orgRootId: orgRoot.id,
orgChild1Id : orgChild1.id, orgChild2Id : orgChild2.id,
orgChild3Id : orgChild3.id, orgChild4Id : orgChild4.id,
next_holderId: IsNull() || "",
},
}),
totalRootPositionNextVacant:
await this.posMasterRepository.count({
where: {
orgRevisionId: orgRoot.orgRevisionId,
orgRootId: orgRoot.id,
orgChild1Id: orgChild1.id,
orgChild2Id: orgChild2.id,
orgChild3Id: orgChild3.id,
orgChild4Id: orgChild4.id,
next_holderId: IsNull() || "",
},
}),
})),
),
})),
@ -1541,15 +1594,24 @@ export class OrganizationController extends Controller {
orgRevisionDraft.orgRevisionIsCurrent = true;
orgRevisionDraft.orgRevisionIsDraft = false;
await this.orgRevisionRepository.save(orgRevisionDraft);
const posMaster = await this.posMasterRepository.find({
where: { orgRevisionId: orgRevisionDraft.id },
});
posMaster.forEach(async (item) => {
// if(item.next_holderId != null){
item.current_holderId = item.next_holderId;
item.next_holderId = null;
await this.posMasterRepository.save(item);
// }
});
return new HttpSuccess();
}
/**
* Cronjob
*/
async cronjobRevision() {
const today = new Date();
today.setHours(0, 0, 0, 0); // Set time to the beginning of the day
const orgRevisionPublish = await this.orgRevisionRepository
@ -1571,7 +1633,6 @@ export class OrganizationController extends Controller {
orgRevisionPublish.orgRevisionIsDraft = false;
orgRevisionPublish.orgRevisionIsCurrent = false;
await this.orgRevisionRepository.save(orgRevisionPublish);
}
orgRevisionDraft.orgRevisionIsCurrent = true;
orgRevisionDraft.orgRevisionIsDraft = false;
@ -1582,12 +1643,12 @@ export class OrganizationController extends Controller {
});
posMaster.forEach(async (item) => {
// if(item.next_holderId != null){
item.current_holderId = item.next_holderId;
item.next_holderId = null;
await this.posMasterRepository.save(item);
item.current_holderId = item.next_holderId;
item.next_holderId = null;
await this.posMasterRepository.save(item);
// }
});
return new HttpSuccess();
}
}

View file

@ -426,7 +426,7 @@ export class PositionController extends Controller {
requestBody: CreatePosMaster,
@Request() request: { user: Record<string, any> },
) {
const posMaster = await this.posMasterRepository.findOne({ where: { id: id } });
let posMaster = await this.posMasterRepository.findOne({ where: { id: id } });
if (!posMaster) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลอัตรากำลัง");
}
@ -435,6 +435,9 @@ export class PositionController extends Controller {
posMaster.orgChild2Id = null;
posMaster.orgChild3Id = null;
posMaster.orgChild4Id = null;
posMaster.posMasterNo = requestBody.posMasterNo;
posMaster.posMasterNoPrefix = requestBody.posMasterNoPrefix;
posMaster.posMasterNoSuffix = requestBody.posMasterNoSuffix;
let orgRoot: any = null;
if (requestBody.orgRootId != null)
@ -514,7 +517,7 @@ export class PositionController extends Controller {
position.positionExecutiveField = x.posDictExecutiveField;
position.positionArea = x.posDictArea;
position.positionIsSelected = false;
position.posMasterId = posMaster.id;
position.posMasterId = posMaster?.id;
position.createdUserId = request.user.sub;
position.createdFullName = request.user.name;
position.lastUpdateUserId = request.user.sub;

View file

@ -330,6 +330,14 @@ export class ProfileController extends Controller {
{
keyword: `%${requestBody.keyword}%`,
},
)
.orWhere(
requestBody.keyword != null && requestBody.keyword != ""
? "profile.citizenId LIKE :keyword"
: "1=1",
{
keyword: `%${requestBody.keyword}%`,
},
);
}),
)

View file

@ -88,10 +88,10 @@ export class CreatePosDict {
posExecutiveId: string | null;
@Column()
posDictExecutiveField: string;
posDictExecutiveField: string | null;
@Column()
posDictArea: string;
posDictArea: string | null;
}
export type UpdatePosDict = Partial<CreatePosDict>;

View file

@ -49,7 +49,7 @@ export class Position extends EntityBase {
length: 255,
default: null,
})
positionExecutiveField: string;
positionExecutiveField?: string;
@Column({
nullable: true,
@ -57,7 +57,7 @@ export class Position extends EntityBase {
length: 255,
default: null,
})
positionArea: string;
positionArea?: string;
@Column({
comment: "เป็นตำแหน่งที่ถูกเลือกในรอบนั้นๆ หรือไม่?",