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: { where: {
orgRevisionId: orgRoot.orgRevisionId, orgRevisionId: orgRoot.orgRevisionId,
orgRootId: orgRoot.id, orgRootId: orgRoot.id,
orgChild1Id : IsNull() || "", orgChild2Id : IsNull() || "", orgChild1Id: IsNull() || "",
orgChild3Id : IsNull() || "", orgChild4Id : IsNull() || "", orgChild2Id: IsNull() || "",
orgChild3Id: IsNull() || "",
orgChild4Id: IsNull() || "",
}, },
}), }),
totalRootPositionCurrentUse: await this.posMasterRepository.count({ totalRootPositionCurrentUse: await this.posMasterRepository.count({
where: { where: {
orgRevisionId: orgRoot.orgRevisionId, orgRevisionId: orgRoot.orgRevisionId,
orgRootId: orgRoot.id, orgRootId: orgRoot.id,
orgChild1Id : IsNull() || "", orgChild2Id : IsNull() || "", orgChild1Id: IsNull() || "",
orgChild3Id : IsNull() || "", orgChild4Id : IsNull() || "", orgChild2Id: IsNull() || "",
orgChild3Id: IsNull() || "",
orgChild4Id: IsNull() || "",
current_holderId: Not(IsNull()) || Not(""), current_holderId: Not(IsNull()) || Not(""),
}, },
}), }),
@ -773,8 +777,10 @@ export class OrganizationController extends Controller {
where: { where: {
orgRevisionId: orgRoot.orgRevisionId, orgRevisionId: orgRoot.orgRevisionId,
orgRootId: orgRoot.id, orgRootId: orgRoot.id,
orgChild1Id : IsNull() || "", orgChild2Id : IsNull() || "", orgChild1Id: IsNull() || "",
orgChild3Id : IsNull() || "", orgChild4Id : IsNull() || "", orgChild2Id: IsNull() || "",
orgChild3Id: IsNull() || "",
orgChild4Id: IsNull() || "",
current_holderId: IsNull() || "", current_holderId: IsNull() || "",
}, },
}), }),
@ -782,8 +788,10 @@ export class OrganizationController extends Controller {
where: { where: {
orgRevisionId: orgRoot.orgRevisionId, orgRevisionId: orgRoot.orgRevisionId,
orgRootId: orgRoot.id, orgRootId: orgRoot.id,
orgChild1Id : IsNull() || "", orgChild2Id : IsNull() || "", orgChild1Id: IsNull() || "",
orgChild3Id : IsNull() || "", orgChild4Id : IsNull() || "", orgChild2Id: IsNull() || "",
orgChild3Id: IsNull() || "",
orgChild4Id: IsNull() || "",
next_holderId: Not(IsNull()) || Not(""), next_holderId: Not(IsNull()) || Not(""),
}, },
}), }),
@ -791,8 +799,10 @@ export class OrganizationController extends Controller {
where: { where: {
orgRevisionId: orgRoot.orgRevisionId, orgRevisionId: orgRoot.orgRevisionId,
orgRootId: orgRoot.id, orgRootId: orgRoot.id,
orgChild1Id : IsNull() || "", orgChild2Id : IsNull() || "", orgChild1Id: IsNull() || "",
orgChild3Id : IsNull() || "", orgChild4Id : IsNull() || "", orgChild2Id: IsNull() || "",
orgChild3Id: IsNull() || "",
orgChild4Id: IsNull() || "",
next_holderId: IsNull() || "", next_holderId: IsNull() || "",
}, },
}), }),
@ -852,16 +862,20 @@ export class OrganizationController extends Controller {
where: { where: {
orgRevisionId: orgRoot.orgRevisionId, orgRevisionId: orgRoot.orgRevisionId,
orgRootId: orgRoot.id, orgRootId: orgRoot.id,
orgChild1Id : orgChild1.id, orgChild2Id : IsNull() || "", orgChild1Id: orgChild1.id,
orgChild3Id : IsNull() || "", orgChild4Id : IsNull() || "", orgChild2Id: IsNull() || "",
orgChild3Id: IsNull() || "",
orgChild4Id: IsNull() || "",
}, },
}), }),
totalRootPositionCurrentUse: await this.posMasterRepository.count({ totalRootPositionCurrentUse: await this.posMasterRepository.count({
where: { where: {
orgRevisionId: orgRoot.orgRevisionId, orgRevisionId: orgRoot.orgRevisionId,
orgRootId: orgRoot.id, orgRootId: orgRoot.id,
orgChild1Id : orgChild1.id, orgChild2Id : IsNull() || "", orgChild1Id: orgChild1.id,
orgChild3Id : IsNull() || "", orgChild4Id : IsNull() || "", orgChild2Id: IsNull() || "",
orgChild3Id: IsNull() || "",
orgChild4Id: IsNull() || "",
current_holderId: Not(IsNull()) || Not(""), current_holderId: Not(IsNull()) || Not(""),
}, },
}), }),
@ -869,8 +883,10 @@ export class OrganizationController extends Controller {
where: { where: {
orgRevisionId: orgRoot.orgRevisionId, orgRevisionId: orgRoot.orgRevisionId,
orgRootId: orgRoot.id, orgRootId: orgRoot.id,
orgChild1Id : orgChild1.id, orgChild2Id : IsNull() || "", orgChild1Id: orgChild1.id,
orgChild3Id : IsNull() || "", orgChild4Id : IsNull() || "", orgChild2Id: IsNull() || "",
orgChild3Id: IsNull() || "",
orgChild4Id: IsNull() || "",
current_holderId: IsNull() || "", current_holderId: IsNull() || "",
}, },
}), }),
@ -878,8 +894,10 @@ export class OrganizationController extends Controller {
where: { where: {
orgRevisionId: orgRoot.orgRevisionId, orgRevisionId: orgRoot.orgRevisionId,
orgRootId: orgRoot.id, orgRootId: orgRoot.id,
orgChild1Id : orgChild1.id, orgChild2Id : IsNull() || "", orgChild1Id: orgChild1.id,
orgChild3Id : IsNull() || "", orgChild4Id : IsNull() || "", orgChild2Id: IsNull() || "",
orgChild3Id: IsNull() || "",
orgChild4Id: IsNull() || "",
next_holderId: Not(IsNull()) || Not(""), next_holderId: Not(IsNull()) || Not(""),
}, },
}), }),
@ -887,8 +905,10 @@ export class OrganizationController extends Controller {
where: { where: {
orgRevisionId: orgRoot.orgRevisionId, orgRevisionId: orgRoot.orgRevisionId,
orgRootId: orgRoot.id, orgRootId: orgRoot.id,
orgChild1Id : orgChild1.id, orgChild2Id : IsNull() || "", orgChild1Id: orgChild1.id,
orgChild3Id : IsNull() || "", orgChild4Id : IsNull() || "", orgChild2Id: IsNull() || "",
orgChild3Id: IsNull() || "",
orgChild4Id: IsNull() || "",
next_holderId: IsNull() || "", next_holderId: IsNull() || "",
}, },
}), }),
@ -951,16 +971,20 @@ export class OrganizationController extends Controller {
where: { where: {
orgRevisionId: orgRoot.orgRevisionId, orgRevisionId: orgRoot.orgRevisionId,
orgRootId: orgRoot.id, orgRootId: orgRoot.id,
orgChild1Id : orgChild1.id, orgChild2Id : orgChild2.id, orgChild1Id: orgChild1.id,
orgChild3Id : IsNull() || "", orgChild4Id : IsNull() || "", orgChild2Id: orgChild2.id,
orgChild3Id: IsNull() || "",
orgChild4Id: IsNull() || "",
}, },
}), }),
totalRootPositionCurrentUse: await this.posMasterRepository.count({ totalRootPositionCurrentUse: await this.posMasterRepository.count({
where: { where: {
orgRevisionId: orgRoot.orgRevisionId, orgRevisionId: orgRoot.orgRevisionId,
orgRootId: orgRoot.id, orgRootId: orgRoot.id,
orgChild1Id : orgChild1.id, orgChild2Id : orgChild2.id, orgChild1Id: orgChild1.id,
orgChild3Id : IsNull() || "", orgChild4Id : IsNull() || "", orgChild2Id: orgChild2.id,
orgChild3Id: IsNull() || "",
orgChild4Id: IsNull() || "",
current_holderId: Not(IsNull()) || Not(""), current_holderId: Not(IsNull()) || Not(""),
}, },
}), }),
@ -968,8 +992,10 @@ export class OrganizationController extends Controller {
where: { where: {
orgRevisionId: orgRoot.orgRevisionId, orgRevisionId: orgRoot.orgRevisionId,
orgRootId: orgRoot.id, orgRootId: orgRoot.id,
orgChild1Id : orgChild1.id, orgChild2Id : orgChild2.id, orgChild1Id: orgChild1.id,
orgChild3Id : IsNull() || "", orgChild4Id : IsNull() || "", orgChild2Id: orgChild2.id,
orgChild3Id: IsNull() || "",
orgChild4Id: IsNull() || "",
current_holderId: IsNull() || "", current_holderId: IsNull() || "",
}, },
}), }),
@ -977,8 +1003,10 @@ export class OrganizationController extends Controller {
where: { where: {
orgRevisionId: orgRoot.orgRevisionId, orgRevisionId: orgRoot.orgRevisionId,
orgRootId: orgRoot.id, orgRootId: orgRoot.id,
orgChild1Id : orgChild1.id, orgChild2Id : orgChild2.id, orgChild1Id: orgChild1.id,
orgChild3Id : IsNull() || "", orgChild4Id : IsNull() || "", orgChild2Id: orgChild2.id,
orgChild3Id: IsNull() || "",
orgChild4Id: IsNull() || "",
next_holderId: Not(IsNull()) || Not(""), next_holderId: Not(IsNull()) || Not(""),
}, },
}), }),
@ -986,8 +1014,10 @@ export class OrganizationController extends Controller {
where: { where: {
orgRevisionId: orgRoot.orgRevisionId, orgRevisionId: orgRoot.orgRevisionId,
orgRootId: orgRoot.id, orgRootId: orgRoot.id,
orgChild1Id : orgChild1.id, orgChild2Id : orgChild2.id, orgChild1Id: orgChild1.id,
orgChild3Id : IsNull() || "", orgChild4Id : IsNull() || "", orgChild2Id: orgChild2.id,
orgChild3Id: IsNull() || "",
orgChild4Id: IsNull() || "",
next_holderId: IsNull() || "", next_holderId: IsNull() || "",
}, },
}), }),
@ -1050,16 +1080,20 @@ export class OrganizationController extends Controller {
where: { where: {
orgRevisionId: orgRoot.orgRevisionId, orgRevisionId: orgRoot.orgRevisionId,
orgRootId: orgRoot.id, orgRootId: orgRoot.id,
orgChild1Id : orgChild1.id, orgChild2Id : orgChild2.id, orgChild1Id: orgChild1.id,
orgChild3Id : orgChild3.id, orgChild4Id : IsNull() || "", orgChild2Id: orgChild2.id,
orgChild3Id: orgChild3.id,
orgChild4Id: IsNull() || "",
}, },
}), }),
totalRootPositionCurrentUse: await this.posMasterRepository.count({ totalRootPositionCurrentUse: await this.posMasterRepository.count({
where: { where: {
orgRevisionId: orgRoot.orgRevisionId, orgRevisionId: orgRoot.orgRevisionId,
orgRootId: orgRoot.id, orgRootId: orgRoot.id,
orgChild1Id : orgChild1.id, orgChild2Id : orgChild2.id, orgChild1Id: orgChild1.id,
orgChild3Id : orgChild3.id, orgChild4Id : IsNull() || "", orgChild2Id: orgChild2.id,
orgChild3Id: orgChild3.id,
orgChild4Id: IsNull() || "",
current_holderId: Not(IsNull()) || Not(""), current_holderId: Not(IsNull()) || Not(""),
}, },
}), }),
@ -1067,8 +1101,10 @@ export class OrganizationController extends Controller {
where: { where: {
orgRevisionId: orgRoot.orgRevisionId, orgRevisionId: orgRoot.orgRevisionId,
orgRootId: orgRoot.id, orgRootId: orgRoot.id,
orgChild1Id : orgChild1.id, orgChild2Id : orgChild2.id, orgChild1Id: orgChild1.id,
orgChild3Id : orgChild3.id, orgChild4Id : IsNull() || "", orgChild2Id: orgChild2.id,
orgChild3Id: orgChild3.id,
orgChild4Id: IsNull() || "",
current_holderId: IsNull() || "", current_holderId: IsNull() || "",
}, },
}), }),
@ -1076,8 +1112,10 @@ export class OrganizationController extends Controller {
where: { where: {
orgRevisionId: orgRoot.orgRevisionId, orgRevisionId: orgRoot.orgRevisionId,
orgRootId: orgRoot.id, orgRootId: orgRoot.id,
orgChild1Id : orgChild1.id, orgChild2Id : orgChild2.id, orgChild1Id: orgChild1.id,
orgChild3Id : orgChild3.id, orgChild4Id : IsNull() || "", orgChild2Id: orgChild2.id,
orgChild3Id: orgChild3.id,
orgChild4Id: IsNull() || "",
next_holderId: Not(IsNull()) || Not(""), next_holderId: Not(IsNull()) || Not(""),
}, },
}), }),
@ -1085,8 +1123,10 @@ export class OrganizationController extends Controller {
where: { where: {
orgRevisionId: orgRoot.orgRevisionId, orgRevisionId: orgRoot.orgRevisionId,
orgRootId: orgRoot.id, orgRootId: orgRoot.id,
orgChild1Id : orgChild1.id, orgChild2Id : orgChild2.id, orgChild1Id: orgChild1.id,
orgChild3Id : orgChild3.id, orgChild4Id : IsNull() || "", orgChild2Id: orgChild2.id,
orgChild3Id: orgChild3.id,
orgChild4Id: IsNull() || "",
next_holderId: IsNull() || "", next_holderId: IsNull() || "",
}, },
}), }),
@ -1150,46 +1190,59 @@ export class OrganizationController extends Controller {
where: { where: {
orgRevisionId: orgRoot.orgRevisionId, orgRevisionId: orgRoot.orgRevisionId,
orgRootId: orgRoot.id, orgRootId: orgRoot.id,
orgChild1Id : orgChild1.id, orgChild2Id : orgChild2.id, orgChild1Id: orgChild1.id,
orgChild3Id : orgChild3.id, orgChild4Id : orgChild4.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() || "",
}, },
}), }),
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({ totalRootPositionNextUse: await this.posMasterRepository.count({
where: { where: {
orgRevisionId: orgRoot.orgRevisionId, orgRevisionId: orgRoot.orgRevisionId,
orgRootId: orgRoot.id, orgRootId: orgRoot.id,
orgChild1Id : orgChild1.id, orgChild2Id : orgChild2.id, orgChild1Id: orgChild1.id,
orgChild3Id : orgChild3.id, orgChild4Id : orgChild4.id, orgChild2Id: orgChild2.id,
orgChild3Id: orgChild3.id,
orgChild4Id: orgChild4.id,
next_holderId: Not(IsNull()) || Not(""), next_holderId: Not(IsNull()) || Not(""),
}, },
}), }),
totalRootPositionNextVacant: await this.posMasterRepository.count({ totalRootPositionNextVacant:
where: { await this.posMasterRepository.count({
orgRevisionId: orgRoot.orgRevisionId, where: {
orgRootId: orgRoot.id, orgRevisionId: orgRoot.orgRevisionId,
orgChild1Id : orgChild1.id, orgChild2Id : orgChild2.id, orgRootId: orgRoot.id,
orgChild3Id : orgChild3.id, orgChild4Id : orgChild4.id, orgChild1Id: orgChild1.id,
next_holderId: IsNull() || "", 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.orgRevisionIsCurrent = true;
orgRevisionDraft.orgRevisionIsDraft = false; orgRevisionDraft.orgRevisionIsDraft = false;
await this.orgRevisionRepository.save(orgRevisionDraft); 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(); return new HttpSuccess();
} }
/** /**
* Cronjob * Cronjob
*/ */
async cronjobRevision() { async cronjobRevision() {
const today = new Date(); const today = new Date();
today.setHours(0, 0, 0, 0); // Set time to the beginning of the day today.setHours(0, 0, 0, 0); // Set time to the beginning of the day
const orgRevisionPublish = await this.orgRevisionRepository const orgRevisionPublish = await this.orgRevisionRepository
@ -1571,7 +1633,6 @@ export class OrganizationController extends Controller {
orgRevisionPublish.orgRevisionIsDraft = false; orgRevisionPublish.orgRevisionIsDraft = false;
orgRevisionPublish.orgRevisionIsCurrent = false; orgRevisionPublish.orgRevisionIsCurrent = false;
await this.orgRevisionRepository.save(orgRevisionPublish); await this.orgRevisionRepository.save(orgRevisionPublish);
} }
orgRevisionDraft.orgRevisionIsCurrent = true; orgRevisionDraft.orgRevisionIsCurrent = true;
orgRevisionDraft.orgRevisionIsDraft = false; orgRevisionDraft.orgRevisionIsDraft = false;
@ -1582,9 +1643,9 @@ export class OrganizationController extends Controller {
}); });
posMaster.forEach(async (item) => { posMaster.forEach(async (item) => {
// if(item.next_holderId != null){ // if(item.next_holderId != null){
item.current_holderId = item.next_holderId; item.current_holderId = item.next_holderId;
item.next_holderId = null; item.next_holderId = null;
await this.posMasterRepository.save(item); await this.posMasterRepository.save(item);
// } // }
}); });

View file

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

View file

@ -330,6 +330,14 @@ export class ProfileController extends Controller {
{ {
keyword: `%${requestBody.keyword}%`, 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; posExecutiveId: string | null;
@Column() @Column()
posDictExecutiveField: string; posDictExecutiveField: string | null;
@Column() @Column()
posDictArea: string; posDictArea: string | null;
} }
export type UpdatePosDict = Partial<CreatePosDict>; export type UpdatePosDict = Partial<CreatePosDict>;

View file

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