From 1b20184df8a27d0c36b616bf2dd6e88c796e031e Mon Sep 17 00:00:00 2001
From: liuxiaolong <liuxiaolong@aiotlink.com>
Date: 星期二, 18 八月 2020 11:24:58 +0800
Subject: [PATCH] plateNo compare,ignore chinese word and ignore D,0
---
service/carService.go | 42 ++++++++++++++++++++++++++++++++++--------
1 files changed, 34 insertions(+), 8 deletions(-)
diff --git a/service/carService.go b/service/carService.go
index 3e8e228..b3b1c25 100644
--- a/service/carService.go
+++ b/service/carService.go
@@ -8,6 +8,7 @@
"fmt"
"github.com/astaxie/beego"
"strconv"
+ "strings"
)
type CarService struct {
hikUtil *reqUtil.HikHttpUtil
@@ -181,8 +182,11 @@
vehicles := sv.GetVehicleListByPerson(userId)
if vehicles != nil {
for _,veh := range vehicles {
- myPlateNosMap[veh.PlateNo] = veh.PlateNo
- //myPlateNos = append(myPlateNos, veh.PlateNo)
+ if veh.PlateNo != "" {
+ ncStr := veh.PlateNo[1:] //鎶婄涓�浣嶆眽瀛楀墧闄ゆ帀
+ myPlateNosMap[ncStr] = ncStr
+ }
+ //myPlateNosMap[veh.PlateNo] = veh.PlateNo
}
}
}
@@ -211,7 +215,6 @@
return nil
}
for _,s := range spaceList {
-
pi := models.PosInfo {
SpaceNo: s.SpaceNo,
PosNo: "",
@@ -222,11 +225,7 @@
} else if s.PlateNos != "" {
pi.PlateNo = s.PlateNos
}
- isMine := false
- if _,exist := myPlateNosMap[pi.PlateNo]; exist {
- isMine = true
- }
- pi.IsMine = isMine
+ pi.IsMine = isMyPlateNo(myPlateNosMap, pi.PlateNo)
if v,ok := models.SpaceNo2Pos[s.SpaceNo];ok {
pi.PosNo = v
}
@@ -249,6 +248,33 @@
return resultList
}
+//鍒ゆ柇鏄笉鏄嚜宸辩殑杞︾墝鍙�
+//1.鐩墠鏈夎璇嗗埆鐨勯棶棰橈紝浼氭妸D璇嗗埆鎴�0,D鍜�0涓嶅垎
+//2.姹夊瓧璇瘑鍒殑鍑犵巼姣旇緝楂�
+func isMyPlateNo(plateNoM map[string]string, targetPlateNo string) bool {
+ if targetPlateNo != "" {
+ nctPlateNo := targetPlateNo[1:]
+ if _,exist := plateNoM[nctPlateNo];exist {
+ return true
+ } else {
+ match := false
+ for k,_ := range plateNoM {
+ newK := strings.ReplaceAll(k, "D", "*")
+ newK = strings.ReplaceAll(newK, "0", "*")
+
+ tt := strings.ReplaceAll(targetPlateNo,"D", "*")
+ tt = strings.ReplaceAll(tt,"0", "*")
+ if newK == tt {
+ match = true
+ break
+ }
+ }
+ return match
+ }
+ }
+ return false
+}
+
func (sv *CarService) BindCarSpace() bool {
url := "/artemis/api/pms/v1/parking_space/car_bind/add"
reqBody := map[string]interface{} {
--
Gitblit v1.8.0