|
@@ -32,7 +32,7 @@ func getDeviceDailyRunningRecord(client *redis.Client, key string) (*domain.Devi |
|
@@ -32,7 +32,7 @@ func getDeviceDailyRunningRecord(client *redis.Client, key string) (*domain.Devi |
32
|
// 保存每日设备运行数据
|
32
|
// 保存每日设备运行数据
|
33
|
func SaveDeviceDailyRunningRecord(record *domain.DeviceDailyRunningRecord) error {
|
33
|
func SaveDeviceDailyRunningRecord(record *domain.DeviceDailyRunningRecord) error {
|
34
|
client := GetRedis()
|
34
|
client := GetRedis()
|
35
|
- key := DeviceDailyRunningRecordKey(record.CreatedAt, record.DeviceCode)
|
35
|
+ key := DeviceDailyRunningRecordKey(record.ProductDate.Local(), record.DeviceCode)
|
36
|
recordData, err := json.Marshal(record)
|
36
|
recordData, err := json.Marshal(record)
|
37
|
result := client.Set(key, recordData, time.Hour*24*5)
|
37
|
result := client.Set(key, recordData, time.Hour*24*5)
|
38
|
_, err = result.Result()
|
38
|
_, err = result.Result()
|
|
@@ -42,14 +42,14 @@ func SaveDeviceDailyRunningRecord(record *domain.DeviceDailyRunningRecord) error |
|
@@ -42,14 +42,14 @@ func SaveDeviceDailyRunningRecord(record *domain.DeviceDailyRunningRecord) error |
42
|
// 保存每日设备运行数据
|
42
|
// 保存每日设备运行数据
|
43
|
func RemoveDeviceDailyRunningRecord(t time.Time, deviceCode string) error {
|
43
|
func RemoveDeviceDailyRunningRecord(t time.Time, deviceCode string) error {
|
44
|
client := GetRedis()
|
44
|
client := GetRedis()
|
45
|
- key := DeviceDailyRunningRecordKey(t, deviceCode)
|
45
|
+ key := DeviceDailyRunningRecordKey(t.Local(), deviceCode)
|
46
|
result := client.Del(key)
|
46
|
result := client.Del(key)
|
47
|
_, err := result.Result()
|
47
|
_, err := result.Result()
|
48
|
return err
|
48
|
return err
|
49
|
}
|
49
|
}
|
50
|
|
50
|
|
51
|
func DeviceDailyRunningRecordKey(t time.Time, deviceCode string) string {
|
51
|
func DeviceDailyRunningRecordKey(t time.Time, deviceCode string) string {
|
52
|
- 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)
|
52
|
+ 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)
|
53
|
return str
|
53
|
return str
|
54
|
}
|
54
|
}
|
55
|
|
55
|
|