123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- package service
- import (
- deviceDao "iot_manager_service/app/device/dao"
- )
- type BigService interface {
- DeviceCount() deviceDao.DeviceStatus
- ListDevices() []deviceDao.Device
- }
- var BigServer = new(bigService)
- type bigService struct {
- }
- func (big *bigService) DeviceNum(queryType string) deviceDao.QueryDevices {
- var server BigService
- server = getService(queryType)
- obj := server.DeviceCount()
- return deviceDao.QueryDevices{
- CountNum: obj.CountNum,
- FaultNum: obj.FaultNum,
- Devices: server.ListDevices(),
- }
- }
- func (big *bigService) GetLampCount() (int64, int64) {
- dao := deviceDao.LampPole{}
- all, err1 := dao.CountAll()
- fault, err2 := dao.CountFault()
- if err1 != nil {
- all = 0
- }
- if err2 != nil {
- fault = 0
- }
- return all, fault
- }
- func (big *bigService) DevicesStatus() []deviceDao.DeviceStatus {
- //1.灯杆 2.灯控 3.摄像头 4.led 5.环境传感器 6.网关 7. 报警器 8.管理端
- //9.路面状况传感器 10.ip音柱 11.集控器 12.抓拍单元
- var names = []string{"camera", "wisdomGateway", "lightControl", "switchBox", "infoBoard",
- "optoSensor", "zigBee", "aKeyAlarmTerminal", "aKeyAlarmServe", "lampPole", "captureUnit", "bridgeSensor", "ipCast", "manhole"}
- var rsp = make([]deviceDao.DeviceStatus, 0, 14)
- for _, v := range names {
- ds := getService(v).DeviceCount()
- ds.DeviceType = v
- rsp = append(rsp, ds)
- }
- return rsp
- }
- func (big *bigService) AlarmStatus() []deviceDao.DeviceStatus {
- var names = []string{"camera", "lightControl", "infoBoard", "optoSensor",
- "zigBee", "lampPole", "captureUnit"}
- var rsp = make([]deviceDao.DeviceStatus, 0, 6)
- for _, v := range names {
- ds := getService(v).DeviceCount()
- ds.DeviceType = v
- rsp = append(rsp, ds)
- }
- return rsp
- }
- func getService(deviceName string) BigService {
- switch deviceName {
- case "camera":
- return CameraService
- case "wisdomGateway", "gateway":
- return GatewayService
- case "lightControl", "control":
- return LightControlService
- case "switchBox", "box":
- return SwitchBoxService
- case "infoBoard", "board":
- return InfoBoardService
- case "optoSensor", "sensor":
- return OptoSensorService
- case "zigBee", "zigbee":
- return ZigbeeService
- case "aKeyAlarmTerminal", "terminal":
- return AlarmTerminalService
- case "aKeyAlarmServe", "serve":
- return AlarmService
- case "lampPole", "lamppole":
- return LampPoleService
- case "captureUnit":
- return CaptureUintService
- case "bridgeSensor", "xueshui":
- return BridgeService
- case "ipCast", "ipcast":
- return IpBroadcastService
- case "manhole":
- return ManholeCoverService
- default:
- return nil
- }
- }
- func (big *bigService) GetEnergy(start, end string) []deviceDao.Energy {
- return deviceDao.GetEnergy(start, end)
- }
- func (big *bigService) GetLightRate(tenant string) []interface{} {
- return deviceDao.GetLightRate(tenant)
- }
- func (big *bigService) GetAlarmInfo() deviceDao.AlarmList {
- return deviceDao.GetAlarmInfo()
- }
- func (big *bigService) GetEnv(deviceId string) deviceDao.Environment {
- return deviceDao.GetEnvData(deviceId)
- }
- func (big *bigService) GetLEDProgram(tenantId string) []deviceDao.InfoBoardProgram {
- return deviceDao.GetLEDProgramList(tenantId)
- }
- func (big *bigService) GetProgramUrl(id string) deviceDao.Program {
- return deviceDao.GetProgramUrl(id)
- }
- func (big *bigService) GetBridgeSensors(tenantId string) []deviceDao.Sensor {
- return deviceDao.GetBridgeSensors(tenantId)
- }
- func (big *bigService) OverView(tenantId, padScreen string) []deviceDao.OverViewInfo {
- dao := deviceDao.OverView{}
- return dao.Query(tenantId, padScreen)
- }
- func (big *bigService) Submit(data []deviceDao.OverView) {
- dao := deviceDao.OverView{}
- for _, v := range data {
- dao.Submit(v)
- }
- }
|