正在显示
8 个修改的文件
包含
17 行增加
和
15 行删除
| @@ -42,7 +42,7 @@ func AutoFlushDeviceDailyRunningRecord(ctx context.Context) error { | @@ -42,7 +42,7 @@ func AutoFlushDeviceDailyRunningRecord(ctx context.Context) error { | ||
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | for _, v := range records { | 44 | for _, v := range records { |
| 45 | - if v.UpdatedAt.Add(time.Minute * 5).Before(time.Now()) { | 45 | + if v.UpdatedAt.Add(time.Minute * 20).Before(time.Now()) { |
| 46 | log.Logger.Debug(fmt.Sprintf("【定时刷新设备每日运行记录】 跳过记录 %v 最后更新时间:%v", v, v.UpdatedAt)) | 46 | log.Logger.Debug(fmt.Sprintf("【定时刷新设备每日运行记录】 跳过记录 %v 最后更新时间:%v", v, v.UpdatedAt)) |
| 47 | continue | 47 | continue |
| 48 | } | 48 | } |
| @@ -61,12 +61,6 @@ func (deviceCollectionService *DeviceCollectionService) CreateDeviceCollection(c | @@ -61,12 +61,6 @@ func (deviceCollectionService *DeviceCollectionService) CreateDeviceCollection(c | ||
| 61 | if deviceCollection, err := deviceCollectionRepository.Save(newDeviceCollection); err != nil { | 61 | if deviceCollection, err := deviceCollectionRepository.Save(newDeviceCollection); err != nil { |
| 62 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 62 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 63 | } else { | 63 | } else { |
| 64 | - //err = domainService.SendWorkshopDeviceData(deviceCollection) | ||
| 65 | - //if err != nil { | ||
| 66 | - // log.Logger.Error("车间设备数据加入redis失败:" + err.Error()) | ||
| 67 | - // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 68 | - //} | ||
| 69 | - | ||
| 70 | if err := transactionContext.CommitTransaction(); err != nil { | 64 | if err := transactionContext.CommitTransaction(); err != nil { |
| 71 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 65 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
| 72 | } | 66 | } |
| @@ -127,8 +121,6 @@ func (deviceCollectionService *DeviceCollectionService) DeviceCollection(createD | @@ -127,8 +121,6 @@ func (deviceCollectionService *DeviceCollectionService) DeviceCollection(createD | ||
| 127 | } | 121 | } |
| 128 | 122 | ||
| 129 | //计算区间的产能 | 123 | //计算区间的产能 |
| 130 | - //switch deviceCollection.DeviceType { | ||
| 131 | - //case domain.DeviceTypeBaoXianJi, domain.DeviceTypeChuanChuanJi, domain.DeviceTypeFengKouJi, domain.DeviceTypeFengXiangJi: | ||
| 132 | if v, ok := newDeviceCollection.Values["Count"]; ok { | 124 | if v, ok := newDeviceCollection.Values["Count"]; ok { |
| 133 | newDeviceCollection.Values["total"] = v // 记录原始值 | 125 | newDeviceCollection.Values["total"] = v // 记录原始值 |
| 134 | newDeviceCollection.Values["Count"] = 0 | 126 | newDeviceCollection.Values["Count"] = 0 |
| @@ -146,12 +138,14 @@ func (deviceCollectionService *DeviceCollectionService) DeviceCollection(createD | @@ -146,12 +138,14 @@ func (deviceCollectionService *DeviceCollectionService) DeviceCollection(createD | ||
| 146 | } | 138 | } |
| 147 | } | 139 | } |
| 148 | } | 140 | } |
| 141 | + // TODO:测试假数据,后期注释掉 | ||
| 142 | + //if createDeviceCollectionCommand.DeviceType == domain.DeviceTypeChuanChuanJi { | ||
| 143 | + // newDeviceCollection.Values["Count"] = rand.Intn(300) | ||
| 144 | + //} | ||
| 149 | deviceCollection, err := deviceCollectionRepository.Save(newDeviceCollection) | 145 | deviceCollection, err := deviceCollectionRepository.Save(newDeviceCollection) |
| 150 | if err != nil { | 146 | if err != nil { |
| 151 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 147 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 152 | } | 148 | } |
| 153 | - // break | ||
| 154 | - //} | ||
| 155 | err = domainService.SendWorkshopDeviceData(deviceCollection) | 149 | err = domainService.SendWorkshopDeviceData(deviceCollection) |
| 156 | if err != nil { | 150 | if err != nil { |
| 157 | log.Logger.Error("车间设备数据加入redis失败:" + err.Error()) | 151 | log.Logger.Error("车间设备数据加入redis失败:" + err.Error()) |
| @@ -14,7 +14,7 @@ type ApproveProductRecordCommand struct { | @@ -14,7 +14,7 @@ type ApproveProductRecordCommand struct { | ||
| 14 | // 审核人 | 14 | // 审核人 |
| 15 | ApproveUserId int `cname:"审核人" json:"approveUserId" valid:"Required"` | 15 | ApproveUserId int `cname:"审核人" json:"approveUserId" valid:"Required"` |
| 16 | // 审核后重量 | 16 | // 审核后重量 |
| 17 | - WeighAfter float64 `cname:"审核后重量" json:"weighAfter" valid:"Required"` | 17 | + WeighAfter float64 `cname:"审核后重量" json:"weightAfter" valid:"Required"` |
| 18 | // 审核时间 | 18 | // 审核时间 |
| 19 | //ApproveAt string `cname:"审核时间" json:"approveAt" valid:"Required"` | 19 | //ApproveAt string `cname:"审核时间" json:"approveAt" valid:"Required"` |
| 20 | } | 20 | } |
| @@ -68,5 +68,11 @@ func (info *ProductRecordStaticInfo) PreStatistics(productWeight float64, second | @@ -68,5 +68,11 @@ func (info *ProductRecordStaticInfo) PreStatistics(productWeight float64, second | ||
| 68 | info.BestOutputWeight = info.OutputWeight | 68 | info.BestOutputWeight = info.OutputWeight |
| 69 | } | 69 | } |
| 70 | info.TotalOtherSecondLevelWeigh = totalOtherSecondLevelWeigh | 70 | info.TotalOtherSecondLevelWeigh = totalOtherSecondLevelWeigh |
| 71 | + if info.OutputWeight == 0 || info.InputWeight == 0 { | ||
| 72 | + info.QualificationRate = 0 | ||
| 73 | + } else if info.OutputWeight == info.InputWeight { | ||
| 74 | + info.QualificationRate = 100 | ||
| 75 | + } else { | ||
| 71 | info.QualificationRate = utils.Round(info.OutputWeight*100.0/info.InputWeight, 0) | 76 | info.QualificationRate = utils.Round(info.OutputWeight*100.0/info.InputWeight, 0) |
| 77 | + } | ||
| 72 | } | 78 | } |
| @@ -34,7 +34,7 @@ func (dao *EmployeeProductRecordDao) WorkerProductRecord(companyId, orgId, planI | @@ -34,7 +34,7 @@ func (dao *EmployeeProductRecordDao) WorkerProductRecord(companyId, orgId, planI | ||
| 34 | query.Where("org_id = ?", orgId) | 34 | query.Where("org_id = ?", orgId) |
| 35 | query.Where("product_worker ->>'userId' = '?'", workerId) | 35 | query.Where("product_worker ->>'userId' = '?'", workerId) |
| 36 | query.Where("product_record_info ->>'productPlanId' = '?'", planId) | 36 | query.Where("product_record_info ->>'productPlanId' = '?'", planId) |
| 37 | - query.Where("product_record_info ->>'productDate' = ?", productTime.Format("2006-01-02")) | 37 | + query.Where("product_record_info ->>'productDate' = ?", productTime.Local().Format("2006-01-02")) |
| 38 | if err := query.First(); err != nil { | 38 | if err := query.First(); err != nil { |
| 39 | if err.Error() == "pg: no rows in result set" { | 39 | if err.Error() == "pg: no rows in result set" { |
| 40 | return nil, domain.ErrorNotFound | 40 | return nil, domain.ErrorNotFound |
| @@ -253,7 +253,7 @@ func (ptr *PGProductRecordService) personalProductStatics(productRecord *domain. | @@ -253,7 +253,7 @@ func (ptr *PGProductRecordService) personalProductStatics(productRecord *domain. | ||
| 253 | 253 | ||
| 254 | } else { | 254 | } else { |
| 255 | if record, e := employeeProductRecordDao.WorkerBestOutputRecord(cid, oid, planId, productRecord.ProductWorker.UserId); e == nil && record != nil { | 255 | if record, e := employeeProductRecordDao.WorkerBestOutputRecord(cid, oid, planId, productRecord.ProductWorker.UserId); e == nil && record != nil { |
| 256 | - yesterdayOutputWeight = record.ProductRecordInfo.OutputWeight | 256 | + bestOutputWeight = record.ProductRecordInfo.OutputWeight |
| 257 | } | 257 | } |
| 258 | } | 258 | } |
| 259 | } | 259 | } |
| @@ -58,7 +58,7 @@ func (subscribeClient *SubscribeClient) Connect() *SubscribeClient { | @@ -58,7 +58,7 @@ func (subscribeClient *SubscribeClient) Connect() *SubscribeClient { | ||
| 58 | //} | 58 | //} |
| 59 | } | 59 | } |
| 60 | opts.OnConnect = func(c pahomqtt.Client) { | 60 | opts.OnConnect = func(c pahomqtt.Client) { |
| 61 | - subscribeClient.log.Info("mqtt reconnected") | 61 | + subscribeClient.log.Info("mqtt connected") |
| 62 | c.Subscribe(subscribeClient.topic, 0, subscribeClient.handler) | 62 | c.Subscribe(subscribeClient.topic, 0, subscribeClient.handler) |
| 63 | } | 63 | } |
| 64 | opts.OnReconnecting = func(client pahomqtt.Client, options *pahomqtt.ClientOptions) { | 64 | opts.OnReconnecting = func(client pahomqtt.Client, options *pahomqtt.ClientOptions) { |
| @@ -77,6 +77,8 @@ type LoggerConfig struct { | @@ -77,6 +77,8 @@ type LoggerConfig struct { | ||
| 77 | //MaxBackups int `json:"max_backups,omitempty"` | 77 | //MaxBackups int `json:"max_backups,omitempty"` |
| 78 | //MaxAge int `json:"max_age,omitempty"` | 78 | //MaxAge int `json:"max_age,omitempty"` |
| 79 | //Compress bool `json:"compress,omitempty"` | 79 | //Compress bool `json:"compress,omitempty"` |
| 80 | + //文件最多保存多少天,默认保存 7 天 | ||
| 81 | + //MaxDays int `json:"maxdays"` | ||
| 80 | } | 82 | } |
| 81 | 83 | ||
| 82 | type internalLog struct { | 84 | type internalLog struct { |
-
请 注册 或 登录 后发表评论