From b42533a6833b3b366f3f5c08bbc27f9f3ccbaeed Mon Sep 17 00:00:00 2001 From: liuxiaolong <liuxiaolong@aiotlink.com> Date: 星期二, 18 八月 2020 16:12:03 +0800 Subject: [PATCH] fix push plateNo compare and add isTest push --- service/msgPush.go | 37 ++++++++++++++++++++++++++++++++----- 1 files changed, 32 insertions(+), 5 deletions(-) diff --git a/service/msgPush.go b/service/msgPush.go index 6e52527..05ebef6 100644 --- a/service/msgPush.go +++ b/service/msgPush.go @@ -7,6 +7,7 @@ "errors" "fmt" "github.com/astaxie/beego" + "strings" "sync" "time" ) @@ -246,7 +247,7 @@ } //瀵瑰凡娉ㄥ唽鐨勭敤鎴疯繘琛屾秷鎭帹閫併�傝皟鐢ㄦ鎺ュ彛鍓嶉渶璋冪敤鍒涘缓娑堟伅鎺ュ彛璁剧疆娑堟伅鍐呭 -func PushByAlias(title string, msg string) (bool, error, []string) { +func PushByAlias(title string, msg string, isTest bool) (bool, error, []string) { var aliasArr []string pushUserM := make(map[string]string) @@ -265,16 +266,22 @@ carPersons := csv.GetVehicleListByPerson("") if carPersons != nil { for _, cp := range carPersons { - carPersonM[cp.PlateNo] = cp.PersonId + ncPlateNo := preDealPlateNo(cp.PlateNo) //鍘绘帀姹夊瓧锛孌鍜�0鏇挎崲鎴�* + if ncPlateNo != "" { + carPersonM[ncPlateNo] = cp.PersonId + } } } delPersonIdM := make(map[string]string) spaceNos := csv.FindSpaceNo("") for _,sn := range spaceNos { if sn.State == 1 && sn.PlateNo != "" { //宸茬粡鎶婅溅鍋滃埌鍋滆溅鍦虹殑杞︿富锛屼笉鍐嶆帹閫佹秷鎭� - if pId,ok := carPersonM[sn.PlateNo];ok { - delPersonIdM[pId] = pId - delete(carPersonM, sn.PlateNo) + realPlateNo := preDealPlateNo(sn.PlateNo) + if realPlateNo != "" { + if pId,ok := carPersonM[realPlateNo];ok { + delPersonIdM[pId] = pId + delete(carPersonM, realPlateNo) + } } } } @@ -291,6 +298,14 @@ lenAS := len(aliasArr) if lenAS == 0 { return false, errors.New("aliasArr is empty"),aliasArr + } + if isTest { + //鍙粰鍐呴儴鎵嬫満鍙锋帹 + testPhones := beego.AppConfig.String("testPushPhones") + if testPhones == "" { + return false, errors.New("test push aliasArr is empty"),aliasArr + } + aliasArr = strings.Split(testPhones, ",") } cResult, taskId, ce := createPushMsg(title, msg) @@ -336,6 +351,18 @@ return false, errors.New("鎺ㄩ�佸け璐�"),aliasArr } +//棰勫鐞嗚溅鐗屽彿锛屽幓闄ら涓眽瀛楋紝浠ュ強蹇界暐D鍜�0 +func preDealPlateNo(pn string) string { + if pn != "" { + r := []rune(pn) + ncStr := string(r[1:]) + newPlateNo := strings.ReplaceAll(ncStr, "D", "*") + newPlateNo = strings.ReplaceAll(newPlateNo, "0", "*") + return newPlateNo + } + return "" +} + func doPush(taskId string, aliasArr []string) (bool,error) { appId := beego.AppConfig.String("pushAppId") baseUrl := beego.AppConfig.String("pushBaseUrl") + appId -- Gitblit v1.8.0