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 {
|
TotalPlace int `json:"totalPlace"`
|
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
|
}
|