作者 yangfu

fix: 车间产能统计增加测试日志

... ... @@ -29,6 +29,8 @@ type DeviceRunningData struct {
// 附加数据
// 匹配数目
Count int `json:"count"`
// 当天数量
TodayTotal int `json:"today_total"`
// 合计数目
Total int `json:"total"`
// 炸机前段温度:炸机前段当前温度 YZJ1 油炸机
... ...
... ... @@ -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 {
... ...
... ... @@ -21,7 +21,7 @@ func Run() {
srv := asynq.NewServer(
asynq.RedisClientOpt{Addr: constant.REDIS_ADDRESS},
asynq.Config{
Concurrency: 4,
//Concurrency: 4,
Queues: map[string]int{
//"critical": 1,
"default": 1,
... ...