14. Employee 服务
通过 client.employee() 访问。提供员工(Employee)的 CRUD 与计数功能。
14.1 方法一览
| 方法 | 返回类型 | HTTP | 端点 |
|---|---|---|---|
create(EmployeeRequestV5) | EmployeeResponseV5 或 null | POST | /api/v5/employee |
update(employee_id, EmployeeRequestV5) | EmployeeResponseV5 或 null | PUT | /api/v5/employee/{id} |
delete(employee_id) | boolean | DELETE | /api/v5/employee/{id} |
get(employee_id) | EmployeeResponseV5 或 null | GET | /api/v5/employee/{id} |
list() | List<EmployeeResponseV5> | GET | /api/v5/employee |
exists(employee_id) | boolean | GET | /api/v5/employee/{id}/exists |
count() | long | GET | /api/v5/employee/count |
14.2 EmployeeRequestV5 / EmployeeResponseV5
| 字段 | 类型 | 说明 |
|---|---|---|
employee_id | String | 员工 ID(PK,通常为工号) |
name | String | 姓名 |
site_id | String | 所属站点 |
org_id | String | 组织 ID |
email | String | 电子邮箱 |
phone | String | 电话号码 |
role_code | String | 角色代码(OPERATOR、SUPERVISOR、ENGINEER 等) |
department | String | 部门 |
14.3 使用示例
创建员工
import plantpulse.api.v5.dto.request.EmployeeRequestV5;
import plantpulse.api.v5.dto.response.EmployeeResponseV5;
EmployeeRequestV5 req = new EmployeeRequestV5();
req.setEmployee_id("EMP_E12345");
req.setName("홍길동");
req.setSite_id("SITE_DJ");
req.setOrg_id("ORG_100");
req.setEmail("hong@example.com");
req.setPhone("01012345678");
req.setRole_code("OPERATOR");
req.setDepartment("생산1팀");
EmployeeResponseV5 created = client.employee().create(req);
查询
EmployeeResponseV5 emp = client.employee().get("EMP_E12345");
if (emp != null) {
System.out.println(emp.getName() + " - " + emp.getDepartment());
}
全部列表 + 按部门过滤
import java.util.List;
import java.util.stream.Collectors;
List<EmployeeResponseV5> all = client.employee().list();
List<EmployeeResponseV5> 생산1팀 = all.stream()
.filter(e -> "생산1팀".equals(e.getDepartment()))
.collect(Collectors.toList());
计数
long total = client.employee().count();
修改 / 删除
EmployeeRequestV5 update = new EmployeeRequestV5();
update.setEmployee_id("EMP_E12345");
update.setName("홍길동");
update.setSite_id("SITE_DJ");
update.setRole_code("SUPERVISOR"); // 승진
client.employee().update("EMP_E12345", update);
client.employee().delete("EMP_E12345");
后续步骤
- Customer 服务
- Product 服务
- Order 服务 — 为工单分配员工