正在显示
5 个修改的文件
包含
13 行增加
和
5 行删除
@@ -151,6 +151,7 @@ func (deviceCollectionService *DeviceCollectionService) DeviceCollection(createD | @@ -151,6 +151,7 @@ func (deviceCollectionService *DeviceCollectionService) DeviceCollection(createD | ||
151 | // newDeviceCollection.Values["Count"] = rand.Intn(300) | 151 | // newDeviceCollection.Values["Count"] = rand.Intn(300) |
152 | // newDeviceCollection.StartupStatus = 1 | 152 | // newDeviceCollection.StartupStatus = 1 |
153 | // newDeviceCollection.ComStatus = 1 | 153 | // newDeviceCollection.ComStatus = 1 |
154 | + // newDeviceCollection.CollectionTime = time.Date(2022,4,18,7,0,0,0,time.Local) | ||
154 | //} | 155 | //} |
155 | if newDeviceCollection, err = deviceCollectionRepository.Save(newDeviceCollection); err != nil { | 156 | if newDeviceCollection, err = deviceCollectionRepository.Save(newDeviceCollection); err != nil { |
156 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 157 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
@@ -70,7 +70,7 @@ func (ptr *PGWorkshopDataConsumeService) Consume(companyId, orgId int, record *d | @@ -70,7 +70,7 @@ func (ptr *PGWorkshopDataConsumeService) Consume(companyId, orgId int, record *d | ||
70 | } | 70 | } |
71 | defer func() { | 71 | defer func() { |
72 | if saveErr != nil { | 72 | if saveErr != nil { |
73 | - redis.RemoveDeviceDailyRunningRecord(time.Now(), deviceRunningData.DeviceCode) | 73 | + redis.RemoveDeviceDailyRunningRecord(deviceRunningData.CollectionTime, deviceRunningData.DeviceCode) |
74 | } | 74 | } |
75 | }() | 75 | }() |
76 | } | 76 | } |
@@ -96,8 +96,9 @@ func (ptr *PGWorkshopDataConsumeService) Consume(companyId, orgId int, record *d | @@ -96,8 +96,9 @@ func (ptr *PGWorkshopDataConsumeService) Consume(companyId, orgId int, record *d | ||
96 | if addSuccess := deviceDailyRecord.AddDeviceRunningData(deviceRunningData); addSuccess { | 96 | if addSuccess := deviceDailyRecord.AddDeviceRunningData(deviceRunningData); addSuccess { |
97 | // 3.保存设备生产记录 (统计车间、员工产能) 批次跟数量不为空 | 97 | // 3.保存设备生产记录 (统计车间、员工产能) 批次跟数量不为空 |
98 | if record.DeviceType == domain.DeviceTypeChuanChuanJi && plan != nil && deviceRunningData.Count > 0 { | 98 | if record.DeviceType == domain.DeviceTypeChuanChuanJi && plan != nil && deviceRunningData.Count > 0 { |
99 | - log.Logger.Debug(fmt.Sprintf("设备统计 设备:%v 当前数量:%v 增加数量:%v", | 99 | + log.Logger.Debug(fmt.Sprintf("设备统计 设备:%v(%v) 当前数量:%v 增加数量:%v", |
100 | deviceDailyRecord.DeviceCode, | 100 | deviceDailyRecord.DeviceCode, |
101 | + deviceDailyRecord.ProductDate.Local().Format("2006-01-02"), | ||
101 | deviceRunningRecord.DeviceRunningRecordInfo.TodayTotal, | 102 | deviceRunningRecord.DeviceRunningRecordInfo.TodayTotal, |
102 | deviceRunningRecord.DeviceRunningRecordInfo.Count)) | 103 | deviceRunningRecord.DeviceRunningRecordInfo.Count)) |
103 | productRecord, _ := ptr.newProductRecord(companyId, orgId, workStation, device, deviceRunningData, plan) | 104 | productRecord, _ := ptr.newProductRecord(companyId, orgId, workStation, device, deviceRunningData, plan) |
@@ -300,7 +301,7 @@ func (ptr *PGWorkshopDataConsumeService) saveDeviceDailyRunningRecord(companyId, | @@ -300,7 +301,7 @@ func (ptr *PGWorkshopDataConsumeService) saveDeviceDailyRunningRecord(companyId, | ||
300 | DeviceCode: device.DeviceCode, | 301 | DeviceCode: device.DeviceCode, |
301 | ProductDate: utils.GetZeroTime(data.CollectionTime), | 302 | ProductDate: utils.GetZeroTime(data.CollectionTime), |
302 | DeviceRunningRecordInfo: recordInfo, | 303 | DeviceRunningRecordInfo: recordInfo, |
303 | - CreatedAt: time.Now(), | 304 | + CreatedAt: data.CollectionTime, |
304 | UpdatedAt: time.Now(), | 305 | UpdatedAt: time.Now(), |
305 | } | 306 | } |
306 | if record, err = deviceDailyRunningRecordRepository.Save(record); err != nil { | 307 | if record, err = deviceDailyRunningRecordRepository.Save(record); err != nil { |
@@ -6,6 +6,7 @@ import ( | @@ -6,6 +6,7 @@ import ( | ||
6 | "github.com/go-redis/redis" | 6 | "github.com/go-redis/redis" |
7 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/constant" | 7 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/constant" |
8 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" | 8 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain" |
9 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/log" | ||
9 | "time" | 10 | "time" |
10 | ) | 11 | ) |
11 | 12 | ||
@@ -13,6 +14,7 @@ import ( | @@ -13,6 +14,7 @@ import ( | ||
13 | func GetDeviceDailyRunningRecord(t time.Time, deviceCode string) (*domain.DeviceDailyRunningRecord, error) { | 14 | func GetDeviceDailyRunningRecord(t time.Time, deviceCode string) (*domain.DeviceDailyRunningRecord, error) { |
14 | client := GetRedis() | 15 | client := GetRedis() |
15 | key := DeviceDailyRunningRecordKey(t, deviceCode) | 16 | key := DeviceDailyRunningRecordKey(t, deviceCode) |
17 | + log.Logger.Debug(fmt.Sprintf("Redis Device:%v GET Key:%v", deviceCode, key)) | ||
16 | return getDeviceDailyRunningRecord(client, key) | 18 | return getDeviceDailyRunningRecord(client, key) |
17 | } | 19 | } |
18 | 20 | ||
@@ -32,7 +34,8 @@ func getDeviceDailyRunningRecord(client *redis.Client, key string) (*domain.Devi | @@ -32,7 +34,8 @@ func getDeviceDailyRunningRecord(client *redis.Client, key string) (*domain.Devi | ||
32 | // 保存每日设备运行数据 | 34 | // 保存每日设备运行数据 |
33 | func SaveDeviceDailyRunningRecord(record *domain.DeviceDailyRunningRecord) error { | 35 | func SaveDeviceDailyRunningRecord(record *domain.DeviceDailyRunningRecord) error { |
34 | client := GetRedis() | 36 | client := GetRedis() |
35 | - key := DeviceDailyRunningRecordKey(record.ProductDate.Local(), record.DeviceCode) | 37 | + key := DeviceDailyRunningRecordKey(record.ProductDate, record.DeviceCode) |
38 | + log.Logger.Debug(fmt.Sprintf("Redis Device:%v SET Key:%v Count:%v", record.DeviceCode, key, record.DeviceRunningRecordInfo.Count)) | ||
36 | recordData, err := json.Marshal(record) | 39 | recordData, err := json.Marshal(record) |
37 | result := client.Set(key, recordData, time.Hour*24*5) | 40 | result := client.Set(key, recordData, time.Hour*24*5) |
38 | _, err = result.Result() | 41 | _, err = result.Result() |
@@ -42,7 +45,7 @@ func SaveDeviceDailyRunningRecord(record *domain.DeviceDailyRunningRecord) error | @@ -42,7 +45,7 @@ func SaveDeviceDailyRunningRecord(record *domain.DeviceDailyRunningRecord) error | ||
42 | // 保存每日设备运行数据 | 45 | // 保存每日设备运行数据 |
43 | func RemoveDeviceDailyRunningRecord(t time.Time, deviceCode string) error { | 46 | func RemoveDeviceDailyRunningRecord(t time.Time, deviceCode string) error { |
44 | client := GetRedis() | 47 | client := GetRedis() |
45 | - key := DeviceDailyRunningRecordKey(t.Local(), deviceCode) | 48 | + key := DeviceDailyRunningRecordKey(t, deviceCode) |
46 | result := client.Del(key) | 49 | result := client.Del(key) |
47 | _, err := result.Result() | 50 | _, err := result.Result() |
48 | return err | 51 | return err |
@@ -68,6 +68,7 @@ func timeParse() { | @@ -68,6 +68,7 @@ func timeParse() { | ||
68 | fmt.Println("1. str: ", str) | 68 | fmt.Println("1. str: ", str) |
69 | t, _ := time.Parse(TIME_LAYOUT, str) | 69 | t, _ := time.Parse(TIME_LAYOUT, str) |
70 | fmt.Println("2. Parse time: ", t) | 70 | fmt.Println("2. Parse time: ", t) |
71 | + fmt.Println("2.1. Parse time: ", t.Local(), t.Local().Local()) | ||
71 | tStr := t.Format(TIME_LAYOUT) | 72 | tStr := t.Format(TIME_LAYOUT) |
72 | fmt.Println("3. Format time str: ", tStr) | 73 | fmt.Println("3. Format time str: ", tStr) |
73 | name, offset := t.Zone() | 74 | name, offset := t.Zone() |
1 | package mqtt | 1 | package mqtt |
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | + "fmt" | ||
4 | pahomqtt "github.com/eclipse/paho.mqtt.golang" | 5 | pahomqtt "github.com/eclipse/paho.mqtt.golang" |
5 | logimp "github.com/linmadan/egglib-go/log" | 6 | logimp "github.com/linmadan/egglib-go/log" |
6 | "github.com/linmadan/egglib-go/utils/json" | 7 | "github.com/linmadan/egglib-go/utils/json" |
@@ -32,6 +33,7 @@ func OnReceiveData(client pahomqtt.Client, message pahomqtt.Message) { | @@ -32,6 +33,7 @@ func OnReceiveData(client pahomqtt.Client, message pahomqtt.Message) { | ||
32 | collectionTime, _ = time.ParseInLocation("2006-01-02 - 15:04:05", t.(string), time.Local) | 33 | collectionTime, _ = time.ParseInLocation("2006-01-02 - 15:04:05", t.(string), time.Local) |
33 | } | 34 | } |
34 | if collectionTime.IsZero() { | 35 | if collectionTime.IsZero() { |
36 | + log.Logger.Error(fmt.Sprintf("采集时间有误:%v ", collectionTime), map[string]interface{}{"data": message}) | ||
35 | return | 37 | return |
36 | } | 38 | } |
37 | var mBytes []byte | 39 | var mBytes []byte |
-
请 注册 或 登录 后发表评论