1309 lines
45 KiB
Go
1309 lines
45 KiB
Go
package admin
|
||
|
||
import (
|
||
. "../../../hotime"
|
||
. "../../common"
|
||
"../../dri/baidu"
|
||
"errors"
|
||
"fmt"
|
||
"github.com/chain-zhang/pinyin"
|
||
"github.com/xuri/excelize"
|
||
"io"
|
||
"os"
|
||
"sort"
|
||
"strings"
|
||
"time"
|
||
)
|
||
|
||
var CompanyInOutCtr = Ctr{
|
||
|
||
"upload": func(this *Context) {
|
||
|
||
//读取网络文件
|
||
fi, fheader, err := this.Req.FormFile("file")
|
||
if err != nil {
|
||
this.Display(3, err)
|
||
return
|
||
|
||
}
|
||
filePath := this.Config.GetString("filePath")
|
||
if filePath == "" {
|
||
filePath = "excel/2006/01/02/"
|
||
}
|
||
|
||
path := time.Now().Format(filePath)
|
||
e := os.MkdirAll(this.Config.GetString("tpt")+"/"+path, os.ModeDir)
|
||
|
||
if e != nil {
|
||
this.Display(3, e)
|
||
return
|
||
}
|
||
|
||
filePath = path + Md5(ObjToStr(RandX(100000, 9999999))) + fheader.Filename[strings.LastIndex(fheader.Filename, "."):]
|
||
newFile, e := os.Create(this.Config.GetString("tpt") + "/" + filePath)
|
||
|
||
if e != nil {
|
||
this.Display(3, e)
|
||
return
|
||
}
|
||
|
||
_, e = io.Copy(newFile, fi)
|
||
|
||
if e != nil {
|
||
this.Display(3, e)
|
||
return
|
||
}
|
||
|
||
//this.Display(0, filePath)
|
||
|
||
//读取excel
|
||
data := excel(this.Config.GetString("tpt") + "/" + filePath)
|
||
if len(data) != 1 {
|
||
this.Display(3, "表格不标准,请重新提交")
|
||
return
|
||
}
|
||
|
||
err = decodeData2Sql(data[0], this)
|
||
if err != nil {
|
||
this.Display(4, err)
|
||
return
|
||
}
|
||
|
||
this.Display(0, "上传成功")
|
||
|
||
},
|
||
"analyse": func(this *Context) {
|
||
companys := this.Db.Select("company", "*")
|
||
|
||
for _, v := range companys {
|
||
|
||
data := analyse(v.GetMap("upload_data"))
|
||
|
||
v["analyse"] = data
|
||
}
|
||
|
||
cs := analyseSort(companys)
|
||
for _, v := range cs {
|
||
as := v.GetMap("analyse")
|
||
//v["analyse1"] = 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) {
|
||
companys := this.Db.Select("company", "*")
|
||
|
||
home_data, six_item_data, three_item_data, n_item_data := totalAnalyse(companys)
|
||
|
||
fmt.Println(six_item_data.ToJsonString())
|
||
|
||
data := Map{
|
||
"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": 3})
|
||
if org_analyse == nil {
|
||
data["name"] = time.Now().Format("2006-01-02 15:04") + "创建"
|
||
data["org_id"] = 3
|
||
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": 3})
|
||
}
|
||
|
||
this.Display(0, data)
|
||
|
||
},
|
||
|
||
"category_analyse": func(this *Context) {
|
||
|
||
categoryIDS := []int{
|
||
1369, //电子行业
|
||
799, //航空航天
|
||
481, //生物医药
|
||
990, //绿色能源
|
||
972, //机械制造
|
||
1021, //建材制造
|
||
717, //化工类
|
||
170, //轻工类
|
||
260, //纺织类
|
||
1088, //商贸类
|
||
1424, //投资管理
|
||
903, //配套类
|
||
959, //其他
|
||
}
|
||
totalAnalyse := this.Db.Get("org_analyse", "*", Map{"org_id": 3})
|
||
|
||
for _, id := range categoryIDS {
|
||
|
||
companys := this.Db.Select("company", Map{"[><]category": "company.category_id=category.id"},
|
||
"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{
|
||
"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["org_id"] = 3
|
||
data["category_id"] = id
|
||
data["create_time"] = time.Now().Unix()
|
||
id := this.Db.Insert("category_analyse", data)
|
||
data["id"] = id
|
||
} else {
|
||
this.Db.Update("category_analyse", data, Map{"AND": Map{"org_id": 3, "category_id": id}})
|
||
}
|
||
|
||
}
|
||
this.Display(0, categoryIDS)
|
||
},
|
||
}
|
||
|
||
//6+3+n及首页数据分析
|
||
func ctgAnalyse(datas []Map, totalAnalyse Map) Map {
|
||
home_data := totalAnalyse.GetMap("home_data")
|
||
|
||
resTotal := Map{
|
||
//经济效益
|
||
"区域生产总值": "暂无",
|
||
"区域企业总数": len(datas),
|
||
|
||
"梯度培育企业数": "暂无",
|
||
|
||
"上市企业数": "暂无",
|
||
"征地企业数/租赁企业数": "暂无",
|
||
"征地企业总面积": "暂无",
|
||
"租赁企业总面积": "暂无",
|
||
"厂房总面积": "暂无",
|
||
|
||
"楼宇总面积": "暂无",
|
||
"办公楼总面积": "暂无",
|
||
"研发楼总面积": "暂无",
|
||
|
||
"区域综合用电": "暂无",
|
||
"区域综合用水": "暂无",
|
||
|
||
"研究生及以上学历人数": "暂无",
|
||
"本科学历人数": "暂无",
|
||
"大专学历人数": "暂无",
|
||
|
||
"大专以下学历人数": "暂无",
|
||
"区域职工平均年收入": "暂无",
|
||
|
||
"技术证书持有人数": "暂无",
|
||
|
||
"拥有环境管理体系数": "暂无",
|
||
"拥有职业健康体系数": "暂无",
|
||
|
||
"属于本区重点企业配套数": "无",
|
||
"宿舍总面积": "无",
|
||
}
|
||
|
||
for _, v := range datas {
|
||
analyse := v.GetMap("analyse")
|
||
upload_data := v.GetMap("upload_data")
|
||
|
||
resTotal["区域经营收入"] = resTotal.GetFloat64("区域经营收入") + upload_data.GetFloat64("IEDC2NYYSR")
|
||
resTotal["区域纳税总值"] = resTotal.GetFloat64("区域纳税总值") + upload_data.GetFloat64("IEDCYNSJ")
|
||
resTotal["区域资产总额"] = resTotal.GetFloat64("区域资产总额") + upload_data.GetFloat64("IEDCZCZE")
|
||
|
||
if upload_data.GetString("IEDC“DJS”QY") != "" && upload_data.GetString("IEDC“DJS”QY") != "无" {
|
||
resTotal["独角兽企业数"] = resTotal.GetInt("独角兽企业数") + 1
|
||
}
|
||
if upload_data.GetString("IEDC“DL”QY") != "" && upload_data.GetString("IEDC“DL”QY") != "无" {
|
||
resTotal["瞪羚企业数"] = resTotal.GetInt("瞪羚企业数") + 1
|
||
}
|
||
|
||
//专精特新企业数
|
||
if analyse.GetInt("ZJTXQLDF") >= 6 {
|
||
resTotal["专精特新企业数"] = resTotal.GetInt("专精特新企业数") + 1
|
||
}
|
||
|
||
//规上企业数
|
||
if v.GetInt("gs") == 1 {
|
||
resTotal["规上企业数"] = resTotal.GetInt("规上企业数") + 1
|
||
}
|
||
|
||
if upload_data.GetString("IEDCJPJSSJGZ") != "" && upload_data.GetString("IEDCJPJSSJGZ") != "无" {
|
||
resTotal["技术改造投资备案数"] = resTotal.GetInt("技术改造投资备案数") + 1
|
||
}
|
||
|
||
if upload_data.GetFloat64("IEDCXZTZQK") > 0 {
|
||
resTotal["固定资产投入数"] = resTotal.GetInt("固定资产投入数") + 1
|
||
}
|
||
|
||
//技术中心
|
||
if (upload_data.GetString("IEDCGJJQYJSZX") != "" && upload_data.GetString("IEDCGJJQYJSZX") != "无") || //国家级
|
||
(upload_data.GetString("IEDCSJQYJSZX") != "" && upload_data.GetString("IEDCSJQYJSZX") != "无") || //省级
|
||
(upload_data.GetString("IEDCSJQYJSZX0") != "" && upload_data.GetString("IEDCSJQYJSZX0") != "无") {
|
||
resTotal["企业技术中心数"] = resTotal.GetInt("企业技术中心数") + 1
|
||
}
|
||
//工程技术中心
|
||
if (upload_data.GetString("IEDCSJGCJSZX0") != "" && upload_data.GetString("IEDCSJQYJSZX") != "无") ||
|
||
(upload_data.GetString("IEDCGJJGCJSZX") != "" && upload_data.GetString("IEDCGJJGCJSZX") != "无") || //国家级
|
||
(upload_data.GetString("IEDCSJGCJSZX") != "" && upload_data.GetString("IEDCSJGCJSZX") != "无") { //省级
|
||
|
||
resTotal["工程技术中心数"] = resTotal.GetInt("工程技术中心数") + 1
|
||
}
|
||
|
||
if upload_data.GetString("IEDCGXJSQY") != "" && upload_data.GetString("IEDCGXJSQY") != "否" {
|
||
resTotal["高新技术企业数"] = resTotal.GetInt("高新技术企业数") + 1
|
||
|
||
}
|
||
|
||
if upload_data.GetString("IEDCQYCPJRBDQMYCPMLQY") != "" && upload_data.GetString("IEDCQYCPJRBDQMYCPMLQY") != "无" {
|
||
resTotal["知名品牌数"] = resTotal.GetInt("知名品牌数") + 1
|
||
}
|
||
|
||
if upload_data.GetString("IEDCST(T)SPC、SBCQY") != "" && upload_data.GetString("IEDCST(T)SPC、SBCQY") != "无" {
|
||
resTotal["首台套/首批次/首版次数"] = resTotal.GetInt("首台套/首批次/首版次数") + 1
|
||
|
||
}
|
||
|
||
resTotal["知识产权数"] = resTotal.GetInt("知识产权数") + upload_data.GetInt("IEDCPGJZL") +
|
||
upload_data.GetInt("IEDCFMZL") + upload_data.GetInt("IEDCSYXXZL") +
|
||
upload_data.GetInt("IEDCWGSJZL")
|
||
|
||
resTotal["区域工业土地总面积"] = resTotal.GetFloat64("区域工业土地总面积") + upload_data.GetFloat64("IEDCYDMJ")
|
||
|
||
resTotal["区域综合用煤"] = resTotal.GetFloat64("区域综合用煤") + upload_data.GetFloat64("IEDCZHNH")
|
||
|
||
resTotal["区域总人数"] = resTotal.GetInt("区域总人数") + upload_data.GetInt("IEDCSBRS")
|
||
|
||
resTotal["产业人才数"] = resTotal.GetInt("产业人才数") + upload_data.GetInt("IEDCCYRC")
|
||
|
||
if upload_data.GetString("IEDCHBJC、HBCCZBFXWT") != "" && upload_data.GetString("IEDCHBJC、HBCCZBFXWT") != "无" {
|
||
resTotal["环保抽查处理数"] = resTotal.GetInt("环保抽查处理数") + 1
|
||
}
|
||
|
||
if upload_data.GetString("IEDCFXAQFXYH") != "" && upload_data.GetString("IEDCFXAQFXYH") != "无" {
|
||
resTotal["安全抽查隐患处理数"] = resTotal.GetInt("安全抽查隐患处理数") + 1
|
||
}
|
||
|
||
if upload_data.GetString("IEDCFSAQSG") != "" && upload_data.GetString("IEDCFSAQSG") != "无" {
|
||
resTotal["亡人事故数"] = resTotal.GetInt("亡人事故数") + 1
|
||
}
|
||
|
||
if upload_data.GetString("IEDCFXYHSYKTXJS") != "" && upload_data.GetString("IEDCFXYHSYKTXJS") != "无" {
|
||
resTotal["拥有安全管理体系数"] = resTotal.GetInt("拥有安全管理体系数") + 1
|
||
}
|
||
|
||
if upload_data.GetString("IEDCQYSCBZHJS") == "达标" {
|
||
resTotal["拥有质量管理体系数"] = resTotal.GetInt("拥有质量管理体系数") + 1
|
||
}
|
||
|
||
if upload_data.GetString("IEDCSJ1HZDQY、Q(S)XZDQY") != "" && upload_data.GetString("IEDCSJ1HZDQY、Q(S)XZDQY") != "否" {
|
||
resTotal["区域100户重点企业数"] = resTotal.GetInt("区域100户重点企业数") + 1
|
||
}
|
||
|
||
if upload_data.GetString("IEDCFHDQZDCY") != "" && upload_data.GetString("IEDCFHDQZDCY") != "否" {
|
||
resTotal["符合本区重点发展产业数"] = resTotal.GetInt("符合本区重点发展产业数") + 1
|
||
}
|
||
|
||
if upload_data.GetString("IEDCFHDQZDCY") != "" && upload_data.GetString("IEDCFHDQZDCY") != "否" {
|
||
resTotal["属于本区重点企业配套数"] = resTotal.GetInt("属于本区重点企业配套数") + 1
|
||
}
|
||
resTotal["企业社保人数"] = resTotal.GetFloat64("企业社保人数") + upload_data.GetFloat64("IEDCSBRS")
|
||
resTotal["企业研发费用"] = resTotal.GetFloat64("企业研发费用") + upload_data.GetFloat64("IEDCNYFFY")
|
||
|
||
resTotal["企业总能耗"] = resTotal.GetFloat64("企业总能耗") + upload_data.GetFloat64("IEDCZHNH")
|
||
resTotal["企业主要污染物排放量"] = resTotal.GetFloat64("企业主要污染物排放量") + upload_data.GetFloat64("IEDCZYWRWPFDL")
|
||
|
||
}
|
||
resTotalNew := Map{}
|
||
for k, _ := range resTotal {
|
||
|
||
if resTotal.GetString(k) != "暂无" {
|
||
resTotalNew[k] = resTotal.GetFloat64(k)
|
||
resTotalNew[k+"比值"] = resTotal.GetFloat64(k) / home_data.GetFloat64(k)
|
||
if resTotalNew.GetFloat64(k+"比值") == 0 {
|
||
resTotalNew[k+"比值"] = "0"
|
||
}
|
||
} else {
|
||
resTotalNew[k+"比值"] = "暂无"
|
||
resTotalNew[k] = "暂无"
|
||
}
|
||
|
||
}
|
||
|
||
return resTotalNew
|
||
}
|
||
|
||
//6+3+n及首页数据分析
|
||
func totalAnalyse(datas []Map) (Map, Map, Map, Map) {
|
||
resTotal := Map{
|
||
//经济效益
|
||
"区域生产总值": "暂无",
|
||
"区域企业总数": len(datas),
|
||
|
||
"梯度培育企业数": "暂无",
|
||
|
||
"上市企业数": "暂无",
|
||
"征地企业数/租赁企业数": "暂无",
|
||
"征地企业总面积": "暂无",
|
||
"租赁企业总面积": "暂无",
|
||
"厂房总面积": "暂无",
|
||
|
||
"楼宇总面积": "暂无",
|
||
"办公楼总面积": "暂无",
|
||
"研发楼总面积": "暂无",
|
||
|
||
"区域综合用电": "暂无",
|
||
"区域综合用水": "暂无",
|
||
|
||
"研究生及以上学历人数": "暂无",
|
||
"本科学历人数": "暂无",
|
||
"大专学历人数": "暂无",
|
||
|
||
"大专以下学历人数": "暂无",
|
||
"区域职工平均年收入": "暂无",
|
||
|
||
"技术证书持有人数": "暂无",
|
||
|
||
"拥有环境管理体系数": "暂无",
|
||
"拥有职业健康体系数": "暂无",
|
||
|
||
"属于本区重点企业配套数": "无",
|
||
"宿舍总面积": "无",
|
||
}
|
||
|
||
sixItem := Map{} //6
|
||
threeItem := Map{} //3
|
||
nItem := Map{} //N
|
||
for _, v := range datas {
|
||
analyse := v.GetMap("analyse")
|
||
upload_data := v.GetMap("upload_data")
|
||
|
||
resTotal["区域经营收入"] = resTotal.GetFloat64("区域经营收入") + upload_data.GetFloat64("IEDC2NYYSR")
|
||
resTotal["区域纳税总值"] = resTotal.GetFloat64("区域纳税总值") + upload_data.GetFloat64("IEDCYNSJ")
|
||
resTotal["区域资产总额"] = resTotal.GetFloat64("区域资产总额") + upload_data.GetFloat64("IEDCZCZE")
|
||
|
||
if upload_data.GetString("IEDC“DJS”QY") != "" && upload_data.GetString("IEDC“DJS”QY") != "无" {
|
||
resTotal["独角兽企业数"] = resTotal.GetInt("独角兽企业数") + 1
|
||
}
|
||
if upload_data.GetString("IEDC“DL”QY") != "" && upload_data.GetString("IEDC“DL”QY") != "无" {
|
||
resTotal["瞪羚企业数"] = resTotal.GetInt("瞪羚企业数") + 1
|
||
}
|
||
|
||
//专精特新企业数
|
||
if analyse.GetInt("ZJTXQLDF") >= 6 {
|
||
resTotal["专精特新企业数"] = resTotal.GetInt("专精特新企业数") + 1
|
||
}
|
||
|
||
//规上企业数
|
||
if v.GetInt("gs") == 1 {
|
||
resTotal["规上企业数"] = resTotal.GetInt("规上企业数") + 1
|
||
}
|
||
|
||
if upload_data.GetString("IEDCJPJSSJGZ") != "" && upload_data.GetString("IEDCJPJSSJGZ") != "无" {
|
||
resTotal["技术改造投资备案数"] = resTotal.GetInt("技术改造投资备案数") + 1
|
||
}
|
||
|
||
if upload_data.GetFloat64("IEDCXZTZQK") > 0 {
|
||
resTotal["固定资产投入数"] = resTotal.GetInt("固定资产投入数") + 1
|
||
}
|
||
|
||
//技术中心
|
||
if (upload_data.GetString("IEDCGJJQYJSZX") != "" && upload_data.GetString("IEDCGJJQYJSZX") != "无") || //国家级
|
||
(upload_data.GetString("IEDCSJQYJSZX") != "" && upload_data.GetString("IEDCSJQYJSZX") != "无") || //省级
|
||
(upload_data.GetString("IEDCSJQYJSZX0") != "" && upload_data.GetString("IEDCSJQYJSZX0") != "无") {
|
||
resTotal["企业技术中心数"] = resTotal.GetInt("企业技术中心数") + 1
|
||
}
|
||
//工程技术中心
|
||
if (upload_data.GetString("IEDCSJGCJSZX0") != "" && upload_data.GetString("IEDCSJQYJSZX") != "无") ||
|
||
(upload_data.GetString("IEDCGJJGCJSZX") != "" && upload_data.GetString("IEDCGJJGCJSZX") != "无") || //国家级
|
||
(upload_data.GetString("IEDCSJGCJSZX") != "" && upload_data.GetString("IEDCSJGCJSZX") != "无") { //省级
|
||
|
||
resTotal["工程技术中心数"] = resTotal.GetInt("工程技术中心数") + 1
|
||
}
|
||
|
||
//技术中心
|
||
if (upload_data.GetString("IEDCGJJQYJSZX") != "" && upload_data.GetString("IEDCGJJQYJSZX") != "无") || //国家级
|
||
(upload_data.GetString("IEDCSJQYJSZX") != "" && upload_data.GetString("IEDCSJQYJSZX") != "无") || //省级
|
||
(upload_data.GetString("IEDCSJQYJSZX0") != "" && upload_data.GetString("IEDCSJQYJSZX0") != "无") ||
|
||
(upload_data.GetString("IEDCSJGCJSZX0") != "" && upload_data.GetString("IEDCSJQYJSZX") != "无") ||
|
||
(upload_data.GetString("IEDCGJJGCJSZX") != "" && upload_data.GetString("IEDCGJJGCJSZX") != "无") || //国家级
|
||
(upload_data.GetString("IEDCSJGCJSZX") != "" && upload_data.GetString("IEDCSJGCJSZX") != "无") { //省级
|
||
|
||
threeItem["投建企业技术中心/工程技术中心企业数"] = resTotal.GetInt("投建企业技术中心/工程技术中心企业数") + 1
|
||
}
|
||
|
||
if upload_data.GetString("IEDCGXJSQY") != "" && upload_data.GetString("IEDCGXJSQY") != "否" {
|
||
resTotal["高新技术企业数"] = resTotal.GetInt("高新技术企业数") + 1
|
||
threeItem["高新技术企业数"] = threeItem.GetInt("高新技术企业数") + 1
|
||
}
|
||
|
||
if upload_data.GetString("IEDCQYCPJRBDQMYCPMLQY") != "" && upload_data.GetString("IEDCQYCPJRBDQMYCPMLQY") != "无" {
|
||
resTotal["知名品牌数"] = resTotal.GetInt("知名品牌数") + 1
|
||
}
|
||
|
||
if upload_data.GetString("IEDCST(T)SPC、SBCQY") != "" && upload_data.GetString("IEDCST(T)SPC、SBCQY") != "无" {
|
||
resTotal["首台套/首批次/首版次数"] = resTotal.GetInt("首台套/首批次/首版次数") + 1
|
||
threeItem["首台套/首批次/首版次数"] = threeItem.GetInt("首台套/首批次/首版次数") + 1
|
||
}
|
||
|
||
if upload_data.GetInt("IEDCSYXXZL") != 0 ||
|
||
upload_data.GetInt("IEDCFMZL") != 0 ||
|
||
upload_data.GetInt("IEDCPGJZL") != 0 {
|
||
|
||
threeItem["发明专利/实用新型专利/PCT国际专利企业数"] = threeItem.GetInt("发明专利/实用新型专利/PCT国际专利企业数") + 1
|
||
}
|
||
|
||
resTotal["知识产权数"] = resTotal.GetInt("知识产权数") + upload_data.GetInt("IEDCPGJZL") +
|
||
upload_data.GetInt("IEDCFMZL") + upload_data.GetInt("IEDCSYXXZL") +
|
||
upload_data.GetInt("IEDCWGSJZL")
|
||
|
||
resTotal["区域工业土地总面积"] = resTotal.GetFloat64("区域工业土地总面积") + upload_data.GetFloat64("IEDCYDMJ")
|
||
|
||
resTotal["区域综合用煤"] = resTotal.GetFloat64("区域综合用煤") + upload_data.GetFloat64("IEDCZHNH")
|
||
|
||
resTotal["区域总人数"] = resTotal.GetInt("区域总人数") + upload_data.GetInt("IEDCSBRS")
|
||
|
||
resTotal["产业人才数"] = resTotal.GetInt("产业人才数") + upload_data.GetInt("IEDCCYRC")
|
||
|
||
if upload_data.GetString("IEDCJPJSSJGZ") != "" && upload_data.GetString("IEDCJPJSSJGZ") != "无" {
|
||
resTotal["实施减排升级改造数"] = resTotal.GetInt("实施减排升级改造数") + 1
|
||
threeItem["减排技术升级改造企业数"] = threeItem.GetInt("减排技术升级改造企业数") + 1
|
||
}
|
||
|
||
if upload_data.GetString("IEDCHBJC、HBCCZBFXWT") != "" && upload_data.GetString("IEDCHBJC、HBCCZBFXWT") != "无" {
|
||
resTotal["环保抽查处理数"] = resTotal.GetInt("环保抽查处理数") + 1
|
||
}
|
||
|
||
if upload_data.GetString("IEDCFXAQFXYH") != "" && upload_data.GetString("IEDCFXAQFXYH") != "无" {
|
||
resTotal["安全抽查隐患处理数"] = resTotal.GetInt("安全抽查隐患处理数") + 1
|
||
}
|
||
|
||
if upload_data.GetString("IEDCFSAQSG") != "" && upload_data.GetString("IEDCFSAQSG") != "无" {
|
||
resTotal["亡人事故数"] = resTotal.GetInt("亡人事故数") + 1
|
||
}
|
||
|
||
if upload_data.GetString("IEDCFXYHSYKTXJS") != "" && upload_data.GetString("IEDCFXYHSYKTXJS") != "无" {
|
||
resTotal["拥有安全管理体系数"] = resTotal.GetInt("拥有安全管理体系数") + 1
|
||
}
|
||
|
||
if upload_data.GetString("IEDCQYSCBZHJS") == "达标" {
|
||
resTotal["拥有质量管理体系数"] = resTotal.GetInt("拥有质量管理体系数") + 1
|
||
}
|
||
|
||
if upload_data.GetString("IEDCSJ1HZDQY、Q(S)XZDQY") != "" && upload_data.GetString("IEDCSJ1HZDQY、Q(S)XZDQY") != "否" {
|
||
resTotal["区域100户重点企业数"] = resTotal.GetInt("区域100户重点企业数") + 1
|
||
}
|
||
|
||
if upload_data.GetString("IEDCFHDQZDCY") != "" && upload_data.GetString("IEDCFHDQZDCY") != "否" {
|
||
resTotal["符合本区重点发展产业数"] = resTotal.GetInt("符合本区重点发展产业数") + 1
|
||
}
|
||
|
||
if upload_data.GetString("IEDCJBZJTXHJJTJ") != "" && upload_data.GetString("IEDCJBZJTXHJJTJ") != "否" {
|
||
resTotal["属于本区重点企业配套数"] = resTotal.GetInt("属于本区重点企业配套数") + 1
|
||
}
|
||
resTotal["企业社保人数"] = resTotal.GetFloat64("企业社保人数") + upload_data.GetFloat64("IEDCSBRS")
|
||
resTotal["企业研发费用"] = resTotal.GetFloat64("企业研发费用") + upload_data.GetFloat64("IEDCNYFFY")
|
||
|
||
if upload_data.GetFloat64("IEDCNYFFY") > 1000 {
|
||
threeItem["研发经费投入>1000万元企业数"] = resTotal.GetInt("研发经费投入>1000万元企业数") + 1
|
||
}
|
||
|
||
resTotal["企业总能耗"] = resTotal.GetFloat64("企业总能耗") + upload_data.GetFloat64("IEDCZHNH")
|
||
resTotal["企业主要污染物排放量"] = resTotal.GetFloat64("企业主要污染物排放量") + upload_data.GetFloat64("IEDCZYWRWPFDL")
|
||
|
||
run := func(level string) {
|
||
resTotal[level+"类企业数"] = resTotal.GetInt(level+"类企业数") + 1
|
||
resTotal[level+"类企业数总分"] = resTotal.GetFloat64(level+"类企业数总分") + v.GetFloat64("score")
|
||
if v.GetFloat64("score") > resTotal.GetFloat64(level+"类企业数最高分") {
|
||
resTotal[level+"类企业数最高分"] = v.GetFloat64("score")
|
||
}
|
||
if v.GetFloat64("score") < resTotal.GetFloat64(level+"类企业数最低分") ||
|
||
resTotal.GetFloat64(level+"类企业数最低分") == 0 {
|
||
resTotal[level+"类企业数最低分"] = v.GetFloat64("score")
|
||
}
|
||
//6
|
||
resTotal[level+"类企业营业收入"] = resTotal.GetFloat64(level+"类企业营业收入") + upload_data.GetFloat64("IEDC2NYYSR")
|
||
resTotal[level+"类企业税收"] = resTotal.GetFloat64(level+"类企业税收") + upload_data.GetFloat64("IEDCYNSJ")
|
||
resTotal[level+"类企业占地面积"] = resTotal.GetFloat64(level+"类企业占地面积") + upload_data.GetFloat64("IEDCYDMJ")
|
||
resTotal[level+"类企业社保人数"] = resTotal.GetInt(level+"类企业社保人数") + upload_data.GetInt("IEDCSBRS")
|
||
resTotal[level+"类企业研发费用"] = resTotal.GetFloat64(level+"类企业研发费用") + upload_data.GetFloat64("IEDCNYFFY")
|
||
resTotal[level+"类企业总能耗"] = resTotal.GetFloat64(level+"类企业总能耗") + upload_data.GetFloat64("IEDCZHNH")
|
||
resTotal[level+"类企业主要污染物排放量"] = resTotal.GetFloat64(level+"类企业主要污染物排放量") + upload_data.GetFloat64("IEDCZYWRWPFDL")
|
||
}
|
||
switch v.GetCeilInt("level") {
|
||
case 0:
|
||
run("A")
|
||
case 1:
|
||
run("B")
|
||
case 2:
|
||
run("C")
|
||
case 3:
|
||
run("D")
|
||
}
|
||
//3
|
||
if upload_data.GetString("IEDCQYCPJRBDQMYCPMLQY") != "" && upload_data.GetString("IEDCQYCPJRBDQMYCPMLQY") != "无" {
|
||
threeItem["进入本地区名优产品目录企业数"] = threeItem.GetInt("进入本地区名优产品目录企业数") + 1
|
||
}
|
||
if analyse.GetInt("LXSNYLDF") == 1 {
|
||
threeItem["连续3年盈利/首年度盈利企业数"] = threeItem.GetInt("连续3年盈利/首年度盈利企业数") + 1
|
||
}
|
||
|
||
if upload_data.GetString("IEDCHBJC、HBCCZBFXWT") == "一般" {
|
||
threeItem["环保检/抽查受一般性处理企业数"] = threeItem.GetInt("环保检/抽查受一般性处理企业数") + 1
|
||
}
|
||
|
||
if upload_data.GetString("IEDCFXAQFXYH") == "一般" {
|
||
threeItem["安全检/抽查存在风险隐患受一般性处理企业数"] = threeItem.GetInt("安全检/抽查存在风险隐患受一般性处理企业数") + 1
|
||
}
|
||
if upload_data.GetString("IEDCFSAQSG") != "无" {
|
||
threeItem["安全事故发生企业数"] = threeItem.GetInt("安全事故发生企业数") + 1
|
||
}
|
||
if upload_data.GetString("IEDCFXYHSYKTXJS") != "无" {
|
||
threeItem["已建/在建风险隐患双预控体系企业数"] = threeItem.GetInt("已建/在建风险隐患双预控体系企业数") + 1
|
||
}
|
||
if upload_data.GetString("IEDCFXYHSYKTXJS") == "未达标" {
|
||
threeItem["生产标准不达标企业数"] = threeItem.GetInt("生产标准不达标企业数") + 1
|
||
}
|
||
if upload_data.GetString("IEDCFHDQZDCY") != "" && upload_data.GetString("IEDCFHDQZDCY") != "否" {
|
||
threeItem["所处产业符合本地区重点发展产业企业数"] = threeItem.GetInt("所处产业符合本地区重点发展产业企业数") + 1
|
||
}
|
||
|
||
if upload_data.GetString("IEDCCYLLZ、SJZD、SJ3HLTQY") != "" && upload_data.GetString("IEDCCYLLZ、SJZD、SJ3HLTQY") != "否" {
|
||
threeItem["产业链链主/省级重点/市级30户龙头企业数"] = threeItem.GetInt("产业链链主/省级重点/市级30户龙头企业数") + 1
|
||
}
|
||
if upload_data.GetString("IEDCCYLLZ、SJZD、SJ3HLTQY") != "" && upload_data.GetString("IEDCCYLLZ、SJZD、SJ3HLTQY") != "否" {
|
||
threeItem["市级100户重点/区市县重点企业数"] = threeItem.GetInt("IEDCSJ1HZDQY、Q(S)XZDQY") + 1
|
||
}
|
||
|
||
//N
|
||
if upload_data.GetInt("IEDCCYRC") > 0 {
|
||
nItem["配备年薪≥30万元人才企业数"] = nItem.GetInt("配备年薪≥30万元人才企业数") + 1
|
||
}
|
||
if upload_data.GetString("IEDCJBZJTXZSCQYQ") != "" && upload_data.GetString("IEDCJBZJTXZSCQYQ") != "否" {
|
||
nItem["有效发明专利≥2项/满足参与制定标准企业数"] = nItem.GetInt("有效发明专利≥2项/满足参与制定标准企业数") + 1
|
||
}
|
||
if upload_data.GetString("IEDCJBZJTXHJJTJ") != "" && upload_data.GetString("IEDCJBZJTXHJJTJ") != "否" {
|
||
nItem["具备技术创新任务设备/环境企业数"] = nItem.GetInt("具备技术创新任务设备/环境企业数") + 1
|
||
}
|
||
if upload_data.GetString("IEDCJBZJTXQYJCYQ") != "" && upload_data.GetString("IEDCJBZJTXQYJCYQ") != "否" {
|
||
nItem["特定细分≥3年且主导产品≥营收60%企业数"] = nItem.GetInt("特定细分≥3年且主导产品≥营收60%企业数") + 1
|
||
}
|
||
if upload_data.GetString("IEDCJBZJTXQYYQCP") != "" && upload_data.GetString("IEDCJBZJTXQYYQCP") != "否" {
|
||
nItem["大专/中级职称占比≥35%企业数"] = nItem.GetInt("大专/中级职称占比≥35%企业数") + 1
|
||
}
|
||
if upload_data.GetString("IEDCJBZJTXHJJTJ") != "" && upload_data.GetString("IEDCJBZJTXHJJTJ") != "否" {
|
||
nItem["进行技术改造企业数"] = nItem.GetInt("进行技术改造企业数") + 1
|
||
}
|
||
|
||
}
|
||
|
||
sixItem["亩均收入"] = resTotal.GetFloat64("区域经营收入") / resTotal.GetFloat64("区域工业土地总面积")
|
||
sixItem["亩均税收"] = resTotal.GetFloat64("区域纳税总值") / resTotal.GetFloat64("区域工业土地总面积")
|
||
sixItem["人均收入"] = resTotal.GetFloat64("区域经营收入") / resTotal.GetFloat64("企业社保人数")
|
||
sixItem["研发经费投入强度"] = resTotal.GetFloat64("企业研发费用") / resTotal.GetFloat64("区域经营收入")
|
||
sixItem["单位能耗税收"] = resTotal.GetFloat64("区域纳税总值") / resTotal.GetFloat64("企业总能耗")
|
||
sixItem["主要污染物税收"] = resTotal.GetFloat64("区域纳税总值") / resTotal.GetFloat64("企业主要污染物排放量")
|
||
|
||
run1 := func(level string) {
|
||
resTotal[level+"类企业数平均分"] = resTotal.GetFloat64(level+"类企业数总分") / resTotal.GetFloat64(level+"类企业数")
|
||
sixItem[level+"类亩均收入"] = resTotal.GetFloat64(level+"类企业营业收入") / resTotal.GetFloat64(level+"类企业占地面积")
|
||
sixItem[level+"类亩均税收"] = resTotal.GetFloat64(level+"类企业税收") / resTotal.GetFloat64(level+"类企业占地面积")
|
||
sixItem[level+"类人均收入"] = resTotal.GetFloat64(level+"类企业营业收入") / resTotal.GetFloat64(level+"类企业社保人数")
|
||
sixItem[level+"类研发经费投入强度"] = resTotal.GetFloat64(level+"类企业研发费用") / resTotal.GetFloat64(level+"类企业营业收入")
|
||
sixItem[level+"类单位能耗税收"] = resTotal.GetFloat64(level+"类企业税收") / resTotal.GetFloat64(level+"类企业总能耗")
|
||
if resTotal.GetFloat64(level+"类企业主要污染物排放量") == 0 {
|
||
fmt.Println(level, resTotal[level+"类企业主要污染物排放量"], resTotal.GetFloat64(level+"类企业主要污染物排放量"))
|
||
resTotal[level+"类企业主要污染物排放量"] = 1
|
||
}
|
||
sixItem[level+"类主要污染物税收"] = resTotal.GetFloat64(level+"类企业税收") / resTotal.GetFloat64(level+"类企业主要污染物排放量")
|
||
}
|
||
|
||
run1("A")
|
||
run1("B")
|
||
run1("C")
|
||
run1("D")
|
||
|
||
return resTotal, sixItem, threeItem, nItem
|
||
}
|
||
|
||
//单个企业分析
|
||
func analyseSort(datas []Map) []Map {
|
||
cs := append(Companys{}, datas...)
|
||
|
||
sort6Get := func(指标名称 string, 指标得分名称 string, cs Companys, point float64) Companys {
|
||
csLength := len(cs)
|
||
analyseSortType = 指标名称 //亩均收入得分
|
||
sort.Sort(cs)
|
||
|
||
for k, data := range cs {
|
||
v := data.GetMap("analyse")
|
||
if ObjToFloat64(k) <= ObjToFloat64(csLength)*0.1 {
|
||
v[指标得分名称] = point * 1.0
|
||
} else if ObjToFloat64(k) <= ObjToFloat64(csLength)*0.3 {
|
||
v[指标得分名称] = point * 0.85
|
||
} else if ObjToFloat64(k) <= ObjToFloat64(csLength)*0.5 {
|
||
v[指标得分名称] = point * 0.75
|
||
} else if ObjToFloat64(k) <= ObjToFloat64(csLength)*0.7 {
|
||
v[指标得分名称] = point * 0.6
|
||
} else if ObjToFloat64(k) <= ObjToFloat64(csLength)*0.9 {
|
||
v[指标得分名称] = point * 0.5
|
||
} else {
|
||
v[指标得分名称] = point * 0.25
|
||
}
|
||
if v.GetFloat64(指标名称) == 0 {
|
||
v[指标得分名称] = point * 0
|
||
}
|
||
|
||
//6项指标得分
|
||
if 指标名称 == "ZYWRWSS" {
|
||
v["NXZBDF"] = v.GetFloat64("MJSRDF") + v.GetFloat64("MJSSDF") +
|
||
v.GetFloat64("RJSRDF") + v.GetFloat64("YFJFTRQDDF") +
|
||
v.GetFloat64("DWNHSSDF") + v.GetFloat64("ZYWRWSSDF")
|
||
}
|
||
}
|
||
return cs
|
||
}
|
||
|
||
sort6Get("MJSR", "MJSRDF", cs, 15)
|
||
sort6Get("MJSS", "MJSSDF", cs, 15)
|
||
sort6Get("RJSR", "RJSRDF", cs, 10)
|
||
sort6Get("YFJFTRQD", "YFJFTRQDDF", cs, 10)
|
||
sort6Get("DWNHSS", "DWNHSSDF", cs, 5)
|
||
sort6Get("ZYWRWSS", "ZYWRWSSDF", cs, 5)
|
||
|
||
csLength := len(cs)
|
||
analyseSortType = "IEDCXZTZQK" //技改投资
|
||
sort.Sort(cs)
|
||
|
||
for k, data := range cs {
|
||
v := data.GetMap("analyse")
|
||
if ObjToFloat64(k) <= ObjToFloat64(csLength)*0.3 {
|
||
v["JGTZDF"] = 5
|
||
} else if ObjToFloat64(k) <= ObjToFloat64(csLength)*0.6 {
|
||
v["JGTZDF"] = 4
|
||
} else {
|
||
v["JGTZDF"] = 2
|
||
}
|
||
if v.GetFloat64("JGTZ") == 0 {
|
||
v["JGTZDF"] = 2
|
||
}
|
||
//N总得分以及所有项总分,以及企业评级
|
||
v["NZDF"] = v.GetFloat64("JGTZDF") + v.GetFloat64("ZJTXQLDF") + v.GetFloat64("CYRCDF")
|
||
|
||
v["ZDF"] = v.GetFloat64("NZDF") + v.GetFloat64("SXZBDF") + v.GetFloat64("NXZBDF")
|
||
}
|
||
|
||
analyseSortType = "ZDF" //技改投资
|
||
sort.Sort(cs)
|
||
|
||
for k, data := range cs {
|
||
v := data.GetMap("analyse")
|
||
if ObjToFloat64(k) <= ObjToFloat64(csLength)*0.1 {
|
||
v["PJ"] = "A"
|
||
} else if ObjToFloat64(k) <= ObjToFloat64(csLength)*0.8 {
|
||
v["PJ"] = "B"
|
||
} else if ObjToFloat64(k) <= ObjToFloat64(csLength)*0.98 {
|
||
v["PJ"] = "C"
|
||
} else {
|
||
v["PJ"] = "D"
|
||
}
|
||
}
|
||
|
||
return cs
|
||
}
|
||
|
||
type Companys []Map
|
||
|
||
var analyseSortType = ""
|
||
|
||
func (s Companys) Len() int {
|
||
return len(s)
|
||
}
|
||
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)
|
||
}
|
||
|
||
func decodeData2Sql(table [][]string, this *Context) error {
|
||
tags := []Map{} //报错所有的tag记录
|
||
tagCtgs := []Map{}
|
||
for k, v := range table {
|
||
|
||
//第一排是指标分类,去除掉第一个参数,其存在合并所以,如果是合并的则删除
|
||
if k == 0 {
|
||
|
||
for ck, cv := range v {
|
||
cv = strings.Replace(cv, " ", "", -1)
|
||
cv = strings.Replace(cv, "\r\t", "", -1)
|
||
cv = strings.Replace(cv, "\r", "", -1)
|
||
v[ck] = cv
|
||
|
||
if ck == 0 {
|
||
continue
|
||
}
|
||
if cv == "" {
|
||
v[ck] = v[ck-1]
|
||
cv = v[ck]
|
||
}
|
||
|
||
tagCtg := this.Db.Get("tag_ctg", "*", Map{"name": cv})
|
||
if tagCtg != nil {
|
||
tagCtgs = append(tagCtgs, tagCtg)
|
||
continue
|
||
}
|
||
tagCtg = Map{
|
||
"name": cv,
|
||
"admin_id": this.Session("admin_id").ToInt(),
|
||
"create_time": time.Now().Unix(),
|
||
"modify_time": time.Now().Unix(),
|
||
}
|
||
id := this.Db.Insert("tag_ctg", tagCtg)
|
||
|
||
if id != 0 {
|
||
tagCtg["id"] = id
|
||
this.Db.Update("tag_ctg", Map{
|
||
"index": "," + ObjToStr(id) + ",",
|
||
}, Map{"id": id})
|
||
|
||
tagCtgs = append(tagCtgs, tagCtg)
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
|
||
//第二排是指标项,去除掉第一个参数,
|
||
//最重要的是参数tag生成,通过中文转拼音获取首字母实现,遇到同名的则最后加一位数字
|
||
if k == 1 {
|
||
|
||
for ck, cv := range v {
|
||
cv = strings.Replace(cv, " ", "", -1)
|
||
cv = strings.Replace(cv, "\r\t", "", -1)
|
||
cv = strings.Replace(cv, "\r", "", -1)
|
||
v[ck] = cv
|
||
if ck == 0 {
|
||
continue
|
||
}
|
||
//补充分类
|
||
if ck >= len(table[0]) {
|
||
tagCtgs = append(tagCtgs, tagCtgs[len(tagCtgs)-1])
|
||
}
|
||
//补充说明
|
||
if ck >= len(table[3]) {
|
||
table[3] = append(table[3], table[3][len(table[3])-1])
|
||
}
|
||
//补充单位
|
||
if ck >= len(table[2]) {
|
||
table[2] = append(table[2], "")
|
||
}
|
||
|
||
tag := this.Db.Get("tag", "*", Map{"name": cv})
|
||
|
||
if tag != nil {
|
||
tags = append(tags, tag)
|
||
continue
|
||
}
|
||
sn, err := pinyin.New(cv).Split(" ").Mode(pinyin.InitialsInCapitals).Convert()
|
||
if err != nil {
|
||
fmt.Println(err)
|
||
sn = cv
|
||
} else {
|
||
|
||
sns := strings.Split(sn, " ")
|
||
|
||
sn = "IEDC"
|
||
for _, v1 := range sns {
|
||
if v1 != "" {
|
||
sn = sn + string([]rune(v1)[:1])
|
||
fmt.Println(sn, v1)
|
||
}
|
||
}
|
||
}
|
||
//sn=strings.Replace(sn,"\ufffd","",-1)
|
||
|
||
tagsn := this.Db.Get("tag", "id", Map{"sn": sn})
|
||
if tagsn != nil {
|
||
for i := 0; i < 100; i++ {
|
||
tagsn = this.Db.Get("tag", "id", Map{"sn": sn + ObjToStr(i)})
|
||
if tagsn == nil {
|
||
sn = sn + ObjToStr(i)
|
||
break
|
||
}
|
||
}
|
||
}
|
||
|
||
tag = Map{
|
||
"name": cv,
|
||
"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"),
|
||
"create_time": time.Now().Unix(),
|
||
"modify_time": time.Now().Unix(),
|
||
}
|
||
id := this.Db.Insert("tag", tag)
|
||
tag["id"] = id
|
||
tags = append(tags, tag)
|
||
}
|
||
|
||
}
|
||
|
||
//第四排以后是数据项,去除掉第一个参数,
|
||
//根据统一社会信用代码识别是否存在,同时将校验部分数字
|
||
if k > 3 {
|
||
|
||
//整行数据
|
||
rowData := Map{}
|
||
for ck, cv := range v {
|
||
if ck == 0 {
|
||
continue
|
||
}
|
||
cv = strings.Replace(cv, " ", "", -1)
|
||
cv = strings.Replace(cv, "\r\t", "", -1)
|
||
cv = strings.Replace(cv, "\r", "", -1)
|
||
v[ck] = cv
|
||
if cv == "" {
|
||
return errors.New("第" + ObjToStr(k+1) + "行," + ObjToStr(ck+1) + "列,数据为空请注意检查")
|
||
}
|
||
|
||
rowData[tags[ck-1].GetString("sn")] = cv
|
||
}
|
||
|
||
companyData := Map{
|
||
"name": rowData["IEDCQYMC"],
|
||
"sn": rowData["IEDCTYSHXYDM"],
|
||
"address": rowData["IEDCQYDZ"],
|
||
"unit": rowData["IEDCSDMC"],
|
||
"zdmj": rowData["IEDCYDMJ"],
|
||
"yysr": rowData["IEDC2NYYSR"],
|
||
"lrze": rowData["IEDC2NLRZE"],
|
||
"yjsj": rowData["IEDCYNSJ"],
|
||
"yfjf": rowData["IEDCNYFFY"],
|
||
"zgrs": rowData["IEDCSBRS"],
|
||
"zywrwpfdl": rowData["IEDCZYWRWPFDL"],
|
||
"zhnh": rowData["IEDCZHNH"],
|
||
"admin_id": this.Session("admin_id").ToInt(),
|
||
"upload_data": rowData.ToJsonString(),
|
||
//"create_time": time.Now().Unix(),
|
||
"modify_time": time.Now().Unix(),
|
||
//"lat": lat,
|
||
//"lng": lng,
|
||
}
|
||
|
||
baiduDataStr, _ := baidu.DefaultBaiDuMap.GetPosition(companyData.GetString("address"))
|
||
baiduData := ObjToMap(baiduDataStr)
|
||
|
||
city := Map{}
|
||
if baiduData != nil && baiduData.GetCeilInt("status") == 0 {
|
||
address := baiduData.GetSlice("result")
|
||
if len(address) != 0 {
|
||
companyData["lat"] = address.GetMap(0).GetMap("location").GetFloat64("lat")
|
||
companyData["lng"] = address.GetMap(0).GetMap("location").GetFloat64("lng")
|
||
|
||
city = this.Db.Get("city", "id", Map{"name[~]": address.GetMap(0).GetString("district"), "ORDER": "`level` DESC"})
|
||
if city == nil {
|
||
city = this.Db.Get("city", "id", Map{"name[~]": address.GetMap(0).GetString("city"), "ORDER": "`level` DESC"})
|
||
}
|
||
}
|
||
}
|
||
|
||
if city != nil {
|
||
companyData["city_id"] = city.GetCeilInt("id")
|
||
}
|
||
|
||
//行业ID
|
||
category := this.Db.Get("category", "id", Map{"code": rowData["IEDCSSXYXLDM"]})
|
||
if category != nil {
|
||
companyData["category_id"] = category.GetCeilInt("id")
|
||
}
|
||
|
||
//此处需要优化
|
||
companyData["org_id"] = 3
|
||
|
||
company := this.Db.Get("company", "id", Map{"sn": companyData["sn"]})
|
||
//没有则创建
|
||
if company == nil {
|
||
//更新两张表
|
||
companyData["create_time"] = time.Now().Unix()
|
||
id := this.Db.Insert("company", companyData)
|
||
companyData["company_id"] = id
|
||
} else {
|
||
//有则更新
|
||
this.Db.Update("company", companyData, Map{"sn": companyData["sn"]})
|
||
companyData["company_id"] = company.GetCeilInt("id")
|
||
companyData["create_time"] = time.Now().Unix()
|
||
}
|
||
|
||
id := this.Db.Insert("company_history", companyData)
|
||
//更新最新的企业信息
|
||
this.Db.Update("company", Map{"company_history_id": id}, Map{"id": company.GetCeilInt("id")})
|
||
|
||
}
|
||
|
||
}
|
||
return nil
|
||
|
||
}
|
||
|
||
func excel(filePath string) [][][]string {
|
||
xlsx, err := excelize.OpenFile(filePath)
|
||
if err != nil {
|
||
fmt.Println(err)
|
||
os.Exit(1)
|
||
}
|
||
list := xlsx.GetSheetList()
|
||
var data [][][]string
|
||
for _, v := range list {
|
||
rows, e := xlsx.GetRows(v)
|
||
if e != nil {
|
||
fmt.Println(e)
|
||
continue
|
||
}
|
||
data = append(data, rows)
|
||
}
|
||
|
||
return data
|
||
}
|
||
|
||
func analyse(data Map) Map {
|
||
res := Map{}
|
||
//亩均收入
|
||
res["MJSR"] = data.GetFloat64("IEDC2NYYSR") / data.GetFloat64("IEDCYDMJ")
|
||
res["MJSRDF"] = "" //亩均收入得分
|
||
//亩均税收
|
||
res["MJSS"] = data.GetFloat64("IEDCYNSJ") / data.GetFloat64("IEDCYDMJ")
|
||
res["MJSSDF"] = "" //亩均税收得分
|
||
|
||
//人均收入
|
||
res["RJSR"] = data.GetFloat64("IEDC2NYYSR") / data.GetFloat64("IEDCSBRS")
|
||
res["RJSRDF"] = "" //人均收入得分
|
||
|
||
//研发经费投入强度
|
||
res["YFJFTRQD"] = data.GetFloat64("IEDCNYFFY") / data.GetFloat64("IEDC2NYYSR")
|
||
res["YFJFTRQDDF"] = "" //研发经费投入强度得分
|
||
|
||
//单位能耗税收
|
||
res["DWNHSS"] = data.GetFloat64("IEDCYNSJ") / data.GetFloat64("IEDCZHNH")
|
||
res["DWNHSSDF"] = "" //单位能耗税收得分
|
||
|
||
//主要污染物税收
|
||
//不足1按1计算
|
||
if data.GetFloat64("IEDCZYWRWPFDL") < 1 {
|
||
data["IEDCZYWRWPFDL"] = 1
|
||
}
|
||
|
||
res["ZYWRWSS"] = data.GetFloat64("IEDCYNSJ") / data.GetFloat64("IEDCZYWRWPFDL")
|
||
res["ZYWRWSSDF"] = "" //主要污染物税收
|
||
|
||
res["NXZBDF"] = "" //6项指标得分
|
||
|
||
//独角兽、瞪羚企业得分,一个一分
|
||
res["DJSDLQYDF"] = 0
|
||
if data.GetString("IEDC“DJS”QY") != "" && data.GetString("IEDC“DJS”QY") != "无" {
|
||
res["DJSDLQYDF"] = res.GetFloat64("DJSDLQYDF") + 1
|
||
}
|
||
if data.GetString("IEDC“DL”QY") != "" && data.GetString("IEDC“DL”QY") != "无" {
|
||
res["DJSDLQYDF"] = res.GetFloat64("DJSDLQYDF") + 1
|
||
}
|
||
|
||
//企业获得国家级、省级、市级企业技术中心,国家级,省级得1分,市级得0.5
|
||
res["JSZXDF"] = 0
|
||
//国家级及省级
|
||
if (data.GetString("IEDCGJJQYJSZX") != "" && data.GetString("IEDCGJJQYJSZX") != "无") || //国家级
|
||
(data.GetString("IEDCSJQYJSZX") != "" && data.GetString("IEDCSJQYJSZX") != "无") || //省级
|
||
(data.GetString("IEDCGJJGCJSZX") != "" && data.GetString("IEDCGJJGCJSZX") != "无") || //国家级
|
||
(data.GetString("IEDCSJGCJSZX") != "" && data.GetString("IEDCSJGCJSZX") != "无") { //省级
|
||
res["JSZXDF"] = res.GetFloat64("JSZXDF") + 1
|
||
} else
|
||
|
||
//市级
|
||
if (data.GetString("IEDCSJQYJSZX0") != "" && data.GetString("IEDCSJQYJSZX0") != "无") ||
|
||
(data.GetString("IEDCSJGCJSZX0") != "" && data.GetString("IEDCSJQYJSZX") != "无") {
|
||
res["JSZXDF"] = res.GetFloat64("JSZXDF") + 0.5
|
||
}
|
||
|
||
//研发费用得分
|
||
res["YFFYDF"] = 0
|
||
if data.GetString("IEDCTRQD1WHZ3YS") != "" && data.GetString("IEDCTRQD1WHZ3YS") != "否" {
|
||
res["YFFYDF"] = 1
|
||
}
|
||
|
||
//高新技术企业得分
|
||
res["GXJSQYDF"] = 0
|
||
if data.GetString("IEDCGXJSQY") != "" && data.GetString("IEDCGXJSQY") != "否" {
|
||
res["GXJSQYDF"] = 1
|
||
}
|
||
//发展潜力总分
|
||
res["FZQLDF"] = res.GetFloat64("GXJSQYDF") + res.GetFloat64("YFFYDF") +
|
||
res.GetFloat64("JSZXDF") + res.GetFloat64("DJSDLQYDF")
|
||
|
||
//首台(套)、首批次、首版次企业
|
||
res["STTDF"] = 0
|
||
if data.GetString("IEDCST(T)SPC、SBCQY") != "" && data.GetString("IEDCST(T)SPC、SBCQY") != "无" {
|
||
res["STTDF"] = 1
|
||
}
|
||
|
||
//专利得分
|
||
res["ZLDF"] = 0
|
||
|
||
res["ZLDF"] = data.GetFloat64("IEDCPGJZL") +
|
||
data.GetFloat64("IEDCFMZL")*0.5 +
|
||
data.GetFloat64("IEDCSYXXZL")*0.1 +
|
||
data.GetFloat64("IEDCWGSJZL")*0.1
|
||
|
||
if res.GetFloat64("ZLDF") > 1 {
|
||
res["ZLDF"] = 1
|
||
}
|
||
|
||
//推广目录得分
|
||
res["TGMLDF"] = 0
|
||
if data.GetString("IEDCQYCPJRBDQMYCPMLQY") != "" && data.GetString("IEDCQYCPJRBDQMYCPMLQY") != "无" {
|
||
res["TGMLDF"] = 1
|
||
}
|
||
|
||
//知识产权总得分ZSCQDF
|
||
res["ZSCQDF"] = res.GetFloat64("ZLDF") + res.GetFloat64("STTDF") + res.GetFloat64("TGMLDF")
|
||
|
||
//连续3年盈利得分
|
||
res["LXSNYLDF"] = 3
|
||
//18年
|
||
if data.GetFloat64("IEDC1NLRZE") < 0 {
|
||
res["LXSNYLDF"] = res.GetInt("LXSNYLDF") - 1
|
||
}
|
||
//19年
|
||
if data.GetFloat64("IEDC1NLRZE0") < 0 {
|
||
res["LXSNYLDF"] = res.GetInt("LXSNYLDF") - 1
|
||
}
|
||
//20年
|
||
if data.GetFloat64("IEDC2NLRZE") < 0 {
|
||
res["LXSNYLDF"] = res.GetInt("LXSNYLDF") - 1
|
||
}
|
||
|
||
if res.GetInt("LXSNYLDF") == 3 {
|
||
res["LXSNYLDF"] = 1
|
||
} else if res.GetInt("LXSNYLDF") > 0 {
|
||
res["LXSNYLDF"] = 0.5
|
||
}
|
||
|
||
//当年利润总额得分
|
||
res["DNLRZEDF"] = 0
|
||
//企业利润率
|
||
res["QYLRL"] = data.GetFloat64("IEDC2NLRZE") / data.GetFloat64("IEDC2NYYSR")
|
||
if res.GetFloat64("QYLRL") > 0.1 {
|
||
res["DNLRZEDF"] = 1
|
||
} else if res.GetFloat64("QYLRL") > 0 {
|
||
res["DNLRZEDF"] = 0.5
|
||
}
|
||
//企业盈利能力总得分
|
||
res["QYYLNLZDF"] = res.GetFloat64("DNLRZEDF") + res.GetFloat64("LXSNYLDF")
|
||
|
||
//发展质量指标总分
|
||
res["FZZLZBZDF"] = res.GetFloat64("QYYLNLZDF") + res.GetFloat64("ZSCQDF") + res.GetFloat64("FZQLDF")
|
||
|
||
//企业连续3年亏损得分
|
||
res["KSDF"] = 3
|
||
//18年
|
||
if data.GetFloat64("IEDC1NLRZE") < 0 {
|
||
res["KSDF"] = res.GetInt("LXSNYLDF") - 1
|
||
}
|
||
//19年
|
||
if data.GetFloat64("IEDC1NLRZE0") < 0 {
|
||
res["KSDF"] = res.GetInt("LXSNYLDF") - 1
|
||
}
|
||
//20年
|
||
if data.GetFloat64("IEDC2NLRZE") < 0 {
|
||
res["KSDF"] = res.GetInt("LXSNYLDF") - 1
|
||
}
|
||
|
||
//先统一扣0.5分
|
||
if res.GetInt("LXSNYLDF") == 0 {
|
||
res["KSDF"] = 0.5
|
||
} else {
|
||
res["KSDF"] = 0
|
||
}
|
||
|
||
//环保检查得分
|
||
res["HBJCDF"] = 1
|
||
if data.GetString("IEDCHBJC、HBCCZBFXWT") == "一般" {
|
||
res["HBJCDF"] = 0.5
|
||
}
|
||
if data.GetString("IEDCHBJC、HBCCZBFXWT") == "重大" {
|
||
res["HBJCDF"] = 0
|
||
}
|
||
|
||
//减排技术升级改造
|
||
res["JPJSSJDF"] = 0
|
||
if data.GetString("IEDCJPJSSJGZ") != "" && data.GetString("IEDCJPJSSJGZ") != "无" {
|
||
res["JPJSSJDF"] = 1
|
||
}
|
||
|
||
//绿色生产工艺
|
||
res["LSSCGYDF"] = res.GetFloat64("JPJSSJDF") + res.GetFloat64("HBJCDF")
|
||
|
||
//安全检查得分
|
||
res["AQJCDF"] = 0
|
||
|
||
if data.GetString("IEDCFXAQFXYH") == "一般" {
|
||
res["AQJCDF"] = -1
|
||
}
|
||
if data.GetString("IEDCFXAQFXYH") == "重大" {
|
||
res["AQJCDF"] = -2
|
||
}
|
||
//安全事故得分
|
||
res["AQSGDF"] = 0
|
||
|
||
if data.GetString("IEDCFSAQSG") == "轻微" {
|
||
res["AQSGDF"] = -0.5
|
||
}
|
||
if data.GetString("IEDCFSAQSG") == "一般" {
|
||
res["AQSGDF"] = -1
|
||
}
|
||
if data.GetString("IEDCFSAQSG") == "重大" {
|
||
res["AQSGDF"] = -2
|
||
}
|
||
|
||
//企业风险隐患双预控体系建设得分
|
||
res["QYFXYHSKTXJSDF"] = 0
|
||
|
||
if data.GetString("IEDCFXYHSYKTXJS") != "" && data.GetString("IEDCFXYHSYKTXJS") != "无" {
|
||
res["QYFXYHSKTXJSDF"] = 1
|
||
}
|
||
|
||
//企业安全生产是否达标得分
|
||
res["QYAQSCDBDF"] = 0
|
||
|
||
if data.GetString("IEDCQYSCBZHJS") == "达标" {
|
||
res["QYAQSCDBDF"] = 1
|
||
}
|
||
|
||
//安全生产管理得分AQSCGLDF
|
||
res["AQSCGLDF"] = res.GetFloat64("QYAQSCDBDF") + res.GetFloat64("QYFXYHSKTXJSDF") +
|
||
res.GetFloat64("AQSGDF") + res.GetFloat64("AQJCDF")
|
||
|
||
//"绿色安全指标得分",
|
||
res["LSAQZBDF"] = (res.GetFloat64("AQSCGLDF") + res.GetFloat64("LSSCGYDF")) / 4 * 5
|
||
|
||
//产业链30户得分
|
||
res["CYL30HDF"] = 0
|
||
|
||
if data.GetString("IEDCCYLLZ、SJZD、SJ3HLTQY") != "" && data.GetString("IEDCCYLLZ、SJZD、SJ3HLTQY") != "否" {
|
||
res["CYL30HDF"] = 1
|
||
}
|
||
|
||
//市级100户重点企业得分
|
||
res["SJ100HZDQYDF"] = 0
|
||
|
||
if data.GetString("IEDCSJ1HZDQY、Q(S)XZDQY") != "" && data.GetString("IEDCSJ1HZDQY、Q(S)XZDQY") != "否" {
|
||
res["SJ100HZDQYDF"] = 1
|
||
}
|
||
|
||
//区域重点企业得分
|
||
res["QYZDQYDF"] = res.GetFloat64("CYL30HDF") + res.GetFloat64("SJ100HZDQYDF")
|
||
|
||
//符合地区重点产业得分
|
||
res["FHDQZDCYDF"] = 0
|
||
|
||
if data.GetString("IEDCFHDQZDCY") != "" && data.GetString("IEDCFHDQZDCY") != "否" {
|
||
res["FHDQZDCYDF"] = 1
|
||
}
|
||
|
||
//协作发展指标得分XZFZZBDF
|
||
res["XZFZZBDF"] = (res.GetFloat64("FHDQZDCYDF") + res.GetFloat64("QYZDQYDF")) / 3 * 5
|
||
|
||
//3项指标
|
||
res["SXZBDF"] = res.GetFloat64("XZFZZBDF") + res.GetFloat64("LSAQZBDF") + res.GetFloat64("FZZLZBZDF")
|
||
|
||
//产业人才得分
|
||
res["CYRCDF"] = 0
|
||
res["CYRCDF"] = data.GetInt("IEDCCYRC") * 2
|
||
if res.GetInt("CYRCDF") > 5 {
|
||
res["CYRCDF"] = 5
|
||
}
|
||
|
||
//资产负债率得分
|
||
res["ZCFZLDF"] = 0
|
||
IEDCZCFZL := ObjToFloat64(strings.Replace(data.GetString("IEDCZCFZL"), "%", "", -1))
|
||
if IEDCZCFZL <= 80 {
|
||
res["ZCFZLDF"] = 1
|
||
}
|
||
|
||
//科研人员占比得分
|
||
res["KYRYZBDF"] = 0
|
||
KYRYZBDF := ObjToFloat64(strings.Replace(data.GetString("IEDCKYRYZB"), "%", "", -1))
|
||
if KYRYZBDF >= 8 {
|
||
res["KYRYZBDF"] = 1
|
||
}
|
||
|
||
//2年研发占比得分
|
||
res["YFZBDF"] = 0
|
||
YFZBDF := ObjToFloat64(strings.Replace(data.GetString("IEDC2NYFZB"), "%", "", -1))
|
||
if YFZBDF >= 1.5 {
|
||
res["YFZBDF"] = 1
|
||
}
|
||
|
||
//具备专精特新知识产权要求得分
|
||
res["JBZJTXZSCQYQDF"] = 0
|
||
if data.GetString("IEDCJBZJTXZSCQYQ") != "" && data.GetString("IEDCJBZJTXZSCQYQ") != "否" {
|
||
res["JBZJTXZSCQYQDF"] = 1
|
||
}
|
||
|
||
//具备专精特新环境及条件得分
|
||
res["JBZJTXHJJTJDF"] = 0
|
||
if data.GetString("IEDCJBZJTXHJJTJ") != "" && data.GetString("IEDCJBZJTXHJJTJ") != "否" {
|
||
res["JBZJTXHJJTJDF"] = 1
|
||
}
|
||
|
||
//具备专精特新企业要求产品得分
|
||
res["JBZJTXQYYQCPDF"] = 0
|
||
if data.GetString("IEDCJBZJTXQYYQCP") != "" && data.GetString("IEDCJBZJTXQYYQCP") != "否" {
|
||
res["JBZJTXQYYQCPDF"] = 1
|
||
}
|
||
|
||
//具备专精特新企业基础要求得分
|
||
res["JBZJTXQYJCYQDF"] = 0
|
||
if data.GetString("IEDCJBZJTXQYJCYQ") != "" && data.GetString("IEDCJBZJTXQYJCYQ") != "否" {
|
||
res["JBZJTXQYJCYQDF"] = 1
|
||
}
|
||
|
||
ZJTXQLDFTotal := res.GetFloat64("JBZJTXQYJCYQDF") +
|
||
res.GetFloat64("JBZJTXQYYQCPDF") +
|
||
res.GetFloat64("JBZJTXHJJTJDF") +
|
||
res.GetFloat64("JBZJTXZSCQYQDF") +
|
||
res.GetFloat64("YFZBDF") +
|
||
res.GetFloat64("KYRYZBDF") +
|
||
res.GetFloat64("ZCFZLDF")
|
||
res["ZJTXQLDF"] = 0
|
||
if ZJTXQLDFTotal >= 5 {
|
||
res["ZJTXQLDF"] = 10
|
||
} else if ZJTXQLDFTotal >= 3 {
|
||
res["ZJTXQLDF"] = 6
|
||
} else if ZJTXQLDFTotal >= 1 {
|
||
res["ZJTXQLDF"] = 3
|
||
}
|
||
|
||
res["JGTZ"] = data.GetFloat64("IEDCXZTZQK")
|
||
|
||
return res
|
||
}
|