123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- package controller
- import (
- "github.com/gin-gonic/gin"
- "github.com/sirupsen/logrus"
- "iot_manager_service/app/device/dao"
- "iot_manager_service/app/device/service"
- "iot_manager_service/app/middleware"
- "iot_manager_service/util/common"
- "net/http"
- "strconv"
- )
- var BigScreen = new(bigScreen)
- type bigScreen struct {
- }
- func (big *bigScreen) DeviceNum(ctx *gin.Context) {
- queryType := ctx.Query("queryType")
- rsp := service.BigServer.DeviceNum(queryType)
- ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, rsp))
- }
- func (big *bigScreen) LampPoleStatus(ctx *gin.Context) {
- var rsp dao.TotalLamp
- all, fault := service.BigServer.GetLampCount()
- rsp.CountNum = all
- rsp.FaultNum = fault
- ctx.JSON(http.StatusOK, common.SuccessResponse(common.Success, rsp))
- }
- func (big *bigScreen) DevicesStatus(ctx *gin.Context) {
- ctx.JSON(http.StatusOK, common.SuccessResponse(common.Success, service.BigServer.DevicesStatus()))
- }
- func (big *bigScreen) Energy(ctx *gin.Context) {
- rsp := service.BigServer.GetEnergy(ctx.Query("startDate"), ctx.Query("endDate"))
- ctx.JSON(http.StatusOK, common.SuccessResponse(common.Success, rsp))
- }
- func (big *bigScreen) LightRate(ctx *gin.Context) {
- authorization := ctx.GetHeader("Authorization")
- claims := middleware.ParseAccessToken(authorization)
-
-
-
-
-
-
-
-
-
- ctx.JSON(http.StatusOK, common.SuccessResponse(common.Success, service.BigServer.GetLightRate(claims.TenantId)))
- }
- func (big *bigScreen) AlarmInfo(ctx *gin.Context) {
- rsp := service.BigServer.GetAlarmInfo()
- ctx.JSON(http.StatusOK, common.SuccessResponse(common.Success, rsp))
- }
- func (big *bigScreen) AlarmStatistics(ctx *gin.Context) {
-
- rsp := service.BigServer.AlarmStatus()
- ctx.JSON(http.StatusOK, common.SuccessResponse(common.Success, rsp))
- }
- func (big *bigScreen) FlowInfo(ctx *gin.Context) {
-
- rsp := service.BigServer.AlarmStatus()
- ctx.JSON(http.StatusOK, common.SuccessResponse(common.Success, rsp))
- }
- func (big *bigScreen) Environment(ctx *gin.Context) {
- deviceId := ctx.Query("id")
- rsp := service.BigServer.GetEnv(deviceId)
- ctx.JSON(http.StatusOK, common.SuccessResponse(common.Success, rsp))
- }
- func (big *bigScreen) InfoBoard(ctx *gin.Context) {
- authorization := ctx.GetHeader("Authorization")
- claims := middleware.ParseAccessToken(authorization)
- rsp := service.BigServer.GetLEDProgram(claims.TenantId)
- ctx.JSON(http.StatusOK, common.SuccessResponse(common.Success, rsp))
- }
- func (big *bigScreen) Program(ctx *gin.Context) {
- id := ctx.Query("id")
- atoi, _ := strconv.Atoi(id)
- rsp := service.BigServer.GetProgramUrl(id)
- rsp.Id = int64(atoi)
- ctx.JSON(http.StatusOK, common.SuccessResponse(common.Success, rsp))
- }
- func (big *bigScreen) BridgeSensor(ctx *gin.Context) {
- authorization := ctx.GetHeader("Authorization")
- claims := middleware.ParseAccessToken(authorization)
- rsp := service.BigServer.GetBridgeSensors(claims.TenantId)
- ctx.JSON(http.StatusOK, common.SuccessResponse(common.Success, rsp))
- }
- func (big *bigScreen) QueryOverView(ctx *gin.Context) {
- padScreen := ctx.Query("padScreen")
- authorization := ctx.GetHeader("Authorization")
- claims := middleware.ParseAccessToken(authorization)
- rsp := service.BigServer.OverView(claims.TenantId, padScreen)
- ctx.JSON(http.StatusOK, common.SuccessResponse(common.Success, rsp))
- }
- func (big *bigScreen) SubmitOverView(ctx *gin.Context) {
- authorization := ctx.GetHeader("Authorization")
- claims := middleware.ParseAccessToken(authorization)
- var req []dao.OverView
- err := ctx.ShouldBind(&req)
- if err != nil {
- logrus.Errorf("SubmitOverView ShouldBind error:%v", err)
- }
- for i, _ := range req {
- req[i].TenantId = claims.TenantId
- }
- service.BigServer.Submit(req)
- ctx.JSON(200, "")
- }
|