engineerper 1 tahun lalu
induk
melakukan
b1f5a4427b
4 mengubah file dengan 72 tambahan dan 1 penghapusan
  1. 18 0
      config.yaml
  2. 12 0
      config/config.go
  3. 40 1
      eventServer/capacity.go
  4. 2 0
      eventServer/eventServer.go

+ 18 - 0
config.yaml

@@ -65,3 +65,21 @@ camera1:
 #摄像头2 测量宽度
 camera2:
   a: [500, 450, 400, 350, 300, 250, 200, 150, 100, 50]
+#泥头车的长宽高和体积
+dump:
+  #20尺柜,毛重17.5吨
+  a: [5.69,2.13,2.18,26]
+  #40尺柜,毛重22吨
+  b: [11.8,2.13,2.18,54]
+  #40尺高柜,毛重22吨
+  c: [11.8,2.13,2.72,68]
+  #45尺高柜,毛重29吨
+  d: [13.58,2.34,2.71,86]
+  #20尺开顶柜,毛重20吨
+  e: [5.89,2.32,2.31,31.5]
+  #40尺开顶柜,毛重30.4吨
+  f: [12.01,2.33,2.15,65]
+  #20尺平底柜,毛重23吨
+  g: [5.85,2.23,2.15,28]
+  #40尺平底柜,毛重36吨
+  h: [12.05,2.12,1.96,50]

+ 12 - 0
config/config.go

@@ -37,6 +37,7 @@ type config struct {
 	Foreign                  Foreign                  `mapstructure:"foreign" yaml:"foreign" json:"foreign"`
 	Hikvision                Hikvision                `mapstructure:"hikvision" yaml:"hikvision" json:"hikvision"`
 	Metering                 Metering                 `mapstructure:"metering" yaml:"metering" json:"metering"`
+	Dump                     Dump                     `mapstructure:"dump" yaml:"dump" json:"dump"`
 }
 
 type System struct {
@@ -149,3 +150,14 @@ type Metering struct {
 		A []int `yaml:"a"`
 	} `yaml:"camera2"`
 }
+
+type Dump struct {
+	A []float64 `yaml:"a"`
+	B []float64 `yaml:"b"`
+	C []float64 `yaml:"c"`
+	D []float64 `yaml:"d"`
+	E []float64 `yaml:"e"`
+	F []float64 `yaml:"f"`
+	G []float64 `yaml:"g"`
+	H []float64 `yaml:"h"`
+}

+ 40 - 1
eventServer/capacity.go

@@ -1,6 +1,9 @@
 package eventServer
 
-import "sync"
+import (
+	"math"
+	"sync"
+)
 
 var LhChan = make(chan [2]float64, 20) //传长,高
 var WChan = make(chan float64, 20)     //传宽
@@ -21,3 +24,39 @@ func CalcCap() (l, w, h float64) {
 	wg.Wait()
 	return
 }
+
+type Constant struct {
+	Length float64
+	Width  float64
+	Height float64
+	Volume float64
+}
+
+func (c Constant) Calc() float64 {
+	return c.Length * c.Width * c.Height
+}
+
+func FindBestMatch(constants []Constant, variable Constant) Constant {
+	bestMatch := constants[0]
+	bestMatchScore := CalculateMatchScore(bestMatch, variable)
+	for i := 1; i < len(constants); i++ {
+		score := CalculateMatchScore(constants[i], variable)
+		if score < bestMatchScore ||
+			(score == bestMatchScore && constants[i].Length > bestMatch.Length) ||
+			(score == bestMatchScore && constants[i].Length == bestMatch.Length && constants[i].Height > bestMatch.Height) ||
+			(score == bestMatchScore && constants[i].Length == bestMatch.Length && constants[i].Height == bestMatch.Height && constants[i].Width > bestMatch.Width) {
+			bestMatch = constants[i]
+			bestMatchScore = score
+		}
+	}
+
+	return bestMatch
+}
+
+func CalculateMatchScore(constant, variable Constant) float64 {
+	//lengthScore := math.Abs(float64(constant.Length - variable.Length))
+	//widthScore := math.Abs(float64(constant.Width - variable.Width))
+	//heightScore := math.Abs(float64(constant.Height - variable.Height))
+
+	return math.Abs(variable.Calc() - constant.Calc())
+}

+ 2 - 0
eventServer/eventServer.go

@@ -86,6 +86,7 @@ func round(num float64, places int) float64 {
 	return math.Round(num*shift) / shift
 }
 
+// 保存摄像机获取到的长度,高度,宽度以及时间
 var bulk = make(map[string][]float64)
 
 // 处理多文件事件
@@ -174,6 +175,7 @@ func handleMultipart(r *http.Request) {
 			//carInfoService.ProcessPlateNumber(number)
 			return
 		}
+
 		f := &mail.File{
 			Name:     picName,
 			MimeType: contentType,