Browse Source

first commit

chengqian 2 years ago
parent
commit
cab0b533a1
100 changed files with 41 additions and 8062 deletions
  1. 6 0
      .gitignore
  2. 32 0
      Makefile
  3. 3 0
      README.md
  4. 0 146
      app/device/controller/GatewayController.go
  5. 0 89
      app/device/controller/IntelligentLightingStrategy.go
  6. 0 96
      app/device/controller/LightStrategy.go
  7. 0 20
      app/device/controller/OnDemandLightingControlStrategy.go
  8. 0 113
      app/device/controller/alarmController.go
  9. 0 101
      app/device/controller/alarmTerminalController.go
  10. 0 113
      app/device/controller/bridgeController.go
  11. 0 131
      app/device/controller/bridgeSensorController.go
  12. 0 139
      app/device/controller/cameraController.go
  13. 0 188
      app/device/controller/captureUintController.go
  14. 0 113
      app/device/controller/garbageController.go
  15. 0 104
      app/device/controller/garbageWayGroupController.go
  16. 0 40
      app/device/controller/handleHistoryController.go
  17. 0 110
      app/device/controller/infoBoardController.go
  18. 0 104
      app/device/controller/ipBroadcastController.go
  19. 0 145
      app/device/controller/lampPoleController.go
  20. 0 149
      app/device/controller/lampPoleGroupController.go
  21. 0 144
      app/device/controller/lightController.go
  22. 0 119
      app/device/controller/manholeCoverController.go
  23. 0 121
      app/device/controller/onDemandGroupController.go
  24. 0 104
      app/device/controller/onDemandSensorController.go
  25. 0 116
      app/device/controller/optoSensorController.go
  26. 0 112
      app/device/controller/switchBoxController.go
  27. 0 104
      app/device/controller/transformerController.go
  28. 0 107
      app/device/controller/utilController.go
  29. 0 86
      app/device/controller/workbenchController.go
  30. 0 113
      app/device/controller/zigbeeController.go
  31. 0 88
      app/device/dao/LightStrategyDao.go
  32. 0 87
      app/device/dao/alarmDao.go
  33. 0 105
      app/device/dao/alarmTerminalDao.go
  34. 0 96
      app/device/dao/bridgeDao.go
  35. 0 92
      app/device/dao/bridgeSensorDao.go
  36. 0 104
      app/device/dao/cameraDao.go
  37. 0 98
      app/device/dao/captureUnitDao.go
  38. 0 65
      app/device/dao/checkPointDao.go
  39. 0 49
      app/device/dao/common.go
  40. 0 98
      app/device/dao/garbageDao.go
  41. 0 76
      app/device/dao/garbageWayGroupDao.go
  42. 0 104
      app/device/dao/gatewayDao.go
  43. 0 30
      app/device/dao/gatewayRelationDao.go
  44. 0 111
      app/device/dao/infoBoardDao.go
  45. 0 65
      app/device/dao/intelligentLightingDao.go
  46. 0 103
      app/device/dao/ipBroadcastDao.go
  47. 0 112
      app/device/dao/lampPoleDao.go
  48. 0 78
      app/device/dao/lampPoleGroupDao.go
  49. 0 35
      app/device/dao/lightConditionDao.go
  50. 0 134
      app/device/dao/lightControlDao.go
  51. 0 98
      app/device/dao/manholeCoverDao.go
  52. 0 79
      app/device/dao/onDemandGroupDao.go
  53. 0 83
      app/device/dao/onDemandSensorDao.go
  54. 0 104
      app/device/dao/optoSensoDao.go
  55. 0 93
      app/device/dao/switchBoxDao.go
  56. 0 52
      app/device/dao/timeConditionDao.go
  57. 0 86
      app/device/dao/transformerDao.go
  58. 0 54
      app/device/dao/venderDao.go
  59. 0 77
      app/device/dao/workbenchDao.go
  60. 0 108
      app/device/dao/zigbeeDao.go
  61. 0 35
      app/device/model/LightStrategy.go
  62. 0 15
      app/device/model/alarmTerminal.go
  63. 0 15
      app/device/model/alarn.go
  64. 0 15
      app/device/model/bridge.go
  65. 0 24
      app/device/model/bridgeSensor.go
  66. 0 38
      app/device/model/camera.go
  67. 0 39
      app/device/model/captureUint.go
  68. 0 52
      app/device/model/common.go
  69. 0 15
      app/device/model/garbage.go
  70. 0 15
      app/device/model/garbageWayGroup.go
  71. 0 37
      app/device/model/gateway.go
  72. 0 15
      app/device/model/infoBoard.go
  73. 0 61
      app/device/model/intelligentLighting.go
  74. 0 15
      app/device/model/ipBroadcast.go
  75. 0 40
      app/device/model/lampPole.go
  76. 0 27
      app/device/model/lampPoleGroup.go
  77. 0 41
      app/device/model/lightControl.go
  78. 0 15
      app/device/model/manholeCover.go
  79. 0 22
      app/device/model/onDemandGroup.go
  80. 0 15
      app/device/model/onDemandSensor.go
  81. 0 15
      app/device/model/optoSenso.go
  82. 0 15
      app/device/model/switchBox.go
  83. 0 15
      app/device/model/transformer.go
  84. 0 15
      app/device/model/util.go
  85. 0 20
      app/device/model/workbench.go
  86. 0 15
      app/device/model/zigbee.go
  87. 0 251
      app/device/service/LightStrategyService.go
  88. 0 116
      app/device/service/alarmService.go
  89. 0 110
      app/device/service/alarmTerminalService.go
  90. 0 128
      app/device/service/bridgeSensorService.go
  91. 0 108
      app/device/service/bridgeService.go
  92. 0 182
      app/device/service/cameraService.go
  93. 0 238
      app/device/service/captureUintService.go
  94. 0 116
      app/device/service/garbageService.go
  95. 0 116
      app/device/service/garbageWayGroupService.go
  96. 0 23
      app/device/service/gatewayRelationService.go
  97. 0 204
      app/device/service/gatewayService.go
  98. 0 110
      app/device/service/infoBoardService.go
  99. 0 123
      app/device/service/intelligentLightingService.go
  100. 0 0
      app/device/service/ipBroadcastService.go

+ 6 - 0
.gitignore

@@ -0,0 +1,6 @@
+/build/
+log
+.idea
+go.sum
+main_demo.go
+/example/

+ 32 - 0
Makefile

@@ -0,0 +1,32 @@
+#打包程序名称
+APP_NAME="iot_service"
+#线上路径
+SERVER_PATH="/opt/lc/iot_svr/"
+
+BINARY="build/${APP_NAME}"
+VERSION=1.0.0
+export GOARCH=amd64
+export GOOS=linux
+SHELL := D:\Programs\Git\bin\bash.exe
+
+clear:
+	@$(RM) ${BINARY}
+
+build:
+	@go build  -o ${BINARY} ./
+
+#发布测试环境
+push-test:clear build
+	@$(call pushServer,"110.40.223.170")
+
+#发布到正式环境
+push-pro:clear build
+	#@$(call pushServer,"106.52.134.22")
+
+.PHONY: build push-test push-pro
+
+define pushServer
+	ssh root@$(1) "service  go-${APP_NAME} stop;"
+    scp -r build/* root@$(1):${SERVER_PATH}
+    ssh root@$(1) "chmod +x ${SERVER_PATH}${APP_NAME};service  go-${APP_NAME} start;sleep 3;service  go-${APP_NAME} status"
+endef

+ 3 - 0
README.md

@@ -0,0 +1,3 @@
+## go 平江智慧路灯大数据平台
+
+### 常见问题

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

@@ -1,146 +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"
-	"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, util.ParamsInvalidResponse(e.Error(), nil))
-		return
-	}
-
-	device, err := service.GatewayService.Get(id)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, util.SuccessResponse(util.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, err := service.GatewayService.List(searchValue, current, size)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	pages := math.Ceil(float64(len(devices)) / float64(size))
-	rsp := model.RspGatewayList{
-		Current: current,
-		Size:    size,
-		Total:   len(devices),
-		Pages:   int(pages),
-		Records: devices,
-	}
-	ctx.JSON(http.StatusOK, util.SuccessResponse(util.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, util.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, util.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, util.SuccessResponse(util.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, util.SuccessResponse(util.Succeeded, devices))
-}
-
-func (c *gatewayCtl) GetRelevanceDetail(ctx *gin.Context) {
-	id, e := strconv.Atoi(ctx.Query("id"))
-	if e != nil {
-		ctx.JSON(http.StatusOK, util.ParamsInvalidResponse(e.Error(), nil))
-		return
-	}
-
-	device, err := service.GatewayService.GetRelevanceDetail(id)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, util.SuccessResponse(util.Succeeded, device))
-}
-
-func gatewayDaoToModel(device dao.Gateway) model.GatewayDetail {
-	return model.GatewayDetail{
-		Gateway:           device,
-		CountLampPole:     0,
-		EndLineTime:       "",
-		NetworkState:      2,
-		RunState:          2,
-		Cpu:               "",
-		Memory:            "",
-		AlarmTerminalList: nil,
-		CameraList:        nil,
-		CaptureUnitList:   nil,
-		InfoBoardList:     nil,
-		IpBroadcastList:   nil,
-		LightControlList:  nil,
-		ZigbeeList:        nil,
-		OptoSensorList:    nil,
-	}
-}

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

@@ -1,89 +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"
-	"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"))
-	if e != nil {
-		ctx.JSON(http.StatusOK, util.ParamsInvalidResponse(e.Error(), nil))
-		return
-	}
-	if publicId == 0 {
-		ctx.JSON(http.StatusOK, util.ParamsInvalidResponse(model.RelationIdInvalid, nil))
-		return
-	}
-
-	detail, err := service.IntelligentLightingService.GetDetailByLight(claims.TenantId, publicId)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, util.SuccessResponse(util.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, util.ParamsInvalidResponse("groupId invalid", nil))
-		return
-	}
-	if current == 0 {
-		current = 1
-	}
-	if size <= 0 || size > 100 {
-		size = 10
-	}
-	strategies, 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:   len(strategies),
-		Pages:   int(pages),
-		Records: strategies,
-	}
-	ctx.JSON(http.StatusOK, util.SuccessResponse(util.Succeeded, rsp))
-}
-
-func (c *intelligentLightingCtl) RelationList(ctx *gin.Context) {
-
-}
-func (c *intelligentLightingCtl) Relation(ctx *gin.Context) {
-
-}
-func (c *intelligentLightingCtl) Remove(ctx *gin.Context) {
-
-}
-func (c *intelligentLightingCtl) ChangeHandSwitch(ctx *gin.Context) {
-
-}
-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"
-	"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, util.ParamsInvalidResponse(e.Error(), nil))
-		return
-	}
-
-	lightStrategy, err := service.LightStrategyService.Get(id)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, util.SuccessResponse(util.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, err := service.LightStrategyService.List(searchValue, current, size)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	pages := math.Ceil(float64(len(lightStrategies)) / float64(size))
-	rsp := model.RspLightStrategyList{
-		Current: current,
-		Size:    size,
-		Total:   len(lightStrategies),
-		Pages:   int(pages),
-		Records: lightStrategies,
-	}
-
-	ctx.JSON(http.StatusOK, util.SuccessResponse(util.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, util.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, util.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, util.SuccessResponse(util.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"
-	"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, util.ParamsInvalidResponse(e.Error(), nil))
-		return
-	}
-
-	device, err := service.AlarmService.Get(id)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, util.SuccessResponse(util.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, err := service.AlarmService.List(searchValue, current, size)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	pages := math.Ceil(float64(len(devices)) / float64(size))
-	rsp := model.RsqAlarmList{
-		Current: current,
-		Size:    size,
-		Total:   len(devices),
-		Pages:   int(pages),
-	}
-	for _, device := range devices {
-
-		rsp.Records = append(rsp.Records, device)
-	}
-	ctx.JSON(http.StatusOK, util.SuccessResponse(util.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, util.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, util.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, util.SuccessResponse(util.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, util.SuccessResponse(util.Succeeded, devices))
-}

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

@@ -1,101 +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"
-	"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, util.ParamsInvalidResponse(e.Error(), nil))
-		return
-	}
-
-	device, err := service.AlarmTerminalService.Get(id)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, util.SuccessResponse(util.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, err := service.AlarmTerminalService.List(searchValue, current, size)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	pages := math.Ceil(float64(len(devices)) / float64(size))
-	rsp := model.RsqAlarmTerminalList{
-		Current: current,
-		Size:    size,
-		Total:   len(devices),
-		Pages:   int(pages),
-	}
-	for _, device := range devices {
-
-		rsp.Records = append(rsp.Records, device)
-	}
-	ctx.JSON(http.StatusOK, util.SuccessResponse(util.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, util.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, util.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, util.SuccessResponse(util.Succeeded, nil))
-}
-
-func (c *alarmTerminalCtl) ImportExcel(ctx *gin.Context) {
-}
-
-func (c *alarmTerminalCtl) ExportExcel(ctx *gin.Context) {
-}
-
-func (c *alarmTerminalCtl) ExportTemplate(ctx *gin.Context) {
-}

+ 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"
-	"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, util.ParamsInvalidResponse(e.Error(), nil))
-		return
-	}
-
-	device, err := service.BridgeService.Get(id)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, util.SuccessResponse(util.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, err := service.BridgeService.List(searchValue, current, size)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	pages := math.Ceil(float64(len(devices)) / float64(size))
-	rsp := model.RsqBridgeList{
-		Current: current,
-		Size:    size,
-		Total:   len(devices),
-		Pages:   int(pages),
-	}
-	for _, device := range devices {
-
-		rsp.Records = append(rsp.Records, device)
-	}
-	ctx.JSON(http.StatusOK, util.SuccessResponse(util.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, util.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, util.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, util.SuccessResponse(util.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, util.SuccessResponse(util.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"
-	"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, util.ParamsInvalidResponse(e.Error(), nil))
-		return
-	}
-
-	device, err := service.BridgeSensorService.Get(id)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, util.SuccessResponse(util.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, err := service.BridgeSensorService.List(searchValue, current, size)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	pages := math.Ceil(float64(len(devices)) / float64(size))
-	rsp := model.RspBridgeSensorList{
-		Current: current,
-		Size:    size,
-		Total:   len(devices),
-		Pages:   int(pages),
-	}
-	for _, device := range devices {
-
-		rsp.Records = append(rsp.Records, device)
-	}
-	ctx.JSON(http.StatusOK, util.SuccessResponse(util.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, util.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, util.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, util.SuccessResponse(util.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, util.SuccessResponse(util.Succeeded, devices))
-}
-
-func (c *bridgeSensorCtl) Enable(ctx *gin.Context) {
-	var req *model.ReqBridgeSensorEnable
-	if err := ctx.ShouldBindJSON(&req); err != nil {
-		ctx.JSON(http.StatusOK, util.ParamsInvalidResponse(err.Error(), nil))
-		return
-	}
-	if req.Status != model.Enable_Enable && req.Status != model.Enable_Disable {
-		ctx.JSON(http.StatusOK, util.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, util.SuccessResponse(util.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"
-	"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, util.ParamsInvalidResponse(e.Error(), nil))
-		return
-	}
-
-	device, err := service.CameraService.Get(id)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, util.SuccessResponse(util.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, err := service.CameraService.List(searchValue, cameraType, current, size)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	pages := math.Ceil(float64(len(devices)) / float64(size))
-	rsp := model.RspCameraList{
-		Current: current,
-		Size:    size,
-		Total:   len(devices),
-		Pages:   int(pages),
-		Records: devices,
-	}
-
-	ctx.JSON(http.StatusOK, util.SuccessResponse(util.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, util.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, util.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, util.SuccessResponse(util.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, util.SuccessResponse(util.Succeeded, devices))
-
-}
-
-func (c *cameraCtl) Enable(ctx *gin.Context) {
-	var req *model.ReqCameraEnable
-	if err := ctx.ShouldBindJSON(&req); err != nil {
-		ctx.JSON(http.StatusOK, util.ParamsInvalidResponse(err.Error(), nil))
-		return
-	}
-	if req.Status != model.Enable_Enable && req.Status != model.Enable_Disable {
-		ctx.JSON(http.StatusOK, util.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, util.SuccessResponse(util.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"
-	"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, util.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, util.SuccessResponse(util.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, util.SuccessResponse(util.Succeeded, device))
-	} else {
-		ctx.JSON(http.StatusOK, util.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, err := service.CaptureUintService.CaptureList(searchValue, current, size)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	pages := math.Ceil(float64(len(devices)) / float64(size))
-	rsp := model.RspCaptureList{
-		Current: current,
-		Size:    size,
-		Total:   len(devices),
-		Pages:   int(pages),
-		Records: devices,
-	}
-
-	ctx.JSON(http.StatusOK, util.SuccessResponse(util.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, util.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, 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:   len(devices),
-		Pages:   int(pages),
-		Records: devices,
-	}
-
-	ctx.JSON(http.StatusOK, util.SuccessResponse(util.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, util.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, util.SuccessResponse(util.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, util.SuccessResponse(util.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, util.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, util.SuccessResponse(util.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, util.SuccessResponse(util.Succeeded, nil))
-	} else {
-		ctx.JSON(http.StatusOK, util.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"
-	"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, util.ParamsInvalidResponse(e.Error(), nil))
-		return
-	}
-
-	device, err := service.GarbageService.Get(id)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, util.SuccessResponse(util.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, err := service.GarbageService.List(searchValue, current, size)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	pages := math.Ceil(float64(len(devices)) / float64(size))
-	rsp := model.RsqGarbageList{
-		Current: current,
-		Size:    size,
-		Total:   len(devices),
-		Pages:   int(pages),
-	}
-	for _, device := range devices {
-
-		rsp.Records = append(rsp.Records, device)
-	}
-	ctx.JSON(http.StatusOK, util.SuccessResponse(util.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, util.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, util.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, util.SuccessResponse(util.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, util.SuccessResponse(util.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"
-	"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, util.ParamsInvalidResponse(e.Error(), nil))
-		return
-	}
-
-	device, err := service.GarbageWayGroupService.Get(id)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, util.SuccessResponse(util.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, err := service.GarbageWayGroupService.List(searchValue, current, size)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	pages := math.Ceil(float64(len(devices)) / float64(size))
-	rsp := model.RsqGarbageWayGroupList{
-		Current: current,
-		Size:    size,
-		Total:   len(devices),
-		Pages:   int(pages),
-	}
-	for _, device := range devices {
-
-		rsp.Records = append(rsp.Records, device)
-	}
-	ctx.JSON(http.StatusOK, util.SuccessResponse(util.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, util.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, util.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, util.SuccessResponse(util.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, util.SuccessResponse(util.Succeeded, devices))
-}

+ 0 - 40
app/device/controller/handleHistoryController.go

@@ -1,40 +0,0 @@
-package controller
-
-import (
-	"github.com/gin-gonic/gin"
-	"iot_manager_service/app/middleware"
-	service2 "iot_manager_service/app/system/service"
-	"iot_manager_service/util"
-	"net/http"
-	"strconv"
-)
-
-// 一键报警服务表管理对象
-var HandleHistory = new(handleHistoryCtl)
-
-type handleHistoryCtl struct{}
-
-func (c *handleHistoryCtl) List(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-
-	handleContent := ctx.Query("handleContent")
-	operationType := ctx.Query("operationType")
-	moduleType := ctx.Query("moduleType")
-	current, _ := strconv.Atoi(ctx.Query("current"))
-	size, _ := strconv.Atoi(ctx.Query("size"))
-	if current == 0 {
-		current = 1
-	}
-	if size <= 0 || size > 100 {
-		size = 10
-	}
-	list, err := service2.OperationHisService.List(claims.TenantId, handleContent, operationType, moduleType, current,
-		size)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-
-	ctx.JSON(http.StatusOK, util.SuccessResponse(util.Succeeded, list))
-}

+ 0 - 110
app/device/controller/infoBoardController.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"
-	"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, util.ParamsInvalidResponse(e.Error(), nil))
-		return
-	}
-
-	device, err := service.InfoBoardService.Get(id)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, util.SuccessResponse(util.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, err := service.InfoBoardService.List(searchValue, current, size)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	pages := math.Ceil(float64(len(devices)) / float64(size))
-	rsp := model.RsqInfoBoardList{
-		Current: current,
-		Size:    size,
-		Total:   len(devices),
-		Pages:   int(pages),
-	}
-	for _, device := range devices {
-
-		rsp.Records = append(rsp.Records, device)
-	}
-	ctx.JSON(http.StatusOK, util.SuccessResponse(util.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, util.ParamsInvalidResponse(err.Error(), nil))
-		return
-	}
-	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, util.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, util.SuccessResponse(util.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) {
-}
-
-func (c *infoBoardCtl) ShowSetting(ctx *gin.Context) {
-}

+ 0 - 104
app/device/controller/ipBroadcastController.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"
-	"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, util.ParamsInvalidResponse(e.Error(), nil))
-		return
-	}
-
-	device, err := service.IpBroadcastService.Get(id)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, util.SuccessResponse(util.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, err := service.IpBroadcastService.List(searchValue, current, size)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	pages := math.Ceil(float64(len(devices)) / float64(size))
-	rsp := model.RsqIpBroadcastList{
-		Current: current,
-		Size:    size,
-		Total:   len(devices),
-		Pages:   int(pages),
-	}
-	for _, device := range devices {
-
-		rsp.Records = append(rsp.Records, device)
-	}
-	ctx.JSON(http.StatusOK, util.SuccessResponse(util.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, util.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, util.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, util.SuccessResponse(util.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) {
-}

+ 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"
-	"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, util.ParamsInvalidResponse(e.Error(), nil))
-		return
-	}
-
-	device, err := service.LampPoleService.Get(id)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, util.SuccessResponse(util.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, util.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, err := service.LampPoleService.List(searchValue, groupId, boxId, current, size)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	pages := math.Ceil(float64(len(devices)) / float64(size))
-	rsp := model.RspLampPoleList{
-		Current: current,
-		Size:    size,
-		Total:   len(devices),
-		Pages:   int(pages),
-	}
-	for _, device := range devices {
-		rsp.Records = append(rsp.Records, lampPoleDaoToModel(device))
-	}
-	ctx.JSON(http.StatusOK, util.SuccessResponse(util.Succeeded, rsp))
-}
-
-func (c *lampPoleCtl) GetRelevanceDetail(ctx *gin.Context) {
-	id, e := strconv.Atoi(ctx.Query("id"))
-	if e != nil {
-		ctx.JSON(http.StatusOK, util.ParamsInvalidResponse(e.Error(), nil))
-		return
-	}
-
-	device, err := service.LampPoleService.GetRelevanceDetail(id)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, util.SuccessResponse(util.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, util.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, util.SuccessResponse(util.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, util.SuccessResponse(util.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 - 149
app/device/controller/lampPoleGroupController.go

@@ -1,149 +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"
-	"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, util.ParamsInvalidResponse(e.Error(), nil))
-		return
-	}
-
-	device, err := service.LampPoleGroupService.Get(id)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, util.SuccessResponse(util.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, util.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, err := service.LampPoleGroupService.List(poleGroupName, current, size)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	pages := math.Ceil(float64(len(devices)) / float64(size))
-	rsp := model.RspLampPoleGroupList{
-		Current: current,
-		Size:    size,
-		Total:   len(devices),
-		Pages:   int(pages),
-	}
-	for _, device := range devices {
-		rsp.Records = append(rsp.Records, lampPoleGroupDaoToModel(device))
-	}
-	ctx.JSON(http.StatusOK, util.SuccessResponse(util.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, util.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, util.SuccessResponse(util.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, util.SuccessResponse(util.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, util.SuccessResponse(util.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, util.SuccessResponse(util.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 - 144
app/device/controller/lightController.go

@@ -1,144 +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"
-	"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, util.ParamsInvalidResponse(e.Error(), nil))
-		return
-	}
-
-	device, err := service.LightControlService.Get(id)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, util.SuccessResponse(util.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, err := service.LightControlService.List(searchValue, controlType, zigbeeId, current, size)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	pages := math.Ceil(float64(len(devices)) / float64(size))
-	rsp := model.RspLightControlList{
-		Current: current,
-		Size:    size,
-		Total:   len(devices),
-		Pages:   int(pages),
-	}
-	for _, d := range devices {
-		rsp.Records = append(rsp.Records, lightControlDaoToModel(d))
-	}
-	ctx.JSON(http.StatusOK, util.SuccessResponse(util.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, util.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, util.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, util.SuccessResponse(util.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, util.SuccessResponse(util.Succeeded, devices))
-}
-
-func (c *lightCtl) Enable(ctx *gin.Context) {
-	var req *model.ReqLightControlEnable
-	if err := ctx.ShouldBindJSON(&req); err != nil {
-		ctx.JSON(http.StatusOK, util.ParamsInvalidResponse(err.Error(), nil))
-		return
-	}
-	if req.Status != model.Enable_Enable && req.Status != model.Enable_Disable {
-		ctx.JSON(http.StatusOK, util.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, util.SuccessResponse(util.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 - 119
app/device/controller/manholeCoverController.go

@@ -1,119 +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"
-	"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, util.ParamsInvalidResponse(e.Error(), nil))
-		return
-	}
-
-	device, err := service.ManholeCoverService.Get(id)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, util.SuccessResponse(util.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, err := service.ManholeCoverService.List(searchValue, current, size)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	pages := math.Ceil(float64(len(devices)) / float64(size))
-	rsp := model.RsqManholeCoverList{
-		Current: current,
-		Size:    size,
-		Total:   len(devices),
-		Pages:   int(pages),
-	}
-	for _, device := range devices {
-
-		rsp.Records = append(rsp.Records, device)
-	}
-	ctx.JSON(http.StatusOK, util.SuccessResponse(util.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, util.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, util.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, util.SuccessResponse(util.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, util.SuccessResponse(util.Succeeded, devices))
-}
-
-func (c *manholeCoverCtl) AllList(ctx *gin.Context) {
-}
-
-func (c *manholeCoverCtl) Setting(ctx *gin.Context) {
-}

+ 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"
-	"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, util.ParamsInvalidResponse(e.Error(), nil))
-		return
-	}
-
-	device, err := service.OnDemandGroupService.Get(id)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, util.SuccessResponse(util.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, util.SuccessResponse(util.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, util.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, util.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, util.SuccessResponse(util.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, util.SuccessResponse(util.Succeeded, devices))
-}
-
-func (c *onDemandGroupCtl) GroupNumber(ctx *gin.Context) {
-	id, e := strconv.Atoi(ctx.Query("id"))
-	if e != nil {
-		ctx.JSON(http.StatusOK, util.ParamsInvalidResponse(e.Error(), nil))
-		return
-	}
-	if id <= 0 {
-		ctx.JSON(http.StatusOK, util.ParamsInvalidResponse(model.ParamsInvalid, nil))
-		return
-	}
-
-	device, err := service.OnDemandGroupService.GroupNumberList(id)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, util.SuccessResponse(util.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"
-	"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, util.ParamsInvalidResponse(e.Error(), nil))
-		return
-	}
-
-	device, err := service.OnDemandSensorService.Get(id)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, util.SuccessResponse(util.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, err := service.OnDemandSensorService.List(searchValue, current, size)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	pages := math.Ceil(float64(len(devices)) / float64(size))
-	rsp := model.RsqOnDemandSensorList{
-		Current: current,
-		Size:    size,
-		Total:   len(devices),
-		Pages:   int(pages),
-	}
-	for _, device := range devices {
-
-		rsp.Records = append(rsp.Records, device)
-	}
-	ctx.JSON(http.StatusOK, util.SuccessResponse(util.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, util.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, util.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, util.SuccessResponse(util.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"
-	"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, util.ParamsInvalidResponse(e.Error(), nil))
-		return
-	}
-
-	device, err := service.OptoSensorService.Get(id)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, util.SuccessResponse(util.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, err := service.OptoSensorService.List(searchValue, current, size)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	pages := math.Ceil(float64(len(devices)) / float64(size))
-	rsp := model.RsqOptoSensorList{
-		Current: current,
-		Size:    size,
-		Total:   len(devices),
-		Pages:   int(pages),
-	}
-	for _, device := range devices {
-
-		rsp.Records = append(rsp.Records, device)
-	}
-	ctx.JSON(http.StatusOK, util.SuccessResponse(util.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, util.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, util.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, util.SuccessResponse(util.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, util.SuccessResponse(util.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"
-	"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, util.ParamsInvalidResponse(e.Error(), nil))
-		return
-	}
-
-	device, err := service.SwitchBoxService.Get(id)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, util.SuccessResponse(util.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, err := service.SwitchBoxService.List(searchValue, current, size)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	pages := math.Ceil(float64(len(devices)) / float64(size))
-	rsp := model.RsqSwitchBoxList{
-		Current: current,
-		Size:    size,
-		Total:   len(devices),
-		Pages:   int(pages),
-	}
-	for _, device := range devices {
-
-		rsp.Records = append(rsp.Records, device)
-	}
-	ctx.JSON(http.StatusOK, util.SuccessResponse(util.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, util.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, util.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, util.SuccessResponse(util.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, util.SuccessResponse(util.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"
-	"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, util.ParamsInvalidResponse(e.Error(), nil))
-		return
-	}
-
-	device, err := service.TransformerService.Get(id)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, util.SuccessResponse(util.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, err := service.TransformerService.List(searchValue, current, size)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	pages := math.Ceil(float64(len(devices)) / float64(size))
-	rsp := model.RsqTransformerList{
-		Current: current,
-		Size:    size,
-		Total:   len(devices),
-		Pages:   int(pages),
-	}
-	for _, device := range devices {
-
-		rsp.Records = append(rsp.Records, device)
-	}
-	ctx.JSON(http.StatusOK, util.SuccessResponse(util.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, util.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, util.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, util.SuccessResponse(util.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, util.SuccessResponse(util.Succeeded, devices))
-}

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

@@ -1,107 +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"
-	"net/http"
-	"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, util.ParamsInvalidResponse("type invalid", nil))
-		return
-	}
-	modeType++ //前端传入的1和2,实际是2和3
-
-	deviceType, err := strconv.Atoi(d)
-	if err != nil {
-		ctx.JSON(http.StatusOK, util.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, util.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, util.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, util.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, util.SuccessResponse("", result))
-}
-
-func (c *utilCtl) GetTenantCode(ctx *gin.Context) {
-	ctx.JSON(http.StatusOK, util.SuccessResponse("", nil))
-}

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

@@ -1,86 +0,0 @@
-package controller
-
-import (
-	"github.com/gin-gonic/gin"
-	"iot_manager_service/app/device/service"
-	"iot_manager_service/app/middleware"
-	"iot_manager_service/util"
-	"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, util.SuccessResponse(util.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, util.SuccessResponse(util.Succeeded, alarms))
-}
-
-func (c *workbenchCtl) Aqi(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, util.SuccessResponse(util.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, util.SuccessResponse(util.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, util.SuccessResponse(util.Succeeded, alarms))
-}
-
-func (c *workbenchCtl) LightRate(ctx *gin.Context) {
-	value, _ := ctx.Get(middleware.Authorization)
-	claims := value.(*middleware.Claims)
-	//queryType=month&startDate=2022-09-01&endDate=2022-10-04
-	alarms, err := service.WorkbenchService.LightRate(claims.TenantId)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, util.SuccessResponse(util.Succeeded, alarms))
-}

+ 0 - 113
app/device/controller/zigbeeController.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"
-	"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, util.ParamsInvalidResponse(e.Error(), nil))
-		return
-	}
-
-	device, err := service.ZigbeeService.Get(id)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	ctx.JSON(http.StatusOK, util.SuccessResponse(util.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, err := service.ZigbeeService.List(searchValue, current, size)
-	if err != nil {
-		ctx.JSON(http.StatusOK, err)
-		return
-	}
-	pages := math.Ceil(float64(len(devices)) / float64(size))
-	rsp := model.RsqZigbeeList{
-		Current: current,
-		Size:    size,
-		Total:   len(devices),
-		Pages:   int(pages),
-	}
-	for _, device := range devices {
-
-		rsp.Records = append(rsp.Records, device)
-	}
-	ctx.JSON(http.StatusOK, util.SuccessResponse(util.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, util.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, util.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, util.SuccessResponse(util.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, util.SuccessResponse(util.Succeeded, devices))
-}

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

@@ -1,88 +0,0 @@
-package dao
-
-import (
-	"github.com/jinzhu/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           int       `gorm:"type:int" json:"tenantId"`                     //租户ID
-	CreateTime         time.Time `gorm:"type:datetime" json:"createTime"`              //新增时间
-	CreateUser         int64     `gorm:"type:bigint" json:"createUser"`                //新增记录操作用户ID
-	UpdateTime         time.Time `gorm:"type:datetime" json:"updateTime"`              //修改时间
-	UpdateUser         int64     `gorm:"type:bigint" 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.Debug().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 = 0
-	_ = Db.Debug().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.Debug().Model(&c).Where("gateway_sn = ? and is_deleted = ?",
-		c.TenantId, c.IsDeleted).Find(&Strategies).Error
-	if gorm.IsRecordNotFoundError(err) {
-		return false
-	}
-	for _, d := range Strategies {
-		if d.ID != c.ID {
-			return true
-		}
-	}
-	return false
-}
-
-func (c *LightStrategy) Create() error {
-	return Db.Debug().Model(&c).Save(&c).Error
-}
-
-func (c *LightStrategy) Update() error {
-	return Db.Debug().Model(&c).Where(" id = ? and is_deleted = 0", c.ID).Update(&c).Error
-}
-
-func (c *LightStrategy) GetStrategy() error {
-	err := Db.Debug().Model(&c).Where(" id = ? and is_deleted = 0", c.ID).First(&c).Error
-	return err
-}
-
-func (c LightStrategy) GetStrategies(offset, limit int) ([]LightStrategy, error) {
-	var Strategies []LightStrategy
-	db := Db.Debug().Model(&c).Where("is_deleted = 0")
-	if c.LightSn != "" {
-		db = db.Where(" light_name like ? or light_sn like ?", "%"+c.LightSn+"%", "%"+c.LightSn+"%")
-	}
-	err := Db.Debug().Model(&c).Offset(offset).Limit(limit).Find(&Strategies).Error
-	return Strategies, err
-
-}
-
-func (c LightStrategy) GetAllStrategies() ([]*LightStrategy, error) {
-	var Strategies []*LightStrategy
-	err := Db.Debug().Model(&c).Where(" tenant_id = ? and is_deleted = ? ", c.TenantId,
-		c.IsDeleted).Scan(&Strategies).Error
-	return Strategies, err
-}

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

@@ -1,87 +0,0 @@
-package dao
-
-import (
-	"github.com/jinzhu/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
-	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    int        `gorm:"type:int" json:"tenantId"`          //租户id
-	CreateTime  time.Time  `gorm:"type:datetime" json:"createTime"`   //新增时间
-	CreateUser  int64      `gorm:"type:bigint" json:"createUser"`     //新增记录操作用户ID
-	UpdateTime  time.Time  `gorm:"type:datetime" json:"updateTime"`   //修改时间
-	UpdateUser  int64      `gorm:"type:bigint" 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.Debug().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 = 0
-	_ = Db.Debug().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.Debug().Model(&c).Where(" serve_sn = ? and is_deleted = ?",
-		c.ServeSN, c.IsDeleted).Find(&devices).Error
-	//如果查询不到,返回相应的错误
-	if gorm.IsRecordNotFoundError(err) {
-		return false
-	}
-	for _, d := range devices {
-		if d.ID != c.ID {
-			return true
-		}
-	}
-	return false
-}
-
-func (c *Alarm) Create() error {
-	return Db.Debug().Model(&c).Save(&c).Error
-}
-
-func (c *Alarm) Update() error {
-	return Db.Debug().Model(&c).Where(" id = ? ", c.ID).Update(&c).Error
-}
-
-func (c *Alarm) GetDevice() error {
-	err := Db.Debug().Model(&c).Where(" id = ? ", c.ID).Scan(&c).Error
-	return err
-}
-
-func (c Alarm) GetDevices(offset, limit int) ([]Alarm, error) {
-	var devices []Alarm
-	err := Db.Debug().Model(&c).Where(" serve_name like ? and is_deleted = 0", "%"+c.ServeName+"%").Offset(offset).Limit(limit).Find(&devices).Error
-	return devices, err
-}
-
-func (c Alarm) GetAllDevices() ([]*Alarm, error) {
-	var devices []*Alarm
-	err := Db.Debug().Model(&c).Where(" tenant_id = ? and is_deleted = ? ", c.TenantId, c.IsDeleted).Scan(&devices).Error
-	return devices, err
-}

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

@@ -1,105 +0,0 @@
-package dao
-
-import (
-	"github.com/jinzhu/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         int       `gorm:"type:int" json:"tenantId"`                  //租户id
-	CreateTime       time.Time `gorm:"type:datetime" json:"createTime"`           //新增时间
-	CreateUser       int64     `gorm:"type:bigint" json:"createUser"`             //新增记录操作用户ID
-	UpdateTime       time.Time `gorm:"type:datetime" json:"updateTime"`           //修改时间
-	UpdateUser       int64     `gorm:"type:bigint" 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.Debug().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 = 0
-	_ = Db.Debug().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.Debug().Model(&c).Where(" terminal_sn = ? and is_deleted = ?",
-		c.TerminalSN, c.IsDeleted).Find(&devices).Error
-	//如果查询不到,返回相应的错误
-	if gorm.IsRecordNotFoundError(err) {
-		return false
-	}
-	for _, d := range devices {
-		if d.ID != c.ID {
-			return true
-		}
-	}
-	return false
-}
-
-func (c *AlarmTerminal) Create() error {
-	return Db.Debug().Model(&c).Save(&c).Error
-}
-
-func (c *AlarmTerminal) Update() error {
-	return Db.Debug().Model(&c).Where(" id = ? ", c.ID).Update(&c).Error
-}
-
-func (c *AlarmTerminal) GetDevice() error {
-	err := Db.Debug().Model(&c).Where(" id = ? ", c.ID).Scan(&c).Error
-	return err
-}
-
-func (c AlarmTerminal) GetDevices(offset, limit int) ([]AlarmTerminal, error) {
-	var devices []AlarmTerminal
-	err := Db.Debug().Model(&c).Where(" terminal_name like ? and is_deleted = 0", "%"+c.TerminalName+"%").Offset(offset).Limit(limit).Find(&devices).Error
-	return devices, err
-}
-
-func (c AlarmTerminal) GetAllDevices() ([]*AlarmTerminal, error) {
-	var devices []*AlarmTerminal
-	err := Db.Debug().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.Debug().Model(&c).Where(" gateway_id = ? and is_deleted = 0",
-		c.GatewayId).Find(&devices)
-	return devices
-}
-
-func (c AlarmTerminal) GetDevicesByLampPole() []AlarmTerminal {
-	var devices []AlarmTerminal
-	Db.Debug().Model(&c).Where("lamp_pole_id = ? and is_deleted = 0",
-		c.LampPoleId).Find(&devices)
-	return devices
-}

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

@@ -1,96 +0,0 @@
-package dao
-
-import (
-	"github.com/jinzhu/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          int       `gorm:"type:int" json:"tenantId"`                   //租户id
-	CreateTime        time.Time `gorm:"type:datetime" json:"createTime"`            //新增时间
-	CreateUser        int64     `gorm:"type:bigint" json:"createUser"`              //新增记录操作用户ID
-	UpdateTime        time.Time `gorm:"type:datetime" json:"updateTime"`            //修改时间
-	UpdateUser        int64     `gorm:"type:bigint" 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.Debug().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 = 0
-	_ = Db.Debug().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.Debug().Model(&c).Where(" sn = ? and is_deleted = ?",
-		c.SN, c.IsDeleted).Find(&devices).Error
-	//如果查询不到,返回相应的错误
-	if gorm.IsRecordNotFoundError(err) {
-		return false
-	}
-	for _, d := range devices {
-		if d.ID != c.ID {
-			return true
-		}
-	}
-	return false
-}
-
-func (c *Bridge) Create() error {
-	return Db.Debug().Model(&c).Save(&c).Error
-}
-
-func (c *Bridge) Update() error {
-	return Db.Debug().Model(&c).Where(" id = ? ", c.ID).Update(&c).Error
-}
-
-func (c *Bridge) GetDevice() error {
-	err := Db.Debug().Model(&c).Where(" id = ? ", c.ID).Scan(&c).Error
-	return err
-}
-
-func (c Bridge) GetDevices(offset, limit int) ([]Bridge, error) {
-	var devices []Bridge
-	err := Db.Debug().Model(&c).Where(" name like ? and is_deleted = 0", "%"+c.Name+"%").Offset(offset).Limit(limit).Find(&devices).Error
-	return devices, err
-}
-
-func (c Bridge) GetAllDevices() ([]*Bridge, error) {
-	var devices []*Bridge
-	err := Db.Debug().Model(&c).Where(" tenant_id = ? and is_deleted = ? ", c.TenantId, c.IsDeleted).Scan(&devices).Error
-	return devices, err
-}

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

@@ -1,92 +0,0 @@
-package dao
-
-import (
-	"github.com/jinzhu/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         int        `gorm:"type:int" json:"tenantID"`                 //租户id
-	CreateTime       time.Time  `gorm:"type:datetime" json:"createTime"`          //新增时间
-	CreateUser       int64      `gorm:"type:bigint" json:"createUser"`            //新增记录操作用户ID
-	UpdateTime       time.Time  `gorm:"type:datetime" json:"updateTime"`          //修改时间
-	UpdateUser       int64      `gorm:"type:bigint" 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.Debug().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 = 0
-	_ = Db.Debug().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.Debug().Model(&c).Where(" sn = ? and is_deleted = ?",
-		c.SN, c.IsDeleted).Find(&devices).Error
-	//如果查询不到,返回相应的错误
-	if gorm.IsRecordNotFoundError(err) {
-		return false
-	}
-	for _, d := range devices {
-		if d.ID != c.ID {
-			return true
-		}
-	}
-	return false
-}
-
-func (c *BridgeSensor) Create() error {
-	return Db.Debug().Model(&c).Save(&c).Error
-}
-
-func (c *BridgeSensor) Update() error {
-	return Db.Debug().Model(&c).Where(" id = ? ", c.ID).Update(&c).Error
-}
-
-func (c *BridgeSensor) GetDevice() error {
-	err := Db.Debug().Model(&c).Where(" id = ? ", c.ID).Scan(&c).Error
-	return err
-}
-
-func (c BridgeSensor) GetDevices(offset, limit int) ([]BridgeSensor, error) {
-	var devices []BridgeSensor
-	err := Db.Debug().Model(&c).Where(" name like ? and is_deleted = 0", "%"+c.Name+"%").Offset(offset).Limit(limit).Find(&devices).Error
-	return devices, err
-}
-
-func (c BridgeSensor) GetAllDevices() ([]*BridgeSensor, error) {
-	var devices []*BridgeSensor
-	err := Db.Debug().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.Debug().Model(&c).Where(" id = ? ", c.ID).Updates(map[string]interface{}{"is_enable": c.IsEnable}).Error
-}

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

@@ -1,104 +0,0 @@
-package dao
-
-import (
-	"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      time.Time `gorm:"type:date" json:"installTime"`                   //安装时间
-	TenantId         int       `gorm:"type:int" json:"tenantId"`                       //租户ID
-	CreateTime       time.Time `gorm:"type:datetime" json:"createTime"`                //新增时间
-	CreateUser       int64     `gorm:"type:bigint" json:"createUser"`                  //新增记录操作用户ID
-	UpdateTime       time.Time `gorm:"type:datetime" json:"updateTime"`                //修改时间
-	UpdateUser       int64     `gorm:"type:bigint" 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:"stream_id"`             //流id
-}
-
-func (CameraDevice) TableName() string {
-	return "device_camera"
-}
-
-func (c CameraDevice) IsExistedBySN() bool {
-	var count = 0
-	_ = Db.Debug().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.Debug().Model(&c).Save(&c).Error
-}
-
-func (c *CameraDevice) Update() error {
-	return Db.Debug().Model(&c).Where(" id = ? ", c.ID).Update(&c).Error
-}
-
-func (c *CameraDevice) GetDevice() error {
-	err := Db.Debug().Model(&c).Where(" id = ? ", c.ID).First(&c).Error
-	return err
-}
-
-func (c CameraDevice) GetDevices(offset, limit int) ([]CameraDevice, error) {
-	var devices []CameraDevice
-	db := Db.Debug().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)
-	}
-
-	err := db.Where("is_deleted = 0").Offset(offset).Limit(limit).Find(&devices).Error
-	return devices, err
-}
-
-func (c *CameraDevice) Delete() error {
-	return Db.Debug().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.Debug().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.Debug().Model(&c).Where(" id = ? ", c.ID).Updates(map[string]interface{}{"is_enable": c.IsEnable}).Error
-}
-
-func (c CameraDevice) GetDevicesByGateway() []CameraDevice {
-	var devices []CameraDevice
-	Db.Debug().Model(&c).Where(" gateway_id = ? and is_deleted = 0",
-		c.GatewayId).Find(&devices)
-	return devices
-}
-
-func (c CameraDevice) GetDevicesByLampPole() []CameraDevice {
-	var devices []CameraDevice
-	Db.Debug().Model(&c).Where("lamp_pole_id = ? and is_deleted = 0",
-		c.LampPoleId).Find(&devices)
-	return devices
-}

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

@@ -1,98 +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:"radar_specification"`         //雷达规格
-	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               int       `gorm:"type:int" json:"tenantId"`                             //租户ID
-	CreateTime             time.Time `gorm:"type:datetime" json:"createTime"`                      //新增时间
-	CreateUser             int64     `gorm:"type:bigint" json:"createUser"`                        //新增记录操作用户ID
-	UpdateTime             time.Time `gorm:"type:datetime" json:"updateTime"`                      //修改时间
-	UpdateUser             int64     `gorm:"type:bigint" 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 = 0
-	_ = Db.Debug().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.Debug().Model(&c).Save(&c).Error
-}
-
-func (c *CaptureUnit) Update() error {
-	return Db.Debug().Model(&c).Where(" id = ? ", c.ID).Update(&c).Error
-}
-
-func (c *CaptureUnit) GetDevice() error {
-	err := Db.Debug().Model(&c).Where(" id = ? ", c.ID).First(&c).Error
-	return err
-}
-
-func (c CaptureUnit) GetDevices(offset, limit int) ([]CaptureUnit, error) {
-	var Captures []CaptureUnit
-	db := Db.Debug().Model(&c)
-	if c.CaptureSn != "" {
-		db = db.Where("capture_name like ? or capture_sn like ?", "%"+c.CaptureSn+"%", "%"+c.CaptureSn+"%")
-	}
-
-	err := db.Where("is_deleted = 0").Offset(offset).Limit(limit).Find(&Captures).Error
-	return Captures, err
-}
-
-func (c *CaptureUnit) Delete() error {
-	return Db.Debug().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.Debug().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.Debug().Model(&c).Where(" gateway_id = ? and is_deleted = 0",
-		c.GatewayId).Find(&devices)
-	return devices
-}
-
-func (c CaptureUnit) GetDevicesByLampPole() []CaptureUnit {
-	var devices []CaptureUnit
-	Db.Debug().Model(&c).Where("lamp_pole_id = ? and is_deleted = 0",
-		c.LampPoleId).Find(&devices)
-	return devices
-}

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

@@ -1,65 +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      int       `gorm:"type:int" json:"tenantId"`               //租户ID
-	CreateTime    time.Time `gorm:"type:datetime" json:"createTime"`        //新增时间
-	CreateUser    int64     `gorm:"type:bigint" json:"createUser"`          //新增记录操作用户ID
-	UpdateTime    time.Time `gorm:"type:datetime" json:"updateTime"`        //修改时间
-	UpdateUser    int64     `gorm:"type:bigint" 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 = 0
-	_ = Db.Debug().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.Debug().Model(&c).Save(&c).Error
-}
-
-func (c *CheckPoint) Update() error {
-	return Db.Debug().Model(&c).Where(" id = ? ", c.ID).Update(&c).Error
-}
-
-func (c *CheckPoint) GetDevice() error {
-	err := Db.Debug().Model(&c).Where(" id = ? ", c.ID).First(&c).Error
-	return err
-}
-
-func (c CheckPoint) GetDevices(offset, limit int) ([]CheckPoint, error) {
-	var Points []CheckPoint
-	db := Db.Debug().Model(&c)
-	if c.PointSN != "" {
-		db = db.Where("point_name like ? or point_sn like ?", "%"+c.PointSN+"%", "%"+c.PointSN+"%")
-	}
-
-	err := db.Where("is_deleted = 0").Offset(offset).Limit(limit).Find(&Points).Error
-	return Points, err
-}
-
-func (c *CheckPoint) Delete() error {
-	return Db.Debug().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.Debug().Model(&c).Where(" tenant_id = ? and is_deleted = ? ", c.TenantId, c.IsDeleted).Scan(&Points).Error
-	return Points, err
-}

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

@@ -1,49 +0,0 @@
-package dao
-
-import (
-	"fmt"
-	"github.com/jinzhu/gorm"
-	"iot_manager_service/app/system/dao"
-)
-
-var Db *gorm.DB
-
-func InitDB(db *gorm.DB) {
-	Db = db
-	err := Db.AutoMigrate(
-		&dao.User{},
-		&dao.Dict{},
-		&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{},
-		&dao.OperationHistory{},
-	).Error
-	if err != nil {
-		panic(fmt.Sprintf("AutoMigrate err : %v", err))
-	}
-}

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

@@ -1,98 +0,0 @@
-package dao
-
-import (
-	"github.com/jinzhu/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        int       `gorm:"type:int" json:"tenantId"`                 //租户id
-	CreateTime      time.Time `gorm:"type:datetime" json:"createTime"`          //新增时间
-	CreateUser      int64     `gorm:"type:bigint" json:"createUser"`            //新增记录操作用户ID
-	UpdateTime      time.Time `gorm:"type:datetime" json:"updateTime"`          //修改时间
-	UpdateUser      int64     `gorm:"type:bigint" 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.Debug().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 = 0
-	_ = Db.Debug().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.Debug().Model(&c).Where(" device_sn = ? and is_deleted = ?",
-		c.DeviceSN, c.IsDeleted).Find(&devices).Error
-	//如果查询不到,返回相应的错误
-	if gorm.IsRecordNotFoundError(err) {
-		return false
-	}
-	for _, d := range devices {
-		if d.ID != c.ID {
-			return true
-		}
-	}
-	return false
-}
-
-func (c *Garbage) Create() error {
-	return Db.Debug().Model(&c).Save(&c).Error
-}
-
-func (c *Garbage) Update() error {
-	return Db.Debug().Model(&c).Where(" id = ? ", c.ID).Update(&c).Error
-}
-
-func (c *Garbage) GetDevice() error {
-	err := Db.Debug().Model(&c).Where(" id = ? ", c.ID).Scan(&c).Error
-	return err
-}
-
-func (c Garbage) GetDevices(offset, limit int) ([]Garbage, error) {
-	var devices []Garbage
-	err := Db.Debug().Model(&c).Where(" device_name like ? and is_deleted = 0", "%"+c.DeviceName+"%").Offset(offset).Limit(limit).Find(&devices).Error
-	return devices, err
-}
-
-func (c Garbage) GetAllDevices() ([]*Garbage, error) {
-	var devices []*Garbage
-	err := Db.Debug().Model(&c).Where(" tenant_id = ? and is_deleted = ? ", c.TenantId, c.IsDeleted).Scan(&devices).Error
-	return devices, err
-}

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

@@ -1,76 +0,0 @@
-package dao
-
-import (
-	"github.com/jinzhu/gorm"
-	"time"
-)
-
-// GarbageWayGroup 垃圾桶道路分组管理
-type GarbageWayGroup struct {
-	ID         int       `gorm:"primary_key" json:"id"`               //编号
-	GroupName  string    `gorm:"type:varchar(64)" json:"groupName"`   //分组名称
-	TenantId   int       `gorm:"type:int" json:"tenantId"`            //租户id
-	CreateTime time.Time `gorm:"type:datetime" json:"createTime"`     //新增时间
-	CreateUser int64     `gorm:"type:bigint" json:"createUser"`       //新增记录操作用户ID
-	UpdateTime time.Time `gorm:"type:datetime" json:"updateTime"`     //修改时间
-	UpdateUser int64     `gorm:"type:bigint" 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.Debug().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 = 0
-	_ = Db.Debug().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.Debug().Model(&c).Where(" group_name = ? and is_deleted = ?",
-		c.GroupName, c.IsDeleted).Find(&devices).Error
-	//如果查询不到,返回相应的错误
-	if gorm.IsRecordNotFoundError(err) {
-		return false
-	}
-	for _, d := range devices {
-		if d.ID != c.ID {
-			return true
-		}
-	}
-	return false
-}
-
-func (c *GarbageWayGroup) Create() error {
-	return Db.Debug().Model(&c).Save(&c).Error
-}
-
-func (c *GarbageWayGroup) Update() error {
-	return Db.Debug().Model(&c).Where(" id = ? ", c.ID).Update(&c).Error
-}
-
-func (c *GarbageWayGroup) GetDevice() error {
-	err := Db.Debug().Model(&c).Where(" id = ? ", c.ID).Scan(&c).Error
-	return err
-}
-
-func (c GarbageWayGroup) GetDevices(offset, limit int) ([]GarbageWayGroup, error) {
-	var devices []GarbageWayGroup
-	err := Db.Debug().Model(&c).Where(" group_name like ? and is_deleted = 0", "%"+c.GroupName+"%").Offset(offset).Limit(limit).Find(&devices).Error
-	return devices, err
-}
-
-func (c GarbageWayGroup) GetAllDevices() ([]*GarbageWayGroup, error) {
-	var devices []*GarbageWayGroup
-	err := Db.Debug().Model(&c).Where(" tenant_id = ? and is_deleted = ? ", c.TenantId, c.IsDeleted).Scan(&devices).Error
-	return devices, err
-}

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

@@ -1,104 +0,0 @@
-package dao
-
-import (
-	"github.com/jinzhu/gorm"
-	"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 time.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           int       `gorm:"type:int" json:"tenantId"`                        //租户ID
-	CreateTime         time.Time `gorm:"type:datetime" json:"createTime"`                 //新增时间
-	CreateUser         int64     `gorm:"type:bigint" json:"createUser"`                   //新增记录操作用户ID
-	UpdateTime         time.Time `gorm:"type:datetime" json:"updateTime"`                 //修改时间
-	UpdateUser         int64     `gorm:"type:bigint" 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.Debug().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 = 0
-	_ = Db.Debug().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.Debug().Model(&c).Where("gateway_sn = ? and is_deleted = ?",
-		c.TenantId, c.IsDeleted).Find(&devices).Error
-	if gorm.IsRecordNotFoundError(err) {
-		return false
-	}
-	for _, d := range devices {
-		if d.ID != c.ID {
-			return true
-		}
-	}
-	return false
-}
-
-func (c *Gateway) Create() error {
-	return Db.Debug().Model(&c).Save(&c).Error
-}
-
-func (c *Gateway) Update() error {
-	return Db.Debug().Model(&c).Where(" id = ? ", c.ID).Update(&c).Error
-}
-
-func (c *Gateway) GetDevice() error {
-	err := Db.Debug().Model(&c).Where(" id = ? ", c.ID).First(&c).Error
-	return err
-}
-
-func (c Gateway) GetDevices(offset, limit int) ([]Gateway, error) {
-	var devices []Gateway
-	db := Db.Debug().Model(&c)
-	if c.GatewaySn != "" {
-		db = db.Where("gateway_name like ? or gateway_sn like ?", "%"+c.GatewaySn+"%", "%"+c.GatewaySn+"%")
-	}
-
-	err := db.Where("is_deleted = 0").Offset(offset).Limit(limit).Find(&devices).Error
-	return devices, err
-}
-
-func (c Gateway) GetAllDevices() ([]*Gateway, error) {
-	var devices []*Gateway
-	err := Db.Debug().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.Debug().Model(&c).Where("lamp_pole_id = ? and is_deleted = 0",
-		c.LampPoleId).Find(&devices)
-	return devices
-}

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

@@ -1,30 +0,0 @@
-package dao
-
-import (
-	"time"
-)
-
-//GatewayRelation 网关挂载设备关联信息表
-type GatewayRelation struct {
-	ID                 int       `gorm:"type:int;primary_key"`                //编号 网关ID
-	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音柱数量
-	Total              int       `gorm:"type:int;default 0"`                  //总数
-	TenantId           int       `gorm:"type:int" 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.Debug().Model(&c).Where("id = ?", c.ID).Find(&c).Error
-}

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

@@ -1,111 +0,0 @@
-package dao
-
-import (
-	"github.com/jinzhu/gorm"
-	"time"
-)
-
-//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:"poleLng"`              //经度
-	PoleLat          float64   `gorm:"type:double(17, 14)  " json:"poleLat"`             //纬度
-	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:time" json:"bootStartTime"`                   //开机开始时间
-	BootEndTime      string    `gorm:"type:time" json:"bootEndTime"`                     //开机结束时间
-	NeverCloseDown   int       `gorm:"type:int" json:"neverCloseDown"`                   //永不关机:1-选择,2-取消
-	InstallTime      time.Time `gorm:"type:date" json:"installTime"`                     //安装时间
-	TenantId         int       `gorm:"type:int" json:"tenantId"`                         //租户ID
-	CreateTime       time.Time `gorm:"type:datetime" json:"createTime"`                  //新增时间
-	CreateUser       int64     `gorm:"type:bigint" json:"createUser"`                    //新增记录操作用户ID
-	UpdateTime       time.Time `gorm:"type:datetime" json:"updateTime"`                  //修改时间
-	UpdateUser       int64     `gorm:"type:bigint" 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禁用
-}
-
-func (InfoBoard) TableName() string {
-	return "device_info_board"
-}
-
-func (c InfoBoard) Delete() error {
-	return Db.Debug().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 = 0
-	_ = Db.Debug().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.Debug().Model(&c).Where(" sn = ? and is_deleted = ?",
-		c.Sn, c.IsDeleted).Find(&devices).Error
-	//如果查询不到,返回相应的错误
-	if gorm.IsRecordNotFoundError(err) {
-		return false
-	}
-	for _, d := range devices {
-		if d.ID != c.ID {
-			return true
-		}
-	}
-	return false
-}
-
-func (c *InfoBoard) Create() error {
-	return Db.Debug().Model(&c).Save(&c).Error
-}
-
-func (c *InfoBoard) Update() error {
-	return Db.Debug().Model(&c).Where(" id = ? ", c.ID).Update(&c).Error
-}
-
-func (c *InfoBoard) GetDevice() error {
-	err := Db.Debug().Model(&c).Where(" id = ? ", c.ID).Scan(&c).Error
-	return err
-}
-
-func (c InfoBoard) GetDevices(offset, limit int) ([]InfoBoard, error) {
-	var devices []InfoBoard
-	err := Db.Debug().Model(&c).Where(" info_name like ? ", "%"+c.InfoName+"%").Offset(offset).Limit(limit).Find(&devices).Error
-	return devices, err
-}
-
-func (c InfoBoard) GetAllDevices() ([]*InfoBoard, error) {
-	var devices []*InfoBoard
-	err := Db.Debug().Model(&c).Where(" tenant_id = ? and is_deleted = ? ", c.TenantId, c.IsDeleted).Scan(&devices).Error
-	return devices, err
-}
-
-func (c InfoBoard) GetDevicesByGateway() []InfoBoard {
-	var devices []InfoBoard
-	Db.Debug().Model(&c).Where(" gateway_id = ? and is_deleted = 0",
-		c.GatewayId).Find(&devices)
-	return devices
-}
-
-func (c InfoBoard) GetDevicesByLampPole() []InfoBoard {
-	var devices []InfoBoard
-	Db.Debug().Model(&c).Where("lamp_pole_id = ? and is_deleted = 0",
-		c.LampPoleId).Find(&devices)
-	return devices
-}

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

@@ -1,65 +0,0 @@
-package dao
-
-import (
-	"time"
-)
-
-type IntelligentLightGroupRelation struct {
-	IntelligentLight
-	LightStrategy
-	LightControl
-	TimeCondition
-}
-
-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     int       `gorm:"type:int" json:"tenantId"`            //租户ID
-	CreateTime   time.Time `gorm:"type:datetime" json:"createTime"`     //新增时间
-	CreateUser   int64     `gorm:"type:bigint" json:"createUser"`       //新增记录操作用户ID
-	UpdateTime   time.Time `gorm:"type:datetime" json:"updateTime"`     //修改时间
-	UpdateUser   int64     `gorm:"type:bigint" json:"updateUser"`       //修改用户
-	IsDeleted    int       `gorm:"type:int;default 0" json:"isDeleted"` //是否删除 0=未删除,1=删除
-}
-
-func (IntelligentLight) TableName() string {
-	return "strategy_intelligent_light"
-}
-
-func (c *IntelligentLight) BatchGet(ids []int) ([]IntelligentLight, error) {
-	var intelligentLights []IntelligentLight
-	err := Db.Debug().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.Debug().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) GetByGroup(searchValue string, current, size,
-	groupId int) ([]IntelligentLightGroupRelation, error) {
-	var groupRelations []IntelligentLightGroupRelation
-	selectStr := "lig.*,con.id,con.name,b.light_name,t.luminance"
-	whereStr := "lig.is_deleted = 0 and relation_type = 1 and lig.tenant_id = ? and con.group_id = ?"
-	whereValue := []interface{}{c.TenantId, groupId}
-	if searchValue != "" {
-		whereStr += " and (con.sn like '%?%' or con.name like '%?%')"
-		whereValue = append(whereValue, searchValue, searchValue)
-	}
-	err := Db.Debug().Table("strategy_intelligent_light lig").Select(selectStr).
-		Joins("left join device_light_control con ON lig.rid = con.id").
-		Joins("left join strategy_light b ON b.id = lig.light_id").
-		Joins("left join strategy_time_condition t ON t.light_id = lig.light_id").
-		Where(whereStr, whereValue...).Offset(current).Limit(size).
-		Order("lig.create_time desc").Scan(&groupRelations).Error
-	return groupRelations, err
-}

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

@@ -1,103 +0,0 @@
-package dao
-
-import (
-	"github.com/jinzhu/gorm"
-	"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地址
-	ServiceIpAddress string     `gorm:"type:varchar(50)" json:"serviceIpAddress"`         //服务IP地址
-	ServerPort       int        `gorm:"type:int" json:"serverPort"`                       //服务端口
-	SoundVolume      int        `gorm:"type:int" json:"soundVolume"`                      //音量0-100换算
-	InstallTime      *time.Time `gorm:"type:date" json:"installTime"`                     //安装时间
-	TenantId         int        `gorm:"type:int" json:"tenantId"`                         //租户ID
-	CreateTime       time.Time  `gorm:"type:datetime" json:"createTime"`                  //新增时间
-	CreateUser       int64      `gorm:"type:bigint" json:"createUser"`                    //新增记录操作用户ID
-	UpdateTime       time.Time  `gorm:"type:datetime" json:"updateTime"`                  //修改时间
-	UpdateUser       int64      `gorm:"type:bigint" 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.Debug().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 = 0
-	_ = Db.Debug().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.Debug().Model(&c).Where(" cast_sn = ? and is_deleted = ?",
-		c.CastSn, c.IsDeleted).Find(&devices).Error
-	//如果查询不到,返回相应的错误
-	if gorm.IsRecordNotFoundError(err) {
-		return false
-	}
-	for _, d := range devices {
-		if d.ID != c.ID {
-			return true
-		}
-	}
-	return false
-}
-
-func (c *IpBroadcast) Create() error {
-	return Db.Debug().Model(&c).Save(&c).Error
-}
-
-func (c *IpBroadcast) Update() error {
-	return Db.Debug().Model(&c).Where(" id = ? ", c.ID).Update(&c).Error
-}
-
-func (c *IpBroadcast) GetDevice() error {
-	err := Db.Debug().Model(&c).Where(" id = ? ", c.ID).Scan(&c).Error
-	return err
-}
-
-func (c IpBroadcast) GetDevices(offset, limit int) ([]IpBroadcast, error) {
-	var devices []IpBroadcast
-	err := Db.Debug().Model(&c).Where(" cast_name like ? ", "%"+c.CastName+"%").Offset(offset).Limit(limit).Find(&devices).Error
-	return devices, err
-}
-
-func (c IpBroadcast) GetAllDevices() ([]IpBroadcast, error) {
-	var devices []IpBroadcast
-	err := Db.Debug().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.Debug().Model(&c).Where(" gateway_id = ? and is_deleted = 0",
-		c.GatewayId).Find(&devices)
-	return devices
-}
-
-func (c IpBroadcast) GetDevicesByLampPole() []IpBroadcast {
-	var devices []IpBroadcast
-	Db.Debug().Model(&c).Where("lamp_pole_id = ? and is_deleted = 0",
-		c.LampPoleId).Find(&devices)
-	return devices
-}

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

@@ -1,112 +0,0 @@
-package dao
-
-import (
-	"github.com/jinzhu/gorm"
-	"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     time.Time `gorm:"type:date" json:"installTime"`             //安装时间
-	LampPolePhoto   string    `gorm:"type:varchar(255)" json:"lampPolePhoto"`   //灯杆照片
-	TenantId        int       `gorm:"type:int" json:"tenantId"`                 //租户ID
-	CreateTime      time.Time `gorm:"type:datetime" json:"createTime"`          //新增时间
-	CreateUser      int64     `gorm:"type:bigint" json:"createUser"`            //新增记录操作用户ID
-	UpdateTime      time.Time `gorm:"type:datetime" json:"updateTime"`          //修改时间
-	UpdateUser      int64     `gorm:"type:bigint" 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.Debug().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 = 0
-	_ = Db.Debug().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.Debug().Model(&c).Where("pole_sn = ? and is_deleted = ?",
-		c.TenantId, c.IsDeleted).Find(&devices).Error
-	if gorm.IsRecordNotFoundError(err) {
-		return false
-	}
-	for _, d := range devices {
-		if d.ID != c.ID {
-			return true
-		}
-	}
-	return false
-}
-
-func (c *LampPole) Create() error {
-	return Db.Debug().Model(&c).Save(&c).Error
-}
-
-func (c *LampPole) Update() error {
-	return Db.Debug().Model(&c).Where(" id = ? ", c.ID).Update(&c).Error
-}
-
-func (c *LampPole) GetDevice() error {
-	err := Db.Debug().Model(&c).Where(" id = ? ", c.ID).First(&c).Error
-	return err
-}
-
-func (c LampPole) GetDevices(offset, limit int) ([]LampPole, error) {
-	var devices []LampPole
-
-	db := Db.Debug().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)
-	}
-	err := db.Where("is_deleted = 0").Offset(offset).Limit(limit).Find(&devices).Error
-	return devices, err
-}
-
-func (c LampPole) GetAllDevices() ([]*LampPole, error) {
-	var devices []*LampPole
-	err := Db.Debug().Model(&c).Where(" tenant_id = ? and is_deleted = ? ", c.TenantId, c.IsDeleted).Scan(&devices).Error
-	return devices, err
-}
-
-func (c LampPole) Count() int {
-	var count = 0
-	_ = Db.Debug().Model(&c).Where(" group_id = ? and is_deleted = ?",
-		c.GroupId, c.IsDeleted).Count(&count).Error
-	return count
-}

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

@@ -1,78 +0,0 @@
-package dao
-
-import (
-	"github.com/jinzhu/gorm"
-	"time"
-)
-
-//LampPoleGroup 灯杆分组
-type LampPoleGroup struct {
-	ID            int       `gorm:"primary_key" json:"id"`                 //编号
-	PoleGroupName string    `gorm:"type:varchar(64)" json:"poleGroupName"` //分组名称
-	TenantId      int       `gorm:"type:int" json:"tenantId"`              //租户ID
-	CreateTime    time.Time `gorm:"type:datetime" json:"createTime"`       //新增时间
-	CreateUser    int64     `gorm:"type:bigint" json:"createUser"`         //新增记录操作用户ID
-	UpdateTime    time.Time `gorm:"type:datetime" json:"updateTime"`       //修改时间
-	UpdateUser    int64     `gorm:"type:bigint" 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" json:"countLampPole"`         //灯杆数
-}
-
-func (LampPoleGroup) TableName() string {
-	return "device_lamp_pole_group"
-}
-
-func (c *LampPoleGroup) Delete() error {
-	return Db.Debug().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 = 0
-	_ = Db.Debug().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.Debug().Model(&c).Where("pole_group_name = ? and tenant_id = ? and is_deleted = ?",
-		c.PoleGroupName, c.TenantId, c.IsDeleted).Find(&devices).Error
-	if gorm.IsRecordNotFoundError(err) {
-		return false
-	}
-	for _, d := range devices {
-		if d.ID != c.ID {
-			return true
-		}
-	}
-	return false
-}
-
-func (c *LampPoleGroup) Create() error {
-	return Db.Debug().Model(&c).Save(&c).Error
-}
-
-func (c *LampPoleGroup) Update() error {
-	return Db.Debug().Model(&c).Where(" id = ? ", c.ID).Updates(map[string]interface{}{"pole_group_name": c.PoleGroupName,
-		"tenant_id": c.TenantId, "update_time": time.Now(), "update_user": c.UpdateUser, "is_deleted": 0}).Error
-}
-
-func (c *LampPoleGroup) GetDevice() error {
-	err := Db.Debug().Model(&c).Where(" id = ? ", c.ID).Scan(&c).Error
-	return err
-}
-
-func (c LampPoleGroup) GetDevices(offset, limit int) ([]LampPoleGroup, error) {
-	var devices []LampPoleGroup
-	err := Db.Debug().Model(&c).Where(" pole_group_name like ? and is_deleted = 0", "%"+c.PoleGroupName+"%").Offset(offset).Limit(limit).Find(&devices).Error
-	return devices, err
-}
-
-func (c LampPoleGroup) GetAllDevices() ([]*LampPoleGroup, error) {
-	var devices []*LampPoleGroup
-	err := Db.Debug().Model(&c).Where(" tenant_id = ? and is_deleted = ? ", c.TenantId, c.IsDeleted).Scan(&devices).Error
-	return devices, err
-}

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

@@ -1,35 +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 int64     `gorm:"type:bigint" json:"createUser"`       //新增记录操作用户ID
-	UpdateTime time.Time `gorm:"type:datetime" json:"updateTime"`     //修改时间
-	UpdateUser int64     `gorm:"type:bigint" 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.Debug().Model(&c).Where("id = ?", c.ID).Find(&c).Error
-}
-
-func (c *LightCondition) BatchGet(ids []int) ([]LightCondition, error) {
-	var conditions []LightCondition
-	err := Db.Debug().Model(&c).Where("id in ?", ids).Find(&conditions).Error
-	return conditions, err
-}
-
-func (c *LightCondition) Save(conditions []LightCondition) error {
-	return Db.Debug().Model(&c).Save(&conditions).Error
-}

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

@@ -1,134 +0,0 @@
-package dao
-
-import (
-	"github.com/jinzhu/gorm"
-	"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:0=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      time.Time `gorm:"type:date" json:"installTime"`              //安装时间
-	TenantId         int       `gorm:"type:int" json:"tenantId"`                  //租户ID
-	CreateTime       time.Time `gorm:"type:datetime" json:"createTime"`           //新增时间
-	CreateUser       int64     `gorm:"type:bigint" json:"createUser"`             //新增记录操作用户ID
-	UpdateTime       time.Time `gorm:"type:datetime" json:"updateTime"`           //修改时间
-	UpdateUser       int64     `gorm:"type:bigint" 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.Debug().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 = 0
-	_ = Db.Debug().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.Debug().Model(&c).Where("pole_sn = ? and is_deleted = ?",
-		c.TenantId, c.IsDeleted).Find(&devices).Error
-	if gorm.IsRecordNotFoundError(err) {
-		return false
-	}
-	for _, d := range devices {
-		if d.ID != c.ID {
-			return true
-		}
-	}
-	return false
-}
-
-func (c *LightControl) Create() error {
-	return Db.Debug().Model(&c).Save(&c).Error
-}
-
-func (c *LightControl) Update() error {
-	return Db.Debug().Model(&c).Where(" id = ? ", c.ID).Update(&c).Error
-}
-
-func (c *LightControl) UpdateEnable() error {
-	return Db.Debug().Model(&c).Where(" id = ? ", c.ID).Updates(map[string]interface{}{"is_enable": c.IsEnable}).Error
-}
-
-func (c *LightControl) GetDevice() error {
-	err := Db.Debug().Model(&c).Where(" id = ? ", c.ID).First(&c).Error
-	return err
-}
-
-func (c *LightControl) GetDevicesByGroup() ([]LightControl, error) {
-	var devices []LightControl
-	err := Db.Debug().Model(&c).Where(" group_id = ? and is_deleted = 0", c.GroupId).Find(&devices).Error
-	return devices, err
-}
-
-func (c LightControl) GetDevices(offset, limit int) ([]LightControl, error) {
-	var devices []LightControl
-
-	db := Db.Debug().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)
-	}
-
-	err := db.Where("is_deleted = 0").Offset(offset).Limit(limit).Find(&devices).Error
-	return devices, err
-}
-
-func (c LightControl) GetAllDevices() ([]LightControl, error) {
-	var devices []LightControl
-	err := Db.Debug().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.Debug().Model(&c).Where(" gateway_id = ? and is_deleted = 0",
-		c.GatewayId).Find(&devices)
-	return devices
-}
-
-func (c LightControl) GetDevicesByLampPole() []LightControl {
-	var devices []LightControl
-	Db.Debug().Model(&c).Where("lamp_pole_id = ? and is_deleted = 0",
-		c.LampPoleId).Find(&devices)
-	return devices
-}

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

@@ -1,98 +0,0 @@
-package dao
-
-import (
-	"github.com/jinzhu/gorm"
-	"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:"transPhotoUrl"`            //种类
-	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            int        `gorm:"type:int" json:"tenantId"`                 //租户ID
-	CreateTime          time.Time  `gorm:"type:datetime" json:"createTime"`          //新增时间
-	CreateUser          int64      `gorm:"type:bigint" json:"createUser"`            //新增记录操作用户ID
-	UpdateTime          time.Time  `gorm:"type:datetime" json:"updateTime"`          //修改时间
-	UpdateUser          int64      `gorm:"type:bigint" 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
-}
-
-func (ManholeCover) TableName() string {
-	return "device_manhole_cover"
-}
-
-func (c ManholeCover) Delete() error {
-	return Db.Debug().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 = 0
-	_ = Db.Debug().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.Debug().Model(&c).Where(" manhole_sn = ? and is_deleted = ?",
-		c.ManholeSn, c.IsDeleted).Find(&devices).Error
-	//如果查询不到,返回相应的错误
-	if gorm.IsRecordNotFoundError(err) {
-		return false
-	}
-	for _, d := range devices {
-		if d.ID != c.ID {
-			return true
-		}
-	}
-	return false
-}
-
-func (c *ManholeCover) Create() error {
-	return Db.Debug().Model(&c).Save(&c).Error
-}
-
-func (c *ManholeCover) Update() error {
-	return Db.Debug().Model(&c).Where(" id = ? ", c.ID).Update(&c).Error
-}
-
-func (c *ManholeCover) GetDevice() error {
-	err := Db.Debug().Model(&c).Where(" id = ? ", c.ID).Scan(&c).Error
-	return err
-}
-
-func (c ManholeCover) GetDevices(offset, limit int) ([]ManholeCover, error) {
-	var devices []ManholeCover
-	err := Db.Debug().Model(&c).Where(" manhole_name like ? and is_deleted = 0", "%"+c.ManholeName+"%").Offset(offset).Limit(limit).Find(&devices).Error
-	return devices, err
-}
-
-func (c ManholeCover) GetAllDevices() ([]*ManholeCover, error) {
-	var devices []*ManholeCover
-	err := Db.Debug().Model(&c).Where(" tenant_id = ? and is_deleted = ? ", c.TenantId, c.IsDeleted).Scan(&devices).Error
-	return devices, err
-}

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

@@ -1,79 +0,0 @@
-package dao
-
-import (
-	"github.com/jinzhu/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          int       `gorm:"type:int" json:"tenantId"`              //租户ID
-	CreateTime        time.Time `gorm:"type:datetime" json:"createTime"`       //新增时间
-	CreateUser        int64     `gorm:"type:bigint" json:"createUser"`         //新增记录操作用户ID
-	UpdateTime        time.Time `gorm:"type:datetime" json:"updateTime"`       //修改时间
-	UpdateUser        int64     `gorm:"type:bigint" 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.Debug().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 = 0
-	_ = Db.Debug().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.Debug().Model(&c).Where("gateway_sn = ? and is_deleted = ?",
-		c.TenantId, c.IsDeleted).Find(&devices).Error
-	if gorm.IsRecordNotFoundError(err) {
-		return false
-	}
-	for _, d := range devices {
-		if d.ID != c.ID {
-			return true
-		}
-	}
-	return false
-}
-
-func (c *OnDemandGroup) Create() error {
-	return Db.Debug().Model(&c).Save(&c).Error
-}
-
-func (c *OnDemandGroup) Update() error {
-	return Db.Debug().Model(&c).Where(" id = ? ", c.ID).Update(&c).Error
-}
-
-func (c *OnDemandGroup) GetDevice() error {
-	err := Db.Debug().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.Debug().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.Debug().Model(&c).Where(" tenant_id = ? and is_deleted = ? ", c.TenantId, c.IsDeleted).Scan(&devices).Error
-	return devices, err
-}

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

@@ -1,83 +0,0 @@
-package dao
-
-import (
-	"github.com/jinzhu/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    int       `gorm:"type:int" json:"tenantId"`             //租户ID
-	CreateTime  time.Time `gorm:"type:datetime" json:"createTime"`      //新增时间
-	CreateUser  int64     `gorm:"type:bigint" json:"createUser"`        //新增记录操作用户ID
-	UpdateTime  time.Time `gorm:"type:datetime" json:"updateTime"`      //修改时间
-	UpdateUser  int64     `gorm:"type:bigint" 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.Debug().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 = 0
-	_ = Db.Debug().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.Debug().Model(&c).Where("sn = ? and is_deleted = ?",
-		c.SN, c.IsDeleted).Find(&devices).Error
-	//如果查询不到,返回相应的错误
-	if gorm.IsRecordNotFoundError(err) {
-		return false
-	}
-	for _, d := range devices {
-		if d.ID != c.ID {
-			return true
-		}
-	}
-	return false
-}
-
-func (c *OnDemandSensor) Create() error {
-	return Db.Debug().Model(&c).Save(&c).Error
-}
-
-func (c *OnDemandSensor) Update() error {
-	return Db.Debug().Model(&c).Where(" id = ? ", c.ID).Update(&c).Error
-}
-
-func (c *OnDemandSensor) GetDevice() error {
-	err := Db.Debug().Model(&c).Where(" id = ? ", c.ID).Scan(&c).Error
-	return err
-}
-
-func (c OnDemandSensor) GetDevices(offset, limit int) ([]OnDemandSensor, error) {
-	var devices []OnDemandSensor
-	err := Db.Debug().Model(&c).Where(" name like ? ", "%"+c.Name+"%").Offset(offset).Limit(limit).Find(&devices).Error
-	return devices, err
-}
-
-func (c OnDemandSensor) GetAllDevices() ([]*OnDemandSensor, error) {
-	var devices []*OnDemandSensor
-	err := Db.Debug().Model(&c).Where(" tenant_id = ? and is_deleted = ? ", c.TenantId,
-		c.IsDeleted).Scan(&devices).Error
-	return devices, err
-}

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

@@ -1,104 +0,0 @@
-package dao
-
-import (
-	"github.com/jinzhu/gorm"
-	"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:"poleLng"`       //经度
-	LampLat          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
-	InstallTime      *time.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         int        `gorm:"type:int" json:"tenantId"`                  //租户ID
-	CreateTime       time.Time  `gorm:"type:datetime" json:"createTime"`           //新增时间
-	CreateUser       int64      `gorm:"type:bigint" json:"createUser"`             //新增记录操作用户ID
-	UpdateTime       time.Time  `gorm:"type:datetime" json:"updateTime"`           //修改时间
-	UpdateUser       int64      `gorm:"type:bigint" 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.Debug().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 = 0
-	_ = Db.Debug().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.Debug().Model(&c).Where(" sn = ? and is_deleted = ?",
-		c.Sn, c.IsDeleted).Find(&devices).Error
-	//如果查询不到,返回相应的错误
-	if gorm.IsRecordNotFoundError(err) {
-		return false
-	}
-	for _, d := range devices {
-		if d.ID != c.ID {
-			return true
-		}
-	}
-	return false
-}
-
-func (c *OptoSensor) Create() error {
-	return Db.Debug().Model(&c).Save(&c).Error
-}
-
-func (c *OptoSensor) Update() error {
-	return Db.Debug().Model(&c).Where(" id = ? ", c.ID).Update(&c).Error
-}
-
-func (c *OptoSensor) GetDevice() error {
-	err := Db.Debug().Model(&c).Where(" id = ? ", c.ID).Scan(&c).Error
-	return err
-}
-
-func (c OptoSensor) GetDevices(offset, limit int) ([]OptoSensor, error) {
-	var devices []OptoSensor
-	err := Db.Debug().Model(&c).Where(" name like ? ", "%"+c.Name+"%").Offset(offset).Limit(limit).Find(&devices).Error
-	return devices, err
-}
-
-func (c OptoSensor) GetAllDevices() ([]*OptoSensor, error) {
-	var devices []*OptoSensor
-	err := Db.Debug().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.Debug().Model(&c).Where(" gateway_id = ? and is_deleted = 0",
-		c.GatewayId).Find(&devices)
-	return devices
-}
-
-func (c OptoSensor) GetDevicesByLampPole() []OptoSensor {
-	var devices []OptoSensor
-	Db.Debug().Model(&c).Where("lamp_pole_id = ? and is_deleted = 0",
-		c.LampPoleId).Find(&devices)
-	return devices
-}

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

@@ -1,93 +0,0 @@
-package dao
-
-import (
-	"github.com/jinzhu/gorm"
-	"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    time.Time `gorm:"type:date" json:"installTime"`                      //安装时间
-	TenantId       int       `gorm:"type:int" json:"tenantId"`                          //租户id
-	CreateTime     time.Time `gorm:"type:datetime" json:"createTime"`                   //新增时间
-	CreateUser     int64     `gorm:"type:bigint" json:"createUser"`                     //新增记录操作用户ID
-	UpdateTime     time.Time `gorm:"type:datetime" json:"updateTime"`                   //修改时间
-	UpdateUser     int64     `gorm:"type:bigint" 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"`              //供电箱照片地址
-}
-
-func (SwitchBox) TableName() string {
-	return "device_switch_box"
-}
-
-func (c SwitchBox) Delete() error {
-	return Db.Debug().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 = 0
-	_ = Db.Debug().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.Debug().Model(&c).Where(" box_sn = ? and is_deleted = ?",
-		c.BoxSN, c.IsDeleted).Find(&devices).Error
-	//如果查询不到,返回相应的错误
-	if gorm.IsRecordNotFoundError(err) {
-		return false
-	}
-	for _, d := range devices {
-		if d.ID != c.ID {
-			return true
-		}
-	}
-	return false
-}
-
-func (c *SwitchBox) Create() error {
-	return Db.Debug().Model(&c).Save(&c).Error
-}
-
-func (c *SwitchBox) Update() error {
-	return Db.Debug().Model(&c).Where(" id = ? ", c.ID).Update(&c).Error
-}
-
-func (c *SwitchBox) GetDevice() error {
-	err := Db.Debug().Model(&c).Where(" id = ? ", c.ID).Scan(&c).Error
-	return err
-}
-
-func (c SwitchBox) GetDevices(offset, limit int) ([]SwitchBox, error) {
-	var devices []SwitchBox
-	err := Db.Debug().Model(&c).Where("(box_name like ?) and is_deleted = 0",
-		"%"+c.BoxName+"%").Offset(offset).Limit(limit).Find(&devices).Error
-	return devices, err
-}
-
-func (c SwitchBox) GetAllDevices() ([]*SwitchBox, error) {
-	var devices []*SwitchBox
-	err := Db.Debug().Model(&c).Where(" tenant_id = ? and is_deleted = ? ", c.TenantId, c.IsDeleted).Scan(&devices).Error
-	return devices, 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 int64     `gorm:"type:bigint" json:"createUser"`       //新增记录操作用户ID
-	UpdateTime time.Time `gorm:"type:datetime" json:"updateTime"`     //修改时间
-	UpdateUser int64     `gorm:"type:bigint" 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.Debug().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.Debug().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.Debug().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.Debug().Model(&c).Find(&conditions).Error
-	return conditions, err
-}
-
-func (c *TimeCondition) Save() error {
-	return Db.Debug().Model(&c).Save(&c).Error
-}
-
-func (c *TimeCondition) Update() error {
-	return Db.Debug().Model(&c).Update(&c).Error
-}

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

@@ -1,86 +0,0 @@
-package dao
-
-import (
-	"github.com/jinzhu/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        int        `gorm:"type:int" json:"tenantId"`                          //租户id
-	CreateTime      time.Time  `gorm:"type:datetime" json:"createTime"`                   //新增时间
-	CreateUser      int64      `gorm:"type:bigint" json:"createUser"`                     //新增记录操作用户ID
-	UpdateTime      time.Time  `gorm:"type:datetime" json:"updateTime"`                   //修改时间
-	UpdateUser      int64      `gorm:"type:bigint" json:"updateUser"`                     //修改用户
-	IsDeleted       int        `gorm:"type:int;default 0" json:"isDeleted"`               //是否删除 0=未删除,1=删除
-	Status          int        `gorm:"type:int" json:"status"`                            //状态 0=正常,1=异常
-}
-
-func (Transformer) TableName() string {
-	return "device_transformer"
-}
-
-func (c Transformer) Delete() error {
-	return Db.Debug().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 = 0
-	_ = Db.Debug().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.Debug().Model(&c).Where(" trans_sn = ? and is_deleted = ?",
-		c.TransSN, c.IsDeleted).Find(&devices).Error
-	//如果查询不到,返回相应的错误
-	if gorm.IsRecordNotFoundError(err) {
-		return false
-	}
-	for _, d := range devices {
-		if d.ID != c.ID {
-			return true
-		}
-	}
-	return false
-}
-
-func (c *Transformer) Create() error {
-	return Db.Debug().Model(&c).Save(&c).Error
-}
-
-func (c *Transformer) Update() error {
-	return Db.Debug().Model(&c).Where(" id = ? ", c.ID).Update(&c).Error
-}
-
-func (c *Transformer) GetDevice() error {
-	err := Db.Debug().Model(&c).Where(" id = ? ", c.ID).Scan(&c).Error
-	return err
-}
-
-func (c Transformer) GetDevices(offset, limit int) ([]Transformer, error) {
-	var devices []Transformer
-	err := Db.Debug().Model(&c).Where(" trans_name like ? and is_deleted = 0", "%"+c.TransName+"%").Offset(offset).Limit(limit).Find(&devices).Error
-	return devices, err
-}
-
-func (c Transformer) GetAllDevices() ([]*Transformer, error) {
-	var devices []*Transformer
-	err := Db.Debug().Model(&c).Where(" tenant_id = ? and is_deleted = ? ", c.TenantId, c.IsDeleted).Scan(&devices).Error
-	return devices, err
-}

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

@@ -1,54 +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    int       `gorm:"type:int" json:"tenantId"`             //租户id
-	CreateTime  time.Time `gorm:"type:datetime" json:"createTime"`      //新增时间
-	CreateUser  int64     `gorm:"type:bigint" json:"createUser"`        //新增记录操作用户ID
-	UpdateTime  time.Time `gorm:"type:datetime" json:"updateTime"`      //修改时间
-	UpdateUser  int64     `gorm:"type:bigint" 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.Debug().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.Debug().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.Debug().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.Debug().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
-	}
-
-}

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

@@ -1,77 +0,0 @@
-package dao
-
-type CountDevice struct {
-	CountNum   int    `json:"countNum"`
-	DeviceType string `json:"deviceType"`
-}
-
-func GetDeviceCount(tenantId int) ([]CountDevice, error) {
-	var result []CountDevice
-	var count CountDevice
-	Db.Debug().Model(&LampPole{}).Select(" count(*) count_num, 'lamppole' device_type ").
-		Where("tenant_id = ? and is_deleted = 0", tenantId).Scan(&count)
-	result = append(result, count)
-	Db.Debug().Model(&CameraDevice{}).Select(" count(*) count_num, 'camera' device_type ").
-		Where("tenant_id = ? and is_deleted = 0", tenantId).Scan(&count)
-	result = append(result, count)
-	Db.Debug().Model(&Gateway{}).Select(" count(*) count_num, 'gateway' device_type ").
-		Where("tenant_id = ? and is_deleted = 0", tenantId).Scan(&count)
-	result = append(result, count)
-	Db.Debug().Model(&LightControl{}).Select(" count(*) count_num, 'control' device_type ").
-		Where("tenant_id = ? and is_deleted = 0", tenantId).Scan(&count)
-	result = append(result, count)
-	Db.Debug().Model(&SwitchBox{}).Select(" count(*) count_num, 'box' device_type ").
-		Where("tenant_id = ? and is_deleted = 0", tenantId).Scan(&count)
-	result = append(result, count)
-	Db.Debug().Model(&InfoBoard{}).Select(" count(*) count_num, 'board' device_type ").
-		Where("tenant_id = ? and is_deleted = 0", tenantId).Scan(&count)
-	result = append(result, count)
-	Db.Debug().Model(&OptoSensor{}).Select(" count(*) count_num, 'sensor' device_type ").
-		Where("tenant_id = ? and is_deleted = 0", tenantId).Scan(&count)
-	result = append(result, count)
-	Db.Debug().Model(&Zigbee{}).Select(" count(*) count_num, 'zigbee' device_type ").
-		Where("tenant_id = ? and is_deleted = 0", tenantId).Scan(&count)
-	result = append(result, count)
-	Db.Debug().Model(&AlarmTerminal{}).Select(" count(*) count_num, 'terminal' device_type ").
-		Where("tenant_id = ? and is_deleted = 0", tenantId).Scan(&count)
-	result = append(result, count)
-	Db.Debug().Model(&Alarm{}).Select(" count(*) count_num, 'alarmserve' device_type ").
-		Where("tenant_id = ? and is_deleted = 0", tenantId).Scan(&count)
-	result = append(result, count)
-	Db.Debug().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 int) (*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 int) (*CountJobTodo, error) {
-	var todos CountJobTodo
-	return &todos, nil
-}
-
-type Notification struct {
-	Category int    `json:"category"`
-	Title    string `json:"title"`
-}
-
-func GetNotification(tenantId int) (*Notification, error) {
-	var notification Notification
-	return &notification, nil
-}

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

@@ -1,108 +0,0 @@
-package dao
-
-import (
-	"github.com/jinzhu/gorm"
-	"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:"channelNum"`                //通道号
-	NetworkNum       int        `gorm:"type:int" json:"networkNum"`                //网络号
-	InstallTime      *time.Time `gorm:"type:date" json:"installTime"`              //安装时间
-	TenantId         int        `gorm:"type:int" json:"tenantId"`                  //租户id
-	CreateTime       time.Time  `gorm:"type:datetime" json:"createTime"`           //新增时间
-	CreateUser       int64      `gorm:"type:bigint" json:"createUser"`             //新增记录操作用户ID
-	UpdateTime       time.Time  `gorm:"type:datetime" json:"updateTime"`           //修改时间
-	UpdateUser       int64      `gorm:"type:bigint" 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地址-备用
-}
-
-func (Zigbee) TableName() string {
-	return "device_zigbee"
-}
-
-func (c Zigbee) Delete() error {
-	return Db.Debug().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 = 0
-	_ = Db.Debug().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.Debug().Model(&c).Where(" sn = ? and is_deleted = ?",
-		c.Sn, c.IsDeleted).Find(&devices).Error
-	//如果查询不到,返回相应的错误
-	if gorm.IsRecordNotFoundError(err) {
-		return false
-	}
-	for _, d := range devices {
-		if d.ID != c.ID {
-			return true
-		}
-	}
-	return false
-}
-
-func (c *Zigbee) Create() error {
-	return Db.Debug().Model(&c).Save(&c).Error
-}
-
-func (c *Zigbee) Update() error {
-	return Db.Debug().Model(&c).Where(" id = ? ", c.ID).Update(&c).Error
-}
-
-func (c *Zigbee) GetDevice() error {
-	err := Db.Debug().Model(&c).Where(" id = ? ", c.ID).Scan(&c).Error
-	return err
-}
-
-func (c Zigbee) GetDevices(offset, limit int) ([]Zigbee, error) {
-	var devices []Zigbee
-	err := Db.Debug().Model(&c).Where(" name like ? ", "%"+c.Name+"%").Offset(offset).Limit(limit).Find(&devices).Error
-	return devices, err
-}
-
-func (c Zigbee) GetAllDevices() ([]Zigbee, error) {
-	var devices []Zigbee
-	err := Db.Debug().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.Debug().Model(&c).Where(" gateway_id = ? and is_deleted = 0",
-		c.GatewayId).Find(&devices)
-	return devices
-}
-
-func (c Zigbee) GetDevicesByLampPole() []Zigbee {
-	var devices []Zigbee
-	Db.Debug().Model(&c).Where("lamp_pole_id = ? and is_deleted = 0",
-		c.LampPoleId).Find(&devices)
-	return devices
-}

+ 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   int    `json:"sn"`   //sn
-	Name string `json:"name"` //名称
-}
-
-const (
-	TimeConditionNull    = "请将时间区间填写完整!"
-	TimeConditionInvalid = "时间区间开始时间不能大于结束时间,请重新调整!"
-)

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

@@ -1,15 +0,0 @@
-package model
-
-import "iot_manager_service/app/device/dao"
-
-type RsqAlarmTerminalList struct {
-	Records []dao.AlarmTerminal `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"` //分组编码
-}

+ 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 - 38
app/device/model/camera.go

@@ -1,38 +0,0 @@
-package model
-
-import "iot_manager_service/app/device/dao"
-
-type CameraDetail struct {
-	dao.CameraDevice
-	PoleGroupName   string `json:"poleGroupName"`   //灯杆分组名
-	Brand           string `json:"brand"`           //品牌名称
-	Model           string `json:"model"`           //型号名称
-	CameraTypeName  string `json:"cameraTypeName"`  //摄像头类型名称
-	RunState        int    `json:"runState"`        //运行状态
-	NetworkState    string `json:"networkState"`    //网络状态
-	EndLineTime     string `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   int    `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 - 39
app/device/model/captureUint.go

@@ -1,39 +0,0 @@
-package model
-
-import "iot_manager_service/app/device/dao"
-
-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    int     `json:"networkState"`    //通讯状态 1在线2离线
-	EndLineTime     string  `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 - 37
app/device/model/gateway.go

@@ -1,37 +0,0 @@
-package model
-
-import (
-	"iot_manager_service/app/device/dao"
-)
-
-type GatewayDetail struct {
-	dao.Gateway
-	CountLampPole     int                 `json:"countLampPole"`         //关联设备数 //todo 修改返回名
-	EndLineTime       string              `json:"endLineTime"`           //最后上线时间
-	NetworkState      int                 `json:"networkState"`          //网络状态
-	RunState          int                 `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   int    `json:"sn"`   //sn
-	Name string `json:"name"` //名称
-}

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

@@ -1,15 +0,0 @@
-package model
-
-import "iot_manager_service/app/device/dao"
-
-type RsqInfoBoardList struct {
-	Records []dao.InfoBoard `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"` //分组编码
-}

+ 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          int    `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 []RspIntelligentLightListDetail `json:"records"` //记录列表
-	Current int                             `json:"current"` //当前分页
-	Size    int                             `json:"size"`    //每页数量
-	Pages   int                             `json:"pages"`   //总页数
-	Total   int                             `json:"total"`
-}

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

@@ -1,15 +0,0 @@
-package model
-
-import "iot_manager_service/app/device/dao"
-
-type RsqIpBroadcastList struct {
-	Records []dao.IpBroadcast `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"` //分组编码
-}

+ 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   int    `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 - 41
app/device/model/lightControl.go

@@ -1,41 +0,0 @@
-package model
-
-import (
-	"iot_manager_service/app/device/dao"
-)
-
-type LightControlDetail struct {
-	dao.LightControl
-	EndLineTime  string `json:"endLineTime"`  //最后上线时间
-	NetworkState int    `json:"networkState"` //网络状态
-	RunState     int    `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 - 15
app/device/model/optoSenso.go

@@ -1,15 +0,0 @@
-package model
-
-import "iot_manager_service/app/device/dao"
-
-type RsqOptoSensorList struct {
-	Records []dao.OptoSensor `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"` //分组编码
-}

+ 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 - 20
app/device/model/workbench.go

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

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

@@ -1,15 +0,0 @@
-package model
-
-import "iot_manager_service/app/device/dao"
-
-type RsqZigbeeList struct {
-	Records []dao.Zigbee `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"` //分组编码
-}

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

@@ -1,251 +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"
-	"sort"
-	"time"
-)
-
-// 中间件管理服务
-var LightStrategyService = new(lightStrategyService)
-
-type lightStrategyService struct{}
-
-func (s *lightStrategyService) Get(id int) (*model.LightStrategyDetail, *util.Errors) {
-	// 创建查询实例
-	strategy := &dao.LightStrategy{
-		ID: id,
-	}
-	err := strategy.GetStrategy()
-	if err != nil {
-		return nil, util.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 int64, tenantId int, req *model.LightStrategyDetail) *util.Errors {
-	// 创建查询实例
-	strategy := req
-	fmt.Printf("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
-		if strategy.IsExistedBySN() {
-			fmt.Printf("Create GetstrategyID err \n")
-			return util.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 util.ParamsInvalidResponse("光照度请填写完整", nil)
-		} else if lightCondition.ScopeEnd > 0 && lightCondition.ScopeStart >= lightCondition.ScopeEnd {
-			return util.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 util.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 util.FailResponse(model.TimeConditionNull, nil)
-		}
-		if (timeCondition.StartTime == "" && timeCondition.EndTime != "") || (timeCondition.
-			StartTime != "" && timeCondition.EndTime == "") {
-			return util.FailResponse(model.TimeConditionNull, nil)
-		} else if timeCondition.EndTime != "" && timeCondition.StartTime >= timeCondition.EndTime {
-			return util.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 {
-			fmt.Printf("Create err = %s \n", err.Error())
-			return util.FailResponse(err.Error(), nil)
-		}
-	} else {
-		if err := strategy.Update(); err != nil {
-			fmt.Printf("Update err = %s \n", err.Error())
-			return util.FailResponse(err.Error(), nil)
-		}
-	}
-
-	//存策略条件
-	_ = TimeConditionService.Save(timeList)
-	_ = LightConditionService.Save(strategy.LightConditionList)
-
-	//todo 调用设备云端的新增或修改
-
-	//todo 自动续期
-	//strategy.IsAutomaticRenewal
-
-	service.OperationHisService.Save(userId, tenantId, util.OperationCreate, util.ModuleTypeDevice,
-		util.DeviceTypeLightStrategy, util.GetDeviceObject(strategy.ID, strategy.LightName), util.OperationSuccess)
-	return util.SuccessResponse(util.Succeeded, nil)
-}
-
-func (s *lightStrategyService) List(searchValue string, current, size int) ([]model.LightStrategyDetail, *util.Errors) {
-	strategy := dao.LightStrategy{}
-	if searchValue != "" {
-		strategy.LightSn = searchValue
-	}
-
-	offset := (current - 1) * size
-	limit := size
-	strategies, err := strategy.GetStrategies(offset, limit)
-	if err != nil {
-		return nil, util.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 = "日出"
-			}
-			detail.CombinationStr = fmt.Sprintf("开灯时段:%s ~ %s , 灯光亮度:%d%%", timeCondition.StartTime,
-				timeCondition.EndTime, timeCondition.Luminance)
-		}
-		details = append(details, detail)
-	}
-	return details, nil
-}
-
-func (s *lightStrategyService) Remove(userId int64, tenantId int, id int) *util.Errors {
-	// 创建查询实例
-	strategy := &dao.LightStrategy{
-		ID:         id,
-		IsDeleted:  1,
-		UpdateUser: userId,
-		UpdateTime: time.Now(),
-	}
-	err := strategy.Delete()
-	if err != nil {
-		return util.FailResponse(err.Error(), nil)
-	}
-	service.OperationHisService.Save(userId, tenantId, util.OperationRemove, util.ModuleTypeDevice,
-		util.DeviceTypeLightStrategy, util.GetDeviceObject(strategy.ID, strategy.LightName), util.OperationSuccess)
-	return nil
-}
-
-func (s *lightStrategyService) GetOne(id int) (*dao.LightStrategy, *util.Errors) {
-	strategy := &dao.LightStrategy{
-		ID: id,
-	}
-	err := strategy.GetStrategy()
-	if err != nil {
-		return nil, nil
-	}
-	return strategy, nil
-}

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

@@ -1,116 +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"
-	"time"
-)
-
-// 中间件管理服务
-var AlarmService = new(alarmService)
-
-type alarmService struct{}
-
-func (s *alarmService) Get(id int) (*dao.Alarm, *util.Errors) {
-	// 创建查询实例
-	device := &dao.Alarm{
-		ID: id,
-	}
-	err := device.GetDevice()
-	if err != nil {
-		return nil, util.FailResponse(err.Error(), nil)
-	}
-	return device, nil
-}
-
-func (s *alarmService) CreateOrUpdate(userId int64, tenantId int, req dao.Alarm) *util.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() {
-			fmt.Printf("Create IsExistedBySN \n")
-			return util.ParamsInvalidResponse(model.RepeatedName, nil)
-		}
-		if err := device.Create(); err != nil {
-			fmt.Printf("Create err = %s \n", err.Error())
-			return util.FailResponse(err.Error(), nil)
-		}
-		service.OperationHisService.Save(userId, tenantId, util.OperationCreate, util.ModuleTypeDevice,
-			util.DeviceTypeAlarmServer, util.GetDeviceObject(device.ID, device.ServeName), util.OperationSuccess)
-		return util.SuccessResponse(util.Succeeded, nil)
-	}
-
-	if device.IsExistedByNameAndCode() {
-		fmt.Printf("Update IsExistedByNameAndCode \n")
-		return util.ParamsInvalidResponse(model.RepeatedName, nil)
-	}
-
-	if err := device.Update(); err != nil {
-		fmt.Printf("Update err = %s \n", err.Error())
-		return util.FailResponse(err.Error(), nil)
-	}
-
-	service.OperationHisService.Save(userId, tenantId, util.OperationUpdate, util.ModuleTypeDevice,
-		util.DeviceTypeAlarmServer, util.GetDeviceObject(device.ID, device.ServeName), util.OperationSuccess)
-	return util.SuccessResponse(util.Succeeded, nil)
-}
-
-func (s *alarmService) List(poleGroupName string, current, size int) ([]dao.Alarm, *util.Errors) {
-	// 创建查询实例
-	device := &dao.Alarm{}
-	offset := (current - 1) * size
-	limit := size
-	devices, err := device.GetDevices(offset, limit)
-	if err != nil {
-		return nil, util.FailResponse(err.Error(), nil)
-	}
-	return devices, nil
-}
-
-func (s *alarmService) Remove(userId int64, tenantId int, id int) *util.Errors {
-	// 创建查询实例
-	device := &dao.Alarm{
-		ID:         id,
-		IsDeleted:  1,
-		UpdateUser: userId,
-		UpdateTime: time.Now(),
-	}
-	err := device.Delete()
-	if err != nil {
-		return util.FailResponse(err.Error(), nil)
-	}
-	service.OperationHisService.Save(userId, tenantId, util.OperationRemove, util.ModuleTypeDevice,
-		util.DeviceTypeAlarmServer, util.GetDeviceObject(device.ID, device.ServeName), util.OperationSuccess)
-	return nil
-}
-
-func (s *alarmService) GetList(tenantId int) ([]*dao.Alarm, *util.Errors) {
-	var devices []*dao.Alarm
-	err := util.Redis.Get(getAlarmListRedisKey(tenantId)).Scan(&devices)
-	if err == nil {
-		return devices, nil
-	}
-	device := &dao.Alarm{
-		TenantId:  tenantId,
-		IsDeleted: 0,
-	}
-	devices, err = device.GetAllDevices()
-	if err != nil {
-		return nil, util.FailResponse(err.Error(), nil)
-	}
-	_ = util.Redis.Set(getAlarmListRedisKey(tenantId), devices, 0).Err()
-	return devices, nil
-}
-
-func getAlarmListRedisKey(tenantId int) string {
-	return fmt.Sprintf(model.AlarmList, tenantId)
-}

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

@@ -1,110 +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"
-	"time"
-)
-
-// 中间件管理服务
-var AlarmTerminalService = new(alarmTerminalService)
-
-type alarmTerminalService struct{}
-
-func (s *alarmTerminalService) Get(id int) (*dao.AlarmTerminal, *util.Errors) {
-	// 创建查询实例
-	device := &dao.AlarmTerminal{
-		ID: id,
-	}
-	err := device.GetDevice()
-	if err != nil {
-		return nil, util.FailResponse(err.Error(), nil)
-	}
-	return device, nil
-}
-
-func (s *alarmTerminalService) CreateOrUpdate(userId int64, tenantId int, req dao.AlarmTerminal) *util.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() {
-			fmt.Printf("Create IsExistedBySN \n")
-			return util.ParamsInvalidResponse(model.RepeatedName, nil)
-		}
-		if err := device.Create(); err != nil {
-			fmt.Printf("Create err = %s \n", err.Error())
-			return util.FailResponse(err.Error(), nil)
-		}
-		service.OperationHisService.Save(userId, tenantId, util.OperationCreate, util.ModuleTypeDevice,
-			util.DeviceTypeAlarmTerminal, util.GetDeviceObject(device.ID, device.TerminalName), util.OperationSuccess)
-		return util.SuccessResponse(util.Succeeded, nil)
-	}
-
-	if device.IsExistedByNameAndCode() {
-		fmt.Printf("Update IsExistedByNameAndCode \n")
-		return util.ParamsInvalidResponse(model.RepeatedName, nil)
-	}
-
-	if err := device.Update(); err != nil {
-		fmt.Printf("Update err = %s \n", err.Error())
-		return util.FailResponse(err.Error(), nil)
-	}
-
-	service.OperationHisService.Save(userId, tenantId, util.OperationUpdate, util.ModuleTypeDevice,
-		util.DeviceTypeAlarmTerminal, util.GetDeviceObject(device.ID, device.TerminalName), util.OperationSuccess)
-	return util.SuccessResponse(util.Succeeded, nil)
-}
-
-func (s *alarmTerminalService) List(poleGroupName string, current, size int) ([]dao.AlarmTerminal, *util.Errors) {
-	// 创建查询实例
-	device := &dao.AlarmTerminal{}
-	offset := (current - 1) * size
-	limit := size
-	devices, err := device.GetDevices(offset, limit)
-	if err != nil {
-		return nil, util.FailResponse(err.Error(), nil)
-	}
-	return devices, nil
-}
-
-func (s *alarmTerminalService) Remove(userId int64, tenantId int, id int) *util.Errors {
-	// 创建查询实例
-	device := &dao.AlarmTerminal{
-		ID:         id,
-		IsDeleted:  1,
-		UpdateUser: userId,
-		UpdateTime: time.Now(),
-	}
-	err := device.Delete()
-	if err != nil {
-		return util.FailResponse(err.Error(), nil)
-	}
-	service.OperationHisService.Save(userId, tenantId, util.OperationRemove, util.ModuleTypeDevice,
-		util.DeviceTypeAlarmTerminal, util.GetDeviceObject(device.ID, device.TerminalName), util.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()
-}

+ 0 - 128
app/device/service/bridgeSensorService.go

@@ -1,128 +0,0 @@
-package service
-
-import (
-	"fmt"
-	"iot_manager_service/app/device/dao"
-	"iot_manager_service/app/system/service"
-	"iot_manager_service/util"
-	"time"
-)
-
-// 中间件管理服务
-var BridgeSensorService = new(bridgeSensorService)
-
-type bridgeSensorService struct{}
-
-func (s *bridgeSensorService) Get(id int) (*dao.BridgeSensor, *util.Errors) {
-	// 创建查询实例
-	device := &dao.BridgeSensor{
-		ID: id,
-	}
-	err := device.GetDevice()
-	if err != nil {
-		return nil, util.FailResponse(err.Error(), nil)
-	}
-	return device, nil
-}
-
-func (s *bridgeSensorService) CreateOrUpdate(userId int64, tenantId int, req dao.BridgeSensor) *util.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() {
-			fmt.Printf("Create GetDeviceID err \n")
-			return util.ParamsInvalidResponse("编码不能重复,请重新填写!", nil)
-		}
-		if err := device.Create(); err != nil {
-			fmt.Printf("Create err = %s \n", err.Error())
-			return util.FailResponse(err.Error(), nil)
-		}
-		service.OperationHisService.Save(userId, tenantId, util.OperationCreate, util.ModuleTypeDevice,
-			util.DeviceTypeBridgeSensor, util.GetDeviceObject(device.ID, device.Name), util.OperationSuccess)
-		return util.SuccessResponse(util.Succeeded, nil)
-	}
-	if device.IsExistedByNameAndCode() {
-		return util.ParamsInvalidResponse("编码不能重复,请重新填写!", nil)
-	}
-
-	if err := device.Update(); err != nil {
-		fmt.Printf("Update err = %s \n", err.Error())
-		return util.FailResponse(err.Error(), nil)
-	}
-
-	service.OperationHisService.Save(userId, tenantId, util.OperationUpdate, util.ModuleTypeDevice,
-		util.DeviceTypeBridgeSensor, util.GetDeviceObject(device.ID, device.Name), util.OperationSuccess)
-	return util.SuccessResponse(util.Succeeded, nil)
-}
-
-func (s *bridgeSensorService) List(searchValue string, current, size int) ([]dao.BridgeSensor, *util.Errors) {
-	device := dao.BridgeSensor{}
-	if searchValue != "" {
-		device.SN = searchValue
-		device.Name = searchValue
-	}
-
-	offset := (current - 1) * size
-	limit := size
-	devices, err := device.GetDevices(offset, limit)
-	if err != nil {
-		return nil, util.FailResponse(err.Error(), nil)
-	}
-	return devices, nil
-}
-
-func (s *bridgeSensorService) Remove(userId int64, tenantId int, id int) *util.Errors {
-	// 创建查询实例
-	device := &dao.BridgeSensor{
-		ID:         id,
-		IsDeleted:  1,
-		UpdateUser: userId,
-		UpdateTime: time.Now(),
-	}
-	err := device.Delete()
-	if err != nil {
-		return util.FailResponse(err.Error(), nil)
-	}
-	service.OperationHisService.Save(userId, tenantId, util.OperationRemove, util.ModuleTypeDevice,
-		util.DeviceTypeBridgeSensor, util.GetDeviceObject(device.ID, device.Name), util.OperationSuccess)
-	return nil
-}
-
-func (s *bridgeSensorService) GetList(tenantId int) ([]*dao.BridgeSensor, *util.Errors) {
-	var devices []*dao.BridgeSensor
-	err := util.Redis.Get(getTransformerListRedisKey(tenantId)).Scan(&devices)
-	if err == nil {
-		return devices, nil
-	}
-
-	device := &dao.BridgeSensor{
-		TenantID:  tenantId,
-		IsDeleted: 0,
-	}
-	devices, err = device.GetAllDevices()
-	if err != nil {
-		return nil, util.FailResponse(err.Error(), nil)
-	}
-	_ = util.Redis.Set(getTransformerListRedisKey(tenantId), devices, 0).Err()
-
-	return devices, nil
-}
-
-func (s *bridgeSensorService) Enable(id, status int) *util.Errors {
-	// 创建查询实例
-	device := &dao.BridgeSensor{
-		ID:       id,
-		IsEnable: status,
-	}
-
-	err := device.UpdateEnable()
-	if err != nil {
-		return util.FailResponse(err.Error(), nil)
-	}
-	return nil
-}

+ 0 - 108
app/device/service/bridgeService.go

@@ -1,108 +0,0 @@
-package service
-
-import (
-	"fmt"
-	"iot_manager_service/app/device/dao"
-	"iot_manager_service/app/system/service"
-	"iot_manager_service/util"
-	"time"
-)
-
-var BridgeService = new(bridgeService)
-
-type bridgeService struct{}
-
-func (s *bridgeService) Get(id int) (*dao.Bridge, *util.Errors) {
-	// 创建查询实例
-	device := &dao.Bridge{
-		ID: id,
-	}
-	err := device.GetDevice()
-	if err != nil {
-		return nil, util.FailResponse(err.Error(), nil)
-	}
-	return device, nil
-}
-
-func (s *bridgeService) CreateOrUpdate(userId int64, tenantId int, req dao.Bridge) *util.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() {
-			fmt.Printf("Create GetDeviceID err \n")
-			return util.ParamsInvalidResponse("编码不能重复,请重新填写!", nil)
-		}
-		if err := device.Create(); err != nil {
-			fmt.Printf("Create err = %s \n", err.Error())
-			return util.FailResponse(err.Error(), nil)
-		}
-		service.OperationHisService.Save(userId, tenantId, util.OperationCreate, util.ModuleTypeDevice,
-			util.DeviceTypeBridge, util.GetDeviceObject(device.ID, device.Name), util.OperationSuccess)
-		return util.SuccessResponse(util.Succeeded, nil)
-	}
-
-	if device.IsExistedByNameAndCode() {
-		return util.ParamsInvalidResponse("编码不能重复,请重新填写!", nil)
-	}
-
-	if err := device.Update(); err != nil {
-		fmt.Printf("Update err = %s \n", err.Error())
-		return util.FailResponse(err.Error(), nil)
-	}
-
-	service.OperationHisService.Save(userId, tenantId, util.OperationUpdate, util.ModuleTypeDevice,
-		util.DeviceTypeBridge, util.GetDeviceObject(device.ID, device.Name), util.OperationSuccess)
-	return util.SuccessResponse(util.Succeeded, nil)
-}
-
-func (s *bridgeService) List(searchValue string, current, size int) ([]dao.Bridge, *util.Errors) {
-	device := dao.Bridge{}
-	if searchValue != "" {
-		device.SN = searchValue
-		device.Name = searchValue
-	}
-
-	offset := (current - 1) * size
-	limit := size
-	devices, err := device.GetDevices(offset, limit)
-	if err != nil {
-		return nil, util.FailResponse(err.Error(), nil)
-	}
-	return devices, nil
-}
-
-func (s *bridgeService) Remove(userId int64, tenantId int, id int) *util.Errors {
-	// 创建查询实例
-	device := &dao.Bridge{
-		ID:         id,
-		IsDeleted:  1,
-		UpdateUser: userId,
-		UpdateTime: time.Now(),
-	}
-	err := device.Delete()
-	if err != nil {
-		return util.FailResponse(err.Error(), nil)
-	}
-	service.OperationHisService.Save(userId, tenantId, util.OperationRemove, util.ModuleTypeDevice,
-		util.DeviceTypeBridge, util.GetDeviceObject(device.ID, device.Name), util.OperationSuccess)
-	return nil
-}
-
-func (s *bridgeService) GetList(tenantId int) ([]*dao.Bridge, *util.Errors) {
-	// todo use redis cache
-	device := &dao.Bridge{
-		TenantId:  tenantId,
-		IsDeleted: 0,
-	}
-	devices, err := device.GetAllDevices()
-	if err != nil {
-		return nil, util.FailResponse(err.Error(), nil)
-	}
-
-	return devices, nil
-}

+ 0 - 182
app/device/service/cameraService.go

@@ -1,182 +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"
-	"strconv"
-	"time"
-)
-
-// 中间件管理服务
-var CameraService = new(cameraService)
-
-type cameraService struct{}
-
-func (s *cameraService) CreateOrUpdate(userId int64, tenantId int, req *model.CameraDetail) *util.Errors {
-	device := req.CameraDevice
-	device.TenantId = tenantId
-	device.UpdateUser = userId
-	device.UpdateTime = time.Now()
-	if device.LampPoleId != 0 {
-		lampPole, err := LampPoleService.GetOne(device.LampPoleId)
-		if err == nil {
-			device.LampLat = lampPole.PoleLat
-			device.LampLng = lampPole.PoleLng
-			device.LampPoleName = lampPole.PoleName
-			device.LampPoleSn = lampPole.PoleSN
-			device.LampPoleLocation = lampPole.InstallLocation
-			device.GroupId = lampPole.GroupId
-		} else {
-			fmt.Printf("LampPoleService.GetOne err = %v \n", err)
-		}
-	}
-
-	if device.ID == 0 {
-		device.CreateTime = time.Now()
-		device.CreateUser = userId
-
-		if device.IsExistedBySN() {
-			fmt.Printf("Create IsExistedBySN \n")
-			return util.ParamsInvalidResponse(model.RepeatedPrompts, nil)
-		}
-		fmt.Printf("device = %+v \n", device)
-		if err := device.Create(); err != nil {
-			fmt.Printf("Create err = %s \n", err.Error())
-			return util.FailResponse(err.Error(), nil)
-		}
-		service.OperationHisService.Save(userId, tenantId, util.OperationCreate, util.ModuleTypeDevice,
-			util.DeviceTypeCamera, util.GetDeviceObject(device.ID, device.DeviceName), util.OperationSuccess)
-		return util.SuccessResponse(util.Succeeded, nil)
-	}
-
-	if err := device.Update(); err != nil {
-		fmt.Printf("Update err = %s \n", err.Error())
-		return util.FailResponse(err.Error(), nil)
-	}
-
-	service.OperationHisService.Save(userId, tenantId, util.OperationUpdate, util.ModuleTypeDevice,
-		util.DeviceTypeCamera, util.GetDeviceObject(device.ID, device.DeviceName), util.OperationSuccess)
-	return util.SuccessResponse(util.Succeeded, nil)
-}
-
-func (s *cameraService) Get(id int) (*model.CameraDetail, *util.Errors) {
-	// 创建查询实例
-	device := &dao.CameraDevice{
-		ID: id,
-	}
-	err := device.GetDevice()
-	if err != nil {
-		return nil, util.FailResponse(err.Error(), nil)
-	}
-
-	detail := &model.CameraDetail{CameraDevice: *device}
-	if device.CameraType == model.CameraTypeBall {
-		detail.CameraTypeName = model.CameraTypeBallName
-	} else if device.CameraType == model.CameraTypeGun {
-		detail.CameraTypeName = model.CameraTypeGunName
-	}
-
-	detail.RunState = util.GetDeviceState(device.DeviceSN)
-	return detail, nil
-}
-
-func (s *cameraService) List(searchValue, cameraType string, current, size int) ([]model.CameraDetail, *util.Errors) {
-	var details []model.CameraDetail
-	device := dao.CameraDevice{}
-
-	if searchValue != "" {
-		device.DeviceSN = searchValue
-	}
-	if cameraType != "" {
-		t, _ := strconv.Atoi(cameraType)
-		device.CameraType = t
-	} else {
-		device.CameraType = -1
-	}
-
-	offset := (current - 1) * size
-	limit := size
-	devices, err := device.GetDevices(offset, limit)
-
-	if err != nil {
-		return nil, util.FailResponse(err.Error(), nil)
-	}
-
-	for _, d := range devices {
-		details = append(details, model.CameraDetail{
-			CameraDevice: d,
-			RunState:     util.GetDeviceState(device.DeviceSN),
-		})
-	}
-
-	return details, nil
-}
-
-func (s *cameraService) Remove(userId int64, tenantId int, id int) *util.Errors {
-	// 创建查询实例
-	device := &dao.CameraDevice{
-		ID:         id,
-		IsDeleted:  1,
-		UpdateUser: userId,
-		UpdateTime: time.Now(),
-	}
-
-	err := device.Delete()
-	if err != nil {
-		return util.FailResponse(err.Error(), nil)
-	}
-	service.OperationHisService.Save(userId, tenantId, util.OperationRemove, util.ModuleTypeDevice,
-		util.DeviceTypeCamera, util.GetDeviceObject(device.ID, device.DeviceName), util.OperationSuccess)
-	return nil
-}
-
-func (s *cameraService) GetList(tenantId int) ([]dao.CameraDevice, *util.Errors) {
-	device := &dao.CameraDevice{
-		TenantId:  tenantId,
-		IsDeleted: 0,
-	}
-	devices, err := device.GetAllDevices()
-	var results []dao.CameraDevice
-	// todo 不要返回多余字段,只需要id和name
-	for _, device := range devices {
-		results = append(results, dao.CameraDevice{ID: device.ID, DeviceName: device.DeviceName + "(" + device.DeviceSN + ")"})
-	}
-	if err != nil {
-		return nil, util.FailResponse(err.Error(), nil)
-	}
-
-	return results, nil
-}
-
-func (s *cameraService) Enable(id, status int) *util.Errors {
-	// 创建查询实例
-	device := &dao.CameraDevice{
-		ID:       id,
-		IsEnable: status,
-	}
-
-	err := device.UpdateEnable()
-	if err != nil {
-		return util.FailResponse(err.Error(), nil)
-	}
-	return nil
-}
-
-func (s *cameraService) GetByGateway(id int) []dao.CameraDevice {
-	// 创建查询实例
-	device := &dao.CameraDevice{
-		GatewayId: id,
-	}
-	return device.GetDevicesByGateway()
-}
-
-func (s *cameraService) GetByLampPole(id int) []dao.CameraDevice {
-	// 创建查询实例
-	device := &dao.CameraDevice{
-		LampPoleId: id,
-	}
-	return device.GetDevicesByLampPole()
-}

+ 0 - 238
app/device/service/captureUintService.go

@@ -1,238 +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"
-	"time"
-)
-
-// 中间件管理服务
-var CaptureUintService = new(captureUintService)
-
-type captureUintService struct{}
-
-func (s *captureUintService) CaptureSubmit(userId int64, tenantId int, req *model.CaptureDetail) *util.Errors {
-	device := req.CaptureUnit
-	device.TenantId = tenantId
-	device.UpdateUser = userId
-	device.UpdateTime = time.Now()
-	if gateway, err := GatewayService.GetOne(device.GatewayId); err == nil {
-		device.GatewayName = gateway.GatewayName
-		device.GatewaySn = gateway.GatewaySn
-	}
-
-	if device.ID == 0 {
-		device.CreateTime = time.Now()
-		device.CreateUser = userId
-
-		if device.IsExistedBySN() {
-			fmt.Printf("Create IsExistedBySN \n")
-			return util.ParamsInvalidResponse(model.RepeatedPrompts, nil)
-		}
-		fmt.Printf("device = %+v \n", device)
-		if err := device.Create(); err != nil {
-			fmt.Printf("Create err = %s \n", err.Error())
-			return util.FailResponse(err.Error(), nil)
-		}
-		service.OperationHisService.Save(userId, tenantId, util.OperationCreate, util.ModuleTypeDevice,
-			util.DeviceTypeCaptureUnit, util.GetDeviceObject(device.ID, device.GatewayName), util.OperationSuccess)
-		return util.SuccessResponse(util.Succeeded, nil)
-	}
-
-	if err := device.Update(); err != nil {
-		fmt.Printf("Update err = %s \n", err.Error())
-		return util.FailResponse(err.Error(), nil)
-	}
-
-	service.OperationHisService.Save(userId, tenantId, util.OperationUpdate, util.ModuleTypeDevice,
-		util.DeviceTypeCaptureUnit, util.GetDeviceObject(device.ID, device.GatewayName), util.OperationSuccess)
-	return util.SuccessResponse(util.Succeeded, nil)
-}
-
-func (s *captureUintService) GetCapture(id int) (*model.CaptureDetail, *util.Errors) {
-	// 创建查询实例
-	device := &dao.CaptureUnit{
-		ID: id,
-	}
-	err := device.GetDevice()
-	if err != nil {
-		return nil, util.FailResponse(err.Error(), nil)
-	}
-	detail := &model.CaptureDetail{CaptureUnit: *device}
-	detail.EndLineTime = ""
-	detail.NetworkState = util.GetDeviceState(device.CaptureSn)
-
-	return detail, nil
-}
-
-func (s *captureUintService) CaptureList(searchValue string, current, size int) ([]model.CaptureDetail, *util.Errors) {
-	var details []model.CaptureDetail
-	device := dao.CaptureUnit{}
-
-	if searchValue != "" {
-		device.CaptureSn = searchValue
-	}
-
-	offset := (current - 1) * size
-	limit := size
-	devices, err := device.GetDevices(offset, limit)
-
-	if err != nil {
-		return nil, util.FailResponse(err.Error(), nil)
-	}
-
-	for _, d := range devices {
-		details = append(details, model.CaptureDetail{
-			CaptureUnit:  d,
-			EndLineTime:  "",
-			NetworkState: util.GetDeviceState(device.CaptureSn),
-		})
-	}
-
-	return details, nil
-}
-
-func (s *captureUintService) CaptureGetList(tenantId int) ([]*dao.CaptureUnit, *util.Errors) {
-	device := &dao.CaptureUnit{
-		TenantId:  tenantId,
-		IsDeleted: 0,
-	}
-	devices, err := device.GetAllDevices()
-	if err != nil {
-		return nil, util.FailResponse(err.Error(), nil)
-	}
-	for _, d := range devices {
-		d.CaptureName = d.CaptureName + "(" + d.CaptureSn + ")"
-	}
-	return devices, nil
-}
-
-func (s *captureUintService) GetPoint(id int) (*dao.CheckPoint, *util.Errors) {
-	// 创建查询实例
-	device := &dao.CheckPoint{
-		ID: id,
-	}
-	err := device.GetDevice()
-	if err != nil {
-		return nil, util.FailResponse(err.Error(), nil)
-	}
-
-	return device, nil
-}
-
-func (s *captureUintService) PointSubmit(userId int64, tenantId int, req *dao.CheckPoint) *util.Errors {
-	device := req
-	device.TenantId = tenantId
-	device.UpdateUser = userId
-	device.UpdateTime = time.Now()
-
-	if device.ID == 0 {
-		device.CreateTime = time.Now()
-		device.CreateUser = userId
-
-		if device.IsExistedBySN() {
-			fmt.Printf("Create IsExistedBySN \n")
-			return util.ParamsInvalidResponse(model.RepeatedPrompts, nil)
-		}
-		fmt.Printf("device = %+v \n", device)
-		if err := device.Create(); err != nil {
-			fmt.Printf("Create err = %s \n", err.Error())
-			return util.FailResponse(err.Error(), nil)
-		}
-		service.OperationHisService.Save(userId, tenantId, util.OperationCreate, util.ModuleTypeDevice,
-			util.DeviceTypePoint, util.GetDeviceObject(device.ID, device.PointName), util.OperationSuccess)
-		return util.SuccessResponse(util.Succeeded, nil)
-	}
-
-	if err := device.Update(); err != nil {
-		fmt.Printf("Update err = %s \n", err.Error())
-		return util.FailResponse(err.Error(), nil)
-	}
-
-	service.OperationHisService.Save(userId, tenantId, util.OperationUpdate, util.ModuleTypeDevice,
-		util.DeviceTypePoint, util.GetDeviceObject(device.ID, device.PointName), util.OperationSuccess)
-	return util.SuccessResponse(util.Succeeded, nil)
-}
-
-func (s *captureUintService) PointList(searchValue string, current, size int) ([]dao.CheckPoint, *util.Errors) {
-	device := dao.CheckPoint{}
-	if searchValue != "" {
-		device.PointSN = searchValue
-	}
-
-	offset := (current - 1) * size
-	limit := size
-	devices, err := device.GetDevices(offset, limit)
-	if err != nil {
-		return nil, util.FailResponse(err.Error(), nil)
-	}
-	return devices, nil
-}
-
-func (s *captureUintService) PointGetList(tenantId int) ([]*dao.CheckPoint, *util.Errors) {
-	device := &dao.CheckPoint{
-		TenantId:  tenantId,
-		IsDeleted: 0,
-	}
-	devices, err := device.GetAllDevices()
-	if err != nil {
-		return nil, util.FailResponse(err.Error(), nil)
-	}
-	for _, d := range devices {
-		d.PointName = d.PointName + "(" + d.PointSN + ")"
-	}
-	return devices, nil
-}
-
-func (s *captureUintService) RemoveCapture(userId int64, tenantId int, id int) *util.Errors {
-	// 创建查询实例
-	device := &dao.CaptureUnit{
-		ID:         id,
-		IsDeleted:  1,
-		UpdateUser: userId,
-		UpdateTime: time.Now(),
-	}
-	err := device.Delete()
-	if err != nil {
-		return util.FailResponse(err.Error(), nil)
-	}
-	service.OperationHisService.Save(userId, tenantId, util.OperationRemove, util.ModuleTypeDevice,
-		util.DeviceTypeCaptureUnit, util.GetDeviceObject(device.ID, device.CaptureName), util.OperationSuccess)
-	return nil
-}
-
-func (s *captureUintService) RemovePoint(userId int64, tenantId int, id int) *util.Errors {
-	// 创建查询实例
-	device := &dao.CheckPoint{
-		ID:         id,
-		IsDeleted:  1,
-		UpdateUser: userId,
-		UpdateTime: time.Now(),
-	}
-	err := device.Delete()
-	if err != nil {
-		return util.FailResponse(err.Error(), nil)
-	}
-	service.OperationHisService.Save(userId, tenantId, util.OperationRemove, util.ModuleTypeDevice,
-		util.DeviceTypePoint, util.GetDeviceObject(device.ID, device.PointName), util.OperationSuccess)
-	return nil
-}
-
-func (s *captureUintService) GetCaptureByGateway(id int) []dao.CaptureUnit {
-	// 创建查询实例
-	device := &dao.CaptureUnit{
-		GatewayId: id,
-	}
-	return device.GetDevicesByGateway()
-}
-
-func (s *captureUintService) GetByLampPole(id int) []dao.CaptureUnit {
-	// 创建查询实例
-	device := &dao.CaptureUnit{
-		LampPoleId: id,
-	}
-	return device.GetDevicesByLampPole()
-}

+ 0 - 116
app/device/service/garbageService.go

@@ -1,116 +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"
-	"time"
-)
-
-var GarbageService = new(garbageService)
-
-type garbageService struct{}
-
-func (s *garbageService) Get(id int) (*dao.Garbage, *util.Errors) {
-	// 创建查询实例
-	device := &dao.Garbage{
-		ID: id,
-	}
-	err := device.GetDevice()
-	if err != nil {
-		return nil, util.FailResponse(err.Error(), nil)
-	}
-	return device, nil
-
-}
-
-func (s *garbageService) CreateOrUpdate(userId int64, tenantId int, req dao.Garbage) *util.Errors {
-	// 创建查询实例
-	device := req
-	device.UpdateUser = userId
-	device.TenantId = tenantId
-	device.UpdateTime = time.Now()
-	if req.ID == 0 {
-		device.CreateTime = time.Now()
-		device.CreateUser = userId
-		if device.IsExistedBySN() {
-			fmt.Printf("Create GetDeviceID err \n")
-			return util.ParamsInvalidResponse("编码不能重复,请重新填写!", nil)
-		}
-		if err := device.Create(); err != nil {
-			fmt.Printf("Create err = %s \n", err.Error())
-			return util.FailResponse(err.Error(), nil)
-		}
-		service.OperationHisService.Save(userId, tenantId, util.OperationCreate, util.ModuleTypeDevice,
-			util.DeviceTypeGarbage, util.GetDeviceObject(device.ID, device.DeviceName), util.OperationSuccess)
-		return util.SuccessResponse(util.Succeeded, nil)
-	}
-	if device.IsExistedByNameAndCode() {
-		return util.ParamsInvalidResponse("编码不能重复,请重新填写!", nil)
-	}
-
-	if err := device.Update(); err != nil {
-		fmt.Printf("Update err = %s \n", err.Error())
-		return util.FailResponse(err.Error(), nil)
-	}
-	service.OperationHisService.Save(userId, tenantId, util.OperationUpdate, util.ModuleTypeDevice,
-		util.DeviceTypeGarbage, util.GetDeviceObject(device.ID, device.DeviceName), util.OperationSuccess)
-	return util.SuccessResponse(util.Succeeded, nil)
-}
-
-func (s *garbageService) List(searchValue string, current, size int) ([]dao.Garbage, *util.Errors) {
-	device := dao.Garbage{}
-	if searchValue != "" {
-		device.DeviceSN = searchValue
-		device.DeviceName = searchValue
-	}
-
-	offset := (current - 1) * size
-	limit := size
-	devices, err := device.GetDevices(offset, limit)
-	if err != nil {
-		return nil, util.FailResponse(err.Error(), nil)
-	}
-	return devices, nil
-}
-
-func (s *garbageService) Remove(userId int64, tenantId int, id int) *util.Errors {
-	// 创建查询实例
-	device := &dao.Garbage{
-		ID:         id,
-		IsDeleted:  1,
-		UpdateUser: userId,
-		UpdateTime: time.Now(),
-	}
-	err := device.Delete()
-	if err != nil {
-		return util.FailResponse(err.Error(), nil)
-	}
-	service.OperationHisService.Save(userId, tenantId, util.OperationRemove, util.ModuleTypeDevice,
-		util.DeviceTypeGarbage, util.GetDeviceObject(device.ID, device.DeviceName), util.OperationSuccess)
-	return nil
-}
-
-func (s *garbageService) GetList(tenantId int) ([]*dao.Garbage, *util.Errors) {
-	var devices []*dao.Garbage
-	err := util.Redis.Get(getGarbageListRedisKey("000000")).Scan(&devices)
-	if err == nil {
-		return devices, nil
-	}
-	device := &dao.Garbage{
-		TenantId:  tenantId,
-		IsDeleted: 0,
-	}
-	devices, err = device.GetAllDevices()
-	if err != nil {
-		return nil, util.FailResponse(err.Error(), nil)
-	}
-	_ = util.Redis.Set(getAlarmListRedisKey(tenantId), devices, 0).Err()
-	return devices, nil
-}
-
-func getGarbageListRedisKey(tenantId string) string {
-	return fmt.Sprintf(model.GarbageList, tenantId)
-}

+ 0 - 116
app/device/service/garbageWayGroupService.go

@@ -1,116 +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"
-	"time"
-)
-
-var GarbageWayGroupService = new(garbageWayGroupService)
-
-type garbageWayGroupService struct{}
-
-func (s *garbageWayGroupService) Get(id int) (*dao.GarbageWayGroup, *util.Errors) {
-	// 创建查询实例
-	device := &dao.GarbageWayGroup{
-		ID: id,
-	}
-	err := device.GetDevice()
-	if err != nil {
-		return nil, util.FailResponse(err.Error(), nil)
-	}
-	return device, nil
-
-}
-
-func (s *garbageWayGroupService) CreateOrUpdate(userId int64, tenantId int, req dao.GarbageWayGroup) *util.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.IsExistedByName() {
-			fmt.Printf("Create GetDeviceID err \n")
-			return util.ParamsInvalidResponse("存在重名,请更改名称!", nil)
-		}
-		if err := device.Create(); err != nil {
-			fmt.Printf("Create err = %s \n", err.Error())
-			return util.FailResponse(err.Error(), nil)
-		}
-		service.OperationHisService.Save(userId, tenantId, util.OperationCreate, util.ModuleTypeDevice,
-			util.DeviceTypeGarbageGroup, util.GetDeviceObject(device.ID, device.GroupName), util.OperationSuccess)
-		return util.SuccessResponse(util.Succeeded, nil)
-	}
-	if device.IsExistedByNameAndCode() {
-		return util.ParamsInvalidResponse("列表中存在重名,请更改垃圾桶道路名称!", nil)
-	}
-
-	if err := device.Update(); err != nil {
-		fmt.Printf("Update err = %s \n", err.Error())
-		return util.FailResponse(err.Error(), nil)
-	}
-
-	service.OperationHisService.Save(userId, tenantId, util.OperationUpdate, util.ModuleTypeDevice,
-		util.DeviceTypeGarbageGroup, util.GetDeviceObject(device.ID, device.GroupName), util.OperationSuccess)
-	return util.SuccessResponse(util.Succeeded, nil)
-}
-
-func (s *garbageWayGroupService) List(searchValue string, current, size int) ([]dao.GarbageWayGroup, *util.Errors) {
-	device := dao.GarbageWayGroup{}
-	if searchValue != "" {
-		device.GroupName = searchValue
-	}
-
-	offset := (current - 1) * size
-	limit := size
-	devices, err := device.GetDevices(offset, limit)
-	if err != nil {
-		return nil, util.FailResponse(err.Error(), nil)
-	}
-	return devices, nil
-}
-
-func (s *garbageWayGroupService) Remove(userId int64, tenantId int, id int) *util.Errors {
-	// 创建查询实例
-	device := &dao.GarbageWayGroup{
-		ID:         id,
-		IsDeleted:  1,
-		UpdateUser: userId,
-		UpdateTime: time.Now(),
-	}
-	err := device.Delete()
-	if err != nil {
-		return util.FailResponse(err.Error(), nil)
-	}
-	service.OperationHisService.Save(userId, tenantId, util.OperationRemove, util.ModuleTypeDevice,
-		util.DeviceTypeGarbageGroup, util.GetDeviceObject(device.ID, device.GroupName), util.OperationSuccess)
-	return nil
-}
-
-func (s *garbageWayGroupService) GetList(tenantId int) ([]*dao.GarbageWayGroup, *util.Errors) {
-	var devices []*dao.GarbageWayGroup
-	err := util.Redis.Get(getGarbageWayGroupListRedisKey("000000")).Scan(&devices)
-	if err == nil {
-		return devices, nil
-	}
-	device := &dao.GarbageWayGroup{
-		TenantId:  tenantId,
-		IsDeleted: 0,
-	}
-	devices, err = device.GetAllDevices()
-	if err != nil {
-		return nil, util.FailResponse(err.Error(), nil)
-	}
-	_ = util.Redis.Set(getGarbageWayGroupListRedisKey("000000"), devices, 0).Err()
-	return devices, nil
-}
-
-func getGarbageWayGroupListRedisKey(tenantId string) string {
-	return fmt.Sprintf(model.GarbageWayGroupList, tenantId)
-}

+ 0 - 23
app/device/service/gatewayRelationService.go

@@ -1,23 +0,0 @@
-package service
-
-import (
-	"iot_manager_service/app/device/dao"
-	"iot_manager_service/util"
-)
-
-// 中间件管理服务
-var GatewayRelationService = new(gatewayRelationService)
-
-type gatewayRelationService struct{}
-
-func (s *gatewayRelationService) Get(id int) (*dao.GatewayRelation, *util.Errors) {
-	// 创建查询实例
-	relation := &dao.GatewayRelation{
-		ID: id,
-	}
-	err := relation.Get()
-	if err != nil {
-		return nil, util.FailResponse(err.Error(), nil)
-	}
-	return relation, nil
-}

+ 0 - 204
app/device/service/gatewayService.go

@@ -1,204 +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"
-	"time"
-)
-
-// 中间件管理服务
-var GatewayService = new(gatewayService)
-
-type gatewayService struct{}
-
-func (s *gatewayService) Get(id int) (*model.GatewayDetail, *util.Errors) {
-	// 创建查询实例
-	device := &dao.Gateway{
-		ID: id,
-	}
-	err := device.GetDevice()
-	if err != nil {
-		return nil, util.FailResponse(err.Error(), nil)
-	}
-
-	detail := &model.GatewayDetail{Gateway: *device}
-
-	relation, e := GatewayRelationService.Get(id)
-	if e == nil {
-		detail.CountLampPole = relation.Total
-	} else {
-		fmt.Printf("GatewayRelationService.Get err = %v", err)
-	}
-
-	detail.EndLineTime = ""
-	state := util.GetDeviceState(device.GatewaySn)
-	detail.RunState = state
-	detail.NetworkState = state
-	return detail, nil
-}
-
-func (s *gatewayService) CreateOrUpdate(userId int64, tenantId int, req *model.GatewayDetail) *util.Errors {
-	device := req.Gateway
-	device.TenantId = tenantId
-	device.UpdateUser = userId
-	device.UpdateTime = time.Now()
-	if device.LampPoleId != 0 {
-		lampPole, err := LampPoleService.GetOne(device.LampPoleId)
-		if err == nil {
-			device.LampLat = lampPole.PoleLat
-			device.LampLng = lampPole.PoleLng
-			device.LampPoleName = lampPole.PoleName
-			device.LampPoleSn = lampPole.PoleSN
-			device.LampPoleLocation = lampPole.InstallLocation
-		} else {
-			fmt.Printf("LampPoleService.GetOne err = %v \n", err)
-		}
-	}
-
-	if device.ID == 0 {
-		device.CreateTime = time.Now()
-		device.CreateUser = userId
-
-		if device.IsExistedBySN() {
-			fmt.Printf("Create IsExistedBySN \n")
-			return util.ParamsInvalidResponse(model.RepeatedPrompts, nil)
-		}
-		fmt.Printf("device = %+v \n", device)
-		if err := device.Create(); err != nil {
-			fmt.Printf("Create err = %s \n", err.Error())
-			return util.FailResponse(err.Error(), nil)
-		}
-		service.OperationHisService.Save(userId, tenantId, util.OperationCreate, util.ModuleTypeDevice,
-			util.DeviceTypeGateway, util.GetDeviceObject(device.ID, device.GatewayName), util.OperationSuccess)
-		return util.SuccessResponse(util.Succeeded, nil)
-	}
-
-	if err := device.Update(); err != nil {
-		fmt.Printf("Update err = %s \n", err.Error())
-		return util.FailResponse(err.Error(), nil)
-	}
-
-	service.OperationHisService.Save(userId, tenantId, util.OperationUpdate, util.ModuleTypeDevice,
-		util.DeviceTypeGateway, util.GetDeviceObject(device.ID, device.GatewayName), util.OperationSuccess)
-	return util.SuccessResponse(util.Succeeded, nil)
-}
-
-func (s *gatewayService) List(searchValue string, current, size int) ([]model.GatewayDetail, *util.Errors) {
-	var details []model.GatewayDetail
-	device := dao.Gateway{}
-
-	if searchValue != "" {
-		device.GatewaySn = searchValue
-	}
-
-	offset := (current - 1) * size
-	limit := size
-	devices, err := device.GetDevices(offset, limit)
-	for _, d := range devices {
-		detail := model.GatewayDetail{Gateway: d}
-		relation, _ := GatewayRelationService.Get(d.ID)
-		if relation != nil {
-			detail.CountLampPole = relation.Total
-		}
-		details = append(details, detail)
-	}
-	if err != nil {
-		return nil, util.FailResponse(err.Error(), nil)
-	}
-	return details, nil
-}
-
-func (s *gatewayService) Remove(userId int64, tenantId int, id int) *util.Errors {
-	// 创建查询实例
-	device := &dao.Gateway{
-		ID:         id,
-		IsDeleted:  1,
-		UpdateUser: userId,
-		UpdateTime: time.Now(),
-	}
-
-	if relation, _ := GatewayRelationService.Get(id); relation != nil && relation.Total > 0 {
-		return util.OperationInvalidResponse(model.GatewayHasRelation, nil)
-	}
-
-	err := device.Delete()
-	if err != nil {
-		return util.FailResponse(err.Error(), nil)
-	}
-	service.OperationHisService.Save(userId, tenantId, util.OperationRemove, util.ModuleTypeDevice,
-		util.DeviceTypeGateway, util.GetDeviceObject(device.ID, device.GatewayName), util.OperationSuccess)
-	return nil
-}
-
-func (s *gatewayService) GetList(tenantId int) ([]*dao.Gateway, *util.Errors) {
-	var devices []*dao.Gateway
-	err := util.Redis.Get(getGatewayListRedisKey(tenantId)).Scan(&devices)
-	if err == nil {
-		return devices, nil
-	}
-
-	device := &dao.Gateway{
-		TenantId:  tenantId,
-		IsDeleted: 0,
-	}
-	devices, err = device.GetAllDevices()
-	for _, device := range devices {
-		device.GatewayName = device.GatewayName + "(" + device.GatewaySn + ")"
-	}
-	if err != nil {
-		return nil, util.FailResponse(err.Error(), nil)
-	}
-	_ = util.Redis.Set(getGatewayListRedisKey(tenantId), devices, 0).Err()
-
-	return devices, nil
-}
-
-func getGatewayListRedisKey(tenantId int) string {
-	return fmt.Sprintf(model.GatewayList, tenantId)
-}
-
-func (s *gatewayService) GetRelevanceDetail(id int) (*model.GatewayDetail, *util.Errors) {
-	// 创建查询实例
-	device := &dao.Gateway{
-		ID: id,
-	}
-	err := device.GetDevice()
-	if err != nil {
-		return nil, util.FailResponse(err.Error(), nil)
-	}
-
-	return &model.GatewayDetail{
-		Gateway:           *device,
-		AlarmTerminalList: AlarmTerminalService.GetByGateway(device.ID),
-		CameraList:        CameraService.GetByGateway(device.ID),
-		CaptureUnitList:   CaptureUintService.GetCaptureByGateway(device.ID),
-		InfoBoardList:     InfoBoardService.GetByGateway(device.ID),
-		IpBroadcastList:   IpBroadcastService.GetByGateway(device.ID),
-		LightControlList:  LightControlService.GetByGateway(device.ID),
-		OptoSensorList:    OptoSensorService.GetByGateway(device.ID),
-		ZigbeeList:        ZigbeeService.GetByGateway(device.ID),
-	}, nil
-}
-
-func (s *gatewayService) GetOne(id int) (*dao.Gateway, *util.Errors) {
-	// 创建查询实例
-	device := &dao.Gateway{
-		ID: id,
-	}
-	err := device.GetDevice()
-	if err != nil {
-		return nil, util.FailResponse(err.Error(), nil)
-	}
-	return device, nil
-}
-
-func (s *gatewayService) GetByLampPole(id int) []dao.Gateway {
-	// 创建查询实例
-	device := &dao.Gateway{
-		LampPoleId: id,
-	}
-	return device.GetDevicesByLampPole()
-}

+ 0 - 110
app/device/service/infoBoardService.go

@@ -1,110 +0,0 @@
-package service
-
-import (
-	"fmt"
-	"iot_manager_service/app/device/dao"
-	"iot_manager_service/app/system/service"
-	"iot_manager_service/util"
-	"time"
-)
-
-var InfoBoardService = new(infoBoardService)
-
-type infoBoardService struct{}
-
-func (s *infoBoardService) Get(id int) (*dao.InfoBoard, *util.Errors) {
-	// 创建查询实例
-	device := &dao.InfoBoard{
-		ID: id,
-	}
-	err := device.GetDevice()
-	if err != nil {
-		return nil, util.FailResponse(err.Error(), nil)
-	}
-	return device, nil
-
-}
-
-func (s *infoBoardService) CreateOrUpdate(userId int64, tenantId int, req dao.InfoBoard) *util.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() {
-			fmt.Printf("Create GetDeviceID err \n")
-			return util.ParamsInvalidResponse("编码不能重复,请重新填写!", nil)
-		}
-		if err := device.Create(); err != nil {
-			fmt.Printf("Create err = %s \n", err.Error())
-			return util.FailResponse(err.Error(), nil)
-		}
-		service.OperationHisService.Save(userId, tenantId, util.OperationCreate, util.ModuleTypeDevice,
-			util.DeviceTypeInfoBoard, util.GetDeviceObject(device.ID, device.InfoName), util.OperationSuccess)
-		return util.SuccessResponse(util.Succeeded, nil)
-	}
-	if device.IsExistedByNameAndCode() {
-		return util.ParamsInvalidResponse("编码不能重复,请重新填写!", nil)
-	}
-
-	if err := device.Update(); err != nil {
-		fmt.Printf("Update err = %s \n", err.Error())
-		return util.FailResponse(err.Error(), nil)
-	}
-
-	service.OperationHisService.Save(userId, tenantId, util.OperationUpdate, util.ModuleTypeDevice,
-		util.DeviceTypeInfoBoard, util.GetDeviceObject(device.ID, device.InfoName), util.OperationSuccess)
-	return util.SuccessResponse(util.Succeeded, nil)
-}
-
-func (s *infoBoardService) List(searchValue string, current, size int) ([]dao.InfoBoard, *util.Errors) {
-	device := dao.InfoBoard{}
-	if searchValue != "" {
-		device.Sn = searchValue
-		device.InfoName = searchValue
-	}
-
-	offset := (current - 1) * size
-	limit := size
-	devices, err := device.GetDevices(offset, limit)
-	if err != nil {
-		return nil, util.FailResponse(err.Error(), nil)
-	}
-	return devices, nil
-}
-
-func (s *infoBoardService) Remove(userId int64, tenantId int, id int) *util.Errors {
-	// 创建查询实例
-	device := &dao.InfoBoard{
-		ID:         id,
-		IsDeleted:  1,
-		UpdateUser: userId,
-		UpdateTime: time.Now(),
-	}
-	err := device.Delete()
-	if err != nil {
-		return util.FailResponse(err.Error(), nil)
-	}
-	service.OperationHisService.Save(userId, tenantId, util.OperationRemove, util.ModuleTypeDevice,
-		util.DeviceTypeInfoBoard, util.GetDeviceObject(device.ID, device.InfoName), util.OperationSuccess)
-	return nil
-}
-
-func (s *infoBoardService) GetByGateway(id int) []dao.InfoBoard {
-	// 创建查询实例
-	device := &dao.InfoBoard{
-		GatewayId: id,
-	}
-	return device.GetDevicesByGateway()
-}
-
-func (s *infoBoardService) GetByLampPole(id int) []dao.InfoBoard {
-	// 创建查询实例
-	device := &dao.InfoBoard{
-		LampPoleId: id,
-	}
-	return device.GetDevicesByLampPole()
-}

+ 0 - 123
app/device/service/intelligentLightingService.go

@@ -1,123 +0,0 @@
-package service
-
-import (
-	"fmt"
-	"iot_manager_service/app/device/dao"
-	"iot_manager_service/app/device/model"
-	"iot_manager_service/util"
-	"strconv"
-	"time"
-)
-
-var IntelligentLightingService = new(intelligentLightingService)
-
-type intelligentLightingService struct{}
-
-func (s *intelligentLightingService) GetDetailByLight(tenantId, id int) (model.RspIntelligentLightDetail,
-	*util.Errors) {
-	detail := model.RspIntelligentLightDetail{}
-	lightControl, _ := LightControlService.GetOne(id)
-	if lightControl != nil {
-		lightControl.LampPoleName = lightControl.LampPoleName + "(" + lightControl.LampPoleSn + ")"
-		detail.LightControlList = []dao.LightControl{*lightControl}
-		detail.LampPoleName = lightControl.LampPoleName
-	}
-	detail.LightRelMap = s.GetLightRelation(tenantId, id, model.RelationTypeLight)
-	return detail, nil
-}
-
-func (s *intelligentLightingService) GetLightRelation(tenantId, rId, relationType int) model.IntelligentLightSimple {
-	detail := model.IntelligentLightSimple{}
-
-	// 获取照明策略关联
-	intelligentLight := dao.IntelligentLight{
-		Rid:          rId,
-		RelationType: relationType,
-		TenantId:     tenantId,
-	}
-	relations, _ := intelligentLight.GetByRidAndType()
-	if len(relations) == 0 {
-		return detail
-	}
-	lightId := relations[0].LightID
-
-	// 获取策略详情(日期,如果是年,使用当前年起始日期)
-	lightStrategy, _ := LightStrategyService.GetOne(lightId)
-
-	if lightStrategy == nil {
-		return detail
-	}
-	//获取灯控名称和SN
-	detail.LightName = lightStrategy.LightName
-	detail.LightSn = lightStrategy.LightSn
-
-	//全年
-	if lightStrategy.IsAllYear == model.IsYear {
-		year := time.Now().Year()
-		detail.EffectiveDate = fmt.Sprintf("%d-01-01 ~ %d-12-31", year, year)
-	} else {
-		detail.EffectiveDate = lightStrategy.StartTime + " ~ " + lightStrategy.EndTime
-	}
-
-	// 获取策略时间(每日的时间策略)
-	timeConditions := TimeConditionService.GetByLightId(lightId)
-	for _, timeCondition := range timeConditions {
-		if timeCondition.StartTime == "" && timeCondition.EndTime == "" {
-			timeCondition.StartTime = "日落"
-			timeCondition.EndTime = "日出"
-		}
-		detail.TimeConditionList = append(detail.TimeConditionList, model.TimeConditionSimple{
-			Luminance: strconv.Itoa(timeCondition.Luminance) + "%",
-			Times:     timeCondition.StartTime + " ~ " + timeCondition.EndTime,
-		})
-	}
-
-	return detail
-}
-
-func (s *intelligentLightingService) BatchGet(ids []int) []dao.IntelligentLight {
-	// 创建查询实例
-	intelligent := &dao.IntelligentLight{}
-	intelligentLights, err := intelligent.BatchGet(ids)
-	if err != nil {
-		return nil
-	}
-	return intelligentLights
-}
-
-func (s *intelligentLightingService) List(tenantId int, searchValue string, current, size,
-	groupId int) ([]model.RspIntelligentLightListDetail, error) {
-	var result []model.RspIntelligentLightListDetail
-	//获取策略关联信息
-	intelligent := &dao.IntelligentLight{
-		RelationType: model.RelationTypeLampPoleGroup,
-		TenantId:     tenantId,
-	}
-
-	list, err := intelligent.GetByGroup(searchValue, current, size, groupId)
-	if err != nil {
-		return nil, nil
-	}
-	for _, intelligentLight := range list {
-		detail := model.RspIntelligentLightListDetail{
-			PublicName:   intelligentLight.LightControl.Name,
-			PublicId:     intelligentLight.LightControl.ID,
-			LampPoleName: intelligentLight.LightControl.LampPoleName,
-			LampPoleSn:   intelligentLight.LightControl.LampPoleSn,
-			StrategyName: intelligentLight.LightName,
-			DeviceSn:     intelligentLight.LightControl.Sn,
-			ControlType:  intelligentLight.LightControl.ControlType,
-			IsShowOpts:   true,
-		}
-
-		if intelligentLight.Luminance > 0 {
-			detail.LightControlState = 1
-		} else {
-			detail.LightControlState = 2
-		}
-		detail.RunState = util.GetDeviceState(detail.DeviceSn)
-		result = append(result, detail)
-	}
-
-	return result, nil
-}

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


Some files were not shown because too many files changed in this diff