更新研发

This commit is contained in:
hoteas
2022-01-26 11:45:17 +08:00
parent cea7e57409
commit 3b11f44915
40 changed files with 10212 additions and 23 deletions
+100 -15
View File
@@ -18,7 +18,12 @@ import (
var CompanyInOutCtr = Ctr{
"upload": func(this *Context) {
//orgId := ObjToInt(this.Req.FormValue("org_id"))
//if orgId == 0 {
// this.Display(3, "参数错误")
// return
//}
orgId := 3
//读取网络文件
fi, fheader, err := this.Req.FormFile("file")
if err != nil {
@@ -63,7 +68,7 @@ var CompanyInOutCtr = Ctr{
return
}
err = decodeData2Sql(data[0], this)
err = decodeData2Sql(data[0], this, orgId)
if err != nil {
this.Display(4, err)
return
@@ -107,13 +112,16 @@ var CompanyInOutCtr = Ctr{
},
"total_analyse": func(this *Context) {
orgId := 3
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.ToJsonString())
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(),
@@ -122,7 +130,7 @@ var CompanyInOutCtr = Ctr{
}
org_analyse := this.Db.Get("org_analyse", "id", Map{"org_id": 3})
if org_analyse == nil {
data["name"] = time.Now().Format("2006-01-02 15:04") + "创建"
data["name"] = org.GetString("name")
data["org_id"] = 3
data["create_time"] = time.Now().Unix()
id := this.Db.Insert("org_analyse", data)
@@ -136,7 +144,8 @@ var CompanyInOutCtr = Ctr{
},
"category_analyse": func(this *Context) {
orgId := 3
org := this.Db.Get("org", "*", Map{"id": orgId})
categoryIDS := []int{
1369, //电子行业
799, //航空航天
@@ -160,12 +169,13 @@ var CompanyInOutCtr = Ctr{
"company.id,company.gs,company.level,company.score,company.upload_data,company.analyse,company.category_id", Map{"category.index[~]": "," + ObjToStr(id) + ","})
ctgAn := ctgAnalyse(companys, totalAnalyse)
data := Map{
"name": org.GetString("name"),
"modify_time": time.Now().Unix(),
"data": ctgAn.ToJsonString(),
}
ctgAnalyse := this.Db.Get("category_analyse", "id", Map{"AND": Map{"org_id": 3, "category_id": id}})
if ctgAnalyse == nil {
data["name"] = time.Now().Format("2006-01-02 15:04") + "创建"
data["name"] = org.GetString("name")
data["org_id"] = 3
data["category_id"] = id
data["create_time"] = time.Now().Unix()
@@ -178,6 +188,27 @@ var CompanyInOutCtr = Ctr{
}
this.Display(0, categoryIDS)
},
"industry_analyse": func(this *Context) {
orgId := 3
industrys := this.Db.Select("industry_analyse", "id,name", Map{"org_id": orgId})
totalAnalyse := this.Db.Get("org_analyse", "*", Map{"org_id": 3})
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})
ctgAn := ctgAnalyse(companys, totalAnalyse)
data := Map{
"modify_time": time.Now().Unix(),
"data": ctgAn.ToJsonString(),
}
this.Db.Update("industry_analyse", data, Map{"AND": Map{"org_id": 3, "industry_id": id}})
}
this.Display(0, industrys)
},
}
//6+3+n及首页数据分析
@@ -245,13 +276,16 @@ func ctgAnalyse(datas []Map, totalAnalyse Map) Map {
resTotal["规上企业数"] = resTotal.GetInt("规上企业数") + 1
}
if upload_data.GetString("IEDCJPJSSJGZ") != "" && upload_data.GetString("IEDCJPJSSJGZ") != "无" {
if upload_data.GetFloat64("IEDCXZTZQK") > 0 {
resTotal["技术改造投资备案数"] = resTotal.GetInt("技术改造投资备案数") + 1
}
if upload_data.GetFloat64("IEDCXZTZQK") > 0 {
resTotal["固定资产投入数"] = resTotal.GetInt("固定资产投入数") + 1
}
if upload_data.GetFloat64("IEDCXZTZQK") > 0 {
resTotal["固定资产投入"] = resTotal.GetFloat64("固定资产投入") + upload_data.GetFloat64("IEDCXZTZQK")
}
//技术中心
if (upload_data.GetString("IEDCGJJQYJSZX") != "" && upload_data.GetString("IEDCGJJQYJSZX") != "无") || //国家级
@@ -416,13 +450,16 @@ func totalAnalyse(datas []Map) (Map, Map, Map, Map) {
resTotal["规上企业数"] = resTotal.GetInt("规上企业数") + 1
}
if upload_data.GetString("IEDCJPJSSJGZ") != "" && upload_data.GetString("IEDCJPJSSJGZ") != "无" {
if upload_data.GetFloat64("IEDCXZTZQK") > 0 {
resTotal["技术改造投资备案数"] = resTotal.GetInt("技术改造投资备案数") + 1
}
if upload_data.GetFloat64("IEDCXZTZQK") > 0 {
resTotal["固定资产投入数"] = resTotal.GetInt("固定资产投入数") + 1
}
if upload_data.GetFloat64("IEDCXZTZQK") > 0 {
resTotal["固定资产投入"] = resTotal.GetFloat64("固定资产投入") + upload_data.GetFloat64("IEDCXZTZQK")
}
//技术中心
if (upload_data.GetString("IEDCGJJQYJSZX") != "" && upload_data.GetString("IEDCGJJQYJSZX") != "无") || //国家级
@@ -649,11 +686,13 @@ func analyseSort(datas []Map) []Map {
sort6Get := func(指标名称 string, 指标得分名称 string, cs Companys, point float64) Companys {
csLength := len(cs)
analyseTypeName = "analyse"
analyseSortType = 指标名称 //亩均收入得分
sort.Sort(cs)
for k, data := range cs {
v := data.GetMap("analyse")
v[指标名称+"排名"] = k + 1
if ObjToFloat64(k) <= ObjToFloat64(csLength)*0.1 {
v[指标得分名称] = point * 1.0
} else if ObjToFloat64(k) <= ObjToFloat64(csLength)*0.3 {
@@ -690,10 +729,13 @@ func analyseSort(datas []Map) []Map {
csLength := len(cs)
analyseSortType = "IEDCXZTZQK" //技改投资
analyseTypeName = "upload_data"
sort.Sort(cs)
for k, data := range cs {
fmt.Println("dasdas", data.GetString("name"), data.GetMap("upload_data").GetFloat64(analyseSortType))
v := data.GetMap("analyse")
v["JGTZPM"] = k + 1
if ObjToFloat64(k) <= ObjToFloat64(csLength)*0.3 {
v["JGTZDF"] = 5
} else if ObjToFloat64(k) <= ObjToFloat64(csLength)*0.6 {
@@ -709,12 +751,14 @@ func analyseSort(datas []Map) []Map {
v["ZDF"] = v.GetFloat64("NZDF") + v.GetFloat64("SXZBDF") + v.GetFloat64("NXZBDF")
}
analyseTypeName = "analyse"
analyseSortType = "ZDF" //技改投资
sort.Sort(cs)
for k, data := range cs {
v := data.GetMap("analyse")
v["ZPM"] = k + 1
v["ZQYS"] = len(cs)
if ObjToFloat64(k) <= ObjToFloat64(csLength)*0.1 {
v["PJ"] = "A"
} else if ObjToFloat64(k) <= ObjToFloat64(csLength)*0.8 {
@@ -732,6 +776,7 @@ func analyseSort(datas []Map) []Map {
type Companys []Map
var analyseSortType = ""
var analyseTypeName = "analyse"
func (s Companys) Len() int {
return len(s)
@@ -740,10 +785,10 @@ func (s Companys) Swap(i, j int) {
s[i], s[j] = s[j], s[i]
}
func (s Companys) Less(i, j int) bool {
return s[i].GetMap("analyse").GetFloat64(analyseSortType) > s[j].GetMap("analyse").GetFloat64(analyseSortType)
return s[i].GetMap(analyseTypeName).GetFloat64(analyseSortType) > s[j].GetMap(analyseTypeName).GetFloat64(analyseSortType)
}
func decodeData2Sql(table [][]string, this *Context) error {
func decodeData2Sql(table [][]string, this *Context, orgId int) error {
tags := []Map{} //报错所有的tag记录
tagCtgs := []Map{}
for k, v := range table {
@@ -856,6 +901,7 @@ func decodeData2Sql(table [][]string, this *Context) error {
"description": table[3][ck], //第三行对应位置为描述
"unit": table[2][ck],
"admin_id": this.Session("admin_id").ToInt(),
"type": 1,
"sn": sn,
"tag_ctg_id": tagCtgs[ck-1].GetCeilInt("id"),
@@ -905,13 +951,19 @@ func decodeData2Sql(table [][]string, this *Context) error {
"zhnh": rowData["IEDCZHNH"],
"admin_id": this.Session("admin_id").ToInt(),
"upload_data": rowData.ToJsonString(),
"org_id": orgId,
//"create_time": time.Now().Unix(),
"modify_time": time.Now().Unix(),
//"lat": lat,
//"lng": lng,
}
baiduDataStr, _ := baidu.DefaultBaiDuMap.GetPosition(companyData.GetString("address"))
//行业ID
org := this.Db.Get("org", "id,name", Map{"id": orgId})
regin := "全国"
if org != nil {
regin = org.GetString("name")
}
baiduDataStr, _ := baidu.DefaultBaiDuMap.GetPosition(companyData.GetString("address"), regin)
baiduData := ObjToMap(baiduDataStr)
city := Map{}
@@ -938,8 +990,41 @@ func decodeData2Sql(table [][]string, this *Context) error {
companyData["category_id"] = category.GetCeilInt("id")
}
//此处需要优化
companyData["org_id"] = 3
////此处需要优化
//companyData["org_id"] = 3
//产业ID
industry := this.Db.Get("industry", "id", Map{"name": rowData["IEDCCYLB"]})
if industry == nil {
industry = Map{
"admin_id": this.Session("admin_id").ToInt(),
"create_time": time.Now().Unix(),
"modify_time": time.Now().Unix(),
"name": rowData["IEDCCYLB"],
}
id := this.Db.Insert("industry", industry)
industry["id"] = id
}
if industry.GetCeilInt("id") != 0 {
//产业ID
industryAnalyse := this.Db.Get("industry_analyse", "id", Map{"AND": Map{"industry_id": industry.GetCeilInt("id"), "org_id": orgId}})
if industryAnalyse == nil {
industryAnalyse = Map{
"name": rowData["IEDCCYLB"],
"create_time": time.Now().Unix(),
"modify_time": time.Now().Unix(),
"org_id": orgId,
"industry_id": industry.GetCeilInt("id"),
}
if city != nil {
industryAnalyse["city_id"] = city.GetCeilInt("id")
}
this.Db.Insert("industry_analyse", industryAnalyse)
}
companyData["industry_id"] = industry.GetCeilInt("id")
}
company := this.Db.Get("company", "id", Map{"sn": companyData["sn"]})
//没有则创建
+1 -1
View File
@@ -61,7 +61,7 @@ var TestCtr = Ctr{
// return
//}
data1, _ := baidu.DefaultBaiDuMap.GetPosition("简阳市东溪镇奎星路28号")
data1, _ := baidu.DefaultBaiDuMap.GetPosition("简阳市东溪镇奎星路28号", "")
this.Display(0, ObjToMap(data1))