Import JSON
รับข้อมูลแถวที่ parse จาก Excel แล้ว (เป็น JSON array) เพื่อสร้าง/แทนที่การตั้งค่าสวัสดิการพนักงานตามปีที่ระบุ ใช้เมื่อฝั่ง client อ่านไฟล์ Excel เองแล้วแปลงเป็น JSON
Endpoint
POST /api/v1/open-apis/welfare/excel_import_jsonRequest Body
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
json_data | array | Yes | Array ของแถวข้อมูล โดยแต่ละแถวใช้ key ตาม column | ดูตัวอย่าง |
year | string | Yes | ปีสวัสดิการ (YYYY) | "2026" |
โครงสร้าง json_data แต่ละแถว
| Key | Field | Description |
|---|---|---|
A | employee_code | รหัสพนักงาน |
F | salary_type_code | รหัสประเภทสวัสดิการ |
H | welfare_prev_amt | ยอดยกมาจากปีก่อน (รองรับ comma เช่น "5,000") |
I | welfare_quota_amt | วงเงินสวัสดิการ (รองรับ comma เช่น "20,000") |
Request Body Example
{
"year": "2026",
"json_data": [
{ "A": "EMP001", "F": "SAL_MED", "H": "5,000", "I": "20,000" },
{ "A": "EMP002", "F": "SAL_MED", "H": "", "I": "15,000" }
]
}Response Format
Success Response (HTTP 200)
{
"code": 200,
"message": "สำเร็จ",
"payload": {
"year": "2026",
"json_data": [
{ "A": "EMP001", "F": "SAL_MED", "H": "5,000", "I": "20,000" },
{ "A": "EMP002", "F": "SAL_MED", "H": "", "I": "15,000" }
],
"log_data": {
"all_record": 2,
"insert_record": 1,
"update_record": 1
}
}
}Response Fields
| Field | Type | Nullable | Description |
|---|---|---|---|
year | string | No | ปีสวัสดิการ |
json_data | array | No | ข้อมูลแถวที่ส่งมา (echo กลับ) |
log_data.all_record | integer | No | จำนวนแถวที่ประมวลผล |
log_data.insert_record | integer | No | จำนวนแถวที่เพิ่มใหม่ (ไม่มี Config เดิม) |
log_data.update_record | integer | No | จำนวนแถวที่แทนที่ (มี Config เดิมและถูกแทนที่) |
Error Response - Missing json_data (HTTP 400)
{
"code": 400,
"message": "Exception File type not support"
}Code Examples
cURL
curl -X POST "https://openapi.humansoft.co.th/api/v1/open-apis/welfare/excel_import_json" \
-H "Ocp-Apim-Subscription-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"year": "2026",
"json_data": [
{ "A": "EMP001", "F": "SAL_MED", "H": "5,000", "I": "20,000" },
{ "A": "EMP002", "F": "SAL_MED", "H": "", "I": "15,000" }
]
}'Notes
ข้อควรทราบ:
- แถวที่ key
Aว่างจะทำให้ หยุดประมวลผลทันที (แถวหลังจากนั้นจะถูกข้ามทั้งหมด) - ถ้า
employee_codeหรือsalary_type_codeไม่พบในระบบ แถวนั้นจะไม่สร้างข้อมูล (ข้ามไป) - ตัวเลขใน key
HและIรองรับ comma separator เช่น"20,000.00" - การทำงานเป็น Replace: ลบ Config เดิมที่มี salary_type, employee, welfare_year เดียวกัน แล้วสร้างใหม่
- Endpoint นี้ไม่มี ID ที่ต้องส่งเป็น Base64 — ใช้
employee_codeและsalary_type_codeเป็นตัวอ้างอิง
Related APIs
- Excel Import - ให้ server อ่านไฟล์
.xlsxเอง - Import File Log - เก็บไฟล์ + log อย่างเดียว
- List Welfare Employee By Type - ตรวจสอบผลหลัง import
Last updated on