From 53e19272d86459efb087dd5a959993d7ff177caf Mon Sep 17 00:00:00 2001 From: Bright Date: Wed, 5 Mar 2025 16:07:14 +0700 Subject: [PATCH 1/2] migrate --- src/entities/TenureLevelEmployee.ts | 88 +++++++++++++++++++ src/entities/TenureLevelOfficer.ts | 88 +++++++++++++++++++ src/entities/TenurePositionEmployee.ts | 71 +++++++++++++++ src/entities/TenurePositionOfficer.ts | 71 +++++++++++++++ .../1741164808500-addNewTable05032025.ts | 21 +++++ 5 files changed, 339 insertions(+) create mode 100644 src/entities/TenureLevelEmployee.ts create mode 100644 src/entities/TenureLevelOfficer.ts create mode 100644 src/entities/TenurePositionEmployee.ts create mode 100644 src/entities/TenurePositionOfficer.ts create mode 100644 src/migration/1741164808500-addNewTable05032025.ts diff --git a/src/entities/TenureLevelEmployee.ts b/src/entities/TenureLevelEmployee.ts new file mode 100644 index 00000000..36ae0176 --- /dev/null +++ b/src/entities/TenureLevelEmployee.ts @@ -0,0 +1,88 @@ +import { + Entity, + Column, + OneToMany, + JoinColumn, + ManyToOne, + Double, + ManyToMany, + JoinTable, +} from "typeorm"; +import { EntityBase } from "./base/Base"; + + +@Entity("tenureLevelEmployee") +export class TenureLevelEmployee extends EntityBase { + @Column({ + nullable: true, + length: 40, + comment: "คีย์นอก(FK)ของตาราง profileEmployee", + default: null, + }) + profileEmployeeId: string; + + @Column({ + nullable: true, + comment: "ระดับซี", + default: null, + length: 255, + }) + positionCee: string; + + @Column({ + nullable: true, + comment: "จำนวนวัน", + default: null, + }) + days_diff: number; + + @Column({ + nullable: true, + comment: "จำนวนปีดำรงตำแหน่งงปัจจุบัน", + default: null, + }) + Years: number; + + @Column({ + nullable: true, + comment: "จำนวนเดือนดำรงตำแหน่งงปัจจุบัน", + default: null, + }) + Months: number; + + @Column({ + nullable: true, + comment: "จำนวนวันดำรงตำแหน่งงปัจจุบัน", + default: null, + }) + Days: number; + + @Column({ + nullable: true, + comment: "ชื่อประเภทตำแหน่ง", + default: null, + length: 255, + }) + positionType: string; + + @Column({ + nullable: true, + comment: "ชื่อระดับตำแหน่ง", + default: null, + length: 255, + }) + positionLevel: string; +} + +export class CreateTenureLevelOfficer { + profileEmployeeId: string; + positionCee: string | null; + days_diff: number | null; + Years: number | null; + Months: number | null; + Days: number | null; + positionType: string | null; + positionLevel: string | null; +} + + diff --git a/src/entities/TenureLevelOfficer.ts b/src/entities/TenureLevelOfficer.ts new file mode 100644 index 00000000..d6df2399 --- /dev/null +++ b/src/entities/TenureLevelOfficer.ts @@ -0,0 +1,88 @@ +import { + Entity, + Column, + OneToMany, + JoinColumn, + ManyToOne, + Double, + ManyToMany, + JoinTable, +} from "typeorm"; +import { EntityBase } from "./base/Base"; + + +@Entity("tenureLevelOfficer") +export class TenureLevelOfficer extends EntityBase { + @Column({ + nullable: true, + length: 40, + comment: "คีย์นอก(FK)ของตาราง Profile", + default: null, + }) + profileId: string; + + @Column({ + nullable: true, + comment: "ระดับซี", + default: null, + length: 255, + }) + positionCee: string; + + @Column({ + nullable: true, + comment: "จำนวนวัน", + default: null, + }) + days_diff: number; + + @Column({ + nullable: true, + comment: "จำนวนปีดำรงตำแหน่งงปัจจุบัน", + default: null, + }) + Years: number; + + @Column({ + nullable: true, + comment: "จำนวนเดือนดำรงตำแหน่งงปัจจุบัน", + default: null, + }) + Months: number; + + @Column({ + nullable: true, + comment: "จำนวนวันดำรงตำแหน่งงปัจจุบัน", + default: null, + }) + Days: number; + + @Column({ + nullable: true, + comment: "ชื่อประเภทตำแหน่ง", + default: null, + length: 255, + }) + positionType: string; + + @Column({ + nullable: true, + comment: "ชื่อระดับตำแหน่ง", + default: null, + length: 255, + }) + positionLevel: string; +} + +export class CreateTenureLevelOfficer { + profileId: string; + positionCee: string | null; + days_diff: number | null; + Years: number | null; + Months: number | null; + Days: number | null; + positionType: string | null; + positionLevel: string | null; +} + + diff --git a/src/entities/TenurePositionEmployee.ts b/src/entities/TenurePositionEmployee.ts new file mode 100644 index 00000000..a246cbd0 --- /dev/null +++ b/src/entities/TenurePositionEmployee.ts @@ -0,0 +1,71 @@ +import { + Entity, + Column, + OneToMany, + JoinColumn, + ManyToOne, + Double, + ManyToMany, + JoinTable, +} from "typeorm"; +import { EntityBase } from "./base/Base"; + + +@Entity("tenurePositionEmployee") +export class TenurePositionEmployee extends EntityBase { + @Column({ + nullable: true, + length: 40, + comment: "คีย์นอก(FK)ของตาราง ProfileEmployee", + default: null, + }) + profileEmployeeId: string; + + @Column({ + nullable: true, + comment: "ชื่อตำแหน่ง", + default: null, + length: 255, + }) + positionName: string; + + @Column({ + nullable: true, + comment: "จำนวนวัน", + default: null, + }) + days_diff: number; + + @Column({ + nullable: true, + comment: "จำนวนปีดำรงตำแหน่งงปัจจุบัน", + default: null, + }) + Years: number; + + @Column({ + nullable: true, + comment: "จำนวนเดือนดำรงตำแหน่งงปัจจุบัน", + default: null, + }) + Months: number; + + @Column({ + nullable: true, + comment: "จำนวนวันดำรงตำแหน่งงปัจจุบัน", + default: null, + }) + Days: number; + +} + +export class CreateTenurePositionEmployee { + profileEmployeeId: string; + positionName: string | null; + days_diff: number | null; + Years: number | null; + Months: number | null; + Days: number | null; +} + + diff --git a/src/entities/TenurePositionOfficer.ts b/src/entities/TenurePositionOfficer.ts new file mode 100644 index 00000000..3d4efe43 --- /dev/null +++ b/src/entities/TenurePositionOfficer.ts @@ -0,0 +1,71 @@ +import { + Entity, + Column, + OneToMany, + JoinColumn, + ManyToOne, + Double, + ManyToMany, + JoinTable, +} from "typeorm"; +import { EntityBase } from "./base/Base"; + + +@Entity("tenurePositionOfficer") +export class TenurePositionOfficer extends EntityBase { + @Column({ + nullable: true, + length: 40, + comment: "คีย์นอก(FK)ของตาราง Profile", + default: null, + }) + profileId: string; + + @Column({ + nullable: true, + comment: "ชื่อตำแหน่ง", + default: null, + length: 255, + }) + positionName: string; + + @Column({ + nullable: true, + comment: "จำนวนวัน", + default: null, + }) + days_diff: number; + + @Column({ + nullable: true, + comment: "จำนวนปีดำรงตำแหน่งงปัจจุบัน", + default: null, + }) + Years: number; + + @Column({ + nullable: true, + comment: "จำนวนเดือนดำรงตำแหน่งงปัจจุบัน", + default: null, + }) + Months: number; + + @Column({ + nullable: true, + comment: "จำนวนวันดำรงตำแหน่งงปัจจุบัน", + default: null, + }) + Days: number; + +} + +export class CreateTenurePositionOfficer { + profileId: string; + positionName: string | null; + days_diff: number | null; + Years: number | null; + Months: number | null; + Days: number | null; +} + + diff --git a/src/migration/1741164808500-addNewTable05032025.ts b/src/migration/1741164808500-addNewTable05032025.ts new file mode 100644 index 00000000..3d7539ec --- /dev/null +++ b/src/migration/1741164808500-addNewTable05032025.ts @@ -0,0 +1,21 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class AddNewTable050320251741164808500 implements MigrationInterface { + name = 'AddNewTable050320251741164808500' + + public async up(queryRunner: QueryRunner): Promise { + 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 { + await queryRunner.query(`DROP TABLE \`tenureLevelOfficer\``); + await queryRunner.query(`DROP TABLE \`tenureLevelEmployee\``); + await queryRunner.query(`DROP TABLE \`tenurePositionOfficer\``); + await queryRunner.query(`DROP TABLE \`tenurePositionEmployee\``); + } + +} \ No newline at end of file From e605aea0eeb7564b5e2acb642ab9666cc1f8beb2 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Wed, 5 Mar 2025 16:44:45 +0700 Subject: [PATCH 2/2] add report filter1 --- src/controllers/ProfileController.ts | 46 +++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 4 deletions(-) diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index 12582e36..391fb4d5 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -31,7 +31,7 @@ import { UpdateProfileMother, UpdateProfileCouple, } from "../entities/Profile"; -import { Brackets, IsNull, Like, Not } from "typeorm"; +import { Brackets, In, IsNull, Like, Not } from "typeorm"; import { OrgRevision } from "../entities/OrgRevision"; import { PosMaster } from "../entities/PosMaster"; import { PosLevel } from "../entities/PosLevel"; @@ -1136,7 +1136,11 @@ export class ProfileController extends Controller { "amount", "remark", ], - where: { profileId: id }, + where: { + profileId: id, + commandCode: In(["5","6"]), + isEntry: false + }, order: { order: "ASC" }, }); @@ -1291,7 +1295,11 @@ export class ProfileController extends Controller { ]; const position_raw = await this.salaryRepo.find({ - where: { profileId: id }, + where: { + profileId: id, + commandCode: In(["1", "2", "3", "4", "8", "10", "11", "12", "15", "16"]), + isEntry: false + }, order: { order: "ASC" }, }); const positionList = @@ -1310,7 +1318,6 @@ export class ProfileController extends Controller { { commandDateAffect: "-", commandDateSign: "-", - refCommandNo: "-", posNo: "-", position: "-", posType: "-", @@ -1402,6 +1409,36 @@ export class ProfileController extends Controller { detail: "-", }, ]; + + const otherIncome_raw = await this.salaryRepo.find({ + where: { + profileId: id, + commandCode: "7", + isEntry: false + }, + order: { order: "ASC" }, + }); + const otherIncome = + otherIncome_raw.length > 0 + ? otherIncome_raw.map((item) => ({ + commandDateAffect: item.commandDateAffect?Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.commandDateAffect)):"", + commandDateSign: item.commandDateSign?Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.commandDateSign)):"", + commandNo: item.commandNo?Extension.ToThaiNumber(item.commandNo):"", + position: item.positionName, + posLevel: item.positionLevel?Extension.ToThaiNumber(item.positionLevel):"", + amount: item.amount?Extension.ToThaiNumber(Number(item.amount).toLocaleString()):"", + })) + : [ + { + commandDateAffect: "-", + commandDateSign: "-", + commandNo: "-", + position: "-", + posLevel: "-", + amount: "-", + }, + ]; + const sum = profiles?Extension.ToThaiNumber((Number(profiles.amount) + Number(profiles.positionSalaryAmount) + Number(profiles.mouthSalaryAmount) + Number(profiles.amountSpecial)).toLocaleString()):""; const fullCurrentAddress = profiles?Extension.ToThaiNumber(profiles.currentAddress + " ตำบล/แขวง " + profiles.currentSubDistrict.name + " อำเภอ/เขต " + profiles.currentDistrict.name + " จังหวัด " + profiles.currentProvince.name + profiles.currentZipCode):""; const fullRegistrationAddress = profiles?Extension.ToThaiNumber(profiles.registrationAddress + " ตำบล/แขวง " + profiles.registrationSubDistrict.name + " อำเภอ/เขต " + profiles.registrationDistrict.name + " จังหวัด " + profiles.registrationProvince.name + profiles.registrationZipCode):""; @@ -1535,6 +1572,7 @@ export class ProfileController extends Controller { duty, assessments, profileAbility, + otherIncome }; return new HttpSuccess({