作者 yangfu

fix: 日志记录异常修改

... ... @@ -67,6 +67,7 @@ func (ptr *PGWorkshopDataConsumeService) Consume(companyId, orgId int, record *d
var saveErr error
if deviceDailyRecord, saveErr = ptr.saveDeviceDailyRunningRecord(companyId, orgId, workStation, device, planId, deviceRunningData); err != nil {
//log.Logger.Error(saveErr.Error())
return nil, err
}
defer func() {
... ... @@ -104,6 +105,7 @@ func (ptr *PGWorkshopDataConsumeService) Consume(companyId, orgId int, record *d
// 3.更新 设备每日运行记录(汇总) - redis更新 十分钟异步刷库
deviceDailyRecord.AddDeviceRunningData(deviceRunningData.CollectionTime, deviceRunningData)
if err = redis.SaveDeviceDailyRunningRecord(deviceDailyRecord); err != nil {
//log.Logger.Error(err.Error())
return nil, err
}
return nil, nil
... ... @@ -278,6 +280,7 @@ func (ptr *PGWorkshopDataConsumeService) saveDeviceDailyRunningRecord(companyId,
}
}
if record != nil {
return record, nil
}
recordInfo := domain.NewDeviceRunningRecordInfo()
... ...
... ... @@ -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
}
... ...