forked from golang/hotime
ces
This commit is contained in:
parent
87039524a7
commit
8159e5cbda
@ -25,7 +25,7 @@ var CompanyInOutCtr = Ctr{
|
||||
//读取网络文件
|
||||
fi, fheader, err := this.Req.FormFile("file")
|
||||
if err != nil {
|
||||
this.Display(3, err)
|
||||
this.Display(3, err.Error())
|
||||
return
|
||||
|
||||
}
|
||||
@ -38,7 +38,7 @@ var CompanyInOutCtr = Ctr{
|
||||
e := os.MkdirAll(this.Config.GetString("tpt")+"/"+path, os.ModeDir)
|
||||
|
||||
if e != nil {
|
||||
this.Display(3, e)
|
||||
this.Display(3, e.Error())
|
||||
return
|
||||
}
|
||||
|
||||
@ -46,14 +46,14 @@ var CompanyInOutCtr = Ctr{
|
||||
newFile, e := os.Create(this.Config.GetString("tpt") + "/" + filePath)
|
||||
|
||||
if e != nil {
|
||||
this.Display(3, e)
|
||||
this.Display(3, e.Error())
|
||||
return
|
||||
}
|
||||
|
||||
_, e = io.Copy(newFile, fi)
|
||||
|
||||
if e != nil {
|
||||
this.Display(3, e)
|
||||
this.Display(3, e.Error())
|
||||
return
|
||||
}
|
||||
|
||||
@ -69,91 +69,91 @@ var CompanyInOutCtr = Ctr{
|
||||
|
||||
err = decodeData2Sql(data[0], this, orgId)
|
||||
if err != nil {
|
||||
this.Display(4, err)
|
||||
this.Display(4, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
this.Display(0, "上传成功")
|
||||
|
||||
},
|
||||
"analyse": func(this *Context) {
|
||||
orgId := ObjToInt(this.Req.FormValue("org_id"))
|
||||
if orgId == 0 {
|
||||
this.Display(3, "参数错误")
|
||||
return
|
||||
}
|
||||
companys := this.Db.Select("company", "*", Map{"org_id": orgId})
|
||||
//"analyse": func(this *Context) {
|
||||
// orgId := ObjToInt(this.Req.FormValue("org_id"))
|
||||
// if orgId == 0 {
|
||||
// this.Display(3, "参数错误")
|
||||
// return
|
||||
// }
|
||||
// companys := this.Db.Select("company", "*", Map{"org_id": orgId})
|
||||
//
|
||||
// for _, v := range companys {
|
||||
//
|
||||
// data := Org[orgId].analyse(v.GetMap("upload_data"))
|
||||
// for k, _ := range data {
|
||||
// data[k] = data.GetFloat64(k)
|
||||
// }
|
||||
// v["analyse"] = data
|
||||
// }
|
||||
//
|
||||
// cs := Org[orgId].analyseSort(companys)
|
||||
// for _, v := range cs {
|
||||
// as := v.GetMap("analyse")
|
||||
// //v["analyse"] = as.ToJsonString()
|
||||
// switch as.GetString("PJ") {
|
||||
// case "A":
|
||||
// v["level"] = 0
|
||||
// case "B":
|
||||
// v["level"] = 1
|
||||
// case "C":
|
||||
// v["level"] = 2
|
||||
// case "D":
|
||||
// v["level"] = 3
|
||||
// }
|
||||
// v["score"] = as.GetFloat64("ZDF")
|
||||
//
|
||||
// this.Db.Update("company", Map{"analyse": as.ToJsonString(), "level": v["level"], "score": v["score"]}, Map{"id": v.GetCeilInt("id")})
|
||||
// this.Db.Update("company_history", Map{"analyse": as.ToJsonString(), "level": v["level"], "score": v["score"]}, Map{"id": v.GetCeilInt("company_history_id")})
|
||||
// }
|
||||
//
|
||||
// this.Display(0, len(companys))
|
||||
//
|
||||
//},
|
||||
|
||||
for _, v := range companys {
|
||||
|
||||
data := Org[orgId].analyse(v.GetMap("upload_data"))
|
||||
for k, _ := range data {
|
||||
data[k] = data.GetFloat64(k)
|
||||
}
|
||||
v["analyse"] = data
|
||||
}
|
||||
|
||||
cs := Org[orgId].analyseSort(companys)
|
||||
for _, v := range cs {
|
||||
as := v.GetMap("analyse")
|
||||
//v["analyse"] = as.ToJsonString()
|
||||
switch as.GetString("PJ") {
|
||||
case "A":
|
||||
v["level"] = 0
|
||||
case "B":
|
||||
v["level"] = 1
|
||||
case "C":
|
||||
v["level"] = 2
|
||||
case "D":
|
||||
v["level"] = 3
|
||||
}
|
||||
v["score"] = as.GetFloat64("ZDF")
|
||||
|
||||
this.Db.Update("company", Map{"analyse": as.ToJsonString(), "level": v["level"], "score": v["score"]}, Map{"id": v.GetCeilInt("id")})
|
||||
this.Db.Update("company_history", Map{"analyse": as.ToJsonString(), "level": v["level"], "score": v["score"]}, Map{"id": v.GetCeilInt("company_history_id")})
|
||||
}
|
||||
|
||||
this.Display(0, len(companys))
|
||||
|
||||
},
|
||||
|
||||
"total_analyse": func(this *Context) {
|
||||
orgId := ObjToInt(this.Req.FormValue("org_id"))
|
||||
if orgId == 0 {
|
||||
this.Display(3, "参数错误")
|
||||
return
|
||||
}
|
||||
|
||||
companys := this.Db.Select("company", "*", Map{"AND": Map{"org_id": orgId}})
|
||||
|
||||
home_data, six_item_data, three_item_data, n_item_data := totalAnalyse(companys)
|
||||
|
||||
org := this.Db.Get("org", "*", Map{"id": orgId})
|
||||
fmt.Println(six_item_data)
|
||||
|
||||
data := Map{
|
||||
"name": org.GetString("name"),
|
||||
"home_data": home_data.ToJsonString(),
|
||||
"six_item_data": six_item_data.ToJsonString(),
|
||||
"three_item_data": three_item_data.ToJsonString(),
|
||||
"n_item_data": n_item_data.ToJsonString(),
|
||||
"modify_time": time.Now().Unix(),
|
||||
}
|
||||
org_analyse := this.Db.Get("org_analyse", "id", Map{"org_id": orgId})
|
||||
if org_analyse == nil {
|
||||
//data["name"] = time.Now().Format("2006-01-02 15:04") + "创建"
|
||||
data["name"] = org.GetString("name")
|
||||
data["org_id"] = orgId
|
||||
data["create_time"] = time.Now().Unix()
|
||||
id := this.Db.Insert("org_analyse", data)
|
||||
data["id"] = id
|
||||
} else {
|
||||
this.Db.Update("org_analyse", data, Map{"org_id": orgId})
|
||||
}
|
||||
|
||||
this.Display(0, data)
|
||||
|
||||
},
|
||||
//"total_analyse": func(this *Context) {
|
||||
// orgId := ObjToInt(this.Req.FormValue("org_id"))
|
||||
// if orgId == 0 {
|
||||
// this.Display(3, "参数错误")
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// companys := this.Db.Select("company", "*", Map{"AND": Map{"org_id": orgId}})
|
||||
//
|
||||
// home_data, six_item_data, three_item_data, n_item_data := totalAnalyse(companys)
|
||||
//
|
||||
// org := this.Db.Get("org", "*", Map{"id": orgId})
|
||||
// fmt.Println(six_item_data)
|
||||
//
|
||||
// data := Map{
|
||||
// "name": org.GetString("name"),
|
||||
// "home_data": home_data.ToJsonString(),
|
||||
// "six_item_data": six_item_data.ToJsonString(),
|
||||
// "three_item_data": three_item_data.ToJsonString(),
|
||||
// "n_item_data": n_item_data.ToJsonString(),
|
||||
// "modify_time": time.Now().Unix(),
|
||||
// }
|
||||
// org_analyse := this.Db.Get("org_analyse", "id", Map{"org_id": orgId})
|
||||
// if org_analyse == nil {
|
||||
// //data["name"] = time.Now().Format("2006-01-02 15:04") + "创建"
|
||||
// data["name"] = org.GetString("name")
|
||||
// data["org_id"] = orgId
|
||||
// data["create_time"] = time.Now().Unix()
|
||||
// id := this.Db.Insert("org_analyse", data)
|
||||
// data["id"] = id
|
||||
// } else {
|
||||
// this.Db.Update("org_analyse", data, Map{"org_id": orgId})
|
||||
// }
|
||||
//
|
||||
// this.Display(0, data)
|
||||
//
|
||||
//},
|
||||
//
|
||||
//"category_analyse": func(this *Context) {
|
||||
//
|
||||
|
@ -208,13 +208,44 @@ func TestAnalyse(companys []Map, tag Map) {
|
||||
//vm.Set(tag.GetString("name"), 0)
|
||||
continue
|
||||
}
|
||||
|
||||
if cmdStr == "res=(key['连续盈利']==0?0:(key['连续盈利']==1?5:10))" {
|
||||
v, _ := vm.Get("key")
|
||||
ks := v.Object().Keys()
|
||||
for i, k := range ks {
|
||||
v1, e1 := v.Object().Get(k)
|
||||
fmt.Println(k, v1, e1, i)
|
||||
}
|
||||
|
||||
fmt.Println("dassdas")
|
||||
}
|
||||
|
||||
if result.String() == ObjToStr(ObjToFloat64(result.String())) {
|
||||
analyseData[tag.GetString("name")] = ObjToFloat64(result.String())
|
||||
//if "成都卡诺普机器人技术股份有限公司"==company.GetString("name"){
|
||||
// fmt.Println("dasdas")
|
||||
//}
|
||||
} else if result.String() == "NaN" {
|
||||
|
||||
v, _ := vm.Get("key")
|
||||
ks := v.Object().Keys()
|
||||
for i, k := range ks {
|
||||
v1, e1 := v.Object().Get(k)
|
||||
fmt.Println(k, v1, e1, i)
|
||||
}
|
||||
|
||||
analyseData[tag.GetString("name")] = 0
|
||||
} else if result.String() == "Infinity" {
|
||||
fmt.Println(cmdStr)
|
||||
//v,_:=vm.Get("key")
|
||||
//ks:=v.Object().Keys()
|
||||
//for i,k:=range ks{
|
||||
// v1,e1:=v.Object().Get(k)
|
||||
// fmt.Println(k,v1,e1,i)
|
||||
//}
|
||||
analyseData[tag.GetString("name")] = 0
|
||||
} else {
|
||||
|
||||
analyseData[tag.GetString("name")] = result.String()
|
||||
}
|
||||
vm.Run("key['" + tag.GetString("name") + "']=" + ObjToStr(analyseData[tag.GetString("name")]))
|
||||
@ -690,43 +721,43 @@ var TestCtr = Ctr{
|
||||
//this.Display(0, data)
|
||||
fmt.Println(unicode.IsPunct(rune(')')))
|
||||
},
|
||||
"app_analyse": func(this *Context) {
|
||||
orgId := 2
|
||||
if orgId == 0 {
|
||||
this.Display(3, "参数错误")
|
||||
return
|
||||
}
|
||||
|
||||
companys := this.Db.Select("company", "*")
|
||||
|
||||
home_data, six_item_data, three_item_data, n_item_data := totalAnalyse(companys)
|
||||
|
||||
org := this.Db.Get("org", "*", Map{"id": orgId})
|
||||
fmt.Println(six_item_data)
|
||||
|
||||
data := Map{
|
||||
"name": org.GetString("name"),
|
||||
"home_data": home_data.ToJsonString(),
|
||||
"six_item_data": six_item_data.ToJsonString(),
|
||||
"three_item_data": three_item_data.ToJsonString(),
|
||||
"n_item_data": n_item_data.ToJsonString(),
|
||||
"modify_time": time.Now().Unix(),
|
||||
}
|
||||
org_analyse := this.Db.Get("org_analyse", "id", Map{"org_id": orgId})
|
||||
if org_analyse == nil {
|
||||
//data["name"] = time.Now().Format("2006-01-02 15:04") + "创建"
|
||||
data["name"] = org.GetString("name")
|
||||
data["org_id"] = orgId
|
||||
data["create_time"] = time.Now().Unix()
|
||||
id := this.Db.Insert("org_analyse", data)
|
||||
data["id"] = id
|
||||
} else {
|
||||
this.Db.Update("org_analyse", data, Map{"org_id": orgId})
|
||||
}
|
||||
|
||||
this.Display(0, data)
|
||||
|
||||
},
|
||||
//"app_analyse": func(this *Context) {
|
||||
// orgId := 2
|
||||
// if orgId == 0 {
|
||||
// this.Display(3, "参数错误")
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// companys := this.Db.Select("company", "*")
|
||||
//
|
||||
// home_data, six_item_data, three_item_data, n_item_data := totalAnalyse(companys)
|
||||
//
|
||||
// org := this.Db.Get("org", "*", Map{"id": orgId})
|
||||
// fmt.Println(six_item_data)
|
||||
//
|
||||
// data := Map{
|
||||
// "name": org.GetString("name"),
|
||||
// "home_data": home_data.ToJsonString(),
|
||||
// "six_item_data": six_item_data.ToJsonString(),
|
||||
// "three_item_data": three_item_data.ToJsonString(),
|
||||
// "n_item_data": n_item_data.ToJsonString(),
|
||||
// "modify_time": time.Now().Unix(),
|
||||
// }
|
||||
// org_analyse := this.Db.Get("org_analyse", "id", Map{"org_id": orgId})
|
||||
// if org_analyse == nil {
|
||||
// //data["name"] = time.Now().Format("2006-01-02 15:04") + "创建"
|
||||
// data["name"] = org.GetString("name")
|
||||
// data["org_id"] = orgId
|
||||
// data["create_time"] = time.Now().Unix()
|
||||
// id := this.Db.Insert("org_analyse", data)
|
||||
// data["id"] = id
|
||||
// } else {
|
||||
// this.Db.Update("org_analyse", data, Map{"org_id": orgId})
|
||||
// }
|
||||
//
|
||||
// this.Display(0, data)
|
||||
//
|
||||
//},
|
||||
"industry_analyse": func(this *Context) {
|
||||
orgId := 1
|
||||
industrys := this.Db.Select("industry_analyse", "id,name", Map{"org_id": orgId})
|
||||
@ -832,6 +863,9 @@ var TestCtr = Ctr{
|
||||
tagCompany1 := this.Db.Select("tag", "*", Map{"AND": Map{"type": 2, "org_id": orgId}, "ORDER": Slice{"`sort` DESC", "id ASC"}})
|
||||
//cs := append(NewCompanys{}, companys...)
|
||||
for _, tag := range tagCompany1 {
|
||||
if tag.GetString("name") == "发展潜力得分" {
|
||||
fmt.Println("dasdas")
|
||||
}
|
||||
TestAnalyse(companys, tag)
|
||||
//fmt.Println(data)
|
||||
}
|
||||
|
@ -10,6 +10,23 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
func convertToTitle(columnNumber int) string {
|
||||
var res []byte
|
||||
for columnNumber > 0 {
|
||||
a := columnNumber % 26
|
||||
if a == 0 {
|
||||
a = 26
|
||||
}
|
||||
res = append(res, 'A'+byte(a-1))
|
||||
columnNumber = (columnNumber - a) / 26
|
||||
}
|
||||
// 上面输出的res是反着的,前后交换
|
||||
for i, n := 0, len(res); i < n/2; i++ {
|
||||
res[i], res[n-1-i] = res[n-1-i], res[i]
|
||||
}
|
||||
return string(res)
|
||||
}
|
||||
|
||||
var analyseCtr = Ctr{
|
||||
|
||||
"home_data": func(this *Context) {
|
||||
@ -47,15 +64,28 @@ var analyseCtr = Ctr{
|
||||
|
||||
filePath := "temp/home" + ObjToStr(orgId) + ".xlsx"
|
||||
f, e := excelize.OpenFile(this.Config.GetString("tpt") + "/" + filePath)
|
||||
// 设置单元格的值
|
||||
tagCompany1 := this.Db.Select("tag", "*", Map{"AND": Map{"type": 2, "org_id": orgId}, "ORDER": Slice{"`sort` DESC", "id ASC"}})
|
||||
if e != nil {
|
||||
f = excelize.NewFile()
|
||||
// 创建一个工作表
|
||||
f.NewSheet("企业分析")
|
||||
|
||||
f.NewSheet("IEDC全局分析")
|
||||
// 创建一个工作表
|
||||
f.NewSheet("“6”项量化")
|
||||
f.NewSheet("“3”项定性")
|
||||
f.NewSheet("“N”项特色")
|
||||
f.DeleteSheet("Sheet1")
|
||||
|
||||
//cs := append(NewCompanys{}, companys...)
|
||||
f.SetCellValue("企业分析", convertToTitle(1)+"1", "企业名")
|
||||
for k, tag := range tagCompany1 {
|
||||
|
||||
f.SetCellValue("企业分析", convertToTitle(k+2)+"1", tag.GetString("name"))
|
||||
|
||||
}
|
||||
|
||||
// 设置单元格的值
|
||||
f.SetCellValue("IEDC全局分析", "A1", "指标项")
|
||||
f.SetCellValue("IEDC全局分析", "B1", "指标值")
|
||||
@ -98,6 +128,33 @@ var analyseCtr = Ctr{
|
||||
run("“N”项特色", nItemData, f)
|
||||
//f.SetCellValue("Sheet1", "B2", 100)
|
||||
|
||||
companys := this.Db.Select("company", "*", Map{"AND": Map{"org_id": orgId}, "ORDER": "`analyse`->'$.\"总排名\"' ASC"})
|
||||
for k, v := range companys {
|
||||
//上传数据
|
||||
upload_data := v.GetMap("upload_data")
|
||||
collect_data := v.GetMap("collect_data")
|
||||
analysess := v.GetMap("analyse")
|
||||
//total:=Map{}
|
||||
//for kk {
|
||||
//
|
||||
//}
|
||||
|
||||
f.SetCellValue("企业分析", convertToTitle(1)+ObjToStr(k+2), v.GetString("name"))
|
||||
for k1, tag := range tagCompany1 {
|
||||
if analysess[tag.GetString("sn")] != nil {
|
||||
f.SetCellValue("企业分析", convertToTitle(k1+2)+ObjToStr(k+2), analysess[tag.GetString("sn")])
|
||||
}
|
||||
if upload_data[tag.GetString("sn")] != nil {
|
||||
f.SetCellValue("企业分析", convertToTitle(k1+2)+ObjToStr(k+2), upload_data[tag.GetString("sn")])
|
||||
}
|
||||
if collect_data[tag.GetString("sn")] != nil {
|
||||
f.SetCellValue("企业分析", convertToTitle(k1+2)+ObjToStr(k+2), collect_data[tag.GetString("sn")])
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
f.Save()
|
||||
this.Resp.Header().Set("Location", "/"+filePath)
|
||||
this.Resp.WriteHeader(307) //关键在这里!
|
||||
|
BIN
example/iedc.exe
BIN
example/iedc.exe
Binary file not shown.
Loading…
Reference in New Issue
Block a user