device_collection.go
1.3 KB
package transform
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/pg/models"
)
func TransformToDeviceCollectionDomainModelFromPgModels(deviceCollectionModel *models.DeviceCollection) (*domain.DeviceCollection, error) {
if deviceCollectionModel.DeviceType == domain.DeviceTypeYouZhaJi {
if tmp, ok := deviceCollectionModel.Values["Temp1"]; ok {
deviceCollectionModel.Values["FrontTemp"] = tmp
}
if tmp, ok := deviceCollectionModel.Values["Temp2"]; ok {
deviceCollectionModel.Values["TankTemp"] = tmp
}
if tmp, ok := deviceCollectionModel.Values["Temp3"]; ok {
deviceCollectionModel.Values["BackTemp"] = tmp
}
}
return &domain.DeviceCollection{
DeviceCollectionId: deviceCollectionModel.DeviceCollectionId,
WorkShopName: deviceCollectionModel.WorkShopName,
DeviceSn: deviceCollectionModel.DeviceSn,
DeviceType: deviceCollectionModel.DeviceType,
StartupStatus: deviceCollectionModel.StartupStatus,
CollectionTime: deviceCollectionModel.CreatedAt,
ComStatus: deviceCollectionModel.ComStatus,
Values: deviceCollectionModel.Values,
ProductCount: deviceCollectionModel.ProductCount,
LatestUpdateTime: deviceCollectionModel.LatestUpdateTime,
}, nil
}