You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.5 KiB
56 lines
1.5 KiB
package common_models
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
)
|
|
|
|
type IotaData struct {
|
|
UserId string `json:"userId"`
|
|
ThingId string `json:"thingId"`
|
|
DimensionId string `json:"dimensionId"`
|
|
DimCapId string `json:"dimCapId"`
|
|
CapId string `json:"capId"`
|
|
DeviceId string `json:"deviceId"`
|
|
ScheduleId string `json:"scheduleId"`
|
|
TaskId string `json:"taskId"`
|
|
JobId int `json:"jobId"`
|
|
JobRepeatId int `json:"jobRepeatId"`
|
|
TriggerTime time.Time `json:"triggerTime"`
|
|
RealTime time.Time `json:"realTime"`
|
|
FinishTime time.Time `json:"finishTime"`
|
|
Seq int `json:"seq"`
|
|
Released bool `json:"released"`
|
|
Data Data `json:"data"`
|
|
}
|
|
|
|
// ReadTaskId 支持内部字段定义任务ID (_acq_number)
|
|
func (the *IotaData) ReadTaskId() (taskId string) {
|
|
taskId = the.TaskId
|
|
//可能的覆盖
|
|
dtype, ok := the.Data.Data["_data_type"]
|
|
if ok && dtype == RawTypeVib {
|
|
taskId = the.TriggerTime.Format("20060102150405")
|
|
} else {
|
|
if acq, ok := the.Data.Data["_acq_number"]; ok {
|
|
taskId = the.TriggerTime.Format("20060102") + fmt.Sprintf("%v", acq)
|
|
}
|
|
}
|
|
return taskId
|
|
}
|
|
|
|
type Data struct {
|
|
Type int `json:"type"`
|
|
Data map[string]any `json:"data"`
|
|
Result struct {
|
|
Code int `json:"code"`
|
|
Msg string `json:"msg"`
|
|
Detail string `json:"detail"`
|
|
ErrTimes int `json:"errTimes"`
|
|
Dropped bool `json:"dropped"`
|
|
} `json:"result"`
|
|
}
|
|
|
|
func (the *Data) Success() bool {
|
|
return the.Result.Code == 0
|
|
}
|
|
|