移块上云插件文档
    正在准备搜索索引...

    定时任务

    索引

    属性

    injectName: "scheduledTask" = 'scheduledTask'

    方法

    • 创建定时任务

      参数

      • options: {
            cacheTime?: number;
            complete: () => void;
            dayOfWeek?: string;
            dk: string;
            enabled?: boolean;
            fail: (res: Error) => void;
            pk: string;
            success: (res: ResponseData) => void;
            timers: CronJobTimer[];
            timeZone?: string;
            timeZoneId?: string;
            type: CornJobType;
        }
        • 可选cacheTime?: number

          下行缓存时间,单位秒,值范围:0-7776000

        • complete: () => void

          接口调用结束的回调函数(调用成功、失败都会执行)

        • 可选dayOfWeek?: string

          重复周期:1:周一,2:周二,3:周三,4:周四,5:周五,6:周六,7:周日,多个使用英文逗号分隔, 当 type = custom-repeat multi-section random 时必填

        • dk: string

          设备 deviceKey

        • 可选enabled?: boolean

          定时任务状态,启动:true,停止:false

        • fail: (res: Error) => void

          接口调用失败的回调函数

        • pk: string

          产品 productKey

        • success: (res: ResponseData) => void

          接口调用成功的回调函数

        • timers: CronJobTimer[]

          定时任务列表

        • 可选timeZone?: string

          时区偏移量,格式:+-HH:mm,例如:+08:00

        • 可选timeZoneId?: string

          时区标识符,例如:Asia/Shanghai

        • type: CornJobType

          定时任务类型

      返回 void

      const plugin = requirePlugin('quecPlugin')
      plugin.scheduledTask.addCornJobV2({
      dayOfWeek: "1",
      dk: "xx",
      enabled: true,
      pk: "xxx",
      timers: [{
      time: "01:00:00",
      action:"[
      {"modelCode":"switch","modelName":"开关","modelType":"PROPERTY","dataType":"BOOL","value":true},
      {"modelCode":"temperature","modelName":"目标温度","modelType":"PROPERTY","dataType":"INT","value":10}
      ]",
      delay:0,
      taskLogo:'',
      taskName:''
      cacheTime0
      }],
      type: "custom-repeat"
      success (res) {},
      fail (res) {},
      complete (res) { }
      })
    • 批量删除定时任务

      参数

      • options: {
            complete: () => void;
            fail: (res: Error) => void;
            ruleIdList: string[];
            success: (res: ResponseData) => void;
        }
        • complete: () => void

          接口调用结束的回调函数(调用成功、失败都会执行)

        • fail: (res: Error) => void

          接口调用失败的回调函数

        • ruleIdList: string[]

          定时任务 ID 列表

        • success: (res: ResponseData) => void

          接口调用成功的回调函数

      返回 void

      const plugin = requirePlugin('quecPlugin')
      plugin.scheduledTask.batchDeleteCronJob({
      ruleIdList:['Iy2dExTngD5sV0A2Rx34'],
      success (res) {},
      fail (res) {},
      complete (res) { }
      })
    • 查询定时任务详情

      参数

      • options: {
            complete: () => void;
            fail: (res: Error) => void;
            ruleId: string;
            success: (res: ResponseData) => void;
        }
        • complete: () => void

          接口调用结束的回调函数(调用成功、失败都会执行)

        • fail: (res: Error) => void

          接口调用失败的回调函数

        • ruleId: string

          定时任务 ID

        • success: (res: ResponseData) => void

          接口调用成功的回调函数

      返回 void

      const plugin = requirePlugin('quecPlugin')
      plugin.scheduledTask.getCronJobInfoV2({
      ruleId:'xxx',
      success (res) {},
      fail (res) {},
      complete (res) { }
      })
    • 查询定时任务列表

      参数

      • options: {
            complete: () => void;
            dk: string;
            fail: (res: Error) => void;
            page?: number;
            pageSize?: number;
            pk: string;
            success: (res: ResponseData) => void;
            type?: CornJobType;
        }
        • complete: () => void

          接口调用结束的回调函数(调用成功、失败都会执行)

        • dk: string

          设备 deviceKey

        • fail: (res: Error) => void

          接口调用失败的回调函数

        • 可选page?: number

          当前页码

        • 可选pageSize?: number

          每页数量

        • pk: string

          产品 productKey

        • success: (res: ResponseData) => void

          接口调用成功的回调函数

        • 可选type?: CornJobType

          定时任务类型

      返回 void

      const plugin = requirePlugin('quecPlugin')
      plugin.scheduledTask.getCronJobListV2({
      dk: "xx",
      pk: "xxx",
      success (res) {},
      fail (res) {},
      complete (res) { }
      })
    • 修改定时任务

      参数

      • options: {
            cacheTime?: number;
            complete: () => void;
            dayOfWeek: string;
            dk: string;
            enabled?: boolean;
            fail: (res: Error) => void;
            pk: string;
            ruleId: string;
            success: (res: ResponseData) => void;
            timers: CronJobTimer[];
            timeZone?: string;
            timeZoneId?: string;
            type: CornJobType;
        }
        • 可选cacheTime?: number

          下行缓存时间,单位秒,值范围:0-7776000

        • complete: () => void

          接口调用结束的回调函数(调用成功、失败都会执行)

        • dayOfWeek: string

          重复周期:1:周一,2:周二,3:周三,4:周四,5:周五,6:周六,7:周日,多个使用英文逗号分隔, 当 type = custom-repeat multi-section random 时必填

        • dk: string

          设备 deviceKey

        • 可选enabled?: boolean

          定时任务状态,启动:true,停止:false

        • fail: (res: Error) => void

          接口调用失败的回调函数

        • pk: string

          产品 productKey

        • ruleId: string

          定时任务 ID

        • success: (res: ResponseData) => void

          接口调用成功的回调函数

        • timers: CronJobTimer[]

          定时任务列表

        • 可选timeZone?: string

          时区偏移量,格式:+-HH:mm,例如:+08:00

        • 可选timeZoneId?: string

          时区标识符,例如:Asia/Shanghai

        • type: CornJobType

          定时任务类型

      返回 void

      const plugin = requirePlugin('quecPlugin')
      plugin.scheduledTask.setCronJobV2({
      ruleId:1,
      dayOfWeek: "1",
      dk: "xx",
      enabled: true,
      pk: "xxx",
      timers: [{
      time: "01:00:00",
      action:"[
      {"modelCode":"switch","modelName":"开关","modelType":"PROPERTY","dataType":"BOOL","value":true},
      {"modelCode":"temperature","modelName":"目标温度","modelType":"PROPERTY","dataType":"INT","value":10}
      ]",
      delay:0,
      taskLogo:'',
      taskName:''
      cacheTime0
      }],
      type: "custom-repeat"
      success (res) {},
      fail (res) {},
      complete (res) { }
      })