123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- package service
- import (
- "fmt"
- dataDao "iot_manager_service/app/data/dao"
- "iot_manager_service/app/device/dao"
- "iot_manager_service/app/device/model"
- "iot_manager_service/util/common"
- )
- // 中间件管理服务
- var WorkbenchService = new(workbenchService)
- type workbenchService struct{}
- func (s *workbenchService) CountDevice(tenantId int) ([]dao.CountDevice, *common.Errors) {
- counts, err := dao.GetDeviceCount(tenantId)
- if err != nil {
- return nil, common.FailResponse(err.Error(), nil)
- }
- return counts, nil
- }
- func (s *workbenchService) CountAlarm(tenantId int) (*dao.CountAlarm, *common.Errors) {
- count, err := dao.GetAlarmCount(tenantId)
- if err != nil {
- return nil, common.FailResponse(err.Error(), nil)
- }
- return count, nil
- }
- func (s *workbenchService) CountJobTodo(tenantId int) (*dao.CountAlarm, *common.Errors) {
- count, err := dao.GetAlarmCount(tenantId)
- if err != nil {
- return nil, common.FailResponse(err.Error(), nil)
- }
- return count, nil
- }
- func (s *workbenchService) Notification(tenantId int) (*dao.Notification, *common.Errors) {
- notification, err := dao.GetNotification(tenantId)
- if err != nil {
- return nil, common.FailResponse(err.Error(), nil)
- }
- return notification, nil
- }
- func (s *workbenchService) LightRate(tenantId int) (*model.RspLightRate, *common.Errors) {
- var rsp model.RspLightRate
- return &rsp, nil
- }
- //工作台-采集点
- func (s *workbenchService) Aqi(tenantId int) (interface{}, interface{}) {
- aqi, err := dao.GetAqi(tenantId)
- if err != nil {
- return nil, common.FailResponse(err.Error(), nil)
- }
- s.getNewsDate(aqi)
- return aqi, nil
- }
- func (s *workbenchService) getNewsDate(vo *dao.OptoSensorVO) *dao.OptoSensorVO {
- //var meteorologicalDataList []omodel.EnvironmentDetail
- //meteorologicalDataVO := omodel.EnvironmentDetail{}
- //meteorologicalDataVO.Sn = vo.Sn
- //meteorologicalDataList = append(meteorologicalDataList, meteorologicalDataVO)
- devId := vo.ID
- environmentData := dataDao.EnvironmentData{DeviceId: devId}
- environmentData.Get()
- vo.RealTimeTemperature = fmt.Sprintf("%.2f ℃", environmentData.Temperature)
- vo.Pm25 = fmt.Sprintf("%.2f ug/m³", environmentData.Pm25)
- vo.AirIndex = int(environmentData.Air)
- vo.AirQuality = common.CalculateAirQuality(string(fmt.Sprintf("%.2f", environmentData.Air)))
- vo.EndLineTime = vo.UpdateTime.Format("2006-01-02 15:04:05")
- vo.Humidity = fmt.Sprintf("%.2f", environmentData.Humidity)
- vo.Pm10 = fmt.Sprintf("%.2f", environmentData.Pm10)
- vo.Noise = fmt.Sprintf("%.2f", environmentData.Noise)
- vo.Pressure = fmt.Sprintf("%.2f", environmentData.Hpa) //大气压
- vo.Direction = common.CalculateDirection(environmentData.WindDirection) //风向
- vo.RealTimeWindSpeed = common.CalculateSpeed(fmt.Sprintf("%.2f", environmentData.WindSpeed)) //风力等级
- return vo
- }
|