diff --git a/src/controllers/DevelopmentController.ts b/src/controllers/DevelopmentController.ts index 0a48802..154e511 100644 --- a/src/controllers/DevelopmentController.ts +++ b/src/controllers/DevelopmentController.ts @@ -2189,9 +2189,15 @@ export class DevelopmentController extends Controller { reasonActual70: getDevelopment.reasonActual70, reasonActual20: getDevelopment.reasonActual20, reasonActual10: getDevelopment.reasonActual10, + isReasonActual70: getDevelopment.isReasonActual70, + isReasonActual20: getDevelopment.isReasonActual20, + isReasonActual10: getDevelopment.isReasonActual10, reasonPlanned70: getDevelopment.reasonPlanned70, reasonPlanned20: getDevelopment.reasonPlanned20, reasonPlanned10: getDevelopment.reasonPlanned10, + isReasonPlanned70: getDevelopment.isReasonPlanned70, + isReasonPlanned20: getDevelopment.isReasonPlanned20, + isReasonPlanned10: getDevelopment.isReasonPlanned10, developmentProjectTechniqueActuals: getDevelopment.developmentProjectTechniqueActuals .map((x) => x.name) .sort(), @@ -2244,6 +2250,9 @@ export class DevelopmentController extends Controller { reasonActual70: getDevelopment.reasonActual70, reasonActual20: getDevelopment.reasonActual20, reasonActual10: getDevelopment.reasonActual10, + isReasonActual70: getDevelopment.isReasonActual70, + isReasonActual20: getDevelopment.isReasonActual20, + isReasonActual10: getDevelopment.isReasonActual10, developmentProjectTechniqueActuals: getDevelopment.developmentProjectTechniqueActuals .map((x) => x.name) .sort(), @@ -2344,6 +2353,7 @@ export class DevelopmentController extends Controller { relations: ["posLevel", "posType", "employeePosLevel", "employeePosType"], order: { isDone: "ASC", + isDoneIDP: "ASC", citizenId: "ASC", }, }); @@ -2380,6 +2390,7 @@ export class DevelopmentController extends Controller { dateStart: item.dateStart, dateEnd: item.dateEnd, isDone: item.isDone, + isDoneIDP: item.isDoneIDP, isProfile: item.isProfile, })); return new HttpSuccess(_getDevelopment); @@ -2461,6 +2472,96 @@ export class DevelopmentController extends Controller { return new HttpSuccess(getDevelopment); } + /** + * API รายละเอียดโครงการ/หลักสูตรการฝึกอบรม tab6 IDP ส่งบันทึกทะเบียนประวัติ + * + * @summary DEV_00 - รายละเอียดโครงการ/หลักสูตรการฝึกอบรมtab6 IDP ส่งบันทึกทะเบียนประวัติ # + * + * @param {string} id Id โครงการ + */ + @Get("tab6/done-idp/{id}") + async GetDevelopemtTab6IDPDoneById(@Path() id: string, @Request() request: RequestWithUser) { + const getDevelopment = await this.developmentHistoryRepository.find({ + where: { developmentId: id, isDoneIDP: false }, + relations: ["development", "development.developmentProjectTechniqueActuals"], + }); + await Promise.all( + getDevelopment.map(async (x) => { + const _data = Object.assign(new DevelopmentHistory(), x); + if (x.type == "OFFICER") { + await new CallAPI() + .PostData(request, "/org/profile/development", { + type: "DEVELOP", + profileId: x.profileId, + name: x.development.projectName, + achievement10: null, + achievement5: null, + achievement0: null, + kpiDevelopmentId: x.development.id, + reasonDevelopment70: x.development.reasonActual70, + reasonDevelopment20: x.development.reasonActual20, + reasonDevelopment10: x.development.reasonActual10, + isDevelopment70: x.development.isReasonActual70, + isDevelopment20: x.development.isReasonActual20, + isDevelopment10: x.development.isReasonActual10, + developmentTarget: null, + developmentResults: null, + developmentReport: null, + developmentProjects: x.development.developmentProjectTechniqueActuals.map( + (x) => x.name, + ), + }) + .then((x) => { + _data.isDoneIDP = true; + }) + .catch((x) => { + _data.isDoneIDP = false; + }); + } else if (x.type == "EMPLOYEE") { + await new CallAPI() + .PostData(request, "/org/profile-employee/development", { + type: "DEVELOP", + profileEmployeeId: x.profileId, + name: x.development.projectName, + achievement10: null, + achievement5: null, + achievement0: null, + kpiDevelopmentId: x.development.id, + reasonDevelopment70: x.development.reasonActual70, + reasonDevelopment20: x.development.reasonActual20, + reasonDevelopment10: x.development.reasonActual10, + isDevelopment70: false, + isDevelopment20: false, + isDevelopment10: false, + developmentTarget: null, + developmentResults: null, + developmentReport: null, + developmentProjects: x.development.developmentProjectTechniqueActuals.map( + (x) => x.name, + ), + }) + .then((x) => { + _data.isDoneIDP = true; + }) + .catch((x) => { + _data.isDoneIDP = false; + }); + } + + _data.lastUpdateUserId = request.user.sub; + _data.lastUpdateFullName = request.user.name; + _data.lastUpdatedAt = new Date(); + // addLogSequence(request, { + // action: "database", + // status: "success", + // description: "Store DevelopmentHistory.", + // }); + await this.developmentHistoryRepository.save(_data, { data: request }); + }), + ); + return new HttpSuccess(getDevelopment); + } + /** * API list หน่วยงาน * @@ -2634,7 +2735,10 @@ export class DevelopmentController extends Controller { }); } else if (item["ประเภท"] == "ลูกจ้างประจำ") { await new CallAPI() - .GetData(request, `/org/unauthorize/employee-prem/citizen/${item["รหัสประจำตัวประชาชน"]}`) + .GetData( + request, + `/org/unauthorize/employee-prem/citizen/${item["รหัสประจำตัวประชาชน"]}`, + ) .then(async (x: any) => { let development = Object.assign(new DevelopmentHistory(), x); development.dateStart = diff --git a/src/entities/Development.ts b/src/entities/Development.ts index eb4b00e..b807734 100644 --- a/src/entities/Development.ts +++ b/src/entities/Development.ts @@ -294,6 +294,24 @@ export class Development extends EntityBase { }) reasonPlanned10: string; + @Column({ + comment: "รายละเอียดอื่นๆ 70 แผน", + default: false, + }) + isReasonPlanned70: boolean; + + @Column({ + comment: "รายละเอียดอื่นๆ 20 แผน", + default: false, + }) + isReasonPlanned20: boolean; + + @Column({ + comment: "รายละเอียดอื่นๆ 10 แผน", + default: false, + }) + isReasonPlanned10: boolean; + @OneToMany( () => DevelopmentProjectTechniquePlanned, (developmentProjectTechniquePlanned: DevelopmentProjectTechniquePlanned) => @@ -322,6 +340,24 @@ export class Development extends EntityBase { }) reasonActual10: string; + @Column({ + comment: "รายละเอียดอื่นๆ 70 จริง", + default: false, + }) + isReasonActual70: boolean; + + @Column({ + comment: "รายละเอียดอื่นๆ 20 จริง", + default: false, + }) + isReasonActual20: boolean; + + @Column({ + comment: "รายละเอียดอื่นๆ 10 จริง", + default: false, + }) + isReasonActual10: boolean; + @OneToMany( () => DevelopmentProjectTechniqueActual, (developmentProjectTechniqueActual: DevelopmentProjectTechniqueActual) => @@ -775,6 +811,12 @@ export class UpdateDevelopment3 { @Column() reasonPlanned10?: string; @Column() + isReasonPlanned70?: string; + @Column() + isReasonPlanned20?: string; + @Column() + isReasonPlanned10?: string; + @Column() isBackActual?: boolean | null; @Column() isHoldActual?: boolean | null; @@ -793,6 +835,12 @@ export class UpdateDevelopment3 { @Column() reasonActual10?: string; @Column() + isReasonActual70?: boolean; + @Column() + isReasonActual20?: boolean; + @Column() + isReasonActual10?: boolean; + @Column() strategyChildPlannedId?: string | null; @Column() strategyChildPlannedNode?: number | null; @@ -810,7 +858,6 @@ export class UpdateDevelopment4 { @Column() projectEvaluation: string | null; //end - } export class UpdateDevelopment5 { //new @@ -866,7 +913,7 @@ export class UpdateDevelopment8_1 { //end } -export class UpdateDevelopment8{ +export class UpdateDevelopment8 { @Column() expect: string | null; -} \ No newline at end of file +} diff --git a/src/entities/DevelopmentHistory.ts b/src/entities/DevelopmentHistory.ts index f283e28..eeb61a1 100644 --- a/src/entities/DevelopmentHistory.ts +++ b/src/entities/DevelopmentHistory.ts @@ -216,6 +216,12 @@ export class DevelopmentHistory extends EntityBase { }) isDone: boolean; + @Column({ + comment: "บันทึก IDP ที่ทะเบียนประวัติ", + default: false, + }) + isDoneIDP: boolean; + @Column({ comment: "มีข้อมูลอยู่ในทะเบียนประวัติ", default: false, @@ -320,4 +326,3 @@ export class CreateDevelopmentHistoryOBO { @Column() dateEnd: Date | null; } - diff --git a/src/interfaces/call-api.ts b/src/interfaces/call-api.ts index f3d1b6f..711dc95 100644 --- a/src/interfaces/call-api.ts +++ b/src/interfaces/call-api.ts @@ -1,16 +1,4 @@ -import { - Controller, - Request, - Get, - Post, - Put, - Delete, - Patch, - Route, - Security, - Tags, - Path, -} from "tsoa"; +import { Path } from "tsoa"; import axios from "axios"; import { addLogSequence } from "./utils"; diff --git a/src/migration/1723605750693-import0508241320.ts b/src/migration/1723605750693-import0508241320.ts deleted file mode 100644 index 97a5c4b..0000000 --- a/src/migration/1723605750693-import0508241320.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class Import05082413201723605750693 implements MigrationInterface { - name = 'Import05082413201723605750693' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`CREATE TABLE \`developmentRisk\` (\`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', \`issues\` varchar(255) NULL COMMENT 'ประเด็นความเสี่ยง', \`chance\` int NULL COMMENT 'โอกาสที่จะเกิด', \`effects\` int NULL COMMENT 'ผลกระทบจากการเกิด', \`riskLevel\` varchar(255) NULL COMMENT 'ระดับความเสี่ยง', \`riskManagement\` varchar(255) NULL COMMENT 'เเนวทางการบริหารความเสี่ยง', \`developmentId\` varchar(255) NULL COMMENT 'คีย์นอก(FK)ของตาราง development', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); - await queryRunner.query(`CREATE TABLE \`developmentOther\` (\`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', \`topicAcademic\` varchar(255) NULL COMMENT 'หัวข้อ/ประเด็นการฝึกอบรม ศึกษาดูงาน', \`addressAcademic\` varchar(255) NULL COMMENT 'สถานที่ฝึกอบรม ศึกษาดูงาน', \`provinceActualId\` varchar(255) NULL COMMENT 'จังหวัด(ข้อมูลวิชาการ)', \`developmentId\` varchar(255) NULL COMMENT 'คีย์นอก(FK)ของตาราง development', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`progressTracking\` longtext NULL COMMENT 'การติดตามความก้าวหน้า'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`projectEvaluation\` longtext NULL COMMENT 'การประเมินผลโครงการ'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`obstacle\` longtext NULL COMMENT 'ปัญหาอุปสรรค'`); - await queryRunner.query(`ALTER TABLE \`development\` ADD \`suggestion\` longtext NULL COMMENT 'ข้อเสนอแนะ'`); - await queryRunner.query(`ALTER TABLE \`developmentRisk\` ADD CONSTRAINT \`FK_b1990ff92f534f65a4653ef1671\` FOREIGN KEY (\`developmentId\`) REFERENCES \`development\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE \`developmentOther\` ADD CONSTRAINT \`FK_d5dfdb7ca0d11c0cdf3b3a55e6f\` FOREIGN KEY (\`developmentId\`) REFERENCES \`development\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`developmentOther\` DROP FOREIGN KEY \`FK_d5dfdb7ca0d11c0cdf3b3a55e6f\``); - await queryRunner.query(`ALTER TABLE \`developmentRisk\` DROP FOREIGN KEY \`FK_b1990ff92f534f65a4653ef1671\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`suggestion\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`obstacle\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`projectEvaluation\``); - await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`progressTracking\``); - await queryRunner.query(`DROP TABLE \`developmentOther\``); - await queryRunner.query(`DROP TABLE \`developmentRisk\``); - } - -} diff --git a/src/migration/1727719189429-update_developmentHis_add_isDoneIDP.ts b/src/migration/1727719189429-update_developmentHis_add_isDoneIDP.ts new file mode 100644 index 0000000..c577bb8 --- /dev/null +++ b/src/migration/1727719189429-update_developmentHis_add_isDoneIDP.ts @@ -0,0 +1,14 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class UpdateDevelopmentHisAddIsDoneIDP1727719189429 implements MigrationInterface { + name = 'UpdateDevelopmentHisAddIsDoneIDP1727719189429' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD \`isDoneIDP\` tinyint NOT NULL COMMENT 'บันทึก IDP ที่ทะเบียนประวัติ' DEFAULT 0`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP COLUMN \`isDoneIDP\``); + } + +} diff --git a/src/migration/1727753251629-update_development_add_isReasonActual70.ts b/src/migration/1727753251629-update_development_add_isReasonActual70.ts new file mode 100644 index 0000000..32c8f84 --- /dev/null +++ b/src/migration/1727753251629-update_development_add_isReasonActual70.ts @@ -0,0 +1,24 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class UpdateDevelopmentAddIsReasonActual701727753251629 implements MigrationInterface { + name = 'UpdateDevelopmentAddIsReasonActual701727753251629' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`development\` ADD \`isReasonPlanned70\` tinyint NOT NULL COMMENT 'รายละเอียดอื่นๆ 70 แผน' DEFAULT 0`); + await queryRunner.query(`ALTER TABLE \`development\` ADD \`isReasonPlanned20\` tinyint NOT NULL COMMENT 'รายละเอียดอื่นๆ 20 แผน' DEFAULT 0`); + await queryRunner.query(`ALTER TABLE \`development\` ADD \`isReasonPlanned10\` varchar(255) NULL COMMENT 'รายละเอียดอื่นๆ 10 แผน'`); + await queryRunner.query(`ALTER TABLE \`development\` ADD \`isReasonActual70\` tinyint NOT NULL COMMENT 'รายละเอียดอื่นๆ 70 จริง' DEFAULT 0`); + await queryRunner.query(`ALTER TABLE \`development\` ADD \`isReasonActual20\` tinyint NOT NULL COMMENT 'รายละเอียดอื่นๆ 20 จริง' DEFAULT 0`); + await queryRunner.query(`ALTER TABLE \`development\` ADD \`isReasonActual10\` varchar(255) NULL COMMENT 'รายละเอียดอื่นๆ 10 จริง'`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`isReasonActual10\``); + await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`isReasonActual20\``); + await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`isReasonActual70\``); + await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`isReasonPlanned10\``); + await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`isReasonPlanned20\``); + await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`isReasonPlanned70\``); + } + +} diff --git a/src/migration/1727755044851-update_development_add_isReasonActual10.ts b/src/migration/1727755044851-update_development_add_isReasonActual10.ts new file mode 100644 index 0000000..a5a0c33 --- /dev/null +++ b/src/migration/1727755044851-update_development_add_isReasonActual10.ts @@ -0,0 +1,20 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class UpdateDevelopmentAddIsReasonActual101727755044851 implements MigrationInterface { + name = 'UpdateDevelopmentAddIsReasonActual101727755044851' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`isReasonPlanned10\``); + await queryRunner.query(`ALTER TABLE \`development\` ADD \`isReasonPlanned10\` tinyint NOT NULL COMMENT 'รายละเอียดอื่นๆ 10 แผน' DEFAULT 0`); + await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`isReasonActual10\``); + await queryRunner.query(`ALTER TABLE \`development\` ADD \`isReasonActual10\` tinyint NOT NULL COMMENT 'รายละเอียดอื่นๆ 10 จริง' DEFAULT 0`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`isReasonActual10\``); + await queryRunner.query(`ALTER TABLE \`development\` ADD \`isReasonActual10\` varchar(255) NULL COMMENT 'รายละเอียดอื่นๆ 10 จริง'`); + await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`isReasonPlanned10\``); + await queryRunner.query(`ALTER TABLE \`development\` ADD \`isReasonPlanned10\` varchar(255) NULL COMMENT 'รายละเอียดอื่นๆ 10 แผน'`); + } + +}