# 取得專案自動帶入的booking phase
參考 API 通用格式 : [連結](/XL6s3RkpRJexXJ3vFmqHlA)
## 1️⃣ 介紹
### 資料影響範圍
> R-讀取 O-輸出(產生成文件) W-寫入
```
project (R) 專案資料表
phase (R) 階段資料表
project_phase (R) 專案階段
project_booking_phase (R) 專案booking 人員資料表
avg_working_hours (R) 人均工時資料表
client_phase (R) 客戶Phase別名
```
### 功能說明
取得專案內所有的booking phase列表
## 2️⃣ 請求說明 Request
### Header 欄位
| 項目 | 說明 |
|----|----|
| URL | /epdhp/booking/project/autogen|
| method | post |
| Header | Bearer Token |
| Header x-identity | {permId} |
### Request Body 欄位
> Y:必填 / N:選填 / M:情況必填
| 欄位 | 名稱 | 資料型別 | 必填 | 資料儲存 & 說明 |
|----|----|------|----|-----------|
| phaseType | 類型 | string | Y | 1:Est / 2:Phase |
| pid | 專案代號 | string | Y | |
| resourceId | Booking員工編號 | string | Y | |
### Request Body 範例
```json
{
"phaseType": "1",
"pid": "123",
"resourceId": "10007122"
}
```
## 3️⃣ 業務說明
### 流程
1. 檢核必填欄位{pid}
2. 依{pid}及{phaseType}查尋project_phase資料表,找出該專案所設定的Phase
3. 傳入的{phaseType}為2時,查詢條件為project_phase.type = '2' or '3'
4. 當project_phase.type = '3'時,回傳的type須為2
5. 以priority由小到到排序
6. 查詢resource.resourceId = {resourceId}的div_id、dep_id及role_id
7. 承上,利用這三個欄位及phaseId查詢avg_working_hours是否取得資料
* 如果有取得: response.effort = avg_working_hours.effort
* 如果沒有取得: response.effort = 0.00
8. name 需關聯client_phase
* 若client_phase搜尋出來有資料,則name為搜尋出來的client_phase.phase_alias
name格式為:client_phase.phase_alias(project_phase.name)
* 若client_phase沒有資料,則看type = 1 或2 時 name = project_phase.name
* 若client_phase沒有資料,則看type = 3 時 name = project_phase.cust_name
## 4️⃣ 回應說明 Response
| 欄位 | 名稱 | 資料型別 | 資料儲存 & 說明 |
| ----- | -------------- | -------- | --------------- |
| phaseId | 時程編號 | string | |
| name | 時程名稱 | string | |
| type | 類型 | string | 1:Est / 2:Phase |
| startDate | 起始時間 | string / null | fmt yyyy-mm-dd |
| endDate | 截止時間 | string / null | fmt yyyy-mm-dd |
| effort | 使用率 | decimal / null | 小數點兩位,不用給% |
### Response 範例
```json
{
"syscode": "0000",
"message": "Success.",
"success": true,
"total": 3,
"data": [
{
"phaseId": "dd0bec41-bb39-42c6-9059-0088eb80973d",
"name": "Est",
"type": "1",
"startDate":"2024-01-01",
"endDate":"2024-04-30",
"effort": 0.00
},
{
"phaseId": "2f8f8aa3-f078-49ad-a933-1fc91c69957c",
"name": "EVT",
"type": "2",
"startDate":"2024-01-01",
"endDate":"2024-04-30",
"effort": 0.00
},
{
"phaseId": "cf023e66-6226-49f7-91e1-a613b6fc8af7",
"name": "DVT1",
"type": "2",
"startDate":"2024-01-01",
"endDate":"2024-04-30",
"effort": 0.00
},
{
"phaseId": "cf023e66-6226-49f7-91e1-a613b6fc8af7",
"name": "ROG",
"type": "2",
"startDate":"2024-01-01",
"endDate":"2024-04-30",
"effort": 0.00
}
]
}