New file |
| | |
| | | package controllers |
| | | |
| | | import ( |
| | | "basic.com/pubsub/esutil.git" |
| | | "basic.com/valib/logger.git" |
| | | "github.com/gin-gonic/gin" |
| | | "strconv" |
| | | "webserver/cache" |
| | | "webserver/extend/code" |
| | | "webserver/extend/config" |
| | | "webserver/extend/util" |
| | | ) |
| | | |
| | | type ClearDataController struct{} |
| | | |
| | | type clearParams struct { |
| | | StartTime string `json:"startTime"` |
| | | EndTime string `json:"endTime"` |
| | | } |
| | | |
| | | func (cdc *ClearDataController) ClearEsData(c *gin.Context) { |
| | | var cp clearParams |
| | | localConf, err := cache.GetServerInfo() |
| | | if err != nil || localConf.AlarmIp == "" || localConf.ServerId == "" { |
| | | logger.Debug("localConfig is wrong!!!") |
| | | util.ResponseFormat(c, code.ComError, "es config err") |
| | | return |
| | | } |
| | | ip := localConf.AlarmIp |
| | | port := strconv.Itoa(int(localConf.AlarmPort)) |
| | | analyServerId := localConf.ServerId |
| | | c.BindJSON(&cp) |
| | | startTime := cp.StartTime |
| | | endTime := cp.EndTime |
| | | queryRes, queryErr := esutil.QueryAnalyServerData(ip, port, config.EsInfo.EsIndex.AiOcean.IndexName, startTime, endTime, analyServerId) |
| | | if queryErr != nil { |
| | | util.ResponseFormat(c, code.InvalidRequest, "校验数据失败") |
| | | return |
| | | } |
| | | if queryRes != true { |
| | | util.ResponseFormat(c, code.InvalidRequest, "数据已删除或该时间段无数据") |
| | | return |
| | | } |
| | | addRes, addErr := esutil.AddDelTask(ip, port, config.BasicFS.IndexName, startTime, endTime, analyServerId) |
| | | if addErr != nil { |
| | | util.ResponseFormat(c, code.InvalidRequest, "追加任务失败") |
| | | return |
| | | } |
| | | if addRes != true { |
| | | util.ResponseFormat(c, code.InvalidRequest, "追加任务失败") |
| | | return |
| | | } |
| | | deleteRes, deleteErr := esutil.DeleteAnalyServerData(ip, port, config.BasicFS.IndexName, startTime, endTime, analyServerId) |
| | | if deleteErr != nil { |
| | | util.ResponseFormat(c, code.InvalidRequest, "数据删除失败") |
| | | return |
| | | } |
| | | if deleteRes != true { |
| | | util.ResponseFormat(c, code.InvalidRequest, "数据删除失败") |
| | | return |
| | | } |
| | | util.ResponseFormat(c, code.Success, deleteRes) |
| | | return |
| | | } |
| | |
| | | UploadSuffixError = &Code{http.StatusBadRequest, false, "该上传文件格式目前暂不支持"} |
| | | // UploadSizeLimit 目前上传仅支持小于5M的文件内容 |
| | | UploadSizeLimit = &Code{http.StatusBadRequest, false, "目前上传仅支持小于5M的文件内容"} |
| | | InvalidRequest = &Code{http.StatusBadRequest, false, "请求无效"} |
| | | LoginSuccess = &Code{http.StatusOK, true, "登录成功"} |
| | | // SigninInfoError 账户名或密码有误 |
| | | LoginInfoError = &Code{http.StatusUnauthorized, false, "用户名或密码错误"} |
| | |
| | | Port string `mapstructure:"port"` |
| | | } |
| | | |
| | | type elastic struct { |
| | | IndexName string `mapstructure: "indexName"` |
| | | IndexType string `mapstructure: "indexType"` |
| | | } |
| | | |
| | | var SoPath = &sopath{} |
| | | |
| | | var EsInfo = &esinfo{} |
| | | |
| | | var BasicFS = &elastic{} |
| | | |
| | | type facedetect struct { |
| | | Ip string `mapstructure:"Ip"` |
| | |
| | | viper.UnmarshalKey("facedetect", FaceDetectSet) |
| | | viper.UnmarshalKey("dbpersoncompare", DbPersonCompInfo) |
| | | viper.UnmarshalKey("espersoncompare", EsCompServerInfo) |
| | | viper.UnmarshalKey("elastic.basicFS", BasicFS) |
| | | } |
| | |
| | | esSearchController := new(controllers.EsSearchController) |
| | | esManagementController := new(controllers.EsManagementController) |
| | | realTimeController := new(controllers.RealTimeController) |
| | | clearDataController := new(controllers.ClearDataController) |
| | | cameraTimeRuleController := new(controllers.CameraTimeruleController) |
| | | polygonController := new(controllers.CameraPolygonController) |
| | | cameraTaskController := new(controllers.CameraTaskController) |
| | |
| | | realTime.POST("/initForCaptureData", realTimeController.InitForCaptureData) |
| | | realTime.POST("/initForMonitoringData", realTimeController.InitForMonitoringData) |
| | | } |
| | | //清理数据 |
| | | clearData := r.Group(urlPrefix + "/clearData") |
| | | { |
| | | clearData.POST("/clearEsData", clearDataController.ClearEsData) |
| | | } |
| | | |
| | | //底库 操作 |
| | | vdbtable := r.Group(urlPrefix + "/dbtable") |
| | | { |