| | |
| | | package service |
| | | |
| | | import ( |
| | | "apsClient/conf" |
| | | "apsClient/constvar" |
| | | "apsClient/model" |
| | | "fmt" |
| | | "github.com/jinzhu/gorm" |
| | | "github.com/spf13/cast" |
| | | "sync" |
| | | "time" |
| | |
| | | } |
| | | |
| | | func TaskFlagSet(channel int32) { |
| | | defaultCacheStore.Add(fmt.Sprintf(CurrentTaskCacheKey, channel), struct{}{}) |
| | | defaultCacheStore.Add(fmt.Sprintf(CurrentTaskCacheKey, channel), true) |
| | | } |
| | | |
| | | func TaskFlagUnset(channel int32) { |
| | | defaultCacheStore.Remove(fmt.Sprintf(CurrentTaskCacheKey, channel)) |
| | | defaultCacheStore.Add(fmt.Sprintf(CurrentTaskCacheKey, channel), false) |
| | | } |
| | | |
| | | func TaskFlagGet(channel int32) bool { |
| | | if _, ok := defaultCacheStore.Get(fmt.Sprintf(CurrentTaskCacheKey, channel)); ok { |
| | | if v, ok := defaultCacheStore.Get(fmt.Sprintf(CurrentTaskCacheKey, channel)); ok { |
| | | return v.(bool) |
| | | } |
| | | _, err := model.NewProceduresSearch(nil).SetDeviceId(conf.Conf.System.DeviceId).SetStatus(model.ProcedureStatusProcessing).SetChannels([]int32{channel}).First() |
| | | if err == gorm.ErrRecordNotFound { |
| | | defaultCacheStore.Add(fmt.Sprintf(CurrentTaskCacheKey, channel), false) |
| | | return false |
| | | } else { |
| | | defaultCacheStore.Add(fmt.Sprintf(CurrentTaskCacheKey, channel), true) |
| | | return true |
| | | } |
| | | return false |
| | | } |
| | | |
| | | func ProgressCacheGet(channel int32) (*model.ProductionProgress, bool) { |