作者 yangfu

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

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