engineerper il y a 2 ans
Parent
commit
440a24f3ee
100 fichiers modifiés avec 0 ajouts et 9727 suppressions
  1. 0 161
      app/data/controller/calcTask.go
  2. 0 177
      app/data/dao/environmentDao.go
  3. 0 34
      app/data/dao/garbageDao.go
  4. 0 45
      app/data/model/environmentData.go
  5. 0 41
      app/data/model/garbageData.go
  6. 0 160
      app/data/service/environmentDataService.go
  7. 0 65
      app/data/service/garbageDataService.go
  8. 0 125
      app/device/controller/GatewayController.go
  9. 0 153
      app/device/controller/IntelligentLightingStrategy.go
  10. 0 96
      app/device/controller/LightStrategy.go
  11. 0 20
      app/device/controller/OnDemandLightingControlStrategy.go
  12. 0 113
      app/device/controller/alarmController.go
  13. 0 98
      app/device/controller/alarmTerminalController.go
  14. 0 136
      app/device/controller/bigController.go
  15. 0 113
      app/device/controller/bridgeController.go
  16. 0 131
      app/device/controller/bridgeSensorController.go
  17. 0 139
      app/device/controller/cameraController.go
  18. 0 188
      app/device/controller/captureUintController.go
  19. 0 113
      app/device/controller/garbageController.go
  20. 0 104
      app/device/controller/garbageWayGroupController.go
  21. 0 201
      app/device/controller/infoBoardController.go
  22. 0 173
      app/device/controller/ipBroadcastController.go
  23. 0 145
      app/device/controller/lampPoleController.go
  24. 0 150
      app/device/controller/lampPoleGroupController.go
  25. 0 142
      app/device/controller/lightController.go
  26. 0 140
      app/device/controller/manholeCoverController.go
  27. 0 121
      app/device/controller/onDemandGroupController.go
  28. 0 104
      app/device/controller/onDemandSensorController.go
  29. 0 116
      app/device/controller/optoSensorController.go
  30. 0 112
      app/device/controller/switchBoxController.go
  31. 0 104
      app/device/controller/transformerController.go
  32. 0 219
      app/device/controller/utilController.go
  33. 0 104
      app/device/controller/workbenchController.go
  34. 0 110
      app/device/controller/zigbeeController.go
  35. 0 90
      app/device/dao/LightStrategyDao.go
  36. 0 120
      app/device/dao/alarmDao.go
  37. 0 146
      app/device/dao/alarmTerminalDao.go
  38. 0 178
      app/device/dao/bigModel.go
  39. 0 158
      app/device/dao/bigScreen.go
  40. 0 131
      app/device/dao/bridgeDao.go
  41. 0 95
      app/device/dao/bridgeSensorDao.go
  42. 0 155
      app/device/dao/cameraDao.go
  43. 0 128
      app/device/dao/captureUnitDao.go
  44. 0 67
      app/device/dao/checkPointDao.go
  45. 0 46
      app/device/dao/common.go
  46. 0 107
      app/device/dao/garbageDao.go
  47. 0 79
      app/device/dao/garbageWayGroupDao.go
  48. 0 141
      app/device/dao/gatewayDao.go
  49. 0 69
      app/device/dao/gatewayRelationDao.go
  50. 0 174
      app/device/dao/infoBoardDao.go
  51. 0 182
      app/device/dao/intelligentLightingDao.go
  52. 0 160
      app/device/dao/ipBroadcastDao.go
  53. 0 178
      app/device/dao/lampPoleDao.go
  54. 0 89
      app/device/dao/lampPoleGroupDao.go
  55. 0 38
      app/device/dao/lightConditionDao.go
  56. 0 170
      app/device/dao/lightControlDao.go
  57. 0 149
      app/device/dao/manholeCoverDao.go
  58. 0 79
      app/device/dao/onDemandGroupDao.go
  59. 0 86
      app/device/dao/onDemandSensorDao.go
  60. 0 168
      app/device/dao/optoSensoDao.go
  61. 0 165
      app/device/dao/switchBoxDao.go
  62. 0 21
      app/device/dao/tenantCodeDao.go
  63. 0 52
      app/device/dao/timeConditionDao.go
  64. 0 90
      app/device/dao/transformerDao.go
  65. 0 74
      app/device/dao/venderDao.go
  66. 0 218
      app/device/dao/workbenchDao.go
  67. 0 147
      app/device/dao/zigbeeDao.go
  68. 0 71
      app/device/edge_service/cltLedControlService.go
  69. 0 66
      app/device/edge_service/forLightControlService.go
  70. 0 201
      app/device/edge_service/ipCastControlService.go
  71. 0 35
      app/device/model/LightStrategy.go
  72. 0 25
      app/device/model/alarmTerminal.go
  73. 0 15
      app/device/model/alarn.go
  74. 0 15
      app/device/model/bridge.go
  75. 0 24
      app/device/model/bridgeSensor.go
  76. 0 41
      app/device/model/camera.go
  77. 0 42
      app/device/model/captureUint.go
  78. 0 52
      app/device/model/common.go
  79. 0 15
      app/device/model/garbage.go
  80. 0 15
      app/device/model/garbageWayGroup.go
  81. 0 38
      app/device/model/gateway.go
  82. 0 50
      app/device/model/infoBoard.go
  83. 0 61
      app/device/model/intelligentLighting.go
  84. 0 25
      app/device/model/ipBroadcast.go
  85. 0 40
      app/device/model/lampPole.go
  86. 0 27
      app/device/model/lampPoleGroup.go
  87. 0 42
      app/device/model/lightControl.go
  88. 0 15
      app/device/model/manholeCover.go
  89. 0 22
      app/device/model/onDemandGroup.go
  90. 0 15
      app/device/model/onDemandSensor.go
  91. 0 25
      app/device/model/optoSenso.go
  92. 0 15
      app/device/model/switchBox.go
  93. 0 15
      app/device/model/transformer.go
  94. 0 15
      app/device/model/util.go
  95. 0 26
      app/device/model/workbench.go
  96. 0 25
      app/device/model/zigbee.go
  97. 0 264
      app/device/service/LightStrategyService.go
  98. 0 140
      app/device/service/alarmService.go
  99. 0 147
      app/device/service/alarmTerminalService.go
  100. 0 0
      app/device/service/bigService.go

+ 0 - 161
app/data/controller/calcTask.go

@@ -1,161 +0,0 @@
-package controller
-
-import (
-	"bytes"
-	"encoding/json"
-	"github.com/robfig/cron"
-	"io/ioutil"
-	"iot_manager_service/app/data/model"
-	"iot_manager_service/app/data/service"
-	deviceCtl "iot_manager_service/app/device/controller"
-	deviceSer "iot_manager_service/app/device/service"
-	recordCtl "iot_manager_service/app/record/controller"
-	warnSer "iot_manager_service/app/warn/service"
-	"iot_manager_service/util/cache"
-	"iot_manager_service/util/logger"
-	"net/http"
-	"time"
-)
-
-func CalcTask() {
-	hourSpec := "0 0 */1 * * ?"
-	//minuteSpec := "0 */1 * * * ?"
-	daySpec := "0 1 0 * * ?"
-	c := cron.New()
-	_ = c.AddFunc(hourSpec, func() {
-		devices := deviceSer.GarbageService.GetAll()
-		var deviceIds []string
-		for _, d := range devices {
-			deviceIds = append(deviceIds, d.DeviceIMei)
-		}
-		GarbageDataSync(deviceIds)
-	})
-
-	//【环境传感】日数据 统计
-	_ = c.AddFunc(hourSpec, func() {
-		service.EnvironmentDataService.DataSync()
-	})
-	//【环境传感】天数据 统计
-	_ = c.AddFunc(daySpec, func() {
-		service.EnvironmentDataService.DayDataSync()
-	})
-	//【告警管理】处理告警消息 同步告警
-	c.AddFunc("0 1 0 * * ?", func() {
-		warnSer.PlatformAlarmService.SyncAlarm()
-	})
-	//【告警管理】发送告警
-	_ = c.AddFunc(hourSpec, func() {
-		//发送告警
-		warnSer.TaskWarnService.HandlingAlarms()
-	})
-	//【一键告警】每59秒 同步记录
-	c.AddFunc("*/59 * * * * ?", func() {
-		recordCtl.AKeyAlarmRecord.SosRecordSync()
-	})
-	//【led信息屏】每天6点和18点0分之后 同步亮度与音量(白天亮度高音量大,晚上变小)
-	c.AddFunc("1 0 6,18 * * ?", func() {
-		deviceCtl.InfoBoard.CronSyncBrightnessAndMusicvolume()
-	})
-	//【led信息屏】每59秒 播放节目同步
-	c.AddFunc("*/59 * * * * ?", func() {
-		deviceCtl.InfoBoard.CronSyncLedPaying(0)
-	})
-	//【IP音柱】每59秒 播放节目同步
-	c.AddFunc("*/10 * * * * ?", func() {
-		deviceCtl.IpBroadcast.CronSyncIpCastPaying(0)
-	})
-	c.Start()
-}
-
-func GarbageDataSync(deviceIds []string) {
-	if len(deviceIds) == 0 {
-		return
-	}
-	url := "http://124.239.149.63:5000/admin/garbage/can/getGarbageCanByDeviceIdsList"
-	req := model.GarbageDataReq{
-		DeviceIds: deviceIds,
-	}
-	data, err := json.Marshal(&req)
-	if err != nil {
-		logger.Logger.Warningf("GarbageDataSync Marshal err = %s", err.Error())
-		return
-	}
-	body := bytes.NewBuffer(data)
-	request, err := http.NewRequest("POST", url, body)
-	if err != nil {
-		logger.Logger.Warningf("GarbageDataSync NewRequest err = %s", err.Error())
-		return
-	}
-	request.Header.Set("Authorization", "Bearer "+GarbageLogin())
-	request.Header.Set("Content-Type", "application/json")
-	response, err := http.DefaultClient.Do(request)
-	if err != nil {
-		logger.Logger.Warningf("GarbageDataSync Do err = %s", err.Error())
-		return
-	}
-	rspData, err := ioutil.ReadAll(response.Body)
-	if err != nil {
-		logger.Logger.Warningf("GarbageDataSync ReadAll err = %s", err.Error())
-		return
-	}
-	var rsp model.GarbageDataRsp
-	err = json.Unmarshal(rspData, &rsp)
-	if err != nil {
-		logger.Logger.Warningf("GarbageDataSync Unmarshal err = %s", err.Error())
-		return
-	}
-	if rsp.Code != 0 {
-		logger.Logger.Warningf("GarbageDataSync rsp.Code != 0 msg = %s", rsp.Msg)
-		return
-	}
-
-	service.GarbageDataService.BatchSave(rsp.Data)
-}
-
-func GarbageLogin() string {
-	value, err := cache.Redis.Get(model.GarbageLoginKey).Result()
-	if err == nil {
-		return value
-	}
-
-	url := "http://124.239.149.63:5000/admin/user/login"
-	req := model.GarbageLoginReq{
-		Username: "湖南溢满1",
-		Password: "T2rMLUCMaaBXfjBjZ7myOA==",
-	}
-	data, err := json.Marshal(&req)
-	if err != nil {
-		logger.Logger.Warningf("GarbageLogin Marshal err = %s", err.Error())
-		return ""
-	}
-	body := bytes.NewBuffer(data)
-	request, err := http.NewRequest("POST", url, body)
-	if err != nil {
-		logger.Logger.Warningf("GarbageLogin NewRequest err = %s", err.Error())
-		return ""
-	}
-	request.Header.Set("Content-Type", "application/json")
-
-	response, err := http.DefaultClient.Do(request)
-	if err != nil {
-		logger.Logger.Warningf("GarbageLogin Do err = %s", err.Error())
-		return ""
-	}
-	rspData, err := ioutil.ReadAll(response.Body)
-	if err != nil {
-		logger.Logger.Warningf("GarbageLogin ReadAll err = %s", err.Error())
-		return ""
-	}
-	var rsp model.GarbageLoginRsp
-	err = json.Unmarshal(rspData, &rsp)
-	if err != nil {
-		logger.Logger.Warningf("GarbageLogin Unmarshal err = %s", err.Error())
-		return ""
-	}
-	if rsp.Code != 0 {
-		logger.Logger.Warningf("GarbageLogin rsp.Code != 0 msg = %s", rsp.Msg)
-		return ""
-	}
-	cache.Redis.Set(model.GarbageLoginKey, rsp.Data.AccessToken, 2*time.Hour)
-	return rsp.Data.AccessToken
-}

+ 0 - 177
app/data/dao/environmentDao.go

@@ -1,177 +0,0 @@
-package dao
-
-import "time"
-
-// EnvironmentData 环境监测器数据
-type EnvironmentData struct {
-	ID            int       `gorm:"primary_key" json:"id"`                 //编号
-	DeviceId      int       `gorm:"type:int" json:"deviceId"`              //设备名称
-	Pm25          float32   `gorm:"type:float(10, 2)" json:"pm25"`         //PM2.5
-	Pm10          float32   `gorm:"type:float(10, 2)" json:"pm10"`         //PM10
-	WindSpeed     float32   `gorm:"type:float(10, 2)" json:"windSpeed"`    //风速
-	WindDirection string    `gorm:"type:varchar(10)" json:"windDirection"` //风向
-	Hpa           float32   `gorm:"type:float(10, 2)" json:"hpa"`          //气压
-	Rainfall      float32   `gorm:"type:float(10, 2)" json:"rainfall"`     //降雨量
-	Temperature   float32   `gorm:"type:float(10, 2)" json:"temp"`         //温度
-	Humidity      float32   `gorm:"type:float(10, 2)" json:"humidity"`     //湿度
-	Noise         float32   `gorm:"type:float(10, 2)" json:"noise"`        //噪音
-	Ultraviolet   float32   `gorm:"type:float(10, 2)" json:"ultraviolet"`  //紫外线
-	Illuminance   float32   `gorm:"type:float(10, 2)" json:"illuminance"`  //光照强度
-	Air           float32   `gorm:"type:float(10, 2)" json:"air"`          //空气质量指数
-	AirName       string    `gorm:"varchar(100)" json:"airName"`           //空气质量指数
-	IsDay         int       `gorm:"type:int" json:"isDay"`                 //是否用于天数据 7点的采集数据用于天数据,0否 1是
-	TenantId      string    `gorm:"type:varchar(12)" json:"tenantId"`
-	PostTime      time.Time `gorm:"type:datetime" json:"postTime"`      //采集时间
-	CreateTime    time.Time `gorm:"type:datetime" json:"createTime"`    //新增时间
-	CreateDate    string    `gorm:"type:varchar(50)" json:"createDate"` //显示时间
-}
-
-type EnvironmentScopeData struct {
-	Time      string `json:"time"`
-	Val       string `json:"val"`
-	Maxval    string `json:"maxval"`
-	Minval    string `json:"minval"`
-	ModelType int    `json:"modelType"`
-}
-
-func (EnvironmentData) TableName() string {
-	return "data_environment"
-}
-
-func (c *EnvironmentData) Save() error {
-	return Db.Model(&c).Create(&c).Error
-}
-
-func (c *EnvironmentData) BatchSave(data []EnvironmentData) error {
-	return Db.Model(&c).Create(&data).Error
-}
-
-func (c *EnvironmentData) Get() error {
-	return Db.Model(&c).Where("device_id = ?", c.DeviceId).Order("post_time desc").First(&c).Error
-}
-
-func (c *EnvironmentData) GetByTime(start, end time.Time) ([]EnvironmentData, error) {
-	var data []EnvironmentData
-	err := Db.Model(&c).Where("device_id = ? and is_day = ? and create_time >= ? and create_time <= ?",
-		c.DeviceId, c.IsDay, start, end).Order("create_time").Find(&data).Error
-	return data, err
-}
-
-func (c *EnvironmentData) GetEnvironmentScope(queryType int, s string) []EnvironmentScopeData {
-	var environmentScope []EnvironmentScopeData
-	var field string
-	switch queryType {
-	case 1:
-		field = "air"
-	case 2:
-		field = "pm25"
-	case 3:
-		field = "pm10"
-	case 4:
-		field = "temperature"
-	case 5:
-		field = "humidity"
-	case 6:
-		field = "wind_speed"
-	case 7:
-		field = "hpa"
-	case 8:
-		field = "noise"
-	}
-	dateStr := "%Y-%m-%d %H:00:00"
-	postTime := time.Now().Format("2006-01-02")
-	if s == "history" {
-		postTime = time.Now().AddDate(0, 0, -1).Format("2006-01-02")
-	}
-	if c.IsDay != 1 {
-		dateStr = "%Y-%m-%d 00:00:00"
-		postTime = time.Now().Format("2006-01-02")
-		if s == "history" {
-			postTime = time.Now().AddDate(0, -1, 0).Format("2006-01-02")
-		}
-	}
-	sql := `
-		SELECT
-			DATE_FORMAT( ( post_time ), '` + dateStr + `' ) AS time,
-			ROUND(min(` + field + `), 2) AS minval,
-			ROUND(max(` + field + `),2) as maxval,
-			ROUND(avg(` + field + `),2)as val
-		FROM
-			data_environment 
-		WHERE
-			device_id = ? and
-			post_time LIKE "` + postTime + `%"
-			GROUP BY DATE_FORMAT( ( post_time ), '` + dateStr + `' )
-			`
-	Db.Raw(sql, c.DeviceId).Find(&environmentScope)
-	return environmentScope
-}
-
-// EnvironmentDataDay 环境监测器天数据统计
-type EnvironmentDataSummary struct {
-	DeviceId int `gorm:"type:int" json:"deviceId"` //设备名称
-	//1=空气质量 2=PM2.5 3=pm10 4=温度 5=湿度 6=风速 7=气压 8=噪音 9=光照强度 10=风向 11=降雨量 12=紫外线
-	DataType   int       `gorm:"type:int" json:"dataType"`
-	ValAvg     float32   `gorm:"type:float(10, 2)" json:"valAvg"`       //天均值
-	ValMax     float32   `gorm:"type:float(10, 2)" json:"valMax"`       //天最大
-	ValMin     float32   `gorm:"type:float(10, 2)" json:"valMin"`       //天最小
-	CreateTime time.Time `gorm:"type:datetime;index" json:"createTime"` //新增时间
-}
-
-func (EnvironmentDataSummary) TableName() string {
-	return "data_environment_summary"
-}
-
-func (c *EnvironmentDataSummary) DaySummary(start, end time.Time) error {
-	err := Db.Model(&c).Exec(`INSERT INTO data_environment_summary
-    select device_id,
-       data_type,
-       round(avg(value), 2)    val_avg,
-       max(if(value='',0,value))           val_max,
-       min(if(value='',0,value))           val_min,
-       adddate(current_date, -1) create_time
-from (
-         SELECT device_id, 2 AS data_type, pm25 AS value, create_time
-         FROM data_environment
-         UNION ALL
-         SELECT device_id, 3 AS data_type, pm10 AS value, create_time
-         FROM data_environment
-         UNION ALL
-         SELECT device_id, 4 AS data_type, wind_speed AS value, create_time
-         FROM data_environment
-         UNION ALL
-         SELECT device_id, 5 AS data_type, wind_direction AS value, create_time
-         FROM data_environment
-         UNION ALL
-         SELECT device_id, 6 AS data_type, hpa AS value, create_time
-         FROM data_environment
-         UNION ALL
-         SELECT device_id, 7 AS data_type, rainfall AS value, create_time
-         FROM data_environment
-         UNION ALL
-         SELECT device_id, 8 AS data_type, temperature AS value, create_time
-         FROM data_environment
-         UNION ALL
-         SELECT device_id, 9 AS data_type, humidity AS value, create_time
-         FROM data_environment
-         UNION ALL
-         SELECT device_id, 10 AS data_type, noise AS value, create_time
-         FROM data_environment
-         UNION ALL
-         SELECT device_id, 11 AS data_type, ultraviolet AS value, create_time
-         FROM data_environment
-         UNION ALL
-         SELECT device_id, 12 AS data_type, illuminance AS value, create_time
-         FROM data_environment
-         UNION ALL
-         SELECT device_id, 1 AS data_type, air AS value, create_time
-         FROM data_environment
-     ) a
-where data_type!=5 and create_time > ? and create_time <= ?
-group by device_id, data_type`, start, end).Error
-	return err
-}
-
-func (c *EnvironmentDataSummary) Get() error {
-	return Db.Model(&c).Where("device_id = ?", c.DeviceId).Order("create_time desc").First(&c).Error
-}

+ 0 - 34
app/data/dao/garbageDao.go

@@ -1,34 +0,0 @@
-package dao
-
-// GarbageData 垃圾桶数据
-type GarbageData struct {
-	ID                  int     `gorm:"primary_key" json:"id"`                       //编号
-	DeviceId            string  `gorm:"type:varchar(20)" json:"deviceId"`            //设备名称
-	StartTime           string  `gorm:"type:varchar(15)" json:"startTime"`           //工作时段开始时间
-	EndTime             string  `gorm:"type:varchar(15)" json:"endTime"`             //工作时段结束时间
-	PostTime            string  `gorm:"type:varchar(30)" json:"postTime"`            //上传时间
-	BatteryVoltage      float32 `gorm:"type:float(5, 1)" json:"batteryVoltage"`      //电池电压
-	BatteryPercentage   float32 `gorm:"type:float(5, 1)" json:"batteryPercentage"`   //电池电量
-	SensorCount         int     `gorm:"type:int" json:"sensorCount"`                 //传感器通道数量
-	SensorOne           float32 `gorm:"type:float(5, 1)" json:"sensorOne"`           //通道一原始数值
-	SensorTwo           float32 `gorm:"type:float(5, 1)" json:"sensorTwo"`           //通道二原始数值
-	SensorOnePercentage float32 `gorm:"type:float(5, 1)" json:"sensorOnePercentage"` //通道一垃圾量百分比
-	SensorTwoPercentage float32 `gorm:"type:float(5, 1)" json:"sensorTwoPercentage"` //通道二垃圾量百分比
-	WorkTime            string  `gorm:"type:varchar(50)" json:"workTime"`            //工作时间段
-}
-
-func (GarbageData) TableName() string {
-	return "data_garbage"
-}
-
-func (c *GarbageData) Save() error {
-	return Db.Model(&c).Create(&c).Error
-}
-
-func (c *GarbageData) BatchSave(data []GarbageData) error {
-	return Db.Model(&c).Create(&data).Error
-}
-
-func (c *GarbageData) Get() error {
-	return Db.Model(&c).Where("device_id = ?", c.DeviceId).Find(&c).Error
-}

+ 0 - 45
app/data/model/environmentData.go

@@ -1,45 +0,0 @@
-package model
-
-const EnvironmentDataKey = "environment_data_%d"
-
-const (
-	ModelInfoDefault       = iota
-	ModelInfoNoise         //噪音
-	ModelInfoPM25          //pm2.5
-	ModelInfoPM10          //pm10
-	ModelInfoTemprature    //温度
-	ModelInfoHumidity      //湿度
-	ModelInfoPressure      //气压
-	ModelInfowindSpeed     //风速
-	ModelInfoWindDirection //风向
-
-	ModelInfoRainfall        //降雨量
-	ModelInfoUltravioletRays //紫外线
-	ModelInfoLightIntensity  //光照强度
-
-	ModelInfoAirQuality      //空气质量
-	ModelInfoAll        = 20 //综合,所有类型
-	ModelInfoAQI        = 21 //空气质量AQI
-)
-
-func CalculateDirection(windDirection float32) string {
-	result := "-"
-	if windDirection > 337.5 || windDirection <= 22.5 {
-		result = "北"
-	} else if windDirection > 22.5 || windDirection <= 67.5 {
-		result = "东北"
-	} else if windDirection > 67.5 || windDirection <= 112.5 {
-		result = "东"
-	} else if windDirection > 112.5 || windDirection <= 157.5 {
-		result = "东南"
-	} else if windDirection > 157.5 || windDirection <= 202.5 {
-		result = "南"
-	} else if windDirection > 202.5 || windDirection <= 247.5 {
-		result = "西南"
-	} else if windDirection > 247.5 || windDirection <= 292.5 {
-		result = "西"
-	} else if windDirection > 292.5 || windDirection <= 337.5 {
-		result = "西北"
-	}
-	return result
-}

+ 0 - 41
app/data/model/garbageData.go

@@ -1,41 +0,0 @@
-package model
-
-type GarbageDataRsp struct {
-	Code int                 `json:"code"`
-	Msg  string              `json:"msg"`
-	Data []GarbageDataDetail `json:"data"`
-}
-
-type GarbageDataReq struct {
-	DeviceIds []string `json:"deviceIds"`
-}
-type GarbageDataDetail struct {
-	DeviceId            string  `json:"deviceId"`
-	StartTime           string  `json:"startTime"`
-	EndTime             string  `json:"endTime"`
-	PostTime            string  `json:"postTime"`
-	BatteryVoltage      float32 `json:"batteryVoltage"`
-	BatteryPercentage   float32 `json:"batteryPercentage"`
-	SensorCount         int     `json:"sensorCount"`
-	SensorOne           float32 `json:"sensorOne"`
-	SensorTwo           float32 `json:"sensorTwo"`
-	SensorOnePercentage float32 `json:"sensorOnePercentage"`
-	SensorTwoPercentage float32 `json:"sensorTwoPercentage"`
-	WorkTime            string  `json:"workTime"`
-}
-
-type GarbageLoginReq struct {
-	Username string `json:"username"`
-	Password string `json:"password"`
-}
-type GarbageLoginRsp struct {
-	Code int    `json:"code"`
-	Msg  string `json:"msg"`
-	Data struct {
-		AccessToken string `json:"access_token"`
-	} `json:"data"`
-}
-
-const GarbageLoginKey = "garbage_login_token"
-
-const GarbageDataKey = "garbage_data_%s"

+ 0 - 160
app/data/service/environmentDataService.go

@@ -1,160 +0,0 @@
-package service
-
-import (
-	"encoding/json"
-	"fmt"
-	"iot_manager_service/app/data/dao"
-	"iot_manager_service/app/data/model"
-	device "iot_manager_service/app/device/service"
-	"iot_manager_service/util/cache"
-	"iot_manager_service/util/common"
-	"iot_manager_service/util/logger"
-	"strconv"
-	"time"
-)
-
-var EnvironmentDataService = new(environmentDataService)
-
-type environmentDataService struct{}
-
-func (s *environmentDataService) DataSync() {
-	devices := device.OptoSensorService.GetAll()
-	if len(devices) == 0 {
-		return
-	}
-
-	var environmentDatas []dao.EnvironmentData
-	for _, d := range devices {
-		creatTime, values := cache.GetDeviceData(d.Sn)
-		now := time.Now()
-		environmentData := dao.EnvironmentData{
-			DeviceId:   d.ID,
-			PostTime:   creatTime,
-			TenantId:   d.TenantId,
-			CreateTime: time.Date(now.Year(), now.Month(), now.Day(), now.Hour(), 0, 0, 0, time.Local),
-		}
-		for key, value := range values {
-			switch key {
-			case model.ModelInfoNoise:
-				environmentData.Noise = value
-			case model.ModelInfoPM25:
-				environmentData.Pm25 = value
-			case model.ModelInfoPM10:
-				environmentData.Pm10 = value
-			case model.ModelInfoTemprature:
-				environmentData.Temperature = value
-			case model.ModelInfoHumidity:
-				environmentData.Humidity = value
-			case model.ModelInfoPressure:
-				environmentData.Hpa = value
-			case model.ModelInfowindSpeed:
-				environmentData.WindSpeed = value
-			case model.ModelInfoWindDirection:
-				//environmentData.WindDirection = model.CalculateDirection(value)
-				environmentData.WindDirection = model.CalculateDirection(value)
-			case model.ModelInfoRainfall:
-				environmentData.Rainfall = value
-			case model.ModelInfoUltravioletRays:
-				environmentData.Ultraviolet = value
-			case model.ModelInfoLightIntensity:
-				environmentData.Illuminance = value
-			}
-		}
-		aqi := common.CountAqi(float64(environmentData.Pm25), float64(environmentData.Pm10))
-		value, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", aqi), 32)
-		environmentData.Air = float32(value)
-		environmentData.AirName = common.CalculateAirQuality(float64(environmentData.Air))
-		// 7点的数据用于天数据
-		environmentData.CreateDate = environmentData.CreateTime.Format("2006-01-02 15:04:06")
-		if environmentData.CreateTime.Hour() == 7 {
-			environmentData.IsDay = 1
-			environmentData.CreateDate = environmentData.CreateTime.Format("2006-01-02")
-		}
-
-		environmentDatas = append(environmentDatas, environmentData)
-		b, _ := json.Marshal(&environmentData)
-		cache.Redis.Set(fmt.Sprintf(model.EnvironmentDataKey, d.ID), string(b), 0)
-	}
-	environment := &dao.EnvironmentData{}
-	err := environment.BatchSave(environmentDatas)
-	if err != nil {
-		logger.Logger.Errorf("DataSync Hour.BatchSave err = %s", err.Error())
-	}
-
-}
-
-func (s *environmentDataService) DayDataSync() {
-	summary := &dao.EnvironmentDataSummary{}
-	yesterday := time.Now().Add(-24 * time.Hour)
-	now := time.Now()
-	start := time.Date(yesterday.Year(), yesterday.Month(), yesterday.Day(), 0, 0, 0, 0, time.Local)
-	end := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local)
-	err := summary.DaySummary(start, end)
-	if err != nil {
-		logger.Logger.Errorf("DayDataSync err = %s", err.Error())
-	}
-}
-
-func (s *environmentDataService) Get(deviceId int) *dao.EnvironmentData {
-	var EnvironmentData dao.EnvironmentData
-	result, err := cache.Redis.Get(fmt.Sprintf(model.EnvironmentDataKey, deviceId)).Result()
-	if err == nil {
-		err = json.Unmarshal([]byte(result), &EnvironmentData)
-		if err != nil {
-			return nil
-		}
-		return &EnvironmentData
-	}
-	EnvironmentData = dao.EnvironmentData{
-		DeviceId: deviceId,
-	}
-	_ = EnvironmentData.Get()
-	return &EnvironmentData
-}
-
-func (s *environmentDataService) GetData(deviceId, isDay int, start, end time.Time) ([]dao.EnvironmentData, error) {
-	var EnvironmentData dao.EnvironmentData
-
-	EnvironmentData = dao.EnvironmentData{
-		DeviceId: deviceId,
-		IsDay:    isDay,
-	}
-	return EnvironmentData.GetByTime(start, end)
-}
-
-func (s *environmentDataService) GetScopeData(deviceId int, isDay int, queryType int) (interface{}, error) {
-	var chartHistoryList []dao.EnvironmentScopeData
-	var chartNowList []dao.EnvironmentScopeData
-	var unit string
-	switch queryType {
-	case 1:
-		unit = "aqi"
-	case 2:
-		unit = "ug/m³"
-	case 3:
-		unit = "ug/m³"
-	case 4:
-		unit = "℃"
-	case 5:
-		unit = "%"
-	case 6:
-		unit = "m/s"
-	case 7:
-		unit = "hPa"
-	case 8:
-		unit = "dB"
-	}
-	var EnvironmentData dao.EnvironmentData
-
-	EnvironmentData = dao.EnvironmentData{
-		DeviceId: deviceId,
-		IsDay:    isDay,
-	}
-	chartHistoryList = EnvironmentData.GetEnvironmentScope(queryType, "history")
-	chartNowList = EnvironmentData.GetEnvironmentScope(queryType, "now")
-	data := make(map[string]interface{})
-	data["unit"] = unit
-	data["chartHistoryList"] = chartHistoryList
-	data["chartNowList"] = chartNowList
-	return data, nil
-}

+ 0 - 65
app/data/service/garbageDataService.go

@@ -1,65 +0,0 @@
-package service
-
-import (
-	"encoding/json"
-	"fmt"
-	"iot_manager_service/app/data/dao"
-	"iot_manager_service/app/data/model"
-	"iot_manager_service/util/cache"
-	"iot_manager_service/util/common"
-)
-
-var GarbageDataService = new(garbageDataService)
-
-type garbageDataService struct{}
-
-func (s *garbageDataService) BatchSave(details []model.GarbageDataDetail) *common.Errors {
-	garbage := &dao.GarbageData{DeviceId: ""}
-	var data []dao.GarbageData
-	for _, detail := range details {
-		garbageData := dao.GarbageData{
-			DeviceId:            detail.DeviceId,
-			StartTime:           detail.StartTime,
-			EndTime:             detail.EndTime,
-			PostTime:            detail.PostTime,
-			BatteryVoltage:      detail.BatteryVoltage,
-			BatteryPercentage:   detail.BatteryPercentage,
-			SensorCount:         detail.SensorCount,
-			SensorOne:           detail.SensorOne,
-			SensorTwo:           detail.SensorTwo,
-			SensorOnePercentage: detail.SensorOnePercentage,
-			SensorTwoPercentage: detail.SensorTwoPercentage,
-			WorkTime:            detail.WorkTime,
-		}
-		b, _ := json.Marshal(&garbageData)
-		cache.Redis.Set(fmt.Sprintf(model.GarbageDataKey, detail.DeviceId), string(b), 0)
-		data = append(data, garbageData)
-	}
-	if len(data) == 0 {
-		return nil
-	}
-
-	err := garbage.BatchSave(data)
-	if err != nil {
-		return common.FailResponse(err.Error(), nil)
-	}
-	return nil
-}
-
-func (s *garbageDataService) Get(deviceId string) *dao.GarbageData {
-	var garbageData dao.GarbageData
-	result, err := cache.Redis.Get(fmt.Sprintf(model.GarbageDataKey, deviceId)).Result()
-	if err == nil {
-		err = json.Unmarshal([]byte(result), &garbageData)
-		if err != nil {
-			return nil
-		}
-		return &garbageData
-	}
-
-	garbageData = dao.GarbageData{
-		DeviceId: deviceId,
-	}
-	_ = garbageData.Get()
-	return &garbageData
-}

+ 0 - 125
app/device/controller/GatewayController.go

@@ -1,125 +0,0 @@
-package controller
-
-import (
-	"github.com/gin-gonic/gin"
-	"iot_manager_service/app/device/model"
-	"iot_manager_service/app/device/service"
-	"iot_manager_service/app/middleware"
-	"iot_manager_service/util/common"
-	"math"
-	"net/http"
-	"strconv"
-)
-
-// 智慧网关基本信息管理对象
-var Gateway = new(gatewayCtl)
-
-type gatewayCtl struct{}
-
-func (c *gatewayCtl) Detail(ctx *gin.Context) {
-	id, e := strconv.Atoi(ctx.Query("id"))
-	if e != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(e.Error(), nil))
-		return
-	}
-
-	device, err := service.GatewayService.Get(id)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, device))
-}
-
-func (c *gatewayCtl) List(ctx *gin.Context) {
-	searchValue := ctx.Query("searchValue")
-	current, _ := strconv.Atoi(ctx.Query("current"))
-	size, _ := strconv.Atoi(ctx.Query("size"))
-	if current == 0 {
-		current = 1
-	}
-	if size <= 0 || size > 100 {
-		size = 10
-	}
-
-	devices, total, err := service.GatewayService.List(searchValue, current, size)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	pages := math.Ceil(float64(total) / float64(size))
-	rsp := model.RspGatewayList{
-		Current: current,
-		Size:    size,
-		Total:   int(total),
-		Pages:   int(pages),
-		Records: devices,
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, rsp))
-}
-
-func (c *gatewayCtl) CreateOrUpdate(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	var req *model.GatewayDetail
-	if err := ctx.ShouldBindJSON(&req); err != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(err.Error(), nil))
-		return
-	}
-	err := service.GatewayService.CreateOrUpdate(claims.UserId, claims.TenantId, req)
-	ctx.JSON(http.StatusOK, err)
-}
-
-func (c *gatewayCtl) Remove(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	var req *model.ReqGatewayRemove
-	if err := ctx.ShouldBindJSON(&req); err != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(err.Error(), nil))
-		return
-	}
-	err := service.GatewayService.Remove(claims.UserId, claims.TenantId, req.IDs)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, nil))
-}
-
-func (c *gatewayCtl) ImportExcel(ctx *gin.Context) {
-}
-
-func (c *gatewayCtl) ExportExcel(ctx *gin.Context) {
-}
-
-func (c *gatewayCtl) ExportTemplate(ctx *gin.Context) {
-}
-
-func (c *gatewayCtl) GetList(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	devices, err := service.GatewayService.GetList(claims.TenantId)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, devices))
-}
-
-func (c *gatewayCtl) GetRelevanceDetail(ctx *gin.Context) {
-	id, e := strconv.Atoi(ctx.Query("id"))
-	if e != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(e.Error(), nil))
-		return
-	}
-
-	device, err := service.GatewayService.GetRelevanceDetail(id)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, device))
-}

+ 0 - 153
app/device/controller/IntelligentLightingStrategy.go

@@ -1,153 +0,0 @@
-package controller
-
-import (
-	"github.com/gin-gonic/gin"
-	"iot_manager_service/app/device/model"
-	"iot_manager_service/app/device/service"
-	"iot_manager_service/app/middleware"
-	"iot_manager_service/util/common"
-	"math"
-	"net/http"
-	"strconv"
-)
-
-var IntelligentLighting = new(intelligentLightingCtl)
-
-type intelligentLightingCtl struct{}
-
-func (c *intelligentLightingCtl) Detail(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	publicId, e := strconv.Atoi(ctx.Query("publicId"))
-	reqType, _ := strconv.Atoi(ctx.Query("type"))
-	if e != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(e.Error(), nil))
-		return
-	}
-	if publicId == 0 {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(model.RelationIdInvalid, nil))
-		return
-	}
-
-	detail, err := service.IntelligentLightingService.GetDetailByLight(claims.TenantId, publicId, reqType)
-
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, detail))
-}
-
-func (c *intelligentLightingCtl) List(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	searchValue := ctx.Query("searchValue")
-	groupId := ctx.Query("groupId")
-	current, _ := strconv.Atoi(ctx.Query("current"))
-	size, _ := strconv.Atoi(ctx.Query("size"))
-	gId, err := strconv.Atoi(groupId)
-	if err != nil {
-		//ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, "分组没选 "))
-		//return
-		gId = 0
-	}
-	if current == 0 {
-		current = 1
-	}
-	if size <= 0 || size > 100 {
-		size = 10
-	}
-	strategies, total, err := service.IntelligentLightingService.List(claims.TenantId, searchValue, current, size, gId)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	pages := math.Ceil(float64(len(strategies)) / float64(size))
-	rsp := model.RspIntelligentLightList{
-		Current: current,
-		Size:    size,
-		Total:   int(total),
-		Pages:   int(pages),
-		Records: strategies,
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, rsp))
-}
-
-// RelationList 策略列表
-func (c *intelligentLightingCtl) RelationList(ctx *gin.Context) {
-	//value, _ := ctx.Get(middleware.Authorization)
-	//claims := value.(*middleware.Claims)
-	current, _ := strconv.Atoi(ctx.Query("current"))
-	size, _ := strconv.Atoi(ctx.Query("size"))
-	if current == 0 {
-		current = 1
-	}
-	if size <= 0 || size > 100 {
-		size = 10
-	}
-	searchValue := ""
-	strategies, _, err := service.LightStrategyService.List(searchValue, current, size)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	rsp := strategies
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, rsp))
-}
-
-// Relation 关联策略
-func (c *intelligentLightingCtl) Relation(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-	publicId, _ := strconv.Atoi(ctx.Query("publicId"))
-	lightId, _ := strconv.Atoi(ctx.Query("lightId"))
-	relationType, _ := strconv.Atoi(ctx.Query("relationType"))
-
-	err := service.IntelligentLightingService.Relation(claims.UserId, claims.TenantId, publicId, lightId, relationType)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, nil))
-}
-
-// Remove 恢复到分组策略
-func (c *intelligentLightingCtl) Recovery(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-	groupId, _ := strconv.Atoi(ctx.Query("groupId"))
-	id, _ := strconv.Atoi(ctx.Query("id"))
-
-	err := service.IntelligentLightingService.Recovery(claims.UserId, claims.TenantId, groupId, id)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, nil))
-}
-
-// ChangeHandSwitch 开灯控制
-func (c *intelligentLightingCtl) ChangeHandSwitch(ctx *gin.Context) {
-	handSwitch, _ := strconv.Atoi(ctx.Query("handSwitch"))
-	handType, _ := strconv.Atoi(ctx.Query("handType"))
-	publicId, _ := strconv.Atoi(ctx.Query("publicId"))
-	handTime, _ := strconv.Atoi(ctx.Query("handTime"))
-	luminance, _ := strconv.Atoi(ctx.Query("luminance"))
-	explain := ctx.Query("explain")
-	publicName := ctx.Query("publicName")
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	err := service.IntelligentLightingService.ChangeHandSwitch(claims.UserId, claims.TenantId, handSwitch, handType, publicId, handTime, luminance, explain, publicName)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, nil))
-}
-func (c *intelligentLightingCtl) GetStatus(ctx *gin.Context) {
-
-}

+ 0 - 96
app/device/controller/LightStrategy.go

@@ -1,96 +0,0 @@
-package controller
-
-import (
-	"github.com/gin-gonic/gin"
-	"iot_manager_service/app/device/model"
-	"iot_manager_service/app/device/service"
-	"iot_manager_service/app/middleware"
-	"iot_manager_service/util/common"
-	"math"
-	"net/http"
-	"strconv"
-)
-
-// LightStrategy 照明策略
-var LightStrategy = new(lightStrategyCtl)
-
-type lightStrategyCtl struct{}
-
-func (c *lightStrategyCtl) Detail(ctx *gin.Context) {
-	id, e := strconv.Atoi(ctx.Query("id"))
-	if e != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(e.Error(), nil))
-		return
-	}
-
-	lightStrategy, err := service.LightStrategyService.Get(id)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, lightStrategy))
-}
-
-func (c *lightStrategyCtl) List(ctx *gin.Context) {
-	searchValue := ctx.Query("searchValue")
-	current, _ := strconv.Atoi(ctx.Query("current"))
-	size, _ := strconv.Atoi(ctx.Query("size"))
-	if current == 0 {
-		current = 1
-	}
-	if size <= 0 || size > 100 {
-		size = 10
-	}
-
-	lightStrategies, total, err := service.LightStrategyService.List(searchValue, current, size)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	pages := math.Ceil(float64(int(total)) / float64(size))
-	rsp := model.RspLightStrategyList{
-		Current: current,
-		Size:    size,
-		Total:   int(total),
-		Pages:   int(pages),
-		Records: lightStrategies,
-	}
-
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, rsp))
-}
-
-func (c *lightStrategyCtl) CreateOrUpdate(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	// 参数验证
-	var req *model.LightStrategyDetail
-	if err := ctx.ShouldBind(&req); err != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(err.Error(), nil))
-		return
-	}
-	err := service.LightStrategyService.CreateOrUpdate(claims.UserId, claims.TenantId, req)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, nil)
-}
-
-func (c *lightStrategyCtl) Remove(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	var req *model.ReqLightStrategyRemove
-	if err := ctx.ShouldBindJSON(&req); err != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(err.Error(), nil))
-		return
-	}
-	err := service.LightStrategyService.Remove(claims.UserId, claims.TenantId, req.IDs)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, nil))
-
-}

+ 0 - 20
app/device/controller/OnDemandLightingControlStrategy.go

@@ -1,20 +0,0 @@
-package controller
-
-import "github.com/gin-gonic/gin"
-
-var OnDemandLightingControl = new(onDemandLightingControlCtl)
-
-type onDemandLightingControlCtl struct{}
-
-func (c *onDemandLightingControlCtl) Detail(ctx *gin.Context) {
-
-}
-func (c *onDemandLightingControlCtl) List(ctx *gin.Context) {
-
-}
-func (c *onDemandLightingControlCtl) Relation(ctx *gin.Context) {
-
-}
-func (c *onDemandLightingControlCtl) ChangeHandSwitch(ctx *gin.Context) {
-
-}

+ 0 - 113
app/device/controller/alarmController.go

@@ -1,113 +0,0 @@
-package controller
-
-import (
-	"github.com/gin-gonic/gin"
-	"iot_manager_service/app/device/dao"
-	"iot_manager_service/app/device/model"
-	"iot_manager_service/app/device/service"
-	"iot_manager_service/app/middleware"
-	"iot_manager_service/util/common"
-	"math"
-	"net/http"
-	"strconv"
-)
-
-// 一键报警服务表管理对象
-var Alarm = new(alarmCtl)
-
-type alarmCtl struct{}
-
-func (c *alarmCtl) Detail(ctx *gin.Context) {
-	id, e := strconv.Atoi(ctx.Query("id"))
-	if e != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(e.Error(), nil))
-		return
-	}
-
-	device, err := service.AlarmService.Get(id)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, device))
-}
-
-func (c *alarmCtl) List(ctx *gin.Context) {
-	searchValue := ctx.Query("searchValue")
-	current, _ := strconv.Atoi(ctx.Query("current"))
-	size, _ := strconv.Atoi(ctx.Query("size"))
-	if current == 0 {
-		current = 1
-	}
-	if size <= 0 || size > 100 {
-		size = 10
-	}
-	devices, total, err := service.AlarmService.List(searchValue, current, size)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	pages := math.Ceil(float64(total) / float64(size))
-	rsp := model.RsqAlarmList{
-		Current: current,
-		Size:    size,
-		Total:   int(total),
-		Pages:   int(pages),
-	}
-	for _, device := range devices {
-
-		rsp.Records = append(rsp.Records, device)
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, rsp))
-}
-
-func (c *alarmCtl) CreateOrUpdate(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	var req dao.Alarm
-	if err := ctx.ShouldBindJSON(&req); err != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(err.Error(), nil))
-		return
-	}
-	err := service.AlarmService.CreateOrUpdate(claims.UserId, claims.TenantId, req)
-	ctx.JSON(http.StatusOK, err)
-}
-
-func (c *alarmCtl) Remove(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	var req *model.ReqAlarmRemove
-	if err := ctx.ShouldBindJSON(&req); err != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(err.Error(), nil))
-		return
-	}
-	err := service.AlarmService.Remove(claims.UserId, claims.TenantId, req.IDs)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, nil))
-}
-
-func (c *alarmCtl) ImportExcel(ctx *gin.Context) {
-}
-
-func (c *alarmCtl) ExportExcel(ctx *gin.Context) {
-}
-
-func (c *alarmCtl) ExportTemplate(ctx *gin.Context) {
-}
-
-func (c *alarmCtl) GetList(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	devices, err := service.AlarmService.GetList(claims.TenantId)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, devices))
-}

+ 0 - 98
app/device/controller/alarmTerminalController.go

@@ -1,98 +0,0 @@
-package controller
-
-import (
-	"github.com/gin-gonic/gin"
-	"iot_manager_service/app/device/dao"
-	"iot_manager_service/app/device/model"
-	"iot_manager_service/app/device/service"
-	"iot_manager_service/app/middleware"
-	"iot_manager_service/util/common"
-	"math"
-	"net/http"
-	"strconv"
-)
-
-// 一键报警终端表管理对象
-var AlarmTerminal = new(alarmTerminalCtl)
-
-type alarmTerminalCtl struct{}
-
-func (c *alarmTerminalCtl) Detail(ctx *gin.Context) {
-	id, e := strconv.Atoi(ctx.Query("id"))
-	if e != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(e.Error(), nil))
-		return
-	}
-
-	device, err := service.AlarmTerminalService.Get(id)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, device))
-}
-
-func (c *alarmTerminalCtl) List(ctx *gin.Context) {
-	searchValue := ctx.Query("searchValue")
-	current, _ := strconv.Atoi(ctx.Query("current"))
-	size, _ := strconv.Atoi(ctx.Query("size"))
-	if current == 0 {
-		current = 1
-	}
-	if size <= 0 || size > 100 {
-		size = 10
-	}
-	devices, total, err := service.AlarmTerminalService.List(searchValue, current, size)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	pages := math.Ceil(float64(total) / float64(size))
-	rsp := model.RsqAlarmTerminalList{
-		Current: current,
-		Size:    size,
-		Total:   int(total),
-		Pages:   int(pages),
-		Records: devices,
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, rsp))
-}
-
-func (c *alarmTerminalCtl) CreateOrUpdate(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	var req dao.AlarmTerminal
-	if err := ctx.ShouldBindJSON(&req); err != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(err.Error(), nil))
-		return
-	}
-	err := service.AlarmTerminalService.CreateOrUpdate(claims.UserId, claims.TenantId, req)
-	ctx.JSON(http.StatusOK, err)
-}
-
-func (c *alarmTerminalCtl) Remove(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	var req *model.ReqAlarmTerminalRemove
-	if err := ctx.ShouldBindJSON(&req); err != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(err.Error(), nil))
-		return
-	}
-	err := service.AlarmTerminalService.Remove(claims.UserId, claims.TenantId, req.IDs)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, nil))
-}
-
-func (c *alarmTerminalCtl) ImportExcel(ctx *gin.Context) {
-}
-
-func (c *alarmTerminalCtl) ExportExcel(ctx *gin.Context) {
-}
-
-func (c *alarmTerminalCtl) ExportTemplate(ctx *gin.Context) {
-}

+ 0 - 136
app/device/controller/bigController.go

@@ -1,136 +0,0 @@
-package controller
-
-import (
-	"github.com/gin-gonic/gin"
-	"github.com/sirupsen/logrus"
-	"iot_manager_service/app/device/dao"
-	"iot_manager_service/app/device/service"
-	"iot_manager_service/app/middleware"
-	"iot_manager_service/util/common"
-	"net/http"
-	"strconv"
-)
-
-//点击获取当前设备总数/状态数量+列表
-//http://localhost/api/longchi/largescreen/mapclieck/device-num?queryType=lampPole
-//需要数据:
-//countNum:灯杆总数,
-//faultNum:灯杆报警数,
-//[]polist:(lng经度,lat纬度,status:状态,name:名字,code:编码,lampPoleName:灯杆名,brand:品牌,model:型号,linkNum:连接设备数,)
-
-var BigScreen = new(bigScreen)
-
-type bigScreen struct {
-}
-
-func (big *bigScreen) DeviceNum(ctx *gin.Context) {
-	queryType := ctx.Query("queryType")
-	rsp := service.BigServer.DeviceNum(queryType)
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, rsp))
-}
-
-func (big *bigScreen) LampPoleStatus(ctx *gin.Context) {
-	var rsp dao.TotalLamp
-	all, fault := service.BigServer.GetLampCount()
-	rsp.CountNum = all
-	rsp.FaultNum = fault
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Success, rsp))
-}
-
-// DevicesStatus 设备统计  /api/longchi/largescreen/overview/device-status
-func (big *bigScreen) DevicesStatus(ctx *gin.Context) {
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Success, service.BigServer.DevicesStatus()))
-}
-
-// Energy 能耗: /api/longchi/largescreen/overview/energy-consumption
-func (big *bigScreen) Energy(ctx *gin.Context) {
-	rsp := service.BigServer.GetEnergy(ctx.Query("startDate"), ctx.Query("endDate"))
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Success, rsp))
-}
-
-// LightRate 亮灯率:  /api/longchi/largescreen/overview/lighting-rate
-func (big *bigScreen) LightRate(ctx *gin.Context) {
-	authorization := ctx.GetHeader("Authorization")
-	claims := middleware.ParseAccessToken(authorization)
-	//rsp := service.BigServer.GetLightRate(claims.TenantId)
-	//var rsp = make([]interface{}, 0, 4)
-	//var lrm = dao.LightRateM{Month: "2023-07", Rate: 30}
-	//var lrq = dao.LightRateQ{Quarter: "3", Rate: 50}
-	//var lry = dao.LightRateY{Year: "2023", Rate: 50}
-	//rsp = append(rsp, []interface{}{})
-	//rsp = append(rsp, lrm)
-	//rsp = append(rsp, lrq)
-	//rsp = append(rsp, lry)
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Success, service.BigServer.GetLightRate(claims.TenantId)))
-}
-
-// AlarmInfo http://localhost/api/longchi/largescreen/overview/alarm-information
-func (big *bigScreen) AlarmInfo(ctx *gin.Context) {
-	rsp := service.BigServer.GetAlarmInfo()
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Success, rsp))
-}
-
-// AlarmStatistics 报警设备统计 http://localhost/api/longchi/largescreen/overview/alarm-device-count?startDate=2022-07-10&endDate=2023-07-10
-func (big *bigScreen) AlarmStatistics(ctx *gin.Context) {
-	//deviceType faultNum
-	rsp := service.BigServer.AlarmStatus()
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Success, rsp))
-}
-
-// FlowInfo 工单信息 http://localhost/api/longchi/largescreen/overview/flow-information
-func (big *bigScreen) FlowInfo(ctx *gin.Context) {
-	//deviceType faultNum
-	rsp := service.BigServer.AlarmStatus()
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Success, rsp))
-}
-
-func (big *bigScreen) Environment(ctx *gin.Context) {
-	deviceId := ctx.Query("id")
-	rsp := service.BigServer.GetEnv(deviceId)
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Success, rsp))
-}
-
-func (big *bigScreen) InfoBoard(ctx *gin.Context) {
-	authorization := ctx.GetHeader("Authorization")
-	claims := middleware.ParseAccessToken(authorization)
-	rsp := service.BigServer.GetLEDProgram(claims.TenantId)
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Success, rsp))
-}
-
-func (big *bigScreen) Program(ctx *gin.Context) {
-	id := ctx.Query("id")
-	atoi, _ := strconv.Atoi(id)
-	rsp := service.BigServer.GetProgramUrl(id)
-	rsp.Id = int64(atoi)
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Success, rsp))
-}
-func (big *bigScreen) BridgeSensor(ctx *gin.Context) {
-	authorization := ctx.GetHeader("Authorization")
-	claims := middleware.ParseAccessToken(authorization)
-	rsp := service.BigServer.GetBridgeSensors(claims.TenantId)
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Success, rsp))
-}
-
-// QueryOverView http://localhost/api/longchi/largescreen/setting/query-large-screen?padScreen=overview
-func (big *bigScreen) QueryOverView(ctx *gin.Context) {
-	padScreen := ctx.Query("padScreen")
-	authorization := ctx.GetHeader("Authorization")
-	claims := middleware.ParseAccessToken(authorization)
-	rsp := service.BigServer.OverView(claims.TenantId, padScreen)
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Success, rsp))
-}
-
-func (big *bigScreen) SubmitOverView(ctx *gin.Context) {
-	authorization := ctx.GetHeader("Authorization")
-	claims := middleware.ParseAccessToken(authorization)
-	var req []dao.OverView
-	err := ctx.ShouldBind(&req)
-	if err != nil {
-		logrus.Errorf("SubmitOverView ShouldBind error:%v", err)
-	}
-	for i, _ := range req {
-		req[i].TenantId = claims.TenantId
-	}
-	service.BigServer.Submit(req)
-	ctx.JSON(200, "")
-}

+ 0 - 113
app/device/controller/bridgeController.go

@@ -1,113 +0,0 @@
-package controller
-
-import (
-	"github.com/gin-gonic/gin"
-	"iot_manager_service/app/device/dao"
-	"iot_manager_service/app/device/model"
-	"iot_manager_service/app/device/service"
-	"iot_manager_service/app/middleware"
-	"iot_manager_service/util/common"
-	"math"
-	"net/http"
-	"strconv"
-)
-
-// 桥梁管理对象
-var Bridge = new(bridgeCtl)
-
-type bridgeCtl struct{}
-
-func (c *bridgeCtl) Detail(ctx *gin.Context) {
-	id, e := strconv.Atoi(ctx.Query("id"))
-	if e != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(e.Error(), nil))
-		return
-	}
-
-	device, err := service.BridgeService.Get(id)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, device))
-}
-
-func (c *bridgeCtl) List(ctx *gin.Context) {
-	searchValue := ctx.Query("searchValue")
-	current, _ := strconv.Atoi(ctx.Query("current"))
-	size, _ := strconv.Atoi(ctx.Query("size"))
-	if current == 0 {
-		current = 1
-	}
-	if size <= 0 || size > 100 {
-		size = 10
-	}
-	devices, total, err := service.BridgeService.List(searchValue, current, size)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	pages := math.Ceil(float64(total) / float64(size))
-	rsp := model.RsqBridgeList{
-		Current: current,
-		Size:    size,
-		Total:   int(total),
-		Pages:   int(pages),
-	}
-	for _, device := range devices {
-
-		rsp.Records = append(rsp.Records, device)
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, rsp))
-}
-
-func (c *bridgeCtl) CreateOrUpdate(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	var req dao.Bridge
-	if err := ctx.ShouldBindJSON(&req); err != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(err.Error(), nil))
-		return
-	}
-	err := service.BridgeService.CreateOrUpdate(claims.UserId, claims.TenantId, req)
-	ctx.JSON(http.StatusOK, err)
-}
-
-func (c *bridgeCtl) Remove(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	var req *model.ReqBridgeRemove
-	if err := ctx.ShouldBindJSON(&req); err != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(err.Error(), nil))
-		return
-	}
-	err := service.BridgeService.Remove(claims.UserId, claims.TenantId, req.IDs)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, nil))
-}
-
-func (c *bridgeCtl) ImportExcel(ctx *gin.Context) {
-}
-
-func (c *bridgeCtl) ExportExcel(ctx *gin.Context) {
-}
-
-func (c *bridgeCtl) ExportTemplate(ctx *gin.Context) {
-}
-
-func (c *bridgeCtl) GetList(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	devices, err := service.BridgeService.GetList(claims.TenantId)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, devices))
-}

+ 0 - 131
app/device/controller/bridgeSensorController.go

@@ -1,131 +0,0 @@
-package controller
-
-import (
-	"github.com/gin-gonic/gin"
-	"iot_manager_service/app/device/dao"
-	"iot_manager_service/app/device/model"
-	"iot_manager_service/app/device/service"
-	"iot_manager_service/app/middleware"
-	"iot_manager_service/util/common"
-	"math"
-	"net/http"
-	"strconv"
-)
-
-// 桥梁传感器管理对象
-var BridgeSensor = new(bridgeSensorCtl)
-
-type bridgeSensorCtl struct{}
-
-func (c *bridgeSensorCtl) Detail(ctx *gin.Context) {
-	id, e := strconv.Atoi(ctx.Query("id"))
-	if e != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(e.Error(), nil))
-		return
-	}
-
-	device, err := service.BridgeSensorService.Get(id)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, device))
-}
-
-func (c *bridgeSensorCtl) List(ctx *gin.Context) {
-	searchValue := ctx.Query("searchValue")
-	current, _ := strconv.Atoi(ctx.Query("current"))
-	size, _ := strconv.Atoi(ctx.Query("size"))
-	if current == 0 {
-		current = 1
-	}
-	if size <= 0 || size > 100 {
-		size = 10
-	}
-	devices, total, err := service.BridgeSensorService.List(searchValue, current, size)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	pages := math.Ceil(float64(total) / float64(size))
-	rsp := model.RspBridgeSensorList{
-		Current: current,
-		Size:    size,
-		Total:   int(total),
-		Pages:   int(pages),
-	}
-	for _, device := range devices {
-
-		rsp.Records = append(rsp.Records, device)
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, rsp))
-}
-
-func (c *bridgeSensorCtl) CreateOrUpdate(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	var req dao.BridgeSensor
-	if err := ctx.ShouldBindJSON(&req); err != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(err.Error(), nil))
-		return
-	}
-	err := service.BridgeSensorService.CreateOrUpdate(claims.UserId, claims.TenantId, req)
-	ctx.JSON(http.StatusOK, err)
-}
-
-func (c *bridgeSensorCtl) Remove(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	var req *model.ReqBridgeSensorRemove
-	if err := ctx.ShouldBindJSON(&req); err != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(err.Error(), nil))
-		return
-	}
-	err := service.BridgeSensorService.Remove(claims.UserId, claims.TenantId, req.IDs)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, nil))
-}
-
-func (c *bridgeSensorCtl) ImportExcel(ctx *gin.Context) {
-}
-
-func (c *bridgeSensorCtl) ExportExcel(ctx *gin.Context) {
-}
-
-func (c *bridgeSensorCtl) ExportTemplate(ctx *gin.Context) {
-}
-
-func (c *bridgeSensorCtl) GetList(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	devices, err := service.BridgeSensorService.GetList(claims.TenantId)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, devices))
-}
-
-func (c *bridgeSensorCtl) Enable(ctx *gin.Context) {
-	var req *model.ReqBridgeSensorEnable
-	if err := ctx.ShouldBindJSON(&req); err != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(err.Error(), nil))
-		return
-	}
-	if req.Status != model.Enable_Enable && req.Status != model.Enable_Disable {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(model.EnableInvalid, nil))
-		return
-	}
-	err := service.BridgeSensorService.Enable(req.ID, req.Status)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, nil))
-}

+ 0 - 139
app/device/controller/cameraController.go

@@ -1,139 +0,0 @@
-package controller
-
-import (
-	"github.com/gin-gonic/gin"
-	"iot_manager_service/app/device/model"
-	"iot_manager_service/app/device/service"
-	"iot_manager_service/app/middleware"
-	"iot_manager_service/util/common"
-	"math"
-	"net/http"
-	"strconv"
-)
-
-// 摄像头管理对象
-var Camera = new(cameraCtl)
-
-type cameraCtl struct{}
-
-func (c *cameraCtl) Detail(ctx *gin.Context) {
-	id, e := strconv.Atoi(ctx.Query("id"))
-	if e != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(e.Error(), nil))
-		return
-	}
-
-	device, err := service.CameraService.Get(id)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, device))
-}
-
-func (c *cameraCtl) List(ctx *gin.Context) {
-	searchValue := ctx.Query("searchValue")
-	cameraType := ctx.Query("cameraType")
-	current, _ := strconv.Atoi(ctx.Query("current"))
-	size, _ := strconv.Atoi(ctx.Query("size"))
-	if current == 0 {
-		current = 1
-	}
-	if size <= 0 || size > 100 {
-		size = 10
-	}
-
-	devices, total, err := service.CameraService.List(searchValue, cameraType, current, size)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	pages := math.Ceil(float64(total) / float64(size))
-	rsp := model.RspCameraList{
-		Current: current,
-		Size:    size,
-		Total:   int(total),
-		Pages:   int(pages),
-		Records: devices,
-	}
-
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, rsp))
-}
-
-func (c *cameraCtl) CreateOrUpdate(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	// 参数验证
-	var req *model.CameraDetail
-	if err := ctx.ShouldBind(&req); err != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(err.Error(), nil))
-		return
-	}
-	err := service.CameraService.CreateOrUpdate(claims.UserId, claims.TenantId, req)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, nil)
-}
-
-func (c *cameraCtl) Remove(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	var req *model.ReqCameraRemove
-	if err := ctx.ShouldBindJSON(&req); err != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(err.Error(), nil))
-		return
-	}
-	err := service.CameraService.Remove(claims.UserId, claims.TenantId, req.IDs)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, nil))
-}
-
-func (c *cameraCtl) Count(ctx *gin.Context) {
-}
-
-func (c *cameraCtl) ImportExcel(ctx *gin.Context) {
-}
-
-func (c *cameraCtl) ExportExcel(ctx *gin.Context) {
-}
-
-func (c *cameraCtl) ExportTemplate(ctx *gin.Context) {
-}
-
-func (c *cameraCtl) GetList(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	devices, err := service.CameraService.GetList(claims.TenantId)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, devices))
-
-}
-
-func (c *cameraCtl) Enable(ctx *gin.Context) {
-	var req *model.ReqCameraEnable
-	if err := ctx.ShouldBindJSON(&req); err != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(err.Error(), nil))
-		return
-	}
-	if req.Status != model.Enable_Enable && req.Status != model.Enable_Disable {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(model.EnableInvalid, nil))
-		return
-	}
-	err := service.CameraService.Enable(req.ID, req.Status)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, nil))
-}

+ 0 - 188
app/device/controller/captureUintController.go

@@ -1,188 +0,0 @@
-package controller
-
-import (
-	"github.com/gin-gonic/gin"
-	"iot_manager_service/app/device/dao"
-	"iot_manager_service/app/device/model"
-	"iot_manager_service/app/device/service"
-	"iot_manager_service/app/middleware"
-	"iot_manager_service/util/common"
-	"math"
-	"net/http"
-	"strconv"
-)
-
-// 抓拍单元管理对象
-var CaptureUint = new(captureUintCtl)
-
-type captureUintCtl struct{}
-
-func (c *captureUintCtl) Detail(ctx *gin.Context) {
-	id, e := strconv.Atoi(ctx.Query("id"))
-	if e != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(e.Error(), nil))
-		return
-	}
-	deviceType := ctx.Query("type")
-	if deviceType == model.TypeCapture {
-		device, err := service.CaptureUintService.GetCapture(id)
-		if err != nil {
-			ctx.JSON(http.StatusOK, err)
-			return
-		}
-		ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, device))
-	} else if deviceType == model.TypePoint {
-		device, err := service.CaptureUintService.GetPoint(id)
-		if err != nil {
-			ctx.JSON(http.StatusOK, err)
-			return
-		}
-		ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, device))
-	} else {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(model.TypeInvalid, nil))
-	}
-}
-
-func (c *captureUintCtl) CaptureList(ctx *gin.Context) {
-	searchValue := ctx.Query("searchValue")
-	current, _ := strconv.Atoi(ctx.Query("current"))
-	size, _ := strconv.Atoi(ctx.Query("size"))
-	if current == 0 {
-		current = 1
-	}
-	if size <= 0 || size > 100 {
-		size = 10
-	}
-
-	devices, total, err := service.CaptureUintService.CaptureList(searchValue, current, size)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	pages := math.Ceil(float64(total) / float64(size))
-	rsp := model.RspCaptureList{
-		Current: current,
-		Size:    size,
-		Total:   int(total),
-		Pages:   int(pages),
-		Records: devices,
-	}
-
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, rsp))
-}
-
-func (c *captureUintCtl) CaptureSubmit(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	// 参数验证
-	var req *model.CaptureDetail
-	if err := ctx.ShouldBind(&req); err != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(err.Error(), nil))
-		return
-	}
-	err := service.CaptureUintService.CaptureSubmit(claims.UserId, claims.TenantId, req)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, nil)
-}
-
-func (c *captureUintCtl) PointList(ctx *gin.Context) {
-	searchValue := ctx.Query("searchValue")
-	current, _ := strconv.Atoi(ctx.Query("current"))
-	size, _ := strconv.Atoi(ctx.Query("size"))
-	if current == 0 {
-		current = 1
-	}
-	if size <= 0 || size > 100 {
-		size = 10
-	}
-
-	devices, total, err := service.CaptureUintService.PointList(searchValue, current, size)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	pages := math.Ceil(float64(len(devices)) / float64(size))
-	rsp := model.RspPointList{
-		Current: current,
-		Size:    size,
-		Total:   int(total),
-		Pages:   int(pages),
-		Records: devices,
-	}
-
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, rsp))
-}
-
-func (c *captureUintCtl) PointSubmit(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	// 参数验证
-	var req *dao.CheckPoint
-	if err := ctx.ShouldBind(&req); err != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(err.Error(), nil))
-		return
-	}
-	err := service.CaptureUintService.PointSubmit(claims.UserId, claims.TenantId, req)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, nil)
-}
-
-func (c *captureUintCtl) CaptureGetList(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	devices, err := service.CaptureUintService.CaptureGetList(claims.TenantId)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, devices))
-}
-
-func (c *captureUintCtl) PointGetList(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	devices, err := service.CaptureUintService.PointGetList(claims.TenantId)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, devices))
-}
-
-func (c *captureUintCtl) Remove(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	var req *model.ReqCaptureRemove
-	if err := ctx.ShouldBindJSON(&req); err != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(err.Error(), nil))
-		return
-	}
-	if req.Type == model.TypeCapture {
-		err := service.CaptureUintService.RemoveCapture(claims.UserId, claims.TenantId, req.IDs)
-		if err != nil {
-			ctx.JSON(http.StatusOK, err)
-			return
-		}
-		ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, nil))
-	} else if req.Type == model.TypePoint {
-		err := service.CaptureUintService.RemovePoint(claims.UserId, claims.TenantId, req.IDs)
-		if err != nil {
-			ctx.JSON(http.StatusOK, err)
-			return
-		}
-		ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, nil))
-	} else {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(model.TypeInvalid, nil))
-	}
-}

+ 0 - 113
app/device/controller/garbageController.go

@@ -1,113 +0,0 @@
-package controller
-
-import (
-	"github.com/gin-gonic/gin"
-	"iot_manager_service/app/device/dao"
-	"iot_manager_service/app/device/model"
-	"iot_manager_service/app/device/service"
-	"iot_manager_service/app/middleware"
-	"iot_manager_service/util/common"
-	"math"
-	"net/http"
-	"strconv"
-)
-
-// 垃圾桶管理对象
-var Garbage = new(garbageCtl)
-
-type garbageCtl struct{}
-
-func (c *garbageCtl) Detail(ctx *gin.Context) {
-	id, e := strconv.Atoi(ctx.Query("id"))
-	if e != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(e.Error(), nil))
-		return
-	}
-
-	device, err := service.GarbageService.Get(id)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, device))
-}
-
-func (c *garbageCtl) List(ctx *gin.Context) {
-	searchValue := ctx.Query("searchValue")
-	current, _ := strconv.Atoi(ctx.Query("current"))
-	size, _ := strconv.Atoi(ctx.Query("size"))
-	if current == 0 {
-		current = 1
-	}
-	if size <= 0 || size > 100 {
-		size = 10
-	}
-	devices, total, err := service.GarbageService.List(searchValue, current, size)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	pages := math.Ceil(float64(total) / float64(size))
-	rsp := model.RsqGarbageList{
-		Current: current,
-		Size:    size,
-		Total:   int(total),
-		Pages:   int(pages),
-	}
-	for _, device := range devices {
-
-		rsp.Records = append(rsp.Records, device)
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, rsp))
-}
-
-func (c *garbageCtl) CreateOrUpdate(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	var req dao.Garbage
-	if err := ctx.ShouldBindJSON(&req); err != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(err.Error(), nil))
-		return
-	}
-	err := service.GarbageService.CreateOrUpdate(claims.UserId, claims.TenantId, req)
-	ctx.JSON(http.StatusOK, err)
-}
-
-func (c *garbageCtl) Remove(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	var req *model.ReqGarbageRemove
-	if err := ctx.ShouldBindJSON(&req); err != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(err.Error(), nil))
-		return
-	}
-	err := service.GarbageService.Remove(claims.UserId, claims.TenantId, req.IDs)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, nil))
-}
-
-func (c *garbageCtl) ImportExcel(ctx *gin.Context) {
-}
-
-func (c *garbageCtl) ExportExcel(ctx *gin.Context) {
-}
-
-func (c *garbageCtl) ExportTemplate(ctx *gin.Context) {
-}
-
-func (c *garbageCtl) GetList(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	devices, err := service.GarbageService.GetList(claims.TenantId)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, devices))
-}

+ 0 - 104
app/device/controller/garbageWayGroupController.go

@@ -1,104 +0,0 @@
-package controller
-
-import (
-	"github.com/gin-gonic/gin"
-	"iot_manager_service/app/device/dao"
-	"iot_manager_service/app/device/model"
-	"iot_manager_service/app/device/service"
-	"iot_manager_service/app/middleware"
-	"iot_manager_service/util/common"
-	"math"
-	"net/http"
-	"strconv"
-)
-
-// 垃圾桶道路管理对象
-var GarbageWay = new(garbageWayCtl)
-
-type garbageWayCtl struct{}
-
-func (c *garbageWayCtl) Detail(ctx *gin.Context) {
-	id, e := strconv.Atoi(ctx.Query("id"))
-	if e != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(e.Error(), nil))
-		return
-	}
-
-	device, err := service.GarbageWayGroupService.Get(id)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, device))
-}
-
-func (c *garbageWayCtl) List(ctx *gin.Context) {
-	searchValue := ctx.Query("wayName")
-	current, _ := strconv.Atoi(ctx.Query("current"))
-	size, _ := strconv.Atoi(ctx.Query("size"))
-	if current == 0 {
-		current = 1
-	}
-	if size <= 0 || size > 100 {
-		size = 10
-	}
-	devices, total, err := service.GarbageWayGroupService.List(searchValue, current, size)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	pages := math.Ceil(float64(total) / float64(size))
-	rsp := model.RsqGarbageWayGroupList{
-		Current: current,
-		Size:    size,
-		Total:   int(total),
-		Pages:   int(pages),
-	}
-	for _, device := range devices {
-
-		rsp.Records = append(rsp.Records, device)
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, rsp))
-}
-
-func (c *garbageWayCtl) CreateOrUpdate(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	var req dao.GarbageWayGroup
-	if err := ctx.ShouldBindJSON(&req); err != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(err.Error(), nil))
-		return
-	}
-	err := service.GarbageWayGroupService.CreateOrUpdate(claims.UserId, claims.TenantId, req)
-	ctx.JSON(http.StatusOK, err)
-}
-
-func (c *garbageWayCtl) Remove(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	var req *model.ReqGarbageWayGroupRemove
-	if err := ctx.ShouldBindJSON(&req); err != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(err.Error(), nil))
-		return
-	}
-	err := service.GarbageWayGroupService.Remove(claims.UserId, claims.TenantId, req.IDs)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, nil))
-}
-
-func (c *garbageWayCtl) GetList(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	devices, err := service.GarbageWayGroupService.GetList(claims.TenantId)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, devices))
-}

+ 0 - 201
app/device/controller/infoBoardController.go

@@ -1,201 +0,0 @@
-package controller
-
-import (
-	"github.com/gin-gonic/gin"
-	"iot_manager_service/app/device/dao"
-	"iot_manager_service/app/device/model"
-	"iot_manager_service/app/device/service"
-	"iot_manager_service/app/middleware"
-	service2 "iot_manager_service/app/multimedia/service"
-	"iot_manager_service/util/cache"
-	"iot_manager_service/util/common"
-	"math"
-	"net/http"
-	"strconv"
-)
-
-// 信息屏基本信息管理对象
-var InfoBoard = new(infoBoardCtl)
-
-type infoBoardCtl struct{}
-
-func (c *infoBoardCtl) Detail(ctx *gin.Context) {
-	id, e := strconv.Atoi(ctx.Query("id"))
-	if e != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(e.Error(), nil))
-		return
-	}
-
-	device, err := service.InfoBoardService.Get(id)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, device))
-}
-
-func (c *infoBoardCtl) List(ctx *gin.Context) {
-	searchValue := ctx.Query("searchValue")
-	current, _ := strconv.Atoi(ctx.Query("current"))
-	size, _ := strconv.Atoi(ctx.Query("size"))
-	if current == 0 {
-		current = 1
-	}
-	if size <= 0 || size > 100 {
-		size = 10
-	}
-	devices, total, err := service.InfoBoardService.List(searchValue, current, size)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	pages := math.Ceil(float64(total) / float64(size))
-	rsp := model.RsqInfoBoardList{
-		Current: current,
-		Size:    size,
-		Total:   int(total),
-		Pages:   int(pages),
-		Records: devices,
-	}
-
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, rsp))
-}
-
-func (c *infoBoardCtl) CreateOrUpdate(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	var req dao.InfoBoard
-	if err := ctx.ShouldBindJSON(&req); err != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(err.Error(), nil))
-		return
-	}
-	if req.ID > 0 {
-		//更新 排程
-		service.InfoBoardService.EdgeCmd(claims.TenantId, req.Sn, 6, req.ID)
-	}
-	err := service.InfoBoardService.CreateOrUpdate(claims.UserId, claims.TenantId, req)
-	ctx.JSON(http.StatusOK, err)
-}
-
-func (c *infoBoardCtl) Remove(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	var req *model.ReqInfoBoardRemove
-	if err := ctx.ShouldBindJSON(&req); err != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(err.Error(), nil))
-		return
-	}
-	err := service.InfoBoardService.Remove(claims.UserId, claims.TenantId, req.IDs)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, nil))
-}
-
-func (c *infoBoardCtl) ImportExcel(ctx *gin.Context) {
-}
-
-func (c *infoBoardCtl) ExportExcel(ctx *gin.Context) {
-}
-
-func (c *infoBoardCtl) ExportTemplate(ctx *gin.Context) {
-}
-
-func (c *infoBoardCtl) SystemOperation(ctx *gin.Context) {
-}
-
-func (c *infoBoardCtl) Enable(ctx *gin.Context) {
-	//TODO:未做
-}
-
-func (c *infoBoardCtl) ShowSetting(ctx *gin.Context) {
-	id, e := strconv.Atoi(ctx.Query("id"))
-	if e != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(e.Error(), nil))
-		return
-	}
-
-	device, err := service.InfoBoardService.Get(id)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, device))
-}
-
-type edgeCmdReq struct {
-	InfoSn    string `json:"infoSn"`
-	Id        int    `json:"id"`
-	Directive int    `json:"directive"`
-	Condition string `json:"condition"`
-}
-
-// EdgeCmd 向边缘端发送cmd命令
-func (c *infoBoardCtl) EdgeCmd(ctx *gin.Context) {
-	var req *edgeCmdReq
-	if err := ctx.ShouldBindJSON(&req); err != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(err.Error(), nil))
-		return
-	}
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-	if req.Directive == 101 {
-		var req2 dao.InfoBoard
-		req2.ID = req.Id
-		req2.Condition = req.Condition
-		service.InfoBoardService.CreateOrUpdate(claims.UserId, claims.TenantId, req2)
-	}
-	//更新排程
-	if req.Directive == 4 {
-		c.CronSyncLedPaying(req.Id)
-	}
-	service.InfoBoardService.EdgeCmd(claims.TenantId, req.InfoSn, req.Directive, req.Id)
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, nil))
-}
-
-// CronSyncBrightnessAndMusicvolume 同步亮度与音量
-func (s *infoBoardCtl) CronSyncBrightnessAndMusicvolume() {
-	board := dao.InfoBoard{}
-	list, err := board.GetAllDevicesNotTenant()
-	if err != nil {
-		return
-	}
-	for _, led := range list {
-		_, retState := cache.GetDeviceState(led.Sn)
-		// 只有设备在线 才能向边缘端下发命令
-		if retState == "1" {
-			service.InfoBoardService.EdgeCmd(led.TenantId, led.Sn, 101, led.ID)
-		}
-	}
-}
-
-// CronSyncLedPaying 同步播放当前节目
-func (s *infoBoardCtl) CronSyncLedPaying(id int) {
-	board := dao.InfoBoard{}
-	if id > 0 {
-		board.ID = id
-	}
-	list, err := board.GetAllDevicesNotTenant()
-	if err != nil {
-		return
-	}
-	for _, led := range list {
-		_, retState := cache.GetDeviceState(led.Sn)
-		currPaying := cache.GetDeviceLedData(led.Sn)
-		if retState == "1" && len(currPaying) != 0 {
-			playing := currPaying["playing"].(string) //得到当前正播放的节目
-			playJson := service2.PublishLibrariesService.LedPaying(led.ID, playing)
-			if playJson != "" {
-				service.InfoBoardService.EdgePushLedProgram(led.TenantId, led.Sn, playJson)
-				//需要更新
-			} else {
-				//无需更新
-			}
-		} else {
-			//led设备不在线Sn = %v \n", led.Sn
-		}
-	}
-}

+ 0 - 173
app/device/controller/ipBroadcastController.go

@@ -1,173 +0,0 @@
-package controller
-
-import (
-	"github.com/gin-gonic/gin"
-	"iot_manager_service/app/device/dao"
-	"iot_manager_service/app/device/edge_service"
-	"iot_manager_service/app/device/model"
-	"iot_manager_service/app/device/service"
-	"iot_manager_service/app/middleware"
-	service2 "iot_manager_service/app/multimedia/service"
-	"iot_manager_service/util/common"
-	"math"
-	"net/http"
-	"strconv"
-)
-
-// IP广播基本信息管理对象
-var IpBroadcast = new(ipBroadcastCtl)
-
-type ipBroadcastCtl struct{}
-
-func (c *ipBroadcastCtl) Detail(ctx *gin.Context) {
-	id, e := strconv.Atoi(ctx.Query("id"))
-	if e != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(e.Error(), nil))
-		return
-	}
-
-	device, err := service.IpBroadcastService.Get(id)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, device))
-}
-
-func (c *ipBroadcastCtl) List(ctx *gin.Context) {
-	searchValue := ctx.Query("searchValue")
-	current, _ := strconv.Atoi(ctx.Query("current"))
-	size, _ := strconv.Atoi(ctx.Query("size"))
-	if current == 0 {
-		current = 1
-	}
-	if size <= 0 || size > 100 {
-		size = 10
-	}
-	devices, total, err := service.IpBroadcastService.List(searchValue, current, size)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	pages := math.Ceil(float64(total) / float64(size))
-	rsp := model.RsqIpBroadcastList{
-		Current: current,
-		Size:    size,
-		Total:   int(total),
-		Pages:   int(pages),
-	}
-	for _, device := range devices {
-
-		rsp.Records = append(rsp.Records, device)
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, rsp))
-}
-
-func (c *ipBroadcastCtl) CreateOrUpdate(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	var req dao.IpBroadcast
-	if err := ctx.ShouldBindJSON(&req); err != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(err.Error(), nil))
-		return
-	}
-	err := service.IpBroadcastService.CreateOrUpdate(claims.UserId, claims.TenantId, req)
-	ctx.JSON(http.StatusOK, err)
-}
-
-func (c *ipBroadcastCtl) Remove(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	var req *model.ReqIpBroadcastRemove
-	if err := ctx.ShouldBindJSON(&req); err != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(err.Error(), nil))
-		return
-	}
-	err := service.IpBroadcastService.Remove(claims.UserId, claims.TenantId, req.IDs)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, nil))
-}
-
-func (c *ipBroadcastCtl) ImportExcel(ctx *gin.Context) {
-}
-
-func (c *ipBroadcastCtl) ExportExcel(ctx *gin.Context) {
-}
-
-func (c *ipBroadcastCtl) ExportTemplate(ctx *gin.Context) {
-}
-
-func (c *ipBroadcastCtl) SettingVolume(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	var req dao.IpBroadcast
-	if err := ctx.ShouldBindJSON(&req); err != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(err.Error(), nil))
-		return
-	}
-	if req.SoundVolume <= 1 {
-		req.SoundVolume = 1
-	}
-	err2 := edge_service.IpCastControlService{}.SetVol(req.CastSn, req.SoundVolume)
-	if err2 != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(err2.Error(), nil))
-		return
-	}
-	err := service.IpBroadcastService.CreateOrUpdate(claims.UserId, claims.TenantId, req)
-	ctx.JSON(http.StatusOK, err)
-}
-
-type settingIpCastReq struct {
-	ID        int `json:"id"`
-	Directive int `json:"directive"`
-}
-
-func (c *ipBroadcastCtl) SettingIpCast(ctx *gin.Context) {
-	var req settingIpCastReq
-	if err := ctx.ShouldBindJSON(&req); err != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(err.Error(), nil))
-		return
-	}
-	if req.Directive == 1 {
-		err := edge_service.IpCastControlService{}.SetStop()
-		if err != nil {
-			ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(err.Error(), nil))
-			return
-		}
-	}
-	if req.Directive == 2 {
-		c.CronSyncIpCastPaying(req.ID)
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, nil))
-}
-
-// 同步播放ip音柱节目
-func (c *ipBroadcastCtl) CronSyncIpCastPaying(id int) {
-	board := dao.IpBroadcast{}
-	if id > 0 {
-		board.ID = id
-	}
-	list, err := board.GetAllDevicesNotTenant()
-	if err != nil {
-		return
-	}
-	for _, IPCast := range list {
-		device, _ := service.IpBroadcastService.Get(IPCast.ID)
-		if device.PlayState == "空闲" {
-			playJson, ptype := service2.PublishLibrariesService.IPCastPaying(IPCast.ID)
-			if playJson != "" {
-				err := edge_service.IpCastControlService{}.PushPlay(playJson, ptype)
-				if err != nil {
-					return
-				}
-			} else {
-			}
-		}
-	}
-}

+ 0 - 145
app/device/controller/lampPoleController.go

@@ -1,145 +0,0 @@
-package controller
-
-import (
-	"github.com/gin-gonic/gin"
-	"iot_manager_service/app/device/dao"
-	"iot_manager_service/app/device/model"
-	"iot_manager_service/app/device/service"
-	"iot_manager_service/app/middleware"
-	"iot_manager_service/util/common"
-	"math"
-	"net/http"
-	"strconv"
-)
-
-// 灯杆基本信息管理对象
-var LampPole = new(lampPoleCtl)
-
-type lampPoleCtl struct{}
-
-func (c *lampPoleCtl) Detail(ctx *gin.Context) {
-	id, e := strconv.Atoi(ctx.Query("id"))
-	if e != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(e.Error(), nil))
-		return
-	}
-
-	device, err := service.LampPoleService.Get(id)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, device))
-}
-
-func (c *lampPoleCtl) CreateOrUpdate(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	var req *dao.LampPole
-	if err := ctx.ShouldBindJSON(&req); err != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(err.Error(), nil))
-		return
-	}
-	err := service.LampPoleService.CreateOrUpdate(claims.UserId, claims.TenantId, req)
-	ctx.JSON(http.StatusOK, err)
-}
-
-func (c *lampPoleCtl) List(ctx *gin.Context) {
-	searchValue := ctx.Query("searchValue")
-	groupId := ctx.Query("groupId")
-	boxId := ctx.Query("boxId")
-	current, _ := strconv.Atoi(ctx.Query("current"))
-	size, _ := strconv.Atoi(ctx.Query("size"))
-	if current == 0 {
-		current = 1
-	}
-	if size <= 0 || size > 100 {
-		size = 10
-	}
-
-	devices, total, err := service.LampPoleService.List(searchValue, groupId, boxId, current, size)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	pages := math.Ceil(float64(total) / float64(size))
-	rsp := model.RspLampPoleList{
-		Current: current,
-		Size:    size,
-		Total:   int(total),
-		Pages:   int(pages),
-	}
-	for _, device := range devices {
-		rsp.Records = append(rsp.Records, lampPoleDaoToModel(device))
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, rsp))
-}
-
-func (c *lampPoleCtl) GetRelevanceDetail(ctx *gin.Context) {
-	id, e := strconv.Atoi(ctx.Query("id"))
-	if e != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(e.Error(), nil))
-		return
-	}
-
-	device, err := service.LampPoleService.GetRelevanceDetail(id)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, device))
-}
-
-func (c *lampPoleCtl) Remove(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	var req *model.ReqLampPoleRemove
-	if err := ctx.ShouldBindJSON(&req); err != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(err.Error(), nil))
-		return
-	}
-	err := service.LampPoleService.Remove(claims.UserId, claims.TenantId, req.IDs)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, nil))
-}
-
-func (c *lampPoleCtl) ImportExcel(ctx *gin.Context) {
-}
-
-func (c *lampPoleCtl) ExportExcel(ctx *gin.Context) {
-}
-
-func (c *lampPoleCtl) ExportTemplate(ctx *gin.Context) {
-}
-
-func (c *lampPoleCtl) GetList(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	devices, err := service.LampPoleService.GetList(claims.TenantId)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, devices))
-}
-
-func lampPoleDaoToModel(device dao.LampPole) model.LampPoleDetail {
-	return model.LampPoleDetail{
-		LampPole:          device,
-		AlarmTerminalList: nil,
-		CameraList:        nil,
-		CaptureUnitList:   nil,
-		GatewayList:       nil,
-		InfoBoardList:     nil,
-		IpBroadcastList:   nil,
-		LightControlList:  nil,
-		SensorList:        nil,
-		ZigbeeList:        nil,
-	}
-}

+ 0 - 150
app/device/controller/lampPoleGroupController.go

@@ -1,150 +0,0 @@
-package controller
-
-import (
-	"github.com/gin-gonic/gin"
-	"iot_manager_service/app/device/dao"
-	"iot_manager_service/app/device/model"
-	"iot_manager_service/app/device/service"
-	"iot_manager_service/app/middleware"
-	"iot_manager_service/util/common"
-	"math"
-	"net/http"
-	"strconv"
-)
-
-// 灯杆分组管理对象
-var LampPoleGroup = new(lampPoleGroupCtl)
-
-type lampPoleGroupCtl struct{}
-
-// Detail 获取详情
-func (c *lampPoleGroupCtl) Detail(ctx *gin.Context) {
-	id, e := strconv.Atoi(ctx.Query("id"))
-	if e != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(e.Error(), nil))
-		return
-	}
-
-	device, err := service.LampPoleGroupService.Get(id)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, lampPoleGroupDaoToModel(*device)))
-}
-
-// CreateOrUpdate 新增、更新
-func (c *lampPoleGroupCtl) CreateOrUpdate(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	var req *dao.LampPoleGroup
-	if err := ctx.ShouldBindJSON(&req); err != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(err.Error(), nil))
-		return
-	}
-
-	err := service.LampPoleGroupService.CreateOrUpdate(claims.UserId, claims.TenantId, req)
-	ctx.JSON(http.StatusOK, err)
-}
-
-// List 获取分页列表
-func (c *lampPoleGroupCtl) List(ctx *gin.Context) {
-	poleGroupName := ctx.Query("poleGroupName")
-	current, _ := strconv.Atoi(ctx.Query("current"))
-	size, _ := strconv.Atoi(ctx.Query("size"))
-	if current == 0 {
-		current = 1
-	}
-	if size <= 0 || size > 100 {
-		size = 10
-	}
-
-	devices, total, err := service.LampPoleGroupService.List(poleGroupName, current, size)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	pages := math.Ceil(float64(total) / float64(size))
-	rsp := model.RspLampPoleGroupList{
-		Current: current,
-		Size:    size,
-		Total:   int(total),
-		Pages:   int(pages),
-	}
-	for _, device := range devices {
-		rsp.Records = append(rsp.Records, lampPoleGroupDaoToModel(device))
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, rsp))
-}
-
-// Remove 删除
-func (c *lampPoleGroupCtl) Remove(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	var req *model.ReqLampPoleGroupRemove
-
-	if err := ctx.ShouldBindJSON(&req); err != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(err.Error(), nil))
-		return
-	}
-	err := service.LampPoleGroupService.Remove(claims.UserId, claims.TenantId, req.IDs, req.Name)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, nil))
-}
-
-// GetList 获取下拉列表
-func (c *lampPoleGroupCtl) GetList(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	devices, err := service.LampPoleGroupService.GetList(claims.TenantId)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, devices))
-}
-
-// FiltrationList 获取智能照明灯杆分组下拉(过滤掉没有灯控的分组显示)
-func (c *lampPoleGroupCtl) FiltrationList(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	devices, err := service.LampPoleGroupService.GetFiltration(claims.TenantId)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, devices))
-}
-
-// GetTree 获取所有的灯杆分组所属灯杆
-func (c *lampPoleGroupCtl) GetTree(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	//todo 灯杆列表赋值
-	// var rsp model.ReqLampPoleGroupSubmit
-	devices, err := service.LampPoleGroupService.GetTree(claims.TenantId)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, devices))
-}
-
-func lampPoleGroupDaoToModel(device dao.LampPoleGroup) model.LampPoleGroupDetail {
-	return model.LampPoleGroupDetail{
-		LampPoleGroup:  device,
-		PublicName:     "",
-		LampPoleVOList: []model.LampPoleDetail{},
-		CameraList:     []dao.CameraDevice{},
-		SwitchBoxList:  []dao.SwitchBox{},
-		InfoBoardList:  []dao.InfoBoard{},
-	}
-}

+ 0 - 142
app/device/controller/lightController.go

@@ -1,142 +0,0 @@
-package controller
-
-import (
-	"github.com/gin-gonic/gin"
-	"iot_manager_service/app/device/dao"
-	"iot_manager_service/app/device/model"
-	"iot_manager_service/app/device/service"
-	"iot_manager_service/app/middleware"
-	"iot_manager_service/util/common"
-	"math"
-	"net/http"
-	"strconv"
-)
-
-// 灯控基本信息管理对象
-var Light = new(lightCtl)
-
-type lightCtl struct{}
-
-func (c *lightCtl) Detail(ctx *gin.Context) {
-	id, e := strconv.Atoi(ctx.Query("id"))
-	if e != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(e.Error(), nil))
-		return
-	}
-
-	device, err := service.LightControlService.Get(id)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, device))
-}
-
-func (c *lightCtl) List(ctx *gin.Context) {
-	searchValue := ctx.Query("searchValue")
-	controlType := ctx.Query("controlType")
-	zigbeeId := ctx.Query("zigbeeId")
-	current, _ := strconv.Atoi(ctx.Query("current"))
-	size, _ := strconv.Atoi(ctx.Query("size"))
-	if current == 0 {
-		current = 1
-	}
-	if size <= 0 || size > 100 {
-		size = 10
-	}
-
-	devices, total, err := service.LightControlService.List(searchValue, controlType, zigbeeId, current, size)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	pages := math.Ceil(float64(total) / float64(size))
-	rsp := model.RspLightControlList{
-		Current: current,
-		Size:    size,
-		Total:   int(total),
-		Pages:   int(pages),
-		Records: devices,
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, rsp))
-}
-
-func (c *lightCtl) CreateOrUpdate(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	var req *dao.LightControl
-	if err := ctx.ShouldBindJSON(&req); err != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(err.Error(), nil))
-		return
-	}
-	err := service.LightControlService.CreateOrUpdate(claims.UserId, claims.TenantId, req)
-	ctx.JSON(http.StatusOK, err)
-}
-
-func (c *lightCtl) Remove(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	var req *model.ReqLightControlRemove
-	if err := ctx.ShouldBindJSON(&req); err != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(err.Error(), nil))
-		return
-	}
-	err := service.LightControlService.Remove(claims.UserId, claims.TenantId, req.IDs)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, nil))
-}
-
-func (c *lightCtl) ImportExcel(ctx *gin.Context) {
-}
-
-func (c *lightCtl) ExportExcel(ctx *gin.Context) {
-}
-
-func (c *lightCtl) ExportTemplate(ctx *gin.Context) {
-}
-
-func (c *lightCtl) GetList(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	devices, err := service.LightControlService.GetList(claims.TenantId)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, devices))
-}
-
-func (c *lightCtl) Enable(ctx *gin.Context) {
-	var req *model.ReqLightControlEnable
-	if err := ctx.ShouldBindJSON(&req); err != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(err.Error(), nil))
-		return
-	}
-	if req.Status != model.Enable_Enable && req.Status != model.Enable_Disable {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(model.EnableInvalid, nil))
-		return
-	}
-	err := service.LightControlService.Enable(req.ID, req.Status)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, nil))
-}
-
-func (c *lightCtl) Switch(ctx *gin.Context) {
-}
-
-func lightControlDaoToModel(device dao.LightControl) model.LightControlDetail {
-	return model.LightControlDetail{LightControl: device}
-}
-
-func (c *lightCtl) ChangeHandSwitch(ctx *gin.Context) {
-
-}

+ 0 - 140
app/device/controller/manholeCoverController.go

@@ -1,140 +0,0 @@
-package controller
-
-import (
-	"github.com/gin-gonic/gin"
-	"iot_manager_service/app/device/dao"
-	"iot_manager_service/app/device/model"
-	"iot_manager_service/app/device/service"
-	"iot_manager_service/app/middleware"
-	"iot_manager_service/util/common"
-	"math"
-	"net/http"
-	"strconv"
-)
-
-// 井盖基本信息管理对象
-var ManholeCover = new(manholeCoverCtl)
-
-type manholeCoverCtl struct{}
-
-func (c *manholeCoverCtl) Detail(ctx *gin.Context) {
-	id, e := strconv.Atoi(ctx.Query("id"))
-	if e != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(e.Error(), nil))
-		return
-	}
-
-	device, err := service.ManholeCoverService.Get(id)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, device))
-}
-
-func (c *manholeCoverCtl) List(ctx *gin.Context) {
-	searchValue := ctx.Query("searchValue")
-	current, _ := strconv.Atoi(ctx.Query("current"))
-	size, _ := strconv.Atoi(ctx.Query("size"))
-	if current == 0 {
-		current = 1
-	}
-	if size <= 0 || size > 100 {
-		size = 10
-	}
-	devices, total, err := service.ManholeCoverService.List(searchValue, current, size)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	pages := math.Ceil(float64(total) / float64(size))
-	rsp := model.RsqManholeCoverList{
-		Current: current,
-		Size:    size,
-		Total:   int(total),
-		Pages:   int(pages),
-	}
-	for _, device := range devices {
-
-		rsp.Records = append(rsp.Records, device)
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, rsp))
-}
-
-func (c *manholeCoverCtl) CreateOrUpdate(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	var req dao.ManholeCover
-	if err := ctx.ShouldBindJSON(&req); err != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(err.Error(), nil))
-		return
-	}
-	err := service.ManholeCoverService.CreateOrUpdate(claims.UserId, claims.TenantId, req)
-	ctx.JSON(http.StatusOK, err)
-}
-
-func (c *manholeCoverCtl) Remove(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	var req *model.ReqManholeCoverRemove
-	if err := ctx.ShouldBindJSON(&req); err != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(err.Error(), nil))
-		return
-	}
-	err := service.ManholeCoverService.Remove(claims.UserId, claims.TenantId, req.IDs)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, nil))
-}
-
-func (c *manholeCoverCtl) ImportExcel(ctx *gin.Context) {
-}
-
-func (c *manholeCoverCtl) ExportExcel(ctx *gin.Context) {
-}
-
-func (c *manholeCoverCtl) ExportTemplate(ctx *gin.Context) {
-}
-
-func (c *manholeCoverCtl) GetList(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	devices, err := service.ManholeCoverService.GetList(claims.TenantId)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, devices))
-}
-
-func (c *manholeCoverCtl) AllList(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	devices, err := service.ManholeCoverService.GetList(claims.TenantId)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, devices))
-}
-
-func (c *manholeCoverCtl) Setting(ctx *gin.Context) {
-	threshold := ctx.Query("threshold")
-	idStr := ctx.Query("id")
-	id, _ := strconv.Atoi(idStr)
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	err := service.ManholeCoverService.Setting(claims.TenantId, id, threshold)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, nil))
-}

+ 0 - 121
app/device/controller/onDemandGroupController.go

@@ -1,121 +0,0 @@
-package controller
-
-import (
-	"github.com/gin-gonic/gin"
-	"iot_manager_service/app/device/dao"
-	"iot_manager_service/app/device/model"
-	"iot_manager_service/app/device/service"
-	"iot_manager_service/app/middleware"
-	"iot_manager_service/util/common"
-	"math"
-	"net/http"
-	"strconv"
-)
-
-// 灯随车走分组管理对象
-var OnDemandGroup = new(onDemandGroupCtl)
-
-type onDemandGroupCtl struct{}
-
-func (c *onDemandGroupCtl) Detail(ctx *gin.Context) {
-	id, e := strconv.Atoi(ctx.Query("id"))
-	if e != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(e.Error(), nil))
-		return
-	}
-
-	device, err := service.OnDemandGroupService.Get(id)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, device))
-}
-
-func (c *onDemandGroupCtl) List(ctx *gin.Context) {
-	searchValue := ctx.Query("searchValue")
-	current, _ := strconv.Atoi(ctx.Query("current"))
-	size, _ := strconv.Atoi(ctx.Query("size"))
-	if current == 0 {
-		current = 1
-	}
-	if size <= 0 || size > 100 {
-		size = 10
-	}
-
-	devices, err := service.OnDemandGroupService.List(searchValue, current, size)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	pages := math.Ceil(float64(len(devices)) / float64(size))
-	rsp := model.RspOnDemandGroupList{
-		Current: current,
-		Size:    size,
-		Total:   len(devices),
-		Pages:   int(pages),
-		Records: devices,
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, rsp))
-}
-
-func (c *onDemandGroupCtl) CreateOrUpdate(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	var req *dao.OnDemandGroup
-	if err := ctx.ShouldBindJSON(&req); err != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(err.Error(), nil))
-		return
-	}
-	err := service.OnDemandGroupService.CreateOrUpdate(claims.UserId, claims.TenantId, req)
-	ctx.JSON(http.StatusOK, err)
-}
-
-func (c *onDemandGroupCtl) Remove(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	var req *model.ReqOnDemandGroupRemove
-	if err := ctx.ShouldBindJSON(&req); err != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(err.Error(), nil))
-		return
-	}
-	err := service.OnDemandGroupService.Remove(claims.UserId, claims.TenantId, req.IDs)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, nil))
-}
-
-func (c *onDemandGroupCtl) GetList(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	devices, err := service.OnDemandGroupService.GetList(claims.TenantId)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, devices))
-}
-
-func (c *onDemandGroupCtl) GroupNumber(ctx *gin.Context) {
-	id, e := strconv.Atoi(ctx.Query("id"))
-	if e != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(e.Error(), nil))
-		return
-	}
-	if id <= 0 {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(model.ParamsInvalid, nil))
-		return
-	}
-
-	device, err := service.OnDemandGroupService.GroupNumberList(id)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, device))
-}

+ 0 - 104
app/device/controller/onDemandSensorController.go

@@ -1,104 +0,0 @@
-package controller
-
-import (
-	"github.com/gin-gonic/gin"
-	"iot_manager_service/app/device/dao"
-	"iot_manager_service/app/device/model"
-	"iot_manager_service/app/device/service"
-	"iot_manager_service/app/middleware"
-	"iot_manager_service/util/common"
-	"math"
-	"net/http"
-	"strconv"
-)
-
-// OnDemandSensor 灯随车走传感器管理对象
-var OnDemandSensor = new(onDemandSensorCtl)
-
-type onDemandSensorCtl struct{}
-
-func (c *onDemandSensorCtl) Detail(ctx *gin.Context) {
-	id, e := strconv.Atoi(ctx.Query("id"))
-	if e != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(e.Error(), nil))
-		return
-	}
-
-	device, err := service.OnDemandSensorService.Get(id)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, device))
-}
-
-func (c *onDemandSensorCtl) List(ctx *gin.Context) {
-	searchValue := ctx.Query("searchValue")
-	current, _ := strconv.Atoi(ctx.Query("current"))
-	size, _ := strconv.Atoi(ctx.Query("size"))
-	if current == 0 {
-		current = 1
-	}
-	if size <= 0 || size > 100 {
-		size = 10
-	}
-	devices, total, err := service.OnDemandSensorService.List(searchValue, current, size)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	pages := math.Ceil(float64(total) / float64(size))
-	rsp := model.RsqOnDemandSensorList{
-		Current: current,
-		Size:    size,
-		Total:   int(total),
-		Pages:   int(pages),
-	}
-	for _, device := range devices {
-
-		rsp.Records = append(rsp.Records, device)
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, rsp))
-}
-
-func (c *onDemandSensorCtl) CreateOrUpdate(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	var req dao.OnDemandSensor
-	if err := ctx.ShouldBindJSON(&req); err != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(err.Error(), nil))
-		return
-	}
-	err := service.OnDemandSensorService.CreateOrUpdate(claims.UserId, claims.TenantId, req)
-	ctx.JSON(http.StatusOK, err)
-}
-
-func (c *onDemandSensorCtl) Remove(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	var req *model.ReqOnDemandSensorRemove
-	if err := ctx.ShouldBindJSON(&req); err != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(err.Error(), nil))
-		return
-	}
-	err := service.OnDemandSensorService.Remove(claims.UserId, claims.TenantId, req.IDs)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, nil))
-}
-
-func (c *onDemandSensorCtl) ImportExcel(ctx *gin.Context) {
-}
-
-func (c *onDemandSensorCtl) ExportExcel(ctx *gin.Context) {
-}
-
-func (c *onDemandSensorCtl) ExportTemplate(ctx *gin.Context) {
-}
-
-func (c *onDemandSensorCtl) Enable(ctx *gin.Context) {
-}

+ 0 - 116
app/device/controller/optoSensorController.go

@@ -1,116 +0,0 @@
-package controller
-
-import (
-	"github.com/gin-gonic/gin"
-	"iot_manager_service/app/device/dao"
-	"iot_manager_service/app/device/model"
-	"iot_manager_service/app/device/service"
-	"iot_manager_service/app/middleware"
-	"iot_manager_service/util/common"
-	"math"
-	"net/http"
-	"strconv"
-)
-
-// 环境传感器管理对象
-var OptoSensor = new(optoSensorCtl)
-
-type optoSensorCtl struct{}
-
-func (c *optoSensorCtl) Detail(ctx *gin.Context) {
-	id, e := strconv.Atoi(ctx.Query("id"))
-	if e != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(e.Error(), nil))
-		return
-	}
-
-	device, err := service.OptoSensorService.Get(id)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, device))
-}
-
-func (c *optoSensorCtl) List(ctx *gin.Context) {
-	searchValue := ctx.Query("searchValue")
-	current, _ := strconv.Atoi(ctx.Query("current"))
-	size, _ := strconv.Atoi(ctx.Query("size"))
-	if current == 0 {
-		current = 1
-	}
-	if size <= 0 || size > 100 {
-		size = 10
-	}
-	devices, total, err := service.OptoSensorService.List(searchValue, current, size)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	pages := math.Ceil(float64(total) / float64(size))
-	rsp := model.RsqOptoSensorList{
-		Current: current,
-		Size:    size,
-		Total:   int(total),
-		Pages:   int(pages),
-	}
-	for _, device := range devices {
-
-		rsp.Records = append(rsp.Records, device)
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, rsp))
-}
-
-func (c *optoSensorCtl) CreateOrUpdate(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	var req dao.OptoSensor
-	if err := ctx.ShouldBindJSON(&req); err != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(err.Error(), nil))
-		return
-	}
-	err := service.OptoSensorService.CreateOrUpdate(claims.UserId, claims.TenantId, req)
-	ctx.JSON(http.StatusOK, err)
-}
-
-func (c *optoSensorCtl) Remove(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	var req *model.ReqOptoSensorRemove
-	if err := ctx.ShouldBindJSON(&req); err != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(err.Error(), nil))
-		return
-	}
-	err := service.OptoSensorService.Remove(claims.UserId, claims.TenantId, req.IDs)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, nil))
-}
-
-func (c *optoSensorCtl) ImportExcel(ctx *gin.Context) {
-}
-
-func (c *optoSensorCtl) ExportExcel(ctx *gin.Context) {
-}
-
-func (c *optoSensorCtl) ExportTemplate(ctx *gin.Context) {
-}
-
-func (c *optoSensorCtl) GetList(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	devices, err := service.OptoSensorService.GetList(claims.TenantId)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, devices))
-}
-
-func (c *optoSensorCtl) SetDefault(ctx *gin.Context) {
-}

+ 0 - 112
app/device/controller/switchBoxController.go

@@ -1,112 +0,0 @@
-package controller
-
-import (
-	"github.com/gin-gonic/gin"
-	"iot_manager_service/app/device/dao"
-	"iot_manager_service/app/device/model"
-	"iot_manager_service/app/device/service"
-	"iot_manager_service/app/middleware"
-	"iot_manager_service/util/common"
-	"math"
-	"net/http"
-	"strconv"
-)
-
-// 配电箱基本信息管理对象
-var SwitchBox = new(switchBoxCtl)
-
-type switchBoxCtl struct{}
-
-func (c *switchBoxCtl) Detail(ctx *gin.Context) {
-	id, e := strconv.Atoi(ctx.Query("id"))
-	if e != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(e.Error(), nil))
-		return
-	}
-
-	device, err := service.SwitchBoxService.Get(id)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, device))
-}
-
-func (c *switchBoxCtl) List(ctx *gin.Context) {
-	searchValue := ctx.Query("searchValue")
-	current, _ := strconv.Atoi(ctx.Query("current"))
-	size, _ := strconv.Atoi(ctx.Query("size"))
-	if current == 0 {
-		current = 1
-	}
-	if size <= 0 || size > 100 {
-		size = 10
-	}
-	devices, total, err := service.SwitchBoxService.List(searchValue, current, size)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	pages := math.Ceil(float64(total) / float64(size))
-	rsp := model.RsqSwitchBoxList{
-		Current: current,
-		Size:    size,
-		Total:   int(total),
-		Pages:   int(pages),
-	}
-	for _, device := range devices {
-
-		rsp.Records = append(rsp.Records, device)
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, rsp))
-}
-
-func (c *switchBoxCtl) CreateOrUpdate(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	var req dao.SwitchBox
-	if err := ctx.ShouldBindJSON(&req); err != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(err.Error(), nil))
-		return
-	}
-	err := service.SwitchBoxService.CreateOrUpdate(claims.UserId, claims.TenantId, req)
-	ctx.JSON(http.StatusOK, err)
-}
-
-func (c *switchBoxCtl) Remove(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	var req *model.ReqSwitchBoxRemove
-	if err := ctx.ShouldBindJSON(&req); err != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(err.Error(), nil))
-		return
-	}
-	err := service.SwitchBoxService.Remove(claims.UserId, claims.TenantId, req.IDs)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, nil))
-}
-
-func (c *switchBoxCtl) GetList(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	devices, err := service.SwitchBoxService.GetList(claims.TenantId)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, devices))
-}
-
-func (c *switchBoxCtl) ImportExcel(ctx *gin.Context) {
-}
-func (c *switchBoxCtl) ExportExcel(ctx *gin.Context) {
-}
-func (c *switchBoxCtl) ExportTemplate(ctx *gin.Context) {
-
-}

+ 0 - 104
app/device/controller/transformerController.go

@@ -1,104 +0,0 @@
-package controller
-
-import (
-	"github.com/gin-gonic/gin"
-	"iot_manager_service/app/device/dao"
-	"iot_manager_service/app/device/model"
-	"iot_manager_service/app/device/service"
-	"iot_manager_service/app/middleware"
-	"iot_manager_service/util/common"
-	"math"
-	"net/http"
-	"strconv"
-)
-
-// 变压器基本信息管理对象
-var Transformer = new(transformerCtl)
-
-type transformerCtl struct{}
-
-func (c *transformerCtl) Detail(ctx *gin.Context) {
-	id, e := strconv.Atoi(ctx.Query("id"))
-	if e != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(e.Error(), nil))
-		return
-	}
-
-	device, err := service.TransformerService.Get(id)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, device))
-}
-
-func (c *transformerCtl) List(ctx *gin.Context) {
-	searchValue := ctx.Query("searchValue")
-	current, _ := strconv.Atoi(ctx.Query("current"))
-	size, _ := strconv.Atoi(ctx.Query("size"))
-	if current == 0 {
-		current = 1
-	}
-	if size <= 0 || size > 100 {
-		size = 10
-	}
-	devices, total, err := service.TransformerService.List(searchValue, current, size)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	pages := math.Ceil(float64(total) / float64(size))
-	rsp := model.RsqTransformerList{
-		Current: current,
-		Size:    size,
-		Total:   int(total),
-		Pages:   int(pages),
-	}
-	for _, device := range devices {
-
-		rsp.Records = append(rsp.Records, device)
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, rsp))
-}
-
-func (c *transformerCtl) CreateOrUpdate(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	var req dao.Transformer
-	if err := ctx.ShouldBindJSON(&req); err != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(err.Error(), nil))
-		return
-	}
-	err := service.TransformerService.CreateOrUpdate(claims.UserId, claims.TenantId, req)
-	ctx.JSON(http.StatusOK, err)
-}
-
-func (c *transformerCtl) Remove(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	var req *model.ReqTransformerRemove
-	if err := ctx.ShouldBindJSON(&req); err != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(err.Error(), nil))
-		return
-	}
-	err := service.TransformerService.Remove(claims.UserId, claims.TenantId, req.IDs)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, nil))
-}
-
-func (c *transformerCtl) GetList(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	devices, err := service.TransformerService.GetList(claims.TenantId)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, devices))
-}

+ 0 - 219
app/device/controller/utilController.go

@@ -1,219 +0,0 @@
-package controller
-
-import (
-	"github.com/gin-gonic/gin"
-	"iot_manager_service/app/device/model"
-	"iot_manager_service/app/device/service"
-	"iot_manager_service/app/middleware"
-	"iot_manager_service/util/common"
-	"net/http"
-	"sort"
-	"strconv"
-)
-
-// 工具服务
-var Util = new(utilCtl)
-
-type utilCtl struct{}
-
-// GetModelList 获取厂家/品牌/型号列表
-// 查询类型 type:1-厂家,2-品牌,3-型号
-//deviceType 设备类型
-//0-摄像头
-//1 灯控
-//2 信息屏
-//3 配电箱
-//4  网关
-//5  环境监测
-//6  ZigBee
-//7  一键告警终端
-//8 一键告警服务端
-//11 桥梁传感器
-//12 ip音柱
-//13 井盖
-//14 垃圾桶
-func (c *utilCtl) GetModelList(ctx *gin.Context) {
-	t := ctx.Query("type")
-	d := ctx.Query("deviceType")
-	id := ctx.Query("id")
-	pid := ctx.Query("pid")
-	modeType, err := strconv.Atoi(t)
-	if err != nil || modeType < 1 || modeType > 3 {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse("type invalid", nil))
-		return
-	}
-	modeType++ //前端传入的1和2,实际是2和3
-
-	deviceType, err := strconv.Atoi(d)
-	if err != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse("deviceType invalid", nil))
-		return
-	}
-	parentId := -1
-	if id != "" {
-		parentId, _ = strconv.Atoi(id)
-	} else if pid != "" {
-		parentId, _ = strconv.Atoi(pid)
-	}
-
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	var result []model.VendorDetail
-	if modeType == model.TypeVendor {
-		vendors, err := service.UtilService.GetDeviceVendor(claims.TenantId, deviceType)
-		if err != nil {
-			ctx.JSON(http.StatusOK, common.FailResponse(err.Error(), nil))
-			return
-		}
-		for _, vendor := range vendors {
-			result = append(result, model.VendorDetail{
-				Id:       vendor.ID,
-				ParentId: vendor.ParentId,
-				Vendor:   vendor.VendorValue,
-			})
-		}
-	} else if modeType == model.TypeBrand {
-		vendors, err := service.UtilService.GetDeviceBrand(claims.TenantId, deviceType)
-		if err != nil {
-			ctx.JSON(http.StatusOK, common.FailResponse(err.Error(), nil))
-			return
-		}
-		for _, vendor := range vendors {
-			result = append(result, model.VendorDetail{
-				Id:       vendor.ID,
-				ParentId: vendor.ParentId,
-				Brand:    vendor.VendorValue,
-			})
-		}
-	} else if modeType == model.TypeModel {
-		vendors, err := service.UtilService.GetDeviceModel(claims.TenantId, deviceType, parentId)
-		if err != nil {
-			ctx.JSON(http.StatusOK, common.FailResponse(err.Error(), nil))
-			return
-		}
-		for _, vendor := range vendors {
-			result = append(result, model.VendorDetail{
-				Id:       vendor.ID,
-				ParentId: vendor.ParentId,
-				Model:    vendor.VendorValue,
-			})
-		}
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse("", result))
-}
-
-func (c *utilCtl) GetTenantCode(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-	id := claims.TenantId
-	code, _ := service.UtilService.GetTenantCode(id)
-	code.CityCode = ctx.Query("type") + code.CityCode
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, code))
-}
-
-type vendorList struct {
-	Records          []vendorListNew `json:"records"`
-	Total            int             `json:"total"`
-	Size             int             `json:"size"`
-	Current          int             `json:"current"`
-	Orders           []interface{}   `json:"orders"`
-	OptimizeCountSQL bool            `json:"optimizeCountSql"`
-	HitCount         bool            `json:"hitCount"`
-	SearchCount      bool            `json:"searchCount"`
-	Pages            int             `json:"pages"`
-}
-type vendorListNew struct {
-	ID         int    `json:"id"`
-	Vender     string `json:"vender"`
-	Brand      string `json:"brand"`
-	Model      string `json:"model"`
-	Pid        int
-	DeviceType int `json:"deviceType"`
-}
-
-func (c *utilCtl) GetVenderList(ctx *gin.Context) {
-	var result vendorList
-	deviceType := ctx.Query("deviceType")
-	if deviceType == "" {
-		deviceType = "-1"
-	}
-	venderValue := ctx.Query("venderValue")
-	current := ctx.Query("current")
-	size := ctx.Query("size")
-	offset, _ := strconv.Atoi(current)
-	limit, _ := strconv.Atoi(size)
-	if offset == 0 {
-		offset = 1
-		limit = 10
-	}
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-	deviceTypeInt, _ := strconv.Atoi(deviceType)
-	vendors, _, err := service.UtilService.GetDeviceVendorList(claims.TenantId, venderValue, deviceTypeInt, offset, limit)
-	vendorsMap := make(map[int]vendorListNew)
-	vendorListNews1 := make(map[int]vendorListNew)
-	vendorListNews2 := make(map[int]vendorListNew)
-	vendorListNews3 := make(map[int]vendorListNew)
-	for _, vendor := range vendors {
-		vendorsMap[vendor.ID] = vendorListNew{
-			ID:         vendor.ID,
-			Vender:     vendor.VendorValue,
-			DeviceType: vendor.DeviceType,
-			Pid:        vendor.ParentId,
-		}
-		if vendor.VendorType == 3 {
-			vendorListNews3[vendor.ID] = vendorsMap[vendor.ID]
-		}
-		if vendor.VendorType == 2 {
-			vendorListNews2[vendor.ID] = vendorsMap[vendor.ID]
-		}
-		if vendor.VendorType == 1 {
-			vendorListNews1[vendor.ID] = vendorsMap[vendor.ID]
-		}
-	}
-	var vendorListNews []vendorListNew
-	for _, listNew := range vendorListNews3 {
-		vendorListNews = append(vendorListNews, vendorListNew{
-			ID:         listNew.ID,
-			Vender:     vendorListNews1[vendorListNews2[listNew.Pid].Pid].Vender,
-			Brand:      vendorListNews2[listNew.Pid].Vender,
-			Model:      listNew.Vender,
-			DeviceType: listNew.DeviceType,
-			Pid:        listNew.Pid,
-		})
-	}
-	sort.Slice(vendorListNews, func(i, j int) bool {
-		return vendorListNews[i].ID > vendorListNews[j].ID
-	})
-
-	if err != nil {
-		ctx.JSON(http.StatusOK, common.FailResponse(err.Error(), nil))
-		return
-	}
-	result.Records = vendorListNews
-	result.Total = len(vendorListNews)
-	ctx.JSON(http.StatusOK, common.SuccessResponse("", result))
-}
-
-func (c *utilCtl) GetVenderDetail(ctx *gin.Context) {
-	//idStr := ctx.Query("id")
-	//var vendorListNew vendorListNew
-	//id, _ := strconv.Atoi(idStr)
-	ctx.JSON(http.StatusOK, common.SuccessResponse("", nil))
-}
-
-func (c *utilCtl) GetVenderRemove(ctx *gin.Context) {
-	idStr := ctx.Query("id")
-	id, _ := strconv.Atoi(idStr)
-	err := service.UtilService.GetRemoveVendor(id)
-	if err != nil {
-		ctx.JSON(http.StatusOK, common.FailResponse(err.Error(), nil))
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse("", nil))
-}
-
-func (c *utilCtl) GetVenderSubmit(ctx *gin.Context) {
-	ctx.JSON(http.StatusOK, common.SuccessResponse("", nil))
-}

+ 0 - 104
app/device/controller/workbenchController.go

@@ -1,104 +0,0 @@
-package controller
-
-import (
-	"github.com/gin-gonic/gin"
-	"iot_manager_service/app/device/model"
-	"iot_manager_service/app/device/service"
-	"iot_manager_service/app/middleware"
-	"iot_manager_service/util/common"
-	"net/http"
-)
-
-// 工作台管理对象
-var Workbench = new(workbenchCtl)
-
-type workbenchCtl struct{}
-
-func (c *workbenchCtl) CountDevice(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	devices, err := service.WorkbenchService.CountDevice(claims.TenantId)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, devices))
-}
-
-func (c *workbenchCtl) CountAlarm(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	alarms, err := service.WorkbenchService.CountAlarm(claims.TenantId)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, alarms))
-}
-
-func (c *workbenchCtl) Aqi(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	alarms, err := service.WorkbenchService.Aqi(claims.TenantId)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, alarms))
-}
-
-func (c *workbenchCtl) CountJobTodo(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	alarms, err := service.WorkbenchService.CountJobTodo(claims.TenantId)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, alarms))
-}
-
-//	func (c *workbenchCtl) Notification(ctx *gin.Context) {
-//		value, _ := ctx.Get(middleware.Authorization)
-//		claims := value.(*middleware.Claims)
-//
-//		alarms, err := service.WorkbenchService.Notification(claims.TenantId)
-//		if err != nil {
-//			ctx.JSON(http.StatusOK, err)
-//			return
-//		}
-//		ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, alarms))
-//
-// }
-// 显示设备离线的状态
-func (c *workbenchCtl) Notification(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-	alarms, err := service.WorkbenchService.Notification(claims.TenantId)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, alarms))
-
-}
-
-func (c *workbenchCtl) LightRate(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-	var req model.ReqLightRates
-	if err := ctx.ShouldBindQuery(&req); err != nil {
-		ctx.JSON(http.StatusServiceUnavailable, err)
-	}
-	//queryType=month&startDate=2022-09-01&endDate=2022-10-04
-	alarms, err := service.WorkbenchService.LightRate(claims.TenantId, req)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, alarms))
-}

+ 0 - 110
app/device/controller/zigbeeController.go

@@ -1,110 +0,0 @@
-package controller
-
-import (
-	"github.com/gin-gonic/gin"
-	"iot_manager_service/app/device/dao"
-	"iot_manager_service/app/device/model"
-	"iot_manager_service/app/device/service"
-	"iot_manager_service/app/middleware"
-	"iot_manager_service/util/common"
-	"math"
-	"net/http"
-	"strconv"
-)
-
-// zigBee网关管理对象
-var Zigbee = new(zigbeeCtl)
-
-type zigbeeCtl struct{}
-
-func (c *zigbeeCtl) Detail(ctx *gin.Context) {
-	id, e := strconv.Atoi(ctx.Query("id"))
-	if e != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(e.Error(), nil))
-		return
-	}
-
-	device, err := service.ZigbeeService.Get(id)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, device))
-}
-
-func (c *zigbeeCtl) List(ctx *gin.Context) {
-	searchValue := ctx.Query("searchValue")
-	current, _ := strconv.Atoi(ctx.Query("current"))
-	size, _ := strconv.Atoi(ctx.Query("size"))
-	if current == 0 {
-		current = 1
-	}
-	if size <= 0 || size > 100 {
-		size = 10
-	}
-	devices, total, err := service.ZigbeeService.List(searchValue, current, size)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	pages := math.Ceil(float64(total) / float64(size))
-	rsp := model.RsqZigbeeList{
-		Current: current,
-		Size:    size,
-		Total:   int(total),
-		Pages:   int(pages),
-		Records: devices,
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, rsp))
-}
-
-func (c *zigbeeCtl) CreateOrUpdate(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	var req dao.Zigbee
-	if err := ctx.ShouldBindJSON(&req); err != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(err.Error(), nil))
-		return
-	}
-	err := service.ZigbeeService.CreateOrUpdate(claims.UserId, claims.TenantId, req)
-	ctx.JSON(http.StatusOK, err)
-}
-
-func (c *zigbeeCtl) Remove(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	var req *model.ReqZigbeeRemove
-	if err := ctx.ShouldBindJSON(&req); err != nil {
-		ctx.JSON(http.StatusOK, common.ParamsInvalidResponse(err.Error(), nil))
-		return
-	}
-	err := service.ZigbeeService.Remove(claims.UserId, claims.TenantId, req.IDs)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, nil))
-}
-
-func (c *zigbeeCtl) ImportExcel(ctx *gin.Context) {
-}
-
-func (c *zigbeeCtl) ExportExcel(ctx *gin.Context) {
-}
-
-func (c *zigbeeCtl) ExportTemplate(ctx *gin.Context) {
-}
-
-func (c *zigbeeCtl) GetList(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	devices, err := service.ZigbeeService.GetList(claims.TenantId)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, devices))
-}

+ 0 - 90
app/device/dao/LightStrategyDao.go

@@ -1,90 +0,0 @@
-package dao
-
-import (
-	"gorm.io/gorm"
-	"time"
-)
-
-type LightStrategy struct {
-	ID                 int       `gorm:"primary key" json:"id"`                        //编号
-	LightName          string    `gorm:"type:varchar(64)" json:"lightName"`            //策略名称
-	LightControlType   int       `gorm:"type:int" json:"lightControlType"`             //灯控类型 设置 1=485,2=nb-iot
-	OptoSensorID       int       `gorm:"type:int" json:"optoSensorId"`                 //光传感器ID
-	StartTime          string    `gorm:"type:varchar(60)" json:"startTime"`            //策略期限开始时间
-	EndTime            string    `gorm:"type:varchar(60)" json:"endTime"`              //策略期限结束时间
-	IsAllYear          int       `gorm:"type:int;default 1" json:"isAllYear"`          //全年设置2=是,1=否
-	IsAutomaticRenewal int       `gorm:"type:int;default 1" json:"isAutomaticRenewal"` //自动续期设置 2=是,1=否
-	TenantId           string    `gorm:"type:varchar(12)" json:"tenantId"`             //租户ID
-	CreateTime         time.Time `gorm:"type:datetime" json:"createTime"`              //新增时间
-	CreateUser         int       `gorm:"type:int" json:"createUser"`                   //新增记录操作用户ID
-	UpdateTime         time.Time `gorm:"type:datetime" json:"updateTime"`              //修改时间
-	UpdateUser         int       `gorm:"type:int" json:"updateUser"`                   //修改用户
-	IsDeleted          int       `gorm:"type:int;default 0" json:"isDeleted"`          //是否删除 0=未删除,1=删除
-	Status             int       `gorm:"type:int;default 1" json:"status"`             //状态 0=正常,1=异常
-	LightSn            string    `gorm:"type:varchar(64)" json:"lightSn"`              //策略编码
-	ManualTime         int       `gorm:"type:int;default 0" json:"manualTime"`         //手动控制时间
-}
-
-func (LightStrategy) TableName() string {
-	return "strategy_light"
-}
-
-func (c *LightStrategy) Delete() error {
-	return Db.Model(&c).Where("id = ?", c.ID).Updates(map[string]interface{}{"update_time": c.UpdateTime,
-		"update_user": c.UpdateUser, "is_deleted": c.IsDeleted}).Error
-}
-
-func (c LightStrategy) IsExistedBySN() bool {
-	var count int64
-	_ = Db.Model(&c).Where(" light_sn = ? and is_deleted = ?",
-		c.LightSn, c.IsDeleted).Count(&count).Error
-	return count > 0
-}
-
-func (c LightStrategy) IsExistedByNameAndCode() bool {
-	var Strategies []LightStrategy
-	err := Db.Model(&c).Where("gateway_sn = ? and is_deleted = ?",
-		c.TenantId, c.IsDeleted).Find(&Strategies).Error
-	if err == gorm.ErrRecordNotFound {
-		return false
-	}
-	for _, d := range Strategies {
-		if d.ID != c.ID {
-			return true
-		}
-	}
-	return false
-}
-
-func (c *LightStrategy) Create() error {
-	return Db.Model(&c).Save(&c).Error
-}
-
-func (c *LightStrategy) Update() error {
-	return Db.Model(&c).Where(" id = ? and is_deleted = 0", c.ID).Updates(&c).Error
-}
-
-func (c *LightStrategy) GetStrategy() error {
-	err := Db.Model(&c).Where(" id = ? and is_deleted = 0", c.ID).First(&c).Error
-	return err
-}
-
-func (c LightStrategy) GetStrategies(offset, limit int) ([]LightStrategy, int64, error) {
-	var Strategies []LightStrategy
-	var count int64
-	db := Db.Model(&c).Where("is_deleted = 0")
-	if c.LightSn != "" {
-		db = db.Where(" light_name like ? or light_sn like ?", "%"+c.LightSn+"%", "%"+c.LightSn+"%")
-	}
-	db.Count(&count)
-	err := db.Offset(offset).Limit(limit).Find(&Strategies).Error
-	return Strategies, count, err
-
-}
-
-func (c LightStrategy) GetAllStrategies() ([]*LightStrategy, error) {
-	var Strategies []*LightStrategy
-	err := Db.Model(&c).Where(" tenant_id = ? and is_deleted = ? ", c.TenantId,
-		c.IsDeleted).Scan(&Strategies).Error
-	return Strategies, err
-}

+ 0 - 120
app/device/dao/alarmDao.go

@@ -1,120 +0,0 @@
-package dao
-
-import (
-	"gorm.io/gorm"
-	"time"
-)
-
-// Alarm 一键报警服务
-type Alarm struct {
-	ID          int        `gorm:"primary_key" json:"id"`             //编号
-	ServeName   string     `gorm:"varchar(64)" json:"serveName"`      //设备名称
-	ServeSN     string     `gorm:"type:varchar(60)" json:"serveSn"`   //设备序编码
-	BrandID     int        `gorm:"type:int" json:"brandId"`           //设备品牌ID
-	CountRel    int        `gorm:"-" json:"countRel"`                 //关联终端数
-	ModelID     int        `gorm:"type:int" json:"modelId"`           //设备型号ID
-	ServeType   int        `gorm:"type:int" json:"serveType"`         //服务
-	ServeIP     string     `gorm:"type:varchar(50)" json:"serveIp"`   //所属服务IP地址
-	ServePort   int        `gorm:"type:int" json:"servePort"`         //端口
-	Account     string     `gorm:"type:varchar(4000)" json:"account"` //账号
-	Pwd         string     `gorm:"type:varchar(4000)" json:"pwd"`     //密码
-	Numeration  int        `gorm:"type:int" json:"numeration"`        //编号
-	IPAddress   string     `gorm:"type:varchar(50)" json:"ipAddress"` //IP地址
-	InstallTime *time.Time `gorm:"type:date" json:"installTime"`      //安装时间
-	TenantId    string     `gorm:"type:varchar(12)" json:"tenantId"`  //租户id
-	CreateTime  time.Time  `gorm:"type:datetime" json:"createTime"`   //新增时间
-	CreateUser  int        `gorm:"type:int" json:"createUser"`        //新增记录操作用户ID
-	UpdateTime  time.Time  `gorm:"type:datetime" json:"updateTime"`   //修改时间
-	UpdateUser  int        `gorm:"type:int" json:"updateUser"`        //修改用户
-	IsDeleted   int        `gorm:"type:int" json:"isDeleted"`         //是否删除 0=未删除,1=删除
-	Status      int        `gorm:"type:int" json:"status"`            //告警状态 1处理完成2待处理3无需处理
-	Tag         string     `gorm:"type:varchar(255)" json:"tag"`      //标签,(备用,逗号区分)
-}
-
-func (Alarm) TableName() string {
-	return "device_a_key_alarm_serve"
-}
-
-func (c Alarm) Delete() error {
-	return Db.Model(&c).Where("id = ?", c.ID).Updates(map[string]interface{}{"update_time": c.UpdateTime, "update_user": c.UpdateUser, "is_deleted": c.IsDeleted}).Error
-}
-
-func (c Alarm) IsExistedBySN() bool {
-	var count int64
-	_ = Db.Model(&c).Where("  serve_sn = ? and is_deleted = ?",
-		c.ServeSN, c.IsDeleted).Count(&count).Error
-	return count > 0
-}
-
-func (c Alarm) IsExistedByNameAndCode() bool {
-	var devices []Alarm
-	err := Db.Model(&c).Where(" serve_sn = ? and is_deleted = ?",
-		c.ServeSN, c.IsDeleted).Find(&devices).Error
-	//如果查询不到,返回相应的错误
-	if gorm.ErrRecordNotFound == err {
-		return false
-	}
-	for _, d := range devices {
-		if d.ID != c.ID {
-			return true
-		}
-	}
-	return false
-}
-
-func (c *Alarm) Create() error {
-	return Db.Model(&c).Save(&c).Error
-}
-
-func (c *Alarm) Update() error {
-	return Db.Model(&c).Where(" id = ? ", c.ID).Updates(&c).Error
-}
-
-func (c *Alarm) GetDevice() error {
-	err := Db.Model(&c).Where(" id = ? ", c.ID).Scan(&c).Error
-	return err
-}
-
-func (c Alarm) GetDevices(offset, limit int) ([]Alarm, int64, error) {
-	var devices []Alarm
-	var count int64
-	db := Db.Model(&c).Where(" serve_name like ? and is_deleted = 0", "%"+c.ServeName+"%")
-	db.Count(&count)
-	err := db.Offset(offset).Limit(limit).Find(&devices).Error
-	return devices, count, err
-}
-
-func (c Alarm) GetAllDevices() ([]*Alarm, error) {
-	var devices []*Alarm
-	err := Db.Model(&c).Where(" tenant_id = ? and is_deleted = ? ", c.TenantId, c.IsDeleted).Scan(&devices).Error
-	return devices, err
-}
-
-func (c Alarm) DeviceCount1() (int64, int64) {
-	var all, fault int64
-	err := Db.Model(&c).Where("is_deleted = 0").Count(&all).Error
-	if err != nil {
-		all = -1
-	}
-	err = Db.Model(&c).Where("is_deleted = 0 and status = 0").Count(&fault).Error
-	if err != nil {
-		fault = -1
-	}
-	return all, fault
-}
-
-func (c Alarm) ListDevices1() []Device {
-	var devices []Alarm
-	Db.Model(&c).Where("is_deleted = 0").Find(&devices)
-	var rsp = make([]Device, 0, len(devices))
-	for _, v := range devices {
-		var d = Device{
-			Status: v.Status,
-			Name:   v.ServeName,
-			Code:   v.ServeSN,
-			Model:  "模型",
-		}
-		rsp = append(rsp, d)
-	}
-	return rsp
-}

+ 0 - 146
app/device/dao/alarmTerminalDao.go

@@ -1,146 +0,0 @@
-package dao
-
-import (
-	"gorm.io/gorm"
-	"time"
-)
-
-// AlarmTerminal 一键报警服务
-type AlarmTerminal struct {
-	ID               int       `gorm:"primary_key" json:"id"`                     //编号
-	TerminalName     string    `gorm:"varchar(64)" json:"terminalName"`           //设备名称
-	TerminalSN       string    `gorm:"type:varchar(60)" json:"terminalSn"`        //设备序编码
-	BrandId          int       `gorm:"type:int" json:"brandId"`                   //设备品牌ID
-	ModelId          int       `gorm:"type:int" json:"modelId"`                   //设备型号ID
-	GatewayId        int       `gorm:"type:int" json:"gatewayId"`                 //所属网关
-	LampPoleId       int       `gorm:"type:int" json:"lampPoleId"`                //所属灯杆 灯杆ID
-	LampPoleName     string    `gorm:"type:varchar(64)" json:"lampPoleName"`      //灯杆名称
-	LampPoleSn       string    `gorm:"type:varchar(64)" json:"lampPoleSn"`        //灯杆编码
-	LampPoleLocation string    `gorm:"type:varchar(255)" json:"lampPoleLocation"` //灯杆安装位置
-	PoleLng          float64   `gorm:"type:double(17, 14) " json:"poleLng"`       //经度
-	PoleLat          float64   `gorm:"type:double(17, 14)  " json:"poleLat"`      //纬度
-	Numeration       int       `gorm:"type:int" json:"numeration"`                //编号
-	ServeId          int       `gorm:"type:int" json:"serveId"`                   //所属服务ID
-	IPAddress        string    `gorm:"type:varchar(50)" json:"ipAddress"`         //IP地址
-	InstallTime      time.Time `gorm:"type:date" json:"installTime"`              //安装时间
-	TenantId         string    `gorm:"type:varchar(12)" json:"tenantId"`          //租户id
-	CreateTime       time.Time `gorm:"type:datetime" json:"createTime"`           //新增时间
-	CreateUser       int       `gorm:"type:int" json:"createUser"`                //新增记录操作用户ID
-	UpdateTime       time.Time `gorm:"type:datetime" json:"updateTime"`           //修改时间
-	UpdateUser       int       `gorm:"type:int" json:"updateUser"`                //修改用户
-	IsDeleted        int       `gorm:"type:int" json:"isDeleted"`                 //是否删除 0=未删除,1=删除
-	Status           int       `gorm:"type:int  " json:"status"`                  //告警状态 1处理完成2待处理3无需处理
-	Tag              string    `gorm:"type:varchar(255)" json:"tag"`              //标签,(备用,逗号区分)
-}
-
-func (AlarmTerminal) TableName() string {
-	return "device_a_key_alarm_terminal"
-}
-
-func (c AlarmTerminal) Delete() error {
-	return Db.Model(&c).Where("id = ?", c.ID).Updates(map[string]interface{}{"update_time": c.UpdateTime,
-		"update_user": c.UpdateUser, "is_deleted": c.IsDeleted}).Error
-}
-
-func (c AlarmTerminal) IsExistedBySN() bool {
-	var count int64
-	_ = Db.Model(&c).Where("  terminal_sn = ? and is_deleted = ?",
-		c.TerminalSN, c.IsDeleted).Count(&count).Error
-	return count > 0
-}
-
-func (c AlarmTerminal) IsExistedByNameAndCode() bool {
-	var devices []AlarmTerminal
-	err := Db.Model(&c).Where(" terminal_sn = ? and is_deleted = ?",
-		c.TerminalSN, c.IsDeleted).Find(&devices).Error
-	//如果查询不到,返回相应的错误
-	if gorm.ErrRecordNotFound == err {
-		return false
-	}
-	for _, d := range devices {
-		if d.ID != c.ID {
-			return true
-		}
-	}
-	return false
-}
-
-func (c *AlarmTerminal) Create() error {
-	return Db.Model(&c).Save(&c).Error
-}
-
-func (c *AlarmTerminal) Update() error {
-	return Db.Model(&c).Where(" id = ? ", c.ID).Updates(&c).Error
-}
-
-func (c *AlarmTerminal) GetDevice() error {
-	err := Db.Model(&c).Where(" id = ? ", c.ID).Scan(&c).Error
-	return err
-}
-
-func (c AlarmTerminal) GetDevices(offset, limit int) ([]AlarmTerminal, int64, error) {
-	var devices []AlarmTerminal
-	var count int64
-	db := Db.Model(&c).Where(" terminal_name like ? and is_deleted = 0", "%"+c.TerminalName+"%")
-	db.Count(&count)
-	err := db.Offset(offset).Limit(limit).Find(&devices).Error
-	return devices, count, err
-}
-
-func (c AlarmTerminal) GetAllDevices() ([]*AlarmTerminal, error) {
-	var devices []*AlarmTerminal
-	err := Db.Model(&c).Where(" tenant_id = ? and is_deleted = ? ", c.TenantId, c.IsDeleted).Scan(&devices).Error
-	return devices, err
-}
-
-func (c AlarmTerminal) GetDevicesByGateway() []AlarmTerminal {
-	var devices []AlarmTerminal
-	Db.Model(&c).Where(" gateway_id = ? and is_deleted = 0",
-		c.GatewayId).Find(&devices)
-	return devices
-}
-
-func (c AlarmTerminal) GetDevicesByLampPole() []AlarmTerminal {
-	var devices []AlarmTerminal
-	Db.Model(&c).Where("lamp_pole_id = ? and is_deleted = 0",
-		c.LampPoleId).Find(&devices)
-	return devices
-}
-
-func (c AlarmTerminal) GetTerminalCount(serverId int) int64 {
-	var count int64
-	Db.Model(&c).Where("serve_id = ? and is_deleted = 0",
-		serverId).Count(&count)
-	return count
-}
-
-func (c AlarmTerminal) DeviceCount1() (int64, int64) {
-	var all, fault int64
-	err := Db.Model(&c).Where("is_deleted = 0").Count(&all).Error
-	if err != nil {
-		all = -1
-	}
-	err = Db.Model(&c).Where("is_deleted = 0 and status = 0").Count(&fault).Error
-	if err != nil {
-		fault = -1
-	}
-	return all, fault
-}
-
-func (c AlarmTerminal) ListDevices1() []Device {
-	var devices []AlarmTerminal
-	Db.Model(&c).Where("is_deleted = 0").Find(&devices)
-	var rsp = make([]Device, 0, len(devices))
-	for _, v := range devices {
-		var d = Device{
-			Lng:          v.PoleLng,
-			Lat:          v.PoleLat,
-			Status:       v.Status,
-			Name:         v.TerminalName,
-			Code:         v.TerminalSN,
-			LampPoleName: v.LampPoleName,
-		}
-		rsp = append(rsp, d)
-	}
-	return rsp
-}

+ 0 - 178
app/device/dao/bigModel.go

@@ -1,178 +0,0 @@
-package dao
-
-import (
-	"time"
-)
-
-type QueryDevices struct {
-	//countNum:灯杆总数,
-	//faultNum:灯杆报警数,
-	CountNum int64    `json:"countNum"`
-	FaultNum int64    `json:"faultNum"`
-	Devices  []Device `json:"list"`
-}
-
-type Device struct {
-	//lng经度,lat纬度,status:状态,name:名字,code:编码,lampPoleName:灯杆名,brand:品牌,model:型号,linkNum:连接设备数,
-	Lng          float64 `json:"lng"`
-	Lat          float64 `json:"lat"`
-	Status       int     `json:"status"`
-	Name         string  `json:"name"`
-	Code         string  `json:"code"`
-	LampPoleName string  `json:"lampPoleName"`
-	Model        string  `json:"model"`
-	LinkNum      int64   `json:"linkNum"`
-}
-
-type TotalLamp struct {
-	CountNum int64 `json:"countNum"`
-	FaultNum int64 `json:"faultNum"`
-}
-
-type ConfigInfo struct {
-	Id        int64  `json:"id"`
-	SiteValue string `json:"siteValue"`
-}
-
-// url: '/api/longchi/largescreen/overview/device-status',
-type DeviceStatus struct {
-	DeviceType string `json:"deviceType"`
-	CountNum   int64  `json:"countNum"`
-	FaultNum   int64  `json:"faultNum"`
-}
-
-func (d *DeviceStatus) Set(n, m int64) {
-	d.CountNum = n
-	d.FaultNum = m
-}
-
-// /api/longchi/largescreen/overview/energy-consumption
-type Energy struct {
-	Date       string  `json:"date"`
-	Difference float64 `json:"difference"`
-}
-type LightRate struct {
-	Data []interface{}
-}
-
-// LightRate 亮灯率:  /api/longchi/largescreen/overview/lighting-rate
-type LightRateM struct {
-	Month string  `json:"month"`
-	Rate  float64 `json:"rate"`
-}
-type LightRateQ struct {
-	Quarter string  `json:"quarter"`
-	Rate    float64 `json:"rate"`
-}
-type LightRateY struct {
-	Year string  `json:"year"`
-	Rate float64 `json:"rate"`
-}
-
-// AlarmInfo http://localhost/api/longchi/largescreen/overview/alarm-information
-type AlarmList struct {
-	Backlog        int64       `json:"backlog"`
-	LastMonthAlarm int64       `json:"lastMonthAlarm"`
-	LastYearAlarm  int64       `json:"lastYearAlarm"`
-	List           []AlarmInfo `json:"list"`
-}
-
-type AlarmInfo struct {
-	ArmContent        string         `gorm:"arm_content" json:"armContent"`
-	ArmDeviceTypeName string         `gorm:"arm_device_type_name" json:"armDeviceTypeName"`
-	ArmLevelName      string         `gorm:"level_name" json:"armLevelName"`
-	CreateTime        DateTimeString `gorm:"arm_time" json:"createTime"`
-}
-type DateTimeString time.Time
-
-const DateTimeFormatCN = "2006-01-02 15:04:05"
-
-func (t *DateTimeString) UnmarshalJSON(data []byte) (err error) {
-	now, err := time.ParseInLocation(`"`+DateTimeFormatCN+`"`, string(data), time.Local)
-	*t = DateTimeString(now)
-	return
-}
-
-func (t *DateTimeString) MarshalJSON() ([]byte, error) {
-	b := make([]byte, 0, len(DateTimeFormatCN)+2)
-	b = append(b, '"')
-	b = time.Time(*t).AppendFormat(b, DateTimeFormatCN)
-	b = append(b, '"')
-	return b, nil
-}
-func (t *DateTimeString) String() string {
-	return time.Time(*t).Format(DateTimeFormatCN)
-}
-
-// lastYearJob,本月已处理lastMonthJob,待处理backJob,list{type,name,createTime})
-type FlowList struct {
-	LastYearJob  int64      `json:"lastYearJob"`
-	LastMonthJob int64      `json:"lastMonthJob"`
-	List         []FlowInfo `json:"list"`
-}
-type FlowInfo struct {
-	Name       string    `json:"name"`
-	CreateTime time.Time `json:"createTime"`
-}
-
-// /setting/query-large-screen
-type ScreenSet struct {
-	SiteValue string
-}
-
-// 环境监测http://localhost/api/longchi/largescreen/overview/weather-now?id=1
-type Environment struct {
-	//AirIndex         int64
-	Air float64 `json:"airQuality"`
-	//LampPoleLocation string    `json:"lampPoleLocation"`
-	CreateDate    string  `json:"endLineTime"`
-	Temperature   float64 `json:"realTimeTemperature"`
-	Humidity      float64 `json:"humidity"`
-	Pm25          float64 `json:"pm25"`
-	Pm10          float64 `json:"pm10"`
-	Noise         float64 `json:"noise"`
-	Hpa           float64 `json:"pressure"` //气压
-	WindDirection string  `json:"direction"`
-	WindSpeed     float64 `json:"realTimeWindSpeed"` //风力等级
-}
-
-// 信息屏
-
-type InfoBoardProgram struct {
-	Id             int64      `json:"id"`
-	Name           string     `json:"name"`           //节目名字
-	Duration       int64      `json:"duration"`       //播放时长
-	Count          int64      `json:"countDeviceNum"` //关联设备
-	ResolutionName string     `json:"resolutionName"` //分辨率
-	EndTime        DateString `json:"endTime"`        //结束时间
-}
-type Program struct {
-	Id      int64  `json:"id"`
-	SendUrl string `json:"sendUrl"`
-}
-
-type DateString time.Time
-
-const TimeFormatCN = "2006-01-02"
-
-func (t *DateString) UnmarshalJSON(data []byte) (err error) {
-	now, err := time.ParseInLocation(`"`+TimeFormatCN+`"`, string(data), time.Local)
-	*t = DateString(now)
-	return
-}
-
-func (t *DateString) MarshalJSON() ([]byte, error) {
-	b := make([]byte, 0, len(TimeFormatCN)+2)
-	b = append(b, '"')
-	b = time.Time(*t).AppendFormat(b, TimeFormatCN)
-	b = append(b, '"')
-	return b, nil
-}
-func (t *DateString) String() string {
-	return time.Time(*t).Format(TimeFormatCN)
-}
-
-type Sensor struct {
-	Id   int64  `json:"id"`
-	Name string `json:"name"`
-}

+ 0 - 158
app/device/dao/bigScreen.go

@@ -1,158 +0,0 @@
-package dao
-
-import (
-	"iot_manager_service/util/logger"
-)
-
-type Big interface {
-	ListDevices() ([]Device, int64, error)
-	CountFault() (int64, error)
-}
-
-func getLinkNum(sn string) int64 {
-	var i int64
-	//SELECT total FROM device_wisdom_gateway a LEFT JOIN device_gateway_relation b ON a.id = b.id
-	//WHERE a.lamp_pole_sn='ZHDG4306268O408R' ORDER BY total DESC LIMIT 1;
-	Db.Select("total").Table("device_wisdom_gateway a").
-		Joins("LEFT JOIN device_gateway_relation b ON a.id = b.id").
-		Where("a.lamp_pole_sn = ?", sn).
-		Order("total DESC").Limit(1).Find(&i)
-	return i
-}
-
-func GetEnergy(start, end string) []Energy {
-	var rsp = make([]Energy, 0, 12)
-	//select  SUBSTR(date FROM 1 FOR 7) AS date1,SUM(difference) AS difference
-	//FROM `t_device_energy_day_data` t WHERE date BETWEEN "2023-04-01" AND "2023-06-01" GROUP BY date1;
-	rows, err := Db.Select("SUBSTR(date FROM 1 FOR 7) AS dates,SUM(difference) AS difference").
-		Table("`t_device_energy_day_data`").Where("date BETWEEN ? AND ?", start, end).Group("dates").Rows()
-	defer rows.Close()
-	if err != nil {
-		logger.Logger.Errorf("GetEnergy error: %v", err)
-	}
-	for rows.Next() {
-		var e Energy
-		rows.Scan(&e.Date, &e.Difference)
-		rsp = append(rsp, e)
-	}
-	return rsp
-}
-
-// GetLightRate
-// SELECT DATE_FORMAT(NOW(),'%Y-%m') AS month, AVG(rate) AS rate FROM `t_lamp_lighting_rate_day_data` WHERE SUBSTR(date FROM 1 FOR 7) = DATE_FORMAT(NOW(),'%Y-%m') AND tenant = '000000';
-// SELECT QUARTER(NOW()) AS quarter, AVG(rate) AS rate FROM `t_lamp_lighting_rate_day_data` WHERE QUARTER(date) = QUARTER(NOW()) AND tenant = '000000';
-// SELECT YEAR(NOW()) AS year, AVG(rate) AS rate FROM `t_lamp_lighting_rate_day_data` WHERE YEAR(date) = YEAR(NOW()) AND tenant = '000000';
-func GetLightRate(tenant string) []interface{} {
-	var rsp = make([]interface{}, 0, 4)
-	var lrm LightRateM
-	var lrq LightRateQ
-	var lry LightRateY
-	Db.Select("DATE_FORMAT(NOW(),'%Y-%m') AS month,ROUND(AVG(rate),2) AS rate").Table("`t_lamp_lighting_rate_day_data`").
-		Where("SUBSTR(date FROM 1 FOR 7) = DATE_FORMAT(NOW(),'%Y-%m') And tenant = ?", tenant).Find(&lrm)
-	Db.Select("QUARTER(NOW()) AS quarter, ROUND(AVG(rate),2) AS rate").Table("`t_lamp_lighting_rate_day_data`").
-		Where("quarter(date) = quarter(NOW()) AND tenant = ?", tenant).Find(&lrq)
-	Db.Select("YEAR(NOW()) AS year, ROUND(AVG(rate),2) AS rate").Table("`t_lamp_lighting_rate_day_data`").
-		Where("YEAR(date) = YEAR(NOW()) AND tenant = ?", tenant).Find(&lry)
-	//lr[0].Month = ""
-	rsp = append(rsp, []interface{}{})
-	rsp = append(rsp, lrm)
-	rsp = append(rsp, lrq)
-	rsp = append(rsp, lry)
-	return rsp
-}
-
-// GetAlarmInfo 1待处理2忽略3已处理4其他
-// #待处理
-// SELECT COUNT(id) FROM `warn_platform_alarm` WHERE arm_handle = 1;
-// SELECT arm_content,arm_device_type_name,dict_value AS level_name,arm_time
-// FROM `warn_platform_alarm` w JOIN `dict` d
-// ON w.arm_level = d.dict_key
-// WHERE w.arm_handle = 1 AND d.`code` = 'arm_level_type'
-// LIMIT 10;
-// #本月已处理
-// SELECT COUNT(id) FROM `warn_platform_alarm` WHERE SUBSTR(arm_end_time FROM 1 FOR 7)=SUBSTR(NOW() FROM 1 FOR 7) AND arm_handle = 3;
-// #本年已处理
-// SELECT COUNT(id) FROM `warn_platform_alarm` WHERE YEAR(arm_end_time)=YEAR(NOW()) AND arm_handle = 3;
-func GetAlarmInfo() AlarmList {
-	var al AlarmList
-	Db.Select("COUNT(id)").Table("`warn_platform_alarm`").
-		Where("arm_handle = 1").Find(&al.Backlog)
-	Db.Select("COUNT(id)").Table("`warn_platform_alarm`").
-		Where("SUBSTR(arm_end_time FROM 1 FOR 7)=SUBSTR(NOW() FROM 1 FOR 7) AND arm_handle = 3").Find(&al.LastMonthAlarm)
-	Db.Select("COUNT(id)").Table("`warn_platform_alarm`").
-		Where("YEAR(arm_end_time)=YEAR(NOW()) AND arm_handle = 3").Find(&al.LastYearAlarm)
-	Db.Select("arm_content,arm_device_type_name,dict_value AS arm_level_name,arm_time AS create_time").
-		Table("`warn_platform_alarm` AS w JOIN `dict` AS d ON w.arm_level = d.dict_key").
-		Where("w.arm_handle = 1 AND d.`code` = 'arm_level_type'").Order("create_time DESC").Limit(7).Find(&al.List)
-	return al
-}
-
-type OverView struct {
-	Id        int64  `gorm:"primary_key" json:"id"`
-	TenantId  string `json:"tenantId"`
-	PadScreen string `json:"padScreen"`
-	Site      string `json:"site"`
-	SiteValue int64  `json:"siteValue"`
-}
-
-func (o *OverView) TableName() string {
-	return "big_screen_overview"
-}
-
-type OverViewInfo struct {
-	Id        int64 `gorm:"primary_key" json:"id"`
-	SiteValue int64 `json:"siteValue"`
-}
-
-func (o *OverView) Query(tenantId, padScreen string) []OverViewInfo {
-	var rsp []OverViewInfo
-	Db.Select("id, site_value").Table(o.TableName()).Where("tenant_id = ? AND pad_screen = ?", tenantId, padScreen).Find(&rsp)
-	return rsp
-}
-func (o *OverView) Submit(data OverView) {
-	Db.Model(&o).Select("pad_screen", "site_value").Where("id=?", data.Id).Updates(&data)
-}
-
-func GetEnvData(id string) Environment {
-	var env Environment
-	//"lampPoleLocation"
-	Db.Select("air, create_date, temperature, humidity, pm25, pm10, noise, hpa, wind_direction, wind_speed").
-		Table("data_environment").Where("device_id=?", id).
-		Order("create_date DESC").Limit(1).Find(&env)
-	return env
-}
-
-// GetLEDProgramList
-// SELECT m.id,m.name,m.duration,d.dict_value, end_time
-// FROM `media_publish_libraries` m JOIN `dict` d
-// ON dict_key = m.resolution
-// WHERE m.tenant_id = '000000' and m.sys_type=0 and m.is_deleted = 0 AND d.code = 'resolution_type'
-// ORDER BY id desc LIMIT 10
-func GetLEDProgramList(tenantId string) []InfoBoardProgram {
-	var list []InfoBoardProgram
-	Db.Select("m.id,m.name,m.duration,d.dict_value AS resolution_name, end_time ,(LENGTH(info_id) - LENGTH(REPLACE(info_id, ',', '')) + 1) AS count").
-		Table("`media_publish_libraries` m JOIN `dict` d ON dict_key = m.resolution").
-		Where("d.code='resolution_type' AND m.sys_type=0 AND m.is_deleted=0 AND m.tenant_id=?", tenantId).
-		Order("id DESC").Limit(10).Find(&list)
-	return list
-}
-
-func GetProgramUrl(id string) Program {
-	var rsp Program
-	//SELECT name FROM `media_publish_libraries` WHERE id = 45
-	t1 := Db.Select("name").Table("media_publish_libraries").Where("id=(?)", id)
-	//SELECT id FROM `media_program` WHERE name =?
-	t2 := Db.Select("id").Table("media_program").Where("name=(?)", t1)
-	//SELECT library_id FROM media_program_relation WHERE program_id = ?
-	t3 := Db.Select("library_id").Table("media_program_relation").Where("program_id=(?)", t2)
-	//SELECT material_address FROM `media_library` WHERE id =?
-	Db.Select("material_address AS send_url").Table("media_library").Where("id =(?)", t3).Find(&rsp)
-	return rsp
-}
-
-func GetBridgeSensors(tenantId string) []Sensor {
-	var rsp []Sensor
-	//SELECT id,name FROM `device_bridge_sensor` WHERE tenant_id = '000000' AND is_deleted = 0
-	Db.Select("id,name").Table("device_bridge_sensor").Where("tenant_id = ? AND is_deleted = 0", tenantId).Find(&rsp)
-	return rsp
-}

+ 0 - 131
app/device/dao/bridgeDao.go

@@ -1,131 +0,0 @@
-package dao
-
-import (
-	"gorm.io/gorm"
-	"time"
-)
-
-type Bridge struct {
-	ID                int       `gorm:"primary_key" json:"id"`                      //编号
-	Name              string    `gorm:"type:varchar(64)" json:"name"`               //名称
-	SN                string    `gorm:"type:varchar(60)" json:"sn"`                 //唯一编码
-	Lng               float64   `gorm:"type:double(17, 14)" json:"lng"`             //经度
-	Lat               float64   `gorm:"type:double(17, 14)" json:"lat"`             //纬度
-	ProvinceName      string    `gorm:"type:varchar(60)" json:"provinceName"`       //省份
-	CityName          string    `gorm:"type:varchar(60)" json:"cityName"`           //市
-	DistrictName      string    `gorm:"type:varchar(60)" json:"districtName"`       //区
-	InstallPosition   string    `gorm:"type:varchar(100)" json:"installLocation"`   //位置
-	PurposeType       int       `gorm:"type:int" json:"purposeType"`                //用途类型
-	StraddlesType     int       `gorm:"type:int" json:"straddlesType"`              //跨越类型
-	StuffType         int       `gorm:"type:int" json:"stuffType"`                  //材料类型
-	StructureType     int       `gorm:"type:int" json:"structureType"`              //结构类型
-	TechniqueGrade    int       `gorm:"type:int" json:"techniqueGrade"`             //技术等级
-	CompletionTime    string    `gorm:"type:date" json:"completionTime"`            //建成时间
-	Length            int       `gorm:"type:int" json:"length"`                     //长度
-	Width             int       `gorm:"type:int" json:"width"`                      //宽度
-	Height            int       `gorm:"type:int" json:"height"`                     //高度
-	TrafficNum        int       `gorm:"type:int" json:"trafficNum"`                 //车道数
-	IsOpenTraffic     int       `gorm:"type:int" json:"isOpenTraffic"`              //是否已通车
-	DesignSpeed       int       `gorm:"type:int" json:"designSpeed"`                //设计时速
-	BriefIntroduction string    `gorm:"type:varchar(255)" json:"briefIntroduction"` //简介
-	Photo             string    `gorm:"type:varchar(255)" json:"photo"`             //照片
-	TenantId          string    `gorm:"type:varchar(12)" json:"tenantId"`           //租户id
-	CreateTime        time.Time `gorm:"type:datetime" json:"createTime"`            //新增时间
-	CreateUser        int       `gorm:"type:int" json:"createUser"`                 //新增记录操作用户ID
-	UpdateTime        time.Time `gorm:"type:datetime" json:"updateTime"`            //修改时间
-	UpdateUser        int       `gorm:"type:int" json:"updateUser"`                 //修改用户
-	IsDeleted         int       `gorm:"type:int;default 0" json:"isDeleted"`        //是否删除 0=未删除,1=删除
-	Status            int       `gorm:"type:int" json:"status"`                     //状态 0=正常,1=异常
-}
-
-func (Bridge) TableName() string {
-	return "device_bridge"
-}
-
-func (c Bridge) Delete() error {
-	return Db.Model(&c).Where("id = ?", c.ID).Updates(map[string]interface{}{"update_time": c.UpdateTime,
-		"update_user": c.UpdateUser, "is_deleted": c.IsDeleted}).Error
-}
-
-func (c Bridge) IsExistedBySN() bool {
-	var count int64
-	_ = Db.Model(&c).Where("  tsn = ? and is_deleted = ?",
-		c.SN, c.IsDeleted).Count(&count).Error
-	return count > 0
-}
-
-func (c Bridge) IsExistedByNameAndCode() bool {
-	var devices []Bridge
-	err := Db.Model(&c).Where(" sn = ? and is_deleted = ?",
-		c.SN, c.IsDeleted).Find(&devices).Error
-	//如果查询不到,返回相应的错误
-	if gorm.ErrRecordNotFound == err {
-		return false
-	}
-	for _, d := range devices {
-		if d.ID != c.ID {
-			return true
-		}
-	}
-	return false
-}
-
-func (c *Bridge) Create() error {
-	return Db.Model(&c).Save(&c).Error
-}
-
-func (c *Bridge) Update() error {
-	return Db.Model(&c).Where(" id = ? ", c.ID).Updates(&c).Error
-}
-
-func (c *Bridge) GetDevice() error {
-	err := Db.Model(&c).Where(" id = ? ", c.ID).Scan(&c).Error
-	return err
-}
-
-func (c Bridge) GetDevices(offset, limit int) ([]Bridge, int64, error) {
-	var devices []Bridge
-	var count int64
-	db := Db.Model(&c).Where(" name like ? and is_deleted = 0", "%"+c.Name+"%")
-	db.Count(&count)
-	err := db.Offset(offset).Limit(limit).Find(&devices).Error
-	return devices, count, err
-}
-
-func (c Bridge) GetAllDevices() ([]*Bridge, error) {
-	var devices []*Bridge
-	err := Db.Model(&c).Where(" tenant_id = ? and is_deleted = ? ", c.TenantId, c.IsDeleted).Scan(&devices).Error
-	return devices, err
-}
-
-func (c Bridge) DeviceCount1() (int64, int64) {
-	var all, fault int64
-	err := Db.Model(&c).Where("is_deleted = 0").Count(&all).Error
-	if err != nil {
-		all = -1
-	}
-	err = Db.Model(&c).Where("is_deleted = 0 and status = 0").Count(&fault).Error
-	if err != nil {
-		fault = -1
-	}
-	return all, fault
-}
-
-func (c Bridge) ListDevices1() []Device {
-	var devices []Bridge
-	Db.Model(&c).Where("is_deleted = 0").Find(&devices)
-	var rsp = make([]Device, 0, len(devices))
-	for _, v := range devices {
-		var d = Device{
-			Lng:          v.Lng,
-			Lat:          v.Lat,
-			Status:       v.Status,
-			Name:         v.Name,
-			Code:         v.SN,
-			LampPoleName: v.DistrictName,
-			Model:        "模型",
-		}
-		rsp = append(rsp, d)
-	}
-	return rsp
-}

+ 0 - 95
app/device/dao/bridgeSensorDao.go

@@ -1,95 +0,0 @@
-package dao
-
-import (
-	"gorm.io/gorm"
-	"time"
-)
-
-type BridgeSensor struct {
-	ID               int        `gorm:"primary_key" json:"id"`                    //编号
-	SensorType       int        `gorm:"type:int" json:"sensorType"`               //传感器类型
-	Name             string     `gorm:"type:varchar(64)" json:"name"`             //名称
-	SN               string     `gorm:"type:varchar(60)" json:"sn"`               //唯一编码
-	BrandID          int        `gorm:"type:int" json:"brandID"`                  //设备名称
-	ModelID          int        `gorm:"type:int" json:"modelID"`                  //设备型号
-	BridgeId         int        `gorm:"type:int" json:"bridgeId"`                 //所属桥梁id
-	BridgeSn         string     `gorm:"type:varchar(60)" json:"bridgeSn"`         //所属桥梁编码
-	GatewayId        int        `gorm:"type:int" json:"gatewayId"`                //所属网关id
-	GatewaySN        string     `gorm:"type:varchar(60)" json:"gatewaySn"`        //所属网关编码
-	InstallPosition  string     `gorm:"type:varchar(100)" json:"installPosition"` //安装位置
-	InstallTime      *time.Time `gorm:"type:date" json:"installTime"`             //安装时间
-	IPAddress        string     `gorm:"type:varchar(64)" json:"ipAddress"`        //IP地址-备用
-	TenantID         string     `gorm:"type:varchar(12)" json:"tenantID"`         //租户id
-	CreateTime       time.Time  `gorm:"type:datetime" json:"createTime"`          //新增时间
-	CreateUser       int        `gorm:"type:int" json:"createUser"`               //新增记录操作用户ID
-	UpdateTime       time.Time  `gorm:"type:datetime" json:"updateTime"`          //修改时间
-	UpdateUser       int        `gorm:"type:int" json:"updateUser"`               //修改用户
-	IsDeleted        int        `gorm:"type:int;default 0" json:"isDeleted"`      //是否删除 0=未删除,1=删除
-	Status           int        `gorm:"type:int" json:"status"`                   //状态 0=正常,1=异常
-	IsEnable         int        `gorm:"type:tinyint; default 1" json:"isEnable"`  //启用禁用:1启用,2禁用
-	TerrainClearance float32    `gorm:"double(4, 2)" json:"terrainClearance"`     //状态 0=正常,1=异常
-}
-
-func (BridgeSensor) TableName() string {
-	return "device_bridge_sensor"
-}
-
-func (c BridgeSensor) Delete() error {
-	return Db.Model(&c).Where("id = ?", c.ID).Updates(map[string]interface{}{"update_time": c.UpdateTime,
-		"update_user": c.UpdateUser, "is_deleted": c.IsDeleted}).Error
-}
-
-func (c BridgeSensor) IsExistedBySN() bool {
-	var count int64
-	_ = Db.Model(&c).Where("  tsn = ? and is_deleted = ?",
-		c.SN, c.IsDeleted).Count(&count).Error
-	return count > 0
-}
-
-func (c BridgeSensor) IsExistedByNameAndCode() bool {
-	var devices []BridgeSensor
-	err := Db.Model(&c).Where(" sn = ? and is_deleted = ?",
-		c.SN, c.IsDeleted).Find(&devices).Error
-	//如果查询不到,返回相应的错误
-	if gorm.ErrRecordNotFound == err {
-		return false
-	}
-	for _, d := range devices {
-		if d.ID != c.ID {
-			return true
-		}
-	}
-	return false
-}
-
-func (c *BridgeSensor) Create() error {
-	return Db.Model(&c).Save(&c).Error
-}
-
-func (c *BridgeSensor) Update() error {
-	return Db.Model(&c).Where(" id = ? ", c.ID).Updates(&c).Error
-}
-
-func (c *BridgeSensor) GetDevice() error {
-	err := Db.Model(&c).Where(" id = ? ", c.ID).Scan(&c).Error
-	return err
-}
-
-func (c BridgeSensor) GetDevices(offset, limit int) ([]BridgeSensor, int64, error) {
-	var devices []BridgeSensor
-	var count int64
-	db := Db.Model(&c).Where(" name like ? and is_deleted = 0", "%"+c.Name+"%")
-	db.Count(&count)
-	err := db.Offset(offset).Limit(limit).Find(&devices).Error
-	return devices, count, err
-}
-
-func (c BridgeSensor) GetAllDevices() ([]*BridgeSensor, error) {
-	var devices []*BridgeSensor
-	err := Db.Model(&c).Where(" tenant_id = ? and is_deleted = ? ", c.TenantID, c.IsDeleted).Scan(&devices).Error
-	return devices, err
-}
-
-func (c *BridgeSensor) UpdateEnable() error {
-	return Db.Model(&c).Where(" id = ? ", c.ID).Updates(map[string]interface{}{"is_enable": c.IsEnable}).Error
-}

+ 0 - 155
app/device/dao/cameraDao.go

@@ -1,155 +0,0 @@
-package dao
-
-import (
-	"iot_manager_service/util/common"
-	"time"
-)
-
-// CameraDevice 网关下挂载的设备, 摄像头
-type CameraDevice struct {
-	ID               int         `gorm:"primary_key" json:"id"`                          //编号
-	DeviceName       string      `gorm:"type:varchar(64)" json:"deviceName"`             //设备名称
-	DeviceSN         string      `gorm:"type:varchar(64)" json:"deviceSn"`               //设备序列号
-	CameraType       int         `gorm:"type:int" json:"cameraType"`                     //摄像机类型 0=枪机,1=球机
-	GatewayId        int         `gorm:"type:int" json:"gatewayId"`                      //所属网关
-	LampPoleId       int         `gorm:"type:int" json:"lampPoleId"`                     //归属灯杆 灯杆ID
-	LampPoleName     string      `gorm:"type:varchar(64)" json:"lampPoleName"`           //灯杆名称
-	LampPoleSn       string      `gorm:"type:varchar(64)" json:"lampPoleSn"`             //灯杆sn
-	LampPoleLocation string      `gorm:"type:varchar(255)" json:"lampPoleLocation"`      //灯杆安装位置
-	LampLat          float64     `gorm:"type:double(17,14)" json:"lampLat"`              //经度
-	LampLng          float64     `gorm:"type:double(17,14)" json:"lampLng"`              //纬度
-	GroupId          int         `gorm:"type:int" json:"groupId"`                        //灯杆分组ID
-	BrandId          int         `gorm:"type:int" json:"brandId"`                        //设备品牌
-	ModelId          int         `gorm:"type:int" json:"modelId"`                        //设备型号
-	RatedPower       float32     `gorm:"type:float(8,2);default 0.00" json:"ratedPower"` //功率
-	MonitorAddress   string      `gorm:"type:varchar(255)" json:"monitorAddress"`        //监控地址 ip:端口
-	IPAddress        string      `gorm:"type:varchar(40)" json:"ipAddress"`              //IP地址
-	InstallTime      common.Time `gorm:"type:date" json:"installTime"`                   //安装时间
-	TenantId         string      `gorm:"type:varchar(12)" json:"tenantId"`               //租户ID
-	CreateTime       time.Time   `gorm:"type:datetime" json:"createTime"`                //新增时间
-	CreateUser       int         `gorm:"type:int" json:"createUser"`                     //新增记录操作用户ID
-	UpdateTime       time.Time   `gorm:"type:datetime" json:"updateTime"`                //修改时间
-	UpdateUser       int         `gorm:"type:int" json:"updateUser"`                     //修改用户
-	IsDeleted        int         `gorm:"type:int;default 0" json:"isDeleted"`            //是否删除 0=未删除,1=删除
-	Status           int         `gorm:"type:int" json:"status"`                         //状态 0=正常,1=异常
-	Tag              string      `gorm:"type:varchar(255)" json:"tag"`                   //标签,(备用,逗号区分)
-	IsEnable         int         `gorm:"type:int;default 2" json:"isEnable"`             //启用禁用:1启用,2禁用
-	StreamId         string      `gorm:"type:varchar(100)" json:"streamId"`              //流id
-}
-
-func (CameraDevice) TableName() string {
-	return "device_camera"
-}
-
-func (c CameraDevice) IsExistedBySN() bool {
-	var count int64
-	_ = Db.Model(&c).Where("device_sn = ? and is_deleted = ?",
-		c.DeviceSN, c.IsDeleted).Count(&count).Error
-	return count > 0
-}
-
-func (c *CameraDevice) Create() error {
-	return Db.Model(&c).Save(&c).Error
-}
-
-func (c *CameraDevice) Update() error {
-	return Db.Model(&c).Where(" id = ? ", c.ID).Updates(&c).Error
-}
-
-func (c *CameraDevice) GetDevice() error {
-	err := Db.Model(&c).Where(" id = ? ", c.ID).First(&c).Error
-	return err
-}
-
-func (c CameraDevice) GetDevices(offset, limit int) ([]CameraDevice, int64, error) {
-	var devices []CameraDevice
-	var count int64
-	db := Db.Model(&c)
-	if c.DeviceSN != "" {
-		db = db.Where("device_name like ? or device_sn like ?", "%"+c.DeviceSN+"%", "%"+c.DeviceSN+"%")
-	}
-	if c.CameraType != -1 {
-		db = db.Where("camera_type = ?", c.CameraType)
-	}
-
-	db = db.Where("is_deleted = 0")
-	db.Count(&count)
-	err := db.Offset(offset).Limit(limit).Find(&devices).Error
-	return devices, count, err
-}
-
-func (c *CameraDevice) Delete() error {
-	return Db.Model(&c).Where("id = ?", c.ID).Updates(map[string]interface{}{"update_time": c.UpdateTime,
-		"update_user": c.UpdateUser, "is_deleted": c.IsDeleted}).Error
-}
-
-func (c CameraDevice) GetAllDevices() ([]*CameraDevice, error) {
-	var devices []*CameraDevice
-	err := Db.Model(&c).Where(" tenant_id = ? and is_deleted = ? ", c.TenantId, c.IsDeleted).Scan(&devices).Error
-	return devices, err
-}
-
-func (c *CameraDevice) UpdateEnable() error {
-	return Db.Model(&c).Where(" id = ? ", c.ID).Updates(map[string]interface{}{"is_enable": c.IsEnable}).Error
-}
-
-func (c CameraDevice) GetDevicesByGateway() []CameraDevice {
-	var devices []CameraDevice
-	Db.Model(&c).Where(" gateway_id = ? and is_deleted = 0",
-		c.GatewayId).Find(&devices)
-	return devices
-}
-
-func (c CameraDevice) GetDevicesByLampPole() []CameraDevice {
-	var devices []CameraDevice
-	Db.Model(&c).Where("lamp_pole_id = ? and is_deleted = 0",
-		c.LampPoleId).Find(&devices)
-	return devices
-}
-
-func (c CameraDevice) GetDevicesByLampPoleGroup() []CameraDevice {
-	var devices []CameraDevice
-	Db.Model(&c).Where("group_id = ? and is_deleted = 0",
-		c.GroupId).Find(&devices)
-	return devices
-}
-
-func (c CameraDevice) GetDevicesByIds(ids string) []CameraDevice {
-	var devices []CameraDevice
-	db := Db.Model(&c).Where("is_deleted = 0")
-	db.Where("id in (" + ids + ")")
-	db.Find(&devices)
-	return devices
-}
-
-func (c CameraDevice) DeviceCount1() (int64, int64) {
-	var all, fault int64
-	err := Db.Model(&c).Where("is_deleted = 0").Count(&all).Error
-	if err != nil {
-		all = -1
-	}
-	err = Db.Model(&c).Where("is_deleted = 0 and status = 0").Count(&fault).Error
-	if err != nil {
-		fault = -1
-	}
-	return all, fault
-}
-func (c CameraDevice) ListDevices1() []Device {
-	var devices []CameraDevice
-	Db.Model(&c).Where("is_deleted = 0").Find(&devices)
-	var rsp = make([]Device, 0, len(devices))
-	for _, v := range devices {
-		var d = Device{
-			Lng:          v.LampLng,
-			Lat:          v.LampLat,
-			Status:       v.Status,
-			Name:         v.DeviceName,
-			Code:         v.DeviceSN,
-			LampPoleName: v.LampPoleName,
-			Model:        "模型",
-			LinkNum:      getLinkNum(v.LampPoleSn),
-		}
-		rsp = append(rsp, d)
-	}
-	return rsp
-}

+ 0 - 128
app/device/dao/captureUnitDao.go

@@ -1,128 +0,0 @@
-package dao
-
-import (
-	"time"
-)
-
-// CaptureUnit 抓拍单元
-type CaptureUnit struct {
-	ID                     int       `gorm:"primary_key" json:"id"`                                //编号
-	CaptureName            string    `gorm:"type:varchar(64)" json:"captureName"`                  //设备名称
-	CaptureSn              string    `gorm:"type:varchar(60)" json:"captureSn"`                    //设备序列号
-	PointId                int       `gorm:"type:int" json:"pointId"`                              //卡口ID
-	LampPoleId             int       `gorm:"type:int" json:"lampPoleId"`                           //灯杆ID
-	WayName                string    `gorm:"type:varchar(64)" json:"wayName"`                      //道路名称
-	CaptureDirection       int       `gorm:"type:int" json:"captureDirection"`                     //灯杆sn
-	InstallTime            time.Time `gorm:"type:date" json:"installTime"`                         //安装时间
-	TerrainClearance       float32   `gorm:"type:float(10,1);default 0.0" json:"terrainClearance"` //离地高度(米)
-	CaptureLane            string    `gorm:"type:varchar(120)" json:"captureLane"`                 //抓拍车道
-	VidiconPixel           int       `gorm:"type:int" json:"vidiconPixel"`                         //相机像素
-	VidiconSpecification   string    `gorm:"type:varchar(255)" json:"vidiconSpecification"`        //相机规格
-	RadarCount             int       `gorm:"type:int" json:"radarCount"`                           //雷达数量
-	RadarSpecification     string    `gorm:"type:varchar(255)" json:"radarSpecification"`          //雷达规格
-	SuggestSpeed           int       `gorm:"type:int" json:"suggestSpeed"`                         //雷达数量
-	FillLightCount         int       `gorm:"type:int" json:"fillLightCount"`                       //补光灯数量
-	FillLightSpecification string    `gorm:"type:varchar(255)" json:"fillLightSpecification"`      //补光灯规格
-	PowerSpecification     string    `gorm:"type:varchar(255)" json:"powerSpecification"`          //电源规格
-	CaptureIp              string    `gorm:"type:varchar(60)" json:"captureIp"`                    //ip
-	CapturePort            int       `gorm:"type:int" json:"capturePort"`                          //端口
-	GatewayId              int       `gorm:"type:int" json:"gatewayId"`                            //网关ID
-	GatewayName            string    `gorm:"type:varchar(80)" json:"gatewayName"`                  //网关名称
-	GatewaySn              string    `gorm:"type:varchar(30)" json:"gatewaySn"`                    //网关编码
-	TenantId               string    `gorm:"type:varchar(12)" json:"tenantId"`                     //租户ID
-	CreateTime             time.Time `gorm:"type:datetime" json:"createTime"`                      //新增时间
-	CreateUser             int       `gorm:"type:int" json:"createUser"`                           //新增记录操作用户ID
-	UpdateTime             time.Time `gorm:"type:datetime" json:"updateTime"`                      //修改时间
-	UpdateUser             int       `gorm:"type:int" json:"updateUser"`                           //修改用户
-	IsDeleted              int       `gorm:"type:int;default 0" json:"isDeleted"`                  //是否删除 0=未删除,1=删除
-}
-
-func (CaptureUnit) TableName() string {
-	return "device_capture_unit"
-}
-
-func (c CaptureUnit) IsExistedBySN() bool {
-	var count int64
-	_ = Db.Model(&c).Where("capture_sn = ? and is_deleted = ?",
-		c.CaptureSn, c.IsDeleted).Count(&count).Error
-	return count > 0
-}
-
-func (c *CaptureUnit) Create() error {
-	return Db.Model(&c).Save(&c).Error
-}
-
-func (c *CaptureUnit) Update() error {
-	return Db.Model(&c).Where(" id = ? ", c.ID).Updates(&c).Error
-}
-
-func (c *CaptureUnit) GetDevice() error {
-	err := Db.Model(&c).Where(" id = ? ", c.ID).First(&c).Error
-	return err
-}
-
-func (c CaptureUnit) GetDevices(offset, limit int) ([]CaptureUnit, int64, error) {
-	var Captures []CaptureUnit
-	var count int64
-	db := Db.Model(&c)
-	if c.CaptureSn != "" {
-		db = db.Where("capture_name like ? or capture_sn like ?", "%"+c.CaptureSn+"%", "%"+c.CaptureSn+"%")
-	}
-
-	db = db.Where("is_deleted = 0")
-	db.Count(&count)
-	err := db.Offset(offset).Limit(limit).Find(&Captures).Error
-	return Captures, count, err
-}
-
-func (c *CaptureUnit) Delete() error {
-	return Db.Model(&c).Where("id = ?", c.ID).Updates(map[string]interface{}{"update_time": c.UpdateTime,
-		"update_user": c.UpdateUser, "is_deleted": c.IsDeleted}).Error
-}
-
-func (c CaptureUnit) GetAllDevices() ([]*CaptureUnit, error) {
-	var Captures []*CaptureUnit
-	err := Db.Model(&c).Where(" tenant_id = ? and is_deleted = ? ", c.TenantId, c.IsDeleted).Scan(&Captures).Error
-	return Captures, err
-}
-
-func (c CaptureUnit) GetDevicesByGateway() []CaptureUnit {
-	var devices []CaptureUnit
-	Db.Model(&c).Where(" gateway_id = ? and is_deleted = 0",
-		c.GatewayId).Find(&devices)
-	return devices
-}
-
-func (c CaptureUnit) GetDevicesByLampPole() []CaptureUnit {
-	var devices []CaptureUnit
-	Db.Model(&c).Where("lamp_pole_id = ? and is_deleted = 0",
-		c.LampPoleId).Find(&devices)
-	return devices
-}
-func (c CaptureUnit) DeviceCount1() (int64, int64) {
-	var all, fault int64
-	err := Db.Model(&c).Where("is_deleted = 0").Count(&all).Error
-	if err != nil {
-		all = 0
-	}
-	err = Db.Model(&c).Where("is_deleted = 0 and status = 0").Count(&fault).Error
-	if err != nil {
-		fault = 0
-	}
-	return all, fault
-}
-
-func (c CaptureUnit) ListDevices1() []Device {
-	var devices []CaptureUnit
-	Db.Model(&c).Where("is_deleted = 0").Find(&devices)
-	var rsp = make([]Device, 0, len(devices))
-	for _, v := range devices {
-		var d = Device{
-			Name:         v.CaptureName,
-			Code:         v.CaptureSn,
-			LampPoleName: v.GatewayName,
-		}
-		rsp = append(rsp, d)
-	}
-	return rsp
-}

+ 0 - 67
app/device/dao/checkPointDao.go

@@ -1,67 +0,0 @@
-package dao
-
-import (
-	"time"
-)
-
-// CheckPoint 卡口
-type CheckPoint struct {
-	ID            int       `gorm:"primary_key" json:"id"`                  //编号
-	PointName     string    `gorm:"type:varchar(64)" json:"pointName"`      //卡口名称
-	PointSN       string    `gorm:"type:varchar(60)" json:"pointSn"`        //卡口编码
-	PointLocation string    `gorm:"type:varchar(150)" json:"pointLocation"` //卡口位置
-	TenantId      string    `gorm:"type:varchar(12)" json:"tenantId"`       //租户ID
-	CreateTime    time.Time `gorm:"type:datetime" json:"createTime"`        //新增时间
-	CreateUser    int       `gorm:"type:int" json:"createUser"`             //新增记录操作用户ID
-	UpdateTime    time.Time `gorm:"type:datetime" json:"updateTime"`        //修改时间
-	UpdateUser    int       `gorm:"type:int" json:"updateUser"`             //修改用户
-	IsDeleted     int       `gorm:"type:int;default 0" json:"isDeleted"`    //是否删除 0=未删除,1=删除
-}
-
-func (CheckPoint) TableName() string {
-	return "device_check_point"
-}
-
-func (c CheckPoint) IsExistedBySN() bool {
-	var count int64
-	_ = Db.Model(&c).Where("point_sn = ? and is_deleted = ?",
-		c.PointSN, c.IsDeleted).Count(&count).Error
-	return count > 0
-}
-
-func (c *CheckPoint) Create() error {
-	return Db.Model(&c).Save(&c).Error
-}
-
-func (c *CheckPoint) Update() error {
-	return Db.Model(&c).Where(" id = ? ", c.ID).Updates(&c).Error
-}
-
-func (c *CheckPoint) GetDevice() error {
-	err := Db.Model(&c).Where(" id = ? ", c.ID).First(&c).Error
-	return err
-}
-
-func (c CheckPoint) GetDevices(offset, limit int) ([]CheckPoint, int64, error) {
-	var Points []CheckPoint
-	var count int64
-	db := Db.Model(&c)
-	if c.PointSN != "" {
-		db = db.Where("point_name like ? or point_sn like ?", "%"+c.PointSN+"%", "%"+c.PointSN+"%")
-	}
-	db = db.Where("is_deleted = 0")
-	db.Count(&count)
-	err := db.Offset(offset).Limit(limit).Find(&Points).Error
-	return Points, count, err
-}
-
-func (c *CheckPoint) Delete() error {
-	return Db.Model(&c).Where("id = ?", c.ID).Updates(map[string]interface{}{"update_time": c.UpdateTime,
-		"update_user": c.UpdateUser, "is_deleted": c.IsDeleted}).Error
-}
-
-func (c CheckPoint) GetAllDevices() ([]*CheckPoint, error) {
-	var Points []*CheckPoint
-	err := Db.Model(&c).Where(" tenant_id = ? and is_deleted = ? ", c.TenantId, c.IsDeleted).Scan(&Points).Error
-	return Points, err
-}

+ 0 - 46
app/device/dao/common.go

@@ -1,46 +0,0 @@
-package dao
-
-import (
-	"fmt"
-	"gorm.io/gorm"
-)
-
-var Db *gorm.DB
-
-func InitDB(db *gorm.DB) {
-	Db = db
-	err := Db.AutoMigrate(
-		&LampPoleGroup{},
-		&LampPole{},
-		&Gateway{},
-		&GatewayRelation{},
-		&Transformer{},
-		&LightControl{},
-		&Garbage{},
-		&GarbageWayGroup{},
-		&OnDemandGroup{},
-		&OnDemandSensor{},
-		&Zigbee{},
-		&CameraDevice{},
-		&InfoBoard{},
-		&Alarm{},
-		&CaptureUnit{},
-		&CheckPoint{},
-		&AlarmTerminal{},
-		&Bridge{},
-		&BridgeSensor{},
-		&IpBroadcast{},
-		&ManholeCover{},
-		&OptoSensor{},
-		&SwitchBox{},
-		&IntelligentLight{},
-		&TimeCondition{},
-		&LightStrategy{},
-		&LightCondition{},
-		&DeviceVendor{},
-		&TenantCode{},
-	)
-	if err != nil {
-		panic(fmt.Sprintf("AutoMigrate err : %v", err))
-	}
-}

+ 0 - 107
app/device/dao/garbageDao.go

@@ -1,107 +0,0 @@
-package dao
-
-import (
-	"gorm.io/gorm"
-	"time"
-)
-
-// Garbage 垃圾桶道路分组管理
-type Garbage struct {
-	ID              int       `gorm:"primary_key" json:"id"`                    //编号
-	DeviceName      string    `gorm:"type:varchar(64)" json:"deviceName"`       //垃圾桶名称
-	DeviceSN        string    `gorm:"type:varchar(60)" json:"deviceSn"`         //垃圾桶序列号
-	DeviceIMei      string    `gorm:"type:varchar(64)" json:"deviceIMei"`       //传感器编码-唯一不允许重复
-	KindType        int       `gorm:"type:int" json:"kindType"`                 //种类
-	Material        int       `gorm:"type:int" json:"material"`                 //材质
-	BrandId         int       `gorm:"type:int" json:"brandId"`                  //品牌
-	ModelId         int       `gorm:"type:int" json:"modelId"`                  //型号
-	GarbageOneType  int       `gorm:"type:int" json:"garbageOneType"`           //桶1类型
-	GarbageTwoType  int       `gorm:"type:int" json:"garbageTwoType"`           //桶2类型
-	GarbageHeight   int       `gorm:"type:int" json:"garbageHeight"`            //内桶高度
-	TotalHeight     int       `gorm:"type:int" json:"totalHeight"`              //传感器距离内桶高度
-	InstallTime     time.Time `gorm:"type:date" json:"installTime"`             //安装时间
-	WayID           int       `gorm:"type:int" json:"wayId"`                    //所属道路号
-	CameraID        int       `gorm:"type:int" json:"cameraId"`                 //摄像机id
-	CameraSN        string    `gorm:"type:varchar(60)" json:"cameraSn"`         //摄像机sn
-	PoleLng         float64   `gorm:"type:double(17, 14)" json:"poleLng"`       //经度
-	PoleLat         float64   `gorm:"type:double(17, 14)" json:"poleLat"`       //纬度
-	ProvinceName    string    `gorm:"type:varchar(60)" json:"provinceName"`     //省份
-	CityName        string    `gorm:"type:varchar(60)" json:"cityName"`         //市
-	DistrictName    string    `gorm:"type:varchar(60)" json:"districtName"`     //区
-	InstallLocation string    `gorm:"type:varchar(100)" json:"installLocation"` //安装位置
-	PhotoUrl        string    `gorm:"type:varchar(255)" json:"photoUrl"`        //供电箱照片地址
-	Remark          string    `gorm:"type:varchar(1000)" json:"remark"`         //备注
-	TenantId        string    `gorm:"type:varchar(12)" json:"tenantId"`         //租户id
-	CreateTime      time.Time `gorm:"type:datetime" json:"createTime"`          //新增时间
-	CreateUser      int       `gorm:"type:int" json:"createUser"`               //新增记录操作用户ID
-	UpdateTime      time.Time `gorm:"type:datetime" json:"updateTime"`          //修改时间
-	UpdateUser      int       `gorm:"type:int" json:"updateUser"`               //修改用户
-	IsDeleted       int       `gorm:"type:int;default 0" json:"isDeleted"`      //是否删除 0=未删除,1=删除
-	Threshold       int       `gorm:"type:int" json:"threshold"`                //阈值设定:告警百分比%
-}
-
-func (Garbage) TableName() string {
-	return "device_garbage"
-}
-
-func (c Garbage) Delete() error {
-	return Db.Model(&c).Where("id = ?", c.ID).Updates(map[string]interface{}{"update_time": c.UpdateTime,
-		"update_user": c.UpdateUser, "is_deleted": c.IsDeleted}).Error
-}
-
-func (c Garbage) IsExistedBySN() bool {
-	var count int64
-	_ = Db.Model(&c).Where("  device_sn = ? and is_deleted = ?",
-		c.DeviceSN, c.IsDeleted).Count(&count).Error
-	return count > 0
-}
-
-func (c Garbage) IsExistedByNameAndCode() bool {
-	var devices []Garbage
-	err := Db.Model(&c).Where(" device_sn = ? and is_deleted = ?",
-		c.DeviceSN, c.IsDeleted).Find(&devices).Error
-	//如果查询不到,返回相应的错误
-	if gorm.ErrRecordNotFound == err {
-		return false
-	}
-	for _, d := range devices {
-		if d.ID != c.ID {
-			return true
-		}
-	}
-	return false
-}
-
-func (c *Garbage) Create() error {
-	return Db.Model(&c).Save(&c).Error
-}
-
-func (c *Garbage) Update() error {
-	return Db.Model(&c).Where(" id = ? ", c.ID).Updates(&c).Error
-}
-
-func (c *Garbage) GetDevice() error {
-	err := Db.Model(&c).Where(" id = ? ", c.ID).Scan(&c).Error
-	return err
-}
-
-func (c Garbage) GetDevices(offset, limit int) ([]Garbage, int64, error) {
-	var devices []Garbage
-	var count int64
-	db := Db.Model(&c).Where(" device_name like ? and is_deleted = 0", "%"+c.DeviceName+"%")
-	db.Count(&count)
-	err := db.Offset(offset).Limit(limit).Find(&devices).Error
-	return devices, count, err
-}
-
-func (c Garbage) GetAllDevices() ([]*Garbage, error) {
-	var devices []*Garbage
-	err := Db.Model(&c).Where(" tenant_id = ? and is_deleted = ? ", c.TenantId, c.IsDeleted).Scan(&devices).Error
-	return devices, err
-}
-
-func (c Garbage) GetAll() []*Garbage {
-	var devices []*Garbage
-	Db.Model(&c).Where("is_deleted = 0 ").Scan(&devices)
-	return devices
-}

+ 0 - 79
app/device/dao/garbageWayGroupDao.go

@@ -1,79 +0,0 @@
-package dao
-
-import (
-	"gorm.io/gorm"
-	"time"
-)
-
-// GarbageWayGroup 垃圾桶道路分组管理
-type GarbageWayGroup struct {
-	ID         int       `gorm:"primary_key" json:"id"`               //编号
-	GroupName  string    `gorm:"type:varchar(64)" json:"groupName"`   //分组名称
-	TenantId   string    `gorm:"type:varchar(12)" json:"tenantId"`    //租户id
-	CreateTime time.Time `gorm:"type:datetime" json:"createTime"`     //新增时间
-	CreateUser int       `gorm:"type:int" json:"createUser"`          //新增记录操作用户ID
-	UpdateTime time.Time `gorm:"type:datetime" json:"updateTime"`     //修改时间
-	UpdateUser int       `gorm:"type:int" json:"updateUser"`          //修改用户
-	IsDeleted  int       `gorm:"type:int;default 0" json:"isDeleted"` //是否删除 0=未删除,1=删除
-	Remark     string    `gorm:"type:varchar(255)" json:"remark"`     //备注
-}
-
-func (GarbageWayGroup) TableName() string {
-	return "device_garbage_way_group"
-}
-
-func (c GarbageWayGroup) Delete() error {
-	return Db.Model(&c).Where("id = ?", c.ID).Updates(map[string]interface{}{"update_time": c.UpdateTime,
-		"update_user": c.UpdateUser, "is_deleted": c.IsDeleted}).Error
-}
-
-func (c GarbageWayGroup) IsExistedByName() bool {
-	var count int64
-	_ = Db.Model(&c).Where("  group_name = ? and is_deleted = ?",
-		c.GroupName, c.IsDeleted).Count(&count).Error
-	return count > 0
-}
-
-func (c GarbageWayGroup) IsExistedByNameAndCode() bool {
-	var devices []Garbage
-	err := Db.Model(&c).Where(" group_name = ? and is_deleted = ?",
-		c.GroupName, c.IsDeleted).Find(&devices).Error
-	//如果查询不到,返回相应的错误
-	if gorm.ErrRecordNotFound == err {
-		return false
-	}
-	for _, d := range devices {
-		if d.ID != c.ID {
-			return true
-		}
-	}
-	return false
-}
-
-func (c *GarbageWayGroup) Create() error {
-	return Db.Model(&c).Save(&c).Error
-}
-
-func (c *GarbageWayGroup) Update() error {
-	return Db.Model(&c).Where(" id = ? ", c.ID).Updates(&c).Error
-}
-
-func (c *GarbageWayGroup) GetDevice() error {
-	err := Db.Model(&c).Where(" id = ? ", c.ID).Scan(&c).Error
-	return err
-}
-
-func (c GarbageWayGroup) GetDevices(offset, limit int) ([]GarbageWayGroup, int64, error) {
-	var devices []GarbageWayGroup
-	var count int64
-	db := Db.Model(&c).Where(" group_name like ? and is_deleted = 0", "%"+c.GroupName+"%")
-	db.Count(&count)
-	err := db.Offset(offset).Limit(limit).Find(&devices).Error
-	return devices, count, err
-}
-
-func (c GarbageWayGroup) GetAllDevices() ([]*GarbageWayGroup, error) {
-	var devices []*GarbageWayGroup
-	err := Db.Model(&c).Where(" tenant_id = ? and is_deleted = ? ", c.TenantId, c.IsDeleted).Scan(&devices).Error
-	return devices, err
-}

+ 0 - 141
app/device/dao/gatewayDao.go

@@ -1,141 +0,0 @@
-package dao
-
-import (
-	"gorm.io/gorm"
-	"iot_manager_service/util/common"
-	"time"
-)
-
-// Gateway 网关设备
-type Gateway struct {
-	ID                 int         `gorm:"primary_key" json:"id"`                           //编号
-	GatewayName        string      `gorm:"type:varchar(64)"  json:"gatewayName"`            //设备名称
-	GatewaySn          string      `gorm:"type:varchar(60)" json:"gatewaySn"`               //设备序列号
-	LampPoleId         int         `gorm:"type:int" json:"lampPoleId"`                      //所属灯杆
-	LampPoleSn         string      `gorm:"type:varchar(64)" json:"lampPoleSn"`              //所属灯杆SN
-	LampPoleName       string      `gorm:"type:varchar(64)" json:"lampPoleName"`            //灯杆名称
-	LampPoleLocation   string      `gorm:"type:varchar(255)" json:"lampPoleLocation"`       //灯杆安装位置
-	LampLat            float64     `gorm:"type:double(17,14)" json:"lampLat"`               //纬度
-	LampLng            float64     `gorm:"type:double(17,14)" json:"lampLng"`               //经度
-	BrandId            int         `gorm:"type:int" json:"brandId"`                         //设备品牌
-	ModelId            int         `gorm:"type:int" json:"modelId"`                         //设备型号
-	GatewayInstallTime common.Time `gorm:"type:date" json:"gatewayInstallTime"`             //安装时间
-	RatedPower         float32     `gorm:"type:double(8,2);default:0.00" json:"ratedPower"` //功率
-	IpAddress          string      `gorm:"type:varchar(50)" json:"ipAddress"`               //IP地址
-	DiNum              int         `gorm:"type:int;default 0" json:"diNum"`                 //DI口数量
-	DoNum              int         `gorm:"type:int;default 0" json:"doNum"`                 //DO口数量
-	Num485             int         `gorm:"type:int;default 0" json:"num485"`                //485口数量
-	NetworkNum         int         `gorm:"type:int;default 0" json:"networkNum"`            //网口数量
-	TenantId           string      `gorm:"type:varchar(12)" json:"tenantId"`                //租户ID
-	CreateTime         time.Time   `gorm:"type:datetime" json:"createTime"`                 //新增时间
-	CreateUser         int         `gorm:"type:int" json:"createUser"`                      //新增记录操作用户ID
-	UpdateTime         time.Time   `gorm:"type:datetime" json:"updateTime"`                 //修改时间
-	UpdateUser         int         `gorm:"type:int" json:"updateUser"`                      //修改用户
-	IsDeleted          int         `gorm:"type:int;default 0" json:"isDeleted"`             //是否删除 0=未删除,1=删除
-	Status             int         `gorm:"type:int" json:"status"`                          //状态 0=正常,1=异常
-	Tag                string      `gorm:"type:varchar(255)" json:"tag"`                    //标签,(备用,逗号区分)
-}
-
-func (Gateway) TableName() string {
-	return "device_wisdom_gateway"
-}
-
-func (c *Gateway) Delete() error {
-	return Db.Model(&c).Where("id = ?", c.ID).Updates(map[string]interface{}{"update_time": c.UpdateTime,
-		"update_user": c.UpdateUser, "is_deleted": c.IsDeleted}).Error
-}
-
-func (c Gateway) IsExistedBySN() bool {
-	var count int64
-	_ = Db.Model(&c).Where(" gateway_sn = ? and is_deleted = ?",
-		c.GatewaySn, c.IsDeleted).Count(&count).Error
-	return count > 0
-}
-
-func (c Gateway) IsExistedByNameAndCode() bool {
-	var devices []Gateway
-	err := Db.Model(&c).Where("gateway_sn = ? and is_deleted = ?",
-		c.TenantId, c.IsDeleted).Find(&devices).Error
-	if gorm.ErrRecordNotFound == err {
-		return false
-	}
-	for _, d := range devices {
-		if d.ID != c.ID {
-			return true
-		}
-	}
-	return false
-}
-
-func (c *Gateway) Create() error {
-	return Db.Model(&c).Save(&c).Error
-}
-
-func (c *Gateway) Update() error {
-	return Db.Model(&c).Where(" id = ? ", c.ID).Updates(&c).Error
-}
-
-func (c *Gateway) GetDevice() error {
-	err := Db.Model(&c).Where(" id = ? ", c.ID).First(&c).Error
-	return err
-}
-
-func (c Gateway) GetDevices(offset, limit int) ([]Gateway, int64, error) {
-	var devices []Gateway
-	var count int64
-	db := Db.Model(&c)
-	if c.GatewaySn != "" {
-		db = db.Where("gateway_name like ? or gateway_sn like ?", "%"+c.GatewaySn+"%", "%"+c.GatewaySn+"%")
-	}
-
-	tx := db.Where("is_deleted = 0")
-	tx.Count(&count)
-	err := tx.Offset(offset).Limit(limit).Order("gateway_name asc").Find(&devices).Error
-	return devices, count, err
-}
-
-func (c Gateway) GetAllDevices() ([]*Gateway, error) {
-	var devices []*Gateway
-	err := Db.Model(&c).Where(" tenant_id = ? and is_deleted = ? ", c.TenantId, c.IsDeleted).Scan(&devices).Error
-	return devices, err
-}
-
-func (c Gateway) GetDevicesByLampPole() []Gateway {
-	var devices []Gateway
-	Db.Model(&c).Where("lamp_pole_id = ? and is_deleted = 0",
-		c.LampPoleId).Find(&devices)
-	return devices
-}
-
-func (c Gateway) DeviceCount1() (int64, int64) {
-	var all, fault int64
-	err := Db.Model(&c).Where("is_deleted = 0").Count(&all).Error
-	if err != nil {
-		all = -1
-	}
-	err = Db.Model(&c).Where("is_deleted = 0 and status = 0").Count(&fault).Error
-	if err != nil {
-		fault = -1
-	}
-	return all, fault
-}
-
-func (c Gateway) ListDevices1() []Device {
-	var devices []Gateway
-	Db.Model(&c).Where("is_deleted = 0").Find(&devices)
-	var rsp = make([]Device, 0, len(devices))
-	for _, v := range devices {
-		var d = Device{
-			Lng:          v.LampLng,
-			Lat:          v.LampLat,
-			Status:       v.Status,
-			Name:         v.GatewayName,
-			Code:         v.GatewaySn,
-			LampPoleName: v.LampPoleName,
-			Model:        "模型",
-			LinkNum:      getLinkNum(v.LampPoleSn),
-		}
-		rsp = append(rsp, d)
-	}
-	return rsp
-}

+ 0 - 69
app/device/dao/gatewayRelationDao.go

@@ -1,69 +0,0 @@
-package dao
-
-import (
-	"time"
-)
-
-// GatewayRelation 网关挂载设备关联信息表
-type GatewayRelation struct {
-	ID                 int       `gorm:"type:int;primary_key"` //编号 网关ID
-	CameraCount        int       `gorm:"type:int;default 0" comment:"球机数量"`
-	LightControlCount  int       `gorm:"type:int;default 0"` //灯控数量
-	InfoBoardCount     int       `gorm:"type:int;default 0"` //信息屏数量
-	OptoSensorCount    int       `gorm:"type:int;default 0"` //环境传感器数量
-	ZigbeeCount        int       `gorm:"type:int;default 0"` //Zigbee设备数量
-	AlarmTerminalCount int       `gorm:"type:int;default 0"` //告警终端数量
-	CaptureUnitCount   int       `gorm:"type:int;default 0"` //抓拍单元数量
-	IpBroadcastCount   int       `gorm:"type:int;default 0"` //IP音柱数量
-	CurveSensorCount   int       `gorm:"type:int;default 0" comment:"信息屏"`
-	Total              int       `gorm:"type:int;default 0"`                  //总数
-	TenantId           string    `gorm:"type:varchar(12)" json:"tenantId"`    //租户ID
-	CreateTime         time.Time `gorm:"type:datetime" json:"createTime"`     //新增时间
-	UpdateTime         time.Time `gorm:"type:datetime" json:"updateTime"`     //修改时间
-	IsDeleted          int       `gorm:"type:int;default 0" json:"isDeleted"` //是否删除 0=未删除,1=删
-}
-
-func (GatewayRelation) TableName() string {
-	return "device_gateway_relation"
-}
-
-func (c *GatewayRelation) Get() error {
-	return Db.Model(&c).Where("id = ?", c.ID).Find(&c).Error
-}
-
-// 2022-12-08 dsx 查出所有数据更新进去
-func (c *GatewayRelation) Update() error {
-	gatewayId := c.ID
-	relation := GatewayRelation{}
-	sql := `SELECT * from (
-				(SELECT count(1) camera_count from device_camera where is_deleted=0 and gateway_id in (?)) as camera_count,
-				(SELECT count(1) light_control_count from device_light_control where is_deleted=0 and gateway_id in (?)) as light_control_count,
-				(SELECT count(1) info_board_count from device_info_board where is_deleted=0 and gateway_id in (?)) as info_board_count,
-				(SELECT count(1) opto_sensor_count from device_opto_sensor where is_deleted=0 and gateway_id in (?)) as opto_sensor_count,
-				(SELECT count(1) zigbee_count from device_zigbee where is_deleted=0 and gateway_id in (?)) as zigbee_count,
-				(SELECT count(1) alarm_terminal_count from device_a_key_alarm_terminal where is_deleted=0 and gateway_id in (?)) as alarm_terminal_count,
-				(SELECT count(1) capture_unit_count from device_capture_unit where is_deleted=0 and gateway_id in (?)) as capture_unit_count,
-				(SELECT count(1) ip_broadcast_count from device_ip_broadcast where is_deleted=0 and gateway_id in (?)) as ip_broadcast_count,
-				(SELECT count(1) curve_sensor_count from device_curve_sensor where is_deleted=0 and gateway_id in (?)) as curve_sensor_count
-            ) limit 1`
-	Db.Model(&c).Raw(sql, gatewayId, gatewayId, gatewayId, gatewayId, gatewayId, gatewayId, gatewayId, gatewayId, gatewayId).Scan(&relation)
-	relation.Total = relation.CameraCount + relation.LightControlCount + relation.InfoBoardCount +
-		relation.OptoSensorCount + relation.ZigbeeCount + relation.AlarmTerminalCount +
-		relation.CaptureUnitCount + relation.IpBroadcastCount + relation.CurveSensorCount
-	var count int64
-	_ = Db.Model(&c).Where(" id = ? ", gatewayId).Count(&count)
-	if count > 0 {
-		relation.UpdateTime = time.Now()
-
-		if relation.Total > 0 {
-			return Db.Model(&c).Where(" id = ? ", gatewayId).Updates(&relation).Error
-		} else {
-			return Db.Model(&c).Where(" id = ? ", gatewayId).Updates(map[string]interface{}{"total": 0}).Error
-		}
-	} else {
-		relation.ID = int(gatewayId)
-		relation.UpdateTime = time.Now()
-		relation.CreateTime = time.Now()
-		return Db.Model(&c).Create(&relation).Error
-	}
-}

+ 0 - 174
app/device/dao/infoBoardDao.go

@@ -1,174 +0,0 @@
-package dao
-
-import (
-	"gorm.io/gorm"
-	"iot_manager_service/util/common"
-	"time"
-)
-
-// InfoBoard InfoBoard信息基本屏
-type InfoBoard struct {
-	ID               int         `gorm:"primary_key" json:"id"`                            //编号
-	InfoName         string      `gorm:"type:varchar(60)" json:"infoName"`                 //名称
-	Sn               string      `gorm:"type:varchar(60)" json:"sn"`                       //设备序列号
-	LampPoleId       int         `gorm:"type:int" json:"lampPoleId"`                       //所属灯杆id
-	LampPoleName     string      `gorm:"type:varchar(64)" json:"lampPoleName"`             //灯杆名称
-	LampPoleSn       string      `gorm:"type:varchar(64)" json:"lampPoleSn"`               //灯杆编码
-	LampPoleLocation string      `gorm:"type:varchar(255)" json:"lampPoleLocation"`        //灯杆安装位置
-	PoleLng          float64     `gorm:"type:double(17, 14) " json:"lampLng"`              //经度
-	PoleLat          float64     `gorm:"type:double(17, 14)  " json:"lampLat"`             //纬度
-	GatewayId        int         `gorm:"type:int" json:"gatewayId"`                        //所属网关id
-	GroupId          int         `gorm:"type:int" json:"groupId"`                          //所属灯杆分组
-	Resolution       int         `gorm:"type:int" json:"resolution"`                       //分辨率
-	BrandId          int         `gorm:"type:int" json:"brandId"`                          //设备名
-	ModelId          int         `gorm:"type:int" json:"modelId"`                          //设备型号
-	InfoSize         int         `gorm:"type:int" json:"infoSize"`                         //信息屏尺寸
-	RatedPower       float32     `gorm:"type:float(8, 2); default 0.00" json:"ratedPower"` //额定功率(LED灯)
-	IPAddress        string      `gorm:"type:varchar(64)" json:"ipAddress"`                //IP地址
-	BootStartTime    string      `gorm:"type:varchar(64)" json:"bootStartTime"`            //开机开始时间
-	BootEndTime      string      `gorm:"type:varchar(64)" json:"bootEndTime"`              //开机结束时间
-	NeverCloseDown   int         `gorm:"type:int" json:"neverCloseDown"`                   //永不关机:1-选择,2-取消
-	InstallTime      common.Time `gorm:"type:date" json:"installTime"`                     //安装时间
-	TenantId         string      `gorm:"type:varchar(12)" json:"tenantId"`                 //租户ID
-	CreateTime       time.Time   `gorm:"type:datetime" json:"createTime"`                  //新增时间
-	CreateUser       int         `gorm:"type:int" json:"createUser"`                       //新增记录操作用户ID
-	UpdateTime       time.Time   `gorm:"type:datetime" json:"updateTime"`                  //修改时间
-	UpdateUser       int         `gorm:"type:int" json:"updateUser"`                       //修改用户
-	IsDeleted        int         `gorm:"type:int;default 0" json:"isDeleted"`              //是否删除 0=未删除,1=删除
-	Tag              string      `gorm:"type:varchar(255)" json:"tag"`                     //标签,保留字段(逗号区分)
-	ExteriorUid      int         `gorm:"type:bigint" json:"exteriorUid"`                   //外设ID
-	IsEnable         int         `gorm:"type:int; default 2 " json:"isEnable"`             //启用禁用:1启用,2禁用
-
-	Condition string `gorm:"type:varchar(255);default='80,30,30,5'" json:"condition"` //白天晚上 亮度 音量调节
-}
-
-func (InfoBoard) TableName() string {
-	return "device_info_board"
-}
-
-func (c InfoBoard) Delete() error {
-	return Db.Model(&c).Where("id = ?", c.ID).Updates(map[string]interface{}{"update_time": c.UpdateTime,
-		"update_user": c.UpdateUser, "is_deleted": c.IsDeleted}).Error
-}
-
-func (c InfoBoard) IsExistedBySN() bool {
-	var count int64
-	_ = Db.Model(&c).Where("  sn = ? and is_deleted = ?",
-		c.Sn, c.IsDeleted).Count(&count).Error
-	return count > 0
-}
-
-func (c InfoBoard) IsExistedByNameAndCode() bool {
-	var devices []InfoBoard
-	err := Db.Model(&c).Where(" sn = ? and is_deleted = ?",
-		c.Sn, c.IsDeleted).Find(&devices).Error
-	//如果查询不到,返回相应的错误
-	if gorm.ErrRecordNotFound == err {
-		return false
-	}
-	for _, d := range devices {
-		if d.ID != c.ID {
-			return true
-		}
-	}
-	return false
-}
-
-func (c *InfoBoard) Create() error {
-	return Db.Model(&c).Save(&c).Error
-}
-
-func (c *InfoBoard) Update() error {
-	return Db.Model(&c).Where(" id = ? ", c.ID).Updates(&c).Error
-}
-
-func (c *InfoBoard) GetDevice() (InfoBoard, error) {
-	var device InfoBoard
-	err := Db.Model(&c).Where(" is_deleted = 0 and id = ? ", c.ID).Scan(&device).Error
-	return device, err
-}
-
-func (c InfoBoard) GetDevices(offset, limit int) ([]InfoBoard, int64, error) {
-	var devices []InfoBoard
-	var count int64
-	db := Db.Model(&c).Where("is_deleted = 0  and (info_name like ? or sn like ?) ", "%"+c.InfoName+"%", "%"+c.InfoName+"%")
-	db.Count(&count)
-	err := db.Offset(offset).Limit(limit).Order("info_name asc").Find(&devices).Error
-	return devices, count, err
-}
-
-func (c InfoBoard) GetAllDevices() ([]*InfoBoard, error) {
-	var devices []*InfoBoard
-	err := Db.Model(&c).Where(" tenant_id = ? and is_deleted = 0 ", c.TenantId).Scan(&devices).Error
-	return devices, err
-}
-
-func (c InfoBoard) GetAllDevicesNotTenant() ([]*InfoBoard, error) {
-	var devices []*InfoBoard
-	db := Db.Model(&c)
-	if c.ID > 0 {
-		db.Where("id=?", c.ID)
-	}
-	err := db.Where("is_deleted = 0 ").Scan(&devices).Error
-	return devices, err
-}
-
-func (c InfoBoard) GetDevicesByGateway() []InfoBoard {
-	var devices []InfoBoard
-	Db.Model(&c).Where(" gateway_id = ? and is_deleted = 0",
-		c.GatewayId).Find(&devices)
-	return devices
-}
-
-func (c InfoBoard) GetDevicesByLampPole() []InfoBoard {
-	var devices []InfoBoard
-	Db.Model(&c).Where("lamp_pole_id = ? and is_deleted = 0",
-		c.LampPoleId).Find(&devices)
-	return devices
-}
-
-func (c InfoBoard) GetDevicesByResolution() []InfoBoard {
-	var devices []InfoBoard
-	Db.Model(&c).Where("resolution = ? and tenant_id = ? and is_deleted = 0",
-		c.Resolution, c.TenantId).Find(&devices)
-	return devices
-}
-
-func (c InfoBoard) GetDevicesByIds(ids string) []InfoBoard {
-	var devices []InfoBoard
-	Db.Model(&c).Where("id in ("+ids+")"+" and tenant_id = ?  and is_deleted = 0",
-		c.TenantId).Scan(&devices)
-	return devices
-}
-
-func (c InfoBoard) DeviceCount1() (int64, int64) {
-	var all, fault int64
-	err := Db.Model(&c).Where("is_deleted = 0").Count(&all).Error
-	if err != nil {
-		all = 0
-	}
-	err = Db.Model(&c).Where("is_deleted = 0 and status = 0").Count(&fault).Error
-	if err != nil {
-		fault = 0
-	}
-	return all, fault
-}
-
-func (c InfoBoard) ListDevices1() []Device {
-	var devices []InfoBoard
-	Db.Model(&c).Where("is_deleted = 0").Find(&devices)
-	var rsp = make([]Device, 0, len(devices))
-	for _, v := range devices {
-		var d = Device{
-			Lng:          v.PoleLng,
-			Lat:          v.PoleLat,
-			Status:       -1,
-			Name:         v.InfoName,
-			Code:         v.Sn,
-			LampPoleName: v.LampPoleName,
-			Model:        "模型",
-		}
-		rsp = append(rsp, d)
-	}
-	return rsp
-}

+ 0 - 182
app/device/dao/intelligentLightingDao.go

@@ -1,182 +0,0 @@
-package dao
-
-import (
-	"fmt"
-	"time"
-)
-
-type LightrelationVo struct {
-	ID                 int    `json:"id"`
-	LightID            int    `json:"lightId"`
-	RelationType       int    `json:"relationType"`
-	Rid                int    `json:"rid"`
-	CreateTime         string `json:"createTime"`
-	CreateUser         string `json:"createUser"`
-	UpdateTime         string `json:"updateTime"`
-	UpdateUser         string `json:"updateUser"`
-	IsDeleted          int    `json:"isDeleted"`
-	TenantID           string `json:"tenantId"`
-	IsAutomaticRenewal int    `json:"isAutomaticRenewal"`
-	EffectiveDate      string `json:"effectiveDate"`
-	EndTime            string `json:"endTime"`
-	DeviceSn           string `json:"deviceSn"`
-	Location           string `json:"location"`
-
-	LightControlState  string             `json:"lightControlState"`
-	IsShowOpts         bool               `json:"isShowOpts"`
-	PublicID           int                `json:"publicId"`
-	CombinationStrList []interface{}      `gorm:"-" json:"combinationStrList"`
-	RunState           string             `json:"runState"`
-	Children           *[]LightrelationVo `gorm:"-" json:"children"`
-	GroupID            int                `json:"groupId"`
-	LampPoleSn         string             `json:"lampPoleSn"`
-	LightName          string             `json:"lightName"`
-	ControlType        int                `json:"controlType"`
-	InstallTime        string             `json:"installTime"`
-	LampPoleName       string             `json:"lampPoleName"`
-	IsAllYear          int                `json:"isAllYear"`
-	PublicName         string             `json:"publicName"`
-	StartTime          string             `json:"startTime"`
-	LightSn            string             `json:"lightSn"`
-	HandSwitch         int                `json:"handSwitch"`
-	CombinationStr     string             `json:"combinationStr"`
-	LampLng            float64            `json:"lampLng"`
-	LampLat            float64            `json:"lampLat"`
-}
-
-type IntelligentLightGroupRelation struct {
-	IntelligentLight
-	LightStrategy
-	LightControl
-	TimeCondition
-	PublicName string `gorm:"_" json:"publicName"`
-}
-
-type IntelligentLight struct {
-	ID           int       `gorm:"primary key" json:"id"`               //编号
-	LightID      int       `gorm:"type:int" json:"lightID"`             //照明策略id
-	RelationType int       `gorm:"type:int" json:"relationType"`        //关联类型1=灯控,2=灯杆分组
-	Rid          int       `gorm:"type:int" json:"rid"`                 //关联外键ID 根据type类型关联至其表
-	TenantId     string    `gorm:"type:varchar(12)" json:"tenantId"`    //租户ID
-	CreateTime   time.Time `gorm:"type:datetime" json:"createTime"`     //新增时间
-	CreateUser   int       `gorm:"type:int" json:"createUser"`          //新增记录操作用户ID
-	UpdateTime   time.Time `gorm:"type:datetime" json:"updateTime"`     //修改时间
-	UpdateUser   int       `gorm:"type:int" json:"updateUser"`          //修改用户
-	IsDeleted    int       `gorm:"type:int;default 0" json:"isDeleted"` //是否删除 0=未删除,1=删除
-}
-
-func (IntelligentLight) TableName() string {
-	return "strategy_intelligent_light"
-}
-
-// CreateDefaultStrategyByLight 创建默认
-func (c *IntelligentLight) CreateDefaultStrategyByLight(rid int, relationType int, lightId int) error {
-	var intelligentLights IntelligentLight
-	intelligentLights.LightID = lightId
-	intelligentLights.RelationType = relationType
-	intelligentLights.Rid = rid
-	intelligentLights.TenantId = c.TenantId
-	intelligentLights.CreateTime = time.Now()
-	intelligentLights.UpdateTime = time.Now()
-	err := Db.Model(&c).Save(&intelligentLights).Error
-	return err
-}
-
-// 批量获取
-func (c *IntelligentLight) BatchGet(ids []int) ([]IntelligentLight, error) {
-	var intelligentLights []IntelligentLight
-	err := Db.Model(&c).Where("light_id in ? and is_deleted = 0", ids).Find(&intelligentLights).Error
-	return intelligentLights, err
-}
-
-func (c *IntelligentLight) GetByRidAndType() ([]IntelligentLight, error) {
-	var intelligentLights []IntelligentLight
-	db := Db.Model(&c).Where("relation_type = ? and is_deleted = 0 and tenant_id = ?",
-		c.RelationType, c.TenantId)
-	if c.Rid > 0 {
-		db = db.Where("rid = ?", c.Rid)
-	}
-	err := db.Find(&intelligentLights).Error
-	return intelligentLights, err
-}
-
-func (c *IntelligentLight) GetByGroup2(searchValue string, current, size,
-	groupId int) ([]LightrelationVo, error) {
-	var groupRelations []LightrelationVo
-	where := "lig.tenant_id = ?"
-	if groupId != 0 {
-		where += fmt.Sprintf(" AND lig.rid in(%v)", groupId)
-	}
-	sql := `SELECT lig.*,gro.id public_id,gro.pole_group_name public_name,b.light_name,b.light_sn,b.start_time,b.end_time,b.is_all_year,b.is_automatic_renewal
-        FROM strategy_intelligent_light lig
-        LEFT JOIN device_lamp_pole_group gro ON lig.rid=gro.id
-        LEFT JOIN strategy_light b ON b.id=lig.light_id
-        WHERE lig.is_deleted=0 AND lig.relation_type=2 AND gro.is_deleted=0
-				and ` + where + `
-        ORDER BY lig.create_time desc`
-	tx := Db.Raw(sql, c.TenantId).Scan(&groupRelations)
-	return groupRelations, tx.Error
-}
-
-func (c *IntelligentLight) GetByGroup(searchValue string, current, size,
-	groupId int) ([]LightrelationVo, int64, error) {
-	var groupRelations []LightrelationVo
-	where := " AND con.tenant_id = ?"
-	if groupId != 0 {
-		where += fmt.Sprintf(" AND con.group_id in(%v)", groupId)
-	}
-	if searchValue != "" {
-		where += fmt.Sprintf(" and (con.sn like '%%v%' or con.name like '%$v%')", searchValue)
-	}
-	offset := (current - 1) * size
-	limit := size
-
-	sql := `SELECT
-			lig.*,
-			con.control_type,
-			con.id public_id,
-			con.NAME public_name,
-			con.sn device_sn,
-			con.lamp_pole_name,
-			con.lamp_pole_sn,
-			con.group_id,
-			con.lamp_lat,
-			con.lamp_lng,
-			con.id as rid,
-		
-			b.light_name,
-			b.light_sn,
-			b.start_time,
-			b.end_time,
-			is_all_year,
-			b.is_automatic_renewal,
-			con.lamp_pole_location,
-			con.install_time 
-		FROM
-			device_light_control con
-			left  JOIN strategy_intelligent_light lig ON  con.id = lig.rid 
-			LEFT JOIN strategy_light b ON b.id = lig.light_id
-		WHERE
-			con.is_deleted = 0
-			
-			` + where + `
-		ORDER BY
-			con.name asc `
-
-	var count int64
-	Db.Raw(sql, c.TenantId).Count(&count)
-	sql += `limit ?,?`
-	tx := Db.Raw(sql, c.TenantId, offset, limit).Scan(&groupRelations)
-	return groupRelations, count, tx.Error
-
-}
-
-func (c IntelligentLight) Update() error {
-	return Db.Model(&c).Where(" id = ? and is_deleted = 0", c.ID).Updates(&c).Error
-}
-
-func (c IntelligentLight) Get() (IntelligentLight, error) {
-	var intelligentLight IntelligentLight
-	err := Db.Model(&c).Where("is_deleted = 0 and rid = ? and relation_type = ?", c.Rid, c.RelationType).First(&intelligentLight).Error
-	return intelligentLight, err
-}

+ 0 - 160
app/device/dao/ipBroadcastDao.go

@@ -1,160 +0,0 @@
-package dao
-
-import (
-	"gorm.io/gorm"
-	"iot_manager_service/util/common"
-	"time"
-)
-
-type IpBroadcast struct {
-	ID               int         `gorm:"primary_key" json:"id"`                            //编号
-	CastName         string      `gorm:"type:varchar(64)" json:"castName"`                 //设备名称
-	CastSn           string      `gorm:"type:varchar(60)" json:"castSn"`                   //设备序列号
-	LampPoleId       int         `gorm:"type:int" json:"lampPoleId"`                       //所属灯杆id
-	LampPoleSn       string      `gorm:"type:varchar(64)" json:"lampPoleSn"`               //所属灯杆sn
-	GroupId          int         `gorm:"type:int" json:"groupId"`                          //灯杆分组ID
-	GatewayId        int         `gorm:"type:int" json:"gatewayId"`                        //所属网关id
-	GatewaySn        string      `gorm:"type:varchar(64)" json:"gatewaySn"`                //所属网关sn
-	BrandId          int         `gorm:"type:int" json:"brandId"`                          //设备名称
-	ModelId          int         `gorm:"type:int" json:"modelId"`                          //设备型号
-	RatedPower       float32     `gorm:"type:float(8, 2); default 0.00" json:"ratedPower"` //额定功率(LED灯)
-	IPAddress        string      `gorm:"type:varchar(50)" json:"ipAddress"`                //IP地址
-	PlayState        string      `gorm:"-" json:"playState"`                               //播放状态
-	ServiceIpAddress string      `gorm:"type:varchar(50)" json:"serviceIpAddress"`         //服务IP地址
-	ServerPort       int         `gorm:"type:int" json:"serverPort"`                       //服务端口
-	SoundVolume      int         `gorm:"type:int;default=0" json:"soundVolume"`            //音量0-100换算
-	InstallTime      common.Time `gorm:"type:date" json:"installTime"`                     //安装时间
-	TenantId         string      `gorm:"type:varchar(12)" json:"tenantId"`                 //租户ID
-	CreateTime       time.Time   `gorm:"type:datetime" json:"createTime"`                  //新增时间
-	CreateUser       int         `gorm:"type:int" json:"createUser"`                       //新增记录操作用户ID
-	UpdateTime       time.Time   `gorm:"type:datetime" json:"updateTime"`                  //修改时间
-	UpdateUser       int         `gorm:"type:int" json:"updateUser"`                       //修改用户
-	IsDeleted        int         `gorm:"type:int;default 0" json:"isDeleted"`              //是否删除 0=未删除,1=删除
-}
-
-func (IpBroadcast) TableName() string {
-	return "device_ip_broadcast"
-}
-
-func (c IpBroadcast) Delete() error {
-	return Db.Model(&c).Where("id = ?", c.ID).Updates(map[string]interface{}{"update_time": c.UpdateTime,
-		"update_user": c.UpdateUser, "is_deleted": c.IsDeleted}).Error
-}
-
-func (c IpBroadcast) IsExistedBySN() bool {
-	var count int64
-	_ = Db.Model(&c).Where("  cast_sn = ? and is_deleted = ?",
-		c.CastSn, c.IsDeleted).Count(&count).Error
-	return count > 0
-}
-
-func (c IpBroadcast) IsExistedByNameAndCode() bool {
-	var devices []IpBroadcast
-	err := Db.Model(&c).Where(" cast_sn = ? and is_deleted = ?",
-		c.CastSn, c.IsDeleted).Find(&devices).Error
-	//如果查询不到,返回相应的错误
-	if gorm.ErrRecordNotFound == err {
-		return false
-	}
-	for _, d := range devices {
-		if d.ID != c.ID {
-			return true
-		}
-	}
-	return false
-}
-
-func (c *IpBroadcast) Create() error {
-	return Db.Model(&c).Save(&c).Error
-}
-
-func (c *IpBroadcast) Update() error {
-	return Db.Model(&c).Where(" id = ? ", c.ID).Updates(&c).Error
-}
-
-func (c *IpBroadcast) GetDevice() error {
-	err := Db.Model(&c).Where(" id = ? ", c.ID).Scan(&c).Error
-	return err
-}
-
-func (c IpBroadcast) GetDevices(offset, limit int) ([]IpBroadcast, int64, error) {
-	var devices []IpBroadcast
-	var count int64
-	db := Db.Model(&c).Where("is_deleted = 0 and cast_name like ? ", "%"+c.CastName+"%")
-	db.Count(&count)
-	err := db.Offset(offset).Limit(limit).Find(&devices).Error
-	return devices, count, err
-}
-
-func (c IpBroadcast) GetAllDevices() ([]IpBroadcast, error) {
-	var devices []IpBroadcast
-	err := Db.Model(&c).Where(" tenant_id = ? and is_deleted = ? ", c.TenantId,
-		c.IsDeleted).Scan(&devices).Error
-	return devices, err
-}
-
-func (c IpBroadcast) GetDevicesByGateway() []IpBroadcast {
-	var devices []IpBroadcast
-	Db.Model(&c).Where(" gateway_id = ? and is_deleted = 0",
-		c.GatewayId).Find(&devices)
-	return devices
-}
-
-func (c IpBroadcast) GetDevicesByLampPole() []IpBroadcast {
-	var devices []IpBroadcast
-	Db.Model(&c).Where("lamp_pole_id = ? and is_deleted = 0",
-		c.LampPoleId).Find(&devices)
-	return devices
-}
-
-func (c IpBroadcast) GetAll() []IpBroadcast {
-	var devices []IpBroadcast
-	Db.Model(&c).Where(" tenant_id = ? and is_deleted = ? ", c.TenantId,
-		c.IsDeleted).Scan(&devices)
-	return devices
-}
-
-func (c IpBroadcast) GetByIds(ids string) []IpBroadcast {
-	var devices []IpBroadcast
-	Db.Model(&c).Where(" tenant_id = ? and is_deleted = ?", c.TenantId,
-		c.IsDeleted).Where("id in (" + ids + ")").Scan(&devices)
-	return devices
-}
-
-func (c IpBroadcast) GetAllDevicesNotTenant() ([]*IpBroadcast, error) {
-	var devices []*IpBroadcast
-	db := Db.Model(&c)
-	if c.ID > 0 {
-		db.Where("id=?", c.ID)
-	}
-	err := db.Where("is_deleted = 0 ").Scan(&devices).Error
-	return devices, err
-}
-
-func (c IpBroadcast) DeviceCount1() (int64, int64) {
-	var all, fault int64
-	err := Db.Model(&c).Where("is_deleted = 0").Count(&all).Error
-	if err != nil {
-		all = 0
-	}
-	err = Db.Model(&c).Where("is_deleted = 0 and status = 0").Count(&fault).Error
-	if err != nil {
-		fault = 0
-	}
-	return all, fault
-}
-
-func (c IpBroadcast) ListDevices1() []Device {
-	var devices []IpBroadcast
-	Db.Model(&c).Where("is_deleted = 0").Find(&devices)
-	var rsp = make([]Device, 0, len(devices))
-	for _, v := range devices {
-		var d = Device{
-			Name:  v.CastName,
-			Code:  v.CastSn,
-			Model: "模型",
-		}
-		rsp = append(rsp, d)
-	}
-	return rsp
-}

+ 0 - 178
app/device/dao/lampPoleDao.go

@@ -1,178 +0,0 @@
-package dao
-
-import (
-	"gorm.io/gorm"
-	"iot_manager_service/util/common"
-	"time"
-)
-
-// LampPole 灯杆设备
-type LampPole struct {
-	ID              int         `gorm:"primary_key" json:"id"`                    //编号
-	PoleName        string      `gorm:"type:varchar(64)"  json:"poleName"`        //灯杆名称
-	PoleSN          string      `gorm:"type:varchar(60)" json:"poleSn"`           //灯杆唯一识别码
-	PoleSize        float32     `gorm:"type:double(3,1)" json:"poleSize"`         //灯杆规格
-	GroupId         int         `gorm:"type:int" json:"groupId"`                  //所属灯杆分组
-	GatewayId       string      `gorm:"type:varchar(32)" json:"gatewayId"`        //所属网关id
-	BoxId           int         `gorm:"type:int" json:"boxId"`                    //所属配电箱
-	CoordType       int         `gorm:"type:int;default 1" json:"coordType"`      //经纬度类型0=百度,1=高德,2=腾讯,3=GPS
-	ProvinceName    string      `gorm:"type:varchar(60)" json:"provinceName"`     //省份
-	CityName        string      `gorm:"type:varchar(60)" json:"cityName"`         //城市
-	DistrictName    string      `gorm:"type:varchar(60)" json:"districtName"`     //区域
-	InstallLocation string      `gorm:"type:varchar(100)" json:"installLocation"` //安装位置
-	PoleLng         float64     `gorm:"type:double(17,14)" json:"poleLng"`        //经度
-	PoleLat         float64     `gorm:"type:double(17,14)" json:"poleLat"`        //纬度
-	RealLng         float64     `gorm:"type:double(17,14)" json:"realLng"`        //真实经度
-	RealLat         float64     `gorm:"type:double(17,14)" json:"realLat"`        //真实纬度
-	IsCross         int         `gorm:"type:int" json:"isCross"`                  //是否为路口-0-是1-不是
-	InstallTime     common.Time `gorm:"type:date" json:"installTime"`             //安装时间
-	LampPolePhoto   string      `gorm:"type:varchar(255)" json:"lampPolePhoto"`   //灯杆照片
-	TenantId        string      `gorm:"type:varchar(12)" json:"tenantId"`         //租户ID
-	CreateTime      time.Time   `gorm:"type:datetime" json:"createTime"`          //新增时间
-	CreateUser      int         `gorm:"type:int" json:"createUser"`               //新增记录操作用户ID
-	UpdateTime      time.Time   `gorm:"type:datetime" json:"updateTime"`          //修改时间
-	UpdateUser      int         `gorm:"type:int" json:"updateUser"`               //修改用户
-	IsDeleted       int         `gorm:"type:int;default 0" json:"isDeleted"`      //是否删除 0=未删除,1=删除
-	Status          int         `gorm:"type:int" json:"status"`                   //状态 0=正常,1=异常
-	Tag             string      `gorm:"type:varchar(255)" json:"tag"`             //标签,(备用,逗号区分)
-	BridgeId        int         `gorm:"type:int" json:"bridgeId"`                 //桥梁ID
-}
-
-func (LampPole) TableName() string {
-	return "device_lamp_pole"
-}
-
-func (c *LampPole) Delete() error {
-	return Db.Model(&c).Where("id = ?", c.ID).Updates(map[string]interface{}{"update_time": c.UpdateTime,
-		"update_user": c.UpdateUser, "is_deleted": c.IsDeleted}).Error
-}
-
-func (c LampPole) IsExistedBySN() bool {
-	var count int64
-	_ = Db.Model(&c).Where(" pole_sn = ? and is_deleted = ?",
-		c.PoleSN, c.IsDeleted).Count(&count).Error
-	return count > 0
-}
-
-func (c LampPole) IsExistedByNameAndCode() bool {
-	var devices []LampPoleGroup
-	err := Db.Model(&c).Where("pole_sn = ? and is_deleted = ?",
-		c.TenantId, c.IsDeleted).Find(&devices).Error
-	if gorm.ErrRecordNotFound == err {
-		return false
-	}
-	for _, d := range devices {
-		if d.ID != c.ID {
-			return true
-		}
-	}
-	return false
-}
-
-func (c *LampPole) Create() error {
-	return Db.Model(&c).Save(&c).Error
-}
-
-func (c *LampPole) Update() error {
-	return Db.Model(&c).Where(" id = ? ", c.ID).Updates(&c).Error
-}
-
-func (c *LampPole) GetDevice() error {
-	err := Db.Model(&c).Where(" id = ? ", c.ID).First(&c).Error
-	return err
-}
-
-func (c LampPole) GetDevices(offset, limit int) ([]LampPole, int64, error) {
-	var devices []LampPole
-	var count int64
-	db := Db.Model(&c)
-	if c.PoleSN != "" {
-		db = db.Where("pole_name like ? or pole_sn like ?", "%"+c.PoleSN+"%", "%"+c.PoleSN+"%")
-	}
-	if c.GroupId != -1 {
-		db = db.Where("group_id = ?", c.GroupId)
-	}
-	if c.BoxId != -1 {
-		db = db.Where("box_id = ?", c.BoxId)
-	}
-	db = db.Where("is_deleted = 0")
-	db.Count(&count)
-	err := db.Offset(offset).Limit(limit).Find(&devices).Error
-	return devices, count, err
-}
-
-func (c LampPole) GetAllDevices() ([]*LampPole, error) {
-	var devices []*LampPole
-	err := Db.Model(&c).Where(" tenant_id = ? and is_deleted = ? ", c.TenantId, c.IsDeleted).Scan(&devices).Error
-	return devices, err
-}
-
-func (c LampPole) Count() int64 {
-	var count int64
-	_ = Db.Model(&c).Where(" group_id = ? and is_deleted = ?",
-		c.GroupId, c.IsDeleted).Count(&count).Error
-	return count
-}
-
-// GetSwitchBoxCount 得到 配电箱 关联灯杆数 2022-12-08 dsx
-func (c LampPole) GetSwitchBoxCount() (int64, error) {
-	var count int64
-	err := Db.Model(&c).Where("(box_id = ?) and is_deleted = 0",
-		c.BoxId).Count(&count).Error
-	return count, err
-}
-
-// GetGroupIdCount 得到 灯杆分组 关联灯杆数 2022-12-09 dsx
-func (c LampPole) GetGroupIdCount() (int, error) {
-	var count int64
-	err := Db.Model(&c).Where("(group_id = ?) and is_deleted = 0",
-		c.GroupId).Count(&count).Error
-	return int(count), err
-}
-
-// CountAll SELECT COUNT(id) AS countNum FROM `device_lamp_pole` WHERE `is_deleted` = 0;
-func (c LampPole) CountAll() (int64, error) {
-	var i int64
-	err := Db.Table("device_lamp_pole").Where("is_deleted = 0").Count(&i).Error
-	return i, err
-}
-
-// CountFault SELECT COUNT(id) AS faultNum FROM `device_lamp_pole` WHERE `is_deleted` = 0 AND `status` = -1;
-func (c LampPole) CountFault() (int64, error) {
-	var i int64
-	err := Db.Model(&c).Where(map[string]interface{}{"is_deleted": 0, "status": 0}).Count(&i).Error
-	return i, err
-}
-
-func (c LampPole) ListDevices1() []Device {
-	var devices []LampPole
-	Db.Model(&c).Where("is_deleted = 0").Find(&devices)
-	var rsp = make([]Device, 0, len(devices))
-	for _, v := range devices {
-		var d = Device{
-			Lng:          v.PoleLng,
-			Lat:          v.PoleLat,
-			Status:       v.Status,
-			Name:         v.PoleName,
-			Code:         v.PoleSN,
-			LampPoleName: v.PoleName,
-			Model:        "型号",
-			LinkNum:      getLinkNum(v.PoleSN),
-		}
-		rsp = append(rsp, d)
-	}
-	return rsp
-}
-
-func (c LampPole) DeviceCount1() (int64, int64) {
-	var all, fault int64
-	err := Db.Model(&c).Where("is_deleted = 0").Count(&all).Error
-	if err != nil {
-		all = -1
-	}
-	err = Db.Model(&c).Where("is_deleted = 0 and status = 0").Count(&fault).Error
-	if err != nil {
-		fault = -1
-	}
-	return all, fault
-}

+ 0 - 89
app/device/dao/lampPoleGroupDao.go

@@ -1,89 +0,0 @@
-package dao
-
-import (
-	"gorm.io/gorm"
-	"iot_manager_service/util/common"
-	"time"
-)
-
-// LampPoleGroup 灯杆分组
-type LampPoleGroup struct {
-	ID            int         `gorm:"primary_key" json:"id"`                             //编号
-	PoleGroupName string      `gorm:"type:varchar(64)" json:"poleGroupName"`             //分组名称
-	TenantId      string      `gorm:"type:varchar(12)" json:"tenantId"`                  //租户ID
-	CreateTime    common.Time `gorm:"type:datetime;not null'" json:"createTime"`         //新增时间
-	CreateUser    int         `gorm:"type:int" json:"createUser"`                        //新增记录操作用户ID
-	UpdateTime    common.Time `gorm:"type:datetime" json:"updateTime"`                   //修改时间
-	UpdateUser    int         `gorm:"type:int" json:"updateUser"`                        //修改用户
-	IsDeleted     int         `gorm:"type:int;default 0" json:"isDeleted"`               //是否删除 0=未删除,1=删除
-	Tag           string      `gorm:"type:varchar(255)" json:"tag"`                      //标签,(备用,逗号区分)
-	Remark        string      `gorm:"type:varchar(255)" json:"remark"`                   //备注
-	CountLampPole int         `gorm:"type:int;default 0" json:"countLampPole,omitempty"` //灯杆数
-}
-
-func (LampPoleGroup) TableName() string {
-	return "device_lamp_pole_group"
-}
-
-func (c *LampPoleGroup) Delete() error {
-	return Db.Model(&c).Where("id = ?", c.ID).Updates(map[string]interface{}{"update_time": c.UpdateTime,
-		"update_user": c.UpdateUser, "is_deleted": c.IsDeleted}).Error
-}
-
-func (c LampPoleGroup) IsExistedByName() bool {
-	var count int64
-	_ = Db.Model(&c).Where(" pole_group_name = ? and tenant_id = ? and is_deleted = ?",
-		c.PoleGroupName, c.TenantId, c.IsDeleted).Count(&count).Error
-	return count > 0
-}
-
-func (c LampPoleGroup) IsExistedByNameAndCode() bool {
-	var devices []LampPoleGroup
-	err := Db.Model(&c).Where("pole_group_name = ? and tenant_id = ? and is_deleted = ?",
-		c.PoleGroupName, c.TenantId, c.IsDeleted).Find(&devices).Error
-	if gorm.ErrRecordNotFound == err {
-		return false
-	}
-	for _, d := range devices {
-		if d.ID != c.ID {
-			return true
-		}
-	}
-	return false
-}
-
-func (c *LampPoleGroup) Create() error {
-	return Db.Model(&c).Save(&c).Error
-}
-
-func (c *LampPoleGroup) Update() error {
-	return Db.Model(&c).Where(" id = ? ", c.ID).Updates(map[string]interface{}{"pole_group_name": c.PoleGroupName, "remark": c.Remark,
-		"tenant_id": c.TenantId, "update_time": time.Now(), "update_user": c.UpdateUser, "is_deleted": 0}).Error
-}
-
-func (c *LampPoleGroup) GetDevice() error {
-	err := Db.Model(&c).Where(" id = ? ", c.ID).Scan(&c).Error
-	return err
-}
-
-func (c LampPoleGroup) GetDevices(offset, limit int) ([]LampPoleGroup, int64, error) {
-	var devices []LampPoleGroup
-	var count int64
-	db := Db.Model(&c).Where(" pole_group_name like ? and is_deleted = 0", "%"+c.PoleGroupName+"%")
-	db.Count(&count)
-	err := db.Offset(offset).Limit(limit).Find(&devices).Error
-	return devices, count, err
-}
-
-func (c LampPoleGroup) GetAllDevices() ([]*LampPoleGroup, error) {
-	var devices []*LampPoleGroup
-	err := Db.Model(&c).Where(" tenant_id = ? and is_deleted = ? ", c.TenantId, c.IsDeleted).Scan(&devices).Error
-	return devices, err
-}
-
-func (c LampPoleGroup) BatchGet(ids []int) []*LampPoleGroup {
-	var devices []*LampPoleGroup
-	Db.Model(&c).Where(" tenant_id = ? and is_deleted = ? and id in (?)", c.TenantId,
-		c.IsDeleted, ids).Scan(&devices)
-	return devices
-}

+ 0 - 38
app/device/dao/lightConditionDao.go

@@ -1,38 +0,0 @@
-package dao
-
-import "time"
-
-type LightCondition struct {
-	ID         int       `gorm:"primary key" json:"id"`               //编号
-	LightId    int       `gorm:"type:int" json:"lightId"`             //照明策略id
-	ScopeStart int       `gorm:"type:int" json:"scopeStart"`          //光照度范围开始值
-	ScopeEnd   int       `gorm:"type:int" json:"scopeEnd"`            //光照度范围结束值
-	Luminance  int       `gorm:"type:int " json:"luminance"`          //开灯亮度
-	Remark     string    `gorm:"type:varchar(255)" json:"remark"`     //备注
-	CreateTime time.Time `gorm:"type:datetime" json:"createTime"`     //新增时间
-	CreateUser int       `gorm:"type:int" json:"createUser"`          //新增记录操作用户ID
-	UpdateTime time.Time `gorm:"type:datetime" json:"updateTime"`     //修改时间
-	UpdateUser int       `gorm:"type:int" json:"updateUser"`          //修改用户
-	IsDeleted  int       `gorm:"type:int;default 0" json:"isDeleted"` //是否删除 0=未删除,1=删除
-}
-
-func (LightCondition) TableName() string {
-	return "strategy_light_condition"
-}
-
-func (c *LightCondition) Get() error {
-	return Db.Model(&c).Where("id = ?", c.ID).Find(&c).Error
-}
-
-func (c *LightCondition) BatchGet(ids []int) ([]LightCondition, error) {
-	var conditions []LightCondition
-	err := Db.Model(&c).Where("id in ?", ids).Find(&conditions).Error
-	return conditions, err
-}
-
-func (c *LightCondition) Save(conditions []LightCondition, lightId int) error {
-	for i, _ := range conditions {
-		conditions[i].LightId = lightId
-	}
-	return Db.Model(&c).Save(&conditions).Error
-}

+ 0 - 170
app/device/dao/lightControlDao.go

@@ -1,170 +0,0 @@
-package dao
-
-import (
-	"gorm.io/gorm"
-	"iot_manager_service/util/common"
-	"time"
-)
-
-// LightControl 灯控
-type LightControl struct {
-	ID               int         `gorm:"primary_key" json:"id"`                     //编号
-	Name             string      `gorm:"type:varchar(64)"  json:"name"`             //名称
-	Sn               string      `gorm:"type:varchar(60)" json:"sn"`                //设备序列号
-	ControlType      int         `gorm:"type:int" json:"controlType"`               //控制器类型 type:2=485灯控,1=NB-iot箱
-	ControlTypeName  string      `gorm:"-" json:"controlTypeName"`                  //控制器类型 type:2=485灯控,1=NB-iot箱
-	GroupId          int         `gorm:"type:int" json:"groupId"`                   //所属灯杆分组
-	GatewayId        int         `gorm:"type:varchar(32)" json:"gatewayId"`         //所属网关id
-	LampPoleId       int         `gorm:"type:int" json:"lampPoleId"`                //所属灯杆 灯杆ID
-	LampPoleName     string      `gorm:"type:varchar(64)" json:"lampPoleName"`      //灯杆名称
-	LampPoleSn       string      `gorm:"type:varchar(64)" json:"lampPoleSn"`        //灯杆SN
-	LampPoleLocation string      `gorm:"type:varchar(255)" json:"lampPoleLocation"` //灯杆安装位置
-	LampLat          float64     `gorm:"type:double(17,14)" json:"lampLat"`         //纬度
-	LampLng          float64     `gorm:"type:double(17,14)" json:"lampLng"`         //经度
-	RatedPower       float32     `gorm:"type:double(8,2)" json:"ratedPower"`        //额定功率(LED灯)
-	BrandId          int         `gorm:"type:int" json:"brandId"`                   //设备品牌
-	ModelId          int         `gorm:"type:int" json:"modelId"`                   //设备型号
-	InstallTime      common.Time `gorm:"type:date" json:"installTime"`              //安装时间
-	TenantId         string      `gorm:"type:varchar(12)" json:"tenantId"`          //租户ID
-	CreateTime       time.Time   `gorm:"type:datetime" json:"createTime"`           //新增时间
-	CreateUser       int         `gorm:"type:int" json:"createUser"`                //新增记录操作用户ID
-	UpdateTime       time.Time   `gorm:"type:datetime" json:"updateTime"`           //修改时间
-	UpdateUser       int         `gorm:"type:int" json:"updateUser"`                //修改用户
-	IsDeleted        int         `gorm:"type:int;default 0" json:"isDeleted"`       //是否删除 0=未删除,1=删除
-	Status           int         `gorm:"type:int" json:"status"`                    //状态 0=正常,1=异常
-	Tag              string      `gorm:"type:varchar(255)" json:"tag"`              //标签,(备用,逗号区分)
-	ControlNo        string      `gorm:"type:varchar(10)" json:"controlNo"`         //编号
-	ChannelNum       int         `gorm:"type:int" json:"channelNum"`                //通道号
-	NetworkNum       int         `gorm:"type:int" json:"networkNum"`                //网络号
-	ZigbeeId         int         `gorm:"type:int" json:"zigbeeId"`                  //zigbeeID
-	ZigbeeName       string      `gorm:"type:varchar(10)" json:"zigbeeName"`        //zigbee名称
-	ZigbeeSn         string      `gorm:"type:varchar(10)" json:"zigbeeSn"`          //zigbee编码
-	IsEnable         int         `gorm:"type:int;default 2" json:"isEnable"`        //启用禁用:1启用2禁用
-	IsOnDemand       int         `gorm:"type:int; default 0" json:"isOnDemand"`     //灯控类型:0-普通灯控,1-灯随车走灯控
-}
-
-func (LightControl) TableName() string {
-	return "device_light_control"
-}
-
-func (c *LightControl) Delete() error {
-	return Db.Model(&c).Where("id = ?", c.ID).Updates(map[string]interface{}{"update_time": c.UpdateTime,
-		"update_user": c.UpdateUser, "is_deleted": c.IsDeleted}).Error
-}
-
-func (c LightControl) IsExistedBySN() bool {
-	var count int64
-	_ = Db.Model(&c).Where("sn = ? and is_deleted = ?",
-		c.Sn, c.IsDeleted).Count(&count).Error
-	return count > 0
-}
-
-func (c LightControl) IsExistedByNameAndCode() bool {
-	var devices []LightControl
-	err := Db.Model(&c).Where("pole_sn = ? and is_deleted = ?",
-		c.TenantId, c.IsDeleted).Find(&devices).Error
-	if gorm.ErrRecordNotFound == err {
-		return false
-	}
-	for _, d := range devices {
-		if d.ID != c.ID {
-			return true
-		}
-	}
-	return false
-}
-
-func (c *LightControl) Create() error {
-	return Db.Model(&c).Save(&c).Error
-}
-
-func (c *LightControl) Update() error {
-	return Db.Model(&c).Where(" id = ? ", c.ID).Updates(&c).Error
-}
-
-func (c *LightControl) UpdateEnable() error {
-	return Db.Model(&c).Where(" id = ? ", c.ID).Updates(map[string]interface{}{"is_enable": c.IsEnable}).Error
-}
-
-func (c *LightControl) GetDevice() error {
-	err := Db.Model(&c).Where(" id = ? ", c.ID).First(&c).Error
-	return err
-}
-
-func (c *LightControl) GetDevicesByGroup() ([]LightControl, error) {
-	var devices []LightControl
-	err := Db.Model(&c).Where(" group_id = ? and is_deleted = 0", c.GroupId).Order("create_time asc").Find(&devices).Error
-	return devices, err
-}
-
-func (c LightControl) GetDevices(offset, limit int) ([]LightControl, int64, error) {
-	var devices []LightControl
-	var count int64
-
-	db := Db.Model(&c)
-	if c.Sn != "" {
-		db = db.Where("name like ? or sn like ?", "%"+c.Sn+"%", "%"+c.Sn+"%")
-	}
-	if c.ControlType != 0 {
-		db = db.Where("control_type = ?", c.ControlType)
-	}
-	if c.ZigbeeId != 0 {
-		db = db.Where("zigbee_id = ?", c.ZigbeeId)
-	}
-
-	db = db.Where("is_deleted = 0")
-	db.Count(&count)
-	err := db.Offset(offset).Limit(limit).Order("name asc").Find(&devices).Error
-	return devices, count, err
-}
-
-func (c LightControl) GetAllDevices() ([]LightControl, error) {
-	var devices []LightControl
-	err := Db.Model(&c).Where(" tenant_id = ? and is_deleted = ? ", c.TenantId, c.IsDeleted).Scan(&devices).Error
-	return devices, err
-}
-
-func (c LightControl) GetDevicesByGateway() []LightControl {
-	var devices []LightControl
-	Db.Model(&c).Where(" gateway_id = ? and is_deleted = 0",
-		c.GatewayId).Find(&devices)
-	return devices
-}
-
-func (c LightControl) GetDevicesByLampPole() []LightControl {
-	var devices []LightControl
-	Db.Model(&c).Where("lamp_pole_id = ? and is_deleted = 0",
-		c.LampPoleId).Find(&devices)
-	return devices
-}
-
-func (c LightControl) DeviceCount1() (int64, int64) {
-	var all, fault int64
-	err := Db.Model(&c).Where("is_deleted = 0").Count(&all).Error
-	if err != nil {
-		all = -1
-	}
-	err = Db.Model(&c).Where("is_deleted = 0 and status = 0").Count(&fault).Error
-	if err != nil {
-		fault = -1
-	}
-	return all, fault
-}
-
-func (c LightControl) ListDevices1() []Device {
-	var devices []LightControl
-	Db.Model(&c).Where("is_deleted = 0").Find(&devices)
-	var rsp = make([]Device, 0, len(devices))
-	for _, v := range devices {
-		var d = Device{
-			Lng:          v.LampLng,
-			Lat:          v.LampLat,
-			Status:       v.Status,
-			Name:         v.Name,
-			Code:         v.Sn,
-			LampPoleName: v.LampPoleName,
-		}
-		rsp = append(rsp, d)
-	}
-	return rsp
-}

+ 0 - 149
app/device/dao/manholeCoverDao.go

@@ -1,149 +0,0 @@
-package dao
-
-import (
-	"gorm.io/gorm"
-	"iot_manager_service/util/common"
-	"time"
-)
-
-// ManholeCover 井盖基本信息
-type ManholeCover struct {
-	ID                  int        `gorm:"primary_key" json:"id"`                    //编号
-	ManholeName         string     `gorm:"type:varchar(64)" json:"manholeName"`      //设备名称
-	ManholeSn           string     `gorm:"type:varchar(60)" json:"manholeSn"`        //设备序列号
-	DeviceIMei          string     `gorm:"type:varchar(64)" json:"deviceIMei"`       //IMEI-唯一不允许重复
-	BrandId             int        `gorm:"type:int" json:"brandId"`                  //设备名称
-	ModelId             int        `gorm:"type:int" json:"modelId"`                  //设备型号
-	KindType            int        `gorm:"type:int" json:"kindType"`                 //种类
-	Radius              int        `gorm:"type:int" json:"radius"`                   //半径
-	MaterialQuality     int        `gorm:"type:int" json:"materialQuality"`          //材质
-	InstallLocationType int        `gorm:"type:int" json:"installLocationType"`      //安装位置类型
-	WayName             string     `gorm:"type:varchar(60)" json:"wayName"`          //所属道路
-	InstallTime         *time.Time `gorm:"type:date" json:"installTime"`             //安装时间
-	ProvinceName        string     `gorm:"varchar(12)" json:"provinceName"`          //省份
-	CityName            string     `gorm:"type:varchar(12)" json:"cityName"`         //市
-	DistrictName        string     `gorm:"type:varchar(12)" json:"districtName"`     //区
-	InstallLocation     string     `gorm:"type:varchar(100)" json:"installLocation"` //安装位置
-	Latitude            float64    `gorm:"type:double(17, 14) " json:"latitude"`     //纬度
-	Longitude           float64    `gorm:"type:double(17, 14)  " json:"longitude"`   //经度
-	PhotoUrl            string     `gorm:"type:varchar(255) " json:"photoUrl"`       //照片地址
-	Remark              string     `gorm:"type:varchar(1000)  " json:"remark"`       //备注
-	TenantId            string     `gorm:"type:varchar(12)" json:"tenantId"`         //租户ID
-	CreateTime          time.Time  `gorm:"type:datetime" json:"createTime"`          //新增时间
-	CreateUser          int        `gorm:"type:int" json:"createUser"`               //新增记录操作用户ID
-	UpdateTime          time.Time  `gorm:"type:datetime" json:"updateTime"`          //修改时间
-	UpdateUser          int        `gorm:"type:int" json:"updateUser"`               //修改用户
-	IsDeleted           int        `gorm:"type:int;default 0" json:"isDeleted"`      //是否删除 0=未删除,1=删除
-	Status              int        `gorm:"type:int" json:"status"`                   //状态 0=正常,1=异常
-	Tag                 string     `gorm:"type:varchar(255)" json:"tag"`             //标签,保留字段(逗号区分)
-	Threshold           string     `gorm:"type: varchar(255)" json:"threshold"`      //阈值
-	CameraId            int        `gorm:"type:int" json:"cameraId"`                 //归属摄像机id
-	CameraSn            string     `gorm:"type: varchar(60) " json:"cameraSn"`       //归属摄像机sn
-
-	LeanAngleAlarm int     `json:"leanAngleAlarm"`                         //告警倾斜
-	BatteryAlarm   float64 `gorm:"type: varchar(60) " json:"batteryAlarm"` //告警电压
-	MinTemp        float64 `gorm:"type: varchar(60) " json:"minTemp"`      //低温阈值
-	MaxTemp        float64 `gorm:"type: varchar(60) " json:"maxTemp"`      //高温阈值
-
-	LeanAngle    int         `json:"leanAngle"`                         //倾斜角度
-	Temperature  float64     `json:"temperature"`                       //温度
-	BatteryLevel float64     `json:"batteryLevel"`                      //电压
-	Csq          int         `json:"csq"`                               //信号
-	LastPostTime common.Time `gorm:"type:datetime" json:"lastPostTime"` //最后上报时间
-}
-
-func (ManholeCover) TableName() string {
-	return "device_manhole_cover"
-}
-
-func (c ManholeCover) Delete() error {
-	return Db.Model(&c).Where("id = ?", c.ID).Updates(map[string]interface{}{"update_time": c.UpdateTime,
-		"update_user": c.UpdateUser, "is_deleted": c.IsDeleted}).Error
-}
-
-func (c ManholeCover) IsExistedBySN() bool {
-	var count int64
-	_ = Db.Model(&c).Where("  manhole_sn = ? and is_deleted = ?",
-		c.ManholeSn, c.IsDeleted).Count(&count).Error
-	return count > 0
-}
-
-func (c ManholeCover) IsExistedByNameAndCode() bool {
-	var devices []ManholeCover
-	err := Db.Model(&c).Where(" manhole_sn = ? and is_deleted = ?",
-		c.ManholeSn, c.IsDeleted).Find(&devices).Error
-	//如果查询不到,返回相应的错误
-	if gorm.ErrRecordNotFound == err {
-		return false
-	}
-	for _, d := range devices {
-		if d.ID != c.ID {
-			return true
-		}
-	}
-	return false
-}
-
-func (c *ManholeCover) Create() error {
-	return Db.Model(&c).Save(&c).Error
-}
-
-func (c *ManholeCover) Update() error {
-	return Db.Model(&c).Where(" id = ? ", c.ID).Updates(&c).Error
-}
-
-func (c *ManholeCover) GetDevice() error {
-	err := Db.Model(&c).Where(" id = ? ", c.ID).Scan(&c).Error
-	return err
-}
-
-func (c ManholeCover) GetDevices(offset, limit int) ([]ManholeCover, int64, error) {
-	var devices []ManholeCover
-	var count int64
-	db := Db.Model(&c).Where(" manhole_name like ? and is_deleted = 0", "%"+c.ManholeName+"%")
-	db.Count(&count)
-	err := db.Offset(offset).Limit(limit).Find(&devices).Error
-	return devices, count, err
-}
-
-func (c ManholeCover) GetAllDevices() ([]*ManholeCover, error) {
-	var devices []*ManholeCover
-	err := Db.Model(&c).Where(" tenant_id = ? and is_deleted = ? ", c.TenantId, c.IsDeleted).Scan(&devices).Error
-	return devices, err
-}
-
-func (c ManholeCover) FindDeviceIdByImei(imei string) (int, error) {
-	var device ManholeCover
-	err := Db.Raw("SELECT * FROM `device_manhole_cover` WHERE `device_i_mei` = ? AND `is_deleted` = '0' limit 1", imei).First(&device).Error
-	return device.ID, err
-}
-
-func (c ManholeCover) DeviceCount1() (int64, int64) {
-	var all, fault int64
-	err := Db.Model(&c).Where("is_deleted = 0").Count(&all).Error
-	if err != nil {
-		all = -1
-	}
-	err = Db.Model(&c).Where("is_deleted = 0 and status = 0").Count(&fault).Error
-	if err != nil {
-		fault = -1
-	}
-	return all, fault
-}
-func (c ManholeCover) ListDevices1() []Device {
-	var devices []ManholeCover
-	Db.Model(&c).Where("is_deleted = 0").Find(&devices)
-	var rsp = make([]Device, 0, len(devices))
-	for _, v := range devices {
-		var d = Device{
-			Lng:          v.Longitude,
-			Lat:          v.Latitude,
-			Status:       v.Status,
-			Name:         v.ManholeName,
-			Code:         v.ManholeSn,
-			LampPoleName: v.WayName,
-		}
-		rsp = append(rsp, d)
-	}
-	return rsp
-}

+ 0 - 79
app/device/dao/onDemandGroupDao.go

@@ -1,79 +0,0 @@
-package dao
-
-import (
-	"gorm.io/gorm"
-	"time"
-)
-
-// OnDemandGroup 灯随车走分组
-type OnDemandGroup struct {
-	ID                int       `gorm:"primary_key" json:"id"`                 //编号
-	PoleGroupName     string    `gorm:"type:varchar(64)" json:"poleGroupName"` //分组名称
-	SN                string    `gorm:"type:varchar(60)" json:"sn"`            //SN
-	LampPoleCount     int       `gorm:"type:int" json:"lampPoleCount"`         //灯杆数量
-	LightingNum       int       `gorm:"type:int" json:"lightingNum"`           //亮灯数量
-	BeforeLightingNum int       `gorm:"type:int" json:"beforeLightingNum"`     //提前亮灯数
-	OutTimes          int       `gorm:"type:int" json:"outTimes"`              //延迟时间
-	TenantId          string    `gorm:"type:varchar(12)" json:"tenantId"`      //租户ID
-	CreateTime        time.Time `gorm:"type:datetime" json:"createTime"`       //新增时间
-	CreateUser        int       `gorm:"type:int" json:"createUser"`            //新增记录操作用户ID
-	UpdateTime        time.Time `gorm:"type:datetime" json:"updateTime"`       //修改时间
-	UpdateUser        int       `gorm:"type:int" json:"updateUser"`            //修改用户
-	IsDeleted         int       `gorm:"type:int;default 0" json:"isDeleted"`   //是否删除 0=未删除,1=删除
-}
-
-func (OnDemandGroup) TableName() string {
-	return "device_on_demand_group"
-}
-
-func (c *OnDemandGroup) Delete() error {
-	return Db.Model(&c).Where("id = ?", c.ID).Updates(map[string]interface{}{"update_time": c.UpdateTime,
-		"update_user": c.UpdateUser, "is_deleted": c.IsDeleted}).Error
-}
-
-func (c OnDemandGroup) IsExistedBySN() bool {
-	var count int64
-	_ = Db.Model(&c).Where(" sn = ? and is_deleted = ?",
-		c.SN, c.IsDeleted).Count(&count).Error
-	return count > 0
-}
-
-func (c OnDemandGroup) IsExistedByNameAndCode() bool {
-	var devices []Gateway
-	err := Db.Model(&c).Where("gateway_sn = ? and is_deleted = ?",
-		c.TenantId, c.IsDeleted).Find(&devices).Error
-	if gorm.ErrRecordNotFound == err {
-		return false
-	}
-	for _, d := range devices {
-		if d.ID != c.ID {
-			return true
-		}
-	}
-	return false
-}
-
-func (c *OnDemandGroup) Create() error {
-	return Db.Model(&c).Save(&c).Error
-}
-
-func (c *OnDemandGroup) Update() error {
-	return Db.Model(&c).Where(" id = ? ", c.ID).Updates(&c).Error
-}
-
-func (c *OnDemandGroup) GetDevice() error {
-	err := Db.Model(&c).Where(" id = ? ", c.ID).First(&c).Error
-	return err
-}
-
-func (c OnDemandGroup) GetDevices(offset, limit int) ([]OnDemandGroup, error) {
-	var devices []OnDemandGroup
-	err := Db.Model(&c).Where("(pole_group_name like ? or sn like ?) and is_deleted = 0", "%"+c.PoleGroupName+"%", "%"+c.PoleGroupName+"%").Offset(offset).Limit(limit).Find(&devices).Error
-	return devices, err
-}
-
-func (c OnDemandGroup) GetAllDevices() ([]*OnDemandGroup, error) {
-	var devices []*OnDemandGroup
-	err := Db.Model(&c).Where(" tenant_id = ? and is_deleted = ? ", c.TenantId, c.IsDeleted).Scan(&devices).Error
-	return devices, err
-}

+ 0 - 86
app/device/dao/onDemandSensorDao.go

@@ -1,86 +0,0 @@
-package dao
-
-import (
-	"gorm.io/gorm"
-	"time"
-)
-
-// OnDemandSensor 灯随车走
-type OnDemandSensor struct {
-	ID          int       `gorm:"primary key" json:"id"`                //编号
-	Name        string    `gorm:"type:varchar(64)" json:"name"`         //名称
-	SN          string    `gorm:"type:varchar(60)" json:"sn"`           //唯一编码
-	BrandID     int       `gorm:"type:int" json:"brandId"`              //设备名称
-	ModelID     int       `gorm:"type:int" json:"modelId"`              //设备型号
-	LampPoleID  int       `gorm:"type:int" json:"lampPoleId"`           //所属灯杆
-	SensorPhoto string    `gorm:"type:varchar(255)" json:"sensorPhoto"` //传感器照片
-	InstallTime time.Time `gorm:"type:date" json:"installTime"`         //安装时间
-	TenantId    string    `gorm:"type:varchar(12)" json:"tenantId"`     //租户ID
-	CreateTime  time.Time `gorm:"type:datetime" json:"createTime"`      //新增时间
-	CreateUser  int       `gorm:"type:int" json:"createUser"`           //新增记录操作用户ID
-	UpdateTime  time.Time `gorm:"type:datetime" json:"updateTime"`      //修改时间
-	UpdateUser  int       `gorm:"type:int" json:"updateUser"`           //修改用户
-	IsDeleted   int       `gorm:"type:int; default 0" json:"isDeleted"` //是否删除:0=未删除,1=删除
-	Status      int       `gorm:"type:int; default 0" json:"status"`    //状态0=正常,1=异常
-}
-
-func (OnDemandSensor) TableName() string {
-	return "device_on_demand_sensor"
-}
-
-func (c OnDemandSensor) Delete() error {
-	return Db.Model(&c).Where("id = ?", c.ID).Updates(map[string]interface{}{"update_time": c.UpdateTime,
-		"update_user": c.UpdateUser, "is_deleted": c.IsDeleted}).Error
-}
-
-func (c OnDemandSensor) IsExistedBySN() bool {
-	var count int64
-	_ = Db.Model(&c).Where("  sn = ? and is_deleted = ?",
-		c.SN, c.IsDeleted).Count(&count).Error
-	return count > 0
-}
-
-func (c OnDemandSensor) IsExistedByNameAndCode() bool {
-	var devices []OnDemandSensor
-	err := Db.Model(&c).Where("sn = ? and is_deleted = ?",
-		c.SN, c.IsDeleted).Find(&devices).Error
-	//如果查询不到,返回相应的错误
-	if gorm.ErrRecordNotFound == err {
-		return false
-	}
-	for _, d := range devices {
-		if d.ID != c.ID {
-			return true
-		}
-	}
-	return false
-}
-
-func (c *OnDemandSensor) Create() error {
-	return Db.Model(&c).Save(&c).Error
-}
-
-func (c *OnDemandSensor) Update() error {
-	return Db.Model(&c).Where(" id = ? ", c.ID).Updates(&c).Error
-}
-
-func (c *OnDemandSensor) GetDevice() error {
-	err := Db.Model(&c).Where(" id = ? ", c.ID).Scan(&c).Error
-	return err
-}
-
-func (c OnDemandSensor) GetDevices(offset, limit int) ([]OnDemandSensor, int64, error) {
-	var devices []OnDemandSensor
-	var count int64
-	db := Db.Model(&c).Where(" name like ? ", "%"+c.Name+"%")
-	db.Count(&count)
-	err := db.Offset(offset).Limit(limit).Find(&devices).Error
-	return devices, count, err
-}
-
-func (c OnDemandSensor) GetAllDevices() ([]*OnDemandSensor, error) {
-	var devices []*OnDemandSensor
-	err := Db.Model(&c).Where(" tenant_id = ? and is_deleted = ? ", c.TenantId,
-		c.IsDeleted).Scan(&devices).Error
-	return devices, err
-}

+ 0 - 168
app/device/dao/optoSensoDao.go

@@ -1,168 +0,0 @@
-package dao
-
-import (
-	"gorm.io/gorm"
-	"iot_manager_service/util/common"
-	"time"
-)
-
-// OptoSensor 集控器
-type OptoSensor struct {
-	ID               int         `gorm:"primary_key" json:"id"`                     //编号
-	Name             string      `gorm:"type:varchar(64)" json:"name"`              //名称
-	Sn               string      `gorm:"type:varchar(60)" json:"sn"`                //唯一编码
-	LampPoleId       int         `gorm:"type:int" json:"lampPoleId"`                //灯杆id
-	LampPoleName     string      `gorm:"type:varchar(64)" json:"lampPoleName"`      //灯杆名称
-	LampPoleSn       string      `gorm:"type:varchar(64)" json:"lampPoleSn"`        //灯杆编码
-	LampPoleLocation string      `gorm:"type:varchar(255)" json:"lampPoleLocation"` //灯杆安装位置
-	LampLng          float64     `gorm:"type:double(17, 14) " json:"lampLng"`       //经度
-	LampLat          float64     `gorm:"type:double(17, 14)  " json:"lampLat"`      //纬度
-	BrandId          int         `gorm:"type:int" json:"brandId"`                   //设备名称
-	ModelId          int         `gorm:"type:int" json:"modelId"`                   //设备型号
-	GatewayId        int         `gorm:"type:int" json:"gatewayId"`                 //所属网关id
-	InstallTime      common.Time `gorm:"type:date" json:"installTime"`              //安装时间
-	IPAddress        string      `gorm:"type:varchar(64)" json:"ipAddress"`         //IP地址-备用
-	IsDefault        int         `gorm:"type:int;default 0" json:"isDefault"`       //是否设为首页默认展示 0=不展示,1=设置展示
-	TenantId         string      `gorm:"type:varchar(12)" json:"tenantId"`          //租户ID
-	CreateTime       time.Time   `gorm:"type:datetime" json:"createTime"`           //新增时间
-	CreateUser       int         `gorm:"type:int" json:"createUser"`                //新增记录操作用户ID
-	UpdateTime       time.Time   `gorm:"type:datetime" json:"updateTime"`           //修改时间
-	UpdateUser       int         `gorm:"type:int" json:"updateUser"`                //修改用户
-	IsDeleted        int         `gorm:"type:int;default 0" json:"isDeleted"`       //是否删除 0=未删除,1=删除
-	Status           int         `gorm:"type:int" json:"status"`                    //状态 0=正常,1=异常
-	Tag              string      `gorm:"type:varchar(255)" json:"tag"`              //标签,保留字段(逗号区分)
-}
-
-func (OptoSensor) TableName() string {
-	return "device_opto_sensor"
-}
-
-func (c OptoSensor) Delete() error {
-	return Db.Model(&c).Where("id = ?", c.ID).Updates(map[string]interface{}{"update_time": c.UpdateTime,
-		"update_user": c.UpdateUser, "is_deleted": c.IsDeleted}).Error
-}
-
-func (c OptoSensor) IsExistedBySN() bool {
-	var count int64
-	_ = Db.Model(&c).Where("  sn = ? and is_deleted = ?",
-		c.Sn, c.IsDeleted).Count(&count).Error
-	return count > 0
-}
-
-func (c OptoSensor) IsExistedByNameAndCode() bool {
-	var devices []Zigbee
-	err := Db.Model(&c).Where(" sn = ? and is_deleted = ?",
-		c.Sn, c.IsDeleted).Find(&devices).Error
-	//如果查询不到,返回相应的错误
-	if gorm.ErrRecordNotFound == err {
-		return false
-	}
-	for _, d := range devices {
-		if d.ID != c.ID {
-			return true
-		}
-	}
-	return false
-}
-
-func (c *OptoSensor) Create() error {
-	return Db.Model(&c).Save(&c).Error
-}
-
-func (c *OptoSensor) Update() error {
-	return Db.Model(&c).Where(" id = ? ", c.ID).Updates(&c).Error
-}
-
-func (c *OptoSensor) GetDevice() error {
-	err := Db.Model(&c).Where(" id = ? ", c.ID).Find(&c).Error
-	return err
-}
-
-func (c OptoSensor) GetDevices(offset, limit int) ([]OptoSensor, int64, error) {
-	var devices []OptoSensor
-	var count int64
-	db := Db.Model(&c).Where("is_deleted=0 and name like ? ", "%"+c.Name+"%")
-	db.Count(&count)
-	err := db.Offset(offset).Limit(limit).Find(&devices).Error
-	return devices, count, err
-}
-
-func (c OptoSensor) GetAllDevices() ([]*OptoSensor, error) {
-	var devices []*OptoSensor
-	err := Db.Model(&c).Where(" tenant_id = ? and is_deleted = ? ", c.TenantId, c.IsDeleted).Scan(&devices).Error
-	return devices, err
-}
-
-func (c OptoSensor) GetDevicesByGateway() []OptoSensor {
-	var devices []OptoSensor
-	Db.Model(&c).Where(" gateway_id = ? and is_deleted = 0",
-		c.GatewayId).Find(&devices)
-	return devices
-}
-
-func (c OptoSensor) GetDevicesByLampPole() []OptoSensor {
-	var devices []OptoSensor
-	Db.Model(&c).Where("lamp_pole_id = ? and is_deleted = 0",
-		c.LampPoleId).Find(&devices)
-	return devices
-}
-
-func (c OptoSensor) GetDevicesByTenantId() []OptoSensor {
-	var devices []OptoSensor
-	Db.Model(&c).Where("tenant_id = ? and is_deleted = 0",
-		c.TenantId).Find(&devices)
-	return devices
-}
-
-func (c OptoSensor) GetAll() []*OptoSensor {
-	var devices []*OptoSensor
-	Db.Model(&c).Where("is_deleted = 0").Find(&devices)
-	return devices
-}
-
-func (c OptoSensor) getList(optoSensor OptoSensor) []OptoSensorVO {
-	var optoSensorVO []OptoSensorVO
-	tenantId := optoSensor.TenantId
-	if tenantId == "" {
-		tenantId = c.TenantId
-	}
-	optoSensor.TenantId = tenantId
-	where := ""
-	if optoSensor.IsDefault == 1 {
-		where = "and a.is_default=1"
-	}
-	Db.Model(&c).Raw("SELECT a.*, v3.id brand, v4.id model, lamp.district_name FROM device_opto_sensor a LEFT JOIN device_vendor v3 ON v3.id = a.brand_id LEFT JOIN device_vendor v4 ON v4.id = a.model_id LEFT JOIN device_lamp_pole lamp ON lamp.id = a.lamp_pole_id WHERE a.is_deleted = 0 " + where).Scan(&optoSensorVO)
-
-	return optoSensorVO
-}
-
-func (c OptoSensor) DeviceCount1() (int64, int64) {
-	var all, fault int64
-	err := Db.Model(&c).Where("is_deleted = 0").Count(&all).Error
-	if err != nil {
-		all = -1
-	}
-	err = Db.Model(&c).Where("is_deleted = 0 and status = 0").Count(&fault).Error
-	if err != nil {
-		fault = -1
-	}
-	return all, fault
-}
-
-func (c OptoSensor) ListDevices1() []Device {
-	var devices []OptoSensor
-	Db.Model(&c).Where("is_deleted = 0").Find(&devices)
-	var rsp = make([]Device, 0, len(devices))
-	for _, v := range devices {
-		var d = Device{
-			Lng:          v.LampLng,
-			Lat:          v.LampLat,
-			Status:       v.Status,
-			Name:         v.Name,
-			Code:         v.Sn,
-			LampPoleName: v.LampPoleName,
-		}
-		rsp = append(rsp, d)
-	}
-	return rsp
-}

+ 0 - 165
app/device/dao/switchBoxDao.go

@@ -1,165 +0,0 @@
-package dao
-
-import (
-	"gorm.io/gorm"
-	"iot_manager_service/util/common"
-	"time"
-)
-
-// SwitchBox 供电箱
-type SwitchBox struct {
-	ID             int         `gorm:"primary_key" json:"id"`                             //编号
-	BoxName        string      `gorm:"type:varchar(64)" json:"boxName"`                   //供电箱名称
-	BoxSN          string      `gorm:"type:varchar(60)" json:"boxSn"`                     //设备序列号
-	BrandId        int         `gorm:"type:int" json:"brandId"`                           //品牌
-	ModelId        int         `gorm:"type:int" json:"modelId"`                           //配电箱型号
-	TransformerId  int         `gorm:"type:int" json:"transformerId"`                     //变压器ID
-	TransformerNum string      `gorm:"type:varchar(60)" json:"transformerNum"`            //变压器出线口编号
-	RatedPower     float32     `gorm:"type:double(8, 2) default 0.00 " json:"ratedPower"` //功率
-	ProvinceName   string      `gorm:" type:varchar(12)" json:"provinceName"`             //省份
-	CityName       string      `gorm:"type:varchar(12)" json:"cityName"`                  //市
-	DistrictName   string      `gorm:"type:varchar(12)" json:"districtName"`              //区
-	BoxLocation    string      `gorm:"type:varchar(100)" json:"boxLocation"`              //详细位置
-	PoleLng        float64     `gorm:"type:double(17, 14) " json:"poleLng"`               //经度
-	PoleLat        float64     `gorm:"type:double(17, 14)  " json:"poleLat"`              //纬度
-	MonitorAddress string      `gorm:"type:varchar(255)   " json:"monitorAddress"`        //监控地址
-	InstallTime    common.Time `gorm:"type:date" json:"installTime"`                      //安装时间
-	TenantId       string      `gorm:"type:varchar(12)" json:"tenantId"`                  //租户id
-	CreateTime     time.Time   `gorm:"type:datetime" json:"createTime"`                   //新增时间
-	CreateUser     int         `gorm:"type:int" json:"createUser"`                        //新增记录操作用户ID
-	UpdateTime     time.Time   `gorm:"type:datetime" json:"updateTime"`                   //修改时间
-	UpdateUser     int         `gorm:"type:int" json:"updateUser"`                        //修改用户
-	IsDeleted      int         `gorm:"type:int;default 0" json:"isDeleted"`               //是否删除 0=未删除,1=删除
-	Status         int         `gorm:"type:int" json:"status"`                            //状态 0=正常,1=异常
-	Tag            string      `gorm:"type:varchar(255)" json:"tag"`                      //标签,保留字段(逗号区分)
-	BoxPhotoUrl    string      `gorm:"type:varchar(255)" json:"boxPhotoUrl"`              //供电箱照片地址
-
-	CountLampPole int64 `gorm:"-" json:"countLampPole" comment:"关联灯杆数" default:0`
-}
-
-func (SwitchBox) TableName() string {
-	return "device_switch_box"
-}
-
-func (c SwitchBox) Delete() error {
-	return Db.Model(&c).Where("id = ?", c.ID).Updates(map[string]interface{}{"update_time": c.UpdateTime,
-		"update_user": c.UpdateUser, "is_deleted": c.IsDeleted}).Error
-}
-
-func (c SwitchBox) IsExistedBySN() bool {
-	var count int64
-	_ = Db.Model(&c).Where("  box_sn = ? and is_deleted = ?",
-		c.BoxSN, c.IsDeleted).Count(&count).Error
-	return count > 0
-}
-
-func (c SwitchBox) IsExistedByNameAndCode() bool {
-	var devices []SwitchBox
-	err := Db.Model(&c).Where(" box_sn = ? and is_deleted = ?",
-		c.BoxSN, c.IsDeleted).Find(&devices).Error
-	//如果查询不到,返回相应的错误
-	if gorm.ErrRecordNotFound == err {
-		return false
-	}
-	for _, d := range devices {
-		if d.ID != c.ID {
-			return true
-		}
-	}
-	return false
-}
-
-func (c *SwitchBox) Create() error {
-	return Db.Model(&c).Save(&c).Error
-}
-
-func (c *SwitchBox) Update() error {
-	return Db.Model(&c).Where(" id = ? ", c.ID).Updates(&c).Error
-}
-
-func (c *SwitchBox) GetDevice() error {
-	err := Db.Model(&c).Where(" id = ? ", c.ID).Scan(&c).Error
-	return err
-}
-
-func (c SwitchBox) GetDevices(offset, limit int) ([]SwitchBox, int64, error) {
-	var devices []SwitchBox
-	var count int64
-	db := Db.Model(&c).Where("(box_name like ?) and is_deleted = 0",
-		"%"+c.BoxName+"%")
-	db.Count(&count)
-	err := db.Offset(offset).Limit(limit).Find(&devices).Error
-	return devices, count, err
-}
-
-// 得到关联设备 2022-12-08 dsx
-func (c SwitchBox) GetDeviceCount() (int64, error) {
-	var count int64
-	err := Db.Model(&c).Where("(transformer_id = ?) and is_deleted = 0",
-		c.TransformerId).Count(&count).Error
-	return count, err
-}
-
-func (c SwitchBox) GetAllDevices() ([]*SwitchBox, error) {
-	var devices []*SwitchBox
-	err := Db.Model(&c).Where(" tenant_id = ? and is_deleted = ? ", c.TenantId, c.IsDeleted).Scan(&devices).Error
-	return devices, err
-}
-
-// CountFault SELECT COUNT(id) FROM `device_lamp_pole` WHERE `is_deleted` = 0 AND `status` = 0;
-func (c SwitchBox) CountFault() (int64, error) {
-	var i int64
-	err := Db.Model(&c).Where(map[string]interface{}{"is_deleted": "0", "status": "0"}).Count(&i).Error
-	return i, err
-}
-
-func (c SwitchBox) ListDevices() ([]Device, int64, error) {
-	var devices []SwitchBox
-	result := Db.Model(&c).Where("is_deleted = 0").Find(&devices)
-	var rsp = make([]Device, 0, len(devices))
-	for _, v := range devices {
-		var d = Device{
-			Lng:    v.PoleLng,
-			Lat:    v.PoleLat,
-			Status: v.Status,
-			Name:   v.BoxName,
-			Code:   v.BoxSN,
-			Model:  "型号",
-		}
-		rsp = append(rsp, d)
-	}
-	var i int64
-	result.Count(&i)
-	return rsp, i, result.Error
-}
-
-func (c SwitchBox) DeviceCount1() (int64, int64) {
-	var all, fault int64
-	err := Db.Model(&c).Where("is_deleted = 0").Count(&all).Error
-	if err != nil {
-		all = -1
-	}
-	err = Db.Model(&c).Where("is_deleted = 0 and status = 0").Count(&fault).Error
-	if err != nil {
-		fault = -1
-	}
-	return all, fault
-}
-
-func (c SwitchBox) ListDevices1() []Device {
-	var devices []SwitchBox
-	Db.Model(&c).Where("is_deleted = 0").Find(&devices)
-	var rsp = make([]Device, 0, len(devices))
-	for _, v := range devices {
-		var d = Device{
-			Lng:    v.PoleLng,
-			Lat:    v.PoleLat,
-			Status: v.Status,
-			Name:   v.BoxName,
-			Code:   v.BoxSN,
-			Model:  "模型",
-		}
-		rsp = append(rsp, d)
-	}
-	return rsp
-}

+ 0 - 21
app/device/dao/tenantCodeDao.go

@@ -1,21 +0,0 @@
-package dao
-
-type TenantCode struct {
-	ID       int     `gorm:"primary_key" json:"id" COMMENT "编号"`
-	TenantId string  `gorm:"varchar(12)"  json:"tenantId" COMMENT "租户ID"`
-	CityCode string  `gorm:"varchar(6)" json:"cityCode"  COMMENT "城市行政编码"`
-	CityName string  `gorm:"varchar(255)" json:"cityName"  COMMENT "城市名称"`
-	CityLng  float64 `gorm:"double(18,14)" json:"cityLng"  COMMENT "经度"`
-	CityLat  float64 `gorm:"double(18,14)" json:"cityLat" COMMENT "纬度"`
-}
-
-func (TenantCode) TableName() string {
-	return "tenant_code"
-}
-
-//根据租户得到位置记录
-func (c *TenantCode) GetTenantCode() (TenantCode, error) {
-	var tenantCode TenantCode
-	err := Db.Model(&c).Where(" tenant_id = ?", c.TenantId).Find(&tenantCode).Error
-	return tenantCode, err
-}

+ 0 - 52
app/device/dao/timeConditionDao.go

@@ -1,52 +0,0 @@
-package dao
-
-import "time"
-
-type TimeCondition struct {
-	ID         int       `gorm:"primary key" json:"id"`               //编号
-	LightId    int       `gorm:"type:int;default 0" json:"lightId"`   //照明策略id
-	StartTime  string    `gorm:"type:varchar(60)" json:"startTime"`   //开始时间
-	EndTime    string    `gorm:"type:varchar(60)" json:"endTime"`     //结束时间
-	Luminance  int       `gorm:"type:int " json:"luminance"`          //开灯亮度
-	Remark     string    `gorm:"type:varchar(255)" json:"remark"`     //备注
-	CreateTime time.Time `gorm:"type:datetime" json:"createTime"`     //新增时间
-	CreateUser int       `gorm:"type:int" json:"createUser"`          //新增记录操作用户ID
-	UpdateTime time.Time `gorm:"type:datetime" json:"updateTime"`     //修改时间
-	UpdateUser int       `gorm:"type:int" json:"updateUser"`          //修改用户
-	IsDeleted  int       `gorm:"type:int;default 0" json:"isDeleted"` //是否删除 0=未删除,1=删除
-	Sunshine   int       `gorm:"type:int;default 1" json:"sunshine"`  //日出日落 设置 2=开启,1=不开启
-}
-
-func (TimeCondition) TableName() string {
-	return "strategy_time_condition"
-}
-
-func (c *TimeCondition) Get() error {
-	return Db.Model(&c).Where("id = ? and is_deleted = 0", c.ID).Find(&c).Error
-}
-
-func (c *TimeCondition) BatchGet(ids []int) ([]TimeCondition, error) {
-	var conditions []TimeCondition
-	err := Db.Model(&c).Where("id in ? and is_deleted = 0", ids).Find(&conditions).Error
-	return conditions, err
-}
-
-func (c *TimeCondition) GetByLightId() ([]TimeCondition, error) {
-	var conditions []TimeCondition
-	err := Db.Model(&c).Where("light_id = ? and is_deleted = 0", c.LightId).Find(&conditions).Error
-	return conditions, err
-}
-
-func (c *TimeCondition) GetAll() ([]TimeCondition, error) {
-	var conditions []TimeCondition
-	err := Db.Model(&c).Find(&conditions).Error
-	return conditions, err
-}
-
-func (c *TimeCondition) Save() error {
-	return Db.Model(&c).Save(&c).Error
-}
-
-func (c *TimeCondition) Update() error {
-	return Db.Model(&c).Updates(&c).Error
-}

+ 0 - 90
app/device/dao/transformerDao.go

@@ -1,90 +0,0 @@
-package dao
-
-import (
-	"gorm.io/gorm"
-	"time"
-)
-
-// Transformer 变压器
-type Transformer struct {
-	ID              int        `gorm:"primary_key" json:"id"`                             //编号
-	TransName       string     `gorm:"type:varchar(60)" json:"transName"`                 //变压器名称
-	TransSN         string     `gorm:"type:varchar(60)" json:"transSn"`                   //设备序列号
-	RatedPower      float32    `gorm:"type:double(8, 2) default 0.00 " json:"ratedPower"` //功率
-	ProvinceName    string     `gorm:" varchar(12)" json:"provinceName"`                  //省份
-	CityName        string     `gorm:"type:varchar(12)" json:"cityName"`                  //市
-	DistrictName    string     `gorm:"type:varchar(12)" json:"districtName"`              //区
-	InstallLocation string     `gorm:"type:varchar(100)" json:"installLocation"`          //详细位置
-	PoleLng         float64    `gorm:"type:double(17, 14) " json:"poleLng"`               //经度
-	PoleLat         float64    `gorm:"type:double(17, 14)  " json:"poleLat"`              //纬度
-	TransPhotoUrl   string     `gorm:"type:varchar(255)" json:"transPhotoUrl"`            //变压器照片地址
-	InstallTime     *time.Time `gorm:"type:date" json:"installTime"`                      //安装时间
-	TenantId        string     `gorm:"type:varchar(12)" json:"tenantId"`                  //租户id
-	CreateTime      time.Time  `gorm:"type:datetime" json:"createTime"`                   //新增时间
-	CreateUser      int        `gorm:"type:int" json:"createUser"`                        //新增记录操作用户ID
-	UpdateTime      time.Time  `gorm:"type:datetime" json:"updateTime"`                   //修改时间
-	UpdateUser      int        `gorm:"type:int" json:"updateUser"`                        //修改用户
-	IsDeleted       int        `gorm:"type:int;default 0" json:"isDeleted"`               //是否删除 0=未删除,1=删除
-	Status          int        `gorm:"type:int" json:"status"`                            //状态 0=正常,1=异常
-	CountNum        int64      `gorm:"-" json:"countNum"`                                 //关联供电箱数量
-}
-
-func (Transformer) TableName() string {
-	return "device_transformer"
-}
-
-func (c Transformer) Delete() error {
-	return Db.Model(&c).Where("id = ?", c.ID).Updates(map[string]interface{}{"update_time": c.UpdateTime,
-		"update_user": c.UpdateUser, "is_deleted": c.IsDeleted}).Error
-}
-
-func (c Transformer) IsExistedBySN() bool {
-	var count int64
-	_ = Db.Model(&c).Where("  trans_sn = ? and is_deleted = ?",
-		c.TransSN, c.IsDeleted).Count(&count).Error
-	return count > 0
-}
-
-func (c Transformer) IsExistedByNameAndCode() bool {
-	var devices []Transformer
-	err := Db.Model(&c).Where(" trans_sn = ? and is_deleted = ?",
-		c.TransSN, c.IsDeleted).Find(&devices).Error
-	//如果查询不到,返回相应的错误
-	if gorm.ErrRecordNotFound == err {
-		return false
-	}
-	for _, d := range devices {
-		if d.ID != c.ID {
-			return true
-		}
-	}
-	return false
-}
-
-func (c *Transformer) Create() error {
-	return Db.Model(&c).Save(&c).Error
-}
-
-func (c *Transformer) Update() error {
-	return Db.Model(&c).Where(" id = ? ", c.ID).Updates(&c).Error
-}
-
-func (c *Transformer) GetDevice() error {
-	err := Db.Model(&c).Where(" id = ? ", c.ID).Scan(&c).Error
-	return err
-}
-
-func (c Transformer) GetDevices(offset, limit int) ([]Transformer, int64, error) {
-	var count int64
-	var devices []Transformer
-	db := Db.Model(&c).Where(" trans_name like ? and is_deleted = 0", "%"+c.TransName+"%")
-	db.Count(&count)
-	err := db.Offset(offset).Limit(limit).Find(&devices).Error
-	return devices, count, err
-}
-
-func (c Transformer) GetAllDevices() ([]*Transformer, error) {
-	var devices []*Transformer
-	err := Db.Model(&c).Where(" tenant_id = ? and is_deleted = ? ", c.TenantId, c.IsDeleted).Scan(&devices).Error
-	return devices, err
-}

+ 0 - 74
app/device/dao/venderDao.go

@@ -1,74 +0,0 @@
-package dao
-
-import (
-	"time"
-)
-
-// DeviceVendor 厂家
-type DeviceVendor struct {
-	ID          int       `gorm:"primary_key" json:"id"`                //编号
-	VendorType  int       `gorm:"int" json:"vendorType"`                //类型:1-厂家名称,2-品牌,3-型号
-	VendorValue string    `gorm:"type:varchar(200)" json:"vendorValue"` //值
-	ParentId    int       `gorm:"type:int" json:"parentId"`             //父id,厂家为-1
-	DeviceType  int       `gorm:"type:int" json:"deviceType"`           //设备类型
-	TenantId    string    `gorm:"type:varchar(12)" json:"tenantId"`     //租户id
-	CreateTime  time.Time `gorm:"type:datetime" json:"createTime"`      //新增时间
-	CreateUser  int       `gorm:"type:int" json:"createUser"`           //新增记录操作用户ID
-	UpdateTime  time.Time `gorm:"type:datetime" json:"updateTime"`      //修改时间
-	UpdateUser  int       `gorm:"type:int" json:"updateUser"`           //修改用户
-	IsDeleted   int       `gorm:"type:int" json:"isDeleted"`            //是否删除 0=未删除,1=删除
-}
-
-func (DeviceVendor) TableName() string {
-	return "device_vendor"
-}
-
-func (c *DeviceVendor) GetVendor() ([]DeviceVendor, error) {
-	var vendors []DeviceVendor
-	err := Db.Model(&c).Select("id, parent_id, vendor_value").
-		Where(" vendor_type = 1 and device_type = ? and is_deleted = 0 and tenant_id = ?", c.DeviceType, c.TenantId).
-		Find(&vendors).Error
-	return vendors, err
-}
-
-func (c *DeviceVendor) GetBrand() ([]DeviceVendor, error) {
-	var vendors []DeviceVendor
-	err := Db.Model(&c).Select("id, parent_id, vendor_value").
-		Where(" vendor_type = 2 and device_type = ? and is_deleted = 0 and tenant_id = ?", c.DeviceType, c.TenantId).Find(&vendors).Error
-	return vendors, err
-}
-
-func (c *DeviceVendor) GetModel() ([]DeviceVendor, error) {
-	var vendors []DeviceVendor
-	if c.ParentId > 0 {
-		err := Db.Model(&c).Select("id, parent_id, vendor_value").
-			Where(" vendor_type = 3 and device_type = ? and is_deleted = 0 and tenant_id = ? and parent_id = ?",
-				c.DeviceType, c.TenantId, c.ParentId).Find(&vendors).Error
-		return vendors, err
-	} else {
-		err := Db.Model(&c).Select("id, parent_id, vendor_value").
-			Where(" vendor_type = 3 and device_type = ? and is_deleted = 0 and tenant_id = ?", c.DeviceType, c.TenantId).Find(&vendors).Error
-		return vendors, err
-	}
-
-}
-
-func (c DeviceVendor) GetDeviceVendors(offset, limit int) ([]DeviceVendor, int64, error) {
-	var devices []DeviceVendor
-	var count int64
-	db := Db.Model(&c).Where("is_deleted=0")
-	if c.VendorValue != "" {
-		db.Where("vendor_value like ? ", "%"+c.VendorValue+"%")
-	}
-
-	if c.DeviceType >= 0 {
-		db.Where("device_type=? ", c.DeviceType)
-	}
-	db.Count(&count)
-	err := db.Order("id desc").Find(&devices).Error
-	return devices, count, err
-}
-
-func (c DeviceVendor) Remove() error {
-	return Db.Model(&c).Where("id=?", c.ID).Update("is_delete", 1).Error
-}

+ 0 - 218
app/device/dao/workbenchDao.go

@@ -1,218 +0,0 @@
-package dao
-
-import (
-	"fmt"
-	"strings"
-)
-
-// 工作台
-type CountDevice struct {
-	CountNum   int    `json:"countNum"`
-	DeviceType string `json:"deviceType"`
-}
-
-// 获取所有设备的数量
-func GetDeviceCount(tenantId string) ([]CountDevice, error) {
-	var result []CountDevice
-	var count CountDevice
-	Db.Model(&LampPole{}).Select(" count(*) count_num, 'lamppole' device_type ").
-		Where("tenant_id = ? and is_deleted = 0", tenantId).Scan(&count)
-	result = append(result, count)
-	Db.Model(&CameraDevice{}).Select(" count(*) count_num, 'camera' device_type ").
-		Where("tenant_id = ? and is_deleted = 0", tenantId).Scan(&count)
-	result = append(result, count)
-	Db.Model(&Gateway{}).Select(" count(*) count_num, 'gateway' device_type ").
-		Where("tenant_id = ? and is_deleted = 0", tenantId).Scan(&count)
-	result = append(result, count)
-	Db.Model(&LightControl{}).Select(" count(*) count_num, 'control' device_type ").
-		Where("tenant_id = ? and is_deleted = 0", tenantId).Scan(&count)
-	result = append(result, count)
-	Db.Model(&SwitchBox{}).Select(" count(*) count_num, 'box' device_type ").
-		Where("tenant_id = ? and is_deleted = 0", tenantId).Scan(&count)
-	result = append(result, count)
-	Db.Model(&InfoBoard{}).Select(" count(*) count_num, 'board' device_type ").
-		Where("tenant_id = ? and is_deleted = 0", tenantId).Scan(&count)
-	result = append(result, count)
-	Db.Model(&OptoSensor{}).Select(" count(*) count_num, 'sensor' device_type ").
-		Where("tenant_id = ? and is_deleted = 0", tenantId).Scan(&count)
-	result = append(result, count)
-	Db.Model(&Zigbee{}).Select(" count(*) count_num, 'zigbee' device_type ").
-		Where("tenant_id = ? and is_deleted = 0", tenantId).Scan(&count)
-	result = append(result, count)
-	Db.Model(&AlarmTerminal{}).Select(" count(*) count_num, 'terminal' device_type ").
-		Where("tenant_id = ? and is_deleted = 0", tenantId).Scan(&count)
-	result = append(result, count)
-	Db.Model(&Alarm{}).Select(" count(*) count_num, 'alarmserve' device_type ").
-		Where("tenant_id = ? and is_deleted = 0", tenantId).Scan(&count)
-	result = append(result, count)
-	Db.Model(&IpBroadcast{}).Select(" count(*) count_num, 'ipcast' device_type ").
-		Where("tenant_id = ? and is_deleted = 0", tenantId).Scan(&count)
-	result = append(result, count)
-	return result, nil
-}
-
-type CountAlarm struct {
-	LastYearAlarm  int `json:"lastYearAlarm"`
-	LastMonthAlarm int `json:"lastMonthAlarm"`
-	Backlog        int `json:"backlog"`
-}
-
-func GetAlarmCount(tenantId string) (*CountAlarm, error) {
-	var alarm CountAlarm
-	return &alarm, nil
-}
-
-type CountJobTodo struct {
-	BackJob      int `json:"backJob"`
-	LastMonthJob int `json:"lastMonthJob"`
-	LastYearJob  int `json:"lastYearJob"`
-}
-
-func GetCountJobTodo(tenantId string) (*CountJobTodo, error) {
-	var todos CountJobTodo
-	return &todos, nil
-}
-
-type Notification struct {
-	Category int    `json:"category"`
-	Title    string `json:"title"`
-}
-
-//	func GetNotification(tenantId string) (*Notification, error) {
-//		var notification Notification
-//		return &notification, nil
-//	}
-type DeviceState struct {
-	DeviceType string `json:"deviceType"` //设备类型
-	Name       string `json:"name"`       //设备名称
-	Sn         string `json:"sn"`         //设备序列号
-}
-
-// 获取设备离线的状态
-func GetNotification(tenantId string) ([]DeviceState, error) {
-	var result []DeviceState
-	//灯杆设备
-	Db.Model(&LampPole{}).Select(" pole_name as  name, pole_sn as sn,status,'灯杆设备' device_type").
-		Where("tenant_id = ? and status!=-1", tenantId).Find(&result)
-	result = append(result)
-	////摄像机
-	var camera []DeviceState
-	Db.Model(&CameraDevice{}).Select(" device_name as name,device_sn as sn,'摄像机' device_type ").
-		Where("tenant_id = ? and status!=-1", tenantId).Find(&camera)
-	result = append(result, camera...)
-	//网关
-	var gateway []DeviceState
-	Db.Model(&Gateway{}).Select(" gateway_name as name ,gateway_sn as sn,'网关' device_type ").
-		Where("tenant_id = ? and status!=-1", tenantId).Find(&gateway)
-	result = append(result, gateway...)
-	//灯控
-	var light []DeviceState
-	Db.Model(&LightControl{}).Select(" name,sn,'灯控' device_type").
-		Where("tenant_id = ? and status!=-1", tenantId).Find(&light)
-	result = append(result, light...)
-	//供电箱
-	var box []DeviceState
-	Db.Model(&SwitchBox{}).Select(" box_name as name ,box_sn as sn,'供电箱' device_type ").
-		Where("tenant_id = ? and status!=-1", tenantId).Find(&box)
-	result = append(result, box...)
-	//信息基本屏
-	var info []DeviceState
-	Db.Model(&InfoBoard{}).Select(" 'info_name as name,sn,'信息基本屏' device_type ").
-		Where("  tenant_id = ? and is_enable!=1", tenantId).Find(&info)
-	result = append(result, info...)
-	//集控器
-	var sensor []DeviceState
-	Db.Model(&OptoSensor{}).Select(" name,sn,'集控器' device_type ").
-		Where("tenant_id = ? and status!=-1", tenantId).Find(&sensor)
-	result = append(result, sensor...)
-	//Zigbee集控器
-	var zig []DeviceState
-	Db.Model(&Zigbee{}).Select("name,sn,'Zigbee集控器' device_type").
-		Where("tenant_id = ? and status!=-1", tenantId).Find(&zig)
-	result = append(result, zig...)
-	//一键求助终端
-	var terminal []DeviceState
-	Db.Model(&AlarmTerminal{}).Select(" terminal_name as name ,terminal_sn as sn,'一键求助终端' device_type").
-		Where("tenant_id = ? and status!=-1", tenantId).Find(&terminal)
-	result = append(result, terminal...)
-	//一键求助管理机
-	var alarm []DeviceState
-	Db.Model(&Alarm{}).Select("serve_name as name ,serve_sn as sn,'一键求助管理机' device_type").
-		Where("tenant_id = ? and status!=-1", tenantId).Find(&alarm)
-	result = append(result, alarm...)
-	//ip音柱
-	var cast []DeviceState
-	Db.Model(&IpBroadcast{}).Select("cast_name as name,cast_sn as sn,'ip音柱' device_type ").
-		Where("tenant_id = ? and  is_deleted!=0", tenantId).Find(&cast)
-	result = append(result, cast...)
-	//桥梁传感器
-	var bridge []DeviceState
-	Db.Model(&BridgeSensor{}).Select("name,sn,'桥梁传感器' device_type").
-		Where("tenant_id = ? and status!=-1", tenantId).Find(&bridge)
-	result = append(result, bridge...)
-	fmt.Println(result)
-	return result, nil
-}
-
-type AqiData struct {
-	Name string
-	Aqi  float64
-}
-type OptoSensorVO struct {
-	OptoSensor
-	Ids                   string `json:"ids"`                   //用于查询多个ID
-	Brand                 string `json:"brand"`                 //品牌名称
-	Model                 string `json:"model"`                 //型号名称
-	RunState              string `json:"runState"`              //运行状态
-	NetworkState          int    `json:"networkState"`          //网络状态
-	RealTimeTemperature   string `json:"realTimeTemperature"`   //实时温度
-	RealTimeWindSpeed     string `json:"realTimeWindSpeed"`     //实时风速
-	AirQuality            string `json:"airQuality"`            //空气质量等级
-	AirIndex              int    `json:"airIndex"`              //空气质量指数
-	IlluminationIntensity string `json:"illuminationIntensity"` //光照强度
-	Pm25                  string `json:"pm25"`                  //PM2.5
-	Pm10                  string `json:"pm10"`                  //PM10
-	Humidity              string `json:"humidity"`              //湿度
-	Pressure              string `json:"pressure"`              //气压
-	Noise                 string `json:"noise"`                 //噪音
-	Direction             string `json:"direction"`             //风向
-	EndLineTime           string `json:"endLineTime"`           //最后在线时间
-	QueryGatewayIds       string `json:"queryGatewayIds"`       //虚拟字段---用作网关调用这里关联
-	GatewayName           string `json:"gatewayName"`           //所属网关名称
-	GatewaySn             string `json:"gatewaySn"`             //所属网关编码
-	DistrictName          string `json:"districtName"`          //所在区(AQI展示)
-
-}
-
-// 获取aqi
-func GetAqi(tenantId string) (*OptoSensorVO, error) {
-	var sensorVO OptoSensorVO                       // 声明一个OptoSensorVO类型的变量sensorVO
-	var optoSensor OptoSensor                       // 声明一个OptoSensor类型的变量optoSensor
-	optoSensor.TenantId = tenantId                  // 将传入的tenantId赋值给optoSensor的TenantId字段
-	optoSensor.IsDefault = 1                        // 将optoSensor的IsDefault字段设置为1
-	isSet := len(optoSensor.GetDevicesByTenantId()) // 调用optoSensor的GetDevicesByTenantId方法获取设备数量,并将结果赋值给isSet
-	if isSet == 0 {                                 // 如果isSet为0,即没有设备
-		optoSensor.IsDefault = 0 // 将optoSensor的IsDefault字段设置为0
-	}
-	list := optoSensor.getList(optoSensor) // 调用optoSensor的getList方法获取设备列表,并将结果赋值给list
-	if isSet == 0 {                        // 如果isSet为0,即没有设备
-		for _, sensor := range list { // 遍历设备列表
-			if sensor.NetworkState == 1 { // 如果设备的NetworkState字段为1
-				sensorVO = sensor // 将该设备赋值给sensorVO
-				break             // 跳出循环
-			}
-		}
-	} else { // 如果isSet不为0,即有设备
-		if len(list) != 0 { // 如果设备列表不为空
-			sensorVO = list[0] // 将设备列表的第一个设备赋值给sensorVO
-		}
-	}
-	if sensorVO.RealTimeTemperature != "" { // 如果sensorVO的RealTimeTemperature字段不为空
-		temp := strings.Split(sensorVO.RealTimeTemperature, " ") // 使用空格将RealTimeTemperature字段拆分成字符串数组temp
-		if len(temp) == 2 {                                      // 如果拆分后的数组长度为2
-			temperature := temp[0] + " " + temp[1]     // 将temp数组的第一个元素和第二个元素拼接成字符串,并赋值给temperature
-			sensorVO.RealTimeTemperature = temperature // 将temperature赋值给sensorVO的RealTimeTemperature字段
-		}
-	}
-	return &sensorVO, nil // 返回sensorVO的地址和nil作为错误值
-}

+ 0 - 147
app/device/dao/zigbeeDao.go

@@ -1,147 +0,0 @@
-package dao
-
-import (
-	"gorm.io/gorm"
-	"iot_manager_service/util/common"
-	"time"
-)
-
-// Zigbee集控器
-type Zigbee struct {
-	ID               int         `gorm:"primary_key" json:"id"`                     //编号
-	Name             string      `gorm:"type:varchar(64)" json:"name"`              //名称
-	Sn               string      `gorm:"type:varchar(60)" json:"sn"`                //唯一编码
-	GroupId          int         `gorm:"type:int" json:"groupId"`                   //所属灯杆分组id
-	LampPoleId       int         `gorm:"type:int" json:"lampPoleId"`                //所属灯杆id
-	LampPoleName     string      `gorm:"type: varchar(64)" json:"lampPoleName"`     //灯杆名称
-	LampPoleSn       string      `gorm:"type: varchar(64)" json:"lampPoleSn"`       //灯杆编码
-	LampPoleLocation string      `gorm:"type:varchar(255)" json:"lampPoleLocation"` //灯杆安装位置
-	PoleLng          float64     `gorm:"type:double(17, 14)" json:"poleLng"`        //经度
-	PoleLat          float64     `gorm:"type:double(17, 14)" json:"poleLat"`        //纬度
-	BrandId          int         `gorm:"type:int" json:"brandId"`                   //设备名称
-	ModelId          int         `gorm:"type:int" json:"modelId"`                   //设备型号
-	GatewayId        int         `gorm:"type:int" json:"gatewayId"`                 //所属网关id
-	GatewayName      string      `gorm:"type:varchar(64)" json:"gatewayName"`       //所属网关名称
-	GatewaySn        string      `gorm:"type:varchar(60)" json:"gatewaySn"`         //所属网关编码
-	ChannelNum       int         `gorm:"type:int" json:"chanelNum"`                 //通道号
-	NetworkNum       int         `gorm:"type:int" json:"networkNum"`                //网络号
-	InstallTime      common.Time `gorm:"type:date" json:"installTime"`              //安装时间
-	TenantId         string      `gorm:"type:varchar(12)" json:"tenantId"`          //租户id
-	CreateTime       time.Time   `gorm:"type:datetime" json:"createTime"`           //新增时间
-	CreateUser       int         `gorm:"type:int" json:"createUser"`                //新增记录操作用户ID
-	UpdateTime       time.Time   `gorm:"type:datetime" json:"updateTime"`           //修改时间
-	UpdateUser       int         `gorm:"type:int" json:"updateUser"`                //修改用户
-	IsDeleted        int         `gorm:"type:int;default 0" json:"isDeleted"`       //是否删除 0=未删除,1=删除
-	Status           int         `gorm:"type:int" json:"status"`                    //状态0=正常 状态0=正常,1=异常
-	Tag              string      `gorm:"type:varchar(255)" json:"tag"`              //标签,保留字段(逗号区分)
-	IPAddress        string      `gorm:"type:varchar(64)" json:"ipAddress"`         //IP地址-备用
-
-	CountRel int `gorm:"-;default 0" json:"countRel"` //关联终端数-暂无数据 先写个0
-}
-
-func (Zigbee) TableName() string {
-	return "device_zigbee"
-}
-
-func (c Zigbee) Delete() error {
-	return Db.Model(&c).Where("id = ?", c.ID).Updates(map[string]interface{}{"update_time": c.UpdateTime,
-		"update_user": c.UpdateUser, "is_deleted": c.IsDeleted}).Error
-}
-
-func (c Zigbee) IsExistedBySN() bool {
-	var count int64
-	_ = Db.Model(&c).Where("  sn = ? and is_deleted = ?",
-		c.Sn, c.IsDeleted).Count(&count).Error
-	return count > 0
-}
-
-func (c Zigbee) IsExistedByNameAndCode() bool {
-	var devices []Zigbee
-	err := Db.Model(&c).Where(" sn = ? and is_deleted = ?",
-		c.Sn, c.IsDeleted).Find(&devices).Error
-	//如果查询不到,返回相应的错误
-	if gorm.ErrRecordNotFound == err {
-		return false
-	}
-	for _, d := range devices {
-		if d.ID != c.ID {
-			return true
-		}
-	}
-	return false
-}
-
-func (c *Zigbee) Create() error {
-	return Db.Model(&c).Save(&c).Error
-}
-
-func (c *Zigbee) Update() error {
-	return Db.Model(&c).Where(" id = ? ", c.ID).Updates(&c).Error
-}
-
-func (c *Zigbee) GetDevice() error {
-	err := Db.Model(&c).Where(" id = ? ", c.ID).Scan(&c).Error
-	return err
-}
-
-func (c Zigbee) GetDevices(offset, limit int) ([]Zigbee, int64, error) {
-	var devices []Zigbee
-	var count int64
-	db := Db.Model(&c).Where("is_deleted=0 and name like ? ", "%"+c.Name+"%")
-	db.Count(&count)
-	err := db.Offset(offset).Limit(limit).Find(&devices).Error
-	return devices, count, err
-}
-
-func (c Zigbee) GetAllDevices() ([]Zigbee, error) {
-	var devices []Zigbee
-	err := Db.Model(&c).Where(" tenant_id = ? and is_deleted = ? ", c.TenantId, c.IsDeleted).Scan(&devices).Error
-	return devices, err
-}
-
-func (c Zigbee) GetDevicesByGateway() []Zigbee {
-	var devices []Zigbee
-	Db.Model(&c).Where(" gateway_id = ? and is_deleted = 0",
-		c.GatewayId).Find(&devices)
-	return devices
-}
-
-func (c Zigbee) GetDevicesByLampPole() []Zigbee {
-	var devices []Zigbee
-	Db.Model(&c).Where("lamp_pole_id = ? and is_deleted = 0",
-		c.LampPoleId).Find(&devices)
-	return devices
-}
-
-func (c Zigbee) DeviceCount1() (int64, int64) {
-	var all, fault int64
-	err := Db.Model(&c).Where("is_deleted = 0").Count(&all).Error
-	if err != nil {
-		all = -1
-	}
-	err = Db.Model(&c).Where("is_deleted = 0 and status = 0").Count(&fault).Error
-	if err != nil {
-		fault = -1
-	}
-	return all, fault
-}
-
-func (c Zigbee) ListDevices1() []Device {
-	var devices []Zigbee
-	Db.Model(&c).Where("is_deleted = 0").Find(&devices)
-	var rsp = make([]Device, 0, len(devices))
-	for _, v := range devices {
-		var d = Device{
-			Lng:          v.PoleLng,
-			Lat:          v.PoleLat,
-			Status:       v.Status,
-			Name:         v.Name,
-			Code:         v.Sn,
-			LampPoleName: v.LampPoleName,
-			Model:        "模型",
-			LinkNum:      getLinkNum(v.LampPoleSn),
-		}
-		rsp = append(rsp, d)
-	}
-	return rsp
-}

+ 0 - 71
app/device/edge_service/cltLedControlService.go

@@ -1,71 +0,0 @@
-package edge_service
-
-import (
-	"encoding/json"
-	"fmt"
-	"github.com/google/uuid"
-	"io/ioutil"
-	"iot_manager_service/config"
-	"iot_manager_service/util/logger"
-	"net/http"
-	"strings"
-)
-
-// CltLedControlService led 显示屏 请求边缘云端接口
-type CltLedControlService struct{}
-
-type CltLedControlReqPost struct {
-	Codes []string    `json:"codes"`
-	Param interface{} `json:"param"`
-}
-type CltLedControlReq struct {
-	Tenant   string `json:"tenant"`
-	Action   string `json:"action"`
-	PostData CltLedControlReqPost
-}
-
-type CltLedControlRes struct {
-	Code int    `json:"code"`
-	Msg  string `json:"msg"`
-}
-
-func (f CltLedControlService) RequestApi(reqData CltLedControlReq) {
-	cfg := config.Instance()
-	reqId := uuid.New().String()
-	url := fmt.Sprintf("%v/cltled/v1/%v/%v/%v", cfg.Foreign.IotEdgeUrl, reqData.Tenant, reqData.Action, reqId)
-
-	method := "POST"
-
-	client := &http.Client{}
-	marshal, _ := json.Marshal(reqData.PostData)
-
-	req, err := http.NewRequest(method, url, strings.NewReader(string(marshal)))
-	if err != nil {
-		logger.Logger.Errorf("CltLedControlService NewRequest %v", err.Error())
-		return
-	}
-	req.Header.Add("Content-Type", "application/json")
-	res, err := client.Do(req)
-	if err != nil {
-		logger.Logger.Errorf("CltLedControlService Do %v", err.Error())
-		return
-	}
-	defer res.Body.Close()
-
-	body, err := ioutil.ReadAll(res.Body)
-	if err != nil {
-		logger.Logger.Errorf("CltLedControlService ReadAll %v", err.Error())
-		return
-	}
-	var cltLedControlRes CltLedControlRes
-	err = json.Unmarshal(body, &cltLedControlRes)
-	if err != nil {
-		logger.Logger.Errorf("CltLedControlService Unmarshal %v", err.Error())
-		return
-	}
-	if cltLedControlRes.Code != 0 {
-		logger.Logger.Errorf("CltLedControlService cltLedControlRes %v", cltLedControlRes.Msg)
-		return
-	}
-	return
-}

+ 0 - 66
app/device/edge_service/forLightControlService.go

@@ -1,66 +0,0 @@
-package edge_service
-
-import (
-	"encoding/json"
-	"io/ioutil"
-	"iot_manager_service/config"
-	"iot_manager_service/util/logger"
-	"net/http"
-	"strings"
-)
-
-// ForLightControl 灯控相关操作
-type ForLightControl struct{}
-
-type ForLightControlReq struct {
-	Tenant     string   `json:"tenant"`
-	Codes      []string `json:"codes"`
-	Recovery   int      `json:"recovery"`
-	Brightness int      `json:"brightness"`
-	Switchon   int      `json:"switchon"`
-	Whole      int      `json:"whole"`
-}
-type ForLightControlRes struct {
-	Code int    `json:"code"`
-	Msg  string `json:"msg"`
-}
-
-// SwitchLightCtr 向边缘云端发送开关灯指令
-func (f ForLightControl) SwitchLightCtr(reqData ForLightControlReq) {
-	reqData.Whole = 0
-	cfg := config.Instance()
-	url := cfg.Foreign.IotEdgeUrl + "/lamp/v1/switch"
-	method := "POST"
-	client := &http.Client{}
-	marshal, _ := json.Marshal(reqData)
-	req, err := http.NewRequest(method, url, strings.NewReader(string(marshal)))
-
-	if err != nil {
-		logger.Logger.Errorf("SwitchLightCtr NewRequest %v", err.Error())
-		return
-	}
-	req.Header.Add("Content-Type", "application/json")
-	res, err := client.Do(req)
-	if err != nil {
-		logger.Logger.Errorf("SwitchLightCtr Do %v", err.Error())
-		return
-	}
-	defer res.Body.Close()
-
-	body, err := ioutil.ReadAll(res.Body)
-	if err != nil {
-		logger.Logger.Errorf("SwitchLightCtr ReadAll %v", err.Error())
-		return
-	}
-	var forLightControlRes ForLightControlRes
-	err = json.Unmarshal(body, &forLightControlRes)
-	if err != nil {
-		logger.Logger.Errorf("SwitchLightCtr Unmarshal %v", err.Error())
-		return
-	}
-	if forLightControlRes.Code != 0 {
-		logger.Logger.Errorf("SwitchLightCtr forLightControlRes %v", forLightControlRes.Msg)
-		return
-	}
-	return
-}

+ 0 - 201
app/device/edge_service/ipCastControlService.go

@@ -1,201 +0,0 @@
-package edge_service
-
-import (
-	"encoding/json"
-	"errors"
-	"fmt"
-	"io/ioutil"
-	"iot_manager_service/config"
-	"iot_manager_service/util/common"
-	"iot_manager_service/util/logger"
-	"net/http"
-	"strconv"
-	"strings"
-)
-
-// IpCastControlService ip音柱连续控制接口
-type IpCastControlService struct{}
-
-type IpCastControlReq struct {
-	Action   string                 `json:"action"`
-	PostData map[string]interface{} `json:"postData"`
-}
-
-type TermInfo struct {
-	AreaID int    `json:"AreaID"`
-	From   string `json:"From"`
-	ID     int    `json:"ID"`
-	IP     string `json:"IP"`
-	Name   string `json:"Name"`
-	Online int    `json:"Online"`
-	State  int    `json:"State"`
-	Tasks  int    `json:"Tasks"`
-	Vol    int    `json:"Vol"`
-}
-
-// GetTermIds 取设备列表和状态
-func (f IpCastControlService) GetTermIds() (terminfos map[string]TermInfo, err error) {
-	var reqData IpCastControlReq
-	reqData.Action = "GetTermIds"
-	m := make(map[string]interface{})
-	reqData.PostData = m
-	mapStr, err := f.RequestApi(reqData)
-	if err != nil {
-		return terminfos, err
-	}
-	terms, ok := mapStr["Terms"]
-	if ok {
-		marshal, _ := json.Marshal(terms)
-		var terminfosList []TermInfo
-		err := json.Unmarshal(marshal, &terminfosList)
-		terms := make(map[string]TermInfo)
-		for _, info := range terminfosList {
-			info.Vol = int(common.MapRange(float64(info.Vol), 1, 16, 1, 100))
-			terms[info.Name] = info
-		}
-		terminfos = terms
-		if err != nil {
-			return nil, err
-		}
-		return terminfos, nil
-	}
-	return terminfos, err
-}
-
-// SetVol 设置音量
-func (f IpCastControlService) SetVol(sn string, vol int) error {
-	terminfos, err2 := f.GetTermIds()
-	if err2 != nil {
-		return err2
-	}
-	term, ok := terminfos[sn]
-	if !ok {
-		return errors.New("devices not found\tsn=" + sn)
-	}
-	var reqData IpCastControlReq
-	reqData.Action = "TermVolSet"
-	m := make(map[string]interface{})
-	m["TermIds"] = []int{term.ID}
-	m["Volume"] = int(common.MapRange(float64(vol), 1, 100, 1, 16))
-	reqData.PostData = m
-	_, err := f.RequestApi(reqData)
-	if err != nil {
-		return err
-	}
-	return nil
-}
-
-// RequestApi 公共请求
-func (f IpCastControlService) RequestApi(reqData IpCastControlReq) (map[string]interface{}, error) {
-	cfg := config.Instance()
-	url := fmt.Sprintf("%v/%v", cfg.Foreign.IpCastEdgeUrl, reqData.Action)
-	method := "POST"
-	client := &http.Client{}
-	marshal, _ := json.Marshal(reqData.PostData)
-	req, err := http.NewRequest(method, url, strings.NewReader(string(marshal)))
-	if err != nil {
-		logger.Logger.Errorf("IpCastControlService NewRequest %v", err.Error())
-		return nil, err
-	}
-	req.Header.Add("Content-Type", "application/json")
-	res, err := client.Do(req)
-	if err != nil {
-		logger.Logger.Errorf("IpCastControlService Do %v", err.Error())
-		return nil, err
-	}
-	defer res.Body.Close()
-
-	body, err := ioutil.ReadAll(res.Body)
-	if err != nil {
-		logger.Logger.Errorf("IpCastControlService ReadAll %v", err.Error())
-		return nil, err
-	}
-
-	var IpCastControlRes map[string]interface{}
-	err = json.Unmarshal(body, &IpCastControlRes)
-	if err != nil {
-		logger.Logger.Errorf("IpCastControlService Unmarshal %v", err.Error())
-		return nil, err
-	}
-	if IpCastControlRes["Ret"] == 1000 {
-		logger.Logger.Errorf("IpCastControlService  %v", IpCastControlRes)
-		return nil, err
-	}
-	return IpCastControlRes, nil
-}
-
-type uploadMp3Data struct {
-	Remark   string `json:"Remark"`
-	Ret      int    `json:"Ret"`
-	NSeconds int    `json:"nSeconds"`
-}
-
-// UploadMp3GetFileId 上传素材 到ip音柱服务端
-func (f IpCastControlService) UploadMp3GetFileId(imgUrl string, fileName string) (string, error) {
-	cfg := config.Instance()
-	url := fmt.Sprintf("%v/UploadFile:%v", cfg.Foreign.IpCastEdgeUrl, fileName)
-	method := "POST"
-
-	response, err := http.Get(imgUrl)
-	if err != nil {
-		panic(err)
-	}
-	defer response.Body.Close()
-	client := &http.Client{}
-	req, err := http.NewRequest(method, url, response.Body)
-	if err != nil {
-		logger.Logger.Errorf("IpCastControlService UploadMp3GetFileId 1 %v", err.Error())
-		return "", err
-	}
-	req.Header.Add("Content-Type", "audio/mpeg")
-
-	res, err := client.Do(req)
-	if err != nil {
-		logger.Logger.Errorf("IpCastControlService UploadMp3GetFileId 2 %v", err.Error())
-		return "", err
-	}
-	defer res.Body.Close()
-
-	body, err := ioutil.ReadAll(res.Body)
-	if err != nil {
-		logger.Logger.Errorf("IpCastControlService UploadMp3GetFileId 3 %v", err.Error())
-		return "", err
-	}
-	var resData uploadMp3Data
-	err = json.Unmarshal(body, &resData)
-	if err != nil {
-		return "", err
-	}
-	if resData.Ret > 0 {
-		return strconv.Itoa(resData.Ret), nil
-	}
-	return "", errors.New("上传失败啦")
-}
-
-func (f IpCastControlService) SetStop() error {
-	var reqData IpCastControlReq
-	reqData.Action = "StopMp3ByID"
-	m := make(map[string]interface{})
-	m["ID"] = 0
-	reqData.PostData = m
-	_, err := f.RequestApi(reqData)
-	return err
-}
-
-// 发布节目
-func (f IpCastControlService) PushPlay(playJson string, ptype int) error {
-	var reqData IpCastControlReq
-	if ptype == 1 {
-		reqData.Action = "PlayMp3ByID"
-	} else {
-		reqData.Action = "PlayText"
-	}
-	m := make(map[string]interface{})
-	err := json.Unmarshal([]byte(playJson), &m)
-	reqData.PostData = m
-	if err != nil {
-		return err
-	}
-	_, err = f.RequestApi(reqData)
-	return err
-}

+ 0 - 35
app/device/model/LightStrategy.go

@@ -1,35 +0,0 @@
-package model
-
-import "iot_manager_service/app/device/dao"
-
-//灯控策略
-type LightStrategyDetail struct {
-	dao.LightStrategy
-	LightType                string                `json:"lightType"`               //策略类型
-	LightConditionList       []dao.LightCondition  `json:"lightConditionList"`      //光照条件
-	LightConditionDetailList []dao.LightCondition  `json:"lightConditionVOList"`    //详情-光照条件
-	TimeConditionDetailList  []dao.TimeCondition   `json:"timeConditionVOList"`     //详情-时间条件
-	LampPoleDetailList       []LampPoleDetail      `json:"lampPoleDetailList"`      //详情-灯杆名称
-	LampPoleGroupDetailList  []LampPoleGroupDetail `json:"lampPoleGroupDetailList"` //详情-分组名称
-	TimeConditionList        []dao.TimeCondition   `json:"timeConditionList"`       //时间条件
-	CombinationStr           []string              `json:"combinationStr"`          //(智慧照明关联时)组合展示
-}
-
-type RspLightStrategyList struct {
-	Records []LightStrategyDetail `json:"records"` //记录列表
-	Current int                   `json:"current"` //当前分页
-	Size    int                   `json:"size"`    //每页数量
-	Total   int                   `json:"total"`   //总数
-	Pages   int                   `json:"pages"`   //总页数
-}
-
-type ReqLightStrategyRemove struct {
-	IDs  int    `json:"ids"`  //分组编码
-	SN   string `json:"sn"`   //sn
-	Name string `json:"name"` //名称
-}
-
-const (
-	TimeConditionNull    = "请将时间区间填写完整!"
-	TimeConditionInvalid = "时间区间开始时间不能大于结束时间,请重新调整!"
-)

+ 0 - 25
app/device/model/alarmTerminal.go

@@ -1,25 +0,0 @@
-package model
-
-import (
-	"iot_manager_service/app/device/dao"
-	"time"
-)
-
-type RsqAlarmTerminalList struct {
-	Records []AlarmTerminalDetail `json:"records"` //记录列表
-	Current int                   `json:"current"` //当前分页
-	Size    int                   `json:"size"`    //每页数量
-	Pages   int                   `json:"pages"`   //总页数
-	Total   int                   `json:"total"`   //总数
-}
-
-type ReqAlarmTerminalRemove struct {
-	IDs int `json:"ids"` //分组编码
-}
-
-type AlarmTerminalDetail struct {
-	dao.AlarmTerminal
-	EndLineTime  time.Time `json:"endLineTime"`  //最后上线时间
-	NetworkState string    `json:"networkState"` //网络状态
-	RunState     string    `json:"runState"`     //运行状态
-}

+ 0 - 15
app/device/model/alarn.go

@@ -1,15 +0,0 @@
-package model
-
-import "iot_manager_service/app/device/dao"
-
-type RsqAlarmList struct {
-	Records []dao.Alarm `json:"records"` //记录列表
-	Current int         `json:"current"` //当前分页
-	Size    int         `json:"size"`    //每页数量
-	Pages   int         `json:"pages"`   //总页数
-	Total   int         `json:"total"`   //总数
-}
-
-type ReqAlarmRemove struct {
-	IDs int `json:"ids"` //分组编码
-}

+ 0 - 15
app/device/model/bridge.go

@@ -1,15 +0,0 @@
-package model
-
-import "iot_manager_service/app/device/dao"
-
-type RsqBridgeList struct {
-	Records []dao.Bridge `json:"records"` //记录列表
-	Current int          `json:"current"` //当前分页
-	Size    int          `json:"size"`    //每页数量
-	Pages   int          `json:"pages"`   //总页数
-	Total   int          `json:"total"`   //总数
-}
-
-type ReqBridgeRemove struct {
-	IDs int `json:"ids"` //分组编码
-}

+ 0 - 24
app/device/model/bridgeSensor.go

@@ -1,24 +0,0 @@
-package model
-
-import "iot_manager_service/app/device/dao"
-
-type RspBridgeSensorList struct {
-	Records []dao.BridgeSensor `json:"records"` //记录列表
-	Current int                `json:"current"` //当前分页
-	Size    int                `json:"size"`    //每页数量
-	Total   int                `json:"total"`   //总数
-	Pages   int                `json:"pages"`   //总页数
-}
-
-type ReqBridgeSensorRemove struct {
-	IDs  int    `json:"ids"`  //分组编码
-	SN   int    `json:"sn"`   //sn
-	Name string `json:"name"` //名称
-}
-
-type ReqBridgeSensorEnable struct {
-	ID     int `json:"id"`     //编码
-	Status int `json:"status"` //启用禁用:1启用2禁用
-	Name   int `json:"name"`   //名称
-	SN     int `json:"sn"`     //sn
-}

+ 0 - 41
app/device/model/camera.go

@@ -1,41 +0,0 @@
-package model
-
-import (
-	"iot_manager_service/app/device/dao"
-	"time"
-)
-
-type CameraDetail struct {
-	dao.CameraDevice
-	PoleGroupName   string    `json:"poleGroupName"`   //灯杆分组名
-	Brand           string    `json:"brand"`           //品牌名称
-	Model           string    `json:"model"`           //型号名称
-	CameraTypeName  string    `json:"cameraTypeName"`  //摄像头类型名称
-	RunState        string    `json:"runState"`        //运行状态
-	NetworkState    string    `json:"networkState"`    //网络状态
-	EndLineTime     time.Time `json:"endLineTime"`     //最后在线时间
-	QueryGatewayIds string    `json:"queryGatewayIds"` //虚拟字段---用作网关调用这里关联
-	GatewayName     string    `json:"gatewayName"`     //所属网关名称
-	GatewaySn       string    `json:"gatewaySn"`       //所属网关编码
-}
-
-type RspCameraList struct {
-	Records []CameraDetail `json:"records"` //记录列表
-	Current int            `json:"current"` //当前分页
-	Size    int            `json:"size"`    //每页数量
-	Total   int            `json:"total"`   //总数
-	Pages   int            `json:"pages"`   //总页数
-}
-
-type ReqCameraRemove struct {
-	IDs  int    `json:"ids"`  //分组编码
-	SN   string `json:"sn"`   //sn
-	Name string `json:"name"` //名称
-}
-
-type ReqCameraEnable struct {
-	ID     int `json:"id"`     //编码
-	Status int `json:"status"` //启用禁用:1启用2禁用
-	Name   int `json:"name"`   //名称
-	SN     int `json:"sn"`     //sn
-}

+ 0 - 42
app/device/model/captureUint.go

@@ -1,42 +0,0 @@
-package model
-
-import (
-	"iot_manager_service/app/device/dao"
-	"time"
-)
-
-type CaptureDetail struct {
-	dao.CaptureUnit
-	PoleName        string    `json:"poleName"`        //灯杆名称
-	PoleSn          string    `json:"poleSn"`          //灯杆编码
-	PoleLat         float32   `json:"poleLat"`         //灯杆纬度
-	PoleLng         float32   `json:"poleLng"`         //灯杆经度
-	InstallLocation string    `json:"installLocation"` //灯杆地址
-	PointName       string    `json:"pointName"`       //卡口名称
-	PointSn         string    `json:"pointSn"`         //卡口编码
-	PointLocation   string    `json:"pointLocation"`   //卡口位置
-	NetworkState    string    `json:"networkState"`    //通讯状态 1在线2离线
-	EndLineTime     time.Time `json:"endLineTime"`     //最后在线时间
-}
-
-type RspCaptureList struct {
-	Records []CaptureDetail `json:"records"` //记录列表
-	Current int             `json:"current"` //当前分页
-	Size    int             `json:"size"`    //每页数量
-	Total   int             `json:"total"`   //总数
-	Pages   int             `json:"pages"`   //总页数
-}
-
-type RspPointList struct {
-	Records []dao.CheckPoint `json:"records"` //记录列表
-	Current int              `json:"current"` //当前分页
-	Size    int              `json:"size"`    //每页数量
-	Total   int              `json:"total"`   //总数
-	Pages   int              `json:"pages"`   //总页数
-}
-
-type ReqCaptureRemove struct {
-	IDs  int    `json:"ids"`  //分组编码
-	SN   int    `json:"sn"`   //sn
-	Type string `json:"type"` //类型
-}

+ 0 - 52
app/device/model/common.go

@@ -1,52 +0,0 @@
-package model
-
-const (
-	RepeatedPrompts    = "编码不能重复,请重新填写!"
-	GatewayHasRelation = "该网关存在关联设备,请先移除设备!"
-	RepeatedName       = "列表中存在重名,请更改灯杆分组名称!"
-	ZigbeeSelect       = "集中器(ZigBee)选取异常!"
-	ControlNONull      = "编号不能为空!!"
-	ControlNOInvalid   = "编号不符合规则,最小值为1-1,最大值为255-255!"
-
-	EnableInvalid = "启用禁用参数错误"
-	ParamsInvalid = "非法参数!"
-	TypeInvalid   = "非法类型!"
-)
-
-const (
-	ControlType_Default  = iota // 灯控
-	ControlType_NBIoT           //NB-IoT
-	ControlType_485             //485灯控
-	ControlType_ZigBee          //ZigBee
-	ControlType_ZigBeeHL        //ZigBeeHL
-)
-
-const (
-	Enable_Enable  = 1 // 启用
-	Enable_Disable = 2 //停用
-)
-
-const (
-	CameraTypeBall     = 1 //球机
-	CameraTypeGun      = 2 //枪机
-	CameraTypeBallName = "球机"
-	CameraTypeGunName  = "枪机"
-)
-
-const (
-	TypeCapture = "capture"
-	TypePoint   = "point"
-)
-
-//redis
-const (
-	AlarmList           = "%d:AlarmList:GetList"
-	LampPoleGroupList   = "%d:LampPoleGroupList:GetList"
-	GroupFiltrationList = "%d:GroupFiltrationList:GetList"
-	GarbageList         = "%d:GarbageList:GetList"
-	GarbageWayGroupList = "%d:GarbageWayGroupList:GetList"
-	OnDemandGroupList   = "%d:OnDemandGroupList:GetList"
-	SwitchBoxList       = "%d:SwitchBoxList:GetList"
-	TransformerList     = "%d:TransformerList:GetList"
-	GatewayList         = "%d:GatewayList:GetList"
-)

+ 0 - 15
app/device/model/garbage.go

@@ -1,15 +0,0 @@
-package model
-
-import "iot_manager_service/app/device/dao"
-
-type RsqGarbageList struct {
-	Records []dao.Garbage `json:"records"` //记录列表
-	Current int           `json:"current"` //当前分页
-	Size    int           `json:"size"`    //每页数量
-	Pages   int           `json:"pages"`   //总页数
-	Total   int           `json:"total"`   //总数
-}
-
-type ReqGarbageRemove struct {
-	IDs int `json:"ids"` //分组编码
-}

+ 0 - 15
app/device/model/garbageWayGroup.go

@@ -1,15 +0,0 @@
-package model
-
-import "iot_manager_service/app/device/dao"
-
-type RsqGarbageWayGroupList struct {
-	Records []dao.GarbageWayGroup `json:"records"` //记录列表
-	Current int                   `json:"current"` //当前分页
-	Size    int                   `json:"size"`    //每页数量
-	Pages   int                   `json:"pages"`   //总页数
-	Total   int                   `json:"total"`   //总数
-}
-
-type ReqGarbageWayGroupRemove struct {
-	IDs int `json:"ids"` //分组编码
-}

+ 0 - 38
app/device/model/gateway.go

@@ -1,38 +0,0 @@
-package model
-
-import (
-	"iot_manager_service/app/device/dao"
-	"time"
-)
-
-type GatewayDetail struct {
-	dao.Gateway
-	CountLampPole     int                 `json:"countLampPole"`         //关联设备数 //todo 修改返回名
-	EndLineTime       time.Time           `json:"endLineTime"`           //最后上线时间
-	NetworkState      string              `json:"networkState"`          //网络状态
-	RunState          string              `json:"runState"`              //运行状态
-	Cpu               string              `json:"cpu"`                   //CPU占有率
-	Memory            string              `json:"memory"`                //内存占有率
-	AlarmTerminalList []dao.AlarmTerminal `json:"akeyAlarmTerminalList"` //一键告警集合
-	CameraList        []dao.CameraDevice  `json:"cameraList"`            //摄像头集合
-	CaptureUnitList   []dao.CaptureUnit   `json:"captureUnitList"`       //抓拍单元集合
-	InfoBoardList     []dao.InfoBoard     `json:"infoBoardList"`         //信息屏集合
-	IpBroadcastList   []dao.IpBroadcast   `json:"ipBroadcastList"`       //IP音柱集合
-	LightControlList  []dao.LightControl  `json:"lightControlList"`      //灯控集合
-	ZigbeeList        []dao.Zigbee        `json:"zigbeeList"`            //ZigBee集合
-	OptoSensorList    []dao.OptoSensor    `json:"optoSensorList"`        //气象站集合
-}
-
-type RspGatewayList struct {
-	Records []GatewayDetail `json:"records"` //记录列表
-	Current int             `json:"current"` //当前分页
-	Size    int             `json:"size"`    //每页数量
-	Total   int             `json:"total"`   //总数
-	Pages   int             `json:"pages"`   //总页数
-}
-
-type ReqGatewayRemove struct {
-	IDs  int    `json:"ids"`  //分组编码
-	SN   string `json:"sn"`   //sn
-	Name string `json:"name"` //名称
-}

+ 0 - 50
app/device/model/infoBoard.go

@@ -1,50 +0,0 @@
-package model
-
-import (
-	"iot_manager_service/app/device/dao"
-	"time"
-)
-
-type RsqInfoBoardList struct {
-	Records []InfoBoardDetail `json:"records"` //记录列表
-	Current int               `json:"current"` //当前分页
-	Size    int               `json:"size"`    //每页数量
-	Pages   int               `json:"pages"`   //总页数
-	Total   int               `json:"total"`   //总数
-}
-
-type ReqInfoBoardRemove struct {
-	IDs int `json:"ids"` //分组编码
-}
-
-type InfoBoardDetail struct {
-	dao.InfoBoard
-	EndLineTime         time.Time `json:"endLineTime"`         //最后上线时间
-	NetworkState        string    `json:"networkState"`        //网络状态
-	RunState            string    `json:"runState"`            //运行状态
-	PublicName          string    `json:"publicName"`          //节目发布时使用
-	OnTheAir            string    `json:"onTheAir"`            //当前播放的节目
-	ResolutionName      string    `json:"resolutionName"`      //分辨率
-	Volume              string    `json:"volume"`              //音量
-	Voltage             string    `json:"voltage"`             //电压
-	Luminance           string    `json:"luminance"`           //亮度
-	Temperature         string    `json:"temperature"`         //色温
-	RebootTime          string    `json:"rebootTime"`          //重启时间
-	RealStartAndEndTime string    `json:"realStartAndEndTime"` //开机时间和关机时间
-	Power               string    `json:"power"`               //电源状态
-
-}
-
-// CltledData 信息屏 数据
-type CltledData struct {
-	Powerstatus      string `json:"powerstatus"`      //电源状态 1 0
-	Musicvolume      string `json:"musicvolume"`      //音量
-	Brightness       string `json:"brightness"`       //亮度
-	Playing          string `json:"playing"`          //当前播放节目
-	Colortemperature string `json:"colortemperature"` //色温
-	SleepTime        string `json:"sleepTime"`        //关机时间
-	WakeupTime       string `json:"wakeupTime"`       //开机时间
-	RebootTime       string `json:"rebootTime"`       //重启时间
-	RealWidth        string `json:"real_width"`       //宽度
-	RealHeight       string `json:"real_height"`      //高度
-}

+ 0 - 61
app/device/model/intelligentLighting.go

@@ -1,61 +0,0 @@
-package model
-
-import (
-	"iot_manager_service/app/device/dao"
-)
-
-const (
-	RelationIdInvalid         = "该记录未关联策略无法查看,请关联策略!"
-	RelationTypeInvalid       = "查询参数(关联类型)异常"
-	RelationTypeLight         = 1 //关联类型 灯控
-	RelationTypeLampPoleGroup = 2 //关联类型 灯杆分组
-
-	IsYear   = 2 //全年设置2=是,1=否
-	Sunshine = 2 //日出日落 设置 2=开启,1=不开启
-)
-
-type RspIntelligentLightDetail struct {
-	LightControlList []dao.LightControl     `json:"lightControlList"`
-	LampPoleName     string                 `json:"lampPoleName"`
-	LightRelMap      IntelligentLightSimple `json:"lightRelMap"`
-}
-
-type RspIntelligentLightDetailByGroup struct {
-	LightControlList  []dao.LightControl     `json:"lightControlList"`
-	LampPoleGroupName string                 `json:"lampPoleGroupName"`
-	CountLampPole     int                    `json:"countLampPole"`
-	LightRelMap       IntelligentLightSimple `json:"lightRelMap"`
-}
-
-type IntelligentLightSimple struct {
-	TimeConditionList []TimeConditionSimple `json:"timeConditionList"` //时间条件列表
-	LightName         string                `json:"lightName"`         //灯控名称
-	LightSn           string                `json:"lightSn"`           //灯控SN
-	EffectiveDate     string                `json:"effectiveDate"`     //生效日期
-}
-
-type TimeConditionSimple struct {
-	Luminance string `json:"luminance"`
-	Times     string `json:"times"`
-}
-
-type RspIntelligentLightListDetail struct {
-	LightControlState int    `json:"lightControlState"` //灯控状态
-	RunState          string `json:"runState"`          //运行状态
-	PublicName        string `json:"publicName"`        //设备名称(灯杆与灯杆分组公用)
-	PublicId          int    `json:"publicId"`          //设备Id(灯杆与灯杆分组公用ID)
-	LampPoleName      string `json:"lampPoleName"`      //灯杆名称
-	LampPoleSn        string `json:"lampPoleSn"`        //灯杆编码
-	StrategyName      string `json:"strategyName"`      //策略名称
-	DeviceSn          string `json:"deviceSn"`          //灯控设备编码
-	ControlType       int    `json:"controlType"`       //灯控类型
-	IsShowOpts        bool   `json:"isShowOpts"`        //页面是否显示操作按钮
-}
-
-type RspIntelligentLightList struct {
-	Records []dao.LightrelationVo `json:"records"` //记录列表
-	Current int                   `json:"current"` //当前分页
-	Size    int                   `json:"size"`    //每页数量
-	Pages   int                   `json:"pages"`   //总页数
-	Total   int                   `json:"total"`
-}

+ 0 - 25
app/device/model/ipBroadcast.go

@@ -1,25 +0,0 @@
-package model
-
-import (
-	"iot_manager_service/app/device/dao"
-	"time"
-)
-
-type RsqIpBroadcastList struct {
-	Records []IpBroadcastDetail `json:"records"` //记录列表
-	Current int                 `json:"current"` //当前分页
-	Size    int                 `json:"size"`    //每页数量
-	Pages   int                 `json:"pages"`   //总页数
-	Total   int                 `json:"total"`   //总数
-}
-
-type ReqIpBroadcastRemove struct {
-	IDs int `json:"ids"` //分组编码
-}
-
-type IpBroadcastDetail struct {
-	dao.IpBroadcast
-	EndLineTime  time.Time `json:"endLineTime"`  //最后上线时间
-	NetworkState string    `json:"networkState"` //网络状态
-	RunState     string    `json:"runState"`     //运行状态
-}

+ 0 - 40
app/device/model/lampPole.go

@@ -1,40 +0,0 @@
-package model
-
-import (
-	"iot_manager_service/app/device/dao"
-)
-
-type LampPoleDetail struct {
-	dao.LampPole
-	IsCrossName       string              `json:"isCrossName"`           //是否路口名称
-	TagName           string              `json:"tagName"`               //标签(中文)
-	ProvincesName     string              `json:"provincesName"`         //省市区组合地址
-	GatewaySn         string              `json:"gatewaySn"`             //网关编码
-	BoxSn             string              `json:"boxSn"`                 //配电箱编码
-	RunState          string              `json:"runState"`              //运行状态
-	PoleGroupName     string              `json:"poleGroupName"`         //灯杆分组名称
-	BoxName           string              `json:"boxName"`               //配电箱名称
-	AlarmTerminalList []dao.AlarmTerminal `json:"akeyAlarmTerminalList"` //一键告警集合
-	CameraList        []dao.CameraDevice  `json:"cameraList"`            //摄像头集合
-	CaptureUnitList   []dao.CaptureUnit   `json:"captureUnitList"`       //抓拍单元集合
-	GatewayList       []dao.Gateway       `json:"gatewayList"`           //网关集合
-	InfoBoardList     []dao.InfoBoard     `json:"infoBoardList"`         //信息屏集合
-	IpBroadcastList   []dao.IpBroadcast   `json:"ipBroadcastList"`       //IP音柱集合
-	LightControlList  []dao.LightControl  `json:"lightControlList"`      //灯控集合
-	SensorList        []dao.OptoSensor    `json:"sensorList"`            //环境监测集合
-	ZigbeeList        []dao.Zigbee        `json:"zigbeeList"`            //ZigBee集合
-}
-
-type RspLampPoleList struct {
-	Records []LampPoleDetail `json:"records"` //记录列表
-	Current int              `json:"current"` //当前分页
-	Size    int              `json:"size"`    //每页数量
-	Total   int              `json:"total"`   //总数
-	Pages   int              `json:"pages"`   //总页数
-}
-
-type ReqLampPoleRemove struct {
-	IDs  int    `json:"ids"`  //分组编码
-	SN   string `json:"sn"`   //sn
-	Name string `json:"name"` //名称
-}

+ 0 - 27
app/device/model/lampPoleGroup.go

@@ -1,27 +0,0 @@
-package model
-
-import (
-	"iot_manager_service/app/device/dao"
-)
-
-type LampPoleGroupDetail struct {
-	dao.LampPoleGroup
-	PublicName     string             `json:"publicName"`     // 用于虚拟字段组成的树
-	LampPoleVOList []LampPoleDetail   `json:"lampPoleVOList"` //分组下的所有灯杆集合
-	CameraList     []dao.CameraDevice `json:"cameraList"`     //智能安防中调用摄像头直播列表
-	SwitchBoxList  []dao.SwitchBox    `json:"switchBoxList"`  //智能安防中调用配电箱直播列表
-	InfoBoardList  []dao.InfoBoard    `json:"infoBoardList"`  //节目组下查询分组下的信息屏集合
-}
-
-type RspLampPoleGroupList struct {
-	Records []LampPoleGroupDetail `json:"records"` //记录列表
-	Current int                   `json:"current"` //当前分页
-	Size    int                   `json:"size"`    //每页数量
-	Pages   int                   `json:"pages"`   //总页数
-	Total   int                   `json:"total"`   //总数
-}
-
-type ReqLampPoleGroupRemove struct {
-	IDs  int    `json:"ids"`  //分组编码
-	Name string `json:"name"` //分组名
-}

+ 0 - 42
app/device/model/lightControl.go

@@ -1,42 +0,0 @@
-package model
-
-import (
-	"iot_manager_service/app/device/dao"
-	"time"
-)
-
-type LightControlDetail struct {
-	dao.LightControl
-	EndLineTime  time.Time `json:"endLineTime"`  //最后上线时间
-	NetworkState string    `json:"networkState"` //网络状态
-	RunState     string    `json:"runState"`     //运行状态
-}
-
-type RspLightControlList struct {
-	Records []LightControlDetail `json:"records"` //记录列表
-	Current int                  `json:"current"` //当前分页
-	Size    int                  `json:"size"`    //每页数量
-	Total   int                  `json:"total"`   //总数
-	Pages   int                  `json:"pages"`   //总页数
-}
-
-type ReqLightControlRemove struct {
-	IDs  int    `json:"ids"`  //分组编码
-	Name string `json:"name"` //名称
-}
-
-type ReqLightControlEnable struct {
-	ID     int `json:"id"`     //编码
-	Status int `json:"status"` //启用禁用:1启用2禁用
-	Name   int `json:"name"`   //名称
-	SN     int `json:"sn"`     //sn
-}
-
-type ReqLightControlSwitch struct {
-	HandSwitch int    `json:"handSwitch"` //开关要更改的状态1=开启2=关闭
-	HandTime   int    `json:"handTime"`   //手动控制时间(分钟)
-	Luminance  int    `json:"luminance"`  //灯光亮度
-	Explain    string `json:"explain"`    // 更改说明
-	Name       string `json:"name"`       //名称
-	SN         string `json:"sn"`         //SN
-}

+ 0 - 15
app/device/model/manholeCover.go

@@ -1,15 +0,0 @@
-package model
-
-import "iot_manager_service/app/device/dao"
-
-type RsqManholeCoverList struct {
-	Records []dao.ManholeCover `json:"records"` //记录列表
-	Current int                `json:"current"` //当前分页
-	Size    int                `json:"size"`    //每页数量
-	Pages   int                `json:"pages"`   //总页数
-	Total   int                `json:"total"`   //总数
-}
-
-type ReqManholeCoverRemove struct {
-	IDs int `json:"ids"` //分组编码
-}

+ 0 - 22
app/device/model/onDemandGroup.go

@@ -1,22 +0,0 @@
-package model
-
-import "iot_manager_service/app/device/dao"
-
-type ReqOnDemandGroupRemove struct {
-	IDs  int    `json:"ids"`  //分组编码
-	SN   int    `json:"sn"`   //sn
-	Name string `json:"name"` //名称
-}
-
-type RspOnDemandGroupList struct {
-	Records []dao.OnDemandGroup `json:"records"` //记录列表
-	Current int                 `json:"current"` //当前分页
-	Size    int                 `json:"size"`    //每页数量
-	Total   int                 `json:"total"`   //总数
-	Pages   int                 `json:"pages"`   //总页数
-}
-
-type RspOnDemandGroupNumber struct {
-	Name  string `json:"name"`  //key
-	Value int    `json:"value"` //value
-}

+ 0 - 15
app/device/model/onDemandSensor.go

@@ -1,15 +0,0 @@
-package model
-
-import "iot_manager_service/app/device/dao"
-
-type RsqOnDemandSensorList struct {
-	Records []dao.OnDemandSensor `json:"records"` //记录列表
-	Current int                  `json:"current"` //当前分页
-	Size    int                  `json:"size"`    //每页数量
-	Pages   int                  `json:"pages"`   //总页数
-	Total   int                  `json:"total"`   //总数
-}
-
-type ReqOnDemandSensorRemove struct {
-	IDs int `json:"ids"` //分组编码
-}

+ 0 - 25
app/device/model/optoSenso.go

@@ -1,25 +0,0 @@
-package model
-
-import (
-	"iot_manager_service/app/device/dao"
-	"time"
-)
-
-type RsqOptoSensorList struct {
-	Records []OptoSensorDetail `json:"records"` //记录列表
-	Current int                `json:"current"` //当前分页
-	Size    int                `json:"size"`    //每页数量
-	Pages   int                `json:"pages"`   //总页数
-	Total   int                `json:"total"`   //总数
-}
-
-type ReqOptoSensorRemove struct {
-	IDs int `json:"ids"` //分组编码
-}
-
-type OptoSensorDetail struct {
-	dao.OptoSensor
-	EndLineTime  time.Time `json:"endLineTime"`  //最后上线时间
-	NetworkState string    `json:"networkState"` //网络状态
-	RunState     string    `json:"runState"`     //运行状态
-}

+ 0 - 15
app/device/model/switchBox.go

@@ -1,15 +0,0 @@
-package model
-
-import "iot_manager_service/app/device/dao"
-
-type RsqSwitchBoxList struct {
-	Records []dao.SwitchBox `json:"records"` //记录列表
-	Current int             `json:"current"` //当前分页
-	Size    int             `json:"size"`    //每页数量
-	Pages   int             `json:"pages"`   //总页数
-	Total   int             `json:"total"`   //总数
-}
-
-type ReqSwitchBoxRemove struct {
-	IDs int `json:"ids"` //分组编码
-}

+ 0 - 15
app/device/model/transformer.go

@@ -1,15 +0,0 @@
-package model
-
-import "iot_manager_service/app/device/dao"
-
-type RsqTransformerList struct {
-	Records []dao.Transformer `json:"records"` //记录列表
-	Current int               `json:"current"` //当前分页
-	Size    int               `json:"size"`    //每页数量
-	Pages   int               `json:"pages"`   //总页数
-	Total   int               `json:"total"`   //总数
-}
-
-type ReqTransformerRemove struct {
-	IDs int `json:"ids"` //分组编码
-}

+ 0 - 15
app/device/model/util.go

@@ -1,15 +0,0 @@
-package model
-
-const (
-	TypeVendor = 1 //厂商
-	TypeBrand  = 2 //品牌
-	TypeModel  = 3 //型号
-)
-
-type VendorDetail struct {
-	Id       int    `json:"id"`
-	ParentId int    `json:"parent_id"`
-	Vendor   string `json:"vendor"`
-	Brand    string `json:"brand"`
-	Model    string `json:"model"`
-}

+ 0 - 26
app/device/model/workbench.go

@@ -1,26 +0,0 @@
-package model
-
-import (
-	"iot_manager_service/app/device/dao"
-	"time"
-)
-
-type RspCountDevice struct {
-	CountDevices []dao.CountDevice `json:"data"`
-}
-
-type ReqLightRates struct {
-	QueryType string `form:"queryType"`
-	StartDate string `form:"startDate"`
-	EndDate   string `form:"endDate"`
-}
-
-type RspLightRate struct {
-	LightRate []LightRate `json:"lightRate"`
-	Energy    []LightRate `json:"energy"`
-}
-
-type LightRate struct {
-	ColumnValue string    `json:"columnValue"`
-	TimeLine    time.Time `json:"timeLine"`
-}

+ 0 - 25
app/device/model/zigbee.go

@@ -1,25 +0,0 @@
-package model
-
-import (
-	"iot_manager_service/app/device/dao"
-	"time"
-)
-
-type RsqZigbeeList struct {
-	Records []ZigbeeDetail `json:"records"` //记录列表
-	Current int            `json:"current"` //当前分页
-	Size    int            `json:"size"`    //每页数量
-	Pages   int            `json:"pages"`   //总页数
-	Total   int            `json:"total"`   //总数
-}
-
-type ReqZigbeeRemove struct {
-	IDs int `json:"ids"` //分组编码
-}
-
-type ZigbeeDetail struct {
-	dao.Zigbee
-	EndLineTime  time.Time `json:"endLineTime"`  //最后上线时间
-	NetworkState string    `json:"networkState"` //网络状态
-	RunState     string    `json:"runState"`     //运行状态
-}

+ 0 - 264
app/device/service/LightStrategyService.go

@@ -1,264 +0,0 @@
-package service
-
-import (
-	"fmt"
-	"iot_manager_service/app/device/dao"
-	"iot_manager_service/app/device/model"
-	"iot_manager_service/app/system/service"
-	"iot_manager_service/util/common"
-	"iot_manager_service/util/logger"
-	"sort"
-	"time"
-)
-
-// 中间件管理服务
-var LightStrategyService = new(lightStrategyService)
-
-type lightStrategyService struct{}
-
-func (s *lightStrategyService) Get(id int) (*model.LightStrategyDetail, *common.Errors) {
-	// 创建查询实例
-	strategy := &dao.LightStrategy{
-		ID: id,
-	}
-	err := strategy.GetStrategy()
-	if err != nil {
-		return nil, common.FailResponse(err.Error(), nil)
-	}
-
-	lightStrategy := &model.LightStrategyDetail{
-		LightStrategy: *strategy,
-	}
-
-	lightStrategy.TimeConditionList = TimeConditionService.GetByLightId(id)
-
-	if len(lightStrategy.TimeConditionList) > 0 {
-		lightStrategy.LightType = "时间"
-	}
-	lightStrategy.LightType = lightStrategy.LightType + "策略"
-	return lightStrategy, nil
-}
-
-func (s *lightStrategyService) CreateOrUpdate(userId int, tenantId string, req *model.LightStrategyDetail) *common.Errors {
-	// 创建查询实例
-	strategy := req
-	logger.Logger.Errorf("CreateOrUpdate strategy = %+v \n", strategy)
-	strategy.TenantId = tenantId
-	strategy.UpdateUser = userId
-	strategy.UpdateTime = time.Now()
-
-	if len(strategy.LightConditionList) == 0 {
-		for i := 0; i < len(strategy.LightConditionDetailList); i++ {
-			var detail = strategy.LightConditionDetailList[i]
-			condition := dao.LightCondition{
-				ID:         detail.ID,
-				Remark:     detail.Remark,
-				LightId:    detail.LightId,
-				Luminance:  detail.Luminance,
-				ScopeStart: detail.ScopeStart,
-				ScopeEnd:   detail.ScopeEnd,
-			}
-			strategy.LightConditionList = append(strategy.LightConditionList, condition)
-		}
-	}
-	if len(strategy.TimeConditionList) == 0 {
-		for i := 0; i < len(strategy.TimeConditionDetailList); i++ {
-			var detail = strategy.TimeConditionDetailList[i]
-			condition := dao.TimeCondition{
-				ID:        detail.ID,
-				Remark:    detail.Remark,
-				LightId:   detail.LightId,
-				Luminance: detail.Luminance,
-				StartTime: detail.StartTime,
-				EndTime:   detail.EndTime,
-				Sunshine:  detail.Sunshine,
-			}
-			strategy.TimeConditionList = append(strategy.TimeConditionList, condition)
-		}
-	}
-
-	if req.ID == 0 {
-		strategy.CreateTime = time.Now()
-		strategy.CreateUser = userId
-		strategy.Status = 1
-		if strategy.IsExistedBySN() {
-			logger.Logger.Errorf("Create GetstrategyID err \n")
-			return common.ParamsInvalidResponse("编码不能重复,请重新填写!", nil)
-		}
-	}
-
-	//用于比较光照度重叠
-	var overlapList []dao.LightCondition
-	for _, lightCondition := range strategy.LightConditionList {
-		if (lightCondition.ScopeStart != 0 && lightCondition.ScopeEnd == 0) || (lightCondition.
-			ScopeStart == 0 && lightCondition.ScopeEnd != 0) {
-			return common.ParamsInvalidResponse("光照度请填写完整", nil)
-		} else if lightCondition.ScopeEnd > 0 && lightCondition.ScopeStart >= lightCondition.ScopeEnd {
-			return common.ParamsInvalidResponse("光照度起始值不能大于结束值", nil)
-		}
-		overlapList = append(overlapList, lightCondition)
-
-		if lightCondition.ID == 0 {
-			lightCondition.CreateUser = userId
-			lightCondition.CreateTime = time.Now()
-		} else {
-			lightCondition.UpdateUser = userId
-			lightCondition.UpdateTime = time.Now()
-		}
-		lightCondition.LightId = req.ID
-
-	}
-	//光照条件查询是否区间重叠
-	if len(overlapList) > 0 {
-		sort.SliceIsSorted(overlapList, func(i, j int) bool {
-			return overlapList[i].
-				ScopeStart < overlapList[j].ScopeStart
-		})
-		tmp := -1
-		for _, overLap := range overlapList {
-			if tmp >= overLap.ScopeStart {
-				return common.ParamsInvalidResponse("光照条件区间有重叠", nil)
-			}
-			tmp = overLap.ScopeEnd
-		}
-	}
-
-	// 时间策略参数校验
-	var timeList []dao.TimeCondition
-	for _, timeCondition := range strategy.TimeConditionList {
-		if timeCondition.Sunshine == 0 {
-			timeCondition.Sunshine = 1
-		}
-		if timeCondition.Sunshine == 1 && (timeCondition.StartTime == "" && timeCondition.EndTime == "") {
-			return common.FailResponse(model.TimeConditionNull, nil)
-		}
-		if (timeCondition.StartTime == "" && timeCondition.EndTime != "") || (timeCondition.
-			StartTime != "" && timeCondition.EndTime == "") {
-			return common.FailResponse(model.TimeConditionNull, nil)
-		} else if timeCondition.EndTime != "" && timeCondition.StartTime >= timeCondition.EndTime {
-			return common.FailResponse(model.TimeConditionInvalid, nil)
-		}
-		if timeCondition.ID == 0 {
-			timeCondition.CreateUser = userId
-			timeCondition.CreateTime = time.Now()
-		} else {
-			timeCondition.UpdateUser = userId
-			timeCondition.UpdateTime = time.Now()
-		}
-		timeCondition.LightId = req.ID
-		if timeCondition.ID == 0 {
-			timeCondition.CreateUser = userId
-			timeCondition.CreateTime = time.Now()
-		}
-		timeCondition.UpdateUser = userId
-		timeCondition.UpdateTime = time.Now()
-
-		timeList = append(timeList, timeCondition)
-	}
-
-	//存数据库
-	if strategy.ID == 0 {
-		if err := strategy.Create(); err != nil {
-			logger.Logger.Errorf("Create err = %s \n", err.Error())
-			return common.FailResponse(err.Error(), nil)
-		}
-	} else {
-		if err := strategy.Update(); err != nil {
-			logger.Logger.Errorf("Update err = %s \n", err.Error())
-			return common.FailResponse(err.Error(), nil)
-		}
-	}
-
-	//存策略条件
-	_ = TimeConditionService.Save(timeList, strategy.ID)
-	_ = LightConditionService.Save(strategy.LightConditionList, strategy.ID)
-
-	//todo 调用设备云端的新增或修改
-
-	//todo 自动续期
-	//strategy.IsAutomaticRenewal
-
-	service.OperationHisService.Save(userId, tenantId, common.OperationCreate, common.ModuleTypeDevice,
-		common.DeviceTypeLightStrategy, common.GetDeviceObject(strategy.ID, strategy.LightName), common.OperationSuccess)
-	return common.SuccessResponse(common.Succeeded, nil)
-}
-
-func (s *lightStrategyService) List(searchValue string, current, size int) ([]model.LightStrategyDetail, int64, *common.Errors) {
-	strategy := dao.LightStrategy{}
-	if searchValue != "" {
-		strategy.LightSn = searchValue
-	}
-
-	offset := (current - 1) * size
-	limit := size
-	strategies, total, err := strategy.GetStrategies(offset, limit)
-	if err != nil {
-		return nil, 0, common.FailResponse(err.Error(), nil)
-	}
-
-	timeConditions, _ := TimeConditionService.GetAll()
-	timeConditionsMap := make(map[int]dao.TimeCondition)
-	for _, timeCondition := range timeConditions {
-		timeConditionsMap[timeCondition.LightId] = timeCondition
-	}
-
-	year := time.Now().Year()
-	var details []model.LightStrategyDetail
-	for _, strategy := range strategies {
-		if strategy.IsAllYear == model.IsYear {
-			strategy.StartTime = fmt.Sprintf("%d-01-01", year)
-			strategy.StartTime = fmt.Sprintf("%d-12-31", year)
-		}
-		detail := model.LightStrategyDetail{LightStrategy: strategy}
-		if timeCondition, isExist := timeConditionsMap[strategy.ID]; isExist {
-			//开启日出日落
-			if timeCondition.Sunshine == 2 {
-				timeCondition.StartTime = "日落"
-				timeCondition.EndTime = "日出"
-			}
-			str := []string{}
-			str = append(str, fmt.Sprintf("开灯时段:%s ~ %s , 灯光亮度:%d%%", timeCondition.StartTime,
-				timeCondition.EndTime, timeCondition.Luminance))
-			detail.CombinationStr = str
-		}
-		lightStrategy := &model.LightStrategyDetail{
-			LightStrategy: strategy,
-		}
-		lightStrategy.TimeConditionList = TimeConditionService.GetByLightId(strategy.ID)
-		if len(lightStrategy.TimeConditionList) > 0 {
-			lightStrategy.LightType = "时间"
-		}
-		detail.LightType = lightStrategy.LightType + "策略"
-
-		details = append(details, detail)
-	}
-	return details, total, nil
-}
-
-func (s *lightStrategyService) Remove(userId int, tenantId string, id int) *common.Errors {
-	// 创建查询实例
-	strategy := &dao.LightStrategy{
-		ID:         id,
-		IsDeleted:  1,
-		UpdateUser: userId,
-		UpdateTime: time.Now(),
-	}
-	err := strategy.Delete()
-	if err != nil {
-		return common.FailResponse(err.Error(), nil)
-	}
-	service.OperationHisService.Save(userId, tenantId, common.OperationRemove, common.ModuleTypeDevice,
-		common.DeviceTypeLightStrategy, common.GetDeviceObject(strategy.ID, strategy.LightName), common.OperationSuccess)
-	return nil
-}
-
-func (s *lightStrategyService) GetOne(id int) (*dao.LightStrategy, *common.Errors) {
-	strategy := &dao.LightStrategy{
-		ID: id,
-	}
-	err := strategy.GetStrategy()
-	if err != nil {
-		return nil, nil
-	}
-	return strategy, nil
-}

+ 0 - 140
app/device/service/alarmService.go

@@ -1,140 +0,0 @@
-package service
-
-import (
-	"fmt"
-	"iot_manager_service/app/device/dao"
-	"iot_manager_service/app/device/model"
-	"iot_manager_service/app/system/service"
-	"iot_manager_service/util/cache"
-	"iot_manager_service/util/common"
-	"iot_manager_service/util/logger"
-	"time"
-)
-
-// 中间件管理服务
-var AlarmService = new(alarmService)
-
-type alarmService struct{}
-
-// 根据id获取设备信息
-func (s *alarmService) Get(id int) (*dao.Alarm, *common.Errors) {
-	// 创建查询实例
-	device := &dao.Alarm{
-		ID: id,
-	}
-	err := device.GetDevice() //调用device的GetDevice方法,将返回值赋给err
-	if err != nil {
-		return nil, common.FailResponse(err.Error(), nil) //如果err不为nil,则返回一个空指针和错误信息
-	}
-	device.CountRel = int(dao.AlarmTerminal{}.GetTerminalCount(device.ID)) //调用一键报警服务中的获取终端计数的方法,将返回值转换为整数并赋值给device.CountRel
-	return device, nil                                                     //返回设备和nil
-}
-
-// 添加设备或者修改设备
-func (s *alarmService) CreateOrUpdate(userId int, tenantId string, req dao.Alarm) *common.Errors {
-	device := req //创建一个名为device的变量,将传入的req赋值给它
-	device.TenantId = tenantId
-	device.UpdateUser = userId
-	device.UpdateTime = time.Now()
-	if req.ID == 0 { //判断传入的req是否没有ID
-		device.CreateTime = time.Now() //如果req.ID为0,则为device的成员变量CreateTime赋值当前时间
-		device.CreateUser = userId     //device的成员变量CreateUser为传入的userid
-
-		if device.IsExistedBySN() { //判断设备是否已经存在
-			logger.Logger.Errorf("Create IsExistedBySN \n")              //如果设备已经存在,则记录错误日志
-			return common.ParamsInvalidResponse(model.RepeatedName, nil) //返回参数无效的错误响应
-		}
-		if err := device.Create(); err != nil { //尝试创建设备
-			logger.Logger.Errorf("Create err = %s \n", err.Error()) //如果创建失败,则记录错误日志
-			return common.FailResponse(err.Error(), nil)            //返回创建失败的错误响应
-		}
-		service.OperationHisService.Save(userId, tenantId, common.OperationCreate, common.ModuleTypeDevice,
-			common.DeviceTypeAlarmServer, common.GetDeviceObject(device.ID, device.ServeName), common.OperationSuccess) //保存操作历史记录
-		return common.SuccessResponse(common.Succeeded, nil) //返回成功响应
-	}
-
-	if device.IsExistedByNameAndCode() { //判断设备是否已经存在
-		logger.Logger.Errorf("Update IsExistedByNameAndCode \n")     //如果设备已经存在,则记录错误日志
-		return common.ParamsInvalidResponse(model.RepeatedName, nil) //返回参数无效的错误响应
-	}
-	if err := device.Update(); err != nil { //尝试更新设备
-		logger.Logger.Errorf("Update err = %s \n", err.Error()) //如果更新失败,则记录错误日志
-		return common.FailResponse(err.Error(), nil)            //返回更新失败的错误响应
-	}
-
-	service.OperationHisService.Save(userId, tenantId, common.OperationUpdate, common.ModuleTypeDevice,
-		common.DeviceTypeAlarmServer, common.GetDeviceObject(device.ID, device.ServeName), common.OperationSuccess) //保存操作历史记录
-	return common.SuccessResponse(common.Succeeded, nil) //返回成功响应
-}
-
-// 获取所有设备
-func (s *alarmService) List(poleGroupName string, current, size int) ([]dao.Alarm, int64, *common.Errors) {
-	// 创建查询实例
-	device := &dao.Alarm{}
-	offset := (current - 1) * size
-	limit := size
-	devices, total, err := device.GetDevices(offset, limit)
-	if err != nil {
-		return nil, 0, common.FailResponse(err.Error(), nil)
-	}
-	for i, alarm := range devices {
-		devices[i].CountRel = int(dao.AlarmTerminal{}.GetTerminalCount(alarm.ID))
-	}
-	return devices, total, nil
-}
-
-// 移除设备
-func (s *alarmService) Remove(userId int, tenantId string, id int) *common.Errors {
-	// 创建查询实例
-	device := &dao.Alarm{
-		ID:         id,
-		IsDeleted:  1,
-		UpdateUser: userId,
-		UpdateTime: time.Now(),
-	}
-	err := device.Delete()
-	if err != nil {
-		return common.FailResponse(err.Error(), nil)
-	}
-	service.OperationHisService.Save(userId, tenantId, common.OperationRemove, common.ModuleTypeDevice,
-		common.DeviceTypeAlarmServer, common.GetDeviceObject(device.ID, device.ServeName), common.OperationSuccess)
-	return nil
-}
-
-// 获取设备列表
-func (s *alarmService) GetList(tenantId string) ([]*dao.Alarm, *common.Errors) {
-	var devices []*dao.Alarm                                              //声明一个名为devices的变量,类型为指向dao.Alarm结构体的指针的切片
-	err := cache.Redis.Get(getAlarmListRedisKey(tenantId)).Scan(&devices) //从Redis缓存中获取指定租户ID的设备列表,并将结果存储在devices变量中
-	if err == nil {                                                       //判断是否成功从Redis缓存中获取设备列表                                                  //
-		return devices, nil //如果成功获取设备列表,则返回设备列表和nil错误
-	}
-	device := &dao.Alarm{ //创建一个新的dao.Alarm结构体实例,并将其赋值给device变量
-		TenantId:  tenantId,
-		IsDeleted: 0,
-	}
-	devices, err = device.GetAllDevices() //调用device的GetAllDevices方法,获取所有设备列表,并将结果存储在devices变量中
-	if err != nil {                       //判断是否获取设备列表时发生错误
-		return nil, common.FailResponse(err.Error(), nil) //如果发生错误,则返回nil和错误响应
-	}
-	_ = cache.Redis.Set(getAlarmListRedisKey(tenantId), devices, 0).Err() //将获取到的设备列表存储到Redis缓存中,并设置过期时间为0
-	return devices, nil                                                   //返回设备列表和nil错误
-}
-
-// 获取报警列表redis密钥
-func getAlarmListRedisKey(tenantId string) string {
-	return fmt.Sprintf(model.AlarmList, tenantId) //使用fmt.Sprintf函数将model.AlarmList和tenantId格式化为一个字符串,并将其作为方法的返回值
-}
-
-// 获取设备的数量
-func (s *alarmService) DeviceCount() dao.DeviceStatus {
-	var rsp dao.DeviceStatus  //声明一个名为rsp的变量,类型为指向dao.DeviceStatus结构体的指针
-	d := dao.Alarm{}          //声明一个名为d的变量,类型为dao.Alarm结构体
-	rsp.Set(d.DeviceCount1()) //调用rsp的Set方法,将d.DeviceCount1()的结果作为参数传入
-	return rsp                //返回rsp变量
-}
-
-// 设备列表
-func (s *alarmService) ListDevices() []dao.Device {
-	d := dao.Alarm{}        //声明一个d的变量,类型为dao.Alarm结构体
-	return d.ListDevices1() //返回设备的列表
-}

+ 0 - 147
app/device/service/alarmTerminalService.go

@@ -1,147 +0,0 @@
-package service
-
-import (
-	"iot_manager_service/app/device/dao"
-	"iot_manager_service/app/device/model"
-	"iot_manager_service/app/system/service"
-	"iot_manager_service/util/cache"
-	"iot_manager_service/util/common"
-	"iot_manager_service/util/logger"
-	"time"
-)
-
-// 中间件管理服务
-var AlarmTerminalService = new(alarmTerminalService)
-
-type alarmTerminalService struct{}
-
-// 获取单个设备信息
-func (s *alarmTerminalService) Get(id int) (*model.AlarmTerminalDetail, *common.Errors) {
-	// 创建查询实例
-	device := &dao.AlarmTerminal{
-		ID: id,
-	}
-	err := device.GetDevice()
-	if err != nil {
-		return nil, common.FailResponse(err.Error(), nil)
-	}
-	endTime, state := cache.GetDeviceState(device.TerminalSN)
-	return &model.AlarmTerminalDetail{
-		AlarmTerminal: *device,
-		RunState:      state,
-		NetworkState:  state,
-		EndLineTime:   endTime,
-	}, nil
-}
-
-// 添加或者修改设备信息
-func (s *alarmTerminalService) CreateOrUpdate(userId int, tenantId string, req dao.AlarmTerminal) *common.Errors {
-	device := req
-	device.TenantId = tenantId
-	device.UpdateUser = userId
-	device.UpdateTime = time.Now()
-
-	if req.ID == 0 {
-		device.CreateTime = time.Now()
-		device.CreateUser = userId
-
-		if device.IsExistedBySN() {
-			logger.Logger.Errorf("Create IsExistedBySN \n")
-			return common.ParamsInvalidResponse(model.RepeatedName, nil)
-		}
-		if err := device.Create(); err != nil {
-			logger.Logger.Errorf("Create err = %s \n", err.Error())
-			return common.FailResponse(err.Error(), nil)
-		}
-		service.OperationHisService.Save(userId, tenantId, common.OperationCreate, common.ModuleTypeDevice,
-			common.DeviceTypeAlarmTerminal, common.GetDeviceObject(device.ID, device.TerminalName), common.OperationSuccess)
-		return common.SuccessResponse(common.Succeeded, nil)
-	}
-
-	if device.IsExistedByNameAndCode() {
-		logger.Logger.Errorf("Update IsExistedByNameAndCode \n")
-		return common.ParamsInvalidResponse(model.RepeatedName, nil)
-	}
-
-	if err := device.Update(); err != nil {
-		logger.Logger.Errorf("Update err = %s \n", err.Error())
-		return common.FailResponse(err.Error(), nil)
-	}
-
-	service.OperationHisService.Save(userId, tenantId, common.OperationUpdate, common.ModuleTypeDevice,
-		common.DeviceTypeAlarmTerminal, common.GetDeviceObject(device.ID, device.TerminalName), common.OperationSuccess)
-	return common.SuccessResponse(common.Succeeded, nil)
-}
-
-// 获取设备信息
-func (s *alarmTerminalService) List(poleGroupName string, current, size int) ([]model.AlarmTerminalDetail, int64, *common.Errors) {
-	// 创建查询实例
-	device := &dao.AlarmTerminal{}
-	offset := (current - 1) * size
-	limit := size
-	devices, total, err := device.GetDevices(offset, limit)
-	if err != nil {
-		return nil, 0, common.FailResponse(err.Error(), nil)
-	}
-	var details []model.AlarmTerminalDetail
-	for _, d := range devices {
-		endTime, state := cache.GetDeviceState(d.TerminalSN)
-		details = append(details, model.AlarmTerminalDetail{
-			AlarmTerminal: d,
-			RunState:      state,
-			NetworkState:  state,
-			EndLineTime:   endTime,
-		})
-	}
-	return details, total, nil
-}
-
-// 移除设备信息
-func (s *alarmTerminalService) Remove(userId int, tenantId string, id int) *common.Errors {
-	// 创建查询实例
-	device := &dao.AlarmTerminal{
-		ID:         id,
-		IsDeleted:  1,
-		UpdateUser: userId,
-		UpdateTime: time.Now(),
-	}
-	err := device.Delete()
-	if err != nil {
-		return common.FailResponse(err.Error(), nil)
-	}
-	service.OperationHisService.Save(userId, tenantId, common.OperationRemove, common.ModuleTypeDevice,
-		common.DeviceTypeAlarmTerminal, common.GetDeviceObject(device.ID, device.TerminalName), common.OperationSuccess)
-	return nil
-}
-
-// 根据网关获取设备信息
-func (s *alarmTerminalService) GetByGateway(id int) []dao.AlarmTerminal {
-	// 创建查询实例
-	device := &dao.AlarmTerminal{
-		GatewayId: id,
-	}
-	return device.GetDevicesByGateway()
-}
-
-// 根据灯杆设备获取设备信息
-func (s *alarmTerminalService) GetByLampPole(id int) []dao.AlarmTerminal {
-	// 创建查询实例
-	device := &dao.AlarmTerminal{
-		LampPoleId: id,
-	}
-	return device.GetDevicesByLampPole()
-}
-
-// 获取设备的数量
-func (s *alarmTerminalService) DeviceCount() dao.DeviceStatus {
-	var rsp dao.DeviceStatus
-	d := dao.AlarmTerminal{}
-	rsp.Set(d.DeviceCount1())
-	return rsp
-}
-
-// 获取设备列表
-func (s *alarmTerminalService) ListDevices() []dao.Device {
-	d := dao.AlarmTerminal{}
-	return d.ListDevices1()
-}

+ 0 - 0
app/device/service/bigService.go


Certains fichiers n'ont pas été affichés car il y a eu trop de fichiers modifiés dans ce diff