2022-01-22 08:12:02 +00:00
|
|
|
|
package admin
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
. "../../../hotime"
|
|
|
|
|
. "../../common"
|
|
|
|
|
"../../dri/baidu"
|
|
|
|
|
"fmt"
|
2022-02-14 11:10:58 +00:00
|
|
|
|
"github.com/robertkrimen/otto"
|
2022-01-22 08:12:02 +00:00
|
|
|
|
"github.com/xuri/excelize"
|
|
|
|
|
"io/ioutil"
|
|
|
|
|
"os"
|
2022-02-14 11:10:58 +00:00
|
|
|
|
"sort"
|
2022-01-22 08:12:02 +00:00
|
|
|
|
"strings"
|
|
|
|
|
"time"
|
2022-02-14 11:10:58 +00:00
|
|
|
|
"unicode"
|
2022-01-22 08:12:02 +00:00
|
|
|
|
)
|
|
|
|
|
|
2022-02-16 20:10:53 +00:00
|
|
|
|
func TestAnalyse(companys []Map, tag Map) {
|
2022-02-14 11:10:58 +00:00
|
|
|
|
cs := append(NewCompanys{}, companys...)
|
|
|
|
|
for _, company := range companys {
|
|
|
|
|
vm := otto.New()
|
|
|
|
|
vm.Set("sortLevel", func(call otto.FunctionCall) otto.Value {
|
|
|
|
|
AnalyseSortType = call.Argument(0).String()
|
|
|
|
|
sort.Sort(cs)
|
|
|
|
|
for k, v := range cs {
|
2022-02-16 20:10:53 +00:00
|
|
|
|
if company.GetMap(AnalyseTypeName).GetFloat64(AnalyseSortType) >= v.GetMap(AnalyseTypeName).GetFloat64(AnalyseSortType) {
|
2022-02-14 11:10:58 +00:00
|
|
|
|
val, _ := vm.ToValue(k + 1)
|
|
|
|
|
return val
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
val, _ := vm.ToValue(len(cs))
|
|
|
|
|
return val
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
vm.Set("count", func(call otto.FunctionCall) otto.Value {
|
|
|
|
|
//key:=call.Argument(0).String()
|
|
|
|
|
val, _ := vm.ToValue(len(cs))
|
|
|
|
|
return val
|
|
|
|
|
})
|
|
|
|
|
//上传数据
|
|
|
|
|
uploadData := company.GetMap("upload_data")
|
|
|
|
|
for k, _ := range uploadData {
|
|
|
|
|
strV := uploadData.GetString(k)
|
2022-02-16 20:10:53 +00:00
|
|
|
|
strV = strings.Replace(strV, " ", "", -1)
|
2022-02-14 11:10:58 +00:00
|
|
|
|
v := float64(0)
|
2022-02-16 20:10:53 +00:00
|
|
|
|
//if strV == "否" {
|
|
|
|
|
// v = 0
|
|
|
|
|
//}
|
2022-02-14 11:10:58 +00:00
|
|
|
|
|
|
|
|
|
if strings.Index(strV, "%") == len(strV)-1 && len(strV) != 0 {
|
|
|
|
|
v = uploadData.GetFloat64(strings.Replace(strV, "%", "", -1)) / 100
|
|
|
|
|
}
|
|
|
|
|
flV := uploadData.GetFloat64(k)
|
|
|
|
|
if flV != 0 && v == 0 {
|
|
|
|
|
v = flV
|
|
|
|
|
}
|
2022-02-16 20:10:53 +00:00
|
|
|
|
|
|
|
|
|
if v == 0 && strV != "否" && strV != "0" {
|
|
|
|
|
v = 1
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-14 11:10:58 +00:00
|
|
|
|
vm.Set(k, v)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//api采集数据
|
|
|
|
|
collectData := company.GetMap("collect_data")
|
|
|
|
|
for k, cv := range collectData {
|
|
|
|
|
if cv == nil {
|
|
|
|
|
vm.Set(k, 0)
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
strV := collectData.GetString(k)
|
|
|
|
|
if strings.Index(strV, "万人民币") != -1 {
|
2022-02-16 20:10:53 +00:00
|
|
|
|
strV = strings.Replace(strV, "万人民币", "", -1)
|
2022-02-14 11:10:58 +00:00
|
|
|
|
}
|
|
|
|
|
vm.Set(k, strV)
|
|
|
|
|
}
|
|
|
|
|
//api采集数据
|
|
|
|
|
analyseData := company.GetMap("analyse")
|
|
|
|
|
if analyseData == nil {
|
|
|
|
|
analyseData = Map{}
|
|
|
|
|
company["analyse"] = analyseData
|
|
|
|
|
}
|
|
|
|
|
for k, cv := range analyseData {
|
|
|
|
|
vm.Set(k, cv)
|
|
|
|
|
}
|
|
|
|
|
//res:=Map{}
|
|
|
|
|
//analyse
|
|
|
|
|
|
|
|
|
|
//for _,v:=range cmds{
|
|
|
|
|
vm.Set("res", nil)
|
|
|
|
|
_, e := vm.Run(tag.GetString("cmd"))
|
|
|
|
|
if e != nil {
|
2022-02-16 20:10:53 +00:00
|
|
|
|
fmt.Println(e, "dasdas")
|
2022-02-14 11:10:58 +00:00
|
|
|
|
analyseData[tag.GetString("name")] = 0
|
|
|
|
|
vm.Set(tag.GetString("name"), 0)
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
result, e := vm.Get("res")
|
|
|
|
|
if e != nil {
|
2022-02-16 20:10:53 +00:00
|
|
|
|
fmt.Println(e, "312sdqweqw")
|
2022-02-14 11:10:58 +00:00
|
|
|
|
analyseData[tag.GetString("name")] = 0
|
|
|
|
|
vm.Set(tag.GetString("name"), 0)
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
if result.String() == ObjToStr(ObjToFloat64(result.String())) {
|
|
|
|
|
analyseData[tag.GetString("name")] = ObjToFloat64(result.String())
|
|
|
|
|
} else if result.String() == "NaN" {
|
|
|
|
|
analyseData[tag.GetString("name")] = 0
|
2022-02-16 20:10:53 +00:00
|
|
|
|
} else if result.String() == "Infinity" {
|
|
|
|
|
analyseData[tag.GetString("name")] = 0
|
2022-02-14 11:10:58 +00:00
|
|
|
|
} else {
|
|
|
|
|
analyseData[tag.GetString("name")] = result.String()
|
|
|
|
|
}
|
|
|
|
|
vm.Set(tag.GetString("name"), analyseData[tag.GetString("name")])
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type NewCompanys []Map
|
|
|
|
|
|
|
|
|
|
var AnalyseSortType = ""
|
|
|
|
|
var AnalyseTypeName = "analyse"
|
|
|
|
|
|
|
|
|
|
func (s NewCompanys) Len() int {
|
|
|
|
|
return len(s)
|
|
|
|
|
}
|
|
|
|
|
func (s NewCompanys) Swap(i, j int) {
|
|
|
|
|
s[i], s[j] = s[j], s[i]
|
|
|
|
|
}
|
|
|
|
|
func (s NewCompanys) Less(i, j int) bool {
|
|
|
|
|
AnalyseTypeName = "upload_data"
|
|
|
|
|
if s[i].GetMap(AnalyseTypeName)[AnalyseSortType] == nil {
|
|
|
|
|
AnalyseTypeName = "analyse"
|
|
|
|
|
}
|
|
|
|
|
return s[i].GetMap(AnalyseTypeName).GetFloat64(AnalyseSortType) > s[j].GetMap(AnalyseTypeName).GetFloat64(AnalyseSortType)
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-16 20:10:53 +00:00
|
|
|
|
func totalTestAnalyse(companys []Map, tag Map, totalData Map) {
|
2022-02-14 11:10:58 +00:00
|
|
|
|
cs := append(NewCompanys{}, companys...)
|
2022-02-16 20:10:53 +00:00
|
|
|
|
|
|
|
|
|
vm := otto.New()
|
|
|
|
|
vm.Set("vcount", func(call otto.FunctionCall) otto.Value {
|
|
|
|
|
if call.Argument(0).IsUndefined() {
|
|
|
|
|
val, _ := vm.ToValue(0)
|
|
|
|
|
return val
|
|
|
|
|
}
|
|
|
|
|
key := call.Argument(0).String()
|
|
|
|
|
if key == "IEDCSJZJTX0" || key == "IEDCSJZJTX" {
|
|
|
|
|
fmt.Println(key)
|
|
|
|
|
}
|
|
|
|
|
num := float64(0)
|
|
|
|
|
for _, v := range cs {
|
|
|
|
|
AnalyseTypeName := "upload_data"
|
|
|
|
|
if v.GetMap(AnalyseTypeName)[key] == nil {
|
|
|
|
|
AnalyseTypeName = "analyse"
|
2022-02-14 11:10:58 +00:00
|
|
|
|
}
|
2022-02-16 20:10:53 +00:00
|
|
|
|
if v.GetMap(AnalyseTypeName).GetFloat64(key) > 0 {
|
|
|
|
|
//num++
|
|
|
|
|
num = num + v.GetMap(AnalyseTypeName).GetFloat64(key)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
val, _ := vm.ToValue(num)
|
|
|
|
|
return val
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
vm.Set("count", func(call otto.FunctionCall) otto.Value {
|
|
|
|
|
if call.Argument(0).IsUndefined() {
|
|
|
|
|
val, _ := vm.ToValue(len(cs))
|
|
|
|
|
return val
|
|
|
|
|
}
|
|
|
|
|
key := call.Argument(0).String()
|
|
|
|
|
|
|
|
|
|
num := 0
|
|
|
|
|
for _, v := range cs {
|
2022-02-14 11:10:58 +00:00
|
|
|
|
AnalyseTypeName := "upload_data"
|
2022-02-16 20:10:53 +00:00
|
|
|
|
if v.GetMap(AnalyseTypeName)[key] == nil {
|
2022-02-14 11:10:58 +00:00
|
|
|
|
AnalyseTypeName = "analyse"
|
|
|
|
|
}
|
2022-02-16 20:10:53 +00:00
|
|
|
|
if v.GetMap(AnalyseTypeName).GetFloat64(key) > 0 {
|
|
|
|
|
num++
|
2022-02-14 11:10:58 +00:00
|
|
|
|
}
|
2022-02-16 20:10:53 +00:00
|
|
|
|
}
|
|
|
|
|
val, _ := vm.ToValue(num)
|
|
|
|
|
return val
|
|
|
|
|
})
|
|
|
|
|
for _, company := range companys {
|
|
|
|
|
//上传数据
|
|
|
|
|
uploadData := company.GetMap("upload_data")
|
|
|
|
|
for k, _ := range uploadData {
|
|
|
|
|
strV := uploadData.GetString(k)
|
|
|
|
|
strV = strings.Replace(strV, " ", "", -1)
|
|
|
|
|
v := float64(0)
|
|
|
|
|
//if strV == "否" {
|
|
|
|
|
// v = 0
|
|
|
|
|
//}
|
|
|
|
|
if strings.Index(strV, "%") == len(strV)-1 && len(strV) != 0 {
|
|
|
|
|
v = uploadData.GetFloat64(strings.Replace(strV, "%", "", -1)) / 100
|
|
|
|
|
}
|
|
|
|
|
flV := uploadData.GetFloat64(k)
|
|
|
|
|
if flV != 0 && v == 0 {
|
|
|
|
|
v = flV
|
|
|
|
|
}
|
|
|
|
|
if k == "IEDCSJZJTX0" || k == "IEDCSJZJTX" {
|
|
|
|
|
fmt.Println(k)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if v == 0 && strV != "否" && strV != "0" {
|
|
|
|
|
v = 1
|
|
|
|
|
}
|
|
|
|
|
//vm.Set(k, v)
|
|
|
|
|
uploadData[k] = v
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
company["upload_data"] = uploadData
|
|
|
|
|
//api采集数据
|
|
|
|
|
collectData := company.GetMap("collect_data")
|
|
|
|
|
for k, cv := range collectData {
|
|
|
|
|
if cv == nil {
|
|
|
|
|
vm.Set(k, 0)
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
strV := collectData.GetString(k)
|
|
|
|
|
if strings.Index(strV, "万人民币") != -1 {
|
|
|
|
|
strV = strings.Replace(strV, "万人民币", "", -1)
|
|
|
|
|
}
|
|
|
|
|
//vm.Set(k, strV)
|
|
|
|
|
collectData[k] = strV
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
company["collect_data"] = collectData
|
|
|
|
|
//api采集数据
|
|
|
|
|
analyseData := company.GetMap("analyse")
|
|
|
|
|
if analyseData == nil {
|
|
|
|
|
analyseData = Map{}
|
|
|
|
|
company["analyse"] = analyseData
|
|
|
|
|
}
|
|
|
|
|
//for k, cv := range analyseData {
|
|
|
|
|
// vm.Set(k, cv)
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
//totalData:=Map{}
|
|
|
|
|
//analyse
|
|
|
|
|
|
|
|
|
|
//for _,v:=range cmds{
|
|
|
|
|
vm.Set("res", nil)
|
|
|
|
|
_, e := vm.Run(tag.GetString("cmd"))
|
|
|
|
|
if e != nil {
|
|
|
|
|
fmt.Println(e, "asdas")
|
|
|
|
|
totalData[tag.GetString("name")] = 0
|
|
|
|
|
vm.Set(tag.GetString("name"), 0)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
result, e := vm.Get("res")
|
|
|
|
|
if e != nil {
|
|
|
|
|
fmt.Println(e, "312dqwe")
|
|
|
|
|
totalData[tag.GetString("name")] = 0
|
|
|
|
|
vm.Set(tag.GetString("name"), 0)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if result.String() == ObjToStr(ObjToFloat64(result.String())) {
|
|
|
|
|
totalData[tag.GetString("name")] = ObjToFloat64(result.String())
|
|
|
|
|
} else if result.String() == "NaN" {
|
|
|
|
|
totalData[tag.GetString("name")] = 0
|
|
|
|
|
} else if result.String() == "Infinity" {
|
|
|
|
|
totalData[tag.GetString("name")] = 0
|
|
|
|
|
} else {
|
|
|
|
|
totalData[tag.GetString("name")] = result.String()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
vm.Set(tag.GetString("name"), totalData[tag.GetString("name")])
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func totalAnalyse1(companys []Map, totalData Map) {
|
|
|
|
|
cs := append(NewCompanys{}, companys...)
|
|
|
|
|
vm := otto.New()
|
|
|
|
|
vm.Set("vcount", func(call otto.FunctionCall) otto.Value {
|
|
|
|
|
if call.Argument(0).IsUndefined() {
|
|
|
|
|
val, _ := vm.ToValue(0)
|
2022-02-14 11:10:58 +00:00
|
|
|
|
return val
|
2022-02-16 20:10:53 +00:00
|
|
|
|
}
|
|
|
|
|
key := call.Argument(0).String()
|
2022-02-14 11:10:58 +00:00
|
|
|
|
|
2022-02-16 20:10:53 +00:00
|
|
|
|
num := float64(0)
|
|
|
|
|
for _, v := range cs {
|
|
|
|
|
AnalyseTypeName := "upload_data"
|
|
|
|
|
if v.GetMap(AnalyseTypeName)[key] == nil {
|
|
|
|
|
AnalyseTypeName = "analyse"
|
2022-02-14 11:10:58 +00:00
|
|
|
|
}
|
2022-02-16 20:10:53 +00:00
|
|
|
|
if v.GetMap(AnalyseTypeName).GetFloat64(key) > 0 {
|
|
|
|
|
//num++
|
|
|
|
|
num = num + v.GetMap(AnalyseTypeName).GetFloat64(key)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
val, _ := vm.ToValue(num)
|
|
|
|
|
return val
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
vm.Set("count", func(call otto.FunctionCall) otto.Value {
|
|
|
|
|
if call.Argument(0).IsUndefined() {
|
|
|
|
|
val, _ := vm.ToValue(len(cs))
|
|
|
|
|
return val
|
|
|
|
|
}
|
|
|
|
|
key := call.Argument(0).String()
|
|
|
|
|
|
|
|
|
|
num := 0
|
|
|
|
|
for _, v := range cs {
|
2022-02-14 11:10:58 +00:00
|
|
|
|
AnalyseTypeName := "upload_data"
|
2022-02-16 20:10:53 +00:00
|
|
|
|
if v.GetMap(AnalyseTypeName)[key] == nil {
|
2022-02-14 11:10:58 +00:00
|
|
|
|
AnalyseTypeName = "analyse"
|
|
|
|
|
}
|
2022-02-16 20:10:53 +00:00
|
|
|
|
if v.GetMap(AnalyseTypeName).GetFloat64(key) > 0 {
|
|
|
|
|
num++
|
2022-02-14 11:10:58 +00:00
|
|
|
|
}
|
2022-02-16 20:10:53 +00:00
|
|
|
|
}
|
|
|
|
|
val, _ := vm.ToValue(num)
|
|
|
|
|
return val
|
|
|
|
|
})
|
|
|
|
|
vm.Set("hmax", func(call otto.FunctionCall) otto.Value {
|
|
|
|
|
AnalyseSortType = call.Argument(0).String()
|
|
|
|
|
sort.Sort(cs)
|
|
|
|
|
|
|
|
|
|
fmt.Println(0, AnalyseTypeName, AnalyseSortType, cs[0].GetMap(AnalyseTypeName).GetFloat64(AnalyseSortType))
|
|
|
|
|
val, _ := vm.ToValue(cs[0].GetMap(AnalyseTypeName).GetFloat64(AnalyseSortType))
|
|
|
|
|
return val
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
vm.Set("hmin", func(call otto.FunctionCall) otto.Value {
|
|
|
|
|
AnalyseSortType = call.Argument(0).String()
|
|
|
|
|
fmt.Println(AnalyseSortType, "asddas")
|
|
|
|
|
sort.Sort(cs)
|
|
|
|
|
|
|
|
|
|
val, _ := vm.ToValue(cs[len(cs)-1].GetMap(AnalyseTypeName).GetFloat64(AnalyseSortType))
|
|
|
|
|
return val
|
|
|
|
|
})
|
|
|
|
|
//平均值
|
|
|
|
|
vm.Set("haverage", func(call otto.FunctionCall) otto.Value {
|
|
|
|
|
if call.Argument(0).IsUndefined() {
|
|
|
|
|
val, _ := vm.ToValue(0)
|
2022-02-14 11:10:58 +00:00
|
|
|
|
return val
|
2022-02-16 20:10:53 +00:00
|
|
|
|
}
|
|
|
|
|
key := call.Argument(0).String()
|
|
|
|
|
|
|
|
|
|
num := float64(0)
|
|
|
|
|
for _, v := range cs {
|
|
|
|
|
AnalyseTypeName := "upload_data"
|
|
|
|
|
if v.GetMap(AnalyseTypeName)[key] == nil {
|
|
|
|
|
AnalyseTypeName = "analyse"
|
|
|
|
|
}
|
|
|
|
|
if v.GetMap(AnalyseTypeName).GetFloat64(key) > 0 {
|
|
|
|
|
//num++
|
|
|
|
|
num = num + v.GetMap(AnalyseTypeName).GetFloat64(key)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
val, _ := vm.ToValue(num / float64(len(cs)))
|
|
|
|
|
return val
|
|
|
|
|
})
|
|
|
|
|
for _, company := range companys {
|
2022-02-14 11:10:58 +00:00
|
|
|
|
//上传数据
|
|
|
|
|
uploadData := company.GetMap("upload_data")
|
|
|
|
|
for k, _ := range uploadData {
|
|
|
|
|
strV := uploadData.GetString(k)
|
2022-02-16 20:10:53 +00:00
|
|
|
|
strV = strings.Replace(strV, " ", "", -1)
|
2022-02-14 11:10:58 +00:00
|
|
|
|
v := float64(0)
|
2022-02-16 20:10:53 +00:00
|
|
|
|
//if strV == "否" {
|
|
|
|
|
// v = 0
|
|
|
|
|
//}
|
2022-02-14 11:10:58 +00:00
|
|
|
|
|
|
|
|
|
if strings.Index(strV, "%") == len(strV)-1 && len(strV) != 0 {
|
|
|
|
|
v = uploadData.GetFloat64(strings.Replace(strV, "%", "", -1)) / 100
|
|
|
|
|
}
|
|
|
|
|
flV := uploadData.GetFloat64(k)
|
|
|
|
|
if flV != 0 && v == 0 {
|
|
|
|
|
v = flV
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-16 20:10:53 +00:00
|
|
|
|
if v == 0 && strV != "否" && strV != "0" {
|
|
|
|
|
v = 1
|
|
|
|
|
}
|
|
|
|
|
//vm.Set(k, v)
|
|
|
|
|
uploadData[k] = v
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
company["upload_data"] = uploadData
|
2022-02-14 11:10:58 +00:00
|
|
|
|
//api采集数据
|
|
|
|
|
collectData := company.GetMap("collect_data")
|
|
|
|
|
for k, cv := range collectData {
|
|
|
|
|
if cv == nil {
|
|
|
|
|
vm.Set(k, 0)
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
strV := collectData.GetString(k)
|
|
|
|
|
if strings.Index(strV, "万人民币") != -1 {
|
2022-02-16 20:10:53 +00:00
|
|
|
|
strV = strings.Replace(strV, "万人民币", "", -1)
|
2022-02-14 11:10:58 +00:00
|
|
|
|
}
|
2022-02-16 20:10:53 +00:00
|
|
|
|
//vm.Set(k, strV)
|
|
|
|
|
collectData[k] = strV
|
|
|
|
|
|
2022-02-14 11:10:58 +00:00
|
|
|
|
}
|
2022-02-16 20:10:53 +00:00
|
|
|
|
company["collect_data"] = collectData
|
2022-02-14 11:10:58 +00:00
|
|
|
|
//api采集数据
|
|
|
|
|
analyseData := company.GetMap("analyse")
|
|
|
|
|
if analyseData == nil {
|
|
|
|
|
analyseData = Map{}
|
|
|
|
|
company["analyse"] = analyseData
|
|
|
|
|
}
|
2022-02-16 20:10:53 +00:00
|
|
|
|
//for k, cv := range analyseData {
|
|
|
|
|
// vm.Set(k, cv)
|
|
|
|
|
//}
|
|
|
|
|
}
|
2022-02-14 11:10:58 +00:00
|
|
|
|
|
2022-02-16 20:10:53 +00:00
|
|
|
|
for k, _ := range companys[0].GetMap("analyse") {
|
|
|
|
|
|
|
|
|
|
if strings.Contains(k, "排名") {
|
2022-02-14 11:10:58 +00:00
|
|
|
|
continue
|
|
|
|
|
}
|
2022-02-16 20:10:53 +00:00
|
|
|
|
res, e := vm.Run(`res=hmax("` + k + `")`)
|
|
|
|
|
if e == nil {
|
|
|
|
|
totalData[k+"最大值"] = ObjToFloat64(res.String())
|
2022-02-14 11:10:58 +00:00
|
|
|
|
}
|
2022-02-16 20:10:53 +00:00
|
|
|
|
res, e = vm.Run(`res=hmin("` + k + `")`)
|
|
|
|
|
if e == nil {
|
|
|
|
|
totalData[k+"最小值"] = ObjToFloat64(res.String())
|
|
|
|
|
}
|
|
|
|
|
res, e = vm.Run(`res=haverage("` + k + `")`)
|
|
|
|
|
if e == nil {
|
|
|
|
|
totalData[k+"平均值"] = ObjToFloat64(res.String())
|
|
|
|
|
}
|
|
|
|
|
res, e = vm.Run(`res=vcount("` + k + `")`)
|
|
|
|
|
if e == nil {
|
|
|
|
|
totalData[k+"总值"] = ObjToFloat64(res.String())
|
|
|
|
|
}
|
|
|
|
|
res, e = vm.Run(`res=count("` + k + `")`)
|
|
|
|
|
if e == nil {
|
|
|
|
|
totalData[k+"总数"] = ObjToFloat64(res.String())
|
2022-02-14 11:10:58 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-16 20:10:53 +00:00
|
|
|
|
func ctgTestAnalyse(companys []Map, tag Map, totalData, totalAnalyse Map) {
|
2022-02-14 11:10:58 +00:00
|
|
|
|
cs := append(NewCompanys{}, companys...)
|
|
|
|
|
for _, company := range companys {
|
|
|
|
|
vm := otto.New()
|
|
|
|
|
vm.Set("vcount", func(call otto.FunctionCall) otto.Value {
|
|
|
|
|
if call.Argument(0).IsUndefined() {
|
|
|
|
|
val, _ := vm.ToValue(0)
|
|
|
|
|
return val
|
|
|
|
|
}
|
|
|
|
|
key := call.Argument(0).String()
|
|
|
|
|
AnalyseTypeName := "upload_data"
|
|
|
|
|
if company.GetMap(AnalyseTypeName)[key] == nil {
|
|
|
|
|
AnalyseTypeName = "analyse"
|
|
|
|
|
}
|
|
|
|
|
num := float64(0)
|
|
|
|
|
for _, v := range cs {
|
|
|
|
|
if v.GetMap(AnalyseTypeName).GetFloat64(key) > 0 {
|
|
|
|
|
//num++
|
|
|
|
|
num = num + v.GetMap(AnalyseTypeName).GetFloat64(key)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
val, _ := vm.ToValue(num)
|
|
|
|
|
return val
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
vm.Set("count", func(call otto.FunctionCall) otto.Value {
|
|
|
|
|
if call.Argument(0).IsUndefined() {
|
|
|
|
|
val, _ := vm.ToValue(len(cs))
|
|
|
|
|
return val
|
|
|
|
|
}
|
|
|
|
|
key := call.Argument(0).String()
|
|
|
|
|
AnalyseTypeName := "upload_data"
|
|
|
|
|
if company.GetMap(AnalyseTypeName)[key] == nil {
|
|
|
|
|
AnalyseTypeName = "analyse"
|
|
|
|
|
}
|
|
|
|
|
num := 0
|
|
|
|
|
for _, v := range cs {
|
|
|
|
|
if v.GetMap(AnalyseTypeName).GetFloat64(key) > 0 {
|
|
|
|
|
num++
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
val, _ := vm.ToValue(num)
|
|
|
|
|
return val
|
|
|
|
|
})
|
|
|
|
|
//上传数据
|
|
|
|
|
uploadData := company.GetMap("upload_data")
|
|
|
|
|
for k, _ := range uploadData {
|
|
|
|
|
strV := uploadData.GetString(k)
|
2022-02-16 20:10:53 +00:00
|
|
|
|
strV = strings.Replace(strV, " ", "", -1)
|
2022-02-14 11:10:58 +00:00
|
|
|
|
v := float64(0)
|
2022-02-16 20:10:53 +00:00
|
|
|
|
//if strV == "否" {
|
|
|
|
|
// v = 0
|
|
|
|
|
//}
|
|
|
|
|
if strV == "国家级专精特新" {
|
|
|
|
|
fmt.Println(15545)
|
2022-02-14 11:10:58 +00:00
|
|
|
|
}
|
|
|
|
|
if strings.Index(strV, "%") == len(strV)-1 && len(strV) != 0 {
|
|
|
|
|
v = uploadData.GetFloat64(strings.Replace(strV, "%", "", -1)) / 100
|
|
|
|
|
}
|
|
|
|
|
flV := uploadData.GetFloat64(k)
|
|
|
|
|
if flV != 0 && v == 0 {
|
|
|
|
|
v = flV
|
|
|
|
|
}
|
2022-02-16 20:10:53 +00:00
|
|
|
|
|
|
|
|
|
if v == 0 && strV != "否" && strV != "0" {
|
|
|
|
|
v = 1
|
|
|
|
|
}
|
|
|
|
|
uploadData[k] = v
|
|
|
|
|
|
2022-02-14 11:10:58 +00:00
|
|
|
|
}
|
2022-02-16 20:10:53 +00:00
|
|
|
|
company["upload_data"] = uploadData
|
2022-02-14 11:10:58 +00:00
|
|
|
|
|
|
|
|
|
//api采集数据
|
|
|
|
|
collectData := company.GetMap("collect_data")
|
|
|
|
|
for k, cv := range collectData {
|
|
|
|
|
if cv == nil {
|
|
|
|
|
vm.Set(k, 0)
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
strV := collectData.GetString(k)
|
|
|
|
|
if strings.Index(strV, "万人民币") != -1 {
|
2022-02-16 20:10:53 +00:00
|
|
|
|
strV = strings.Replace(strV, "万人民币", "", -1)
|
2022-02-14 11:10:58 +00:00
|
|
|
|
}
|
2022-02-16 20:10:53 +00:00
|
|
|
|
collectData[k] = strV
|
|
|
|
|
|
2022-02-14 11:10:58 +00:00
|
|
|
|
}
|
2022-02-16 20:10:53 +00:00
|
|
|
|
company["collect_data"] = collectData
|
2022-02-14 11:10:58 +00:00
|
|
|
|
//api采集数据
|
|
|
|
|
analyseData := company.GetMap("analyse")
|
|
|
|
|
if analyseData == nil {
|
|
|
|
|
analyseData = Map{}
|
|
|
|
|
company["analyse"] = analyseData
|
|
|
|
|
}
|
2022-02-16 20:10:53 +00:00
|
|
|
|
//for k, cv := range analyseData {
|
|
|
|
|
// vm.Set(k, cv)
|
|
|
|
|
//}
|
2022-02-14 11:10:58 +00:00
|
|
|
|
//totalData:=Map{}
|
|
|
|
|
//analyse
|
|
|
|
|
|
|
|
|
|
//for _,v:=range cmds{
|
|
|
|
|
vm.Set("res", nil)
|
|
|
|
|
_, e := vm.Run(tag.GetString("cmd"))
|
|
|
|
|
if e != nil {
|
|
|
|
|
fmt.Println(e)
|
|
|
|
|
totalData[tag.GetString("name")] = 0
|
|
|
|
|
vm.Set(tag.GetString("name"), 0)
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
result, e := vm.Get("res")
|
|
|
|
|
if e != nil {
|
|
|
|
|
fmt.Println(e)
|
|
|
|
|
totalData[tag.GetString("name")] = 0
|
|
|
|
|
vm.Set(tag.GetString("name"), 0)
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if result.String() == ObjToStr(ObjToFloat64(result.String())) {
|
|
|
|
|
totalData[tag.GetString("name")] = ObjToFloat64(result.String())
|
|
|
|
|
if totalAnalyse.GetMap("home_data").GetCeilFloat64(tag.GetString("name")) == 0 {
|
|
|
|
|
totalData[tag.GetString("name")+"比值"] = 0
|
|
|
|
|
} else {
|
|
|
|
|
totalData[tag.GetString("name")+"比值"] = ObjToFloat64(result.String()) / totalAnalyse.GetMap("home_data").GetCeilFloat64(tag.GetString("name"))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else if result.String() == "NaN" {
|
|
|
|
|
totalData[tag.GetString("name")] = 0
|
|
|
|
|
totalData[tag.GetString("name")+"比值"] = 0
|
2022-02-16 20:10:53 +00:00
|
|
|
|
} else if result.String() == "Infinity" {
|
|
|
|
|
totalData[tag.GetString("name")] = 0
|
|
|
|
|
totalData[tag.GetString("name")+"比值"] = 0
|
2022-02-14 11:10:58 +00:00
|
|
|
|
} else {
|
|
|
|
|
totalData[tag.GetString("name")] = result.String()
|
|
|
|
|
//totalData[tag.GetString("name")+"比值"]=0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
vm.Set(tag.GetString("name"), totalData[tag.GetString("name")])
|
|
|
|
|
}
|
2022-01-22 08:12:02 +00:00
|
|
|
|
|
2022-02-14 11:10:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var TestCtr = Ctr{
|
2022-01-22 08:12:02 +00:00
|
|
|
|
"test": func(this *Context) {
|
2022-02-14 11:10:58 +00:00
|
|
|
|
//data := excel1()
|
|
|
|
|
//this.Display(0, data)
|
|
|
|
|
fmt.Println(unicode.IsPunct(rune(')')))
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
"industry_analyse": func(this *Context) {
|
|
|
|
|
orgId := 1
|
|
|
|
|
industrys := this.Db.Select("industry_analyse", "id,name", Map{"org_id": orgId})
|
|
|
|
|
totalAnalyse := this.Db.Get("org_analyse", "*", Map{"org_id": orgId})
|
|
|
|
|
tagCompany := this.Db.Select("tag", "*", Map{"type": 4, "ORDER": "`sort` ASC"})
|
|
|
|
|
|
|
|
|
|
for _, industry := range industrys {
|
|
|
|
|
id := industry.GetCeilInt("id")
|
|
|
|
|
companys := this.Db.Select("industry", Map{"[><]company": "company.industry_id=industry.id"},
|
|
|
|
|
"company.id,company.gs,company.level,company.score,company.upload_data,company.analyse,company.industry_id", Map{"industry.id": id})
|
|
|
|
|
|
|
|
|
|
for _, v := range companys {
|
|
|
|
|
//上传数据
|
|
|
|
|
v["upload_data"] = v.GetMap("upload_data")
|
|
|
|
|
v["collect_data"] = v.GetMap("collect_data")
|
|
|
|
|
v["analyse"] = v.GetMap("analyse")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//cs := append(NewCompanys{}, companys...)
|
|
|
|
|
ctgAn := Map{}
|
|
|
|
|
for _, tag := range tagCompany {
|
2022-02-16 20:10:53 +00:00
|
|
|
|
ctgTestAnalyse(companys, tag, ctgAn, totalAnalyse)
|
2022-02-14 11:10:58 +00:00
|
|
|
|
//fmt.Println(data)
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-16 20:10:53 +00:00
|
|
|
|
//ctgAn := ctgTestAnalyse(companys, totalAnalyse)
|
2022-02-14 11:10:58 +00:00
|
|
|
|
data := Map{
|
|
|
|
|
"modify_time": time.Now().Unix(),
|
|
|
|
|
"data": ctgAn.ToJsonString(),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.Db.Update("industry_analyse", data, Map{"AND": Map{"org_id": orgId, "industry_id": id}})
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
this.Display(0, industrys)
|
|
|
|
|
},
|
|
|
|
|
"total_Analyse": func(this *Context) {
|
|
|
|
|
|
|
|
|
|
orgId := 1
|
|
|
|
|
companys := this.Db.Select("company", "*")
|
|
|
|
|
for _, v := range companys {
|
|
|
|
|
//上传数据
|
|
|
|
|
v["upload_data"] = v.GetMap("upload_data")
|
|
|
|
|
v["collect_data"] = v.GetMap("collect_data")
|
|
|
|
|
v["analyse"] = v.GetMap("analyse")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tagCompany := this.Db.Select("tag", "*", Map{"type": 4, "ORDER": "`sort` ASC"})
|
|
|
|
|
//cs := append(NewCompanys{}, companys...)
|
|
|
|
|
totalData := Map{}
|
|
|
|
|
for _, tag := range tagCompany {
|
2022-02-16 20:10:53 +00:00
|
|
|
|
totalTestAnalyse(companys, tag, totalData)
|
2022-02-14 11:10:58 +00:00
|
|
|
|
//fmt.Println(data)
|
|
|
|
|
}
|
2022-02-16 20:10:53 +00:00
|
|
|
|
totalAnalyse1(companys, totalData)
|
|
|
|
|
//home_data, six_item_data, three_item_data, n_item_data := totalTestAnalyse(companys)
|
2022-02-14 11:10:58 +00:00
|
|
|
|
org := this.Db.Get("org", "*", Map{"id": orgId})
|
|
|
|
|
//fmt.Println(six_item_data.ToJsonString())
|
2022-02-16 20:10:53 +00:00
|
|
|
|
fmt.Println(totalData)
|
2022-02-14 11:10:58 +00:00
|
|
|
|
data := Map{
|
|
|
|
|
"name": org.GetString("name"),
|
|
|
|
|
"home_data": totalData.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"] = 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})
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-22 08:12:02 +00:00
|
|
|
|
this.Display(0, data)
|
2022-02-14 11:10:58 +00:00
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
"analyse": func(this *Context) {
|
|
|
|
|
|
|
|
|
|
companys := this.Db.Select("company", "*")
|
|
|
|
|
for _, v := range companys {
|
|
|
|
|
//上传数据
|
|
|
|
|
v["upload_data"] = v.GetMap("upload_data")
|
|
|
|
|
v["collect_data"] = v.GetMap("collect_data")
|
|
|
|
|
v["analyse"] = v.GetMap("analyse")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tagCompany := this.Db.Select("tag", "*", Map{"type": 2, "ORDER": "`sort` ASC"})
|
|
|
|
|
//cs := append(NewCompanys{}, companys...)
|
|
|
|
|
for _, tag := range tagCompany {
|
2022-02-16 20:10:53 +00:00
|
|
|
|
TestAnalyse(companys, tag)
|
2022-02-14 11:10:58 +00:00
|
|
|
|
//fmt.Println(data)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, c := range companys {
|
|
|
|
|
this.Db.Update("company", Map{"analyse": c.GetString("analyse")}, Map{"id": c.GetCeilInt("id")})
|
|
|
|
|
fmt.Println(c["analyse"])
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.Display(0, len(companys))
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
"jstest": func(this *Context) {
|
|
|
|
|
vm := otto.New()
|
|
|
|
|
vm.Run(`
|
|
|
|
|
console.log("845458454" ); // 4
|
|
|
|
|
abc = 2 + 2;
|
|
|
|
|
console.log("The value of abc is " + abc); // 4
|
|
|
|
|
`)
|
|
|
|
|
//if value, err := vm.Get("abc"); err == nil {
|
|
|
|
|
// if value_int, err := value.ToInteger(); err == nil {
|
|
|
|
|
// fmt.Printf("", value_int, err)
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
vm.Set("def", 11)
|
|
|
|
|
vm.Run(`
|
|
|
|
|
console.log("The value of def is " + def);
|
|
|
|
|
// The value of def is 11
|
|
|
|
|
`)
|
|
|
|
|
vm.Set("xyzzy", "Nothing happens.")
|
|
|
|
|
vm.Run(`
|
|
|
|
|
console.log(xyzzy.length); // 16
|
|
|
|
|
`)
|
|
|
|
|
|
|
|
|
|
value, _ := vm.Run("xyzzy.length")
|
|
|
|
|
//{
|
|
|
|
|
// // value is an int64 with a value of 16
|
|
|
|
|
// value, _ := value.ToInteger()
|
|
|
|
|
//}
|
|
|
|
|
fmt.Println(value.ToInteger())
|
|
|
|
|
_, err := vm.Run("abcdefghijlmnopqrstuvwxyz.length")
|
|
|
|
|
if err != nil {
|
|
|
|
|
// err = ReferenceError: abcdefghijlmnopqrstuvwxyz is not defined
|
|
|
|
|
// If there is an error, then value.IsUndefined() is true
|
|
|
|
|
//...
|
|
|
|
|
fmt.Println(err)
|
|
|
|
|
}
|
|
|
|
|
vm.Set("sayHello", func(call otto.FunctionCall) otto.Value {
|
|
|
|
|
fmt.Printf("Hello, %s.\n", call.Argument(0).String())
|
|
|
|
|
return otto.Value{}
|
|
|
|
|
})
|
|
|
|
|
result, _ := vm.Run(`
|
|
|
|
|
sayHello("Xyzzy"); // Hello, Xyzzy.
|
|
|
|
|
sayHello(); // Hello, undefined
|
|
|
|
|
|
|
|
|
|
result = twoPlus(2.0); // 4
|
|
|
|
|
`)
|
|
|
|
|
fmt.Println(result.String())
|
|
|
|
|
|
2022-01-22 08:12:02 +00:00
|
|
|
|
},
|
|
|
|
|
"tt": func(this *Context) {
|
|
|
|
|
tag_ctg := this.Db.Get("tag_ctg", "id", Map{"name": "企业数据分析"})
|
|
|
|
|
if tag_ctg == nil {
|
|
|
|
|
tag_ctg = Map{}
|
|
|
|
|
tag_ctg["id"] = this.Db.Insert("tag_ctg", Map{"name": "企业数据分析",
|
|
|
|
|
"admin_id": this.Session("admin_id").ToInt(),
|
|
|
|
|
"create_time": time.Now().Unix(),
|
|
|
|
|
"modify_time": time.Now().Unix()})
|
|
|
|
|
}
|
|
|
|
|
id := tag_ctg.GetCeilInt("id")
|
|
|
|
|
if id == 0 {
|
|
|
|
|
this.Display(3, "分类数据上传失败")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
num := 0
|
|
|
|
|
for k, v := range ADataType {
|
|
|
|
|
tag := this.Db.Get("tag", "id", Map{"sn": k})
|
|
|
|
|
if tag == nil {
|
|
|
|
|
tag = Map{"sn": k, "name": v, "tag_ctg_id": id, "create_time": time.Now().Unix(),
|
|
|
|
|
"modify_time": time.Now().Unix()}
|
|
|
|
|
if strings.Index(k, "DF") == len(k)-2 {
|
|
|
|
|
tag["unit"] = "分"
|
|
|
|
|
}
|
|
|
|
|
tagId := this.Db.Insert("tag", tag)
|
|
|
|
|
if tagId != 0 {
|
|
|
|
|
num++
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.Display(0, num)
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
"api": func(this *Context) {
|
|
|
|
|
//curl -i --get --include 'http://api.81api.com/getCompanyBaseInfo/小米科技有限责任公司/' -H 'Authorization:APPCODE 你自己的AppCode'
|
|
|
|
|
//aliyun.DefaultCompany.Init("06c6a07e89dd45c88de040ee1489eef7")
|
|
|
|
|
//data,err:=aliyun.DefaultCompany.GetCompanyBaseInfo("小米科技有限责任公司")
|
|
|
|
|
//fmt.Println(data)
|
|
|
|
|
//if err!=nil{
|
|
|
|
|
// this.Display(4,err)
|
|
|
|
|
// return
|
|
|
|
|
//}
|
|
|
|
|
|
2022-01-26 03:45:17 +00:00
|
|
|
|
data1, _ := baidu.DefaultBaiDuMap.GetPosition("简阳市东溪镇奎星路28号", "")
|
2022-01-22 08:12:02 +00:00
|
|
|
|
|
|
|
|
|
this.Display(0, ObjToMap(data1))
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
"temp": func(this *Context) {
|
|
|
|
|
count := 0
|
|
|
|
|
for true {
|
|
|
|
|
|
|
|
|
|
data := this.Db.Get("area_copy", "id,parent_id,`index`,parent_code", Map{"index": nil, "ORDER": "`level` ASC"})
|
|
|
|
|
|
|
|
|
|
if data == nil {
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
count++
|
|
|
|
|
//if data.GetCeilInt("parent_id")==0{
|
|
|
|
|
// data["parent_id"]=3750
|
|
|
|
|
//}
|
|
|
|
|
parentData := this.Db.Get("area_copy", "id,parent_id,`index`", Map{"area_code": data.GetString("parent_code")})
|
|
|
|
|
if parentData == nil {
|
|
|
|
|
this.Db.Update("area_copy", Map{"index": data.GetString("id") + ","}, Map{"id": data.GetString("id")})
|
|
|
|
|
} else {
|
|
|
|
|
this.Db.Update("area_copy", Map{"index": parentData.GetString("index") + data.GetString("id") + ",", "parent_id": parentData["id"]}, Map{"id": data.GetString("id")})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
this.Display(0, count)
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
"tempctg": func(this *Context) {
|
|
|
|
|
dataBytes, e := ioutil.ReadFile("2017.json")
|
|
|
|
|
if e != nil {
|
|
|
|
|
this.Display(4, e)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
data := ObjToSlice(string(dataBytes))
|
|
|
|
|
|
|
|
|
|
for k, _ := range data {
|
|
|
|
|
ins := data.GetMap(k)
|
|
|
|
|
ins["level"] = 1
|
|
|
|
|
id := this.Db.Insert("category", Map{"name": ins.GetString("name"),
|
|
|
|
|
"code": ins.GetString("code"),
|
|
|
|
|
"level": ins["level"],
|
|
|
|
|
"parent_id": 1,
|
|
|
|
|
"admin_id": this.Session("admin_id").ToInt(),
|
|
|
|
|
"create_time": time.Now().Unix(),
|
|
|
|
|
"modify_time": time.Now().Unix(),
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
if id != 0 {
|
|
|
|
|
ins["id"] = id
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ins["index"] = ",1," + ObjToStr(id) + ","
|
|
|
|
|
this.Db.Update("category", Map{"index": ins["index"]}, Map{"id": ins["id"]})
|
|
|
|
|
|
|
|
|
|
run(ins, this)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func excel1() Slice {
|
|
|
|
|
xlsx, err := excelize.OpenFile("tpt/piduqu.xlsx")
|
|
|
|
|
if err != nil {
|
|
|
|
|
fmt.Println(err)
|
|
|
|
|
os.Exit(1)
|
|
|
|
|
}
|
|
|
|
|
list := xlsx.GetSheetList()
|
|
|
|
|
data := Slice{}
|
|
|
|
|
for _, v := range list {
|
|
|
|
|
rows, e := xlsx.GetRows(v)
|
|
|
|
|
fmt.Println(rows, e)
|
|
|
|
|
data = append(data, rows)
|
|
|
|
|
|
|
|
|
|
//for k1,v1:=range rows{
|
|
|
|
|
//
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return data
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func run(ins Map, this *Context) {
|
|
|
|
|
cs := ins.GetSlice("children")
|
|
|
|
|
if cs == nil {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
for ck, _ := range cs {
|
|
|
|
|
|
|
|
|
|
cins := cs.GetMap(ck)
|
|
|
|
|
cins["level"] = ins.GetCeilInt("level") + 1
|
|
|
|
|
id := this.Db.Insert("category", Map{"name": cins.GetString("name"),
|
|
|
|
|
"code": cins.GetString("code"),
|
|
|
|
|
"level": cins["level"],
|
|
|
|
|
"parent_id": ins["id"],
|
|
|
|
|
"admin_id": this.Session("admin_id").ToInt(),
|
|
|
|
|
"create_time": time.Now().Unix(),
|
|
|
|
|
"modify_time": time.Now().Unix(),
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
if id != 0 {
|
|
|
|
|
cins["id"] = id
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cins["index"] = ins.GetString("index") + ObjToStr(id) + ","
|
|
|
|
|
this.Db.Update("category", Map{"index": cins["index"]}, Map{"id": cins["id"]})
|
|
|
|
|
|
|
|
|
|
run(cins, this)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|