...
|
...
|
@@ -86,19 +86,27 @@ func (ptr *PGWorkshopDataConsumeService) Consume(companyId, orgId int, record *d |
|
|
}
|
|
|
|
|
|
// 1.保存设备运行记录
|
|
|
deviceRunningData.TodayTotal = deviceDailyRecord.DeviceRunningRecordInfo.Count
|
|
|
deviceRunningRecord, _ = ptr.newDeviceRunningRecord(companyId, orgId, workStation, device, deviceRunningData)
|
|
|
if _, err = deviceRunningRecordRepository.Save(deviceRunningRecord); err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
|
|
|
// 2.更新 设备每日运行记录(汇总) - redis更新 十分钟异步刷库
|
|
|
// 2.更新 设备每日运行记录(汇总) - redis更新 十分钟异步刷库 TODO:这边会有并发问题,加锁
|
|
|
if addSuccess := deviceDailyRecord.AddDeviceRunningData(deviceRunningData); addSuccess {
|
|
|
// 3.保存设备生产记录 (统计车间、员工产能) 批次跟数量不为空
|
|
|
if record.DeviceType == domain.DeviceTypeChuanChuanJi && plan != nil && deviceRunningData.Count > 0 {
|
|
|
log.Logger.Debug(fmt.Sprintf("设备统计 设备:%v 当前数量:%v 增加数量:%v",
|
|
|
deviceDailyRecord.DeviceCode,
|
|
|
deviceRunningRecord.DeviceRunningRecordInfo.TodayTotal,
|
|
|
deviceRunningRecord.DeviceRunningRecordInfo.Count))
|
|
|
productRecord, _ := ptr.newProductRecord(companyId, orgId, workStation, device, deviceRunningData, plan)
|
|
|
productRecordService, _ := NewPGProductRecordService(ptr.transactionContext)
|
|
|
productRecordService.EmployeeProductStatics(productRecord)
|
|
|
productRecordService.WorkshopProductStatics(productRecord)
|
|
|
// 同步执行
|
|
|
//productRecordService, _ := NewPGProductRecordService(ptr.transactionContext)
|
|
|
//productRecordService.EmployeeProductStatics(productRecord)
|
|
|
//productRecordService.WorkshopProductStatics(productRecord)
|
|
|
// 异步执行
|
|
|
SendProductRecordStaticsJob(productRecord)
|
|
|
}
|
|
|
}
|
|
|
if err = redis.SaveDeviceDailyRunningRecord(deviceDailyRecord); err != nil {
|
...
|
...
|
|