跳到主要内容

11. Calendar 服务

通过 client.calendar() 进行访问。将日程(巡检·节假日·检查等)关联至资产/站点进行运营。

10.1 方法一览​

方法返回类型HTTP端点
create(CalendarRequestV5)CalendarResponseV5 或 nullPOST/api/v5/calendar
update(calendar_id, CalendarRequestV5)CalendarResponseV5 或 nullPUT/api/v5/calendar/{id}
delete(calendar_id)booleanDELETE/api/v5/calendar/{id}
get(calendar_id)CalendarResponseV5 或 nullGET/api/v5/calendar/{id}
list()List<CalendarResponseV5>GET/api/v5/calendar
search(from_iso, to_iso)List<CalendarResponseV5>GET/api/v5/calendar/search?from=...&to=...

10.2 日程类型 (target_type)​

代码含义
MTN定期巡检 (Maintenance)
HOLIDAY节假日 / 非作业
INSPECTION定期检查
MEETING会议
TRAINING教育

10.3 CalendarRequestV5 / CalendarResponseV5​

字段类型说明
calendar_idString日程 ID (PK)
target_typeString类型代码
site_idString所属站点
asset_idString目标资产 (Equipment)
start_timestamplong开始时间 (毫秒)
end_timestamplong结束时间 (毫秒)
descriptionString说明
type_color / type_name / type_kindString类型显示信息

10.4 使用示例​

创建日程​

import plantpulse.api.v5.dto.request.CalendarRequestV5;
import plantpulse.api.v5.dto.response.CalendarResponseV5;

CalendarRequestV5 cal = new CalendarRequestV5();
cal.setCalendar_id("CALENDAR_000001");
cal.setSite_id("SITE_DJ");
cal.setAsset_id("EQUIPMENT_000001");
cal.setTarget_type("MTN");
cal.setDescription("CNC #1 정기 점검 — 베어링 교체");

long now = System.currentTimeMillis();
cal.setStart_timestamp(now + 6 * 24 * 3600_000L);
cal.setEnd_timestamp(now + 7 * 24 * 3600_000L);

CalendarResponseV5 created = client.calendar().create(cal);

单条查询​

CalendarResponseV5 c = client.calendar().get("CALENDAR_000001");
if (c != null) {
System.out.println(c.getDescription());
System.out.println("시작: " + c.getStart_timestamp());
}

ISO 日期范围检索​

import java.util.List;

List<CalendarResponseV5> may = client.calendar().search(
"2026-05-01 00:00:00",
"2026-05-31 23:59:59");

完整列表​

List<CalendarResponseV5> all = client.calendar().list();
for (CalendarResponseV5 c : all) {
System.out.println(c.getCalendar_id() + " — " + c.getTarget_type());
}

按资产过滤巡检日程 (客户端)​

import java.util.stream.Collectors;

String targetAsset = "EQUIPMENT_000001";

List<CalendarResponseV5> mtnEvents = client.calendar()
.search("2026-01-01 00:00:00", "2026-12-31 23:59:59")
.stream()
.filter(c -> targetAsset.equals(c.getAsset_id()))
.filter(c -> "MTN".equals(c.getTarget_type()))
.collect(Collectors.toList());

修改 / 删除​

// 수정 — 전체 필드를 다시 보내야 함
CalendarRequestV5 update = new CalendarRequestV5();
update.setCalendar_id("CALENDAR_000001");
update.setSite_id("SITE_DJ");
update.setAsset_id("EQUIPMENT_000001");
update.setTarget_type("MTN");
update.setDescription("점검 연기 — 5월 25일로 변경");
long now = System.currentTimeMillis();
update.setStart_timestamp(now + 11 * 24 * 3600_000L);
update.setEnd_timestamp(now + 12 * 24 * 3600_000L);
client.calendar().update("CALENDAR_000001", update);

// 삭제
client.calendar().delete("CALENDAR_000001");

10.5 应用场景​

场景 — 未来 7 天日程通知​

import java.text.SimpleDateFormat;
import java.util.Date;

SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
long now = System.currentTimeMillis();
String from = fmt.format(new Date(now));
String to = fmt.format(new Date(now + 7L * 24 * 3600_000L));

List<CalendarResponseV5> upcoming = client.calendar().search(from, to);
for (CalendarResponseV5 c : upcoming) {
if ("MTN".equals(c.getTarget_type())) {
sendNotification("점검 예정: " + c.getDescription());
}
}

场景 — 将有巡检日程的资产从 OEE 计算中排除​

long now = System.currentTimeMillis();
String today = fmt.format(new Date(now));

List<CalendarResponseV5> activeEvents = client.calendar()
.search(today, today)
.stream()
.filter(c -> c.getStart_timestamp() <= now
&& c.getEnd_timestamp() >= now)
.filter(c -> "MTN".equals(c.getTarget_type()))
.collect(Collectors.toList());

Set<String> excludedAssets = activeEvents.stream()
.map(CalendarResponseV5::getAsset_id)
.collect(Collectors.toSet());

// OEE 계산 시 excludedAssets 의 자산은 건너뜀

下一步​