Browse Source

update 更新定时任务注册

dev
lucas 3 months ago
parent
commit
ad91b86605
  1. 9
      configFiles/config_河北省公路基础设施监测_承德_轻量化特征数据.yaml
  2. 10
      consumers/consumerHBJCAS.go
  3. 4
      consumers/consumerSinoGnssMySQL.go
  4. 4
      utils/timeRange.go

9
configFiles/config_河北省公路基础设施监测_承德_轻量化特征数据.yaml

@ -13,8 +13,9 @@ ioConfig:
topics: topics:
- t/province/1307 - t/province/1307
monitor: monitor:
#由于振动是触发式,数据迟缓 cron10min也改成1小时一次 上报多条 #振动是触发式,数据迟缓 cron10min也改成1小时一次 上报多条,不进行实时上报
cron10min: 30 0/1 * * * #6/10 * * * * cron10min: 40 0/1 * * * #6/10 * * * *
#普通类型 特征数据
cron1hour: 11 0/1 * * * cron1hour: 11 0/1 * * *
info: info:
rc4key: sK3kJttzZyf7aZI94zSYgytBYCrfZRt6yil2 rc4key: sK3kJttzZyf7aZI94zSYgytBYCrfZRt6yil2
@ -28,7 +29,9 @@ pointInfo:
#裂缝 crack #裂缝 crack
68397: 1301100001 68397: 1301100001
68398: 1301100002 68398: 1301100002
68399: 1301100001 68399: 1301100003
#振动
68400: 1301100004
5016: #河北承德乃积沟大桥 5016: #河北承德乃积沟大桥
#桥墩倾斜 #桥墩倾斜
68384: 13010900001 68384: 13010900001

10
consumers/consumerHBJCAS.go

@ -49,18 +49,19 @@ func (the *consumerHBJCAS) InputInitial() error {
the.monitor = &monitors.CommonMonitor{ the.monitor = &monitors.CommonMonitor{
MonitorHelper: &monitors.MonitorHelper{}, MonitorHelper: &monitors.MonitorHelper{},
} }
the.monitor.Start()
for taskName, cron := range the.Info.Monitor { for taskName, cron := range the.Info.Monitor {
switch taskName { switch taskName {
case "cron10min": case "cron10min":
the.monitor.RegisterTask(cron, the.getEs1HourAggData)
case "cron1hour":
the.monitor.RegisterTask(cron, the.getEs10minAggData) the.monitor.RegisterTask(cron, the.getEs10minAggData)
case "cron1hour":
the.monitor.RegisterTask(cron, the.getEs1HourAggData)
default: default:
log.Printf("定时任务[%s],cron=[%s] 无匹配", taskName, cron) log.Printf("定时任务[%s],cron=[%s] 无匹配", taskName, cron)
} }
} }
the.monitor.Start()
return nil return nil
} }
func (the *consumerHBJCAS) OutputInitial() error { func (the *consumerHBJCAS) OutputInitial() error {
@ -141,7 +142,8 @@ func (the *consumerHBJCAS) getEs1HourAggData() {
} }
func (the *consumerHBJCAS) getEs10minAggData() { func (the *consumerHBJCAS) getEs10minAggData() {
start, end := utils.GetTimeRangeBy10min() //utils.GetTimeRangeBy10min() 由于振动数据
start, end := utils.GetTimeRangeByHour(-1)
log.Printf("查询数据时间范围 %s - %s", start, end) log.Printf("查询数据时间范围 %s - %s", start, end)
factorIds := []int{28} factorIds := []int{28}
structIds := the.getStructIds() structIds := the.getStructIds()

4
consumers/consumerSinoGnssMySQL.go

@ -48,10 +48,10 @@ func (the *consumerSinoGnssMySQL) InputInitial() error {
the.Info.IoConfig.In.Db.Type, the.Info.IoConfig.In.Db.Type,
the.Info.IoConfig.In.Db.ConnStr) the.Info.IoConfig.In.Db.ConnStr)
the.monitor = &monitors.CommonMonitor{ the.monitor = &monitors.CommonMonitor{
MonitorHelper: &monitors.MonitorHelper{CronStr: the.Info.IoConfig.In.CronStr}, MonitorHelper: &monitors.MonitorHelper{},
} }
the.monitor.Start() the.monitor.Start()
the.monitor.RegisterFun(the.onData) the.monitor.RegisterTask(the.Info.IoConfig.In.CronStr, the.onData)
return nil return nil
} }
func (the *consumerSinoGnssMySQL) OutputInitial() error { func (the *consumerSinoGnssMySQL) OutputInitial() error {

4
utils/timeRange.go

@ -24,7 +24,7 @@ func GetTimeRangeBy10min() (start, stop string) {
m := time.Now().Minute() % 10 m := time.Now().Minute() % 10
log.Println(m) log.Println(m)
startTime := time.Now().Add(time.Minute * -1 * time.Duration(m)) startTime := time.Now().Add(time.Minute * -1 * time.Duration(m))
start = startTime.Add(time.Minute * -10).Format("2006-01-02T15:04:00+08:00") start = startTime.Add(time.Minute * -10).Format("2006-01-02T15:04:00.000+08:00")
stop = startTime.Format("2006-01-02T15:04:00+08:00") stop = startTime.Format("2006-01-02T15:04:00.000+08:00")
return return
} }

Loading…
Cancel
Save