Skip to Content
🚀 Welcome to Humansoft Open API Documentation

Calculate Month Queue

คำนวณสรุปเวลาทำงาน ขาด ลา มาสาย และค่าล่วงเวลาประจำเดือนแบบ Batch Processing สำหรับพนักงานหลายคนพร้อมกัน

Endpoint

POST /api/v1/open-apis/salary/update-data-filter?path_action=calculate_month_queue

Request Body

Required Parameters

ParameterTypeRequiredDescriptionExample
employee_codesarrayYes*รายการรหัสพนักงาน (สูงสุด 100 รายการ)["EMP001", "EMP002"]
year_monthstringYesงวดเดือนที่ต้องการคำนวณ (YYYY-MM)"2026-02"

*ไม่จำเป็นเมื่อใช้ calculate_all = true

Optional Parameters

ParameterTypeDefaultDescriptionExample
calculate_tostring"NOW"คำนวณถึง: "NOW" (วันปัจจุบัน), "END" (วันสิ้นสุดงวด)"END"
calculate_allbooleanfalseคำนวณพนักงานทุกคนในงวด (ไม่ต้องส่ง employee_codes)true
keywordstring-ค้นหาพนักงาน (ใช้ร่วมกับ calculate_all)"สมชาย"
branch_listsarray-กรองตามสาขา (Base64 encoded ID)[{"id": "YnJhbmNoXzAw"}]
department_listsarray-กรองตามฝ่าย (Base64 encoded ID)[{"id": "ZGVwdF8wMQ=="}]
division_listsarray-กรองตามแผนก (Base64 encoded ID)
section_listsarray-กรองตามหน่วยงาน (Base64 encoded ID)
position_listsarray-กรองตามตำแหน่ง (Base64 encoded ID)

พารามิเตอร์ที่ลงท้ายด้วย _lists ต้องส่งเป็น array ของ object โดยมี key id ที่เป็น Base64 encoded

Validation Rules

RuleDescription
employee_codesต้องเป็น array มี 1-100 รายการ (ยกเว้นเมื่อใช้ calculate_all)
year_monthต้องเป็นรูปแบบ YYYY-MM
calculate_toต้องเป็น "NOW" หรือ "END" เท่านั้น

Response Format

Success Response

{ "code": 200, "message": "Batch calculation month queued", "results": { "success": [ { "employee_code": "EMP001", "employee_id": "12345", "employee_name": "นายสมชาย ใจดี" } ], "failed": [ { "employee_code": "EMP999", "error": "Employee not found" } ], "already_in_queue": [ { "employee_code": "EMP002", "employee_id": "12346", "employee_name": "นางสมหญิง ใจงาม" } ] }, "summary": { "total_resolved": 2, "success_count": 1, "failed_count": 1, "already_queued_count": 1 } }

Response Fields - results

FieldTypeDescription
successarrayรายการพนักงานที่เข้าคิวสำเร็จ
failedarrayรายการพนักงานที่เข้าคิวไม่สำเร็จ
already_in_queuearrayรายการพนักงานที่อยู่ในคิวแล้ว

Response Fields - summary

FieldTypeDescription
total_resolvednumberจำนวนพนักงานทั้งหมดที่ประมวลผล
success_countnumberจำนวนที่เข้าคิวสำเร็จ
failed_countnumberจำนวนที่เข้าคิวไม่สำเร็จ
already_queued_countnumberจำนวนที่อยู่ในคิวแล้ว

API นี้เป็น Asynchronous — การส่งเข้าคิวสำเร็จไม่ได้หมายความว่าคำนวณเสร็จแล้ว ผลลัพธ์การคำนวณจะพร้อมใช้งานภายหลัง

Error Response

{ "code": 400, "message": "ไม่สำเร็จ", "payload": { "errors": [ "กรุณาระบุ 'employee_codes' (array)", "กรุณาระบุ 'year_month' (รูปแบบ YYYY-MM)" ] } }
HTTP StatusDescription
400พารามิเตอร์ไม่ถูกต้อง หรือเกินจำนวนสูงสุด 100 รายการ
401API Key ไม่ถูกต้องหรือไม่ได้ส่ง

Code Examples

# Batch calculation curl -X POST "https://openapi.humansoft.co.th/api/v1/open-apis/salary/update-data-filter?path_action=calculate_month_queue" \ -H "Ocp-Apim-Subscription-Key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "employee_codes": ["EMP001", "EMP002", "EMP003"], "year_month": "2026-02" }' # Calculate all employees curl -X POST "https://openapi.humansoft.co.th/api/v1/open-apis/salary/update-data-filter?path_action=calculate_month_queue" \ -H "Ocp-Apim-Subscription-Key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "calculate_all": true, "year_month": "2026-02", "calculate_to": "END" }'

Notes

  • แนะนำใช้ batch size 20-50 รายการต่อครั้งเพื่อประสิทธิภาพที่ดี
  • ระบบจะป้องกันการเข้าคิวซ้ำ — ตรวจสอบ already_in_queue ใน response
  • ระบบจะประมวลผลต่อไปแม้บางรายการล้มเหลว
  • สำหรับการคำนวณรายบุคคล ใช้ Calculate Month แทน

Last updated on