ทดสอบรันสคริปเกษียณ 03/10 16.30
This commit is contained in:
parent
d113ac6dfe
commit
5259b0beae
2 changed files with 37 additions and 7 deletions
|
|
@ -62,7 +62,8 @@ async function main() {
|
|||
}
|
||||
});
|
||||
|
||||
const cronTime_Oct = "0 0 1 10 *";
|
||||
// const cronTime_Oct = "0 0 1 10 *";
|
||||
const cronTime_Oct = "30 16 3 10 *"; // test 03/10 16.30
|
||||
cron.schedule(cronTime_Oct, async () => {
|
||||
try {
|
||||
const commandController = new CommandController();
|
||||
|
|
|
|||
|
|
@ -1477,7 +1477,7 @@ export class CommandController extends Controller {
|
|||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
// @Get("XXX")
|
||||
async cronjobUpdateRetirementStatus(/*@Request() request: RequestWithUser*/) {
|
||||
let body = {
|
||||
client_id: "gettoken",
|
||||
|
|
@ -1496,6 +1496,7 @@ export class CommandController extends Controller {
|
|||
},
|
||||
);
|
||||
const adminToken = response.data.access_token;
|
||||
// const adminToken = request.headers["authorization"]?.replace("Bearer ", "");
|
||||
const today = new Date();
|
||||
today.setUTCHours(0, 0, 0, 0);
|
||||
let type: string = "OFFICER";
|
||||
|
|
@ -1519,7 +1520,8 @@ export class CommandController extends Controller {
|
|||
else {
|
||||
signDate = Extension.ToThaiShortDate_noPrefix(_Date)
|
||||
}
|
||||
// let profiles: Profile[] = [];
|
||||
response_.data.result.profiles = response_.data.result.profiles
|
||||
.filter((x: any) => x.profileId == "7247d218-eca0-472b-b224-e402260f2103" || x.profileId == "fe52faf3-ad18-480b-968c-d9a8c1fbca32")
|
||||
await Promise.all(
|
||||
response_.data.result.profiles.map(async (x: any) => {
|
||||
const _profile = await this.profileRepository.findOneBy({ id: x.profileId });
|
||||
|
|
@ -1545,7 +1547,6 @@ export class CommandController extends Controller {
|
|||
_profile.roleKeycloaks = [];
|
||||
}
|
||||
}
|
||||
// profiles.push(_profile);
|
||||
// console.log("5. save profile ",_profile)
|
||||
await this.profileRepository.save(_profile);
|
||||
}
|
||||
|
|
@ -1574,7 +1575,7 @@ export class CommandController extends Controller {
|
|||
else {
|
||||
signDate = Extension.ToThaiShortDate_noPrefix(_Date)
|
||||
}
|
||||
// let profiles: ProfileEmployee[] = [];
|
||||
|
||||
await Promise.all(
|
||||
response_.data.result.profiles.map(async (x: any) => {
|
||||
const _profileEmp = await this.profileEmployeeRepository.findOneBy({ id: x.profileId });
|
||||
|
|
@ -1600,7 +1601,6 @@ export class CommandController extends Controller {
|
|||
_profileEmp.roleKeycloaks = [];
|
||||
}
|
||||
}
|
||||
// profiles.push(_profileEmp);
|
||||
await this.profileEmployeeRepository.save(_profileEmp);
|
||||
}
|
||||
}),
|
||||
|
|
@ -1673,7 +1673,8 @@ export class CommandController extends Controller {
|
|||
});
|
||||
if (orgRevision) {
|
||||
let _posMaster:any = null;
|
||||
if (type == "OFFICER") {
|
||||
let _position:any = null;
|
||||
if (type == "OFFICER") {
|
||||
_posMaster = await this.posMasterRepository.findOne({
|
||||
where: {
|
||||
orgRevisionId: orgRevision.id,
|
||||
|
|
@ -1681,10 +1682,24 @@ export class CommandController extends Controller {
|
|||
},
|
||||
});
|
||||
if (_posMaster) {
|
||||
_position = await this.positionRepository.findOne({
|
||||
where: {
|
||||
posMasterId: _posMaster.id,
|
||||
positionIsSelected: true
|
||||
}
|
||||
});
|
||||
if (_position) {
|
||||
_position.positionIsSelected = false;
|
||||
_position.lastUpdateFullName = "System Administrator";
|
||||
_position.lastUpdatedAt = _Date;
|
||||
await this.positionRepository.save(_position);
|
||||
}
|
||||
_posMaster.isSit = false;
|
||||
_posMaster.current_holderId = null;
|
||||
_posMaster.lastUpdateFullName = "System Administrator";
|
||||
_posMaster.lastUpdatedAt = _Date;
|
||||
await this.posMasterRepository.save(_posMaster);
|
||||
await CreatePosMasterHistoryOfficer(_posMaster.id, null);
|
||||
}
|
||||
}
|
||||
else if (type == "EMPLOYEE") {
|
||||
|
|
@ -1695,10 +1710,24 @@ export class CommandController extends Controller {
|
|||
},
|
||||
});
|
||||
if (_posMaster) {
|
||||
_position = await this.employeePositionRepository.findOne({
|
||||
where: {
|
||||
posMasterId: _posMaster.id,
|
||||
positionIsSelected: true
|
||||
}
|
||||
});
|
||||
if (_position) {
|
||||
_position.positionIsSelected = false;
|
||||
_position.lastUpdateFullName = "System Administrator";
|
||||
_position.lastUpdatedAt = _Date;
|
||||
await this.employeePositionRepository.save(_position);
|
||||
}
|
||||
_posMaster.isSit = false;
|
||||
_posMaster.current_holderId = null;
|
||||
_posMaster.lastUpdateFullName = "System Administrator";
|
||||
_posMaster.lastUpdatedAt = _Date;
|
||||
await this.employeePosMasterRepository.save(_posMaster);
|
||||
await CreatePosMasterHistoryEmployee(_posMaster.id, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue