liuxiaolong
2020-08-06 dbc843d0b37f786fb816131bcc7ebca86dbe72e9
models/car.go
@@ -1,6 +1,9 @@
package models
import "strconv"
import (
   "strconv"
   "sync"
)
var (
   SpaceNo2Pos map[string]string  //海康车位号-页面配置编号
@@ -10,15 +13,20 @@
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)
}
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 {
   Left     int       `json:"left"`
   TotalPermPlace       int       `json:"totalPermPlace"`
   Left                 int       `json:"left"`
}
type PosInfo struct {
@@ -26,6 +34,7 @@
   PosNo          string       `json:"posNo"`
   State          int       `json:"state"`  //0:空闲,1:有车
   PlateNo       string       `json:"plateNo"`
   IsMine          bool       `json:"isMine"`
}
type PosResult []PosInfo