Merge branch 'develop' into adiDev
This commit is contained in:
commit
f0cdce966a
2 changed files with 51 additions and 21 deletions
|
|
@ -22,6 +22,10 @@ import { Profile } from "../entities/Profile";
|
||||||
import { In, LessThan, MoreThan } from "typeorm";
|
import { In, LessThan, MoreThan } from "typeorm";
|
||||||
import permission from "../interfaces/permission";
|
import permission from "../interfaces/permission";
|
||||||
import { setLogDataDiff } from "../interfaces/utils";
|
import { setLogDataDiff } from "../interfaces/utils";
|
||||||
|
import { TenurePositionOfficer } from "../entities/TenurePositionOfficer";
|
||||||
|
import { TenureLevelOfficer } from "../entities/TenureLevelOfficer";
|
||||||
|
import { TenurePositionEmployee } from "../entities/TenurePositionEmployee";
|
||||||
|
import { TenureLevelEmployee } from "../entities/TenureLevelEmployee";
|
||||||
@Route("api/v1/org/profile/salary")
|
@Route("api/v1/org/profile/salary")
|
||||||
@Tags("ProfileSalary")
|
@Tags("ProfileSalary")
|
||||||
@Security("bearerAuth")
|
@Security("bearerAuth")
|
||||||
|
|
@ -29,7 +33,54 @@ export class ProfileSalaryController extends Controller {
|
||||||
private profileRepo = AppDataSource.getRepository(Profile);
|
private profileRepo = AppDataSource.getRepository(Profile);
|
||||||
private salaryRepo = AppDataSource.getRepository(ProfileSalary);
|
private salaryRepo = AppDataSource.getRepository(ProfileSalary);
|
||||||
private salaryHistoryRepo = AppDataSource.getRepository(ProfileSalaryHistory);
|
private salaryHistoryRepo = AppDataSource.getRepository(ProfileSalaryHistory);
|
||||||
|
private positionOfficerRepo = AppDataSource.getRepository(TenurePositionOfficer);
|
||||||
|
private levelOfficerRepo = AppDataSource.getRepository(TenureLevelOfficer);
|
||||||
|
// async cronjobTenurePositionOfficer() {
|
||||||
|
@Get("XXX")
|
||||||
|
public async cronjobTenurePositionOfficer() {
|
||||||
|
let data: any = [];
|
||||||
|
const profile = await this.profileRepo.find({where:{id: "09e89026-c420-4136-bd9e-7e408f530b69"}})
|
||||||
|
await Promise.all(
|
||||||
|
profile.map(async (x) => {
|
||||||
|
const sql_mode = await AppDataSource.query(
|
||||||
|
"SET SESSION sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));",
|
||||||
|
);
|
||||||
|
const position = await AppDataSource.query("CALL GetProfileSalaryPosition(?)", [x.id]);
|
||||||
|
const _position = position.length > 0 ? position[0] : [];
|
||||||
|
const mapPosition =
|
||||||
|
_position.length > 1
|
||||||
|
? _position.slice(1)
|
||||||
|
.map((curr: any, index: number) => ({
|
||||||
|
days_diff: curr.days_diff,
|
||||||
|
positionName: _position[index]?.positionName,
|
||||||
|
}))
|
||||||
|
: [];
|
||||||
|
const calDayDiff = mapPosition
|
||||||
|
.filter((curr: any) => curr.positionName == x.position)
|
||||||
|
.reduce(
|
||||||
|
(acc: any, curr: any) => {
|
||||||
|
acc.days_diff += Number(curr.days_diff) || 0;
|
||||||
|
return acc;
|
||||||
|
},
|
||||||
|
{ days_diff: 0}
|
||||||
|
);
|
||||||
|
console.log("==========> ", calDayDiff)
|
||||||
|
const _mapData = {
|
||||||
|
profileId: x.id,
|
||||||
|
positionName: x.position,
|
||||||
|
days_diff: null,
|
||||||
|
Years: null,
|
||||||
|
Months: null,
|
||||||
|
Days: null,
|
||||||
|
}
|
||||||
|
data.push(_mapData);
|
||||||
|
})
|
||||||
|
|
||||||
|
// await this.positionOfficerRepo.save(data);
|
||||||
|
);
|
||||||
|
|
||||||
|
return new HttpSuccess();
|
||||||
|
}
|
||||||
@Get("user")
|
@Get("user")
|
||||||
public async getSalaryUser(@Request() request: { user: Record<string, any> }) {
|
public async getSalaryUser(@Request() request: { user: Record<string, any> }) {
|
||||||
const profile = await this.profileRepo.findOneBy({ keycloak: request.user.sub });
|
const profile = await this.profileRepo.findOneBy({ keycloak: request.user.sub });
|
||||||
|
|
|
||||||
|
|
@ -1,21 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
|
||||||
|
|
||||||
export class AddNewTable050320251741164808500 implements MigrationInterface {
|
|
||||||
name = 'AddNewTable050320251741164808500'
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(`CREATE TABLE \`tenurePositionEmployee\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`profileEmployeeId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง ProfileEmployee', \`positionName\` varchar(255) NULL COMMENT 'ชื่อตำแหน่ง', \`days_diff\` int NULL COMMENT 'จำนวนวัน', \`Years\` int NULL COMMENT 'จำนวนปีดำรงตำแหน่งงปัจจุบัน', \`Months\` int NULL COMMENT 'จำนวนเดือนดำรงตำแหน่งงปัจจุบัน', \`Days\` int NULL COMMENT 'จำนวนวันดำรงตำแหน่งงปัจจุบัน', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
|
||||||
await queryRunner.query(`CREATE TABLE \`tenurePositionOfficer\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`profileId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง Profile', \`positionName\` varchar(255) NULL COMMENT 'ชื่อตำแหน่ง', \`days_diff\` int NULL COMMENT 'จำนวนวัน', \`Years\` int NULL COMMENT 'จำนวนปีดำรงตำแหน่งงปัจจุบัน', \`Months\` int NULL COMMENT 'จำนวนเดือนดำรงตำแหน่งงปัจจุบัน', \`Days\` int NULL COMMENT 'จำนวนวันดำรงตำแหน่งงปัจจุบัน', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
|
||||||
await queryRunner.query(`CREATE TABLE \`tenureLevelEmployee\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`profileEmployeeId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง profileEmployee', \`positionCee\` varchar(255) NULL COMMENT 'ระดับซี', \`days_diff\` int NULL COMMENT 'จำนวนวัน', \`Years\` int NULL COMMENT 'จำนวนปีดำรงตำแหน่งงปัจจุบัน', \`Months\` int NULL COMMENT 'จำนวนเดือนดำรงตำแหน่งงปัจจุบัน', \`Days\` int NULL COMMENT 'จำนวนวันดำรงตำแหน่งงปัจจุบัน', \`positionType\` varchar(255) NULL COMMENT 'ชื่อประเภทตำแหน่ง', \`positionLevel\` varchar(255) NULL COMMENT 'ชื่อระดับตำแหน่ง', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
|
||||||
await queryRunner.query(`CREATE TABLE \`tenureLevelOfficer\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`profileId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง Profile', \`positionCee\` varchar(255) NULL COMMENT 'ระดับซี', \`days_diff\` int NULL COMMENT 'จำนวนวัน', \`Years\` int NULL COMMENT 'จำนวนปีดำรงตำแหน่งงปัจจุบัน', \`Months\` int NULL COMMENT 'จำนวนเดือนดำรงตำแหน่งงปัจจุบัน', \`Days\` int NULL COMMENT 'จำนวนวันดำรงตำแหน่งงปัจจุบัน', \`positionType\` varchar(255) NULL COMMENT 'ชื่อประเภทตำแหน่ง', \`positionLevel\` varchar(255) NULL COMMENT 'ชื่อระดับตำแหน่ง', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(`DROP TABLE \`tenureLevelOfficer\``);
|
|
||||||
await queryRunner.query(`DROP TABLE \`tenureLevelEmployee\``);
|
|
||||||
await queryRunner.query(`DROP TABLE \`tenurePositionOfficer\``);
|
|
||||||
await queryRunner.query(`DROP TABLE \`tenurePositionEmployee\``);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue