| | |
| | | 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() |
| | | } |
| | | } |
| | | |
| | |
| | | dbPath := rootPath +"/"+ dbUrl |
| | | orm.RegisterDriver("sqlite", orm.DRSqlite) |
| | | _ = orm.RegisterDataBase("default", "sqlite3", dbPath) |
| | | orm.RegisterModel(new(User), new(UserCar), new(SysUpgrade), new(UserClient)) |
| | | orm.RegisterModel(new(User), new(UserCar), new(SysUpgrade), new(UserClient), new(Restriction)) |
| | | _ = orm.RunSyncdb("default", false, true) |
| | | } |
| | |
| | | package models |
| | | |
| | | import ( |
| | | "github.com/astaxie/beego/orm" |
| | | ) |
| | | |
| | | type Restriction struct { |
| | | Date string `orm:"pk;size(50);column(date)" json:"date"` |
| | | Week string `orm:"size(50);column(week)" json:"week"` |
| | | CityName string `orm:"size(50);column(cityName)" json:"cityName"` |
| | | IsXianXing int `orm:"size(8);column(isXianXing)" json:"isXianXing"` |
| | | WeiHao string `orm:"size(50);column(weiHao)" json:"weiHao"` |
| | | } |
| | | |
| | | func (r *Restriction) TableName() string { |
| | | return "sys_restriction" |
| | | } |
| | | |
| | | func (r *Restriction) Insert() (int64,error) { |
| | | o := orm.NewOrm() |
| | | return o.Insert(r) |
| | | } |
| | | |
| | | func (r *Restriction) SelectByDate(date string) error { |
| | | o := orm.NewOrm() |
| | | err := o.QueryTable(r.TableName()).Filter("date", date).One(r) |
| | | return err |
| | | } |
| | |
| | | } |
| | | } else { //用户已存在 |
| | | if phoneNum != tmpUser.PhoneNum { |
| | | tmpUser.UpdatePhoneNum(tmpUser.PhoneNum, hikPersonId) |
| | | tmpUser.UpdatePhoneNum(phoneNum, hikPersonId) |
| | | } |
| | | var plateNos = make([]string, 0) |
| | | hikVehicles := carSv.GetVehicleListByPerson(hikPersonId) |