Mixtimer 定时提醒服务说明

Mixtimer 是一个用于定时提醒的 Block 服务,使用者创建一个计时提醒并设置一个周期时间,启动任务后就会开始一个从现在开始的倒计时,倒计时结束时,服务就会产生一个到期事件,之后此任务状态变为已到期,使用者可以选择处理或者停止任务。选择处理任务,任务会从设置的周期时间开始重新倒计时。此外,任务到期之前,可以手动向此任务的发送一个时间偏移。

定时提醒时间类型有两种,一种是自然时间,一种是运行时间。自然时间就是普通的自然时间计时,运行时间是通过一个统计项目获取具体设备的运行时间来倒计时,所以需要额外配置统计 ID 参数。

服务提供单独创建管理关联单个对象的定时维保任务的接口,也可以通过选择一组维保规则和一组对象创建一个维保项目,一个维保项目等同于根据项目的规则列表和对象列表批量创建一组维保任务。

注意:统计项目运行时间的单位固定为小时,例如统计结果为 10,表示已运行 10 小时

Mixtimer actions 说明

时间长度格式说明:
一些表示时间长度的字段例如 period, notice 使用类似 “1h1m1s” 的字符串表示,h 表示小时,m 表示分钟,s 表示秒,”1h1m1s”表示时长为一小时一分钟一秒,还有例如 “3h” 表示三小时,等等。

定时维保规则

创建定时维保规则

创建一条定时维保规则

  • 参数
参数名称 是否必选 数据类型 数据约束 描述
action String create_timer_rule 方法名
actionid String 活动标识
name String 名称
description String 描述
cycle_type String 倒计时类型,可选 NaturalTime(自然时间)、RunTime(运行时间)
period String 维保周期
notice String 提醒时间
statistics_id cycle_type 为 RunTime 时必填 String 统计id
  • 示例
    自然时间规则
    {
      "action":"create_timer_rule",
      "name": "2day_check",
      "description": "2天检查一次设备运行",
      "cycle_type": "NaturalTime",
      "period": "48h",
      "notice": "1h"
    }

运行时间规则

{
    "action":"create_timer_rule",
    "name": "2day_check",
    "description": "2天检查一次设备运行",
    "cycle_type": "RunTime",
    "statistics_id": "STATISTICS1001",
    "period": "48h",
    "notice": "1h"
}
  • 响应
    {
      "resp": "create_timer_rule",
      "actionid": "",
      "code": 200,
      "msg": "成功",
      "result": {
          "uid": "MIXTIMERULE1"
      }
    }

修改定时维保规则

修改定时维保规则(注意:修改并不会影响已应用此规则的所有维保任务)

  • 参数
参数名称 是否必选 数据类型 数据约束 描述
action String update_timer_rule 方法名
actionid String 活动标识
name String 名称
description String 描述
cycle_type String 倒计时类型,可选 NaturalTime(自然时间)、RunTime(运行时间)
period String 维保周期
notice String 提醒时间
statistics_id cycle_type 为 RunTime 时必填 String 统计id
  • 示例
{
    "action":"update_timer_rule",
    "uid": "MIXTIMERULE1",
    "name": "3day_check_update",
    "description": "3天检查一次设备运行修改",
    "cycle_type": "NaturalTime",
    "period": "72h",
    "notice": "1h"
}
  • 响应
{
    "resp": "update_timer_rule",
    "actionid": "",
    "code": 200,
    "msg": "成功",
    "result": {
        "uid": "MIXTIMERULE1"
    }
}

获取定时维保规则

获取定时维保规则

  • 参数
参数名称 是否必选 数据类型 数据约束 描述
action String get_timer_rule 方法名
actionid String 活动标识
uid String uid
  • 示例
{
    "action":"get_timer_rule",
    "uid": "MIXTIMERULE1581629700001"
}
  • 响应示例
    {
      "resp": "get_timer_rule",
      "code": 200,
      "msg": "成功",
      "result": {
          "uid": "MIXTIMERULE1581629700001",
          "name": "3day_check_update",
          "description": "3天检查一次设备运行修改",
          "cycle_type": "NaturalTime",
          "statistics_id": "",
          "period": "72h0m0s",
          "notice": "1h0m0s",
          "created": "2021-05-08 16:48:16",
          "created_by": 0,
          "last_modified": "2021-05-10 11:41:51",
          "last_modified_by": 0
      }
    }

获取定时维保规则列表

获取定时维保规则列表

  • 参数
参数名称 是否必选 数据类型 数据约束 描述
action String get_timer_rule_list 方法名
actionid String 活动标识
page_index int 页数,不传则获取所有记录
page_size int 页大小,不传则获取所有记录
where_and String and 条件
where_or String or 条件
where_in String in 条件
  • action 参数示例
{
    "action":"get_timer_rule_list",
    "page_size": 10,
    "page_index": 1,
    "where_and": "",
    "where_or": "",
    "where_in": ""
}

响应示例

{
    "resp": "get_timer_rule_list",
    "code": 200,
    "msg": "成功",
    "result": {
        "page_index": 1,
        "page_size": 10,
        "total_pages": 1,
        "total_records": 1,
        "data": [
            {
                "uid": "MIXTIMERULE1581629700001",
                "name": "3day_check_update",
                "description": "3天检查一次设备运行修改",
                "cycle_type": "NaturalTime",
                "statistics_id": "",
                "period": "72h0m0s",
                "notice": "1h0m0s",
                "created": "2021-05-08 16:48:16",
                "created_by": 0,
                "last_modified": "2021-05-10 11:41:51",
                "last_modified_by": 0
            }
        ]
    }
}

删除定时维保规则

删除定时维保规则

  • 参数
参数名称 是否必选 数据类型 数据约束 描述
action String delete_timer_rule 方法名
actionid String 活动标识
uid String uid
  • 示例
{
    "action":"delete_timer_rule",
    "uid": "MIXTIMERULE1581629700001"
}
  • 响应
{
    "resp": "delete_timer_rule",
    "actionid": "",
    "code": 200,
    "msg": "成功",
    "result": {
        "uid": "MIXTIMERULE1581629700001"
    }
}

定时维保项目

创建定时维保项目

创建一个定时维保项目,多选维保规则和对象ID可以批量创建多个具体对象的维保任务

  • 参数
参数名称 是否必选 数据类型 数据约束 描述
action String create_timer_project 方法名
actionid String 活动标识
name String 名称
description String 描述
first_handle_time String 首次维保时间
rule_id_list List 规则id列表
object_id_list List 对象id列表
handler_id_list List 处理人id列表
  • 示例
{
    "action":"create_timer_project",
    "rule_id_list": ["MIXTIMERULE1581629700001"],
    "object_id_list": ["OBJ1", "OBJ2"],
    "handler_id_list": [1001, 1002],
    "first_handle_time": "2021-10-01 00:00:00",
    "name": "hello项目",
    "description": "asaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
}
  • 响应
{
    "resp": "create_timer_project",
    "actionid": "",
    "code": 200,
    "msg": "成功",
    "result": {
        "uid": "MIXTIMERPROJ1"
    }
}

修改定时维保项目

修改一个定时维保项目,会重新应用所有规则到对象列表。
修改前原本属于此项目的维保,如果规则或者对象ID不再符合修改后的规则和对象,会被删除。
根据新的规则和新的对象ID,但是修改前不存在的维保,会新创建出来。
例如项目修改前,有规则1和规则2,对象1和对象2,有4个具体维保:1-1,1-2,2-1,2-2,将项目修改为规则列表规则1和规则3,对象列表对象1,则会变成2个具体维保:1-1,3-1,以前的1-2,2-1,2-2被删除,3-1被新建。

  • 参数
参数名称 是否必选 数据类型 数据约束 描述
action String update_timer_project 方法名
actionid String 活动标识
uid String 项目uid
name String 名称
description String 描述
rule_id_list List 规则id列表
object_id_list List 对象id列表
first_handle_time String 首次维保时间
handler_id_list List 处理人id列表
  • 示例
{
    "action":"update_timer_project",
    "uid": "MIXTIMERPROJ1",
    "rule_id_list": ["MIXTIMERULE1581629700001"],
    "object_id_list": ["OBJ1", "OBJ2"],
    "handler_id_list": [1001, 1002],
    "name": "hello项目",
    "first_handle_time": "2021-12-12 12:12:12",
    "description": "asaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
}
  • 响应
{
    "resp": "update_timer_project",
    "actionid": "",
    "code": 200,
    "msg": "成功",
    "result": {
        "uid": "MIXTIMERPROJ1"
    }
}

删除定时维保项目

删除定时维保项目,会停止并删除项目下所有维保任务

  • 参数
参数名称 是否必选 数据类型 数据约束 描述
action String delete_timer_project 方法名
actionid String 活动标识
uid String uid
  • 示例
{
    "action":"delete_timer_project",
    "uid":"MIXTIMERPROJ1504124900001"
}
  • 响应
{
    "resp": "delete_timer_project",
    "actionid": "",
    "code": 200,
    "msg": "成功",
    "result": {
        "uid": "MIXTIMERPROJ1504124900001"
    }
}

启动定时维保项目下所有维保任务

启动定时维保项目下所有维保任务

  • 参数
参数名称 是否必选 数据类型 数据约束 描述
action String start_timer_project 方法名
actionid String 活动标识
uid String uid
  • 示例
{
    "action":"start_timer_project",
    "uid": "MIXTIMERPROJ1501241100001"
}
  • 响应
{
    "resp": "start_timer_project",
    "actionid": "",
    "code": 200,
    "msg": "成功",
    "result": {
        "uid": "MIXTIMERULE1581629700001"
    }
}

停止定时维保项目下所有维保任务

停止定时维保项目下所有维保任务

  • 参数
参数名称 是否必选 数据类型 数据约束 描述
action String stop_timer_project 方法名
actionid String 活动标识
uid String uid
  • 示例
{
    "action":"stop_timer_project",
    "uid": "MIXTIMERPROJ1501241100001"
}
  • 响应
{
    "resp": "stop_timer_project",
    "actionid": "",
    "code": 200,
    "msg": "成功",
    "result": {
        "uid": "MIXTIMERPROJ1501241100001"
    }
}

获取定时维保项目

获取定时维保项目

  • 参数
参数名称 是否必选 数据类型 数据约束 描述
action String get_timer_project 方法名
actionid String 活动标识
uid String uid
  • 示例
{
    "action":"get_timer_project",
    "uid": "MIXTIMERPROJ1501241100001"
}
  • 响应
{
    "resp": "get_timer_project",
    "actionid": "",
    "code": 200,
    "msg": "成功",
    "result": {
        "uid": "MIXTIMERPROJ1521107600003",
        "name": "高压站定时维保项目",
        "description": "",
        "rule_id_list": [
            "MIXTIMERULE1524979100002"
        ],
        "object_id_list": [
            "OBJ1393762000004",
            "OBJ1390070700005",
            "OBJ1392682700001"
        ],
        "handler_id_list": null,
        "created": "2021-05-12 17:10:11",
        "created_by": 0,
        "last_modified": "",
        "last_modified_by": 0
    }
}

获取定时维保项目列表

获取定时维保项目列表

  • 参数
参数名称 是否必选 数据类型 数据约束 描述
action String get_timer_project_list 方法名
actionid String 活动标识
page_index int 页数,不传则获取所有记录
page_size int 页大小,不传则获取所有记录
where_and String and 条件
where_or String or 条件
where_in String in 条件
  • 示例

    {
      "action":"get_timer_project_list",
      "page_size": 10,
      "page_index": 1,
      "where_and": ""
    }
  • 响应

    {
      "resp": "get_timer_project_list",
      "actionid": "",
      "code": 200,
      "msg": "成功",
      "result": {
          "page_index": 1,
          "page_size": 20,
          "total_pages": 1,
          "total_records": 1,
          "data": [
              {
                  "uid": "MIXTIMERPROJ1521107600003",
                  "name": "高压站定时维保项目",
                  "description": "",
                  "rule_id_list": [
                      "MIXTIMERULE1524979100002"
                  ],
                  "object_id_list": [
                      "OBJ1393762000004",
                      "OBJ1390070700005",
                      "OBJ1392682700001"
                  ],
                  "handler_id_list": null,
                  "created": "2021-05-12 17:10:11",
                  "created_by": 0,
                  "last_modified": "",
                  "last_modified_by": 0
              }
          ]
      }
    }

定时维保任务

创建定时维保

创建一个定时提醒

  • 参数
参数名称 是否必选 数据类型 数据约束 描述
action String create_timer 方法名
actionid String 活动标识
name String 名称
description String 描述
object_id String 对象id
cycle_type String 倒计时类型,可选 NaturalTime(自然时间)、RunTime(运行时间)
period String 维保周期
notice String 提醒时间
first_handle_time String 首次维保时间
statistics_id cycle_type 为 RunTime 时必填 String 统计id
handler_id_list List 处理人id列表
  • action 参数示例

自然时间

{
    "action": "create_timer",
    "name": "test_2day",
    "description": "2天一",
    "object_id": "OBJ1001",
    "cycle_type": "NaturalTime",
    "first_handle_time": "2021-10-01 00:00:00",
    "period": "48h",
    "notice": "1h",  // 到期前 1 小时提前提醒
    "handler_id_list": [1001, 1002],
}

运行时间

{
    "action": "create_timer",
    "name": "test_2day",
    "description": "2天一",
    "object_id": "OBJ1001",
    "cycle_type": "RunTime",
    "statistics_id": "STATISTCS1001",
    "period": "48h",
    "notice": "1h",  // 到期前 1 小时提前提醒
    "handler_id_list": [1001, 1002]
}
  • 响应
{
    "resp": "create_timer",
    "actionid": "",
    "code": 200,
    "msg": "成功",
    "result": {
        "uid": "MIXTIMERULE1"
    }
}

启动定时维保

启动一个定时提醒任务

  • 参数
参数名称 是否必选 数据类型 数据约束 描述
action String start_timer 方法名
actionid String 活动标识
uid String uid
  • action 参数示例
{
    "action": "start_timer",
    "uid": "MIXTIMER1305938200004"
}
  • 响应
{
    "resp": "start_timer",
    "actionid": "",
    "code": 200,
    "msg": "成功",
    "result": {
        "uid": "MIXTIMER1305938200004"
    }
}

停止定时维保

停止一个定时提醒任务

  • 参数
参数名称 是否必选 数据类型 数据约束 描述
action String stop_timer 方法名
actionid String 活动标识
uid String uid
  • action 参数示例
{
    "action": "stop_timer",
    "uid": "MIXTIMER1305938200004"
}
  • 响应
{
    "resp": "stop_timer",
    "actionid": "",
    "code": 200,
    "msg": "成功",
    "result": {
        "uid": "MIXTIMER1305938200004"
    }
}

删除定时维保

删除定时提醒

  • 参数
参数名称 是否必选 数据类型 数据约束 描述
action String delete_timer 方法名
actionid String 活动标识
uid String uid
  • action 参数示例
{
    "action": "delete_timer",
    "uid": "MIXTIMER1305938200004"
}
  • 响应
{
    "resp": "delete_timer",
    "actionid": "",
    "code": 200,
    "msg": "成功",
    "result": {
        "uid": "MIXTIMER1305938200004"
    }
}

修改定时维保

修改定时提醒,不能修改已启动状态的 timer,需要先停止再进行修改。

  • 参数
参数名称 是否必选 数据类型 数据约束 描述
action String update_timer 方法名
actionid String 活动标识
name String 名称
description String 描述
object_id String 对象id
cycle_type String 倒计时类型,可选 NaturalTime(自然时间)、RunTime(运行时间)
period String 维保周期
notice String 提醒时间
first_handle_time String 首次维保时间
statistics_id cycle_type 为 RunTime 时必填 String 统计id
handler_id_list List 处理人id列表
  • action 参数示例
{
    "action": "update_timer",
    "notice": "20h",
    "description": "update",
    "first_handle_time": "2021-10-01 00:00:00",
    "uid": "MIXTIMER1390735800002"
}
  • 响应
{
    "resp": "update_timer",
    "actionid": "",
    "code": 200,
    "msg": "成功",
    "result": {
        "uid": "MIXTIMER1390735800002"
    }
}

获取定时维保

获取定时提醒

  • 参数
参数名称 是否必选 数据类型 数据约束 描述
action String get_timer 方法名
actionid String 活动标识
uid String uid
  • action 参数示例

    {
      "action": "get_timer",
      "uid": "MIXTIMER1390735800002"
    }
  • 响应

{
    "resp": "get_timer",
    "code": 200,
    "msg": "成功",
    "result": {
        "uid": "MIXTIMER1305938200004",
        "name": "test_2day",
        "description": "2天一",
        "object_id": "obj1001",
        "rule_id": "MIXTIMERULE1524979100002",
        "project_id": "MIXTIMERPROJ1521107600003",
        "cycle_type": "NatutalTime",
        "period": "48h0m0s",
        "notice": "1h0m0s",
        "start_time": "2021-03-10 14:57:42",
        "last_handle_time": "",
        "close_time": "",
        "handle_num": 0,
        "handler_id_list": [1001, 1002],
        "is_active": 1,
        "created": "2021-03-10 09:59:59",
        "countdown": "47h33m44s",
        "is_expired": false
    }
}

获取定时维保列表

获取定时维保列表

  • 参数
参数名称 是否必选 数据类型 数据约束 描述
action String get_timer_list 方法名
actionid String 活动标识
page_index int 页数,不传则获取所有记录
page_size int 页大小,不传则获取所有记录
where_and String and 条件
where_or String or 条件
where_in String in 条件
  • action 参数示例

    {
      "action": "get_timer_list",
      "page_index": 1,
      "page_size": 20,
      "where_and": "",
      "where_or": "",
      "where_in": "",
      "order_by": "",
    }
  • 响应

    {
      "resp": "get_timer_list",
      "code": 200,
      "msg": "成功",
      "result": {
          "page_index": 1,
          "page_size": 20,
          "total_pages": 1,
          "total_records": 7,
          "data": [
              {
                  "uid": "MIXTIMER1305938200004",
                  "name": "test_2day",
                  "description": "2天一",
                  "object_id": "obj1001",
                  "rule_id": "MIXTIMERULE1524979100002",
                  "project_id": "MIXTIMERPROJ1521107600003",
                  "cycle_type": "NatutalTime",
                  "period": "48h0m0s",
                  "notice": "1h0m0s",
                  "start_time": "2021-03-10 14:57:42",
                  "last_handle_time": "",
                  "close_time": "",
                  "handle_num": 0,
                  "handler_id_list": [1001, 1002],
                  "is_active": 1,
                  "created": "2021-03-10 09:59:59",
                  "countdown": "47h33m44s",
                  "is_expired": false
              }
          ]
      }
    }

获取维保已到期未到期数量统计信息

获取维保已到期未到期数量统计信息

  • 参数
参数名称 是否必选 数据类型 数据约束 描述
action String get_timer_expired_count 方法名
actionid String 活动标识
where_and String and条件
where_or String or条件
where_in String in条件
  • action 参数示例
{
    "action": "get_timer_expired_count",
    "where_and": "[[\"object_id\",\"=\",\"obj1001\"]]",
    "where_or": "",
    "where_in": "[[\"uid\", \"MIXTIMER1773744200001\"]]"
}
  • 响应
{
    "resp": "get_timer_expired_count",
    "code": 200,
    "msg": "成功",
    "result": {
        "expired": 9,
        "unexpired": 10
    }
}

处理已到期的定时维保

处理已到期的定时提醒,倒计时重置回初始值

  • 参数
参数名称 是否必选 数据类型 数据约束 描述
action String handle_timer 方法名
actionid String 活动标识
timer_id String 维保id
handler_id String 处理人
handler_name String 处理人名称
description String 描述
comment String 维保评价
star Float 评分
fee Float 费用
  • action 参数示例
{
    "action": "handle_timer",
    "timer_id": "MIXTIMER1305938200004",
    "handler_id": 1,
    "handler_name": "处理人",
    "description": "非常好",
    "comment": "非常好comment",
    "star": 0.5,
    "fee": 250.33
}
  • 响应
    {
      "resp": "handle_timer",
      "actionid": "",
      "code": 200,
      "msg": "成功",
      "result": {
          "uid": "MIXTIMER1305938200004"
      }
    }

获取处理记录列表

获取处理记录列表

  • 参数
参数名称 是否必选 数据类型 数据约束 描述
action String get_handle_record_list 方法名
actionid String 活动标识
page_index int 页数,不传则获取所有记录
page_size int 页大小,不传则获取所有记录
where_and String and 条件
where_or String or 条件
where_in String in 条件
  • action 参数示例

    {
      "action": "get_timer_record_list",
      "page_index": 1,
      "page_size": 20,
      "where_and": "[[\"timer_id\", \"=\", \"MIXTIMER1365456700001\"]]",
      "where_or": "",
      "where_in": ""
    }
  • 响应

    {
      "resp": "get_timer_record_list",
      "code": 200,
      "msg": "成功",
      "result": {
          "page_index": 1,
          "page_size": 1,
          "total_pages": 1,
          "total_records": 1,
          "data": [
              {
                  "uid": "TIMEREC1365456700001",
                  "timer_id": "MIXTIMER1365456700001",
                  "object_id": "",
                  "handler_id": 1,
                  "handler_name": "1",
                  "fee": 250.33,
                  "description": "",
                  "images": "",
                  "star": 0.5,
                  "level": 1,
                  "comment": "",
                  "handle_time": "2021-03-11 14:37:23",
                  "created": "2021-03-11 14:37:23"
              }
          ]
      }
    }

设置偏移时间

给当前运行的定时提醒设置一个偏移时间,正值使倒计时减少,到期时间会提前,负值相反。

  • 参数
参数名称 是否必选 数据类型 数据约束 描述
action String set_offset 方法名
actionid String 活动标识
uid String uid
offset String 偏移量
  • action 参数示例
{
    "action": "set_timer_offset",
    "uid": "MIXTIMER1305938200004",
    "offset": "2h"
}
  • 响应
{
    "resp": "set_timer_offset",
    "actionid": "",
    "code": 200,
    "msg": "成功",
    "result": {
        "uid": "MIXTIMER1305938200004"
    }
}

获取超时等级阈值

获取超时等级阈值,单位为天
处理超时小于阈值1时,此次处理记录超时等级为0。超时大于阈值1小于阈值2时,此次处理记录超时等级为1。超时大于阈值2时,此次处理记录超时等级为2。

  • 参数
参数名称 是否必选 数据类型 数据约束 描述
action String get_threshold 方法名
actionid String 活动标识
  • action 参数示例
{
    "action": "get_threshold",
}
  • 响应
{
    "resp": "get_threshold",
    "actionid": "",
    "code": 200,
    "msg": "成功",
    "result": {
        "threshold1": 10,
        "threshold2": 20,
    }
}

设置超时等级阈值

设置超时等级阈值。
处理超时小于阈值1时,此次处理记录超时等级为0。超时大于阈值1小于阈值2时,此次处理记录超时等级为1。超时大于阈值2时,此次处理记录超时等级为2。

  • 参数
参数名称 是否必选 数据类型 数据约束 描述
action String set_threshold 方法名
actionid String 活动标识
threshold1 Int 阈值1
threshold2 Int 阈值2
  • action 参数示例
{
    "action": "set_threshold",
    "threshold1": 3,
    "threshold2": 10
  • 响应
{
    "resp": "set_threshold",
    "actionid": "",
    "code": 200,
    "msg": "成功",
    "result": {
        "threshold1": 3,
        "threshold2": 10,
    }
}

Mixtimer event 说明

定时提醒到期事件

{
    "event": "mixtimer_event",
    "block": "mixtimer",
    "uniqueid": "MIXTIMER1305938200004",
    "datetime": "2006-01-02 15:04:05",
    "uid": "MIXTIMER1305938200004", // timer 的 uid
    "object_id": "OBJ1001", // timer 对应的 object_id
    "handler_id": [1, 2],  // 处理人 ID 列表
    "name": "检查设备运行", // 维保名称
    "rule_name": "规则名称", // 维保规则名称
    "closing_time": "2006-01-02 15:04:05", // 预计到期时间
    "countdown": "1h" // 当前剩余时间
}
文档更新时间: 2024-04-12 17:57   作者:技术支持