Skip to content

Commit 4dbc0b5

Browse files
committed
修复定时任务bug
1 parent 86a6c87 commit 4dbc0b5

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

cron/cron.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ func init() {
5454
interval, _ := rulesMap["interval"].(json.Number).Int64()
5555
if interval == int64(0) {
5656
//单次触发
57+
if _, ok := rulesMap["time"].(string); !ok {
58+
logs.Error("时间触发配置中缺少时间参数")
59+
continue
60+
}
5761
ruleTime, err := time.Parse(format0, rulesMap["time"].(string))
5862
logs.Info("单次触发", ruleTime, "比对", now0)
5963
if err == nil && ruleTime.Equal(now0) {

services/device_service.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,8 +1010,10 @@ func (*DeviceService) GetDeviceOnlineStatus(deviceIdList valid.DeviceIdListValid
10101010
var deviceOnlineStatus = make(map[string]interface{})
10111011
for _, deviceId := range deviceIdList.DeviceIdList {
10121012
var tskvLatest models.TSKVLatest
1013-
result := psql.Mydb.Where("entity_id = ? and key = 'SYS_ONLINE'", deviceId).First(&tskvLatest)
1014-
if result != nil {
1013+
result := psql.Mydb.Model(&models.TSKVLatest{}).Where("entity_id = ? and key = 'SYS_ONLINE'", deviceId).First(&tskvLatest)
1014+
logs.Info("------------------------------------------------ceshi")
1015+
if result.Error != nil {
1016+
logs.Error(result.Error)
10151017
deviceOnlineStatus[deviceId] = "0"
10161018
} else {
10171019
deviceOnlineStatus[deviceId] = tskvLatest.StrV

0 commit comments

Comments
 (0)