No description
Find a file
Suphonchai Phoonsawat 4dab3c5cd9
All checks were successful
Build & Deploy Leave Service / build (push) Successful in 1m52s
fix report leaave
2026-05-01 16:47:34 +07:00
.forgejo/workflows rollback 2026-01-11 21:10:24 +07:00
.github/workflows add noti discord 2026-01-09 18:43:59 +07:00
.vscode Add Insignia launch configuration and improve null checks in InsigniaRequestController #2388 2026-04-02 11:36:59 +07:00
BMA.EHR.API.Document fix defect การลบรอบการปฏิบัติงาน 2023-12-21 09:40:19 +07:00
BMA.EHR.Application fix issue 2026-05-01 16:38:47 +07:00
BMA.EHR.CheckInConsumer สิ่งที่แก้ไข: 2026-04-30 22:02:59 +07:00
BMA.EHR.Command.Service fix การใช้งาน middleware 2025-06-24 10:47:54 +07:00
BMA.EHR.Discipline.Service ปรับให้เป็น process ที่ควรบันทึกตามลำดับ #224 2026-05-01 11:20:15 +07:00
BMA.EHR.Domain เพิ่ม DateSendLeave และปรับ Logic การดึงค่าวันที่ยื่นลา #1567 2026-04-23 15:48:20 +07:00
BMA.EHR.Infrastructure เพิ่ม DateSendLeave และปรับ Logic การดึงค่าวันที่ยื่นลา #1567 2026-04-23 15:48:20 +07:00
BMA.EHR.Insignia Refactor user profile retrieval method in InsigniaRequestController #2390 2026-04-03 12:17:39 +07:00
BMA.EHR.Leave fix report leaave 2026-05-01 16:47:34 +07:00
BMA.EHR.MetaData.Service fix การใช้งาน middleware 2025-06-24 10:47:54 +07:00
BMA.EHR.OrganizationEmployee.Service fix การใช้งาน middleware 2025-06-24 10:47:54 +07:00
BMA.EHR.Placement.Service ปรับให้เป็น process ที่ควรบันทึกตามลำดับ #224 2026-05-01 11:20:15 +07:00
BMA.EHR.Report.Service fix error 2025-09-09 17:30:03 +07:00
BMA.EHR.Retirement.Service ปรับให้เป็น process ที่ควรบันทึกตามลำดับ #224 2026-05-01 11:20:15 +07:00
LinkageResponseTest LK 2024-09-30 09:21:35 +07:00
.dockerignore แก้ไข 2025-04-24 10:59:31 +07:00
.gitattributes Add .gitattributes and .gitignore. 2023-06-05 20:22:49 +07:00
.gitignore ปรับ Middleware โดยรวม Exception + LogWriter ไว้ด้วยกัน 2025-06-24 10:42:11 +07:00
.onedev-buildspec.yml add Insignia CI 2024-12-16 09:17:05 +00:00
BMA.EHR.Solution.sln LK 2024-09-30 09:21:35 +07:00
checkin_load_test.js feat: Change RAbbitMQ Conenction to Pool and Add k6 Test Script for max request per second. 2024-08-20 10:37:47 +07:00
checkin_load_test_expand.js add new Load Test Script 2024-08-20 20:39:06 +07:00
dotnet_keycloak_test.js Add delay to start message consumption until 8:10 AM and implement time calculation 2026-01-19 22:42:39 +07:00
dotnet_leave_test.js Add cancellation token support and extend timeout to 30 minutes for external API calls 2026-01-30 13:35:58 +07:00
Doxyfile_Backend Generate New Dev Document 2023-12-15 12:00:42 +07:00
README.md fix issue 2026-05-01 16:38:47 +07:00

BMA.EHR - HRMS API Backend

ระบบบริหารจัดการทรัพยากรบุคคล (Human Resource Management System) พัฒนาด้วยสถาปัตยกรรม Microservices บน .NET


Tech Stack

Category Technology
Framework .NET 6.0 / 7.0 / 8.0
Architecture Clean Architecture, DDD, CQRS
Database MySQL (Entity Framework Core)
Authentication JWT + Keycloak
Message Queue RabbitMQ
Object Storage MinIO
Background Jobs Hangfire
Logging Serilog + Elasticsearch
Error Tracking Sentry
API Documentation Swagger / OpenAPI
Containerization Docker
Testing xUnit, k6 (Load Testing)

โครงสร้างโปรเจกต์ (Project Structure)

BMA.EHR.Solution.sln
├── src/                                    # Core Libraries
│   ├── BMA.EHR.Domain/                     # Domain layer (Entities, Business Rules)
│   ├── BMA.EHR.Application/                # Application layer (Use Cases, Interfaces)
│   └── BMA.EHR.Infrastructure/             # Infrastructure layer (Data Access, External Services)
│
└── Service/                                # Microservices
    ├── BMA.EHR.Command.Service/             # Command/CQRS API Gateway
    ├── BMA.EHR.MetaData.Service/            # ข้อมูลอ้างอิง (คำนำหน้า, หมู่เลือด, ศาสนา ฯลฯ)
    ├── BMA.EHR.Placement.Service/           # การบริจาค/สั่งย้าย/แต่งตั้ง
    ├── BMA.EHR.OrganizationEmployee.Service/ # โครงสร้างองค์กรและบุคลากร
    ├── BMA.EHR.Discipline.Service/          # การ discipline บุคลากร
    ├── BMA.EHR.Retirement.Service/          # การเกษียณอายุราชการ
    ├── BMA.EHR.Report.Service/              # รายงาน
    ├── BMA.EHR.Insignia/                    # เครื่องราชอิสริยาภรณ์
    ├── BMA.EHR.Leave/                       # ระบบลา
    └── BMA.EHR.CheckInConsumer/             # ลงเวลาปฏิบัติงาน

โมดูลหลัก (Key Modules)

การบริหารทรัพยากรบุคคล

  • Placement Service - สั่งย้าย, แต่งตั้ง, เลื่อนตำแหน่ง, โอนย้ายบุคลากร
  • Organization Employee Service - จัดการโครงสร้างองค์กร, ตำแหน่ง, ข้อมูลบุคลากร
  • Leave Service - การลางาน, การอนุมัติ, วันหยุดนักขัตฤกษ์, ยอดวันลาคงเหลือ
  • Discipline Service - การดำเนินการ discipline, การสืบสวน, เอกสารที่เกี่ยวข้อง
  • Retirement Service - การเกษียณอายุ, เอกสาร, สิทธิประโยชน์
  • Insignia Service - เครื่องราชอิสริยาภรณ์และรางวัล
  • CheckIn Consumer - ติดตามการลงเวลาปฏิบัติงาน

ระบบสนับสนุน

  • Metadata Service - ข้อมูลอ้างอิง (คำนำหน้าชื่อ, หมู่เลือด, ศาสนา, ระดับการศึกษา ฯลฯ)
  • Report Service - สร้างรายงาน PDF/Excel
  • Command Service - API Gateway สำหรับ CQRS command operations

ฟีเจอร์เด่น

  • Real-time Notifications - แจ้งเตือนผ่าน WebSocket
  • Background Processing - งานที่กำหนดเวลาผ่าน Hangfire
  • Event-Driven Communication - สื่อสารระหว่าง services ผ่าน RabbitMQ
  • Document Generation - สร้างเอกสาร PDF/Excel
  • Audit Trail - บันทึกประวัติการเปลี่ยนแปลงข้อมูลทั้งหมด

API Endpoints

API ใช้ versioning และสามารถดูรายละเอียดได้ผ่าน Swagger UI:

/api/v1/placement       # การบริจาค/สั่งย้าย/แต่งตั้ง
/api/v1/leave           # ระบบลา
/api/v1/discipline      # การ discipline
/api/v1/organization    # โครงสร้างองค์กร
/api/v1/metadata        # ข้อมูลอ้างอิง
/api/v1/retirement      # การเกษียณอายุ
/api/v1/insignia        # เครื่องราชอิสริยาภรณ์
/api/v1/reports         # รายงาน

Getting Started

Prerequisites

  • .NET SDK 6.0 / 7.0 / 8.0
  • MySQL Server
  • Keycloak (Authentication Server)
  • RabbitMQ
  • MinIO (Object Storage)
  • Docker (สำหรับ deployment)

Configuration

แต่ละ service มีไฟล์ appsettings.json สำหรับ config ดังนี้:

  • JWT Authentication - เชื่อมต่อกับ Keycloak
  • Database Connection - MySQL connection string
  • RabbitMQ - Message queue connection
  • MinIO - File storage endpoint
  • Elasticsearch - Logging endpoint
  • Mail Server - สำหรับส่งอีเมล

Build & Run

# Restore dependencies
dotnet restore

# Build solution
dotnet build

# Run specific service
dotnet run --project Service/BMA.EHR.Command.Service

Docker

# Build Docker image
docker build -t bma-ehr-service .

# Run container
docker run -d -p 5000:80 bma-ehr-service

Architecture

┌──────────────┐     ┌──────────────┐     ┌──────────────┐
│   Swagger    │     │   Client     │     │   WebSocket  │
│   UI         │     │   Apps       │     │   Clients    │
└──────┬───────┘     └──────┬───────┘     └──────┬───────┘
       │                    │                    │
       └────────────────────┼────────────────────┘
                            │
                   ┌────────▼────────┐
                   │  API Gateway    │
                   │  (Keycloak JWT) │
                   └────────┬────────┘
                            │
       ┌────────────────────┼────────────────────┐
       │                    │                    │
┌──────▼──────┐   ┌────────▼──────┐   ┌────────▼──────┐
│  Placement  │   │    Leave      │   │  Discipline   │
│  Service    │   │    Service    │   │  Service      │
└──────┬──────┘   └────────┬──────┘   └────────┬──────┘
       │                    │                    │
       └────────────────────┼────────────────────┘
                            │
              ┌─────────────▼──────────────┐
              │       MySQL Database       │
              │    (Entity Framework)      │
              └────────────────────────────┘

              ┌────────────────────────────┐
              │   RabbitMQ / MinIO /       │
              │   Elasticsearch / Hangfire │
              └────────────────────────────┘

Dependencies ที่สำคัญ

Package หน้าที่
Entity Framework Core ORM สำหรับ MySQL
Serilog Structured Logging
Swashbuckle API Documentation
Hangfire Background Job Processing
EPPlus สร้าง/อ่านไฟล์ Excel
iTextSharp สร้างไฟล์ PDF
RabbitMQ.Client Message Queue
NEST Elasticsearch Client
ThaiBahtText แปลงตัวเลขเป็นหน่วยบาทไทย
NodaTime Date/Time Handling
Sentry Error Tracking

Testing

# Run unit tests
dotnet test

# Run with coverage
dotnet test --collect:"XPlat Code Coverage"

# Run load tests (k6)
k6 run tests/load/*.js