|
@@ -86,19 +86,27 @@ func (ptr *PGWorkshopDataConsumeService) Consume(companyId, orgId int, record *d |
|
@@ -86,19 +86,27 @@ func (ptr *PGWorkshopDataConsumeService) Consume(companyId, orgId int, record *d |
86
|
}
|
86
|
}
|
87
|
|
87
|
|
88
|
// 1.保存设备运行记录
|
88
|
// 1.保存设备运行记录
|
|
|
89
|
+ deviceRunningData.TodayTotal = deviceDailyRecord.DeviceRunningRecordInfo.Count
|
89
|
deviceRunningRecord, _ = ptr.newDeviceRunningRecord(companyId, orgId, workStation, device, deviceRunningData)
|
90
|
deviceRunningRecord, _ = ptr.newDeviceRunningRecord(companyId, orgId, workStation, device, deviceRunningData)
|
90
|
if _, err = deviceRunningRecordRepository.Save(deviceRunningRecord); err != nil {
|
91
|
if _, err = deviceRunningRecordRepository.Save(deviceRunningRecord); err != nil {
|
91
|
return nil, err
|
92
|
return nil, err
|
92
|
}
|
93
|
}
|
93
|
|
94
|
|
94
|
- // 2.更新 设备每日运行记录(汇总) - redis更新 十分钟异步刷库
|
95
|
+ // 2.更新 设备每日运行记录(汇总) - redis更新 十分钟异步刷库 TODO:这边会有并发问题,加锁
|
95
|
if addSuccess := deviceDailyRecord.AddDeviceRunningData(deviceRunningData); addSuccess {
|
96
|
if addSuccess := deviceDailyRecord.AddDeviceRunningData(deviceRunningData); addSuccess {
|
96
|
// 3.保存设备生产记录 (统计车间、员工产能) 批次跟数量不为空
|
97
|
// 3.保存设备生产记录 (统计车间、员工产能) 批次跟数量不为空
|
97
|
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",
|
|
|
100
|
+ deviceDailyRecord.DeviceCode,
|
|
|
101
|
+ deviceRunningRecord.DeviceRunningRecordInfo.TodayTotal,
|
|
|
102
|
+ deviceRunningRecord.DeviceRunningRecordInfo.Count))
|
98
|
productRecord, _ := ptr.newProductRecord(companyId, orgId, workStation, device, deviceRunningData, plan)
|
103
|
productRecord, _ := ptr.newProductRecord(companyId, orgId, workStation, device, deviceRunningData, plan)
|
99
|
- productRecordService, _ := NewPGProductRecordService(ptr.transactionContext)
|
|
|
100
|
- productRecordService.EmployeeProductStatics(productRecord)
|
|
|
101
|
- productRecordService.WorkshopProductStatics(productRecord)
|
104
|
+ // 同步执行
|
|
|
105
|
+ //productRecordService, _ := NewPGProductRecordService(ptr.transactionContext)
|
|
|
106
|
+ //productRecordService.EmployeeProductStatics(productRecord)
|
|
|
107
|
+ //productRecordService.WorkshopProductStatics(productRecord)
|
|
|
108
|
+ // 异步执行
|
|
|
109
|
+ SendProductRecordStaticsJob(productRecord)
|
102
|
}
|
110
|
}
|
103
|
}
|
111
|
}
|
104
|
if err = redis.SaveDeviceDailyRunningRecord(deviceDailyRecord); err != nil {
|
112
|
if err = redis.SaveDeviceDailyRunningRecord(deviceDailyRecord); err != nil {
|