liuxiaolong
2020-07-29 dd407acf2304fdf68d7a01da9f56660347a32e85
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
44
45
46
47
48
49
50
51
52
package models
 
import (
    "strconv"
    "sync"
)
 
var (
    SpaceNo2Pos map[string]string  //海康车位号-页面配置编号
    Pos2SpaceNo map[string]string  //页面配置编号-海康车位号
)
 
func init() {
    SpaceNo2Pos = make(map[string]string)
    Pos2SpaceNo = make(map[string]string)
}
 
var lock sync.RWMutex
func SetSpaceNo(totalPermSpace int) {
    lock.Lock()
    defer lock.Unlock()
    for i:=0;i<totalPermSpace;i++{
        SpaceNo2Pos[strconv.Itoa(i+1)] = strconv.Itoa(i+1)
    }
}
 
type CarStatistic struct {
    TotalPermPlace         int         `json:"totalPermPlace"`
    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"`
    IsMine             bool         `json:"isMine"`
}
 
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
}