liuxiaolong
2020-06-29 df6d61cdad1b72e1b94e87902b39a09f36b8e044
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package models
 
import "strconv"
 
var (
    SpaceNo2Pos map[string]string  //海康车位号-页面配置编号
    Pos2SpaceNo map[string]string  //页面配置编号-海康车位号
)
 
func init() {
    SpaceNo2Pos = make(map[string]string)
    Pos2SpaceNo = make(map[string]string)
    for i:=1;i<100;i++ {
        posNo := "A"+strconv.Itoa(i)
        SpaceNo2Pos[strconv.Itoa(i)] = posNo
        Pos2SpaceNo[posNo] = strconv.Itoa(i)
    }
}
 
type CarStatistic struct {
    Left     int         `json:"left"`
}
 
type PosInfo struct {
    SpaceNo         string         `json:"spaceNo"`
    PosNo             string         `json:"posNo"`
    State             int         `json:"state"`  //0:空闲,1:有车
    PlateNo         string         `json:"plateNo"`
}
 
type PosResult []PosInfo
 
func (al PosResult) Len()int {
    return len(al)
}
func (al PosResult) Swap(i,j int) {
    al[i],al[j] = al[j],al[i]
}
func (al PosResult) Less(i,j int) bool {
    s1, _ := strconv.Atoi(al[i].SpaceNo)
    s2, _ := strconv.Atoi(al[j].SpaceNo)
    return s1 < s2
}