| | |
| | | |
| | | import ( |
| | | "basic.com/dbapi.git" |
| | | "github.com/gin-gonic/gin" |
| | | "webserver/extend/code" |
| | | "webserver/extend/util" |
| | | "github.com/gin-gonic/gin" |
| | | ) |
| | | |
| | | type CameraTaskArgsController struct { |
| | |
| | | } |
| | | } |
| | | |
| | | // @Summary 根据多个摄像机id查询联动任务规则设置 |
| | | // @Description 根据多个摄像机id查询联动任务规则设置 |
| | | // @Accept json |
| | | // @Produce json |
| | | // @Tags CameraTaskArgs |
| | | // @Param cameraIds body controllers.MultiCamera true "摄像机ids" |
| | | // @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}" |
| | | // @Failure 500 {string} json "{"code":500, success:false, msg:"",data:""}" |
| | | // @Router /data/api-v/cameraTaskArgs/getLinkRulesByCameraIds [get] |
| | | func (controller CameraTaskArgsController) GetLinkRulesByCameraIds(c *gin.Context) { |
| | | var cameraIds MultiCamera |
| | | if err := c.BindJSON(&cameraIds);err !=nil { |
| | | util.ResponseFormat(c,code.RequestParamError,"参数有误") |
| | | return |
| | | } |
| | | var api dbapi.CameraTaskArgsApi |
| | | flag,data := api.GetLinkRulesByCameraIds() |
| | | if flag { |
| | | util.ResponseFormat(c,code.Success,data) |
| | | } else { |
| | | util.ResponseFormat(c,code.ComError,data) |
| | | } |
| | | } |
| | | |
| | | // @SUmmary 根据分组id删除摄像机算法规则 |
| | | // @Description 根据分组id删除摄像机算法规则 |
| | | // @Produce json |
| | |
| | | util.ResponseFormat(c,code.ComError,data) |
| | | } |
| | | |
| | | } |
| | | |
| | | type SaveLinkRulesGroupVo struct { |
| | | LinkTaskId string `json:"link_task_id"`//联动任务id |
| | | GroupId string `json:"group_id"`//分组id |
| | | GroupText string `json:"group_text"`//组规则文字 |
| | | Rules []LinkRuleArgVo `json:"rules"`//组内的规则 |
| | | } |
| | | |
| | | type LinkRuleArgVo struct { |
| | | TaskId string `json:"task_id"` |
| | | CameraTaskArgs |
| | | } |
| | | |
| | | type CameraTaskArgs struct { |
| | | Id string `json:"id"` |
| | | CameraTaskId string `json:"camera_task_id"`//camera_tasks表的主键,摄像机和任务关联id或者联动任务id |
| | | CameraId string `json:"camera_id"`//摄像机id |
| | | PolygonId string `json:"polygon_id"`//多边形id |
| | | SdkId string `json:"sdk_id"`//算法id |
| | | SdkArgAlias string `json:"sdk_arg_alias"`//算法参数别名 |
| | | Operator string `json:"operator"`//计算方式=,>,>=等等 |
| | | OperatorType string `json:"operator_type"`//计算的值类型 |
| | | SdkArgValue string `json:"sdk_arg_value"` //算法参数值设置 |
| | | Sort int `json:"sort"`//排序 |
| | | RuleWithPre string `json:"rule_with_pre"`//与上一条记录的逻辑运算规则(&&,||) |
| | | GroupId string `json:"group_id"`//分组id |
| | | } |
| | | |
| | | // @Summary 保存联动任务规则参数 |
| | | // @Description 保存联动任务规则参数 |
| | | // @Accept json |
| | | // @Produce json |
| | | // @Param saveBody body controllers.SaveLinkRulesGroupVo true "联动任务规则保存参数" |
| | | // @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}" |
| | | // @Failure 500 {string} json "{"code":500, success:false, msg:"",data:""}" |
| | | // @Router /data/api-v/cameraTaskArgs/saveLinkRulesByGroup [post] |
| | | func (controller CameraTaskArgsController) SaveLinkRulesByGroup(c *gin.Context) { |
| | | var saveBody SaveLinkRulesGroupVo |
| | | if err := c.BindJSON(&saveBody);err !=nil { |
| | | util.ResponseFormat(c,code.RequestParamError,"参数有误") |
| | | return |
| | | } |
| | | var api dbapi.CameraTaskArgsApi |
| | | paramBody := util.Struct2Map(saveBody) |
| | | flag,data := api.SaveLinkRulesByGroup(paramBody) |
| | | if flag { |
| | | util.ResponseFormat(c,code.Success,data) |
| | | } else { |
| | | util.ResponseFormat(c,code.ComError,data) |
| | | } |
| | | } |