diff --git a/example/admin/companyinout.go b/example/admin/companyinout.go index 7427663..f370ad8 100644 --- a/example/admin/companyinout.go +++ b/example/admin/companyinout.go @@ -10,6 +10,7 @@ import ( "github.com/xuri/excelize" "io" "os" + "sort" "strings" "time" ) @@ -71,6 +72,670 @@ var CompanyInOutCtr = Ctr{ 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, //绿色能源 + 799, //机械制造 + 1021, //建材制造 + 717, //化工类 + 170, //轻工类 + 260, //纺织类 + 1088, //商贸类 + 1424, //投资管理 + 799, //配套类 + 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.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) + } 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("IEDCFHDQZDCY") != "" && upload_data.GetString("IEDCFHDQZDCY") != "否" { + 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 { @@ -201,7 +866,7 @@ func decodeData2Sql(table [][]string, this *Context) error { //第四排以后是数据项,去除掉第一个参数, //根据统一社会信用代码识别是否存在,同时将校验部分数字 - if k > 4 { + if k > 3 { //整行数据 rowData := Map{} @@ -285,7 +950,9 @@ func decodeData2Sql(table [][]string, this *Context) error { companyData["create_time"] = time.Now().Unix() } - this.Db.Insert("company_history", companyData) + id := this.Db.Insert("company_history", companyData) + //更新最新的企业信息 + this.Db.Update("company", Map{"company_history_id": id}, Map{"id": company.GetCeilInt("id")}) } @@ -314,7 +981,7 @@ func excel(filePath string) [][][]string { return data } -func companyAnalyse(data Map) Map { +func analyse(data Map) Map { res := Map{} //亩均收入 res["MJSR"] = data.GetFloat64("IEDC2NYYSR") / data.GetFloat64("IEDCYDMJ") @@ -335,10 +1002,6 @@ func companyAnalyse(data Map) Map { res["DWNHSS"] = data.GetFloat64("IEDCYNSJ") / data.GetFloat64("IEDCZHNH") res["DWNHSSDF"] = "" //单位能耗税收得分 - //主要污染物税收 - res[""] = data.GetFloat64("IEDCYNSJ") / data.GetFloat64("IEDCZHNH") - res["DF"] = "" //单位能耗税收得分 - //主要污染物税收 //不足1按1计算 if data.GetFloat64("IEDCZYWRWPFDL") < 1 { @@ -346,15 +1009,17 @@ func companyAnalyse(data Map) Map { } res["ZYWRWSS"] = data.GetFloat64("IEDCYNSJ") / data.GetFloat64("IEDCZYWRWPFDL") - res["ZYWRWSSDF"] = "" //单位能耗税收得分 + res["ZYWRWSSDF"] = "" //主要污染物税收 + + res["NXZBDF"] = "" //6项指标得分 //独角兽、瞪羚企业得分,一个一分 res["DJSDLQYDF"] = 0 if data.GetString("IEDC“DJS”QY") != "" && data.GetString("IEDC“DJS”QY") != "无" { - res["DJSDLQYDF"] = res.GetCeilInt("DJSDLQYDF") + 1 + res["DJSDLQYDF"] = res.GetFloat64("DJSDLQYDF") + 1 } if data.GetString("IEDC“DL”QY") != "" && data.GetString("IEDC“DL”QY") != "无" { - res["DJSDLQYDF"] = res.GetCeilInt("DJSDLQYDF") + 1 + res["DJSDLQYDF"] = res.GetFloat64("DJSDLQYDF") + 1 } //企业获得国家级、省级、市级企业技术中心,国家级,省级得1分,市级得0.5 @@ -384,6 +1049,9 @@ func companyAnalyse(data Map) Map { 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 @@ -409,6 +1077,9 @@ func companyAnalyse(data Map) Map { res["TGMLDF"] = 1 } + //知识产权总得分ZSCQDF + res["ZSCQDF"] = res.GetFloat64("ZLDF") + res.GetFloat64("STTDF") + res.GetFloat64("TGMLDF") + //连续3年盈利得分 res["LXSNYLDF"] = 3 //18年 @@ -439,6 +1110,11 @@ func companyAnalyse(data Map) Map { } 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 @@ -458,11 +1134,12 @@ func companyAnalyse(data Map) Map { //先统一扣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 } @@ -472,31 +1149,33 @@ func companyAnalyse(data Map) Map { //减排技术升级改造 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["HBJCDF"] = -1 + res["AQJCDF"] = -1 } if data.GetString("IEDCFXAQFXYH") == "重大" { - res["HBJCDF"] = -2 + res["AQJCDF"] = -2 } //安全事故得分 res["AQSGDF"] = 0 if data.GetString("IEDCFSAQSG") == "轻微" { - res["HBJCDF"] = -0.5 + res["AQSGDF"] = -0.5 } if data.GetString("IEDCFSAQSG") == "一般" { - res["HBJCDF"] = -1 + res["AQSGDF"] = -1 } if data.GetString("IEDCFSAQSG") == "重大" { - res["HBJCDF"] = -2 + res["AQSGDF"] = -2 } //企业风险隐患双预控体系建设得分 @@ -513,6 +1192,13 @@ func companyAnalyse(data Map) Map { 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 @@ -520,62 +1206,98 @@ func companyAnalyse(data Map) Map { 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 } - -var ADataType = Map{ - - "CYL30HDF": "产业链30户得分", - - "QYAQSCDBDF": "企业安全生产是否达标得分", - - "QYFXYHSKTXJSDF": "企业风险隐患双预控体系建设得分", - - "AQSGDF": "安全事故得分", - - "AQJCDF": "安全检查得分", - - "JPJSSJDF": "减排技术升级改造得分", - - "HBJCDF": "环保检查得分", - - "KSDF": "企业连续3年亏损得分", - - "QYLRL": "企业利润率", - - "DNLRZEDF": "当年利润总额得分", - - "LXSNYLDF": "连续3年盈利得分", - - "TGMLDF": "推广目录得分", - - "ZLDF": "专利得分", - - "STTDF": "首台(套)、首批次、首版次企业得分", - - "MJSR": "亩均收入", - "MJSRDF": "亩均收入得分", - - "MJSS": "亩均税收", - "MJSSDF": "亩均税收得分", - - "RJSR": "人均收入", - "RJSRDF": "人均收入得分", - - "YFJFTRQD": "研发经费投入强度", - "YFJFTRQDDF": "研发经费投入强度得分", - - "DWNHSS": "单位能耗税收", - "DWNHSSDF": "单位能耗税收得分", - - "ZYWRWSS": "主要污染物税收", - "ZYWRWSSDF": "主要污染物税收得分", - - "DJSDLQYDF": "独角兽、瞪羚企业得分", - - "JSZXDF": "企业获得技术中心得分", - - "YFFYDF": "研发费用得分", - - "GXJSQYDF": "高新技术企业得分", -}