作者 yangfu

fix:生产审核修改,统计修改

... ... @@ -42,7 +42,7 @@ func AutoFlushDeviceDailyRunningRecord(ctx context.Context) error {
}
for _, v := range records {
if v.UpdatedAt.Add(time.Minute * 5).Before(time.Now()) {
if v.UpdatedAt.Add(time.Minute * 20).Before(time.Now()) {
log.Logger.Debug(fmt.Sprintf("【定时刷新设备每日运行记录】 跳过记录 %v 最后更新时间:%v", v, v.UpdatedAt))
continue
}
... ...
... ... @@ -61,12 +61,6 @@ func (deviceCollectionService *DeviceCollectionService) CreateDeviceCollection(c
if deviceCollection, err := deviceCollectionRepository.Save(newDeviceCollection); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
//err = domainService.SendWorkshopDeviceData(deviceCollection)
//if err != nil {
// log.Logger.Error("车间设备数据加入redis失败:" + err.Error())
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
//}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
... ... @@ -127,8 +121,6 @@ func (deviceCollectionService *DeviceCollectionService) DeviceCollection(createD
}
//计算区间的产能
//switch deviceCollection.DeviceType {
//case domain.DeviceTypeBaoXianJi, domain.DeviceTypeChuanChuanJi, domain.DeviceTypeFengKouJi, domain.DeviceTypeFengXiangJi:
if v, ok := newDeviceCollection.Values["Count"]; ok {
newDeviceCollection.Values["total"] = v // 记录原始值
newDeviceCollection.Values["Count"] = 0
... ... @@ -146,12 +138,14 @@ func (deviceCollectionService *DeviceCollectionService) DeviceCollection(createD
}
}
}
// TODO:测试假数据,后期注释掉
//if createDeviceCollectionCommand.DeviceType == domain.DeviceTypeChuanChuanJi {
// newDeviceCollection.Values["Count"] = rand.Intn(300)
//}
deviceCollection, err := deviceCollectionRepository.Save(newDeviceCollection)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
// break
//}
err = domainService.SendWorkshopDeviceData(deviceCollection)
if err != nil {
log.Logger.Error("车间设备数据加入redis失败:" + err.Error())
... ...
... ... @@ -14,7 +14,7 @@ type ApproveProductRecordCommand struct {
// 审核人
ApproveUserId int `cname:"审核人" json:"approveUserId" valid:"Required"`
// 审核后重量
WeighAfter float64 `cname:"审核后重量" json:"weighAfter" valid:"Required"`
WeighAfter float64 `cname:"审核后重量" json:"weightAfter" valid:"Required"`
// 审核时间
//ApproveAt string `cname:"审核时间" json:"approveAt" valid:"Required"`
}
... ...
... ... @@ -68,5 +68,11 @@ func (info *ProductRecordStaticInfo) PreStatistics(productWeight float64, second
info.BestOutputWeight = info.OutputWeight
}
info.TotalOtherSecondLevelWeigh = totalOtherSecondLevelWeigh
info.QualificationRate = utils.Round(info.OutputWeight*100.0/info.InputWeight, 0)
if info.OutputWeight == 0 || info.InputWeight == 0 {
info.QualificationRate = 0
} else if info.OutputWeight == info.InputWeight {
info.QualificationRate = 100
} else {
info.QualificationRate = utils.Round(info.OutputWeight*100.0/info.InputWeight, 0)
}
}
... ...
... ... @@ -34,7 +34,7 @@ func (dao *EmployeeProductRecordDao) WorkerProductRecord(companyId, orgId, planI
query.Where("org_id = ?", orgId)
query.Where("product_worker ->>'userId' = '?'", workerId)
query.Where("product_record_info ->>'productPlanId' = '?'", planId)
query.Where("product_record_info ->>'productDate' = ?", productTime.Format("2006-01-02"))
query.Where("product_record_info ->>'productDate' = ?", productTime.Local().Format("2006-01-02"))
if err := query.First(); err != nil {
if err.Error() == "pg: no rows in result set" {
return nil, domain.ErrorNotFound
... ...
... ... @@ -253,7 +253,7 @@ func (ptr *PGProductRecordService) personalProductStatics(productRecord *domain.
} else {
if record, e := employeeProductRecordDao.WorkerBestOutputRecord(cid, oid, planId, productRecord.ProductWorker.UserId); e == nil && record != nil {
yesterdayOutputWeight = record.ProductRecordInfo.OutputWeight
bestOutputWeight = record.ProductRecordInfo.OutputWeight
}
}
}
... ...
... ... @@ -58,7 +58,7 @@ func (subscribeClient *SubscribeClient) Connect() *SubscribeClient {
//}
}
opts.OnConnect = func(c pahomqtt.Client) {
subscribeClient.log.Info("mqtt reconnected")
subscribeClient.log.Info("mqtt connected")
c.Subscribe(subscribeClient.topic, 0, subscribeClient.handler)
}
opts.OnReconnecting = func(client pahomqtt.Client, options *pahomqtt.ClientOptions) {
... ...
... ... @@ -77,6 +77,8 @@ type LoggerConfig struct {
//MaxBackups int `json:"max_backups,omitempty"`
//MaxAge int `json:"max_age,omitempty"`
//Compress bool `json:"compress,omitempty"`
//文件最多保存多少天,默认保存 7 天
//MaxDays int `json:"maxdays"`
}
type internalLog struct {
... ...