251218:1701 On going update to 1.7.0: Documnet Number rebuild
Some checks are pending
Spec Validation / validate-markdown (push) Waiting to run
Spec Validation / validate-diagrams (push) Waiting to run
Spec Validation / check-todos (push) Waiting to run

This commit is contained in:
admin
2025-12-18 17:01:42 +07:00
parent aaa5da3ec1
commit 83704377f4
102 changed files with 3385 additions and 1451 deletions

View File

@@ -28,48 +28,48 @@ related:
## 3.1 การจัดการโครงสร้างโครงการและองค์กร (Project Management)
[specs/01-requirements/03.1-project-management.md](./03.1-project-management.md)
[specs/01-requirements/03.1-project-management.md](01-03.1-project-management.md)
## 3.2 การจัดการเอกสารโครงการ (Correspondence)
[specs/01-requirements/03.2-correspondence.md](./03.2-correspondence.md)
[specs/01-requirements/03.2-correspondence.md](01-03.2-correspondence.md)
## 3.3 การจัดการเอกสารโครงการ (RFA)
[specs/01-requirements/03.3-rfa.md](./03.3-rfa.md)
[specs/01-requirements/03.3-rfa.md](01-03.3-rfa.md)
## 3.4 การจัดการแบบคู่สัญญา (Contract Drawing)
[specs/01-requirements/03.4-contract-drawing.md](./03.4-contract-drawing.md)
[specs/01-requirements/03.4-contract-drawing.md](01-03.4-contract-drawing.md)
## 3.5 การจัดกาแบบก่อสร้าง (Shop Drawing)
[specs/01-requirements/03.5-shop-drawing.md](./03.5-shop-drawing.md)
[specs/01-requirements/03.5-shop-drawing.md](01-03.5-shop-drawing.md)
## 3.6 การจัดการ Workflow (Unified Workflow)
[specs/01-requirements/03.6-unified-workflow.md](./03.6-unified-workflow.md)
[specs/01-requirements/03.6-unified-workflow.md](01-03.6-unified-workflow.md)
## 3.7 การจัดการเอกสารนำส่ง (Transmittals)
[specs/01-requirements/03.7-transmittals.md](./03.7-transmittals.md)
[specs/01-requirements/03.7-transmittals.md](01-03.7-transmittals.md)
## 3.8 การจัดการใบเวียนเอกสาร (Circulation Sheet)
[specs/01-requirements/03.8-circulation-sheet.md](./03.8-circulation-sheet.md)
[specs/01-requirements/03.8-circulation-sheet.md](01-03.8-circulation-sheet.md)
## 3.9 ประวัติการแก้ไข (logs)
[specs/01-requirements/03.9-logs.md](./03.9-logs.md)
[specs/01-requirements/03.9-logs.md](01-03.9-logs.md)
## 3.10 การจัดเก็บไฟล์ (File Handling)
[specs/01-requirements/03.10-file-handling.md](./03.10-file-handling.md)
[specs/01-requirements/03.10-file-handling.md](01-03.10-file-handling.md)
## 3.11 การจัดการเลขที่เอกสาร (Document Numbering)
[specs/01-requirements/03.11-document-numbering.md](./03.11-document-numbering.md)
[specs/01-requirements/03.11-document-numbering.md](01-03.11-document-numbering.md)
## 3.12 การจัดการ JSON Details (JSON & Performance - ปรับปรุง)
[specs/01-requirements/03.12-json-details.md](./03.12-json-details.md)
[specs/01-requirements/03.12-json-details.md](01-03.12-json-details.md)

View File

@@ -7,13 +7,14 @@ status: draft
owner: Nattanin Peancharoen
last_updated: 2025-12-17
related:
- specs/01-requirements/01-objectives.md
- specs/01-requirements/02-architecture.md
- specs/01-requirements/03unctional-requirements.md
- specs/03-implementation/document-numbering.md
- specs/04-operations/document-numbering-operations.md
- specs/04-data-dictionary/4_Data_Dictionary_V1_4_4.md
- specs/05-decisions/adr-018-document-numbering.md
- specs/01-requirements/01-01-objectives.md
- specs/01-requirements/01-02-architecture.md
- specs/01-requirements/01-03-functional-requirements.md
- specs/01-requirements/01-03.11-document-numbering.md
- specs/03-implementation/03-04-document-numbering.md
- specs/04-operations/04-08-document-numbering-operations.md
- specs/07-database/07-01-data-dictionary-v1.7.0.md
- specs/05-decisions/ADR-002-document-numbering-strategy.md
Clean Version v1.6.2 Scope of Changes:
- เลือกใช้ Single Numbering System (Option A)
- แก้ Primary Key design ให้ implement ได้จริง
@@ -27,8 +28,8 @@ Clean Version v1.6.2 Scope of Changes:
> **📖 เอกสารที่เกี่ยวข้อง**
>
> - **Implementation Guide**: [document-numbering.md](file:///d:/nap-dms.lcbp3/specs/03-implementation/document-numbering.md) - รายละเอียดการ implement ด้วย NestJS, TypeORM, Redis
> - **Operations Guide**: [document-numbering-operations.md](file:///d:/nap-dms.lcbp3/specs/04-operations/document-numbering-operations.md) - Monitoring, Troubleshooting, Maintenance Procedures
> - **Implementation Guide**: [03-implementation/03-04-document-numbering.md](../03-implementation/03-04-document-numbering.md) - รายละเอียดการ implement ด้วย NestJS, TypeORM, Redis
> - **Operations Guide**: [04-operations/04-08-document-numbering-operations.md](../04-operations/04-08-document-numbering-operations.md) - Monitoring, Troubleshooting, Maintenance Procedures
---
@@ -638,16 +639,17 @@ DIGIT := "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
```sql
CREATE TABLE document_number_counters (
project_id INT NOT NULL,
correspondence_type_id INT NULL,-- NULL = default format for project
originator_organization_id INT NOT NULL,
recipient_organization_id INT NOT NULL DEFAULT 0, -- 0 = no recipient (RFA)
correspondence_type_id INT NOT NULL,
sub_type_id INT DEFAULT 0,
rfa_type_id INT DEFAULT 0,
discipline_id INT DEFAULT 0,
reset_scope VARCHAR(20) NOT NULL,
last_number INT DEFAULT 0 NOT NULL,
version INT DEFAULT 0 NOT NULL,
created_at DATETIME(6) DEFAULT CURRENT_TIMESTAMP(6),
updated_at DATETIME(6) DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
PRIMARY KEY (
project_id,
originator_organization_id,
@@ -661,7 +663,6 @@ CREATE TABLE document_number_counters (
FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE,
FOREIGN KEY (originator_organization_id) REFERENCES organizations(id) ON DELETE CASCADE,
FOREIGN KEY (recipient_organization_id) REFERENCES organizations(id) ON DELETE CASCADE,
FOREIGN KEY (correspondence_type_id) REFERENCES correspondence_types(id) ON DELETE CASCADE
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci
COMMENT = 'ตารางเก็บ Running Number Counters';
@@ -691,6 +692,12 @@ ON document_number_counters (
originator_organization_id,
reset_scope
);
-- Index สำหรับ updated_at
CREATE INDEX idx_counter_updated
ON document_number_counters (
updated_at
);
```
### 3.11.11.3 Numbering Configuration Table
@@ -715,28 +722,93 @@ CREATE TABLE document_numbering_configs (
CREATE TABLE document_number_audit (
id BIGINT AUTO_INCREMENT PRIMARY KEY,
document_id INT NOT NULL,
generated_number VARCHAR(100) NOT NULL,
document_type VARCHAR(50),
document_number VARCHAR(100) NOT NULL,
operation ENUM('RESERVE', 'CONFIRM', 'CANCEL', 'MANUAL_OVERRIDE', 'VOID', 'GENERATE') NOT NULL,
status ENUM('RESERVED', 'CONFIRMED', 'CANCELLED', 'VOID', 'MANUAL'),
counter_key JSON NOT NULL COMMENT 'Counter key used (JSON format)',
reservation_token VARCHAR(36) NULL,
originator_organization_id INT NULL,
recipient_organization_id INT NULL,
template_used VARCHAR(200) NOT NULL,
old_value TEXT NULL,
new_value TEXT NULL,
user_id INT NOT NULL,
ip_address VARCHAR(45),
user_agent TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
is_success BOOLEAN DEFAULT TRUE,
-- Performance & Error Tracking
retry_count INT DEFAULT 0,
lock_wait_ms INT COMMENT 'Lock acquisition time in milliseconds',
total_duration_ms INT COMMENT 'Total generation time',
fallback_used ENUM('NONE', 'DB_LOCK', 'RETRY') DEFAULT 'NONE',
metadata JSON NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
INDEX idx_document_id (document_id),
INDEX idx_user_id (user_id),
INDEX idx_status (status),
INDEX idx_operation (operation),
INDEX idx_document_number (document_number),
INDEX idx_reservation_token (reservation_token);
INDEX idx_created_at (created_at),
FOREIGN KEY (document_id) REFERENCES documents(id) ON DELETE CASCADE,
FOREIGN KEY (user_id) REFERENCES users(id)
) ENGINE=InnoDB COMMENT='Document Number Generation Audit Trail';
```
### 3.11.11.5 Reservation Table
```sql
CREATE TABLE document_number_reservations (
id BIGINT AUTO_INCREMENT PRIMARY KEY,
-- Reservation Details
token VARCHAR(36) NOT NULL UNIQUE COMMENT 'UUID v4',
document_number VARCHAR(100) NOT NULL UNIQUE,
status ENUM('RESERVED', 'CONFIRMED', 'CANCELLED', 'VOID') NOT NULL DEFAULT 'RESERVED',
-- Linkage
document_id INT NULL COMMENT 'FK to documents (NULL until confirmed)',
-- Context (for debugging)
project_id INT NOT NULL,
correspondence_type_id INT NOT NULL,
originator_organization_id INT NOT NULL,
recipient_organization_id INT DEFAULT 0,
user_id INT NOT NULL,
-- Timestamps
reserved_at DATETIME(6) DEFAULT CURRENT_TIMESTAMP(6),
expires_at DATETIME(6) NOT NULL,
confirmed_at DATETIME(6) NULL,
cancelled_at DATETIME(6) NULL,
-- Audit
ip_address VARCHAR(45),
user_agent TEXT,
metadata JSON NULL COMMENT 'Additional context',
-- Indexes
INDEX idx_token (token),
INDEX idx_status (status),
INDEX idx_status_expires (status, expires_at),
INDEX idx_document_id (document_id),
INDEX idx_user_id (user_id),
INDEX idx_reserved_at (reserved_at),
-- Foreign Keys
FOREIGN KEY (document_id) REFERENCES documents(id) ON DELETE SET NULL,
FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE,
FOREIGN KEY (correspondence_type_id) REFERENCES correspondence_types(id) ON DELETE CASCADE,
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
COMMENT='Document Number Reservations - Two-Phase Commit';
```
### 3.11.11.5 Error Log Table
```sql
@@ -1254,9 +1326,9 @@ expected_duplicates: 0
## 3.11.23 References
- [Implementation Guide](file:///d:/nap-dms.lcbp3/specs/03-implementation/document-numbering.md)
- [Operations Guide](file:///d:/nap-dms.lcbp3/specs/04-operations/document-numbering-operations.md)
- [API Design](file:///d:/nap-dms.lcbp3/specs/02-architecture/api-design.md)
- [Implementation Guide](../03-implementation/03-04-document-numbering.md)
- [Operations Guide](../04-operations/04-08-document-numbering-operations.md)
- [API Design](../02-architecture/02-02-api-design.md)
- [Data Dictionary](file:///d:/nap-dms.lcbp3/specs/04-data-dictionary/4_Data_Dictionary_V1_4_4.md)
- [ADR-018: Document Numbering Strategy](file:///d:/nap-dms.lcbp3/specs/05-decisions/adr-018-document-numbering.md)
- [Two-Phase Commit Pattern](https://en.wikipedia.org/wiki/Two-phase_commit_protocol)

View File

@@ -1,8 +1,8 @@
# 📋 Requirements Specification
**Version:** 1.6.0
**Version:** 1.7.0
**Status:** Active
**Last Updated:** 2025-12-13
**Last Updated:** 2025-12-18
---
@@ -16,31 +16,31 @@ This directory contains the functional and non-functional requirements for the L
### Core Requirements
1. [Objectives & Goals](./01-objectives.md) - Project objectives and success criteria
2. [System Architecture & Technology](./02-architecture.md) - High-level architecture requirements
3. [Functional Requirements](./03-functional-requirements.md) - Detailed feature specifications
1. [Objectives & Goals](./01-01-objectives.md) - Project objectives and success criteria
2. [System Architecture & Technology](./01-02-architecture.md) - High-level architecture requirements
3. [Functional Requirements](./01-03-functional-requirements.md) - Detailed feature specifications
### Functional Areas
#### Document Management
- [3.1 Project & Organization Management](./03.1-project-management.md) - Projects, contracts, organizations
- [3.2 Correspondence Management](./03.2-correspondence.md) - Letters and communications
- [3.3 RFA Management](./03.3-rfa.md) - Request for Approval
- [3.4 Contract Drawing Management](./03.4-contract-drawing.md) - Contract drawings (แบบคู่สัญญา)
- [3.5 Shop Drawing Management](./03.5-shop-drawing.md) - Shop drawings (แบบก่อสร้าง)
- [3.1 Project & Organization Management](./01-03.1-project-management.md) - Projects, contracts, organizations
- [3.2 Correspondence Management](./01-03.2-correspondence.md) - Letters and communications
- [3.3 RFA Management](./01-03.3-rfa.md) - Request for Approval
- [3.4 Contract Drawing Management](./01-03.4-contract-drawing.md) - Contract drawings (แบบคู่สัญญา)
- [3.5 Shop Drawing Management](./01-03.5-shop-drawing.md) - Shop drawings (แบบก่อสร้าง)
#### Supporting Features
- [3.6 Unified Workflow](./03.6-unified-workflow.md) - Workflow engine and routing
- [3.7 Transmittals Management](./03.7-transmittals.md) - Document transmittals
- [3.8 Circulation Sheet Management](./03.8-circulation-sheet.md) - Document circulation
- [3.9 Revisions Management](./03.9-revisions.md) - Version control
- [3.10 File Handling](./03.10-file-handling.md) - File storage and processing
- [3.6 Unified Workflow](./01-03.6-unified-workflow.md) - Workflow engine and routing
- [3.7 Transmittals Management](./01-03.7-transmittals.md) - Document transmittals
- [3.8 Circulation Sheet Management](./01-03.8-circulation-sheet.md) - Document circulation
- [3.9 Revisions Management](./01-03.9-logs.md) - Version control
- [3.10 File Handling](./01-03.10-file-handling.md) - File storage and processing
#### **⭐ Document Numbering System**
- [3.11 Document Numbering](./03.11-document-numbering.md) - **Requirements**
- [3.11 Document Numbering](./01-03.11-document-numbering.md) - **Requirements**
- Automatic number generation
- Template-based formatting
- Concurrent request handling
@@ -48,19 +48,19 @@ This directory contains the functional and non-functional requirements for the L
**Implementation & Operations:**
- 📘 [Implementation Guide](../03-implementation/document-numbering.md) - NestJS, TypeORM, Redis code examples
- 📗 [Operations Guide](../04-operations/document-numbering-operations.md) - Monitoring, troubleshooting, runbooks
- 📘 [Implementation Guide](../03-implementation/03-04-document-numbering.md) - NestJS, TypeORM, Redis code examples
- 📗 [Operations Guide](../04-operations/04-08-document-numbering-operations.md) - Monitoring, troubleshooting, runbooks
#### Technical Details
- [3.12 JSON Details](./03.12-json-details.md) - JSON field specifications
- [3.12 JSON Details](./01-03.12-json-details.md) - JSON field specifications
### Cross-Cutting Concerns
4. [Access Control & RBAC](./04-access-control.md) - 4-level hierarchical RBAC
5. [UI/UX Requirements](./05-ui-ux.md) - User interface specifications
6. [Non-Functional Requirements](./06-non-functional.md) - Performance, security, scalability
7. [Testing Requirements](./07-testing.md) - Test strategy and coverage
4. [Access Control & RBAC](./01-04-access-control.md) - 4-level hierarchical RBAC
5. [UI/UX Requirements](./01-05-ui-ux.md) - User interface specifications
6. [Non-Functional Requirements](./01-06-non-functional.md) - Performance, security, scalability
7. [Testing Requirements](./01-07-testing.md) - Test strategy and coverage
---
@@ -76,8 +76,8 @@ This directory contains the functional and non-functional requirements for the L
-**Reorganized Document Numbering documentation**
- Split into: Requirements → Implementation → Operations
- Created [document-numbering.md](../03-implementation/document-numbering.md) implementation guide
- Created [document-numbering-operations.md](../04-operations/document-numbering-operations.md) ops guide
- Created [document-numbering.md](../03-implementation/03-04-document-numbering.md) implementation guide
- Created [document-numbering-operations.md](../04-operations/04-08-document-numbering-operations.md) ops guide
- ✅ Updated schema to match v1.6.0 requirements
- ✅ Enhanced cross-references between documents
@@ -101,19 +101,19 @@ See [CHANGELOG.md](../../CHANGELOG.md) for detailed version history.
### By Feature Status
| Feature Area | Requirements Doc | Status | Implementation | Operations |
| ------------------------- | -------------------------------------- | ---------- | ----------------------------------------------------- | ------------------------------------------------------------ |
| Correspondence Management | [03.2](./03.2-correspondence.md) | ✅ Complete | ✅ Complete | Available |
| RFA Management | [03.3](./03.3-rfa.md) | ✅ Complete | ✅ Complete | Available |
| Contract Drawing | [03.4](./03.4-contract-drawing.md) | ✅ Complete | ✅ Complete | Available |
| Shop Drawing | [03.5](./03.5-shop-drawing.md) | ✅ Complete | ✅ Complete | Available |
| Workflow Engine | [03.6](./03.6-unified-workflow.md) | ✅ Complete | ✅ Complete | Available |
| Transmittals | [03.7](./03.7-transmittals.md) | ✅ Complete | ✅ Complete | Available |
| Circulation Sheets | [03.8](./03.8-circulation-sheet.md) | ✅ Complete | ✅ Complete | Available |
| **Document Numbering** | [03.11](./03.11-document-numbering.md) | ✅ Complete | ✅ [Guide](../03-implementation/document-numbering.md) | ✅ [Guide](../04-operations/document-numbering-operations.md) |
| Access Control (RBAC) | [04](./04-access-control.md) | ✅ Complete | ✅ Complete | Available |
| Search (Elasticsearch) | N/A | ✅ Complete | 🔄 95% | Available |
| Dashboard & Analytics | N/A | ✅ Complete | ✅ Complete | Available |
| Feature Area | Requirements Doc | Status | Implementation | Operations |
| ------------------------- | ----------------------------------------- | ---------- | ----------------------------------------------------------- | ------------------------------------------------------------------ |
| Correspondence Management | [03.2](./01-03.2-correspondence.md) | ✅ Complete | ✅ Complete | Available |
| RFA Management | [03.3](./01-03.3-rfa.md) | ✅ Complete | ✅ Complete | Available |
| Contract Drawing | [03.4](./01-03.4-contract-drawing.md) | ✅ Complete | ✅ Complete | Available |
| Shop Drawing | [03.5](./01-03.5-shop-drawing.md) | ✅ Complete | ✅ Complete | Available |
| Workflow Engine | [03.6](./01-03.6-unified-workflow.md) | ✅ Complete | ✅ Complete | Available |
| Transmittals | [03.7](./01-03.7-transmittals.md) | ✅ Complete | ✅ Complete | Available |
| Circulation Sheets | [03.8](./01-03.8-circulation-sheet.md) | ✅ Complete | ✅ Complete | Available |
| **Document Numbering** | [03.11](./01-03.11-document-numbering.md) | ✅ Complete | ✅ [Guide](../03-implementation/03-04-document-numbering.md) | ✅ [Guide](../04-operations/04-08-document-numbering-operations.md) |
| Access Control (RBAC) | [04](./01-04-access-control.md) | ✅ Complete | ✅ Complete | Available |
| Search (Elasticsearch) | N/A | ✅ Complete | 🔄 95% | Available |
| Dashboard & Analytics | N/A | ✅ Complete | ✅ Complete | Available |
### By Priority
@@ -141,8 +141,8 @@ All requirements documents must meet these criteria:
### For Product Owners / Business Analysts
1. Start with [Objectives & Goals](./01-objectives.md)
2. Review [Functional Requirements](./03-functional-requirements.md)
1. Start with [Objectives & Goals](./01-01-objectives.md)
2. Review [Functional Requirements](./01-03-functional-requirements.md)
3. Check specific feature requirements (3.1-3.12)
### For Developers
@@ -154,13 +154,13 @@ All requirements documents must meet these criteria:
### For QA / Testers
1. Review [Testing Requirements](./07-testing.md)
1. Review [Testing Requirements](./01-07-testing.md)
2. Use requirements as test case source
3. Verify [Non-Functional Requirements](./06-non-functional.md)
3. Verify [Non-Functional Requirements](./01-06-non-functional.md)
### For Operations Team
1. Read [Non-Functional Requirements](./06-non-functional.md) for SLAs
1. Read [Non-Functional Requirements](01-06-non-functional.md) for SLAs
2. Check [Operations Guides](../04-operations/) for specific features
3. Review monitoring and alerting requirements
@@ -178,8 +178,8 @@ All requirements documents must meet these criteria:
## 📝 Document Control
- **Version:** 1.6.0
- **Version:** 1.7.0
- **Owner:** System Architect (Nattanin Peancharoen)
- **Last Review:** 2025-12-13
- **Last Review:** 2025-12-18
- **Next Review:** 2026-01-01
- **Classification:** Internal Use Only