forked from golang/hotime
213 lines
5.8 KiB
Go
213 lines
5.8 KiB
Go
package app
|
|
|
|
import (
|
|
. "../../../hotime"
|
|
. "../../common"
|
|
"time"
|
|
)
|
|
|
|
var analyseCtr = Ctr{
|
|
|
|
"home_data": func(this *Context) {
|
|
orgId := ObjToInt(this.Req.FormValue("org_id"))
|
|
if orgId == 0 {
|
|
this.Display(3, "参数错误")
|
|
return
|
|
}
|
|
res := this.Db.Get("org_analyse", "*", Map{"org_id": orgId})
|
|
if res == nil {
|
|
this.Display(4, "找不到该数据")
|
|
return
|
|
}
|
|
res["home_data"] = res.GetMap("home_data")
|
|
res["six_item_data"] = res.GetMap("six_item_data")
|
|
res["three_item_data"] = res.GetMap("three_item_data")
|
|
res["n_item_data"] = res.GetMap("n_item_data")
|
|
this.Display(0, res)
|
|
},
|
|
|
|
"ctg": func(this *Context) {
|
|
orgId := ObjToInt(this.Req.FormValue("org_id"))
|
|
ctgID := ObjToInt(this.Req.FormValue("ctg_id"))
|
|
if orgId == 0 || ctgID == 0 {
|
|
this.Display(3, "参数错误")
|
|
return
|
|
}
|
|
|
|
res := this.Db.Get("category_analyse", "*", Map{"AND": Map{"org_id": orgId, "category_id": ctgID}})
|
|
if res == nil {
|
|
this.Display(4, "找不到该数据")
|
|
return
|
|
}
|
|
res["data"] = res.GetMap("data")
|
|
res1 := this.Db.Get("org_analyse", "home_data", Map{"org_id": orgId})
|
|
res["home"] = res1.GetMap("home_data")
|
|
this.Display(0, res)
|
|
},
|
|
"industrys": func(this *Context) {
|
|
orgId := ObjToInt(this.Req.FormValue("org_id"))
|
|
if orgId == 0 {
|
|
this.Display(3, "参数错误")
|
|
return
|
|
}
|
|
|
|
res := this.Db.Select("industry_analyse", "industry_id,name", Map{"org_id": orgId})
|
|
if res == nil {
|
|
this.Display(4, "找不到该数据")
|
|
return
|
|
}
|
|
|
|
this.Display(0, res)
|
|
},
|
|
"industry": func(this *Context) {
|
|
orgId := ObjToInt(this.Req.FormValue("org_id"))
|
|
industryId := ObjToInt(this.Req.FormValue("industry_id"))
|
|
if orgId == 0 || industryId == 0 {
|
|
this.Display(3, "参数错误")
|
|
return
|
|
}
|
|
|
|
res := this.Db.Get("industry_analyse", "*", Map{"AND": Map{"org_id": orgId, "industry_id": industryId}})
|
|
if res == nil {
|
|
this.Display(4, "找不到该数据")
|
|
return
|
|
}
|
|
res["data"] = res.GetMap("data")
|
|
res1 := this.Db.Get("org_analyse", "name,home_data", Map{"org_id": orgId})
|
|
res["home"] = res1.GetMap("home_data")
|
|
res["home_name"] = res1.GetString("name")
|
|
this.Display(0, res)
|
|
},
|
|
|
|
"map": func(this *Context) {
|
|
|
|
orgId := ObjToInt(this.Req.FormValue("org_id"))
|
|
industryId := ObjToInt(this.Req.FormValue("industry_id"))
|
|
//if orgId == 0 || industryId == 0 {
|
|
// this.Display(3, "参数错误")
|
|
// return
|
|
//}
|
|
page := ObjToInt(this.Req.FormValue("page"))
|
|
pageSize := ObjToInt(this.Req.FormValue("pageSize"))
|
|
search := this.Req.FormValue("search")
|
|
where := Map{}
|
|
levelStr := this.Req.FormValue("level")
|
|
if levelStr != "" {
|
|
where["level"] = ObjToInt(levelStr)
|
|
}
|
|
if orgId != 0 {
|
|
where["org_id"] = orgId
|
|
}
|
|
if industryId != 0 {
|
|
where["industry_id"] = industryId
|
|
}
|
|
|
|
if search != "" {
|
|
where["name[~]"] = search
|
|
}
|
|
if len(where) > 1 {
|
|
where = Map{"AND": where}
|
|
}
|
|
|
|
if page == 0 {
|
|
page = 1
|
|
}
|
|
if pageSize == 0 {
|
|
pageSize = 10
|
|
}
|
|
count := this.Db.Count("company", where)
|
|
|
|
res := this.Db.Page(page, pageSize).PageSelect("company", Map{"[><]industry": "company.industry_id=industry.id"},
|
|
"company.id,company.name,company.level,company.address,company.score,company.lat,company.lng,company.category_id,industry.name AS industry_name,company.industry_id",
|
|
where)
|
|
|
|
this.Display(0, Map{"count": count, "pageSize": pageSize, "data": res})
|
|
},
|
|
"updateCompany": func(this *Context) {
|
|
lng := ObjToFloat64(this.Req.FormValue("lng"))
|
|
lat := ObjToFloat64(this.Req.FormValue("lat"))
|
|
id := ObjToInt(this.Req.FormValue("id"))
|
|
if lng == 0 || lat == 0 || id == 0 {
|
|
this.Display(3, "请求异常")
|
|
return
|
|
}
|
|
|
|
re := this.Db.Update("company", Map{"lng": lng, "lat": lat}, Map{"id": id})
|
|
if re == 0 {
|
|
this.Display(4, "更新失败")
|
|
return
|
|
}
|
|
this.Display(0, "更新成功")
|
|
},
|
|
|
|
"companys": func(this *Context) {
|
|
|
|
page := ObjToInt(this.Req.FormValue("page"))
|
|
pageSize := ObjToInt(this.Req.FormValue("pageSize"))
|
|
search := this.Req.FormValue("search")
|
|
where := Map{}
|
|
levelStr := this.Req.FormValue("level")
|
|
if levelStr != "" {
|
|
where["level"] = ObjToInt(levelStr)
|
|
}
|
|
|
|
if search != "" {
|
|
where["name[~]"] = search
|
|
}
|
|
if len(where) > 1 {
|
|
where = Map{"AND": where}
|
|
}
|
|
where["ORDER"] = "score DESC"
|
|
if page == 0 {
|
|
page = 1
|
|
}
|
|
if pageSize == 0 {
|
|
pageSize = 10
|
|
}
|
|
count := this.Db.Count("company", where)
|
|
|
|
res := this.Db.Page(page, pageSize).PageSelect("company",
|
|
"id,name,level,score,analyse->'$.MJSR' AS MJSR,analyse->'$.MJSS' AS MJSS,analyse->'$.RJSR' AS RJSR,analyse->'$.YFJFTRQD' AS YFJFTRQD,analyse->'$.DWNHSS' AS DWNHSS,analyse->'$.ZYWRWSS' AS ZYWRWSS,analyse->'$.FZZLZBZDF' AS FZZLZBZDF,analyse->'$.LSAQZBDF' AS LSAQZBDF,analyse->'$.XZFZZBDF' AS XZFZZBDF,analyse->'$.CYRCDF' AS CYRCDF,analyse->'$.ZJTXQLDF' AS ZJTXQLDF,analyse->'$.JGTZDF' AS JGTZDF",
|
|
where)
|
|
|
|
this.Display(0, Map{"count": count, "pageSize": pageSize, "data": res})
|
|
},
|
|
"company": func(this *Context) {
|
|
id := ObjToInt(this.Req.FormValue("id"))
|
|
if id == 0 {
|
|
this.Display(3, "参数错误")
|
|
return
|
|
}
|
|
|
|
res := this.Db.Get("company", "*", Map{"id": id})
|
|
if res == nil {
|
|
this.Display(4, "找不到该数据")
|
|
return
|
|
}
|
|
analyse := res.GetMap("analyse")
|
|
if analyse != nil {
|
|
for k, v := range analyse {
|
|
if ADataType[k] != nil {
|
|
analyse[ADataType.GetString(k)] = v
|
|
}
|
|
}
|
|
res["analyse"] = analyse
|
|
}
|
|
|
|
res["upload_data"] = res.GetMap("upload_data")
|
|
res["collect_data"] = res.GetMap("collect_data")
|
|
if res.GetMap("collect_data") == nil {
|
|
path := "company/" + Md5(res.GetString("name")) + time.Now().Format("/200601021504.json")
|
|
|
|
data := getCompany(res.GetString("name"), this.Config.GetString("tpt")+"/"+path)
|
|
if len(data) != 0 {
|
|
data["path"] = path
|
|
this.Db.Update("company", Map{"collect_data": data.ToJsonString()}, Map{"id": res.GetCeilInt("id")})
|
|
res["collect_data"] = data
|
|
}
|
|
}
|
|
this.Display(0, res)
|
|
|
|
},
|
|
}
|