...
|
...
|
@@ -6,6 +6,7 @@ import ( |
|
|
"github.com/go-redis/redis"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/constant"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/log"
|
|
|
"time"
|
|
|
)
|
|
|
|
...
|
...
|
@@ -13,6 +14,7 @@ import ( |
|
|
func GetDeviceDailyRunningRecord(t time.Time, deviceCode string) (*domain.DeviceDailyRunningRecord, error) {
|
|
|
client := GetRedis()
|
|
|
key := DeviceDailyRunningRecordKey(t, deviceCode)
|
|
|
log.Logger.Debug(fmt.Sprintf("Redis Device:%v GET Key:%v", deviceCode, key))
|
|
|
return getDeviceDailyRunningRecord(client, key)
|
|
|
}
|
|
|
|
...
|
...
|
@@ -32,7 +34,8 @@ func getDeviceDailyRunningRecord(client *redis.Client, key string) (*domain.Devi |
|
|
// 保存每日设备运行数据
|
|
|
func SaveDeviceDailyRunningRecord(record *domain.DeviceDailyRunningRecord) error {
|
|
|
client := GetRedis()
|
|
|
key := DeviceDailyRunningRecordKey(record.ProductDate.Local(), record.DeviceCode)
|
|
|
key := DeviceDailyRunningRecordKey(record.ProductDate, record.DeviceCode)
|
|
|
log.Logger.Debug(fmt.Sprintf("Redis Device:%v SET Key:%v Count:%v", record.DeviceCode, key, record.DeviceRunningRecordInfo.Count))
|
|
|
recordData, err := json.Marshal(record)
|
|
|
result := client.Set(key, recordData, time.Hour*24*5)
|
|
|
_, err = result.Result()
|
...
|
...
|
@@ -42,7 +45,7 @@ func SaveDeviceDailyRunningRecord(record *domain.DeviceDailyRunningRecord) error |
|
|
// 保存每日设备运行数据
|
|
|
func RemoveDeviceDailyRunningRecord(t time.Time, deviceCode string) error {
|
|
|
client := GetRedis()
|
|
|
key := DeviceDailyRunningRecordKey(t.Local(), deviceCode)
|
|
|
key := DeviceDailyRunningRecordKey(t, deviceCode)
|
|
|
result := client.Del(key)
|
|
|
_, err := result.Result()
|
|
|
return err
|
...
|
...
|
|