---
panlei
2019-07-02 9ba527ba346abeae5ceec3df1f50191ac15e5c26
ruleserver/ruleToformula.go
@@ -181,7 +181,7 @@
// 把sdk从数据帧上提取的按照区域分类归置
func SdkDataFormat(cameraId string, arg *SdkData, cameraPolygons []protomsg.CameraPolygon) {
   for _, polygon := range cameraPolygons {
      //log.Println("++++++在这儿看一下区域啊", polygon)
      //log.Println("++++++在这儿看一下区域啊:", polygon.Polygon)
      areaMap := AreaMap{cameraId: cameraId, areaId: polygon.Id, areaJson: polygon.Polygon, triggerLine: polygon.TriggerLine, directionLine: polygon.DirectionLine}
      // 为每个摄像机区域填充数据
      areaMap.CountAreaObjs(arg)
@@ -209,6 +209,7 @@
         for _, taskRule := range taskRuleList {
            ruleList := taskRule.GroupRules // 获取的是task下面的任务组
            taskId := taskRule.TaskId
            //log.Println("------------本组任务下的规则组的数量:",len(ruleList))
            for i := 0; i < len(ruleList); i++ {
               temp := ruleList[i].Rules // temp为一组完整规则 在此需要判断规则是否是联动规则
               if len(temp) > 0 {
@@ -232,6 +233,7 @@
      }
   }()
   log.Println("+++++++++++规则开始运行+++++++++++++++++当前规则--:",*groupRule)
   resultSplice := []*LittleRuleResult{}
   // 先过完条件规则
   for j := 0; j < len(groupRule.Rules); j++ {
@@ -373,7 +375,7 @@
   // }
   for _, obj := range arg.Photo {
      log.Println("------------------看看sdkData的Photo数据----------------", obj, "----顺便看看占比-----:", PgsInterPercent(areaPoints, obj.Rects, widthScale, heigthScale))
      log.Println("------------------看看sdkData:",arg.SdkName,"的Photo数据----------------", obj, "----顺便看看占比-----:", PgsInterPercent(areaPoints, obj.Rects, widthScale, heigthScale))
      if threshold <= obj.Score && size <= float64(obj.Rects.Width*obj.Rects.Height) && intersectionper <= PgsInterPercent(areaPoints, obj.Rects, widthScale, heigthScale) {
         // 这步要备齐表达式里所需要的所有参数
         a.targetNum++
@@ -388,6 +390,7 @@
   a.time = time.Unix(time.Now().Unix(), 0).String()[11:16]
   a.keepRight = arg.KeepRight
   a.isStatic = arg.IsStatic
   log.Println("--------------------看看区域数据:",*a)
}
// 将字符串格式的坐标序列化为Point格式
@@ -718,7 +721,7 @@
   return LittleRuleResult{}
}
func timeRuleResult(rule *protomsg.Rule, am *AreaMap) LittleRuleResult {
   if rule.PolygonId == am.areaId { // 首先规则所对应的区域id要跟区域数据的id对的上
   if rule.PolygonId == am.areaId && rule.SdkId == am.sdkId{ // 首先规则所对应的区域id要跟区域数据的id对的上
      if rule.SdkArgAlias == "time_rule" { // 判断是否符合时间规则
         log.Println("----------当前时间规则:---------",rule)
         // 根据放值字段里存的时间规则的id去另一个表里查需要比对的时间段(比如当前时间是周三,应根据区域id查出其周三的几个布防时间段,数组)
@@ -726,7 +729,7 @@
         now := time.Now()
         index := getIndexOfWeek(now.Weekday().String())
         timeList := GetTimeById(rule.SdkArgValue, index)
         log.Println("当天的时间规则:----------",timeList)
         log.Println("当天的时间段集合:----------",timeList)
         //fmt.Println("从数据库中查出的时间规则:", timeList)
         // 判断图片数据的时间是否符合当前规则 在一个即为true,全不在为false
         flag := "false"