Merge branch 'develop' into adiDev

This commit is contained in:
AdisakKanthawilang 2024-05-20 11:13:18 +07:00
commit 8f74e3a366
6 changed files with 147 additions and 75 deletions

View file

@ -847,6 +847,36 @@ export class ProfileController extends Controller {
? null
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id);
const root =
profile.current_holders == null ||
profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgRoot == null
? null
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgRoot;
const child1 =
profile.current_holders == null ||
profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild1 ==
null
? null
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild1;
const child2 =
profile.current_holders == null ||
profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild2 ==
null
? null
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild2;
const child3 =
profile.current_holders == null ||
profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild3 ==
null
? null
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild3;
const child4 =
profile.current_holders == null ||
profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild4 ==
null
? null
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild4;
const position = await this.positionRepository.findOne({
relations: ["posExecutive"],
where: {
@ -861,8 +891,10 @@ export class ProfileController extends Controller {
firstName: profile.firstName,
lastName: profile.lastName,
citizenId: profile.citizenId,
birthDate: profile.birthDate,
position: profile.position,
posMaster: posMaster == null ? null : posMaster.posMasterNo,
posMasterNo: posMaster == null ? null : posMaster.posMasterNo,
posLevelName: profile.posLevel == null ? null : profile.posLevel.posLevelName,
posLevelRank: profile.posLevel == null ? null : profile.posLevel.posLevelRank,
posLevelId: profile.posLevel == null ? null : profile.posLevel.id,
@ -879,76 +911,21 @@ export class ProfileController extends Controller {
: position.posExecutive.posExecutivePriority,
posExecutiveId:
position == null || position.posExecutive == null ? null : position.posExecutive.id,
rootId:
profile.current_holders == null ||
profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgRoot ==
null
? null
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)
?.orgRootId,
root:
profile.current_holders == null ||
profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgRoot ==
null
? null
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgRoot
.orgRootName,
child1Id:
profile.current_holders == null ||
profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild1 ==
null
? null
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)
?.orgChild1Id,
child1:
profile.current_holders == null ||
profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild1 ==
null
? null
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild1
.orgChild1Name,
child2Id:
profile.current_holders == null ||
profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild2 ==
null
? null
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)
?.orgChild2Id,
child2:
profile.current_holders == null ||
profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild2 ==
null
? null
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild2
.orgChild2Name,
child3Id:
profile.current_holders == null ||
profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild3 ==
null
? null
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)
?.orgChild3Id,
child3:
profile.current_holders == null ||
profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild3 ==
null
? null
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild3
.orgChild3Name,
child4Id:
profile.current_holders == null ||
profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild4 ==
null
? null
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)
?.orgChild4Id,
child4:
profile.current_holders == null ||
profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild4 ==
null
? null
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild4
.orgChild4Name,
rootId: root == null ? null : root.id,
root: root == null ? null : root.orgRootName,
rootShortName: root == null ? null : root.orgRootShortName,
child1Id: child1 == null ? null : child1.id,
child1: child1 == null ? null : child1.orgChild1Name,
child1ShortName: child1 == null ? null : child1.orgChild1ShortName,
child2Id: child2 == null ? null : child2.id,
child2: child2 == null ? null : child2.orgChild2Name,
child2ShortName: child2 == null ? null : child2.orgChild2ShortName,
child3Id: child3 == null ? null : child3.id,
child3: child3 == null ? null : child3.orgChild3Name,
child3ShortName: child3 == null ? null : child3.orgChild3ShortName,
child4Id: child4 == null ? null : child4.id,
child4: child4 == null ? null : child4.orgChild4Name,
child4ShortName: child4 == null ? null : child4.orgChild4ShortName,
node: null,
nodeId: null,
};

View file

@ -132,7 +132,7 @@ export class ProfileEmployeeController extends Controller {
* @param {string} id Id
*/
@Put("{id}")
async updateProfile(
async updateProfileEmployee(
@Request() request: RequestWithUser,
@Path() id: string,
@Body() body: UpdateProfileEmployee,

View file

@ -1,11 +1,28 @@
import { Body, Controller, Example, Get, Patch, Path, Delete, Post, Request, Route, Security, Tags } from "tsoa";
import {
Body,
Controller,
Example,
Get,
Patch,
Path,
Delete,
Post,
Request,
Route,
Security,
Tags,
} from "tsoa";
import { AppDataSource } from "../database/data-source";
import HttpSuccess from "../interfaces/http-success";
import HttpStatus from "../interfaces/http-status";
import HttpError from "../interfaces/http-error";
import { RequestWithUser } from "../middlewares/user";
import { ProfileEmployee } from "../entities/ProfileEmployee";
import { CreateProfileEmployeeGovernment, ProfileGovernment, UpdateProfileGovernment } from "../entities/ProfileGovernment";
import {
CreateProfileEmployeeGovernment,
ProfileGovernment,
UpdateProfileGovernment,
} from "../entities/ProfileGovernment";
import { EmployeePosition } from "../entities/EmployeePosition";
import { EmployeePosMaster } from "../entities/EmployeePosMaster";
import { calculateAge, calculateRetireDate } from "../interfaces/utils";
@ -95,6 +112,14 @@ export class ProfileGovernmentEmployeeController extends Controller {
posMasterNo: posMaster == null ? null : `${orgShortName} ${posMaster.posMasterNo}`, //เลขที่ตำแหน่ง
posType: record.posType == null ? null : record.posType.posTypeName, //ประเภท
dateLeave: record.birthDate == null ? null : calculateRetireDate(record.birthDate), //วันเกษียณ
dateAppoint: record.dateAppoint, //วันที่สั่งบรรจุ
dateStart: record.dateStart, //วันที่เริ่มปฎิบัติงานราชการ
reasonSameDate: record.reasonSameDate, //เหตุผลที่วันที่ไม่ตรงกัน
dateRetire: record.dateRetire ?? null, //วันครบเกษียณอายุ
govAge: record.dateStart == null ? null : calculateAge(record.dateStart), //อายุราชการ
govAgeAbsent: record.govAgeAbsent ?? null, // ขาดราชการ
govAgePlus: record.govAgePlus, // อายุราชการเกื้อกูล
dateRetireLaw: record.dateRetireLaw ?? null, // วันที่เกษียฯอายุราชการตามกฎหมาย
};
return new HttpSuccess(data);
}
@ -185,4 +210,4 @@ export class ProfileGovernmentEmployeeController extends Controller {
// }
// return new HttpSuccess();
// }
}
}

View file

@ -45,6 +45,44 @@ export class ProfileEmployee extends EntityBase {
})
avatarName: string;
@Column({
nullable: true,
type: "datetime",
comment: "วันที่บรรจุ",
default: null,
})
dateAppoint: Date;
@Column({
nullable: true,
type: "datetime",
comment: "วันที่เริ่มปฏิบัติราชการ",
default: null,
})
dateStart: Date;
@Column({
nullable: true,
comment: "ขาดราชการ",
default: null,
})
govAgeAbsent: number;
@Column({
nullable: true,
comment: "อายุราชการเกื้อกูล",
default: null,
})
govAgePlus: number;
@Column({
nullable: true,
comment: "เหตุผลกรณีวันไม่ตรงกัน",
length: 255,
default: null,
})
reasonSameDate: string;
@Column({
nullable: true,
comment: "ประเภทลูกจ้าง (perm->ลูกจ้างประจำ temp->ลูกจ้างชั่วคราว)",

View file

@ -1,5 +1,5 @@
export function calculateAge(start: Date, end = new Date()) {
if (start.getTime() > end.getTime()) return;
if (start.getTime() > end.getTime()) return null;
let year = end.getFullYear() - start.getFullYear();
let month = end.getMonth() - start.getMonth();

View file

@ -0,0 +1,32 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableGovemployee1715930569091 implements MigrationInterface {
name = 'UpdateTableGovemployee1715930569091'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`profileEmployee\` ADD \`dateAppoint\` datetime NULL COMMENT 'วันที่บรรจุ'`);
await queryRunner.query(`ALTER TABLE \`profileEmployee\` ADD \`dateStart\` datetime NULL COMMENT 'วันที่เริ่มปฏิบัติราชการ'`);
await queryRunner.query(`ALTER TABLE \`profileEmployee\` ADD \`govAgeAbsent\` int NULL COMMENT 'ขาดราชการ'`);
await queryRunner.query(`ALTER TABLE \`profileEmployee\` ADD \`govAgePlus\` int NULL COMMENT 'อายุราชการเกื้อกูล'`);
await queryRunner.query(`ALTER TABLE \`profileEmployee\` ADD \`reasonSameDate\` varchar(255) NULL COMMENT 'เหตุผลกรณีวันไม่ตรงกัน'`);
await queryRunner.query(`ALTER TABLE \`profileEmployeeHistory\` ADD \`dateAppoint\` datetime NULL COMMENT 'วันที่บรรจุ'`);
await queryRunner.query(`ALTER TABLE \`profileEmployeeHistory\` ADD \`dateStart\` datetime NULL COMMENT 'วันที่เริ่มปฏิบัติราชการ'`);
await queryRunner.query(`ALTER TABLE \`profileEmployeeHistory\` ADD \`govAgeAbsent\` int NULL COMMENT 'ขาดราชการ'`);
await queryRunner.query(`ALTER TABLE \`profileEmployeeHistory\` ADD \`govAgePlus\` int NULL COMMENT 'อายุราชการเกื้อกูล'`);
await queryRunner.query(`ALTER TABLE \`profileEmployeeHistory\` ADD \`reasonSameDate\` varchar(255) NULL COMMENT 'เหตุผลกรณีวันไม่ตรงกัน'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`profileEmployeeHistory\` DROP COLUMN \`reasonSameDate\``);
await queryRunner.query(`ALTER TABLE \`profileEmployeeHistory\` DROP COLUMN \`govAgePlus\``);
await queryRunner.query(`ALTER TABLE \`profileEmployeeHistory\` DROP COLUMN \`govAgeAbsent\``);
await queryRunner.query(`ALTER TABLE \`profileEmployeeHistory\` DROP COLUMN \`dateStart\``);
await queryRunner.query(`ALTER TABLE \`profileEmployeeHistory\` DROP COLUMN \`dateAppoint\``);
await queryRunner.query(`ALTER TABLE \`profileEmployee\` DROP COLUMN \`reasonSameDate\``);
await queryRunner.query(`ALTER TABLE \`profileEmployee\` DROP COLUMN \`govAgePlus\``);
await queryRunner.query(`ALTER TABLE \`profileEmployee\` DROP COLUMN \`govAgeAbsent\``);
await queryRunner.query(`ALTER TABLE \`profileEmployee\` DROP COLUMN \`dateStart\``);
await queryRunner.query(`ALTER TABLE \`profileEmployee\` DROP COLUMN \`dateAppoint\``);
}
}