...
|
...
|
@@ -28,7 +28,6 @@ func (ptr *PGWorkshopDataConsumeService) Consume(companyId, orgId int, record *d |
|
|
planId int
|
|
|
err error
|
|
|
plan *domain.ProductPlanDispatchRecord
|
|
|
//datetime time.Time
|
|
|
)
|
|
|
var (
|
|
|
deviceRepository, _ = repository.NewDeviceRepository(ptr.transactionContext)
|
...
|
...
|
@@ -67,7 +66,6 @@ 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() {
|
...
|
...
|
@@ -94,20 +92,16 @@ func (ptr *PGWorkshopDataConsumeService) Consume(companyId, orgId int, record *d |
|
|
}
|
|
|
|
|
|
// 2.更新 设备每日运行记录(汇总) - redis更新 十分钟异步刷库
|
|
|
if addSuccess := deviceDailyRecord.AddDeviceRunningData(deviceRunningData.CollectionTime, deviceRunningData); addSuccess {
|
|
|
if addSuccess := deviceDailyRecord.AddDeviceRunningData(deviceRunningData); addSuccess {
|
|
|
// 3.保存设备生产记录 (统计车间、员工产能) 批次跟数量不为空
|
|
|
if record.DeviceType == domain.DeviceTypeChuanChuanJi && plan != nil && deviceRunningData.Count > 0 {
|
|
|
|
|
|
productRecord, _ := ptr.newProductRecord(companyId, orgId, workStation, device, deviceRunningData, plan)
|
|
|
//SendProductRecordStaticsJob(productRecord)
|
|
|
|
|
|
productRecordService, _ := NewPGProductRecordService(ptr.transactionContext)
|
|
|
productRecordService.EmployeeProductStatics(productRecord)
|
|
|
productRecordService.WorkshopProductStatics(productRecord)
|
|
|
}
|
|
|
}
|
|
|
if err = redis.SaveDeviceDailyRunningRecord(deviceDailyRecord); err != nil {
|
|
|
//log.Logger.Error(err.Error())
|
|
|
return nil, err
|
|
|
}
|
|
|
return nil, nil
|
...
|
...
|
@@ -155,16 +149,16 @@ func (ptr *PGWorkshopDataConsumeService) newDeviceRunningData(record *domain.Dev |
|
|
if err != nil {
|
|
|
break
|
|
|
}
|
|
|
data.Temp1 = deviceYouZhaJi.FrontTemp
|
|
|
data.Temp2 = deviceYouZhaJi.BackTemp
|
|
|
data.Temp1 = utils.Truncate(deviceYouZhaJi.FrontTemp, 1)
|
|
|
data.Temp2 = utils.Truncate(deviceYouZhaJi.BackTemp, 1)
|
|
|
} else {
|
|
|
deviceYouZhaJi := &domain.DeviceYouZhaJi2{}
|
|
|
err = json.Unmarshal(mBytes, deviceYouZhaJi)
|
|
|
if err != nil {
|
|
|
break
|
|
|
}
|
|
|
data.Temp1 = deviceYouZhaJi.Temp1
|
|
|
data.Temp2 = deviceYouZhaJi.Temp2
|
|
|
data.Temp1 = utils.Truncate(deviceYouZhaJi.Temp1, 1)
|
|
|
data.Temp2 = utils.Truncate(deviceYouZhaJi.Temp2, 1)
|
|
|
}
|
|
|
break
|
|
|
//串串机
|
...
|
...
|
@@ -189,7 +183,7 @@ func (ptr *PGWorkshopDataConsumeService) newDeviceRunningData(record *domain.Dev |
|
|
if err != nil {
|
|
|
break
|
|
|
}
|
|
|
data.Temp1 = deviceSuDongXian.CurrTemp
|
|
|
data.Temp1 = utils.Truncate(deviceSuDongXian.CurrTemp, 1)
|
|
|
break
|
|
|
//封口机
|
|
|
case domain.DeviceTypeFengKouJi:
|
...
|
...
|
|