123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- package controller
- import (
- "github.com/gin-gonic/gin"
- "iot_manager_service/app/middleware"
- "iot_manager_service/app/operation/model"
- "iot_manager_service/app/operation/service"
- "iot_manager_service/util/common"
- "net/http"
- "strconv"
- )
- // Capture 抓拍单元
- var Capture = new(captureCtl)
- type captureCtl struct{}
- // CountList 取车流量 月日
- func (c captureCtl) CountList(ctx *gin.Context) {
- value, _ := ctx.Get(middleware.Authorization)
- claims := value.(*middleware.Claims)
- var req model.RequestCaptureFilter
- err := ctx.ShouldBindQuery(&req)
- if err != nil {
- ctx.JSON(http.StatusOK, err)
- return
- }
- var records interface{}
- err = nil
- if req.QueryType == "day" {
- records, err = service.CaptureService.GetDayVehicleTotal(claims.TenantId, req)
- } else {
- records, err = service.CaptureService.GetMonthVehicleTotal(claims.TenantId, req)
- }
- if err != nil {
- ctx.JSON(http.StatusOK, err)
- return
- }
- ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, records))
- }
- // SuggestSpeed 取抓拍单元 方位
- func (c captureCtl) SuggestSpeed(ctx *gin.Context) {
- captureId, err := strconv.Atoi(ctx.Query("captureId"))
- if err != nil {
- ctx.JSON(http.StatusOK, err)
- return
- }
- value, _ := ctx.Get(middleware.Authorization)
- claims := value.(*middleware.Claims)
- var records interface{}
- records, err = service.CaptureService.GetSuggestSpeed(claims.TenantId, captureId)
- if err != nil {
- ctx.JSON(http.StatusOK, err)
- return
- }
- ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, records))
- }
- // AreaList 归属地统计 list
- func (c captureCtl) AreaList(ctx *gin.Context) {
- value, _ := ctx.Get(middleware.Authorization)
- claims := value.(*middleware.Claims)
- var req model.RequestCaptureFilter
- err := ctx.ShouldBindQuery(&req)
- if err != nil {
- ctx.JSON(http.StatusOK, err)
- return
- }
- var records interface{}
- records, err = service.CaptureAreaService.GetAreaList(claims.TenantId, req)
- if err != nil {
- ctx.JSON(http.StatusOK, err)
- return
- }
- ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, records))
- }
- // AreaTypeList 归属地统计 line图表
- func (c captureCtl) AreaTypeList(ctx *gin.Context) {
- value, _ := ctx.Get(middleware.Authorization)
- claims := value.(*middleware.Claims)
- var req model.RequestCaptureFilter
- err := ctx.ShouldBindQuery(&req)
- if err != nil {
- ctx.JSON(http.StatusOK, err)
- return
- }
- var records interface{}
- records, err = service.CaptureAreaService.GetAreaTypeList(claims.TenantId, req)
- if err != nil {
- ctx.JSON(http.StatusOK, err)
- return
- }
- ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, records))
- }
- // VehicleTypeEx 车型 列表 查询
- func (c captureCtl) VehicleTypeEx(ctx *gin.Context) {
- value, _ := ctx.Get(middleware.Authorization)
- claims := value.(*middleware.Claims)
- var req model.RequestCaptureFilter
- err := ctx.ShouldBindQuery(&req)
- if err != nil {
- ctx.JSON(http.StatusOK, err)
- return
- }
- var records interface{}
- err = nil
- records, err = service.CaptureVehicleTypeExService.GetVehicleList(claims.TenantId, req)
- if err != nil {
- ctx.JSON(http.StatusOK, err)
- return
- }
- ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, records))
- }
- // VehicleTypeList 车型 line线图数据
- func (c captureCtl) VehicleTypeList(ctx *gin.Context) {
- value, _ := ctx.Get(middleware.Authorization)
- claims := value.(*middleware.Claims)
- var req model.RequestCaptureFilter
- err := ctx.ShouldBindQuery(&req)
- if err != nil {
- ctx.JSON(http.StatusOK, err)
- return
- }
- var records interface{}
- err = nil
- records, err = service.CaptureVehicleTypeExService.GetVehicleTypeList(claims.TenantId, req)
- if err != nil {
- ctx.JSON(http.StatusOK, err)
- return
- }
- ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, records))
- }
- // SpeedList 车速统计
- func (c captureCtl) SpeedList(ctx *gin.Context) {
- value, _ := ctx.Get(middleware.Authorization)
- claims := value.(*middleware.Claims)
- var req model.RequestCaptureFilter
- err := ctx.ShouldBindQuery(&req)
- if err != nil {
- ctx.JSON(http.StatusOK, err)
- return
- }
- var records interface{}
- records, err = service.CaptureSpeedService.GetList(claims.TenantId, req)
- if err != nil {
- ctx.JSON(http.StatusOK, err)
- return
- }
- ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, records))
- }
- // OverSpeedRecord 超速明细
- func (c captureCtl) OverSpeedRecord(ctx *gin.Context) {
- var req model.RequestCaptureOverSpeed
- _ = ctx.ShouldBindQuery(&req)
- var records interface{}
- records, err := service.CaptureSpeedService.GetOverSpeedRecord(req)
- if err != nil {
- ctx.JSON(http.StatusOK, err)
- return
- }
- ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, records))
- }
- // OverSpeedRecordSync 同步超速明细记录
- func (c captureCtl) OverSpeedRecordSync(ctx *gin.Context) {
- var req model.RequestCaptureFilter
- _ = ctx.ShouldBindQuery(&req)
- go func() {
- service.CaptureSpeedService.SyncOverSpeedRecord(req.StartTime, req.EndTime)
- }()
- ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, nil))
- }
|