| | |
| | | import ( |
| | | "car-service/extend/code" |
| | | "car-service/extend/util" |
| | | "car-service/models" |
| | | "encoding/json" |
| | | "fmt" |
| | | "github.com/astaxie/beego" |
| | | "net/http" |
| | | "github.com/robfig/cron" |
| | | "strconv" |
| | | "strings" |
| | | "time" |
| | | ) |
| | | |
| | | type RestrictionController struct { |
| | |
| | | } |
| | | |
| | | func init() { |
| | | getRestrictionInfo() |
| | | date := time.Now().Format("2006-01-02") |
| | | var r models.Restriction |
| | | err := r.SelectByDate(date) |
| | | if err == nil { |
| | | //今日已获取过限行信息 |
| | | todayRes = &RestrictionResult{ |
| | | Date: date, |
| | | Week: r.Week, |
| | | CityName: r.CityName, |
| | | IsXianXing: r.IsXianXing, |
| | | } |
| | | arr := strings.Split(r.WeiHao, ",") |
| | | if len(arr) >0 { |
| | | for _,s := range arr { |
| | | n, e := strconv.Atoi(s) |
| | | if e ==nil { |
| | | todayRes.XxWeiHao = append(todayRes.XxWeiHao,n) |
| | | } |
| | | } |
| | | } |
| | | } else { |
| | | getRestrictionInfo() |
| | | } |
| | | } |
| | | |
| | | // @Title 查询限行尾号 |
| | |
| | | IsXianXing: result.Result.IsXianXing, |
| | | XxWeiHao: result.Result.XXWeiHao, |
| | | } |
| | | rc := models.Restriction{ |
| | | Date: result.Result.Date, |
| | | Week: result.Result.Week, |
| | | CityName: result.Result.CityName, |
| | | IsXianXing: result.Result.IsXianXing, |
| | | } |
| | | var arr []string |
| | | for _,n := range result.Result.XXWeiHao { |
| | | arr=append(arr, strconv.Itoa(n)) |
| | | } |
| | | rc.WeiHao = strings.Join(arr, ",") |
| | | rc.Insert() |
| | | } |
| | | } |
| | | |