[After SIT] รายงานทะเบียนประวัติ เพิ่มค้นหาจาก ระยะเวลาดำรงตำแหน่ง (บริหาร) ปัจจุบัน และแสดงคอลัมน์เพิ่ม issue #1326
This commit is contained in:
parent
3746888ef8
commit
eaafb73479
3 changed files with 66 additions and 1 deletions
|
|
@ -78,6 +78,7 @@ async function main() {
|
|||
const profileSalaryController = new ProfileSalaryController();
|
||||
await profileSalaryController.cronjobTenurePositionOfficer();
|
||||
await profileSalaryController.cronjobTenureLevelOfficer();
|
||||
await profileSalaryController.cronjobTenureExecutivePositionOfficer();
|
||||
await profileSalaryController.cronjobTenurePositionEmployee();
|
||||
await profileSalaryController.cronjobTenureLevelEmployee();
|
||||
} catch (error) {
|
||||
|
|
|
|||
|
|
@ -27,8 +27,11 @@ import { TenurePositionOfficer } from "../entities/TenurePositionOfficer";
|
|||
import { TenureLevelOfficer } from "../entities/TenureLevelOfficer";
|
||||
import { TenurePositionEmployee } from "../entities/TenurePositionEmployee";
|
||||
import { TenureLevelEmployee } from "../entities/TenureLevelEmployee";
|
||||
import { TenurePositionExecutiveOfficer } from "../entities/TenurePositionExecutiveOfficer";
|
||||
import { Command } from "../entities/Command";
|
||||
import { OrgRoot } from "../entities/OrgRoot";
|
||||
import { OrgRevision } from "../entities/OrgRevision";
|
||||
import { Position } from "../entities/Position";
|
||||
@Route("api/v1/org/profile/salary")
|
||||
@Tags("ProfileSalary")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -41,8 +44,11 @@ export class ProfileSalaryController extends Controller {
|
|||
private positionEmployeeRepo = AppDataSource.getRepository(TenurePositionEmployee);
|
||||
private levelOfficerRepo = AppDataSource.getRepository(TenureLevelOfficer);
|
||||
private levelEmployeeRepo = AppDataSource.getRepository(TenureLevelEmployee);
|
||||
private positionExecutiveOfficerRepo = AppDataSource.getRepository(TenurePositionExecutiveOfficer);
|
||||
private commandRepository = AppDataSource.getRepository(Command);
|
||||
private orgRootRepository = AppDataSource.getRepository(OrgRoot);
|
||||
private orgRevisionRepository = AppDataSource.getRepository(OrgRevision);
|
||||
private positionRepo = AppDataSource.getRepository(Position);
|
||||
|
||||
@Get("TenurePositionOfficer")
|
||||
public async cronjobTenurePositionOfficer() {
|
||||
|
|
@ -229,6 +235,64 @@ export class ProfileSalaryController extends Controller {
|
|||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
@Get("TenurePositionExecutiveOfficer")
|
||||
public async cronjobTenureExecutivePositionOfficer() {
|
||||
await this.positionExecutiveOfficerRepo.clear();
|
||||
const profile = await this.profileRepo.find();
|
||||
const orgRevision = await this.orgRevisionRepository.findOne({
|
||||
select: ["id"],
|
||||
where: {
|
||||
orgRevisionIsDraft: false,
|
||||
orgRevisionIsCurrent: true,
|
||||
},
|
||||
});
|
||||
for await (const x of profile) {
|
||||
const position = await this.positionRepo.findOne({
|
||||
where: {
|
||||
positionIsSelected: true,
|
||||
posMaster: {
|
||||
orgRevisionId: orgRevision?.id,
|
||||
current_holderId: x.id,
|
||||
},
|
||||
},
|
||||
order: { createdAt: "DESC" },
|
||||
relations: {
|
||||
posExecutive: true,
|
||||
},
|
||||
});
|
||||
const positionExecutive = await AppDataSource.query("CALL GetProfileSalaryExecutive(?)", [x.id]);
|
||||
const _position = positionExecutive.length > 0 ? positionExecutive[0] : [];
|
||||
const mapPosition =
|
||||
_position.length > 1
|
||||
? _position.slice(1).map((curr: any, index: number) => ({
|
||||
days_diff: curr.days_diff,
|
||||
positionExecutive: _position[index]?.positionExecutive,
|
||||
}))
|
||||
: [];
|
||||
const _posExecutiveName = position?.posExecutive?.posExecutiveName;
|
||||
const calDayDiff = mapPosition
|
||||
.filter((curr: any) => _posExecutiveName && curr.positionExecutive == _posExecutiveName)
|
||||
.reduce(
|
||||
(acc: any, curr: any) => {
|
||||
acc.days_diff += Number(curr.days_diff) || 0;
|
||||
acc.positionExecutive = curr.positionExecutive;
|
||||
return acc;
|
||||
},
|
||||
{ days_diff: 0, positionExecutive: null },
|
||||
);
|
||||
const mapData: any = {
|
||||
profileId: x.id,
|
||||
positionExecutiveName: calDayDiff.positionExecutive,
|
||||
days_diff: calDayDiff.days_diff,
|
||||
Years: (calDayDiff.days_diff / 365.2524).toFixed(4),
|
||||
Months: ((calDayDiff.days_diff / 30.4375) % 12).toFixed(4),
|
||||
Days: (calDayDiff.days_diff % 30.4375).toFixed(4),
|
||||
};
|
||||
await this.positionExecutiveOfficerRepo.save(mapData);
|
||||
}
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
@Get("user")
|
||||
public async getSalaryUser(@Request() request: { user: Record<string, any> }) {
|
||||
const profile = await this.profileRepo.findOneBy({ keycloak: request.user.sub });
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ export class ReportController extends Controller {
|
|||
} else if (tenureType != "" && tenureType == "level") {
|
||||
tenureTypeCondition = "registryOfficer.levelYears BETWEEN :tenureMin AND :tenureMax";
|
||||
} else if (tenureType != "" && tenureType == "posExecutive") {
|
||||
tenureTypeCondition = "registryOfficer.levelYears BETWEEN :tenureMin AND :tenureMax";
|
||||
tenureTypeCondition = "registryOfficer.posExecutiveYears BETWEEN :tenureMin AND :tenureMax";
|
||||
}
|
||||
|
||||
const [lists, total] = await AppDataSource.getRepository(viewRegistryOfficer)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue