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

@ -756,16 +756,20 @@ export class OrganizationController extends Controller {
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,
orgRootId: orgRoot.id,
orgChild1Id : IsNull() || "", orgChild2Id : IsNull() || "",
orgChild3Id : IsNull() || "", orgChild4Id : IsNull() || "",
orgChild1Id: IsNull() || "",
orgChild2Id: IsNull() || "",
orgChild3Id: IsNull() || "",
orgChild4Id: IsNull() || "",
current_holderId: Not(IsNull()) || Not(""),
},
}),
@ -773,8 +777,10 @@ export class OrganizationController extends Controller {
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() || "",
},
}),
@ -782,8 +788,10 @@ export class OrganizationController extends Controller {
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(""),
},
}),
@ -791,8 +799,10 @@ export class OrganizationController extends Controller {
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() || "",
},
}),
@ -852,16 +862,20 @@ export class OrganizationController extends Controller {
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,
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(""),
},
}),
@ -869,8 +883,10 @@ export class OrganizationController extends Controller {
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() || "",
},
}),
@ -878,8 +894,10 @@ export class OrganizationController extends Controller {
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(""),
},
}),
@ -887,8 +905,10 @@ export class OrganizationController extends Controller {
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() || "",
},
}),
@ -951,16 +971,20 @@ export class OrganizationController extends Controller {
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,
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(""),
},
}),
@ -968,8 +992,10 @@ export class OrganizationController extends Controller {
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() || "",
},
}),
@ -977,8 +1003,10 @@ export class OrganizationController extends Controller {
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(""),
},
}),
@ -986,8 +1014,10 @@ export class OrganizationController extends Controller {
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() || "",
},
}),
@ -1050,16 +1080,20 @@ export class OrganizationController extends Controller {
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,
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(""),
},
}),
@ -1067,8 +1101,10 @@ export class OrganizationController extends Controller {
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() || "",
},
}),
@ -1076,8 +1112,10 @@ export class OrganizationController extends Controller {
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(""),
},
}),
@ -1085,8 +1123,10 @@ export class OrganizationController extends Controller {
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() || "",
},
}),
@ -1150,46 +1190,59 @@ export class OrganizationController extends Controller {
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,
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,9 +1643,9 @@ 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);
// }
});

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: "เป็นตำแหน่งที่ถูกเลือกในรอบนั้นๆ หรือไม่?",