Browse Source

lua 类型转换

zhangjinkun 6 years ago
parent
commit
ebdbed806a
3 changed files with 7 additions and 4 deletions
  1. 5 1
      src/jy/util/script.go
  2. 2 3
      udps/main.go
  3. BIN
      udps/udps

+ 5 - 1
src/jy/util/script.go

@@ -172,8 +172,12 @@ func LuaTableToMap(param *lua.LTable) map[string]interface{} {
 			} else {
 				tmp[kk] = false
 			}
+		} else if kk == "comeintime" || kk == "publishtime" {
+			tmp[kk] = qu.Int64All(val.String())
+		} else if v, ok := val.(*lua.LNumber); ok {
+			tmp[kk] = qu.Float64All(v.String())
 		} else {
-			tmp[kk] = v
+			tmp[kk] = val
 		}
 	})
 	return tmp

+ 2 - 3
udps/main.go

@@ -24,16 +24,15 @@ func main() {
 	//2018-06-01,2019-02-20
 	flag.StringVar(&startDate, "start", "", "开始日期2006-01-02")
 	flag.StringVar(&endDate, "end", "", "结束日期2006-01-02")
-	flag.StringVar(&ip, "ip", "127.0.0.1", "dup端口")
+	flag.StringVar(&ip, "ip", "127.0.0.1", "ip")
 	flag.StringVar(&port, "port", "", "dup端口")
 	flag.StringVar(&stype, "stype", "", "stype")
 	flag.Parse()
-	log.Println(startDate, endDate, ip, port)
+	log.Println(startDate, endDate, ip, port, stype)
 	start, _ := time.ParseInLocation(qu.Date_Short_Layout, startDate, time.Local)
 	end, _ := time.ParseInLocation(qu.Date_Short_Layout, endDate, time.Local)
 	sid := bson.NewObjectIdWithTime(start)
 	eid := bson.NewObjectIdWithTime(end)
-	log.Println(sid, eid)
 	udpclient = mu.UdpClient{Local: ":1470", BufSize: 1024}
 	udpclient.Listen(processUdpMsg)
 	by, _ := json.Marshal(map[string]interface{}{

BIN
udps/udps