sunty
2019-11-01 712ef81c6b8813a498a66cf61ffcd37e5c502c8c
Merge remote-tracking branch 'origin/master'

# Conflicts:
# controllers/es.go
1个文件已删除
2个文件已添加
33个文件已修改
613 ■■■■ 已修改文件
config/test.yaml 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/area.go 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/camera.go 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/cameraPTZ.go 71 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/cameraPolygon.go 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/cameraTask.go 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/cameraTaskArgs.go 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/cameraTimerule.go 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/capture.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/cluster.go 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/dbtableperson.go 77 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/dbtablesCon.go 28 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/dictionary.go 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/es.go 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/esSearch.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/eventPush.go 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/fileController.go 65 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/gb28181Cloud.go 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/initForData.go 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/monitoring.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/panTilt.go 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/pollConfig.go 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/sdk.go 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/sysMenu.go 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/sysRole.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/syssetcont.go 70 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/taglist.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/task.go 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/tasklist.go 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/user.go 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
extend/config/config.go 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
extend/sys/system.go 55 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
go.mod 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
go.sum 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
middlewares/auth/auth.go 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
router/router.go 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
config/test.yaml
@@ -24,16 +24,17 @@
  sysThresholds:
  -
    value: 60
    color: #13ce66
    color: '#13ce66'
  -
    value: 80
    color: #FF9C4A
    color: '#FF9C4A'
  -
    value: 95
    color: #f53d3d
    color: '#f53d3d'
  -
    value: 100
    color: #5d0000
    color: '#5d0000'
  ptzSpeed: 50
database:
  driver: sqlite
  name: sqlite3
controllers/area.go
@@ -19,6 +19,7 @@
// @Summary 显示树形结构
// @Description 显示左侧所有区域和摄像机
// @Security ApiKeyAuth
// @Produce json
// @Tags menu
// @Param parentid query string true "区域的id"
@@ -39,6 +40,7 @@
// @Summary 显示Gb28181树形结构
// @Description 显示Gb28181树形结构
// @Security ApiKeyAuth
// @Produce json
// @Tags menu
// @Param parentid query string true "区域的id"
@@ -59,6 +61,7 @@
// @Summary 刷新Gb28181平台树
// @Description 刷新Gb28181平台树
// @Security ApiKeyAuth
// @Produce json
// @Tags menu
// @Param id formData string false "国标平台id"
@@ -76,6 +79,7 @@
    }
}
// @Security ApiKeyAuth
// @Summary 删除Gb28181平台
// @Description 删除Gb28181平台
// @Produce json
@@ -92,6 +96,7 @@
    }
}
// @Security ApiKeyAuth
// @Summary 添加menu的区域
// @Description 添加目录上区域
// @Produce json
@@ -119,6 +124,7 @@
    }
}
// @Security ApiKeyAuth
// @Summary 修改名字
// @Description 修改区域名字
// @Accept  json
@@ -159,6 +165,7 @@
    }
}
// @Security ApiKeyAuth
// @Summary 删除一个区域
// @Description 点击删除按钮时删除一个区域
// @Produce json
controllers/camera.go
@@ -42,6 +42,7 @@
// @Summary 添加摄像机
// @Description  "传入区域的id(areaid)和摄像机名字(name) 必须, 其他参数可以在摄像机配置点击保存进行添加"
// @Security ApiKeyAuth
// @Accept json
// @Produce json
// @Tags camera
@@ -70,6 +71,7 @@
// @Summary 更新摄像机
// @Description "用于更新摄像机操作"
// @Security ApiKeyAuth
// @Accept json
// @Produce json
// @Tags camera
@@ -97,6 +99,7 @@
// @Summary "删除摄像机"
// @Description "根据摄像机id删除摄像机"
// @Security ApiKeyAuth
// @Produce json
// @Tags camera
// @Param cid path string true "摄像机id example: cid0"
@@ -116,6 +119,7 @@
// @Summary 显示摄像机
// @Description "显示摄像机"
// @Security ApiKeyAuth
// @Produce json
// @Tags camera
// @Param cid path string true "摄像机id"
@@ -166,6 +170,7 @@
    return json.Marshal(test)
}
// @Security ApiKeyAuth
// @Summary 将摄像机挂到指定的目录树下
// @Description 将摄像机挂到指定的目录树下
// @Produce json
@@ -182,6 +187,7 @@
    fmt.Println(areaId)
}
// @Security ApiKeyAuth
// @Summary 删除某一个目录树下的指定摄像机
// @Description 删除某一个目录树下的指定摄像机
// @Produce json
@@ -198,9 +204,9 @@
    fmt.Println(areaId)
}
// @Security ApiKeyAuth
// @Summary 根据server获取所有摄像机列表及信息
// @Description 根据server获取所有摄像机列表及信息
// @Security ApiKeyAuth
// @Produce json
// @Tags camera
// @Param cameraName query string false "摄像机名称"
@@ -224,6 +230,7 @@
    }
}
// @Security ApiKeyAuth
// @Summary 获取运行类型获取摄像机列表
// @Description 获取运行类型获取摄像机列表
// @Produce json
@@ -256,6 +263,7 @@
    }
}
// @Security ApiKeyAuth
// @Summary 切换摄像机运行实时或轮询的开关
// @Description 切换摄像机运行实时或轮询的开关
// @Produce json
@@ -284,6 +292,7 @@
    }
}
// @Security ApiKeyAuth
// @Summary  更新底图
// @Description 刷新底图
// @Produce json
@@ -309,6 +318,7 @@
    RunType   int      `json:"run_type"`
}
// @Security ApiKeyAuth
// @Summary 摄像机轮询和实时状态切换
// @Description 摄像机轮询和实时状态切换
// @Produce json
@@ -333,4 +343,22 @@
    }
}
// @Security ApiKeyAuth
// @Summary 统计实时和轮询的运行路数情况
// @Description 统计实时和轮询的运行路数情况
// @Produce json
// @Tags camera
// @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}"
// @Failure 500 {string} json "{"code":500, success:false, msg:"",data:""}"
// @Router /data/api-v/camera/statisticRunInfo [get]
func (cc CameraController) StatisticRunInfo(c *gin.Context) {
    var api dbapi.CameraApi
    b, d := api.StatisticRunInfo()
    if b {
        util.ResponseFormat(c,code.Success,d)
    } else {
        util.ResponseFormat(c,code.ComError,"")
    }
}
controllers/cameraPTZ.go
New file
@@ -0,0 +1,71 @@
package controllers
import (
    "basic.com/dbapi.git"
    "basic.com/gb28181api.git"
    "webserver/extend/code"
    "webserver/extend/config"
    "webserver/extend/util"
    "github.com/gin-gonic/gin"
)
type PanTiltZoomController struct {
}
type PTZInstruct struct {
    CameraId   string `json:"cameraId"`   //摄像机id
    CameraType int    `json:"cameraType"` //摄像机类型
    PTZType    string `json:"ptzType"`    //控制类型 left right top ... stop
}
// @Summary 云台
// @Description 摄像机云台控制
// @Security ApiKeyAuth
// @Produce json
// @Tags camera
// @Param ptzBody body controllers.PTZInstruct true "控制类型:up,down,left,right,zoomin,zoomout,stop"
// @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}"
// @Failure 500 {string} json "{"code":500, success:false, msg:"",data:""}"
// @Router /data/api-v/camera/ptzControl [post]
func (ptz PanTiltZoomController) Move(c *gin.Context) {
    var param PTZInstruct
    if err := c.BindJSON(&param); err != nil {
        util.ResponseFormat(c, code.RequestParamError, "参数有误")
        return
    }
    ptzSpeed := config.Server.PTZSpeed
    if ptzSpeed == 0 {
        ptzSpeed = 50
    }
    if param.CameraType == 1 {
        var api dbapi.SysSetApi
        r, gb28182Config := api.Gb28181ConfigShow()
        if r {
            conf, ok := gb28182Config.(map[string]interface{})
            if ok {
                gb28181api.Init(conf["ServerIp"].(string), int(conf["ServerPort"].(float64)))
            } else {
                util.ResponseFormat(c, code.ComError, "国标配置读取失败")
                return
            }
        } else {
            util.ResponseFormat(c, code.ComError, "国标接口查询失败")
            return
        }
        var gbApi gb28181api.Gb28181Api
        if r := gbApi.SetCameraPtz(param.CameraId, param.PTZType, ptzSpeed); r {
            util.ResponseFormat(c, code.Success, "")
        } else {
            util.ResponseFormat(c, code.Success, "国标接口操作失败")
        }
    } else {
        util.ResponseFormat(c, code.Success, "不支持的摄像机类型")
    }
}
controllers/cameraPolygon.go
@@ -33,6 +33,7 @@
    Y float64 `json:"y"`
}
// @Security ApiKeyAuth
// @Summary 保存摄像机多边形
// @Description  保存摄像机多边形
// @Accept json
@@ -54,7 +55,7 @@
    util.ResponseFormat(c,code.ComError,"保存失败")
}
// @Security ApiKeyAuth
// @Summary 删除摄像机区域
// @Description 删除摄像机区域
// @Accept json
@@ -80,6 +81,7 @@
    util.ResponseFormat(c,code.ComError,"删除")
}
// @Security ApiKeyAuth
// @Summary 查找摄像机区域
// @Description 查找摄像机区域
// @Accept json
controllers/cameraTask.go
@@ -74,6 +74,7 @@
    Polygon CameraPolygonVo `json:"polygon"`
}
// @Security ApiKeyAuth
// @Summary 查询所有任务
// @Description "查询所有任务"
// @Accept json
@@ -95,6 +96,7 @@
    }
}
// @Security ApiKeyAuth
// @Summary 摄像机添加一个任务
// @Description 摄像机添加一个任务
// @Produce json
@@ -123,6 +125,7 @@
    }
}
// @Security ApiKeyAuth
// @Summary 查询所有任务
// @Description "查询所有任务"
// @Produce json
@@ -146,7 +149,7 @@
    }
}
// @Security ApiKeyAuth
// @Summary 摄像机保存任务
// @Description 摄像机保存任务
// @Accept json
@@ -175,6 +178,7 @@
    }
}
// @Security ApiKeyAuth
// @Summary 删除摄像机的任务
// @Description 删除摄像机的任务
// @Produce json
@@ -211,6 +215,7 @@
    AlarmLevel int `json:"alarm_level"`
}
// @Security ApiKeyAuth
// @Summary 保存任务是否下传数据
// @Description 保存任务是否下传数据
// @Accept json
@@ -237,6 +242,7 @@
    }
}
// @Security ApiKeyAuth
// @Summary 保存规则组报警等级
// @Description 保存规则组报警等级
// @Produce json
@@ -267,6 +273,7 @@
    Status int `json:"status"`
}
// @Security ApiKeyAuth
// @Summary 更新任务状态
// @Description 更新任务状态
// @Produce json
controllers/cameraTaskArgs.go
@@ -13,7 +13,7 @@
}
// @Security ApiKeyAuth
// @Summary 根据摄像机id和任务id查询算法配置详情
// @Description 根据摄像机id和任务id查询算法配置详情
// @Produce json
@@ -42,6 +42,7 @@
    }
}
// @Security ApiKeyAuth
// @Summary 根据多个摄像机id查询联动任务规则设置
// @Description 根据多个摄像机id查询联动任务规则设置
// @Accept json
@@ -67,6 +68,7 @@
    }
}
// @Security ApiKeyAuth
// @Summary 根据分组id切换布防或撤防
// @Description 根据分组id切换布防或撤防
// @Produce json
@@ -93,6 +95,7 @@
    }
}
// @Security ApiKeyAuth
// @SUmmary 根据分组id删除摄像机算法规则
// @Description 根据分组id删除摄像机算法规则
// @Produce json
@@ -144,6 +147,7 @@
    GroupId string `json:"group_id"`//分组id
}
// @Security ApiKeyAuth
// @Summary 保存联动任务规则参数
// @Description 保存联动任务规则参数
// @Accept json
controllers/cameraTimerule.go
@@ -29,7 +29,8 @@
    Start string `json:"start"`//开始
    End   string `json:"end"`//结束
}
//
// @Security ApiKeyAuth
// @Summary 时间规则保存
// @Description 时间规则保存
// @Accept json
@@ -62,6 +63,7 @@
    util.ResponseFormat(c,code.ComError,"保存失败")
}
// @Security ApiKeyAuth
// @Summary 删除时间规则
// @Description 删除时间规则
// @Accept json
@@ -85,6 +87,7 @@
    util.ResponseFormat(c, code.ComError, "删除失败")
}
// @Security ApiKeyAuth
// @Summary 查找所有时间规则
// @Description 查找所有时间规则
// @Accept json
controllers/capture.go
@@ -19,6 +19,7 @@
    TreeNodes []string `json:"treeNodes"`
}
// @Security ApiKeyAuth
// @Summary 实时抓拍
// @Description 实时抓拍数据
// @Accept  json
controllers/cluster.go
@@ -54,6 +54,7 @@
    NodeIps []string `json:"nodeIps"`
}
// @Security ApiKeyAuth
// @Summary 创建集群
// @Description 创建集群
// @Accept json
@@ -79,6 +80,7 @@
    }
}
// @Security ApiKeyAuth
// @Summary 生成集群6位随机密码
// @Description 生成集群6位随机密码
// @Produce json
@@ -91,6 +93,7 @@
    util.ResponseFormat(c,code.Success,pwd)
}
// @Security ApiKeyAuth
// @Summary 查询本地集群
// @Description 查询本地集群
// @Produce json
@@ -108,6 +111,7 @@
    }
}
// @Security ApiKeyAuth
// @Summary 搜索集群
// @Description 搜索集群
// @Accept json
@@ -133,6 +137,7 @@
    }
}
// @Security ApiKeyAuth
// @Summary 通过searchNum异步获取集群节点信息
// @Description 通过searchNum异步获取集群节点信息
// @Accept json
@@ -151,6 +156,7 @@
    }
}
// @Security ApiKeyAuth
// @Summary 通过searchNum停止搜索
// @Description 通过searchNum停止搜索
// @Produce json
@@ -168,7 +174,7 @@
    }
}
// @Security ApiKeyAuth
// @Summary 加入集群
// @Description 加入集群
// @Accept json
@@ -195,6 +201,7 @@
    }
}
// @Security ApiKeyAuth
// @Summary 保存集群名称
// @Description 保存集群名称
// @Produce json
@@ -220,6 +227,7 @@
    }
}
// @Security ApiKeyAuth
// @Summary 退出集群
// @Description 退出集群
// @Produce json
controllers/dbtableperson.go
@@ -28,6 +28,7 @@
type DbPersonController struct {
}
// @Security ApiKeyAuth
// @Summary 添加底库人员
// @Description 添加底库人员
// @Accept  json
@@ -81,6 +82,7 @@
    return result
}
// @Security ApiKeyAuth
// @Summary 修改底库人员
// @Description 修改底库人员
// @Accept  json
@@ -108,6 +110,7 @@
    }
}
// @Security ApiKeyAuth
// @Summary 底库人员以图搜图
// @Description 底库人员以图搜图
// @Accept  json
@@ -240,6 +243,7 @@
    return  resultList
}
// @Security ApiKeyAuth
// @Summary 更新底库人脸照片
// @Description 更新底库人脸照片
// @Accept  json
@@ -366,6 +370,7 @@
    return message
}
// @Security ApiKeyAuth
// @Summary 删除底库人员
// @Description 删除库人员
// @Accept  x-www-form-urlencoded
@@ -393,6 +398,7 @@
type DelMultiPerson []string
// @Security ApiKeyAuth
// @Summary 删除底库人员
// @Description 删除库人员
// @Accept  json
@@ -422,6 +428,7 @@
    }
}
// @Security ApiKeyAuth
// @Summary 查询底库人员列表
// @Description 查询库人员列表
// @Accept  json
@@ -491,6 +498,7 @@
    TableIds  []string         `json:"tableIds"`
}
// @Security ApiKeyAuth
// @Summary 抓拍人员加入底库
// @Description 抓拍人员加入底库
// @Accept  json
@@ -500,7 +508,7 @@
// @Success 200 {string} json "{"code":200, msg:"目录结构数据", success:true}"
// @Failure 500 {string} json "{"code":500,  msg:"返回错误信息", success:false}"
// @Router /data/api-v/dbperson/joinDbTable [POST]
func (sc *DbPersonController) JoinDbTable(c *gin.Context) {
func (dbc *DbPersonController) JoinDbTable(c *gin.Context) {
    var reqBody JoinDbTVo
    c.BindJSON(&reqBody)
    if reqBody.CaptureId == "" || len(reqBody.TableIds) ==0 {
@@ -539,10 +547,67 @@
}
type DbtSearch struct {
    TableId string `json:"tableId"`
    OrderName string `json:"orderName"`
    OrderType string `json:"orderType"`
    TableId string         `json:"tableId"`
    OrderName string     `json:"orderName"`
    OrderType string     `json:"orderType"`
    ContentValue string `json:"contentValue"`
    Page int `json:"page"`
    Size int `json:"size"`
    Page int             `json:"page"`
    Size int             `json:"size"`
}
type DbPersonMove struct {
    PersonId string `json:"personId"`
    TableIds []string `json:"tableIds"`
}
// @Security ApiKeyAuth
// @Summary 人员移动
// @Description 人员移动
// @Accept  json
// @Produce json
// @Tags dbperson 底库人员
// @Param obj body controllers.DbPersonMove true "移动参数"
// @Success 200 {string} json "{"code":200, msg:"", success:true}"
// @Failure 500 {string} json "{"code":500, msg:"", success:false}"
// @Router /data/api-v/dbperson/move [POST]
func (dbc *DbPersonController) Move(c *gin.Context) {
    var reqBody DbPersonMove
    c.BindJSON(&reqBody)
    if reqBody.PersonId == "" || len(reqBody.TableIds) == 0 {
        util.ResponseFormat(c,code.RequestParamError, "参数有误")
        return
    }
    var dbpApi dbapi.DbPersonApi
    b,d := dbpApi.Move(reqBody.PersonId, reqBody.TableIds)
    if b {
        util.ResponseFormat(c,code.Success,d)
    } else {
        util.ResponseFormat(c,code.ComError,"")
    }
}
// @Security ApiKeyAuth
// @Summary 人员复制
// @Description 人员复制
// @Accept  json
// @Produce json
// @Tags dbperson 底库人员
// @Param obj body controllers.DbPersonMove true "复制参数"
// @Success 200 {string} json "{"code":200, msg:"", success:true}"
// @Failure 500 {string} json "{"code":500, msg:"", success:false}"
// @Router /data/api-v/dbperson/copy [POST]
func (dbc *DbPersonController) Copy(c *gin.Context) {
    var reqBody DbPersonMove
    c.BindJSON(&reqBody)
    if reqBody.PersonId == "" || len(reqBody.TableIds) == 0 {
        util.ResponseFormat(c,code.RequestParamError, "参数有误")
        return
    }
    var dbpApi dbapi.DbPersonApi
    b,d := dbpApi.Copy(reqBody.PersonId, reqBody.TableIds)
    if b {
        util.ResponseFormat(c,code.Success,d)
    } else {
        util.ResponseFormat(c,code.ComError,"")
    }
}
controllers/dbtablesCon.go
@@ -20,6 +20,7 @@
type DbTableController struct {
}
// @Security ApiKeyAuth
// @Summary 显示底库列表
// @Description 显示同步或本地库列表
// @Accept  x-www-form-urlencoded
@@ -40,6 +41,7 @@
    }
}
// @Security ApiKeyAuth
// @Summary 查询本机所有底库列表
// @Description 查询本机所有底库列表
// @Accept  x-www-form-urlencoded
@@ -77,6 +79,7 @@
    return data
}
// @Security ApiKeyAuth
// @Summary 修改底库
// @Description 修改同步或本地库
// @Accept  json
@@ -89,29 +92,11 @@
func (dbt DbTableController) UpdateDbTables(c *gin.Context) {
    dbtable := new(models.Dbtables)
    err := c.BindJSON(&dbtable)
    if err !=nil || dbtable.Id == "" || dbtable.TableName == "" {
    if err !=nil || dbtable.Id == "" || dbtable.TableName == "" || (dbtable.Enable !=0 && dbtable.Enable !=1) {
        util.ResponseFormat(c,code.RequestParamError,"参数有误")
        return
    }
    currentTime := time.Now()
    startTime := dbtable.StartTime
    endTime := ""
    if dbtable.EndTime != "" {
        endTime = dbtable.EndTime
    }
    st, _ := time.ParseInLocation("2006-01-02 15:04:05", startTime, time.Local)
    if endTime != "" {
        et, _ := time.ParseInLocation("2006-01-02 15:04:05", endTime, time.Local)
        if et.After(currentTime) && st.Before(currentTime) {
            dbtable.Enable = 1
        } else {
            dbtable.Enable = 0
        }
    } else if st.Before(currentTime) && endTime == "" {
        dbtable.Enable = 1
    } else {
        dbtable.Enable = 0
    }
    paramBody := util.Struct2Map(dbtable)
    var tApi dbapi.DbTableApi
    b, data := tApi.UpdateDbTables(paramBody)
@@ -143,6 +128,7 @@
    Enable int `json:"enable"`
}
// @Security ApiKeyAuth
// @Summary 修改底库状态
// @Description 修改同步或本地库底库状态
// @Accept  json
@@ -230,6 +216,7 @@
    return flag
}
// @Security ApiKeyAuth
// @Summary 添加底库
// @Description 添加同步或本地库
// @Accept  json
@@ -296,6 +283,7 @@
    }
}
// @Security ApiKeyAuth
// @Summary 删除底库
// @Description 删除同步或本地库
// @Accept  x-www-form-urlencoded
controllers/dictionary.go
@@ -10,6 +10,7 @@
type DictionaryController struct {
}
// @Security ApiKeyAuth
// @Summary 根据类型查找字典
// @Description  根据类型查找字典
// @Produce json
@@ -28,6 +29,7 @@
    }
}
// @Security ApiKeyAuth
// @Summary 根据父ID查找字典
// @Description  根据父ID查找字典
// @Produce json
controllers/es.go
@@ -26,7 +26,7 @@
type EsClusterInfo struct {
    Ip string `json:"ip"`
}
// @Security ApiKeyAuth
// @Summary 比对数据查询
// @Description  比对数据查询
// @Accept  json
@@ -43,28 +43,28 @@
        util.ResponseFormat(c, code.RequestParamError, "参数有误")
        return
    }
    if searchBody.CompareNum != "" {
    if searchBody.CompareNum !="" {
        //二次搜索,不需要再比对了
        co := service.GetCompResultByNum(searchBody.CompareNum)
        if co != nil {
            //二次搜索和排序
            twiceM := GetCompareDataTwice(co, searchBody)
            util.ResponseFormat(c, code.Success, twiceM)
            twiceM := GetCompareDataTwice(co,searchBody)
            util.ResponseFormat(c,code.Success,twiceM)
            return
        } else {
            m := make(map[string]interface{}, 0)
            m :=make(map[string]interface{},0)
            m["compareNum"] = searchBody.CompareNum
            m["total"] = 0
            m["totalList"] = []CompareResult{}
            util.ResponseFormat(c, code.CompareResultGone, m)
            util.ResponseFormat(c,code.CompareResultGone,m)
            return
        }
    }
    m := make(map[string]interface{}, 0)
    m :=make(map[string]interface{},0)
    m["compareNum"] = searchBody.CompareNum
    m["total"] = 0
    m["totalList"] = []CompareResult{}
    util.ResponseFormat(c, code.CompareResultGone, m)
    util.ResponseFormat(c,code.CompareResultGone,m)
}
func searchEsData(searchBody models.EsSearch) map[string]interface{} {
@@ -114,7 +114,7 @@
    //使用es底层机制处理分页
    //请求头
    localConf, err2 := cache.GetServerInfo()
    if err2 != nil || localConf.AlarmIp == "" || localConf.ServerId == "" {
    if err2 !=nil || localConf.AlarmIp == "" || localConf.ServerId == "" {
        logger.Debug("localConfig is wrong!!!")
        return nil
    }
controllers/esSearch.go
@@ -17,6 +17,7 @@
type EsSearchController struct{}
// @Security ApiKeyAuth
// @Summary 检索
// @Description 信息检索和比对检索
// @Accept  json
controllers/eventPush.go
@@ -47,6 +47,7 @@
    Enable bool   `json:"enable"`
}
// @Security ApiKeyAuth
// @Summary 事件推送保存
// @Description 事件推送保存
// @Tags 事件推送
@@ -70,6 +71,7 @@
    }
}
// @Security ApiKeyAuth
// @Summary 根据事件推送主题的一级和二级选项获取最后下拉菜单列表
// @Description  根据事件推送主题的一级和二级选项获取最后下拉菜单列表
// @Produce json
@@ -95,6 +97,7 @@
    }
}
// @Security ApiKeyAuth
// @Summary 查全部
// @Description  查全部
// @Produce json
@@ -114,6 +117,7 @@
    }
}
// @Security ApiKeyAuth
// @Summary 事件推送编辑
// @Description  事件推送编辑
// @Produce json
@@ -142,6 +146,7 @@
    Enable bool   `json:"enable"`
}
// @Security ApiKeyAuth
// @Summary 改变enable状态
// @Description  改变enable状态
// @Produce json
@@ -166,6 +171,7 @@
    }
}
// @Security ApiKeyAuth
// @Summary 根据id删除
// @Description  根据id删除
// @Accept x-www-form-urlencoded
controllers/fileController.go
@@ -50,6 +50,7 @@
//var weedfsUri = "http://192.168.1.182:9500/submit"
// @Security ApiKeyAuth
// @Summary 依据图片添加底库人员
// @Description  依据图片添加底库返回数据人员
// @Accept  mpfd
@@ -110,6 +111,7 @@
}
var faceExtractedMap = make(map[string]FaceExtract,0)
// @Security ApiKeyAuth
// @Summary 人脸提取
// @Description  人脸提取
// @Produce json
@@ -196,6 +198,7 @@
    BaseInfo []DbPersonVo `json:"baseInfo"`
    VideoUrl string `json:"videoUrl"`
    SdkName string `json:"sdkName"`
    AlarmRules []AlarmRuleVo `json:"alarmRules"`
}
type DbPersonVo struct {
    BwType string `json:"bwType"`
@@ -215,6 +218,15 @@
type ScoreIndex struct {
    CompareScore float32
    Index int
}
type AlarmRuleVo struct {
    GroupId      string `json:"groupId"`
    AlarmLevel   string `json:"alarmLevel"`
    RuleText     string `json:"ruleText"`
    DefenceState bool `json:"defenceState"`
    IsLink          bool `json:"isLink"`
    LinkInfo      string `json:"linkInfo"`
}
//填充向前端返回的数据
@@ -286,7 +298,7 @@
        logger.Debug("comp videoPersons.len:",len(videopersons))
        for _,vp :=range videopersons {
            isAlarmInt, _ := strconv.Atoi(vp.IsAlarm)
            bi := make([]DbPersonVo,0)
            var bi []DbPersonVo
            for _,p :=range vp.BaseInfo {
                bi = append(bi, DbPersonVo{
                    PersonId: p.PersonId,
@@ -298,9 +310,22 @@
                    PhoneNum: p.PhoneNum,
                    Sex: p.Sex,
                    TableId: p.TableId,
                    BwType: strconv.Itoa(int(p.BwType)),
                    BwType: p.BwType,
                    TableName: p.TableName,
                })
            }
            var alarmRules []AlarmRuleVo
            if vp.AlarmRules !=nil && len(vp.AlarmRules) >0 {
                for _,ar :=range vp.AlarmRules {
                    alarmRules = append(alarmRules, AlarmRuleVo{
                        GroupId: ar.GroupId,
                        AlarmLevel: ar.AlarmLevel,
                        RuleText: ar.RuleText,
                        DefenceState: ar.DefenceState,
                        IsLink: ar.IsLink,
                        LinkInfo: ar.LinkInfo,
                    })
                }
            }
            vpE := CompareResult{
                Id: vp.Id,
@@ -319,6 +344,7 @@
                VideoUrl: vp.VideoUrl,
                BaseInfo: bi,
                SdkName: "人脸",
                AlarmRules: alarmRules,
            }
            resultList[captureM[vp.Id].Index] = vpE
        }
@@ -369,6 +395,7 @@
    }
}
// @Security ApiKeyAuth
// @Summary 以图搜图
// @Description  以图搜图
// @Accept json
@@ -566,7 +593,7 @@
            logger.Debug("searchPhoto first Result.len:",len(*co.CompareData),"twice len(captureIds):",len(captureIds))
            if captureIds !=nil {
                var aResult protomsg.SdkCompareResult
                aList := getTwiceSearchResult(co, &captureIds)
                aList := getTwiceSearchResult(co, &captureIds, searchBody)
                aTotal := aList.Len()
                if aTotal <= to {
                    aResult.CompareResult = (*aList)[from:aTotal]
@@ -599,7 +626,7 @@
                    personIdArr = append(personIdArr, pid.Id)
                }
                var aResult protomsg.SdkCompareResult
                aList := getTwiceSearchResult(co, &personIdArr)
                aList := getTwiceSearchResult(co, &personIdArr, searchBody)
                aTotal := aList.Len()
                if aTotal <= to {
                    aResult.CompareResult = (*aList)[from:aTotal]
@@ -639,14 +666,14 @@
    return m
}
func getTwiceSearchResult(co *service.CompareOnce, scopeIds *[]string) *service.CompareList{
func getTwiceSearchResult(co *service.CompareOnce, scopeIds *[]string, searchBody *models.EsSearch) *service.CompareList{
    m := make(map[string]string)
    for _,capId :=range *scopeIds {
        m[capId] = capId
    }
    var totalData service.CompareList
    for _,each :=range *co.CompareData {
        if _,ok :=m[each.Id];ok{
        if _,ok :=m[each.Id];ok && each.CompareScore >= searchBody.Threshold {
            totalData = append(totalData, each)
        }
    }
@@ -777,6 +804,7 @@
/**上传方法**/
// @Security ApiKeyAuth
// @Summary 批量添加底库人员
// @Description  依据图片批量添加底库人员
// @Accept  mpfd
@@ -799,8 +827,10 @@
    }
    extNames := make([]string, 0)
    addResult := make(map[string]interface{}, 0)
    successList := make([]string, 0)
    failList := make([]string,0)
    var successList []string
    var failList []string
    var noFaceList []string
    var multiFaceList []string
    tAllStart := time.Now()
    var wg sync.WaitGroup
    var lock sync.Mutex
@@ -828,7 +858,13 @@
            field, _, err1 := uploadFileReturnAddr(file, filename, tableId)
            lock.Lock()
            if err1 != nil || field == "" {
                failList = append(failList, filename)
                if err1 !=nil && err1.Error() == "NotFeatureFindError" {
                    noFaceList = append(noFaceList, filename)
                } else if err1 !=nil && err1.Error() == "TooManyFaces" {
                    multiFaceList = append(multiFaceList, filename)
                } else {
                    failList = append(failList, filename)
                }
            } else {
                successList = append(successList, filename)
            }
@@ -840,13 +876,15 @@
    logger.Debug("切",len(fileHeaders),"张人脸用时:", time.Since(tAllStart))
    addResult["successList"] = successList
    addResult["failList"] = failList
    addResult["noFaceList"] = noFaceList
    addResult["multiFaceList"] = multiFaceList
    addResult["fields"] = extNames
    //if len(successList)>0 {
    if len(successList)>0 {
        util.ResponseFormat(c, code.DbPersonUploadSuccess, addResult)
    //} else {
    //    util.ResponseFormat(c, code.DbPersonUploadFail, addResult)
    //}
    } else {
        util.ResponseFormat(c, code.DbPersonUploadFail, addResult)
    }
}
type EsPersonSave struct {
@@ -857,6 +895,7 @@
    IdCard string `json:"idCard"`
}
// @Security ApiKeyAuth
// @Summary 上传图片 并切图
// @Description  上传图片 并切图
// @Accept  mpfd
controllers/gb28181Cloud.go
New file
@@ -0,0 +1,18 @@
package controllers
import (
    "basic.com/gb28181api.git"
    "github.com/gin-gonic/gin"
)
type Gb28181CloudController struct {
}
func (gb *Gb28181CloudController) Left(c *gin.Context) {
    cameraId := c.Query("cameraId")
    var gbApi gb28181api.Gb28181Api
    gbApi.SetCameraPtz(cameraId,"",3)
}
controllers/initForData.go
@@ -16,6 +16,7 @@
type InitForData struct {
}
// @Security ApiKeyAuth
// @Summary 抓拍实时图数据初始化
// @Description 实时获取数据
// @Accept  json
@@ -66,6 +67,7 @@
    Tasks []string `json:"tasks"`
}
// @Security ApiKeyAuth
// @Summary 实时任务监控数据初始化
// @Description 实时监控比对数据
// @Accept  json
controllers/monitoring.go
@@ -14,6 +14,7 @@
    "webserver/extend/util"
)
// @Security ApiKeyAuth
// @Summary 实时监控
// @Description 实时监控比对数据
// @Accept  json
controllers/panTilt.go
File was deleted
controllers/pollConfig.go
@@ -18,6 +18,7 @@
    Enable     bool   `json:"enable"`      //是否启用轮询
}
// @Security ApiKeyAuth
// @Summary 保存轮询周期
// @Description 保存轮询周期
// @Produce json
@@ -42,6 +43,7 @@
    }
}
// @Security ApiKeyAuth
// @Summary 保存轮询延时
// @Description 保存轮询延时
// @Produce json
@@ -66,6 +68,7 @@
    }
}
// @Security ApiKeyAuth
// @Summary 获取本机轮询配置
// @Description 获取本机轮询配置
// @Produce json
@@ -87,6 +90,7 @@
    Enable bool `json:"enable"`
}
// @Security ApiKeyAuth
// @Summary 切换轮询开关
// @Description 切换轮询开关
// @Produce json
controllers/sdk.go
@@ -40,6 +40,7 @@
    Sort  int    `json:"sort"`  //参数顺序
}
// @Security ApiKeyAuth
// @Summary 算法保存
// @Description 算法保存
// @Produce json
@@ -65,6 +66,7 @@
    }
}
// @Security ApiKeyAuth
// @Summary 查找所有算法
// @Description 查找所有算法
// @Produce json
@@ -81,6 +83,7 @@
    util.ResponseFormat(c, code.Success, sdks)
}
// @Security ApiKeyAuth
// @Summary 根据id获取算法信息
// @Description 根据id获取算法信息
// @Produce json
@@ -123,6 +126,7 @@
    }
}
// @Security ApiKeyAuth
// @Summary 根据taskId获取算法信息
// @Description 根据taskId获取算法信息
// @Produce json
controllers/sysMenu.go
@@ -13,6 +13,7 @@
}
// @Security ApiKeyAuth
// @Summary 当前用户的系统菜单
// @Description 当前用户的系统菜单
// @Accept json
@@ -35,6 +36,7 @@
    }
}
// @Security ApiKeyAuth
// @Summary 查找当前用户可见的系统菜单
// @Description 查找当前用户可见的系统菜单
// @Accept json
controllers/sysRole.go
@@ -11,6 +11,7 @@
}
// @Security ApiKeyAuth
// @Summary 查找角色列表
// @Description 查找角色列表
// @Tags 系统角色
controllers/syssetcont.go
@@ -1,6 +1,7 @@
package controllers
import (
    "regexp"
    "webserver/extend/code"
    "webserver/extend/config"
    "webserver/extend/sys"
@@ -51,6 +52,7 @@
    NewTime   string `json:"newTime" example:"手动指定时间"`
}
// @Security ApiKeyAuth
// @Summary 存储信息查询
// @Description 存储信息查询
// @Accept  json
@@ -69,6 +71,7 @@
    }
}
// @Security ApiKeyAuth
// @Summary 存储信息修改
// @Description 存储信息修改
// @Accept  json
@@ -95,6 +98,7 @@
    }
}
// @Security ApiKeyAuth
// @Summary 存储信息修改
// @Description 存储信息修改
// @Accept  json
@@ -117,6 +121,7 @@
    }
}
// @Security ApiKeyAuth
// @Summary 视频截取时长修改
// @Description 视频截取时长信息
// @Accept  x-www-form-urlencoded
@@ -142,6 +147,7 @@
    }
}
// @Security ApiKeyAuth
// @Summary 获取分析设备信息
// @Description  分析设备信息
// @Accept  json
@@ -179,6 +185,7 @@
    }
}
// @Security ApiKeyAuth
// saveDevInfo  dev_id dev_name
// @Summary 保存视频分析设备信息
// @Description 分析设备信息
@@ -190,7 +197,6 @@
// @Failure 500 {string} json "{"code":500,  msg:"返回错误信息", success:false}"
// @Router /data/api-v/sysset/saveDevInfo [POST]
func (sset SysSetController) SaveDevInfo(c *gin.Context) {
    dev_name := c.PostForm("server_name")
    var api dbapi.SysSetApi
    paramBody := make(map[string]interface{}, 0)
@@ -211,6 +217,7 @@
    }
}
// @Security ApiKeyAuth
// @Summary GB28181设置查询
// @Description GB28181设置信息查询
// @Accept  json
@@ -229,6 +236,7 @@
    }
}
// @Security ApiKeyAuth
// @Summary GB28181设置信息修改
// @Description GB28181设置修改
// @Accept  json
@@ -255,6 +263,7 @@
    }
}
// @Security ApiKeyAuth
// @Summary 获取时间配置
// @Description  系统时间配置信息
// @Accept  json
@@ -271,6 +280,7 @@
    util.ResponseFormat(c, code.Success, resData)
}
// @Security ApiKeyAuth
// @Summary 测试同步时间
// @Description 测试同步时间服务器是否可用
// @Accept  json
@@ -288,19 +298,17 @@
        return
    }
    isIP, err := sys.RunNTPDate(ntpServer)
    if !isIP {
        util.ResponseFormat(c, code.RequestParamError, "指定的服务器地址错误")
    isConn := sys.RunNTPDate(ntpServer)
    if !isConn {
        util.ResponseFormat(c, code.RequestParamError, "NTP服务器不可用")
        return
    }
    if err == nil {
        util.ResponseFormat(c, code.Success, "")
    } else {
        util.ResponseFormat(c, code.TaskStoped, "")
    }
    util.ResponseFormat(c, code.Success, "")
}
// @Security ApiKeyAuth
// @Summary 设置系统时间
// @Description 校正系统时间
// @Accept  json
@@ -340,6 +348,7 @@
    util.ResponseFormat(c, code.UpdateSuccess, "配置成功")
}
// @Security ApiKeyAuth
// @Summary 查询系统运行信息
// @Description 获取当前系统的运行状态,CPU, GPU, 内存等
// @Produce json
@@ -352,6 +361,7 @@
    util.ResponseFormat(c, code.UpdateSuccess, info)
}
// @Security ApiKeyAuth
// @Summary 查询系统状态阈值设置
// @Description 获取当前系统的运行状态,CPU, GPU, 内存的阈值配置
// @Produce json
@@ -363,6 +373,7 @@
    util.ResponseFormat(c, code.UpdateSuccess, config.Server.SysThresholds)
}
// @Security ApiKeyAuth
// @Summary 重启系统
// @Description 重启操作系统
// @Produce json
@@ -378,3 +389,44 @@
    util.ResponseFormat(c, code.Success, "正在重启")
}
// @Summary 获取定时重启
// @Description 获取定时重启任务的配置规则
// @Produce json
// @Tags sysset
// @Success 200 {string} json "{"code":200, msg:"目录结构数据", success:true}"
// @Failure 500 {string} json "{"code":500,  msg:"返回错误信息", success:false}"
// @Router /data/api-v/sysset/rebootTask [GET]
func (sset SysSetController) GetRebootTask(c *gin.Context) {
    _, msg := sys.ReadRebootTaskInCrontab()
    util.ResponseFormat(c, code.Success, msg)
}
// @Summary 设置定时重启
// @Description 设置定时重启任务的配置规则
// @Produce json
// @Tags sysset
// @Success 200 {string} json "{"code":200, msg:"目录结构数据", success:true}"
// @Failure 500 {string} json "{"code":500,  msg:"返回错误信息", success:false}"
// @Router /data/api-v/sysset/rebootTask [POST]
func (sset SysSetController) SetRebootTask(c *gin.Context) {
    task := c.PostForm("task")
    if len(task) < 1 {
        sys.CleanRebootTask()
        util.ResponseFormat(c, code.Success, "配置成功")
        return
    }
    regEx := `^([0-9*]+\s){4}[0-9*]+$`
    if r, _ := regexp.MatchString(regEx, task); !r {
        util.ResponseFormat(c, code.RequestParamError, "参数错误")
        return
    }
    if r := sys.UpdateRebootTask(task); !r {
        util.ResponseFormat(c, code.UpdateFail, "配置失败")
        return
    }
    util.ResponseFormat(c, code.Success, "配置成功")
}
controllers/taglist.go
@@ -15,6 +15,7 @@
    "github.com/gin-gonic/gin"
)
// @Security ApiKeyAuth
// @Summary 标签列表
// @Description 返回底库标签
// @Accept  json
controllers/task.go
@@ -38,6 +38,7 @@
    FaceExtract_VirtualSdkId = "virtual-faceextract-sdk-pull"//结果输出的算法id
)
// @Security ApiKeyAuth
// @Summary 查找所有任务,包含任务信息和对应的算法信息
// @Description 查找所有任务
// @Produce json
@@ -69,6 +70,7 @@
    }
}
// @Security ApiKeyAuth
// @Summary 检索页面获取所有任务列表(包含已删除的任务)
// @Description 检索页面获取所有任务列表(包含已删除的任务)
// @Produce json
@@ -125,6 +127,7 @@
    }
}
// @Security ApiKeyAuth
// @Summary 添加任务
// @Description 查找所有任务
// @Accept json
@@ -161,6 +164,7 @@
    Sort int `json:"sort"`
}
// @Security ApiKeyAuth
// @Summary 给任务添加算法
// @Description 任务添加算法
// @Produce json
@@ -186,6 +190,7 @@
    }
}
// @Security ApiKeyAuth
// @Summary 任务删除算法
// @Description 根据taskid和sdkid删除
// @Produce json
@@ -211,6 +216,7 @@
    }
}
// @Security ApiKeyAuth
// @Summary 更新任务名称
// @Description 更新任务名称
// @Produce json
@@ -241,6 +247,7 @@
    Enable bool `json:"enable"`
}
// @Security ApiKeyAuth
// @Summary 更新任务状态
// @Description (算法不变,只更新任务状态)
// @Produce json
@@ -266,7 +273,7 @@
    }
}
// @Security ApiKeyAuth
// @Summary 删除任务
// @Description 根据任务id删除任务
// @Produce json
@@ -304,6 +311,7 @@
    SdkArgValue string `json:"sdk_arg_value"`
}
// @Security ApiKeyAuth
// @Summary 保存算法规则
// @Description 保存算法规则
// @Accept json
@@ -330,6 +338,7 @@
    }
}
// @Security ApiKeyAuth
// @Summary 删除算法规则
// @Description 删除算法规则
// @Produce json
@@ -354,7 +363,7 @@
    }
}
// @Security ApiKeyAuth
// @Summary 查询算法规则
// @Description 查询算法规则
// @Produce json
@@ -379,3 +388,21 @@
        util.ResponseFormat(c,code.ComError,"查询失败")
    }
}
// @Security ApiKeyAuth
// @Summary 统计每个任务的摄像机数量
// @Description 统计每个任务的摄像机数量
// @Produce json
// @Tags task
// @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}"
// @Failure 500 {string} json "{"code":500, success:false, msg:"",data:""}"
// @Router /data/api-v/task/statisticTaskCamera [get]
func (tc TaskController) StatisticTaskCamera(c *gin.Context) {
    var taskApi dbapi.TaskApi
    b,d := taskApi.StatisticTaskCamera()
    if b {
        util.ResponseFormat(c,code.Success, d)
    } else {
        util.ResponseFormat(c,code.ComError, "")
    }
}
controllers/tasklist.go
@@ -13,7 +13,7 @@
    "webserver/extend/util"
)
//任务列表
// @Security ApiKeyAuth
// @Summary 任务列表
// @Description 返回任务列表
// @Accept  json
controllers/user.go
@@ -65,6 +65,7 @@
    }
}
// @Security ApiKeyAuth
// @Summary 获取当前用户信息
// @Description 获取当前用户信息
// @Accept json
@@ -92,6 +93,7 @@
    c.JSON(http.StatusOK,"退出成功")
}
// @Security ApiKeyAuth
// @Summary 查找所有用户
// @Description 查找所有用户
// @Accept json
@@ -122,6 +124,7 @@
    MenuIds []string `json:"menuIds"`
}
// @Security ApiKeyAuth
// @Summary 编辑此用户,返回此用户的权限菜单
// @Description 编辑此用户,返回此用户的权限菜单
// @Accept json
@@ -146,6 +149,7 @@
    }
}
// @Security ApiKeyAuth
// @Summary 更新用户名,密码和菜单权限
// @Description 更新用户名,密码和菜单权限
// @Accept json
extend/config/config.go
@@ -26,8 +26,9 @@
    ChannelCount    string `mapstructure: "channelCount"`    //通道个数
    DiskCount       string `mapstructure: "diskCount"`       //硬盘个数
    SudoPassword  string      `mapstructure: "sudoPassword"`
    SudoPassword  string      `mapstructure: "sudoPassword"` //系统密码
    SysThresholds []threshold `mapstructure: "sysThresholds"`
    PTZSpeed      int         `mapstructure: "ptzSpeed"` // 云台移动速度
}
var Server = &server{}
extend/sys/system.go
@@ -119,8 +119,7 @@
func NTPConfig() (bool, string, string) {
    status, server, interval := false, "", ""
    cmd := exec.Command("/bin/sh", "-c", "crontab -l | grep ntpdate | tr -d '\n'")
    cron, _ := cmd.Output()
    cron, _ := execRootCommand("crontab -l | grep ntpdate | tr -d '\n'")
    if task := string(cron); task != "" {
        status = true
        slice := strings.Split(task, " ")
@@ -160,8 +159,6 @@
        return false
    }
    // args := []string{"-s", newTime}
    // exec.Command("date", args...).Run()
    dateCMD := fmt.Sprintf("date -s \"%s\"", newTime)
    execRootCommand(dateCMD)
    stopNTPCron()
@@ -169,7 +166,7 @@
    return true
}
const NTPCRONTABFILE = "~/.webServer.crontab"
const NTPCRONTABFILE = "/tmp/.webServer.crontab"
func EnableNTPCron(server string, interval int) bool {
    stopNTPCron()
@@ -178,24 +175,32 @@
        return false
    }
    addTask := fmt.Sprintf("echo \"*/%d * * * * /usr/sbin/ntpdate %s\" >> %s; crontab %s", interval, server, NTPCRONTABFILE, NTPCRONTABFILE)
    exec.Command("/bin/sh", "-c", addTask).Run()
    update := fmt.Sprintf("echo \"*/%d * * * * /usr/sbin/ntpdate %s\" >> %s", interval, server, NTPCRONTABFILE)
    execRootCommand(update)
    addNTPTask := fmt.Sprintf("crontab %s", NTPCRONTABFILE)
    execRootCommand(addNTPTask)
    return true
}
func stopNTPCron() {
    cleanTask := fmt.Sprintf("crontab -l | grep -v /usr/sbin/ntpdate > %s; crontab %s", NTPCRONTABFILE, NTPCRONTABFILE)
    exec.Command("/bin/sh", "-c", cleanTask).Run()
    update := fmt.Sprintf("crontab -l | grep -v /usr/sbin/ntpdate > %s", NTPCRONTABFILE)
    execRootCommand(update)
    cleanNTPTask := fmt.Sprintf("crontab %s", NTPCRONTABFILE)
    execRootCommand(cleanNTPTask)
}
func RunNTPDate(server string) (bool, error) {
func RunNTPDate(server string) bool {
    if ip := net.ParseIP(server); ip == nil {
        return false, errors.New("参数错误")
        return false
    }
    ntpdate := fmt.Sprintf("/usr/sbin/ntpdate %s", server)
    return true, exec.Command("/bin/sh", "-c", ntpdate).Run()
    _, err := execRootCommand(ntpdate)
    return err == nil
}
func Reboot() (bool, string) {
@@ -203,3 +208,29 @@
    return err == nil, string(stdout)
}
// * * * * * /bin/echo "$(date) Perform basic-reboot-task" >> /tmp/webserver.crontab.log;/sbin/reboot & >> /tmp/webserver.crontab.log
func ReadRebootTaskInCrontab() (bool, string) {
    stdout, err := execRootCommand("crontab -l | grep basic-reboot-task | sed -z -r 's/([^0-9* ]+)(.+)//g'")
    return err == nil, string(stdout)
}
func CleanRebootTask() {
    update := fmt.Sprintf("crontab -l | grep -v basic-reboot-task > %s", NTPCRONTABFILE)
    execRootCommand(update)
    crontab := fmt.Sprintf("crontab %s", NTPCRONTABFILE)
    execRootCommand(crontab)
}
func UpdateRebootTask(task string) bool {
    CleanRebootTask()
    tasks := fmt.Sprintf("%s /bin/echo \"$(date) Perform basic-reboot-task\" >> /tmp/webserver.crontab.log;/sbin/reboot & >> /tmp/webserver.crontab.log", task)
    update := fmt.Sprintf("echo '%s' >> %s", tasks, NTPCRONTABFILE)
    execRootCommand(update)
    addNTPTask := fmt.Sprintf("crontab %s", NTPCRONTABFILE)
    _, err := execRootCommand(addNTPTask)
    return err == nil
}
go.mod
@@ -3,11 +3,12 @@
go 1.12
require (
    basic.com/dbapi.git v0.0.0-20191029073251-acc3826d096d // indirect
    basic.com/dbapi.git v0.0.0-20191031093340-2802ead93fa6 // indirect
    basic.com/fileServer/WeedFSClient.git v0.0.0-20190919054037-0182b6c3f5cb // indirect
    basic.com/gb28181api.git v0.0.0-20191028082253-472438a8407b // indirect
    basic.com/pubsub/cache.git v0.0.0-20190718093725-6a413e1d7d48 // indirect
    basic.com/pubsub/esutil.git v0.0.0-20191029091908-d43f2d92ecb6 // indirect
    basic.com/pubsub/protomsg.git v0.0.0-20190829113947-eb5a5f99a745
    basic.com/pubsub/esutil.git v0.0.0-20191031110806-0712822ce390 // indirect
    basic.com/pubsub/protomsg.git v0.0.0-20191031110456-1a84b09fbcd1 // indirect
    basic.com/valib/capture.git v0.0.0-20190924061718-7e98d8c98b3c // indirect
    basic.com/valib/deliver.git v0.0.0-20190531095353-25d8c3b20051
    basic.com/valib/goffmpeg.git v0.0.0-20191024085028-080acae08ec8 // indirect
go.sum
@@ -1,13 +1,15 @@
basic.com/dbapi.git v0.0.0-20191029073251-acc3826d096d h1:DhbWFpg4/KLeYbMpaLJUlY/z5mSyCx+kPh9JY7OMd2k=
basic.com/dbapi.git v0.0.0-20191029073251-acc3826d096d/go.mod h1:eDXPnxaz6jZPDvBSk7ya7oSASWPCuUEgRTJCjsfKt/Q=
basic.com/dbapi.git v0.0.0-20191031093340-2802ead93fa6 h1:ZSRZQ031oGUT8zT9shvoX9hvFIVbLnNCpJ48SLZKVec=
basic.com/dbapi.git v0.0.0-20191031093340-2802ead93fa6/go.mod h1:eDXPnxaz6jZPDvBSk7ya7oSASWPCuUEgRTJCjsfKt/Q=
basic.com/fileServer/WeedFSClient.git v0.0.0-20190919054037-0182b6c3f5cb h1:fM6DojeInFSCFO+wkba1jtyPiSDqw0jYKi4Tk+e+ka4=
basic.com/fileServer/WeedFSClient.git v0.0.0-20190919054037-0182b6c3f5cb/go.mod h1:FTryK8BsVLfUplx8a3+l8hJWub6VbAWZCUH7sPRZaso=
basic.com/gb28181api.git v0.0.0-20191028082253-472438a8407b h1:Qh7x2PY3HA9B404Llq+olY5/YlGYrM58bpOHa2CGcro=
basic.com/gb28181api.git v0.0.0-20191028082253-472438a8407b/go.mod h1:iKnzuRRqUEgt17894pX3oYcOG2fLYFVcXiZbPoMK7+4=
basic.com/pubsub/cache.git v0.0.0-20190718093725-6a413e1d7d48 h1:BBA30Rgljn6MRieC4gUncETJDyna3ObyubTo9HEQ2M0=
basic.com/pubsub/cache.git v0.0.0-20190718093725-6a413e1d7d48/go.mod h1:gHLJZz2ee1cGL0X0ae69fs56bAxkDgEQwDhhXZJNUcY=
basic.com/pubsub/esutil.git v0.0.0-20191029091908-d43f2d92ecb6 h1:HNdnjoaOpLJvyNzUPD2Yx9tLsS7unR19O+0ZYviW2II=
basic.com/pubsub/esutil.git v0.0.0-20191029091908-d43f2d92ecb6/go.mod h1:yIvppFPFGC61DOdm71ujnsxZBMFUu2yKjr5O43bMWCw=
basic.com/pubsub/protomsg.git v0.0.0-20190829113947-eb5a5f99a745 h1:NQ/172pylwH5BnVwt4vlrXVN+UDn8YJc+5V2ZPaC4P0=
basic.com/pubsub/protomsg.git v0.0.0-20190829113947-eb5a5f99a745/go.mod h1:un5NV5VWQoblVLZfx1Rt5vyLgwR0jI92d3VJhfrJhWU=
basic.com/pubsub/esutil.git v0.0.0-20191031110806-0712822ce390 h1:uM/D7VJ41pg1XXpoe73QqCCnQTE08VhXQ2JAAOnN6ao=
basic.com/pubsub/esutil.git v0.0.0-20191031110806-0712822ce390/go.mod h1:yIvppFPFGC61DOdm71ujnsxZBMFUu2yKjr5O43bMWCw=
basic.com/pubsub/protomsg.git v0.0.0-20191031110456-1a84b09fbcd1 h1:w/hlV2znPkwQxusqH8IIeg8+O3DPkCbRhsVKi6GdckU=
basic.com/pubsub/protomsg.git v0.0.0-20191031110456-1a84b09fbcd1/go.mod h1:un5NV5VWQoblVLZfx1Rt5vyLgwR0jI92d3VJhfrJhWU=
basic.com/valib/capture.git v0.0.0-20190924061718-7e98d8c98b3c h1:aNujtcGxq0cNLSK08cCamAiUYiQ2/ZsUMNXbX2w8Clc=
basic.com/valib/capture.git v0.0.0-20190924061718-7e98d8c98b3c/go.mod h1:y+h7VUnoSQ3jOtf2K3twXNA8fYDfyUsifSswcyKLgNw=
basic.com/valib/deliver.git v0.0.0-20190531095353-25d8c3b20051/go.mod h1:bkYiTUGzckyNOjAgn9rB/DOjFzwoSHJlruuWQ6hu6IY=
middlewares/auth/auth.go
@@ -1,7 +1,6 @@
package auth
import (
    "fmt"
    "github.com/gin-gonic/gin"
    "net/http"
    "strings"
@@ -64,7 +63,6 @@
                c.Abort()
            }
            user := (*jwtDriver).User(c)
            fmt.Println("AuthHandler user:",user)
            if user == nil {
                util.ResponseFormat(c,code.TokenNotFound,"尚未登录,请登录")
                c.Abort()
router/router.go
@@ -43,7 +43,7 @@
    sysMenuController := new(controllers.SysMenuController)
    clusterController := new(controllers.ClusterController)
    sysRoleController := new(controllers.RoleController)
    ptController := new(controllers.PanTiltController)
    ptzController := new(controllers.PanTiltZoomController)
    sysApi := r.Group("/data/api-u/sys")
    {
@@ -102,7 +102,8 @@
        camera.POST("/changeRunType", cameraController.ChangeRunType)
        camera.GET("/getAllCamerasByServer", cameraController.GetAllCamerasByServer)
        camera.POST("/ptControl", ptController.Controlling)
        camera.POST("/ptzControl", ptzController.Move)
        camera.GET("/statisticRunInfo", cameraController.StatisticRunInfo)
    }
    cameraTaskArgsApi := r.Group(urlPrefix + "/cameraTaskArgs")
@@ -144,6 +145,8 @@
        task.GET("/getRulesByTaskSdk", taskController.GetRulesByTaskSdk)
        task.POST("/deleteTaskSdkRule", taskController.DeleteTaskSdkRule)
        task.POST("/saveTaskSdkRule", taskController.SaveTaskSdkRule)
        task.GET("/statisticTaskCamera", taskController.StatisticTaskCamera)
    }
    // 检索 查询 节点操作
@@ -193,6 +196,8 @@
        vdbperson.POST("/updateFace", dbPersonCont.UpdateFace)
        vdbperson.POST("/joinDbTable", dbPersonCont.JoinDbTable)
        vdbperson.POST("/move", dbPersonCont.Move)
        vdbperson.POST("/copy", dbPersonCont.Copy)
    }
    // 系统设置 操作
@@ -213,6 +218,8 @@
        vsset.GET("/sysThresholds", ssController.GetSysThresholds)
        vsset.GET("/reboot", ssController.RebootOS)
        vsset.GET("/rebootTask", ssController.GetRebootTask)
        vsset.POST("/rebootTask", ssController.SetRebootTask)
    }
    //算法库操作