作者 yangfu

fix: 日志记录异常修改

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