Przeglądaj źródła

井盖、桥梁接口

terry 2 lat temu
rodzic
commit
bdaa172fe3

+ 7 - 8
app/data/dao/environmentDao.go

@@ -48,14 +48,13 @@ func (c *EnvironmentData) GetByTime(start, end time.Time) ([]EnvironmentData, er
 
 // EnvironmentDataDay 环境监测器天数据统计
 type EnvironmentDataSummary struct {
-	ID       int `gorm:"primary_key" json:"id"`    //编号
 	DeviceId int `gorm:"type:int" json:"deviceId"` //设备名称
 	//1=空气质量 2=PM2.5 3=pm10 4=温度 5=湿度 6=风速 7=气压 8=噪音 9=光照强度 10=风向 11=降雨量 12=紫外线
 	DataType   int       `gorm:"type:int" json:"dataType"`
-	ValAvg     float32   `gorm:"type:float(10, 2)" json:"valAvg"` //天均值
-	ValMax     float32   `gorm:"type:float(10, 2)" json:"valMax"` //天最大
-	ValMin     float32   `gorm:"type:float(10, 2)" json:"valMin"` //天最小
-	CreateTime time.Time `gorm:"type:datetime" json:"createTime"` //新增时间
+	ValAvg     float32   `gorm:"type:float(10, 2)" json:"valAvg"`       //天均值
+	ValMax     float32   `gorm:"type:float(10, 2)" json:"valMax"`       //天最大
+	ValMin     float32   `gorm:"type:float(10, 2)" json:"valMin"`       //天最小
+	CreateTime time.Time `gorm:"type:datetime;index" json:"createTime"` //新增时间
 }
 
 func (EnvironmentDataSummary) TableName() string {
@@ -66,9 +65,9 @@ func (c *EnvironmentDataSummary) DaySummary(start, end time.Time) error {
 	err := Db.Debug().Model(&c).Exec(`INSERT INTO data_environment_summary
     select device_id,
        data_type,
-       round(avg(value), 2) as   avg_val,
-       max(value)           as   max_val,
-       min(value)           as   min_val,
+       round(avg(value), 2)    val_avg,
+       max(value)           val_max,
+       min(value)           val_min,
        adddate(current_date, -1) create_time
 from (
          SELECT device_id, 2 AS data_type, pm25 AS value, create_time

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

@@ -113,6 +113,15 @@ func (c *manholeCoverCtl) GetList(ctx *gin.Context) {
 }
 
 func (c *manholeCoverCtl) AllList(ctx *gin.Context) {
+	value, _ := ctx.Get(middleware.Authorization)
+	claims := value.(*middleware.Claims)
+
+	devices, err := service.ManholeCoverService.GetList(claims.TenantId)
+	if err != nil {
+		ctx.JSON(http.StatusOK, err)
+		return
+	}
+	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, devices))
 }
 
 func (c *manholeCoverCtl) Setting(ctx *gin.Context) {

+ 30 - 0
app/operation/controller/bridgeController.go

@@ -0,0 +1,30 @@
+package controller
+
+import (
+	"github.com/gin-gonic/gin"
+)
+
+var Bridge = new(bridgeCtl)
+
+type bridgeCtl struct{}
+
+func (c *bridgeCtl) EnvironmentList(ctx *gin.Context) {
+}
+
+func (c *bridgeCtl) SensorList(ctx *gin.Context) {
+}
+
+func (c *bridgeCtl) LiveData(ctx *gin.Context) {
+}
+
+func (c *bridgeCtl) Summary(ctx *gin.Context) {
+}
+
+func (c *bridgeCtl) HealthIndicators(ctx *gin.Context) {
+}
+
+func (c *bridgeCtl) SummaryList(ctx *gin.Context) {
+}
+
+func (c *bridgeCtl) CameraList(ctx *gin.Context) {
+}

+ 15 - 0
app/operation/controller/manholeController.go

@@ -0,0 +1,15 @@
+package controller
+
+import (
+	"github.com/gin-gonic/gin"
+)
+
+var Manhole = new(manholeCtl)
+
+type manholeCtl struct{}
+
+func (c *manholeCtl) HistoryList(ctx *gin.Context) {
+}
+
+func (c *manholeCtl) LiveData(ctx *gin.Context) {
+}

+ 0 - 2
main.go

@@ -5,7 +5,6 @@ import (
 	"gorm.io/driver/mysql"
 	"gorm.io/gorm"
 	gormLogger "gorm.io/gorm/logger"
-
 	"iot_manager_service/app/data/controller"
 	data "iot_manager_service/app/data/dao"
 	device "iot_manager_service/app/device/dao"
@@ -34,7 +33,6 @@ func main() {
 	}
 	minio.InitMinio()
 	controller.CalcTask()
-
 	engine := gin.Default()
 	router.InitRouter(engine)
 	_ = engine.Run(config.Instance().Server.Address)

+ 15 - 0
router/router.go

@@ -496,4 +496,19 @@ func InitRouter(engine *gin.Engine) {
 		garbageGroup.GET("/query-way-realtime", operation.Garbage.GarbageList)
 		garbageGroup.GET("/count-list", operation.Garbage.CountList)
 	}
+	bridgeGroup := operationGroup.Group("/bridge")
+	{
+		bridgeGroup.GET("/data/environmental/environmental-list", operation.Bridge.EnvironmentList)
+		bridgeGroup.GET("/data/sensor/list", operation.Bridge.SensorList)
+		bridgeGroup.GET("/data/sensor/realtime-data", operation.Bridge.LiveData)
+		bridgeGroup.GET("/data/pandect/detail", operation.Bridge.Summary)
+		bridgeGroup.GET("/data/pandect/health-indicators", operation.Bridge.HealthIndicators)
+		bridgeGroup.GET("/data/pandect/list", operation.Bridge.SummaryList)
+		bridgeGroup.GET("/data/pandect/camera-list", operation.Bridge.CameraList)
+	}
+	manholeGroup := operationGroup.Group("/manhole")
+	{
+		manholeGroup.GET("/now", operation.Manhole.LiveData)
+		manholeGroup.GET("/history-list", operation.Manhole.LiveData)
+	}
 }