liuxiaolong
2020-08-05 6ecda400e04a118326cabe768f8808e9b5514af6
service/carService.go
@@ -7,6 +7,7 @@
   "encoding/json"
   "fmt"
   "github.com/astaxie/beego"
   "strconv"
)
type CarService struct {
   hikUtil *reqUtil.HikHttpUtil
@@ -150,9 +151,17 @@
   SpaceType             string       `json:"spaceType"`
}
func (sv *CarService) FindSpaceNo() models.PosResult {
func (sv *CarService) FindSpaceNo(userId string) models.PosResult {
   resultList := make(models.PosResult,0)
   var myPlateNosMap = make(map[string]string)
   vehicles := sv.GetVehicleListByPerson(userId)
   if vehicles != nil {
      for _,veh := range vehicles {
         myPlateNosMap[veh.PlateNo] = veh.PlateNo
         //myPlateNos = append(myPlateNos, veh.PlateNo)
      }
   }
   //bindCars := strings.Join(myPlateNos, ",")
   //先查车库唯一标识
   //parkList := sv.getHikParkList() //先查有几个停车场
   //if parkList != nil {
@@ -161,6 +170,7 @@
         reqBody := map[string]interface{} {
            //"parkSyscode": p.ParkIndexCode,//停车库唯一标识
            //"state": 1, //车位状态,0:空闲,1:停车
            //"bindCars": bindCars,
            "pageNo": 1,
            "pageSize": 1000,
         }
@@ -179,11 +189,16 @@
               return nil
            }
            for _,s := range spaceList {
               isMine := false
               if _,exist := myPlateNosMap[s.PlateNos]; exist {
                  isMine = true
               }
               pi := models.PosInfo {
                  SpaceNo: s.SpaceNo,
                  PosNo: "",
                  State: s.State,
                  PlateNo: s.PlateNos,
                  IsMine: isMine,
               }
               if v,ok := models.SpaceNo2Pos[s.SpaceNo];ok {
                  pi.PosNo = v
@@ -193,6 +208,18 @@
         }
      //}
   //}
   if len(resultList) == 0 {
      for i:=1;i<91;i++ {
         pi := models.PosInfo {
            SpaceNo: strconv.Itoa(i),
            PosNo: "",
            State: 1,
            PlateNo: "",
            IsMine: false,
         }
         resultList = append(resultList, pi)
      }
   }
   return resultList
}