...
|
...
|
@@ -32,7 +32,7 @@ func getDeviceDailyRunningRecord(client *redis.Client, key string) (*domain.Devi |
|
|
// 保存每日设备运行数据
|
|
|
func SaveDeviceDailyRunningRecord(record *domain.DeviceDailyRunningRecord) error {
|
|
|
client := GetRedis()
|
|
|
key := DeviceDailyRunningRecordKey(record.CreatedAt, record.DeviceCode)
|
|
|
key := DeviceDailyRunningRecordKey(record.ProductDate.Local(), record.DeviceCode)
|
|
|
recordData, err := json.Marshal(record)
|
|
|
result := client.Set(key, recordData, time.Hour*24*5)
|
|
|
_, err = result.Result()
|
...
|
...
|
@@ -42,14 +42,14 @@ func SaveDeviceDailyRunningRecord(record *domain.DeviceDailyRunningRecord) error |
|
|
// 保存每日设备运行数据
|
|
|
func RemoveDeviceDailyRunningRecord(t time.Time, deviceCode string) error {
|
|
|
client := GetRedis()
|
|
|
key := DeviceDailyRunningRecordKey(t, deviceCode)
|
|
|
key := DeviceDailyRunningRecordKey(t.Local(), deviceCode)
|
|
|
result := client.Del(key)
|
|
|
_, err := result.Result()
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
func DeviceDailyRunningRecordKey(t time.Time, deviceCode string) string {
|
|
|
str := fmt.Sprintf("%v:device-daily-record:%v-%v:%v:%v", constant.CACHE_PREFIX, constant.MANUFACTURE_DEFAULT_COMPANYID, constant.MANUFACTURE_DEFAULT_ORGID, t.Format("2006-01-02"), deviceCode)
|
|
|
str := fmt.Sprintf("%v:device-daily-record:%v-%v:%v:%v", constant.CACHE_PREFIX, constant.MANUFACTURE_DEFAULT_COMPANYID, constant.MANUFACTURE_DEFAULT_ORGID, t.Local().Format("2006-01-02"), deviceCode)
|
|
|
return str
|
|
|
}
|
|
|
|
...
|
...
|
|